1 #include <QImageReader>
4 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
11 FloatImageObj::FloatImageObj ():FloatObj()
13 // cout << "Const FloatImageObj ()\n";
18 FloatImageObj::FloatImageObj (QGraphicsScene* s):FloatObj(s)
20 // cout << "Const FloatImageObj (s) called from MapCenterObj (s)\n";
25 FloatImageObj::FloatImageObj (QGraphicsScene *s, OrnamentedObj* p):FloatObj(s,p)
27 // cout << "Const FloatImageObj (c,p)\n";
31 FloatImageObj::~FloatImageObj ()
33 // cout << "Destr FloatImageObj "<<this<<"\n";
37 void FloatImageObj::init ()
39 icon=new ImageObj (scene);
40 icon->setPos (absPos.x(), absPos.y() );
41 icon->setVisibility (true);
42 setZValue (Z_FLOATIMG);
43 bbox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));
44 clickBox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));filename="";
45 originalFilename="no original name available";
51 systemFlags->setShowFlags(false);
54 void FloatImageObj::copy (FloatImageObj* other)
56 FloatObj::copy (other);
57 icon->copy (other->icon);
58 filetype=other->filetype;
59 filename=other->filename;
60 originalFilename=other->originalFilename;
61 saveInMap=other->saveInMap;
65 void FloatImageObj::setZValue (const int &i)
71 int FloatImageObj::z ()
73 return qRound (icon->zValue());
76 void FloatImageObj::load (const QPixmap &pixmap)
79 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
80 clickBox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
83 filename="No filename given";
86 bool FloatImageObj::load (const QString &fn)
88 QImageReader reader (fn);
91 if( reader.read (&img))
93 icon->setPixmap(QPixmap::fromImage(img));
94 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
97 filetype=reader.format();
98 setOriginalFilename (fn);
105 void FloatImageObj::save (const QString &fn, const QString &format)
107 icon->save (fn,qPrintable (format));
110 void FloatImageObj::setOriginalFilename(const QString & fn)
114 // Set short name, too. Search from behind:
115 int i=originalFilename.findRev("/");
116 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
119 QString FloatImageObj::getOriginalFilename()
121 return originalFilename;
124 void FloatImageObj::setVisibility(bool v)
126 OrnamentedObj::setVisibility(v);
128 icon->setVisibility(true);
130 icon->setVisibility(false);
133 void FloatImageObj::move (double x, double y)
136 icon->setPos (x+4,y+4);
140 void FloatImageObj::move (QPointF p)
142 OrnamentedObj::move (p.x(),p.y());
145 void FloatImageObj::positionBBox()
150 void FloatImageObj::calcBBoxSize()
155 QRectF FloatImageObj::getTotalBBox()
160 QRectF FloatImageObj::getBBoxSizeWithChildren()
162 //TODO abstract in linkablemapobj.h, not calculated
166 void FloatImageObj::calcBBoxSizeWithChildren()
168 //TODO abstract in linkablemapobj.h