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);
45 bbox.setSize (QSize(icon->size().width(), icon->size().height()));
46 clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
48 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;
64 saveInMap=other->saveInMap;
68 void FloatImageObj::setZ (const int &i)
74 int FloatImageObj::z ()
76 return qRound (icon->z());
79 void FloatImageObj::load (const QPixmap &pixmap)
82 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
83 clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
86 filename="noname.png";
89 bool FloatImageObj::load (const QString &fn)
93 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
96 filetype=QPixmap::imageFormat (fn);
103 void FloatImageObj::save (const QString &fn, const char *format)
105 icon->save (fn,format);
108 void FloatImageObj::setOriginalFilename(const QString & fn)
113 QString FloatImageObj::getOriginalFilename()
115 return originalFilename;
118 void FloatImageObj::setVisibility(bool v)
120 OrnamentedObj::setVisibility(v);
122 icon->setVisibility(true);
124 icon->setVisibility(false);
127 void FloatImageObj::move (double x, double y)
130 icon->move (x+4,y+4);
134 void FloatImageObj::move (QPoint p)
139 void FloatImageObj::positionBBox()
144 void FloatImageObj::calcBBoxSize()
149 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
151 if (hidden) return "";
155 QString useOrientAttr;
157 useOrientAttr=attribut ("useOrientation","true");
159 useOrientAttr=attribut ("useOrientation","false");
161 QString saveInMapAttr;
163 saveInMapAttr=attribut ("saveInMap","true");
166 saveInMapAttr=attribut ("saveInMap","false");
170 exportAttr=attribut ("floatExport","true");
172 exportAttr=attribut ("floatExport","false");
174 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
177 // prevent saving as GIF
181 url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
183 // And really save the image
184 icon->save (tmpdir + "/" + url, filetype);
186 return singleElement ("floatimage",
192 +attribut ("href",QString ("file:")+url)
196 void FloatImageObj::resetSaveCounter()
202 QRect FloatImageObj::getTotalBBox()
207 QRect FloatImageObj::getBBoxSizeWithChilds()
209 //FIXME abstract in linkablemapobj.h, not calculated
213 void FloatImageObj::calcBBoxSizeWithChilds()
215 //FIXME abstract in linkablemapobj.h
218 QString FloatImageObj::getSelectString()
223 if (parObj->getDepth()==0)
224 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
226 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));