1 #include "floatimageobj.h"
5 /////////////////////////////////////////////////////////////////
7 /////////////////////////////////////////////////////////////////
9 int FloatImageObj::counter=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, LinkableMapObj* 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()));
47 originalFilename="no original name available";
52 void FloatImageObj::copy (FloatImageObj* other)
54 FloatObj::copy (other);
55 icon->copy (other->icon);
56 filename=other->filename;
57 saveInMap=other->saveInMap;
61 void FloatImageObj::setZ (const int &i)
67 int FloatImageObj::z ()
69 return qRound (icon->z());
72 void FloatImageObj::load (const QPixmap &pixmap)
75 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
78 filename="noname.png";
81 bool FloatImageObj::load (const QString &fn)
85 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
88 filetype=QPixmap::imageFormat (fn);
95 void FloatImageObj::save (const QString &fn, const char *format)
97 icon->save (fn,format);
100 void FloatImageObj::setOriginalFilename(const QString & fn)
105 QString FloatImageObj::getOriginalFilename()
107 return originalFilename;
110 void FloatImageObj::setVisibility(bool v)
112 LinkableMapObj::setVisibility(v);
114 icon->setVisibility(true);
116 icon->setVisibility(false);
119 void FloatImageObj::move (double x, double y)
122 icon->move (x+4,y+4);
126 void FloatImageObj::move (QPoint p)
131 void FloatImageObj::positionBBox()
136 void FloatImageObj::calcBBoxSize()
141 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
146 attribut("relPosX",QString().setNum(relPos.x(),10)) +
147 attribut("relPosY",QString().setNum(relPos.y(),10));
149 QString useOrientAttr;
151 useOrientAttr=attribut ("useOrientation","true");
153 useOrientAttr=attribut ("useOrientation","false");
155 QString saveInMapAttr;
157 saveInMapAttr=attribut ("saveInMap","true");
160 saveInMapAttr=attribut ("saveInMap","false");
164 exportAttr=attribut ("floatExport","true");
166 exportAttr=attribut ("floatExport","false");
168 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
171 // prevent saving as GIF
175 url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
177 // And really save the image
178 icon->save (tmpdir + "/" + url, filetype);
180 return singleElement ("floatimage",
186 attribut ("href",QString ("file:")+url)
190 void FloatImageObj::resetSaveCounter()
196 QRect FloatImageObj::getTotalBBox()
201 QRect FloatImageObj::getBBoxSizeWithChilds()
203 //FIXME abstract in linkablemapobj.h, not calculated
207 void FloatImageObj::calcBBoxSizeWithChilds()
209 //FIXME abstract in linkablemapobj.h
212 QString FloatImageObj::getSelectString()
217 if (parObj->getDepth()==0)
218 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
220 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));