Esempio n. 1
0
			//----------
			void Sender::update() {
				if (this->controlSocket) {
					this->controlSocket->update();
				}

				if (this->sender) {
					auto kinect = this->getInput<Item::KinectV2>()->getDevice();

					//this should anyway be true if sender exists
					if (kinect) {
						//sync endpoint parameters
						auto endPoint = this->sender->getSender().getEndPoint();
						if (this->parameters.target.ipAddress.get() != endPoint.getEndPoint().address().to_string()
							|| this->parameters.target.port.get() != endPoint.getEndPoint().port()) {
							this->sender->init(*kinect, this->parameters.target.ipAddress, this->parameters.target.port);
						}

						//sync parameters
						if (this->sender->getSender().getPacketSize() != this->parameters.squashBuddies.packetSize) {
							this->sender->getSender().setPacketSize(this->parameters.squashBuddies.packetSize);
						}
						if (this->sender->getSender().getMaxSocketBufferSize() != this->parameters.squashBuddies.maxSocketBufferSize) {
							this->sender->getSender().setMaxSocketBufferSize(this->parameters.squashBuddies.maxSocketBufferSize);
						}

						this->sender->update();
					}
				}
			}
Esempio n. 2
0
Point2d MgArc::_getHandlePoint(int index) const
{
    if (index == 1) {
        return getStartPoint();
    }
    if (index == 2) {
        return getEndPoint();
    }
    if (index == 3) {
        return getMidPoint();
    }
    if (index == 4) {
        return (getStartPoint() * 2 + getCenter()) / 3;
    }
    if (index == 5) {
        return (getEndPoint() * 2 + getCenter()) / 3;
    }
    if (index == 6) {
        return getStartPoint() + getStartTangent();
    }
    if (index == 7) {
        return getEndPoint() + getEndTangent();
    }
    return getCenter();
}
std::string DelegateProxy::infoToFile( ){
	string rm = "";
	if (!m_outOpt.empty()){
		string delegationId=getDelegationId();
		char ws = (char)32;
		time_t now = time(NULL);
		struct tm *ns = localtime(&now);
		// date
		ostringstream date;
		date << Utils::twoDigits(ns->tm_mday) << ws << monthStr[ns->tm_mon]  << ws <<  (ns->tm_year+1900) << "," << ws;
		date << Utils::twoDigits(ns->tm_hour) << ":" << Utils::twoDigits(ns->tm_min) << ":" << Utils::twoDigits(ns->tm_sec) << ws;
		string msg = wmcOpts->getApplicationName( ) +" (" + date.str() + ")\n";
		msg += "=========================================================================\n";
		if (delegationId!=""){msg += "WMProxy: " + getEndPoint( )+ "\ndelegation ID: " +  getDelegationId( ) + "\n";}
		else{msg += "WMProxy: " + getEndPoint( )+ "\ndelegation ID was automatically generated"              + "\n";}
		if( wmcUtils->saveToFile(m_outOpt, msg) < 0 ){
			logInfo->print (WMS_WARNING, "unable to write the delegation operation result " , Utils::getAbsolutePath(m_outOpt));
		} else {
			logInfo->print (WMS_DEBUG, "The DelegateProxy result has been saved in the output file ",
				Utils::getAbsolutePath(m_outOpt));
			rm += "\nThe DelegateProxy result  has been saved in the following file:\n";
			rm += Utils::getAbsolutePath(m_outOpt) + "\n";
		}
	}
        return rm;
}
Esempio n. 4
0
void REllipse::moveEndPoint(const RVector& pos, bool changeAngleOnly) {
    if (changeAngleOnly) {
        endParam = getParamTo(pos);
    }
    else {
        RVector sp = getStartPoint();
        double distOri = sp.getDistanceTo(getEndPoint());
        double angleOri = sp.getAngleTo(getEndPoint());
        if (distOri<RS::PointTolerance) {
            return;
        }

        double distNew = sp.getDistanceTo(pos);
        double angleNew = sp.getAngleTo(pos);
        double factor = distNew / distOri;
        if (factor<RS::PointTolerance) {
            return;
        }
        double angleDelta = angleNew - angleOri;

        center.scale(factor, sp);
        center.rotate(angleDelta, sp);
        majorPoint.scale(factor);
        majorPoint.rotate(angleDelta);
    }
}
Esempio n. 5
0
QPainterPath CurveGraphicsItem::obtainCurvePath() const {
    if (useMidPoint_) {
    return obtainCurvePath(getStartPoint(), getMidPoint()) + 
        obtainCurvePath(getMidPoint(), getEndPoint());    
    } else {
        return obtainCurvePath(getStartPoint(), getEndPoint());
    }
}
Esempio n. 6
0
float MgArc::getSweepAngle() const
{
    if (!mgIsZero(_sweepAngle)) {
        return _sweepAngle;
    }
    
    const float midAngle = (getMidPoint() - getCenter()).angle2();
    const float startAngle = getStartAngle();
    const float endAngle = getEndAngle();

    if (mgEquals(midAngle, startAngle) && mgEquals(startAngle, endAngle)) {
        return endAngle - startAngle;
    }
    
    Tol tol(getRadius() * 1e-3f, 1e-4f);
    if (getStartPoint().isEqualTo(getEndPoint(), tol)
        && (getMidPoint() + (getStartPoint() + getEndPoint()) / 2).isEqualTo(2 * getCenter(), tol)) {
        return _M_2PI;
    }

    float startAngle2 = startAngle;
    float midAngle2 = midAngle;
    float endAngle2 = endAngle;

    // 先尝试看是否为逆时针方向:endAngle2 > midAngle2 > startAngle2 >= 0
    if (startAngle2 < 0)
        startAngle2 += _M_2PI;
    while (midAngle2 < startAngle2)
        midAngle2 += _M_2PI;
    while (endAngle2 < midAngle2)
        endAngle2 += _M_2PI;

    if (fabsf(startAngle2 + endAngle2 - 2 * midAngle2) < _M_PI_6
        && endAngle2 - startAngle2 < _M_2PI) {
        return endAngle2 - startAngle2;
    }

    // 再尝试看是否为顺时针方向:endAngle2 < midAngle2 < startAngle2 <= 0
    startAngle2 = startAngle;
    midAngle2 = midAngle;
    endAngle2 = endAngle;
    if (startAngle2 > 0)
        startAngle2 -= _M_2PI;
    while (midAngle2 > startAngle2)
        midAngle2 -= _M_2PI;
    while (endAngle2 > midAngle2)
        endAngle2 -= _M_2PI;

    if (fabsf(startAngle2 + endAngle2 - 2 * midAngle2) < _M_PI_6) {
        if (endAngle2 - startAngle2 > -_M_2PI)
            return endAngle2 - startAngle2;
        return mgbase::toRange(endAngle2 - startAngle2, -_M_2PI, 0);
    }

    return endAngle - startAngle;   // error
}
Esempio n. 7
0
bool MgArc::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const
{
    bool ret = gs.drawArc(&ctx, getCenter(), getRadius(), 0, getStartAngle(), getSweepAngle());
    if (mode > 0) {
        GiContext ctxln(0, GiColor(0, 126, 0, 64), kGiLineDashDot);
        gs.drawLine(&ctxln, getCenter(), getStartPoint());
        gs.drawLine(&ctxln, getCenter(), getEndPoint());
        gs.drawLine(&ctxln, getStartPoint(), getStartPoint() + getStartTangent());
        gs.drawLine(&ctxln, getEndPoint(), getEndPoint() + getEndTangent());
    }
    return __super::_draw(mode, gs, ctx, segment) || ret;
}
Esempio n. 8
0
void Parse::postProcessGet(QJsonObject obj) {

    qWarning()<<getEndPoint();


    if (getEndPoint() == "classes/Pml?include=owner&order=-updatedAt&limit=2000") {
        qWarning()<<"obj:"<<obj;
        generatePmlXml(obj);
    }

    emit currentObjectChanged( obj);
}
Esempio n. 9
0
RBox RArc::getBoundingBox() const {
    RVector minV;
    RVector maxV;
    double minX = qMin(getStartPoint().x, getEndPoint().x);
    double minY = qMin(getStartPoint().y, getEndPoint().y);
    double maxX = qMax(getStartPoint().x, getEndPoint().x);
    double maxY = qMax(getStartPoint().y, getEndPoint().y);

    if (getStartPoint().getDistanceTo(getEndPoint()) < 1.0e-6 && getRadius()
            > 1.0e5) {
        minV = RVector(minX, minY);
        maxV = RVector(maxX, maxY);
        return RBox(minV, maxV);
    }

    double a1 = RMath::getNormalizedAngle(!isReversed() ? startAngle : endAngle);
    double a2 = RMath::getNormalizedAngle(!isReversed() ? endAngle : startAngle);

    // check for left limit:
    if ((a1<M_PI && a2>M_PI) ||
            (a1>a2-1.0e-12 && a2>M_PI) ||
            (a1>a2-1.0e-12 && a1<M_PI) ) {

        minX = qMin(center.x - radius, minX);
    }

    // check for right limit:
    if (a1 > a2-1.0e-12) {
        maxX = qMax(center.x + radius, maxX);
    }

    // check for bottom limit:
    if ((a1<(M_PI_2*3) && a2>(M_PI_2*3)) ||
            (a1>a2-1.0e-12    && a2>(M_PI_2*3)) ||
            (a1>a2-1.0e-12    && a1<(M_PI_2*3)) ) {

        minY = qMin(center.y - radius, minY);
    }

    // check for top limit:
    if ((a1<M_PI_2 && a2>M_PI_2) ||
            (a1>a2-1.0e-12   && a2>M_PI_2) ||
            (a1>a2-1.0e-12   && a1<M_PI_2) ) {

        maxY = qMax(center.y + radius, maxY);
    }

    minV = RVector(minX, minY);
    maxV = RVector(maxX, maxY);

    return RBox(minV, maxV);
}
Esempio n. 10
0
/*
* Retrieves the list of matching resources
*/
void JobListMatch::jobMatching( ) {
	// checks if jdlstring is not null
        if (m_jdlString.empty()){
                throw WmsClientException(__FILE__,__LINE__,
                        "jobMatching",  DEFAULT_ERR_CODE ,
                        "Null Pointer Error",
                        "Null pointer to JDL string");
        }
	logInfo->print(WMS_DEBUG, "Sending the request to the service", getEndPoint( ));
 	try{
  		// ListMatch
		logInfo->service(WMP_LISTMATCH_SERVICE);
			
		// Set the SOAP timeout
		setSoapTimeout(SOAP_JOB_LIST_MATCH_TIMEOUT);
			
    		m_listResult_v = jobListMatch(m_jdlString, getDelegationId( ), getContext());
		logInfo->result(WMP_LISTMATCH_SERVICE, "The MatchMaking operations have been successfully performed");
      } catch (BaseException &exc) {
		throw WmsClientException(__FILE__,__LINE__,
		"jobListMatch", ECONNABORTED,
		"Operation failed",
		"Unable to perform the operation: "  + errMsg(exc));
  	}
}
Esempio n. 11
0
float MgArc::_hitTest(const Point2d& pt, float tol, MgHitResult& res) const
{
    Point2d points[16];
    int n = mgcurv::arcToBezier(points, getCenter(), getRadius(), 0, getStartAngle(), getSweepAngle());

    float dist, distMin = _FLT_MAX;
    Point2d ptTemp;

    if (_subtype > 0) {
        dist = mglnrel::ptToLine(getCenter(), getStartPoint(), pt, ptTemp);
        if (dist <= tol && dist < distMin) {
            distMin = dist;
            res.nearpt = ptTemp;
        }
        dist = mglnrel::ptToLine(getCenter(), getEndPoint(), pt, ptTemp);
        if (dist <= tol && dist < distMin) {
            distMin = dist;
            res.nearpt = ptTemp;
        }
    }
    for (int i = 0; i + 3 < n; i += 3) {
        mgnear::nearestOnBezier(pt, points + i, ptTemp);
        dist = pt.distanceTo(ptTemp);
        if (dist <= tol && dist < distMin) {
            distMin = dist;
            res.nearpt = ptTemp;
        }
    }
    
    return distMin;
}
Esempio n. 12
0
bool RArcData::moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(center)) {
        center = targetPoint;
        ret = true;
    } else if (referencePoint.equalsFuzzy(getStartPoint())) {
        moveStartPoint(targetPoint);
        ret = true;
    } else if (referencePoint.equalsFuzzy(getEndPoint())) {
        moveEndPoint(targetPoint);
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(center + RVector(radius, 0)) ||
             referencePoint.equalsFuzzy(center + RVector(0, radius)) ||
             referencePoint.equalsFuzzy(center - RVector(radius, 0)) ||
             referencePoint.equalsFuzzy(center - RVector(0, radius))) {
        radius = center.getDistanceTo(targetPoint);
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(getMiddlePoint())) {
        moveMiddlePoint(targetPoint);
        ret = true;
    }
    return ret;
}
Esempio n. 13
0
RBox REllipse::getBoundingBox() const {
    double radius1 = getMajorRadius();
    double radius2 = getMinorRadius();
    double angle = getAngle();
    double a1 = ((!isReversed()) ? startParam : endParam);
    double a2 = ((!isReversed()) ? endParam : startParam);
    RVector startPoint = getStartPoint();
    RVector endPoint = getEndPoint();

    double minX = qMin(startPoint.x, endPoint.x);
    double minY = qMin(startPoint.y, endPoint.y);
    double maxX = qMax(startPoint.x, endPoint.x);
    double maxY = qMax(startPoint.y, endPoint.y);

    // kind of a brute force. TODO: exact calculation
    RVector vp;
    double a = a1;
    do {
        vp.set(center.x + radius1 * cos(a),
               center.y + radius2 * sin(a));
        vp.rotate(angle, center);

        minX = qMin(minX, vp.x);
        minY = qMin(minY, vp.y);
        maxX = qMax(maxX, vp.x);
        maxY = qMax(maxY, vp.y);

        a += 0.03;
    } while (RMath::isAngleBetween(a, a1, a2, false) && a<4*M_PI);

    return RBox(RVector(minX,minY), RVector(maxX,maxY));
}
Esempio n. 14
0
void RSpline::print(QDebug dbg) const {
    dbg.nospace() << "RSpline(";
    RShape::print(dbg);

    dbg.nospace() << ", degree: " << getDegree();
    dbg.nospace() << ", order: " << getOrder();
    dbg.nospace() << ", closed: " << isClosed();
    dbg.nospace() << ", periodic: " << isPeriodic();
    dbg.nospace() << ", start point: " << getStartPoint();
    dbg.nospace() << ", end point: " << getEndPoint();

    QList<RVector> controlPoints = getControlPointsWrapped();
    dbg.nospace() << ",\ncontrolPoints (" << controlPoints.count() << "): ";
    for (int i=0; i<controlPoints.count(); ++i) {
        dbg.nospace() << i << ": " << controlPoints.at(i);
    }

    QList<RVector> fitPoints = getFitPoints();
    dbg.nospace() << ",\nfitPoints (" << fitPoints.count() << "): ";
    for (int i=0; i<fitPoints.count(); ++i) {
        dbg.nospace() << i << ": " << fitPoints.at(i) << ", ";
    }

    QList<double> knotVector = getKnotVector();
    dbg.nospace() << ",\nknots (" << knotVector.count() << "): ";
    for (int i=0; i<knotVector.count(); ++i) {
        dbg.nospace() << i << ": " << knotVector.at(i) << ", ";
    }

    knotVector = getActualKnotVector();
    dbg.nospace() << ",\ninternally used knots (" << knotVector.count() << "): ";
    for (int i=0; i<knotVector.count(); ++i) {
        dbg.nospace() << i << ": " << knotVector.at(i) << ", ";
    }
}
Esempio n. 15
0
void Parse::deleteObject(QString doc)
{
    if (!isReady()) {
        m_deleteQueue.append(doc);
        return;
    }

    ensureEndPointHasPrefix("classes");

    //Get objectId to be deleted
    QString deletedObjectId = getEndPoint();
    int found = deletedObjectId.lastIndexOf('/');
    int length = deletedObjectId.length();
    deletedObjectId = deletedObjectId.right( length - found -1);


    m_conn = connect(this, &BaaS::replyFinished, [=]( QJsonDocument json){
        Q_UNUSED(json);
        disconnect(m_conn);
        if ( isLastRequestSuccessful() ) {
            emit objectDeleted( deletedObjectId );
            if(!m_deleteQueue.isEmpty()) {
                deleteObject(m_deleteQueue.takeFirst());
            }
        }
        else {
            // error, drop the queue
            m_deleteQueue.empty();
        }
    } );

    initHeaders();
    request( BaaS::DELETE, doc.toUtf8() );
}
Esempio n. 16
0
bool RSpline::mirror(const RLine& axis) {
    RVector sp = getStartPoint();
    RVector ep = getEndPoint();

    for (int i=0; i<controlPoints.size(); i++) {
        controlPoints[i].mirror(axis);
    }
    for (int i=0; i<fitPoints.size(); i++) {
        fitPoints[i].mirror(axis);
    }

    RVector absTan = sp+tangentStart;
    absTan.mirror(axis);
    sp.mirror(axis);
    tangentStart = absTan-sp;

    absTan = ep+tangentEnd;
    absTan.mirror(axis);
    ep.mirror(axis);
    tangentEnd = absTan-ep;

    update();

    return true;
}
Esempio n. 17
0
bool MgPath::arcTo(const Point2d& point, const Point2d& end, bool rel)
{
    bool ret = false;
    Point2d lastpt(getEndPoint());

    if (m_data->beginIndex >= 0 
        && getSize(m_data->points) >= m_data->beginIndex + 1
        && m_data->points.size() == m_data->types.size())
    {
        Point2d start = m_data->points[m_data->points.size() - 1];
        Point2d center;
        float radius, startAngle, sweepAngle;

        if (mgcurv::arc3P(start, rel ? point + lastpt : point,
                          rel ? end + lastpt : end,
                          center, radius, &startAngle, &sweepAngle)) {
            Point2d pts[16];
            int n = mgcurv::arcToBezier(pts, center, radius, radius, 
                startAngle, sweepAngle);
            if (n >= 4) {
                ret = true;
                for (int i = 1; i < n; i++) {
                    m_data->points.push_back(pts[i]);
                    m_data->types.push_back(kMgBezierTo);
                }
            }
        }
    }

    return ret;
}
Esempio n. 18
0
/**
 * \return List of RLines describing this spline.
 */
