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);
98 setOriginalFilename (fn);
105 void FloatImageObj::save (const QString &fn, const char *format)
107 icon->save (fn,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->move (x+4,y+4);
140 void FloatImageObj::move (QPoint p)
145 void FloatImageObj::positionBBox()
150 void FloatImageObj::calcBBoxSize()
155 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
157 if (hidden) return "";
161 QString useOrientAttr;
163 useOrientAttr=attribut ("useOrientation","true");
165 useOrientAttr=attribut ("useOrientation","false");
167 QString saveInMapAttr;
169 saveInMapAttr=attribut ("saveInMap","true");
172 saveInMapAttr=attribut ("saveInMap","false");
176 exportAttr=attribut ("floatExport","true");
178 exportAttr=attribut ("floatExport","false");
180 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
183 // prevent saving as GIF
187 url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
189 // And really save the image
190 icon->save (tmpdir + "/" + url, filetype);
192 QString nameAttr=attribut ("orgName",originalFilename);
194 return singleElement ("floatimage",
200 +attribut ("href",QString ("file:")+url)
205 void FloatImageObj::resetSaveCounter()
211 QRect FloatImageObj::getTotalBBox()
216 QRect FloatImageObj::getBBoxSizeWithChilds()
218 //FIXME abstract in linkablemapobj.h, not calculated
222 void FloatImageObj::calcBBoxSizeWithChilds()
224 //FIXME abstract in linkablemapobj.h
227 QString FloatImageObj::getSelectString()
232 if (parObj->getDepth()==0)
233 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
235 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));