52 #include <QVBoxLayout> 54 #include <QGraphicsSceneMouseEvent> 55 #include <QGraphicsGridLayout> 56 #include <QGraphicsLinearLayout> 58 #include "sceneTools.hh" 59 #include "sceneElement.hh" 60 #include "graphicsScene.hh" 62 #include "zoomButton.hh" 64 #include "functionDisplay.hh" 79 QRectF rect = scene_->sceneRect();
81 arrows_[0] =
new Arrow (_scene,
this, Arrow::North);
82 arrows_[1] =
new Arrow (_scene,
this, Arrow::South);
83 arrows_[2] =
new Arrow (_scene,
this, Arrow::East);
84 arrows_[3] =
new Arrow (_scene,
this, Arrow::West);
85 arrows_[4] =
new Arrow (_scene,
this, Arrow::Center);
87 QGraphicsGridLayout *aLayout =
new QGraphicsGridLayout;
88 aLayout->addItem (arrows_[0], 0, 1, Qt::AlignCenter);
89 aLayout->addItem (arrows_[1], 2, 1, Qt::AlignCenter);
90 aLayout->addItem (arrows_[2], 1, 2, Qt::AlignCenter);
91 aLayout->addItem (arrows_[3], 1, 0, Qt::AlignCenter);
92 aLayout->addItem (arrows_[4], 1, 1, Qt::AlignCenter);
94 trash_ =
new Trash (_scene,
this);
96 QGraphicsLinearLayout *zLayout =
new QGraphicsLinearLayout (Qt::Horizontal);
97 zoom_[0] =
new ZoomButton (_scene,
this, ZoomButton::In);
98 zoom_[1] =
new ZoomButton (_scene,
this, ZoomButton::Out);
99 zLayout->addItem (zoom_[0]);
100 zLayout->addItem (zoom_[1]);
103 scene_->addItem (fDisplay_);
106 connect (scene_, SIGNAL (sceneRectChanged (
const QRectF &)),
107 this, SLOT (sceneRectChanged (
const QRectF &)));
109 QGraphicsGridLayout *mLayout =
new QGraphicsGridLayout;
111 mLayout->addItem (aLayout, 0, 2, Qt::AlignTop | Qt::AlignRight);
112 mLayout->addItem (zLayout, 2, 0, Qt::AlignBottom | Qt::AlignLeft);
113 mLayout->addItem (trash_, 2, 2, Qt::AlignBottom | Qt::AlignRight);
114 mLayout->setColumnStretchFactor (1, 1);
115 mLayout->setRowStretchFactor (1, 1);
116 mLayout->setContentsMargins (7, 7, 7, 7);
131 void SceneTools::sceneRectChanged (
const QRectF &_rect)
135 fDisplay_->setPos(_rect.topLeft ());
142 void SceneTools::updateArrows ()
145 QRectF rect = scene_->sceneRect();
147 if (bb.top () < rect.top ())
148 arrows_[0]->setHighlight (
true);
152 if (bb.bottom () > rect.bottom ())
153 arrows_[1]->setHighlight (
true);
157 if (bb.right () > rect.right ())
158 arrows_[2]->setHighlight (
true);
162 if (bb.left () < rect.left ())
163 arrows_[3]->setHighlight (
true);
167 if (rect.center () != bb.center ())
168 arrows_[4]->setHighlight (
true);
178 for (
unsigned int i = 0; i < 5; i++)
180 if (arrows_[i]->contains (arrows_[i]->mapFromScene (_pos)))
183 arrows_[i]->
reset ();
186 for (
unsigned int i = 0; i < 2; i++)
188 if (zoom_[i]->contains (zoom_[i]->mapFromScene (_pos)))
194 if (trash_->contains (trash_->mapFromScene (_pos)))
205 for (
unsigned int i = 0; i < 5; i++)
207 arrows_[i]->
reset ();
209 for (
unsigned int i = 0; i < 2; i++)
215 if (trash_->contains (trash_->mapFromScene (_pos)))
void activate()
Makes the trash opaque (will be called of an element is moved above this widget)
void reset()
Stop the timer.
void mouseMove(QPointF _pos)
Handles mouse movement (will be called by the scene, if the mouse with a draged element is moved) ...
QRectF elementsBoundingRect()
Bounding rectangle of all scene elements.
void activate()
Activates the timer for movement (will be called if an element is moved above)
void setHighlight(bool _highlight)
Highlights the widget if the scene can be moved in this direction.
void deactivate()
Stop the timer.
SceneTools(GraphicsScene *_scene)
Constructor.
void deactivate()
Makes the trash transparent (will be called of an element is moved away from this widget) ...
void mouseRelease(QPointF _pos, QGraphicsItem *_item)
Handles mouse release (will be called by the scene, if the element is dropped)
void activate(QPointF _pos)
Activates the timer for zoom with center at _pos (will be called if an element is moved above) ...
Scene zoom in/out widget.
bool removeElement(SceneElement *_element)
Remove the element from the scene.