55 #include <qiterator.h>
58 #include <QDomNodeList>
59 #include <QMapIterator>
61 #include <QSharedPointer>
62 #include <QStaticStringData>
63 #include <QStringData>
64 #include <QStringDataPtr>
68 #include "../../../dialogs/tools/dialogtool.h"
69 #include "../../../dialogs/tools/dialogmove.h"
70 #include "../../../visualization/line/operation/vistoolmove.h"
71 #include "../../../visualization/visualization.h"
72 #include "../vgeometry/vabstractcurve.h"
73 #include "../vgeometry/varc.h"
74 #include "../vgeometry/vellipticalarc.h"
75 #include "../vgeometry/vcubicbezier.h"
76 #include "../vgeometry/vcubicbezierpath.h"
77 #include "../vgeometry/vgobject.h"
78 #include "../vgeometry/vpointf.h"
79 #include "../vgeometry/vspline.h"
80 #include "../vgeometry/vsplinepath.h"
81 #include "../vpatterndb/vtranslatevars.h"
82 #include "../vmisc/vabstractapplication.h"
83 #include "../vmisc/vcommonsettings.h"
84 #include "../vmisc/diagnostic.h"
85 #include "../vmisc/logging.h"
86 #include "../vpatterndb/vcontainer.h"
87 #include "../vpatterndb/vformula.h"
88 #include "../ifc/ifcdef.h"
89 #include "../ifc/exception/vexception.h"
90 #include "../ifc/xml/vabstractpattern.h"
91 #include "../vwidgets/vabstractsimple.h"
92 #include "../vwidgets/vmaingraphicsscene.h"
93 #include "../../vabstracttool.h"
94 #include "../../vdatatool.h"
95 #include "../vdrawtool.h"
96 #include "../vmisc/logging.h"
105 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
108 QPolygonF originObjects;
109 qCDebug(vTool,
"Find center of objects: ");
110 for (
auto item : objects)
112 qCDebug(vTool,
"Object: %d", item.id);
115 Q_STATIC_ASSERT_X(
static_cast<int>(
GOType::AllCurves) == 10,
"Not all objects were handled.");
117 switch(
static_cast<GOType>(object->getType()))
140 QPointF rotationOrigin = originObjects.boundingRect().center();
141 QLineF move(rotationOrigin, QPointF(rotationOrigin.x() + calcLength, rotationOrigin.y()));
142 move.setAngle(calcAngle);
149 const QString &formulaAngle,
const QString &formulaLength,
const QString &formulaRotation,
152 const Source &typeCreation, QGraphicsItem *parent)
154 , formulaAngle(formulaAngle)
155 , formulaLength(formulaLength)
156 , formulaRotation(formulaRotation)
157 , m_originPointId(originPointId)
172 dialogTool->setSuffix(
suffix);
174 dialogTool->setSourceObjects(
source);
185 QString angle = dialogTool->GetAngle();
186 QString length = dialogTool->GetLength();
187 QString rotation = dialogTool->getRotation();
188 quint32 originPointId = dialogTool->getOriginPointId();
189 const QString
suffix = dialogTool->getSuffix();
195 if (operation !=
nullptr)
209 qreal calcLength = 0;
210 qreal calcRotation = 0;
216 QPointF rotationOrigin;
226 rotationOrigin =
static_cast<QPointF
>(*originPoint);
227 QLineF moveLine(rotationOrigin, QPointF(rotationOrigin.
x() + calcLength, rotationOrigin.
y()));
228 moveLine.setAngle(calcAngle);
229 rotationOrigin = moveLine.p2();
241 qCDebug(vTool,
"Create SourceItem GUI");
242 for (
int i = 0; i <
source.size(); ++i)
245 qCDebug(vTool,
"Add Object: %d", item.
id);
249 Q_STATIC_ASSERT_X(
static_cast<int>(
GOType::AllCurves) == 10,
"Not all objects were handled.");
252 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
253 qCDebug(vTool,
"VToolMove - Rotation Origin");
254 qCDebug(vTool,
"X: %f", rotationOrigin.x());
255 qCDebug(vTool,
"Y: %f", rotationOrigin.y());
256 switch(
static_cast<GOType>(object->getType()))
259 qCDebug(vTool,
"VToolMove - Point");
260 qCDebug(vTool,
"length: %f", calcLength);
261 qCDebug(vTool,
"angle: %f", calcAngle);
262 qCDebug(vTool,
"rotation: %f\n", calcRotation);
263 dest.append(
createPoint(
id, item.
id, calcAngle, calcLength, calcRotation,
267 dest.append(createArc<VArc>(
id, item.
id, calcAngle, calcLength, calcRotation,
271 dest.append(createArc<VEllipticalArc>(
id, item.
id, calcAngle, calcLength, calcRotation,
275 qCDebug(vTool,
"VToolMove - Spline");
276 qCDebug(vTool,
"length: %f", calcLength);
277 qCDebug(vTool,
"angle: %f", calcAngle);
278 qCDebug(vTool,
"rotation: %f\n", calcRotation);
279 dest.append(createCurve<VSpline>(
id, item.
id, calcAngle, calcLength, calcRotation,
283 dest.append(createCurveWithSegments<VSplinePath>(
id, item.
id, calcAngle, calcLength,
284 calcRotation, rotationOrigin,
suffix,
288 dest.append(createCurve<VCubicBezier>(
id, item.
id, calcAngle, calcLength, calcRotation,
292 qCDebug(vTool,
"VToolMove - VCubicBezier");
293 qCDebug(vTool,
"length: %f", calcLength);
294 qCDebug(vTool,
"angle: %f", calcAngle);
295 qCDebug(vTool,
"rotation: %f\n", calcRotation);
296 dest.append(createCurveWithSegments<VCubicBezierPath>(
id, item.
id, calcAngle, calcLength,
297 calcRotation, rotationOrigin,
suffix,
313 qCDebug(vTool,
"Create sourceItem\n");
314 for (
int i = 0; i <
source.size(); ++i)
317 qCDebug(vTool,
"Add Object: %d\n", item.
id);
321 Q_STATIC_ASSERT_X(
static_cast<int>(
GOType::AllCurves) == 10,
"Not all objects were handled.");
324 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
325 switch(
static_cast<GOType>(object->getType()))
329 updatePoint(
id, item.
id, calcAngle, calcLength, calcRotation, rotationOrigin,
334 updateArc<VArc>(
id, item.
id, calcAngle, calcLength, calcRotation, rotationOrigin,
338 updateArc<VEllipticalArc>(
id, item.
id, calcAngle, calcLength, calcRotation, rotationOrigin,
342 updateCurve<VSpline>(
id, item.
id, calcAngle, calcLength, calcRotation, rotationOrigin,
346 updateCurveWithSegments<VSplinePath>(
id, item.
id, calcAngle, calcLength, calcRotation,
350 updateCurve<VCubicBezier>(
id, item.
id, calcAngle, calcLength, calcRotation, rotationOrigin,
354 updateCurveWithSegments<VCubicBezierPath>(
id, item.
id, calcAngle, calcLength, calcRotation,
377 scene->addItem(tool);
381 if (!originPoint.isNull())
385 qCDebug(vTool,
"Increment references");
386 for (
int i = 0; i <
source.size(); ++i)
389 qCDebug(vTool,
"Object: %d", item.
id);
411 if (value.
error() ==
false)
434 if (value.
error() ==
false)
457 if (value.
error() ==
false)
475 return tr(
"Center point");
497 ShowToolVisualization<VisToolMove>(show);
525 QString length = dialogTool->GetLength();
531 source = dialogTool->getSourceObjects();
564 const QString toolTipStr = QString(
"<tr> <td><b>%1:</b> %2°</td> </tr>"
565 "<tr> <td><b>%3:</b> %4 %5</td> </tr>"
566 "<tr> <td><b>%6:</b> %7</td> </tr>"
567 "<tr> <td><b>%8:</b> %9°</td> </tr>")
573 .arg(tr(
"Rotation point"))
575 .arg(tr(
"Rotation angle"))
586 ContextMenu<DialogMove>(event,
id);
597 qreal length, qreal rotation,
const QPointF &rotationOrigin,
601 VPointF moved = point->Move(length, angle,
suffix).Rotate(rotationOrigin, rotation);
602 moved.setIdObject(idTool);
605 item.
mx = moved.mx();
606 item.
my = moved.my();
613 template <
class Item>
615 const QPointF &rotationOrigin,
const QString &suffix,
VContainer *data)
618 Item moved = i->Move(length, angle,
suffix).Rotate(rotationOrigin, rotation);
619 moved.setIdObject(idTool);
629 template <
class Item>
631 const QPointF &rotationOrigin,
const QString &suffix,
634 const DestinationItem item = createItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
641 template <
class Item>
643 const QPointF &rotationOrigin,
const QString &suffix,
VContainer *data)
645 const DestinationItem item = createItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
652 template <
class Item>
654 qreal length, qreal rotation,
const QPointF &rotationOrigin,
657 const DestinationItem item = createItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
668 VPointF moved = point->Move(length, angle,
suffix).Rotate(rotationOrigin, rotation);
669 moved.setIdObject(idTool);
670 moved.setMx(item.
mx);
671 moved.setMy(item.
my);
677 template <
class Item>
679 const QPointF &rotationOrigin,
const QString &suffix,
VContainer *data, quint32
id)
682 Item moved = i->Move(length, angle,
suffix).Rotate(rotationOrigin, rotation);
683 moved.setIdObject(idTool);
688 template <
class Item>
690 const QPointF &rotationOrigin,
const QString &suffix,
VContainer *data, quint32
id)
692 updateItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
suffix,
data,
id);
697 template <
class Item>
699 const QPointF &rotationOrigin,
const QString &suffix,
VContainer *data, quint32
id)
701 updateItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
suffix,
data,
id);
706 template <
class Item>
708 qreal rotation,
const QPointF &rotationOrigin,
709 const QString &suffix,
VContainer *data, quint32
id)
711 updateItem<Item>(idTool, idItem, angle, length, rotation, rotationOrigin,
suffix,
data,
id);
virtual QVector< QPointF > getPoints() const =0
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
QVector< SourceItem > source
static void initOperationToolConnections(VMainGraphicsScene *scene, T *tool)
void SaveSourceDestination(QDomElement &tag)
void InitOperatedObjects()
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE
QVector< DestinationItem > destination
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.
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
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
void AddSpline(const QSharedPointer< VAbstractBezier > &curve, quint32 id, quint32 parentId=null_id)
void AddCurveWithSegments(const QSharedPointer< VAbstractCubicBezierPath > &curve, const quint32 &id, quint32 parentId=null_id)
quint32 AddGObject(VGObject *obj)
AddGObject add new GObject to container.
static const QSharedPointer< VGObject > GetFakeGObject(quint32 id)
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 ".".
The VExceptionBadId class for exception bad id.
The VMainGraphicsScene class main scene.
The VPointF class keep data of point.
QPointF toQPointF() const
qreal y() const
y return y coordinate
qreal x() const
x return x coordinate
void setObjects(QVector< quint32 > objects)
const QString degreeSymbol
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
const QString AttrRotationAngle
QVector< quint32 > sourceToObjects(const QVector< SourceItem > &source)