1 #include "floatimageobj.h"
5 /////////////////////////////////////////////////////////////////
7 /////////////////////////////////////////////////////////////////
9 uint FloatImageObj::saveCounter=0; // make instance
12 FloatImageObj::FloatImageObj ():FloatObj()
14 // cout << "Const FloatImageObj ()\n";
20 FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c)
22 // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n";
28 FloatImageObj::FloatImageObj (QCanvas* c, OrnamentedObj* p):FloatObj(c,p)
30 // cout << "Const FloatImageObj (c,p)\n";
34 FloatImageObj::~FloatImageObj ()
36 // cout << "Destr FloatImageObj "<<this<<"\n";
40 void FloatImageObj::init ()
42 icon=new ImageObj (canvas);
43 icon->move (absPos.x(), absPos.y() );
44 icon->setVisibility (true);
46 bbox.setSize (QSize(icon->size().width(), icon->size().height()));
47 clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
49 originalFilename="no original name available";
55 systemFlags->setShowFlags(false);
58 void FloatImageObj::copy (FloatImageObj* other)
60 FloatObj::copy (other);
61 icon->copy (other->icon);
62 filetype=other->filetype;
63 filename=other->filename;
64 originalFilename=other->originalFilename;
65 saveInMap=other->saveInMap;
69 void FloatImageObj::setZ (const int &i)
75 int FloatImageObj::z ()
77 return qRound (icon->z());
80 void FloatImageObj::load (const QPixmap &pixmap)
83 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
84 clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
87 filename="noname.png";
90 bool FloatImageObj::load (const QString &fn)
94 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
97 filetype=QPixmap::imageFormat (fn);
104 void FloatImageObj::save (const QString &fn, const char *format)
106 icon->save (fn,format);
109 void FloatImageObj::setOriginalFilename(const QString & fn)
114 QString FloatImageObj::getOriginalFilename()
116 return originalFilename;
119 void FloatImageObj::setVisibility(bool v)
121 OrnamentedObj::setVisibility(v);
123 icon->setVisibility(true);
125 icon->setVisibility(false);
128 void FloatImageObj::move (double x, double y)
131 icon->move (x+4,y+4);
135 void FloatImageObj::move (QPoint p)
140 void FloatImageObj::positionBBox()
145 void FloatImageObj::calcBBoxSize()
150 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
152 if (hidden) return "";
156 QString useOrientAttr;
158 useOrientAttr=attribut ("useOrientation","true");
160 useOrientAttr=attribut ("useOrientation","false");
162 QString saveInMapAttr;
164 saveInMapAttr=attribut ("saveInMap","true");
167 saveInMapAttr=attribut ("saveInMap","false");
171 exportAttr=attribut ("floatExport","true");
173 exportAttr=attribut ("floatExport","false");
175 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
178 // prevent saving as GIF
182 url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
184 // And really save the image
185 icon->save (tmpdir + "/" + url, filetype);
187 return singleElement ("floatimage",
193 +attribut ("href",QString ("file:")+url)
197 void FloatImageObj::resetSaveCounter()
203 QRect FloatImageObj::getTotalBBox()
208 QRect FloatImageObj::getBBoxSizeWithChilds()
210 //FIXME abstract in linkablemapobj.h, not calculated
214 void FloatImageObj::calcBBoxSizeWithChilds()
216 //FIXME abstract in linkablemapobj.h
219 QString FloatImageObj::getSelectString()
224 if (parObj->getDepth()==0)
225 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
227 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));