Esempio n. 1
0
bool RDimensionData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    if (referencePoint.equalsFuzzy(definitionPoint)) {
        definitionPoint = targetPoint;
        autoTextPos = true;
        update();
        return true;
    }
    if (textPositionSide.isValid()) {
        if (referencePoint.equalsFuzzy(textPositionSide)) {
            textPositionCenter = targetPoint;
            textPositionSide = RVector::invalid;
            autoTextPos = false;
            update();
            return true;
        }
    }
    if (referencePoint.equalsFuzzy(textPositionCenter)) {
        textPositionCenter = targetPoint;
        autoTextPos = false;
        update();
        return true;
    }

    return false;
}
Esempio n. 2
0
bool RPolylineData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;

    QList<RVector>::iterator it;
    for (it=vertices.begin(); it!=vertices.end(); ++it) {
        if (referencePoint.equalsFuzzy(*it)) {
            (*it) = targetPoint;
            ret = true;
        }
    }

    for (int i=0; i<countSegments(); i++) {
        if (isArcSegmentAt(i)) {
            QSharedPointer<RArc> arc = getSegmentAt(i).dynamicCast<RArc>();
            if (!arc.isNull()) {
                if (referencePoint.equalsFuzzy(arc->getMiddlePoint())) {
                    RArc a = RArc::createFrom3Points(arc->getStartPoint(), targetPoint, arc->getEndPoint());
                    setBulgeAt(i, a.getBulge());
                    ret = true;
                }
            }
        }
    }

    return ret;
}
Esempio n. 3
0
bool RLineData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(startPoint)) {
        startPoint = targetPoint;
        ret = true;
    }
    if (referencePoint.equalsFuzzy(endPoint)) {
        endPoint = targetPoint;
        ret = true;
    }
    return ret;
}
Esempio n. 4
0
bool RRayData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(basePoint)) {
        basePoint = targetPoint;
        ret = true;
    }
    if (referencePoint.equalsFuzzy(getSecondPoint())) {
        setSecondPoint(targetPoint);
        ret = true;
    }
    return ret;
}
Esempio n. 5
0
bool RCircleData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(center)) {
        center = 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;
    }
    return ret;
}
Esempio n. 6
0
bool RPointData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(position)) {
        position = targetPoint;
        ret = true;
    }
    return ret;
}
Esempio n. 7
0
bool RVector::containsFuzzy(const QList<RVector>& vectors, const RVector& v, double tol) {
    for (int i=0; i<vectors.length(); i++) {
        if (v.equalsFuzzy(vectors[i], tol)) {
            return true;
        }
    }

    return false;
}
Esempio n. 8
0
bool RViewportData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {
    bool ret = false;
    if (referencePoint.equalsFuzzy(center)) {
        center = targetPoint;
        ret = true;
    }
    return ret;
}
Esempio n. 9
0
void RSpline::trimEndPoint(const RVector& p) {
    if (splineProxy!=NULL) {
        if (!isValid()) {
            return;
        }
        if (p.equalsFuzzy(getStartPoint())) {
            this->invalidate();
            return;
        }
        if (p.equalsFuzzy(getEndPoint())) {
            return;
        }

        QList<RSpline> splines = splineProxy->split(*this, QList<RVector>() << p);
        if (splines.length()>0) {
            copySpline(splines[0]);
        }
        update();
    }
}
Esempio n. 10
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. 11
0
bool RDimDiametricData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool ret = false;

    if (referencePoint.equalsFuzzy(chordPoint)) {
        RVector c = (definitionPoint + chordPoint)/2.0;
        double d = c.getDistanceTo(chordPoint);
        double a = c.getAngleTo(targetPoint);

        RVector v = RVector::createPolar(d, a);
        chordPoint = c + v;
        definitionPoint = c - v;

        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(definitionPoint)) {
        RVector c = (definitionPoint + chordPoint)/2.0;
        double d = c.getDistanceTo(definitionPoint);
        double a = c.getAngleTo(targetPoint);

        RVector v = RVector::createPolar(d, a);
        definitionPoint = c + v;
        chordPoint = c - v;

        autoTextPos = true;
        ret = true;
    }

    if (!ret) {
        ret = RDimensionData::moveReferencePoint(referencePoint, targetPoint);
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 12
0
bool RDimAlignedData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool ret = RDimLinearData::moveReferencePoint(referencePoint, targetPoint);

    if (referencePoint.equalsFuzzy(refDefinitionPoint1)) {
        definitionPoint = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(refDefinitionPoint2)) {
        definitionPoint = targetPoint;
        autoTextPos = true;
        ret = true;
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 13
0
bool RDimOrdinateData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool ret = RDimensionData::moveReferencePoint(referencePoint, targetPoint);

    if (referencePoint.equalsFuzzy(leaderEndPoint)) {
        leaderEndPoint = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(definingPoint)) {
        definingPoint = targetPoint;
        autoTextPos = true;
        ret = true;
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 14
0
bool RDimensionData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool ret = false;

//    qDebug() << "RDimensionData::moveReferencePoint";
//    qDebug() << "    textPosition: " << textPositionCenter;
//    qDebug() << "    referencePoint: " << referencePoint;

    if (referencePoint.equalsFuzzy(definitionPoint)) {
        definitionPoint = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else {
        if (textPositionSide.isValid()) {
            if (referencePoint.equalsFuzzy(textPositionSide)) {
                textPositionCenter = targetPoint;
                textPositionSide = RVector::invalid;
                autoTextPos = false;
                ret = true;
            }
        }
        else {
            if (referencePoint.equalsFuzzy(textPositionCenter)) {
                textPositionCenter = targetPoint;
                autoTextPos = false;
                ret = true;
            }
        }
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 15
0
bool RDimLinearData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool recomputeDefPoint = false;
    if (referencePoint.equalsFuzzy(definitionPoint)) {
        recomputeDefPoint = true;
    }

    bool ret = RDimensionData::moveReferencePoint(referencePoint, targetPoint);

    if (referencePoint.equalsFuzzy(extensionPoint1)) {
        recomputeDefinitionPoint(extensionPoint1, extensionPoint2,
                                 targetPoint, extensionPoint2);
        extensionPoint1 = targetPoint;
        autoTextPos = true;
        update();
        return true;
    }
    else if (referencePoint.equalsFuzzy(extensionPoint2)) {
        recomputeDefinitionPoint(extensionPoint1, extensionPoint2,
                                 extensionPoint1, targetPoint);
        extensionPoint2 = targetPoint;
        autoTextPos = true;
        update();
        return true;
    }
    else if (recomputeDefPoint) {
        recomputeDefinitionPoint(extensionPoint1, extensionPoint2,
                                 extensionPoint1, extensionPoint2);
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 16
0
bool RDimAngularData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    bool ret = false;

    if (referencePoint.equalsFuzzy(extensionLine1Start)) {
        extensionLine1Start = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(extensionLine1End)) {
        extensionLine1End = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(extensionLine2Start)) {
        extensionLine2Start = targetPoint;
        autoTextPos = true;
        ret = true;
    }
    else if (referencePoint.equalsFuzzy(dimArcPosition)) {
        dimArcPosition = targetPoint;
        autoTextPos = true;
        ret = true;
    }

    if (!ret) {
        ret = RDimensionData::moveReferencePoint(referencePoint, targetPoint);
    }

    if (ret) {
        update();
    }

    return ret;
}
Esempio n. 17
0
void RPolyline::normalize() {
    QList<RVector> newVertices;
    QList<double> newBulges;

    for (int i=0; i<vertices.size(); i++) {
        RVector v = vertices.at(i);
        double b = bulges.at(i);
        if (i==0 || !v.equalsFuzzy(vertices.at(i-1))) {
            newVertices.append(v);
            newBulges.append(b);
        }
    }

    vertices = newVertices;
    bulges = newBulges;
}
Esempio n. 18
0
bool REllipseData::moveReferencePoint(const RVector& referencePoint,
        const RVector& targetPoint) {

    RVector startPoint = getStartPoint();
    RVector endPoint = getEndPoint();

    if (!isFullEllipse()) {
        if (referencePoint.equalsFuzzy(startPoint)) {
            moveStartPoint(targetPoint, true);
            return true;
        }
        if (referencePoint.equalsFuzzy(endPoint)) {
            moveEndPoint(targetPoint, true);
            return true;
        }
    }

    if (referencePoint.equalsFuzzy(center+majorPoint)) {
        double minorRadius = getMinorRadius();
        majorPoint = targetPoint-center;
        setRatio(minorRadius / getMajorRadius());
        return true;
    }

    if (referencePoint.equalsFuzzy(center-majorPoint)) {
        double minorRadius = getMinorRadius();
        majorPoint = -(targetPoint-center);
        setRatio(minorRadius / getMajorRadius());
        return true;
    }

    if (referencePoint.equalsFuzzy(center+getMinorPoint())) {
        setMinorPoint(targetPoint-center);
        return true;
    }
    if (referencePoint.equalsFuzzy(center-getMinorPoint())) {
        setMinorPoint(-(targetPoint-center));
        return true;
    }

    if (referencePoint.equalsFuzzy(center)) {
        center = targetPoint;
        return true;
    }

    return false;
}
Esempio n. 19
0
bool RDimRotatedData::moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint) {
    // if definition point and extension points are on one line,
    // move the extension points together with the definition point:
    bool moveExtensionPoints = false;
    if (referencePoint.equalsFuzzy(definitionPoint)) {
        if (RLine(extensionPoint1, extensionPoint2).isOnShape(definitionPoint, false)) {
            moveExtensionPoints = true;
        }
    }

    bool ret = RDimLinearData::moveReferencePoint(referencePoint, targetPoint);

    if (moveExtensionPoints) {
        // move extension points with definition point:
        RVector dir = RVector::createPolar(1.0, rotation);
        RLine dimLine = RLine(targetPoint, targetPoint + dir);
        extensionPoint1 = dimLine.getClosestPointOnShape(extensionPoint1, false);
        extensionPoint2 = dimLine.getClosestPointOnShape(extensionPoint2, false);
        definitionPoint = RVector::getAverage(extensionPoint1, extensionPoint2);
        //recomputeDefinitionPoint(referencePoint, targetPoint);
    }

    return ret;
}