QList<QSharedPointer<RShape> > RSpline::getExploded(int segments) const {
    if (!exploded.isEmpty() && segments==-1) {
        return exploded;
    }

    //qDebug() << "RSpline::getExploded: segments: " << segments;
    //RDebug::printBacktrace("getExploded:    ");

    //##boundingBox = RBox();

    updateInternal();

    exploded.clear();

    if (!isValid()) {
        //qWarning() << "RSpline::getExploded: invalid spline";
        return exploded;
    }

    if (segments==-1) {
        segments = 8;
    }

    double tMin = getTMin();
    double tMax = getTMax();

    double step = getTDelta() / (controlPoints.size() * segments);

    RVector p1;
    RVector prev = RVector::invalid;
    for (double t = tMin; t<tMax+(step/2.0); t+=step) {
        double tc = qMin(t, tMax);
        p1 = getPointAt(tc);

        if (RMath::isNaN(p1.x) || RMath::isNaN(p1.y)) {
            continue;
        }

        if (prev.isValid()) {
            RLine* line = new RLine(prev, p1);
            exploded.append(QSharedPointer<RShape>(line));
        }
        prev = p1;

        //##boundingBox.growToInclude(p1);
    }

    p1 = getEndPoint();
    if (!RMath::isNaN(p1.x) && !RMath::isNaN(p1.y)) {
        if (prev.isValid()) {
            RLine* line = new RLine(prev, p1);
            // prevent zero length line at the end:
            if (line->getLength()>1.0e-4) {
                exploded.append(QSharedPointer<RShape>(line));
            }
        }
    }

    return exploded;
}
Esempio n. 19
0
bool CapsuleShape::findRayIntersection(const glm::vec3& rayStart, const glm::vec3& rayDirection, float& distance) const {
        glm::vec3 capsuleStart, capsuleEnd;
        getStartPoint(capsuleStart);
        getEndPoint(capsuleEnd);
        // NOTE: findRayCapsuleIntersection returns 'true' with distance = 0 when rayStart is inside capsule.
        // TODO: implement the raycast to return inside surface intersection for the internal rayStart.
        return findRayCapsuleIntersection(rayStart, rayDirection, capsuleStart, capsuleEnd, _radius, distance);
}
Esempio n. 20
0
QList<RVector> RSpline::getEndPoints() const {
    QList<RVector> ret;

    ret.append(getStartPoint());
    ret.append(getEndPoint());

    return ret;
}
Esempio n. 21
0
bool RPolyline::simplify(double angleTolerance) {
    bool ret = false;
    RPolyline newPolyline;
    //ret.appendVertex(getStartPoint());

    RS::EntityType type = RS::EntityUnknown;
    double angle = RMAXDOUBLE;
    //double radius = 0;
    //RVector center;
    //RVector vertex;

    for (int i=0; i<countSegments(); i++) {
        QSharedPointer<RShape> seg = getSegmentAt(i);

        QSharedPointer<RLine> line = seg.dynamicCast<RLine>();
        if (!line.isNull()) {
            double angleDiff = qAbs(RMath::getAngleDifference180(line->getAngle(), angle));
//            qDebug() << "angle diff: " << angleDiff;
//            qDebug() << "tol: " << angleTolerance;
            if (type==RS::EntityLine && angleDiff<angleTolerance) {

                //vertex = line->getEndPoint();
                ret = true;
            }
            else {
                //qDebug() << "start: " << line->getStartPoint();
                newPolyline.appendVertex(line->getStartPoint());
                angle = line->getAngle();
                type = RS::EntityLine;
            }
        }

        QSharedPointer<RArc> arc = seg.dynamicCast<RArc>();
        if (!arc.isNull()) {
            // TODO
            newPolyline.appendVertex(arc->getStartPoint(), arc->getBulge());
        }
    }

    if (isClosed()) {
        newPolyline.setClosed(true);
    }
    else {
        newPolyline.appendVertex(getEndPoint());
    }

//    qDebug() << "old polyline: " << *this;
//    qDebug() << "new polyline: " << newPolyline;

    //*this = newPolyline;

    //clear();
    vertices = newPolyline.vertices;
    bulges = newPolyline.bulges;
    closed = newPolyline.closed;

    return ret;
}
Esempio n. 22
0
bool RArc::stretch(const RPolyline& area, const RVector& offset) {
    bool ret = false;

    if (area.contains(getStartPoint()) && area.contains(getEndPoint())) {
        return move(offset);
    }

    if (area.contains(getStartPoint())) {
        moveStartPoint(getStartPoint() + offset);
        ret = true;
    }
    else if (area.contains(getEndPoint())) {
        moveEndPoint(getEndPoint() + offset);
        ret = true;
    }

    return ret;
}
Esempio n. 23
0
QPainterPath ArrowLinkItem::originalShape() const
{
    QPointF c1 = getControlItemPosFirst();
    QPointF c2 = getControlItemPosSecond();
    QPainterPath path(getStartPoint());
    path.cubicTo(c1, c2, getEndPoint());
    path.cubicTo(c2, c1, getStartPoint());
    return path;
}
Esempio n. 24
0
void ArrowLinkItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    QColor penColor;
    QPointF c1 = getControlItemPosFirst();
    QPointF c2 = getControlItemPosSecond();
    QPointF startPos = getStartPoint();
    QPointF endPos = getEndPoint();

    if(option->state & QStyle::State_Selected)
    {
        setControlPointVisible(true);
		QPen pen(Qt::DotLine);
		pen.setWidth(1);
		pen.setColor(QColor(0, 0, 255, 125));
		painter->save();
        painter->setPen(pen);
        painter->drawLine(c1, startPos);
        painter->drawLine(c2, endPos);
		painter->restore();
		penColor = m_colorSelect;
    }
    else
    {
        setControlPointVisible(false);
        penColor = Qt::blue;
    }
    if(option->state & QStyle::State_MouseOver)
    {
        penColor = penColor.lighter();
    }
    if(option->state & QStyle::State_Sunken)
    {
        penColor.setAlpha(210);
    }
    painter->setPen(QPen(penColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));


    QPainterPath path = originalShape();
    painter->drawPath(path);


    qreal arrowSize = 10;
    QLineF line(endPos, c2);
    double angle = ::acos(line.dx() / (line.length() <= 0 ? 1 : line.length()));
    if (line.dy() >= 0)
        angle = (M_PI * 2) - angle;

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

    QPolygonF arrowHead;
    arrowHead << arrowP2 << arrowP1 << line.p1();
    painter->setBrush(penColor);
    painter->drawPolygon(arrowHead);
}
Esempio n. 25
0
void hdPolyLineFigure::basicDraw(wxBufferedDC &context, hdDrawingView *view)
{
	int posIdx = view->getIdx();
	if(points[posIdx]->count() < 2)
	{
		return;
	}
	hdPoint start, end;

	if(startTerminal)
	{
		startTerminal->setLinePen(linePen);
		start = startTerminal->draw(context, getStartPoint(posIdx), pointAt(posIdx, 1), view);
	}
	else
	{
		start = getStartPoint(posIdx);
	}

	if(endTerminal)
	{
		endTerminal->setLinePen(linePen);
		end = endTerminal->draw(context, getEndPoint(posIdx), pointAt(posIdx, pointCount(posIdx) - 2), view);
	}
	else
	{
		end = getEndPoint(posIdx);
	}

	context.SetPen(linePen);
	for(int i = 0; i < points[posIdx]->count() - 1; i++)
	{
		hdPoint *p1 = (hdPoint *) points[posIdx]->getItemAt(i);
		hdPoint *p2 = (hdPoint *) points[posIdx]->getItemAt(i + 1);

		hdPoint copyP1 = hdPoint (*p1);
		view->CalcScrolledPosition(copyP1.x, copyP1.y, &copyP1.x, &copyP1.y);
		hdPoint copyP2 = hdPoint (*p2);
		view->CalcScrolledPosition(copyP2.x, copyP2.y, &copyP2.x, &copyP2.y);

		context.DrawLine(copyP1, copyP2);
	}
}
Esempio n. 26
0
bool MgPath::lineTo(const Point2d& point, bool rel)
{
    bool ret = (m_data->beginIndex >= 0);
    if (ret) {
        m_data->points.push_back(rel ? point + getEndPoint() : point);
        m_data->types.push_back(kMgLineTo);
    }

    return ret;
}
Esempio n. 27
0
bool MgPath::quadTo(const Point2d& cp, const Point2d& end, bool rel)
{
    Point2d lastpt(getEndPoint());
    
    m_data->points.push_back(rel ? cp + lastpt : cp);
    m_data->points.push_back(rel ? end + lastpt : end);
    m_data->types.push_back(kMgQuadTo);
    m_data->types.push_back(kMgQuadTo);
    return true;
}
Esempio n. 28
0
bool Parse::ensureEndPointHasPrefix(QString prefix)
{
    QString endpt = getEndPoint();
    //if ( endpt.left( prefix.length() ) == prefix )
    if (endpt.startsWith( prefix ))
        return true;
    else{
        setEndPoint( prefix + "/" + endpt);
    }
    return false;
}
Esempio n. 29
0
void RArc::moveStartPoint(const RVector& pos) {
    double bulge = getBulge();

    // full circle: trim instead of move:
    if (bulge < 1.0e-6 || bulge > 1.0e6) {
        startAngle = center.getAngleTo(pos);
    }
    else {
        *this = RArc::createFrom2PBulge(pos, getEndPoint(), bulge);
    }
}
Esempio n. 30
0
bool CapsuleShape::findRayIntersectionWithCaps(const glm::vec3& capsuleCenter, RayIntersectionInfo& intersection) const {
    glm::vec3 capCenter;
    getStartPoint(capCenter);
    bool hit = findRayIntersectionWithCap(capCenter, _radius, capsuleCenter, intersection);
    getEndPoint(capCenter);
    hit = findRayIntersectionWithCap(capCenter, _radius, capsuleCenter, intersection) || hit;
    if (hit) {
        intersection._hitShape = const_cast<CapsuleShape*>(this);
    }
    return hit;
}