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";
50 systemFlags->setShowFlags(false);
53 void FloatImageObj::copy (FloatImageObj* other)
55 FloatObj::copy (other);
56 icon->copy (other->icon);
57 filetype=other->filetype;
58 filename=other->filename;
59 originalFilename=other->originalFilename;
63 void FloatImageObj::setZValue (const int &i)
69 int FloatImageObj::z ()
71 return qRound (icon->zValue());
74 void FloatImageObj::load (const QPixmap &pixmap)
77 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
78 clickBox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
81 filename="No filename given";
84 bool FloatImageObj::load (const QString &fn)
86 QImageReader reader (fn);
89 if( reader.read (&img))
91 icon->setPixmap(QPixmap::fromImage(img));
92 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
95 filetype=reader.format();
96 setOriginalFilename (fn);
103 void FloatImageObj::save (const QString &fn, const QString &format)
105 icon->save (fn,qPrintable (format));
108 void FloatImageObj::setOriginalFilename(const QString & fn)
112 // Set short name, too. Search from behind:
113 int i=originalFilename.findRev("/");
114 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
117 QString FloatImageObj::getOriginalFilename()
119 return originalFilename;
122 void FloatImageObj::setVisibility(bool v)
124 OrnamentedObj::setVisibility(v);
126 icon->setVisibility(true);
128 icon->setVisibility(false);
131 void FloatImageObj::move (double x, double y)
134 icon->setPos (x+4,y+4);
138 void FloatImageObj::move (QPointF p)
140 OrnamentedObj::move (p.x(),p.y());
143 void FloatImageObj::positionBBox()
148 void FloatImageObj::calcBBoxSize()
153 QRectF FloatImageObj::getTotalBBox()
158 QRectF FloatImageObj::getBBoxSizeWithChildren()
160 //TODO abstract in linkablemapobj.h, not calculated
164 void FloatImageObj::calcBBoxSizeWithChildren()
166 //TODO abstract in linkablemapobj.h