46 #include <QVBoxLayout> 48 #include <QGraphicsSceneMouseEvent> 49 #include <QGraphicsGridLayout> 50 #include <QGraphicsLinearLayout> 52 #include "sceneTools.hh" 53 #include "sceneElement.hh" 54 #include "graphicsScene.hh" 56 #include "zoomButton.hh" 58 #include "functionDisplay.hh" 73 QRectF rect = scene_->sceneRect();
75 arrows_[0] =
new Arrow (_scene,
this, Arrow::North);
76 arrows_[1] =
new Arrow (_scene,
this, Arrow::South);
77 arrows_[2] =
new Arrow (_scene,
this, Arrow::East);
78 arrows_[3] =
new Arrow (_scene,
this, Arrow::West);
79 arrows_[4] =
new Arrow (_scene,
this, Arrow::Center);
81 QGraphicsGridLayout *aLayout =
new QGraphicsGridLayout;
82 aLayout->addItem (arrows_[0], 0, 1, Qt::AlignCenter);
83 aLayout->addItem (arrows_[1], 2, 1, Qt::AlignCenter);
84 aLayout->addItem (arrows_[2], 1, 2, Qt::AlignCenter);
85 aLayout->addItem (arrows_[3], 1, 0, Qt::AlignCenter);
86 aLayout->addItem (arrows_[4], 1, 1, Qt::AlignCenter);
88 trash_ =
new Trash (_scene,
this);
90 QGraphicsLinearLayout *zLayout =
new QGraphicsLinearLayout (Qt::Horizontal);
91 zoom_[0] =
new ZoomButton (_scene,
this, ZoomButton::In);
92 zoom_[1] =
new ZoomButton (_scene,
this, ZoomButton::Out);
93 zLayout->addItem (zoom_[0]);
94 zLayout->addItem (zoom_[1]);
97 scene_->addItem (fDisplay_);
100 connect (scene_, SIGNAL (sceneRectChanged (
const QRectF &)),
101 this, SLOT (sceneRectChanged (
const QRectF &)));
103 QGraphicsGridLayout *mLayout =
new QGraphicsGridLayout;
105 mLayout->addItem (aLayout, 0, 2, Qt::AlignTop | Qt::AlignRight);
106 mLayout->addItem (zLayout, 2, 0, Qt::AlignBottom | Qt::AlignLeft);
107 mLayout->addItem (trash_, 2, 2, Qt::AlignBottom | Qt::AlignRight);
108 mLayout->setColumnStretchFactor (1, 1);
109 mLayout->setRowStretchFactor (1, 1);
110 mLayout->setContentsMargins (7, 7, 7, 7);
125 void SceneTools::sceneRectChanged (
const QRectF &_rect)
129 fDisplay_->setPos(_rect.topLeft ());
136 void SceneTools::updateArrows ()
139 QRectF rect = scene_->sceneRect();
141 if (bb.top () < rect.top ())
142 arrows_[0]->setHighlight (
true);
146 if (bb.bottom () > rect.bottom ())
147 arrows_[1]->setHighlight (
true);
151 if (bb.right () > rect.right ())
152 arrows_[2]->setHighlight (
true);
156 if (bb.left () < rect.left ())
157 arrows_[3]->setHighlight (
true);
161 if (rect.center () != bb.center ())
162 arrows_[4]->setHighlight (
true);
172 for (
unsigned int i = 0; i < 5; i++)
174 if (arrows_[i]->contains (arrows_[i]->mapFromScene (_pos)))
177 arrows_[i]->
reset ();
180 for (
unsigned int i = 0; i < 2; i++)
182 if (zoom_[i]->contains (zoom_[i]->mapFromScene (_pos)))
188 if (trash_->contains (trash_->mapFromScene (_pos)))
199 for (
unsigned int i = 0; i < 5; i++)
201 arrows_[i]->
reset ();
203 for (
unsigned int i = 0; i < 2; i++)
209 if (trash_->contains (trash_->mapFromScene (_pos)))
void deactivate()
Makes the trash transparent (will be called of an element is moved away from this widget) ...
void activate()
Makes the trash opaque (will be called of an element is moved above this widget)
bool removeElement(SceneElement *_element)
Remove the element from the scene.
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 reset()
Stop the timer.
void setHighlight(bool _highlight)
Highlights the widget if the scene can be moved in this direction.