58 #include <QSharedPointer>
59 #include <QStaticStringData>
60 #include <QStringData>
61 #include <QStringDataPtr>
63 #include <QMessageBox>
66 #include "../../../../../dialogs/tools/dialogtool.h"
67 #include "../../../../../dialogs/tools/dialogcurveintersectaxis.h"
68 #include "../ifc/ifcdef.h"
69 #include "../ifc/exception/vexception.h"
70 #include "../qmuparser/qmudef.h"
71 #include "../toolcut/vtoolcutsplinepath.h"
72 #include "../vgeometry/vabstractcubicbezier.h"
73 #include "../vgeometry/vabstractcubicbezierpath.h"
74 #include "../vgeometry/vabstractcurve.h"
75 #include "../vgeometry/varc.h"
76 #include "../vgeometry/vellipticalarc.h"
77 #include "../vgeometry/vgobject.h"
78 #include "../vgeometry/vpointf.h"
79 #include "../vgeometry/vspline.h"
80 #include "../vgeometry/vsplinepath.h"
81 #include "../vmisc/vabstractapplication.h"
82 #include "../vmisc/vcommonsettings.h"
83 #include "../vpatterndb/vcontainer.h"
84 #include "../vpatterndb/vtranslatevars.h"
85 #include "../vtools/visualization/visualization.h"
86 #include "../vtools/visualization/line/vistoolcurveintersectaxis.h"
87 #include "../vwidgets/vmaingraphicsscene.h"
88 #include "../../../../vabstracttool.h"
89 #include "../../../vdrawtool.h"
98 const QString &lineType,
const QString &lineWeight,
99 const QString &lineColor,
100 const QString &formulaAngle,
const quint32 &basePointId,
101 const quint32 &curveId,
const Source &typeCreation,
102 QGraphicsItem *parent)
103 :
VToolLinePoint(doc, data, id, lineType, lineWeight, lineColor, QString(), basePointId, 0, parent)
104 , formulaAngle(formulaAngle)
123 dialogTool->setCurveId(
curveId);
124 dialogTool->SetPointName(intersectPoint->name());
135 const QString pointName = dialogTool->getPointName();
136 const QString lineType = dialogTool->getLineType();
137 const QString lineWeight = dialogTool->getLineWeight();
138 const QString
lineColor = dialogTool->getLineColor();
140 const quint32
basePointId = dialogTool->GetBasePointId();
141 const quint32
curveId = dialogTool->getCurveId();
145 if (point !=
nullptr)
154 const QString &lineType,
const QString &lineWeight,
155 const QString &lineColor,
156 QString &formulaAngle, quint32 basePointId,
157 quint32 curveId, qreal mx, qreal my,
bool showPointName,
166 QPointF intersectPoint;
167 const bool isIntersect =
FindPoint(
static_cast<QPointF
>(*basePoint),
angle, curve, &intersectPoint);
171 const QString msg = tr(
"<b><big>Can not create intersection point %1 from point %2</big></b><br>"
172 "<b><big>to curve %3 with an axis angle of %4°</big></b><br><br>"
173 "Using origin point as a place holder until pattern is corrected.")
175 .arg(basePoint->name())
178 QMessageBox msgBox(
qApp->getMainWindow());
179 msgBox.setWindowTitle(tr(
"Intersection Point of Curve & Axis"));
180 msgBox.setWindowFlags(msgBox.windowFlags() & ~Qt::WindowContextHelpButtonHint);
181 msgBox.setWindowIcon(QIcon(
":/toolicon/32x32/curve_intersect_axis.png"));
182 msgBox.setIcon(QMessageBox::Warning);
184 msgBox.setStandardButtons(QMessageBox::Ok);
188 const qreal segLength = curve->GetLengthByPoint(intersectPoint);
220 scene->addItem(point);
234 QRectF rectangle = QRectF(0, 0, INT_MAX, INT_MAX);
235 rectangle.translate(-INT_MAX/2.0, -INT_MAX/2.0);
240 if (points.isEmpty())
243 points = curve->IntersectLine(axis2);
246 if (points.size() > 0)
248 if (points.size() == 1)
250 *intersectPoint = points.at(0);
256 for ( qint32 i = 0; i < points.size(); ++i )
258 lengths.insert(QLineF(points.at(i), axisPoint).length(), i);
262 if (i != lengths.constEnd())
264 *intersectPoint = points.at(i.value());
286 if (value.
error() ==
false)
322 ShowToolVisualization<VisToolCurveIntersectAxis>(show);
330 ContextMenu<DialogCurveIntersectAxis>(event,
id);
379 if (not
vis.isNull())
394 template <
class Item>
406 arc->CutArc(segLength, arc1, arc2);
410 arc->CutArc(0, arc1, arc2);
414 arc1.setId(p->
id() + 1);
415 arc2.setId(p->
id() + 2);
428 a1->setName(arc1.name());
429 a2->setName(arc2.name());
438 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
445 InitArc<VEllipticalArc>(data, segLength, p, curveId);
448 InitArc<VArc>(data, segLength, p, curveId);
457 QPointF spl1p2, spl1p3, spl2p2, spl2p3;
460 spl->
CutSpline(segLength, spl1p2, spl1p3, spl2p2, spl2p3);
464 spl->CutSpline(0, spl1p2, spl1p3, spl2p2, spl2p3);
481 spline1->setName(spl1->
name());
482 spline2->setName(spl2->
name());
488 data->AddSpline(spline1,
NULL_ID, p->id());
489 data->AddSpline(spline2,
NULL_ID, p->id());
526 splP1->setName(splPath1->name());
527 splP2->setName(splPath2->
name());
533 data->AddSpline(splP1,
NULL_ID, p->id());
534 data->AddSpline(splP2,
NULL_ID, p->id());
QPointF CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const
CutSpline cut spline.
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0
virtual void IncrementReferens(quint32 id) const =0
static void AddTool(quint32 id, VDataTool *tool)
AddTool add tool to list tools.
static void InitToolConnections(VMainGraphicsScene *scene, T *tool)
The VContainer class container of all variables.
void AddArc(const QSharedPointer< VAbstractCurve > &arc, const quint32 &id, const quint32 &parentId=null_id)
static quint32 getNextId()
getNextId generate next unique id
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId)
AddLine add line to container.
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
quint32 AddGObject(VGObject *obj)
AddGObject add new GObject to container.
void UpdateGObject(quint32 id, T *obj)
UpdateGObject update GObject by id.
static QString GetParametrString(const QDomElement &domElement, const QString &name, const QString &defValue=QString())
Returns the string value of the given attribute. RENAME: see above.
static quint32 GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
virtual QString name() const
name return name graphical object.
static QPointF BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect)
quint32 id() const
id return id object.
The VMainGraphicsScene class main scene.
The VPointF class keep data of point.
void setShowPointName(bool show)
The VSplinePath class keep information about splinePath.
VSpline class that implements the spline.
void setLineWeight(const QString &value)
void setObject1Id(const quint32 &value)
void setLineStyle(const Qt::PenStyle &value)
const QString degreeSymbol
static Q_REQUIRED_RESULT bool VFuzzyComparePossibleNulls(double p1, double p2)
const QString AttrBasePoint
const QString AttrLineType
const QString LineTypeSolidLine
const QString AttrLineWeight
const QString AttrLineColor
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.