10#include <QGraphicsItem>
11#include <QGraphicsPathItem>
12#include <QGraphicsPolygonItem>
13#include <QGraphicsScene>
18 m_coordSystemIndexToBeRestored (coordSystemIndexToBeRestored)
28 QList<QGraphicsItem*> items = scene.items();
30 QList<QGraphicsItem*>::iterator itr;
31 for (itr = items.begin(); itr != items.end(); itr++) {
33 QGraphicsItem *item = *itr;
35 QGraphicsEllipseItem *itemEllipse =
dynamic_cast<QGraphicsEllipseItem*
> (item);
36 if (itemEllipse !=
nullptr) {
40 itemEllipse->brush());
41 m_ellipses.push_back (ghost);
45 QGraphicsPathItem *itemPath =
dynamic_cast<QGraphicsPathItem*
> (item);
46 if (itemPath !=
nullptr) {
51 m_paths.push_back (ghost);
55 QGraphicsPolygonItem *itemPolygon =
dynamic_cast<QGraphicsPolygonItem*
> (item);
56 if (itemPolygon !=
nullptr) {
59 QPolygonF polygon = itemPolygon->polygon();
60 polygon.translate (itemPolygon->pos ());
64 itemPolygon->brush());
65 m_polygons.push_back (ghost);
75 return m_coordSystemIndexToBeRestored;
82 for (i = 0; i < m_ellipses.count(); i++) {
85 QGraphicsEllipseItem *item = scene.addEllipse (ghost.
rect());
88 item->setPen (ghost.
pen());
89 item->setBrush (ghost.
brush());
91 item->setVisible (
true);
94 for (i = 0; i < m_paths.count(); i++) {
97 QGraphicsPathItem *item = scene.addPath (ghost.
path(),
103 item->setVisible (
true);
106 for (i = 0; i < m_polygons.count(); i++) {
109 QGraphicsPolygonItem *item = scene.addPolygon (ghost.
polygon(),
115 item->setVisible (
true);
121 QList<QGraphicsItem*> items = scene.items();
122 QList<QGraphicsItem*>::iterator itr;
123 for (itr = items.begin(); itr != items.end(); itr++) {
125 QGraphicsItem *item = *itr;
127 if (!data.isNull()) {
129 scene.removeItem (item);
@ DATA_KEY_GHOST
True if item has changed since last mousePressEvent
Ghost for a QGraphicsEllipseItem.
QRectF rect() const
Get method for bounding rectangle.
QPen pen() const
Get method for pen.
QBrush brush() const
Get method for brush.
Ghost for a QGraphicsPathItem.
QPainterPath path() const
Get method for path.
QBrush brush() const
Get method for brush.
QPen pen() const
Get method for pen.
Ghost for a QGraphicsPolygonItem.
QPen pen() const
Get method for pen.
QPolygonF polygon() const
Get method for polygon.
QBrush brush() const
Get method for brush.
unsigned int coordSystemIndexToBeRestored() const
Coordinate system index that was active before the ghosts.
void createGhosts(QGraphicsScene &scene)
Create ghosts from the path/rect/polygon lists.
void captureGraphicsItems(QGraphicsScene &scene)
Take a snapshot of the graphics items.
Ghosts(unsigned int coordSystemIndexToBeRestored)
Single constructor.
void destroyGhosts(QGraphicsScene &scene)
Destory ghosts. Called at end of algorithm.