void RExporter::exportSplineSegment(const RSpline& spline) { RPainterPath pp; pp.setPen(currentPen); pp.setInheritPen(true); pp.addSpline(spline); exportPainterPaths(QList<RPainterPath>() << pp); }
void RExporter::exportSpline(const RSpline& spline, double offset) { RLinetypePattern p = getLinetypePattern(); bool continuous = false; if (getEntity() == NULL || !p.isValid() || p.getNumDashes() == 1 || draftMode || screenBasedLinetypes) { continuous = true; } if (!continuous) { p.scale(getPatternFactor()); if (RMath::isNaN(offset)) { double length = spline.getLength(); offset = getPatternOffset(length, p); } exportExplodable(spline, offset); } else { // version <= 3.0.0 was (line interpolation): //exportExplodable(spline, offset); // performance improvement (using real splines): RPainterPath pp; pp.setPen(QPen(Qt::SolidLine)); pp.addSpline(spline); exportPainterPaths(QList<RPainterPath>() << pp); } /* RLinetypePattern p = getLinetypePattern(); p.scale(getPatternFactor()); if (RMath::isNaN(offset)) { double length = spline.getLength(); offset = getPatternOffset(length, p); } double currentOffset = offset; QList<QSharedPointer<RShape> > sub = spline.getExploded(); QList<QSharedPointer<RShape> >::iterator it; for (it=sub.begin(); it!=sub.end(); ++it) { QSharedPointer<RLine> line = (*it).dynamicCast<RLine>(); if (!line.isNull()) { exportLine(*line.data(), currentOffset); currentOffset -= line->getLength(); } QSharedPointer<RArc> arc = (*it).dynamicCast<RArc>(); if (!arc.isNull()) { exportArc(*arc.data(), currentOffset); currentOffset -= arc->getLength(); } } */ }
bool RExporter::exportLinetypeShape(QList<RPainterPath>& pps, const RLine& line, double total, double length, double angle, const RVector& cursor) { RVector min = RPainterPath::getMinList(pps); RVector max = RPainterPath::getMaxList(pps); bool isCursorOnLine = line.isOnShape(cursor); double diffBefore = total+min.x; double diffAfter = total+max.x-length; bool shapeOutsideBefore = diffBefore < -RS::PointTolerance; bool shapeOutsideAfter = diffAfter > RS::PointTolerance; if (isCursorOnLine && (!shapeOutsideBefore && !shapeOutsideAfter)) { exportPainterPaths(pps, angle, cursor); return true; } else { if (shapeOutsideBefore) { // check if first shape is not entirely before the start point of the line: if (total + max.x < 0.0) { return false; } RLine l = line; if (fabs(total+max.x)<length) { RVector p = RVector( cos(angle) * fabs(total+max.x), sin(angle) * fabs(total+max.x) ); l.endPoint = l.startPoint + p; } exportLineSegment(l, angle); return true; } if (shapeOutsideAfter) { // check if last shape is not entirely after the end point of the line: if (total + min.x > length) { return false; } RLine l = line; if (fabs(total+min.x)>0.0) { RVector p = RVector( cos(angle) * fabs(total+min.x), sin(angle) * fabs(total+min.x) ); l.startPoint = l.startPoint + p; } exportLineSegment(l, angle); return true; } return false; } }
void RExporter::exportPainterPathSource(const RPainterPathSource& pathSource) { exportPainterPaths(pathSource.getPainterPaths()); }
void RExporter::exportPainterPaths(const QList<RPainterPath>& paths, double angle, const RVector& pos) { QList<RPainterPath> pps = paths; RPainterPath::rotateList(pps, angle); RPainterPath::translateList(pps, pos); exportPainterPaths(pps); }
void RExporter::exportSpline(const RSpline& spline, double offset) { RLinetypePattern p = getLinetypePattern(); bool continuous = false; if (getEntity() == NULL || !p.isValid() || p.getNumDashes() <= 1 || draftMode || screenBasedLinetypes || twoColorSelectedMode) { continuous = true; } p.scale(getLineTypePatternScale(p)); double patternLength = p.getPatternLength(); if (patternLength<RS::PointTolerance || spline.getLength() / patternLength > RSettings::getDashThreshold()) { continuous = true; } if (!continuous) { if (getEntity()!=NULL && (getEntity()->getType()!=RS::EntitySpline || RSpline::hasProxy())) { // we have a spline proxy: RShapesExporter(*this, QList<QSharedPointer<RShape> >() << QSharedPointer<RShape>(spline.clone()), offset); } else { // fallback if we don't have a spline proxy: p.scale(getLineTypePatternScale(p)); if (RMath::isNaN(offset)) { double length = spline.getLength(); offset = p.getPatternOffset(length); } exportExplodable(spline, offset); } } else { // version <= 3.0.0 was (line interpolation): //exportExplodable(spline, offset); // performance improvement (using real splines): RPainterPath pp; pp.setPen(currentPen); pp.setInheritPen(true); pp.addSpline(spline); exportPainterPaths(QList<RPainterPath>() << pp); } /* RLinetypePattern p = getLinetypePattern(); p.scale(getLineTypePatternScale(p)); if (RMath::isNaN(offset)) { double length = spline.getLength(); offset = p.getPatternOffset(length); } double currentOffset = offset; QList<QSharedPointer<RShape> > sub = spline.getExploded(); QList<QSharedPointer<RShape> >::iterator it; for (it=sub.begin(); it!=sub.end(); ++it) { QSharedPointer<RLine> line = (*it).dynamicCast<RLine>(); if (!line.isNull()) { exportLine(*line.data(), currentOffset); currentOffset -= line->getLength(); } QSharedPointer<RArc> arc = (*it).dynamicCast<RArc>(); if (!arc.isNull()) { exportArc(*arc.data(), currentOffset); currentOffset -= arc->getLength(); } } */ }