3 /////////////////////////////////////////////////////////////////
5 /////////////////////////////////////////////////////////////////
8 // cout << "Const FlagObj ()\n";
12 FlagObj::FlagObj(QGraphicsScene* s):MapObj(s)
14 // cout << "Const FlagObj this="<<this<<" scene="<<s<<endl;
18 FlagObj::FlagObj (FlagObj* io)
23 FlagObj::FlagObj (Flag* f)
27 icon->load(f->getPixmap());
32 // cout << "Destr FlagObj this="<<this <<" " << qPrintable(name) << "\n";
33 if (icon) delete (icon);
41 icon=new ImageObj (scene);
42 icon->setPos (absPos.x(), absPos.y() );
47 void FlagObj::copy (FlagObj* other)
53 icon->copy(other->icon);
54 setVisibility (other->isVisibleObj() );
57 void FlagObj::move(double x, double y)
64 void FlagObj::moveBy(double x, double y)
66 move (x+absPos.x(),y+absPos.y() );
69 void FlagObj::setVisibility (bool v)
71 MapObj::setVisibility(v);
73 icon->setVisibility(true);
75 icon->setVisibility(false);
78 void FlagObj::load (const QString &fn)
85 void FlagObj::load (const QPixmap &pm)
92 void FlagObj::setName(const QString &n)
97 const QString FlagObj::getName()
102 void FlagObj::setAlwaysVisible(bool b)
107 bool FlagObj::isAlwaysVisible()
112 bool FlagObj::isActive()
117 void FlagObj::toggle()
125 void FlagObj::activate()
128 // only show icon, if flag itself is visible
131 icon->setVisibility (true);
136 void FlagObj::deactivate()
139 // if flag itself is invisible we don't need to call
142 icon->setVisibility (false);
147 void FlagObj::saveToDir (const QString &tmpdir, const QString &prefix)
149 QString fn=tmpdir + prefix + name + ".png";
150 icon->save (fn,"PNG");
153 void FlagObj::positionBBox()
155 bbox.moveTopLeft (absPos );
156 clickBox.moveTopLeft (absPos );
159 void FlagObj::calcBBoxSize()
161 if (visible && state)
162 bbox.setSize ( QSizeF(
163 icon->boundingRect().width(),
164 icon->boundingRect().height() ) );
166 bbox.setSize (QSizeF(0,0));
167 clickBox.setSize (bbox.size());