55 #include <QApplication>
58 #include <QGraphicsLineItem>
59 #include <QGraphicsScene>
60 #include <QGraphicsSceneMouseEvent>
61 #include <QGraphicsView>
63 #include <QMessageBox>
68 #include <QSharedPointer>
69 #include <QStaticStringData>
70 #include <QStringData>
71 #include <QStringDataPtr>
76 #include "../ifc/exception/vexception.h"
77 #include "../ifc/ifcdef.h"
78 #include "../vgeometry/vgobject.h"
79 #include "../vgeometry/vpointf.h"
80 #include "../vmisc/logging.h"
81 #include "../vmisc/vabstractapplication.h"
82 #include "../vpatterndb/vcontainer.h"
83 #include "../vwidgets/vgraphicssimpletextitem.h"
84 #include "../vwidgets/vmaingraphicsscene.h"
85 #include "../vwidgets/vmaingraphicsview.h"
86 #include "../../vdrawtool.h"
87 #include "../../../vabstracttool.h"
88 #include "../../../vdatatool.h"
89 #include "../../../../dialogs/tools/dialogtool.h"
90 #include "../../../../dialogs/tools/dialogsinglepoint.h"
91 #include "../../../../undocommands/add_draftblock.h"
92 #include "../../../../undocommands/delete_draftblock.h"
93 #include "../../../../undocommands/movespoint.h"
107 const QString &draftBlockName, QGraphicsItem * parent )
109 , draftBlockName(draftBlockName)
111 this->setFlag(QGraphicsItem::ItemIsMovable,
true);
112 this->setFlag(QGraphicsItem::ItemSendsGeometryChanges,
true);
127 dialogTool->SetData(p->name(),
static_cast<QPointF
>(*p));
155 scene->addItem(spoint);
175 Q_ASSERT_X(not
draftBlockName.isEmpty(), Q_FUNC_INFO,
"name pattern piece is empty");
188 calcElement.appendChild(sPoint);
190 patternPiece.appendChild(calcElement);
197 qApp->getUndoStack()->push(addPP);
209 if (change == ItemPositionChange && scene())
213 static bool changeFinished =
true;
216 changeFinished =
false;
218 QPointF newPos = value.toPointF();
222 qApp->getUndoStack()->push(moveSP);
224 if (not viewList.isEmpty())
226 if (QGraphicsView *view = viewList.at(0))
228 const int xmargin = 50;
229 const int ymargin = 50;
232 const QRectF itemRect = mapToScene(boundingRect()).boundingRect();
235 if (itemRect.height() + 2*ymargin < viewRect.height() &&
236 itemRect.width() + 2*xmargin < viewRect.width())
238 view->ensureVisible(itemRect, xmargin, ymargin);
245 const QPointF cursorPosition = currentScene->
getScenePos();
246 view->ensureVisible(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10));
250 changeFinished =
true;
272 QPointF pos(
qApp->fromPixel(p->x()),
qApp->fromPixel(p->y()));
280 p->setX(
qApp->toPixel(pos.x()));
281 p->setY(
qApp->toPixel(pos.y()));
291 qCDebug(vTool,
"Deleting base point.");
292 qApp->getSceneView()->itemClicked(
nullptr);
295 qCDebug(vTool,
"Asking.");
298 qCDebug(vTool,
"User said no.");
303 qCDebug(vTool,
"Begin deleting.");
306 qApp->getUndoStack()->push(deletePP);
322 const QPointF p = dialogTool->GetPoint();
323 const QString
name = dialogTool->getPointName();
334 if (flags() & QGraphicsItem::ItemIsMovable)
345 if (flags() & QGraphicsItem::ItemIsMovable)
347 setCursor(QCursor());
354 if (flags() & QGraphicsItem::ItemIsMovable)
356 if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
367 if (flags() & QGraphicsItem::ItemIsMovable)
369 if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
402 const QString toolTipStr = QString(
"<table>"
403 "<tr> <td><b>%1:</b> %2</td> </tr>"
417 qCDebug(vTool,
"Context menu base point");
419 QGuiApplication::restoreOverrideCursor();
420 qCDebug(vTool,
"Restored overridden cursor");
427 qCDebug(vTool,
"Draft Block count > 1");
432 qCDebug(vTool,
"Draft Block count = 1");
438 qCDebug(vTool,
"Tool was deleted. Leave method immediately.");
442 qCDebug(vTool,
"Context menu was closed. Tool was not deleted.");
457 this->setFlag(QGraphicsItem::ItemIsMovable, move);
The DialogSinglePoint class dialog for ToolSinglePoint. Help create point and edit option.
virtual void LiteParseTree(const Document &parse)=0
static const QString TagPieces
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0
int draftBlockCount() const
static const QString TagModeling
static void AddTool(quint32 id, VDataTool *tool)
AddTool add tool to list tools.
static const QString TagDraftBlock
static const QString TagCalculation
virtual QString getTagName() const Q_DECL_OVERRIDE
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.
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
The VMainGraphicsScene class main scene.
QPointF getScenePos() const
static QRectF SceneVisibleArea(QGraphicsView *view)
The VPointF class keep data of point.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
virtual void refreshPointGeometry(const VPointF &point)
void NeedLiteParsing(const Document &parse)
const QString cursorArrowOpenHand
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX, int hotY)
const QString cursorArrowCloseHand