5 #include "mainwindow.h"
11 extern Main *mainWindow;
13 Selection::Selection()
15 color= QColor(255,255,0);
18 Selection::~Selection()
22 void Selection::setModel (VymModel *m)
25 scene=model->getScene();
28 void Selection::copy(const Selection &other)
30 selectList=other.selectList;
31 lastSelectList=other.lastSelectList;
34 void Selection::clear()
37 lastSelectList.clear();
40 void Selection::update()
43 for (int i=0; i< selectList.count(); ++i)
45 bbox=selectList.at(i)->getBBox();
46 selboxList.at(i)->setRect (
48 bbox.width(), bbox.height());
49 selboxList.at(i)->setPen (color);
50 selboxList.at(i)->setBrush (color);
51 selboxList.at(i)->show();
53 model->getMapEditor()->getScene()->update();
56 void Selection::setColor (QColor col)
62 QColor Selection::getColor ()
67 bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet
69 if (!selectList.isEmpty()) unselect();
70 selectList.append (lmo);
71 QGraphicsRectItem *sb = scene->addRect(
75 sb->setZValue(Z_SELBOX);
77 selboxList.append (sb);
80 mainWindow->updateSatellites (model->getMapEditor() );
84 bool Selection::select (const QString &s) // TODO no multiselections yet
92 LinkableMapObj *lmo=model->findObjBySelect(s);
94 // Finally select the found object
105 bool Selection::reselect () // TODO no multiselections yet
107 if (!lastSelectList.isEmpty())
109 select (lastSelectList.first());
116 void Selection::unselect()
118 if (!selectList.isEmpty() )
120 for (int i=0; i< selectList.count(); ++i)
121 selectList.at(i)->unselect();
122 lastSelectList=selectList;
124 while (!selboxList.isEmpty() )
125 delete selboxList.takeFirst();
130 bool Selection::isEmpty()
132 return selectList.isEmpty();
135 uint Selection::count()
137 return selectList.count();
140 Selection::Type Selection::type() // TODO no multiselections yet
142 if (!selectList.isEmpty())
144 LinkableMapObj *sel=selectList.first();
145 if (typeid (*sel)==typeid (BranchObj)) return Branch;
146 if (typeid (*sel)==typeid (MapCenterObj)) return MapCenter;
147 if (typeid (*sel)==typeid (FloatImageObj)) return FloatImage;
152 LinkableMapObj* Selection::first()
154 if (!selectList.isEmpty())
155 return selectList.first();
160 LinkableMapObj* Selection::single()
162 if (selectList.count() == 1)
163 return selectList.first();
168 BranchObj* Selection::getBranch()
170 if (!selectList.isEmpty())
172 LinkableMapObj *sel=selectList.first();
173 if (typeid (*sel)==typeid (BranchObj) ||
174 typeid (*sel)==typeid (MapCenterObj))
175 return (BranchObj*)sel;
180 FloatImageObj* Selection::getFloatImage()
182 if (!selectList.isEmpty())
184 LinkableMapObj *sel=selectList.first();
185 if (typeid (*sel)==typeid (FloatImageObj))
186 return (FloatImageObj*)sel;
191 QString Selection::getSelectString()// TODO no multiselections yet
193 if (selectList.count()==1)
195 return model->getSelectString (selectList.first() );