1 #include "floatimageobj.h"
6 /////////////////////////////////////////////////////////////////
8 /////////////////////////////////////////////////////////////////
10 int FloatImageObj::counter=0; // make instance
13 FloatImageObj::FloatImageObj ():FloatObj()
15 // cout << "Const FloatImageObj ()\n";
21 FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c)
23 // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n";
29 FloatImageObj::FloatImageObj (QCanvas* c, LinkableMapObj* p):FloatObj(c,p)
31 // cout << "Const FloatImageObj (c,p)\n";
35 FloatImageObj::~FloatImageObj ()
37 // cout << "Destr FloatImageObj "<<this<<"\n";
41 void FloatImageObj::init ()
43 icon=new ImageObj (canvas);
44 icon->move (absPos.x(), absPos.y() );
45 icon->setVisibility (true);
46 bbox.setSize (QSize(icon->size().width(), icon->size().height()));
48 originalFilename="no original name available";
53 void FloatImageObj::copy (FloatImageObj* other)
55 FloatObj::copy (other);
56 icon->copy (other->icon);
57 filename=other->filename;
58 saveInMap=other->saveInMap;
62 void FloatImageObj::setZ (const int &i)
68 int FloatImageObj::z ()
70 return lrint (icon->z());
73 bool FloatImageObj::load (const QString &fn)
77 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
80 filetype=QPixmap::imageFormat (fn);
87 void FloatImageObj::save (const QString &fn, const char *format)
89 icon->save (fn,format);
92 void FloatImageObj::setOriginalFilename(const QString & fn)
97 QString FloatImageObj::getOriginalFilename()
99 return originalFilename;
102 void FloatImageObj::setVisibility(bool v)
104 LinkableMapObj::setVisibility(v);
106 icon->setVisibility(true);
108 icon->setVisibility(false);
111 void FloatImageObj::move (double x, double y)
114 icon->move (x+4,y+4);
118 void FloatImageObj::move (QPoint p)
123 void FloatImageObj::positionBBox()
128 void FloatImageObj::calcBBoxSize()
133 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
138 attribut("relPosX",QString().setNum(relPos.x(),10)) +
139 attribut("relPosY",QString().setNum(relPos.y(),10));
141 QString useOrientAttr;
143 useOrientAttr=attribut ("useOrientation","true");
145 useOrientAttr=attribut ("useOrientation","false");
147 QString saveInMapAttr;
149 saveInMapAttr=attribut ("saveInMap","true");
152 saveInMapAttr=attribut ("saveInMap","false");
156 exportAttr=attribut ("floatExport","true");
158 exportAttr=attribut ("floatExport","false");
160 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
163 // prevent saving as GIF
167 url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
169 // And really save the image
170 icon->save (tmpdir + "/" + url, filetype);
172 return singleElement ("floatimage",
178 attribut ("href",QString ("file:")+url)
182 void FloatImageObj::resetSaveCounter()
188 QRect FloatImageObj::getTotalBBox()
193 QRect FloatImageObj::getBBoxSizeWithChilds()
195 //FIXME abstract in linkablemapobj.h, not calculated
199 void FloatImageObj::calcBBoxSizeWithChilds()
201 //FIXME abstract in linkablemapobj.h
204 QString FloatImageObj::getSelectString()
209 if (parObj->getDepth()==0)
210 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
212 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));