55 #include "../ifc/ifcdef.h"
56 #include "../ifc/exception/vexception.h"
57 #include "../vgeometry/vabstractcurve.h"
58 #include "../vgeometry/vgobject.h"
59 #include "../vgeometry/vpointf.h"
60 #include "../vmisc/vabstractapplication.h"
61 #include "../vpatterndb/vcontainer.h"
62 #include "../vwidgets/vmaingraphicsscene.h"
63 #include "../../vdrawtool.h"
64 #include "../../../vabstracttool.h"
65 #include "../../../../dialogs/tools/dialogtool.h"
66 #include "../../../../dialogs/tools/dialogpointofintersectioncurves.h"
67 #include "../../../../visualization/visualization.h"
68 #include "../../../../visualization/path/vistoolpointofintersectioncurves.h"
71 #include <QMessageBox>
72 #include <QSharedPointer>
73 #include <QStaticStringData>
74 #include <QStringData>
75 #include <QStringDataPtr>
84 const quint32 &
id,
const quint32 firstCurveId,
87 QGraphicsItem *parent)
89 firstCurveId(firstCurveId),
90 secondCurveId(secondCurveId),
91 vCrossPoint(vCrossPoint),
92 hCrossPoint(hCrossPoint)
101 auto dialogTool = qobject_cast<DialogPointOfIntersectionCurves*>(
m_dialog);
108 dialogTool->SetPointName(p->name());
119 const quint32
firstCurveId = dialogTool->GetFirstCurveId();
120 const quint32
secondCurveId = dialogTool->GetSecondCurveId();
123 const QString pointName = dialogTool->getPointName();
126 if (point !=
nullptr)
135 quint32 firstCurveId,
136 quint32 secondCurveId,
144 const Source &typeCreation)
152 if (point == QPointF())
154 const QString msg = tr(
"<b><big>Can't find intersection point %1 of Curves</big></b><br>"
155 "Using origin point as a place holder until pattern is corrected.")
158 QMessageBox msgBox(
qApp->getMainWindow());
159 msgBox.setWindowTitle(tr(
"Point Intersect Curves"));
160 msgBox.setWindowFlags(msgBox.windowFlags() & ~Qt::WindowContextHelpButtonHint);
161 msgBox.setWindowIcon(QIcon(
":/toolicon/32x32/intersection_curves.png"));
162 msgBox.setIcon(QMessageBox::Warning);
164 msgBox.setStandardButtons(QMessageBox::Ok);
190 scene->addItem(point);
205 if (curve1Points.isEmpty() || curve2Points.isEmpty())
211 for (
auto i = 0; i < curve1Points.count()-1; ++i )
214 QLineF(curve1Points.at(i), curve1Points.at(i+1)));
217 if (intersections.isEmpty())
222 if (intersections.size() == 1)
224 return intersections.at(0);
230 qreal minY = intersections.at(0).y();
231 vIntersections.append(intersections.at(0));
233 for (
auto i = 1; i < intersections.count(); ++i )
235 const QPointF p = intersections.at(i);
240 else if (p.y() < minY)
243 vIntersections.clear();
244 vIntersections.append(p);
248 vIntersections.append(p);
254 qreal maxY = intersections.at(0).y();
255 vIntersections.append(intersections.at(0));
257 for (
auto i = 1; i < intersections.count(); ++i )
259 const QPointF p = intersections.at(i);
263 vIntersections.clear();
264 vIntersections.append(p);
266 else if (p.y() < maxY)
272 vIntersections.append(p);
277 if (vIntersections.isEmpty())
282 if (vIntersections.size() == 1)
284 return vIntersections.at(0);
287 QPointF crossPoint = vIntersections.at(0);
291 qreal maxX = vIntersections.at(0).x();
293 for (
auto i = 1; i < vIntersections.count(); ++i )
295 const QPointF p = vIntersections.at(i);
305 qreal minX = vIntersections.at(0).x();
307 for (
auto i = 1; i < vIntersections.count(); ++i )
309 const QPointF p = vIntersections.at(i);
402 ShowToolVisualization<VisToolPointOfIntersectionCurves>(show);
420 ContextMenu<DialogPointOfIntersectionCurves>(event,
id);
433 auto dialogTool = qobject_cast<DialogPointOfIntersectionCurves*>(
m_dialog);
466 if (not
vis.isNull())
468 auto visual = qobject_cast<VisToolPointOfIntersectionCurves *>(
vis);
475 visual->RefreshGeometry();
virtual QVector< QPointF > getPoints() const =0
static QVector< QPointF > CurveIntersectLine(const QVector< QPointF > &points, const QLineF &line)
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.
virtual void DecrementReferens(quint32 id) const =0
static void InitToolConnections(VMainGraphicsScene *scene, T *tool)
The VContainer class container of all variables.
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 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 ".".
quint32 getIdTool() const
The VMainGraphicsScene class main scene.
The VPointF class keep data of point.
void setShowPointName(bool show)
@ PointOfIntersectionCurves
const QString AttrHCrossPoint
const QString AttrVCrossPoint