50 #ifndef VSI_GRAPHICSSCENE_HH 51 #define VSI_GRAPHICSSCENE_HH 55 #include <QGraphicsScene> 57 #include <QDomDocument> 58 #include <QDomElement> 62 class QGraphicsRectItem;
76 class ElementFunction;
105 void moveElements (qreal _dx, qreal _dy,
bool _selected =
false);
132 const QList<SceneElement *>&
elements ()
const;
135 QString
generateCode (QString &errors,
bool _codeOnly =
false);
141 void saveToXml (QDomDocument &_doc, QDomElement &_root);
166 virtual void drawBackground(QPainter *_painter,
const QRectF &_rect);
169 void dragEnterEvent (QGraphicsSceneDragDropEvent *_event);
170 void dragLeaveEvent (QGraphicsSceneDragDropEvent *_event);
171 void dragMoveEvent (QGraphicsSceneDragDropEvent *_event);
172 void dropEvent (QGraphicsSceneDragDropEvent *_event);
175 void mousePressEvent (QGraphicsSceneMouseEvent *_event);
176 void mouseMoveEvent (QGraphicsSceneMouseEvent *_event);
177 void mouseReleaseEvent (QGraphicsSceneMouseEvent *_event);
181 void updateConnections ();
184 void sceneResized (
const QRectF &_rect);
189 QString updateConnections (
SceneElement *_from,
bool _isStart);
192 bool validMimeData (
const QMimeData *);
195 QString mimeDataElementName (
const QMimeData *);
198 QPoint mimeDataPoint (
const QMimeData *);
201 void loadElement (QXmlQuery &_xml);
204 void loadConnection (QXmlQuery &_xml);
207 QList<SceneElement *> getAllElements ();
220 QGraphicsRectItem *selection_;
221 QPointF selectionStart_;
222 bool selectionActive_;
QString generateCode(QString &errors, bool _codeOnly=false)
Generate textual script code (_codeOnly = only pure code block)
void loadFromXml(QXmlQuery &_xml)
Load from xml.
ElementArea * elementArea() const
Element area.
GraphicsScene(VSI::Context *_ctx, ElementFunction *_function=NULL)
Constructor.
void scaleElements(qreal _delta)
Scale all elements with scaling center in the center of the scene.
void addElement(SceneElement *_element)
Add the element to the scene.
void saveToXml(QDomDocument &_doc, QDomElement &_root)
Save to xml.
QRectF elementsBoundingRect()
Bounding rectangle of all scene elements.
void contentChanged()
Informs about content changes.
GraphicsView * graphicsView()
Graphics view of the scene.
~GraphicsScene()
Destructor.
void contentChange()
handle content changes
qreal getNewZ()
Returns a new Z value that is above all elements.
void moveElements(qreal _dx, qreal _dy, bool _selected=false)
Moves all elements.
void mouseMove(QPointF _pos)
Redirect mouse movement to tools area.
const QList< SceneElement * > & elements() const
Scene elements.
void mouseRelease(QPointF _pos, QGraphicsItem *_item)
Redirect mouse release to tools area.
void setActiveConnection(Connection *_conn)
Sets the active connection.
void clearScene(bool _start=false)
clear the whole scene (_start = keep start element)
WayFind * wayFind()
WayFind object.
bool removeElement(SceneElement *_element)
Remove the element from the scene.