1 #include <QImageReader>
4 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
12 FloatImageObj::FloatImageObj ():FloatObj()
14 // cout << "Const FloatImageObj ()\n";
20 FloatImageObj::FloatImageObj (QGraphicsScene* s,TreeItem *ti):FloatObj(s,ti)
22 //cout << "Const FloatImageObj s="<<s<<" ti="<<ti<<endl;
28 FloatImageObj::FloatImageObj (QGraphicsScene *s, OrnamentedObj* p):FloatObj(s,p)
30 // cout << "Const FloatImageObj (c,p)\n";
35 FloatImageObj::~FloatImageObj ()
37 // cout << "Destr FloatImageObj "<<this<<"\n";
41 void FloatImageObj::init ()
43 icon=new ImageObj (scene);
44 icon->setPos (absPos.x(), absPos.y() );
45 icon->setVisibility (true);
46 setZValue (Z_FLOATIMG);
47 bbox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));
48 clickBox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));filename="";
49 originalFilename="no original name available";
54 systemFlags->setShowFlags(false);
57 void FloatImageObj::copy (FloatImageObj* other)
59 FloatObj::copy (other);
60 icon->copy (other->icon);
61 filetype=other->filetype;
62 filename=other->filename;
63 originalFilename=other->originalFilename;
67 void FloatImageObj::setZValue (const int &i)
73 int FloatImageObj::z ()
75 return qRound (icon->zValue());
78 void FloatImageObj::load (const QPixmap &pixmap)
81 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
82 clickBox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
85 filename="No filename given";
88 bool FloatImageObj::load (const QString &fn)
90 QImageReader reader (fn);
93 if( reader.read (&img))
95 icon->setPixmap(QPixmap::fromImage(img));
96 bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8));
99 filetype=reader.format();
100 setOriginalFilename (fn);
107 void FloatImageObj::save (const QString &fn, const QString &format)
109 icon->save (fn,qPrintable (format));
112 void FloatImageObj::setOriginalFilename(const QString & fn)
116 // Set short name, too. Search from behind:
117 int i=originalFilename.findRev("/");
118 if (i>=0) originalFilename=originalFilename.remove (0,i+1);
121 QString FloatImageObj::getOriginalFilename()
123 return originalFilename;
126 void FloatImageObj::setVisibility(bool v)
128 OrnamentedObj::setVisibility(v);
130 icon->setVisibility(true);
132 icon->setVisibility(false);
135 void FloatImageObj::move (double x, double y)
138 icon->setPos (x+4,y+4);
142 void FloatImageObj::move (QPointF p)
144 OrnamentedObj::move (p.x(),p.y());
147 void FloatImageObj::positionBBox()
152 void FloatImageObj::calcBBoxSize()
157 QRectF FloatImageObj::getTotalBBox()
162 QRectF FloatImageObj::getBBoxSizeWithChildren()
164 //TODO abstract in linkablemapobj.h, not calculated
168 void FloatImageObj::calcBBoxSizeWithChildren()
170 //TODO abstract in linkablemapobj.h