10 #include <QGraphicsItem> 11 #include <QGraphicsPathItem> 12 #include <QGraphicsPolygonItem> 13 #include <QGraphicsScene> 15 const double Z_VALUE = 100.0;
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 != 0) {
40 itemEllipse->brush());
41 m_ellipses.push_back (ghost);
45 QGraphicsPathItem *itemPath =
dynamic_cast<QGraphicsPathItem*
> (item);
51 m_paths.push_back (ghost);
55 QGraphicsPolygonItem *itemPolygon =
dynamic_cast<QGraphicsPolygonItem*
> (item);
56 if (itemPolygon != 0) {
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());
87 item->setData (DATA_KEY_GHOST, QVariant (
true));
88 item->setPen (ghost.
pen());
89 item->setBrush (ghost.
brush());
90 item->setZValue (Z_VALUE);
91 item->setVisible (
true);
94 for (i = 0; i < m_paths.count(); i++) {
97 QGraphicsPathItem *item = scene.addPath (ghost.
path(),
101 item->setData (DATA_KEY_GHOST, QVariant (
true));
102 item->setZValue (Z_VALUE);
103 item->setVisible (
true);
106 for (i = 0; i < m_polygons.count(); i++) {
109 QGraphicsPolygonItem *item = scene.addPolygon (ghost.
polygon(),
113 item->setData (DATA_KEY_GHOST, QVariant (
true));
114 item->setZValue (Z_VALUE);
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;
126 QVariant data = item->data (DATA_KEY_GHOST);
127 if (!data.isNull()) {
129 scene.removeItem (item);
void createGhosts(QGraphicsScene &scene)
Create ghosts from the path/rect/polygon lists.
QBrush brush() const
Get method for brush.
Ghost for a QGraphicsPathItem.
unsigned int coordSystemIndexToBeRestored() const
Coordinate system index that was active before the ghosts.
QPolygonF polygon() const
Get method for polygon.
QPen pen() const
Get method for pen.
QBrush brush() const
Get method for brush.
Ghosts(unsigned int coordSystemIndexToBeRestored)
Single constructor.
QPen pen() const
Get method for pen.
QRectF rect() const
Get method for bounding rectangle.
void captureGraphicsItems(QGraphicsScene &scene)
Take a snapshot of the graphics items.
Ghost for a QGraphicsPolygonItem.
void destroyGhosts(QGraphicsScene &scene)
Destory ghosts. Called at end of algorithm.
Ghost for a QGraphicsEllipseItem.
QPainterPath path() const
Get method for path.
QBrush brush() const
Get method for brush.
QPen pen() const
Get method for pen.