コード例 #1
0
ファイル: TsUtility.cpp プロジェクト: TerraMA2/terrama2
void TsUtility::testTimeUtilsAddYear()
{
  std::string dateTime = "2016-Apr-12 12:59:00.373302BRT+00";

  boost::posix_time::ptime boostDate(boost::posix_time::time_from_string(dateTime));

  boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("+00"));
  boost::local_time::local_date_time date(boostDate.date(), boostDate.time_of_day(), zone, true);

  std::shared_ptr< te::dt::TimeInstantTZ > dt(new te::dt::TimeInstantTZ(date));

  terrama2::core::TimeUtils::addYear(dt, 3);
  terrama2::core::TimeUtils::addYear(dt, -1);

  std::string dateTime2 = "2018-Apr-12 12:59:00.373302BRT+00";

  boost::posix_time::ptime boostDate2(boost::posix_time::time_from_string(dateTime2));

  boost::local_time::time_zone_ptr zone2(new boost::local_time::posix_time_zone("+00"));
  boost::local_time::local_date_time date2(boostDate2.date(), boostDate2.time_of_day(), zone2, true);

  std::shared_ptr< te::dt::TimeInstantTZ > dt2(new te::dt::TimeInstantTZ(date2));

  if(*dt.get() != *dt2.get())
    QFAIL("Should not be here!");
}
コード例 #2
0
int _tmain(int argc, _TCHAR* argv[])
{
	// 2015Äê9ÔÂ7ÈÕ 17:27:18 ²âÊÔstd::map
	video::ZoneUuid zone(0, 1, 2);
	video::ZoneUuid zone2(1, 0, 0);
	//video::DeviceInfo device(NULL, 1);
	//video::DeviceInfo device2(NULL, 0);
	//video::CBindMap map;
	//map[zone] = device;
	//for (const auto& i : map) {
	//	std::cout << i.first.toString() << i.second.toString() << std::endl;
	//}
	//map[zone2] = device2;
	//for (const auto& i : map) {
	//	std::cout << i.first.toString() << i.second.toString() << std::endl;
	//}
	//// end

	Test test;
	int n = sizeof(test);
	Test2 test2;
	n = sizeof(test2);

	ConnID id;
	id = 123;
	PrivateCmd cmd;
	cmd.AppendConnID(id);
	ConnID id2 = cmd.GetConnID();


	system("pause");
	return 0;
}
コード例 #3
0
ファイル: arrow.cpp プロジェクト: AceXIE/xenomai-lab
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
          QWidget *)
{
    qDebug() << "Arrow: paint";

    if (myStartItem->collidesWithItem(myEndItem))
        return;
/*
    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(myColor);


    QLineF centerLine(myStartItem->pos(), myEndItem->pos());
    QPolygonF endPolygon = myEndItem->polygon();
    //p1 = coordinates of first pointer of enditem in
    //scene coordinates
    QPointF p1 = endPolygon.first() + myEndItem->pos();
    QPointF p2;
    QPointF intersectPoint;
    QLineF polyLine;
    //.count()=.size()
    for (int i = 1; i < endPolygon.count(); ++i) {
        p2 = endPolygon.at(i) + myEndItem->pos();
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType =
            polyLine.intersect(centerLine, &intersectPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
            p1 = p2;
    }
    */

    //qreal comp1=intersectPoint.x();
    //qreal comp2;

    //TODO:
    //This is my patch to define input and output points for lines
    //All code above this point is rendered useless and should be removed

    QPointF intersectPoint;
    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(myColor);

    intersectPoint=myEndItem->pos();
    intersectPoint.setX(intersectPoint.x()-myEndItem->boundingRect().width()/2);

    QPointF otherPoint;
    otherPoint=myStartItem->pos();
    otherPoint.setX(otherPoint.x()+myStartItem->boundingRect().width()/2);
    //original
    setLine(QLineF(otherPoint, intersectPoint));

    if(isZone2()){
        zone2(otherPoint);
    }
    else{
        zone1(otherPoint);
    }

    //double angle = ::acos(line().dx() / line().length());
    double angle=Pi;
    if (line().dy() >= 0)
        angle = (Pi * 2) - angle;


    QPointF arrowP1 = line().p2() + QPointF(sin(angle + Pi / 3) * arrowSize,
                                    cos(angle + Pi / 3) * arrowSize);
    QPointF arrowP2 = line().p2() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
                                    cos(angle + Pi - Pi / 3) * arrowSize);

    arrowHead.clear();
    arrowHead << line().p2() << arrowP1 << arrowP2;

    for(int i=0;i<part.size();++i)
        painter->drawLine(*part[i]);

    //setLine(*part[0]);
    //painter->drawLine(line());
    painter->drawPolygon(arrowHead);
    if (isSelected()) {
        painter->setPen(QPen(myColor, 1, Qt::DashLine));

        QLineF myLine = line();
        myLine.translate(0, 4.0);
        painter->drawLine(myLine);
        myLine.translate(0,-8.0);
        painter->drawLine(myLine);
    }

    //qDebug() << "PAINT ORDER FINISH";
}
コード例 #4
0
void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size()
     || faceZones().size()
     || cellZones().size()
     || topoChanger_.size()
    )
    {
        Info<< "void movingConeTopoFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        return;
    }

    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh" << endl;

    const vectorField& fc = faceCentres();
    const vectorField& fa = faceAreas();

    labelList zone1(fc.size());
    boolList flipZone1(fc.size(), false);
    label nZoneFaces1 = 0;

    labelList zone2(fc.size());
    boolList flipZone2(fc.size(), false);
    label nZoneFaces2 = 0;

    forAll(fc, faceI)
    {
        if
        (
            fc[faceI].x() > -0.003501
         && fc[faceI].x() < -0.003499
        )
        {
            if ((fa[faceI] & vector(1, 0, 0)) < 0)
            {
                flipZone1[nZoneFaces1] = true;
            }

            zone1[nZoneFaces1] = faceI;
            Info<< "face " << faceI << " for zone 1.  Flip: "
                << flipZone1[nZoneFaces1] << endl;
            nZoneFaces1++;
        }
        else if
        (
            fc[faceI].x() > -0.00701
         && fc[faceI].x() < -0.00699
        )
        {
            zone2[nZoneFaces2] = faceI;

            if ((fa[faceI] & vector(1, 0, 0)) > 0)
            {
                flipZone2[nZoneFaces2] = true;
            }

            Info<< "face " << faceI << " for zone 2.  Flip: "
                << flipZone2[nZoneFaces2] << endl;
            nZoneFaces2++;
        }
    }

    zone1.setSize(nZoneFaces1);
    flipZone1.setSize(nZoneFaces1);

    zone2.setSize(nZoneFaces2);
    flipZone2.setSize(nZoneFaces2);

    Info<< "zone: " << zone1 << endl;
    Info<< "zone: " << zone2 << endl;

    List<pointZone*> pz(0);
    List<faceZone*> fz(2);
    List<cellZone*> cz(0);

    label nFz = 0;

    fz[nFz] =
        new faceZone
        (
            "rightExtrusionFaces",
            zone1,
            flipZone1,
            nFz,
            faceZones()
        );
    nFz++;

    fz[nFz] =
        new faceZone
        (
            "leftExtrusionFaces",
            zone2,
            flipZone2,
            nFz,
            faceZones()
        );
    nFz++;

    fz.setSize(nFz);

    Info<< "Adding mesh zones." << endl;
    addZones(pz, fz, cz);


    // Add layer addition/removal interfaces

    List<polyMeshModifier*> tm(2);
    label nMods = 0;

    tm[nMods] =
        new layerAdditionRemoval
        (
            "right",
            nMods,
            topoChanger_,
            "rightExtrusionFaces",
            readScalar
            (
                motionDict_.subDict("right").lookup("minThickness")
            ),
            readScalar
            (
                motionDict_.subDict("right").lookup("maxThickness")
            )
        );
    nMods++;

    tm[nMods] = new layerAdditionRemoval
    (
        "left",
        nMods,
        topoChanger_,
        "leftExtrusionFaces",
        readScalar
        (
            motionDict_.subDict("left").lookup("minThickness")
        ),
        readScalar
        (
            motionDict_.subDict("left").lookup("maxThickness")
        )
    );
    nMods++;
    tm.setSize(nMods);

    Info<< "Adding " << nMods << " mesh modifiers" << endl;
    topoChanger_.addTopologyModifiers(tm);

    write();
}