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 <<<<<<< floatimageobj.cpp
70 return qRound (icon->z());
73 void FloatImageObj::load (const QPixmap &pixmap)
76 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
79 filename="noname.png";
81 return qRound (icon->z());
85 bool FloatImageObj::load (const QString &fn)
89 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
92 filetype=QPixmap::imageFormat (fn);
99 void FloatImageObj::save (const QString &fn, const char *format)
101 icon->save (fn,format);
104 void FloatImageObj::setOriginalFilename(const QString & fn)
109 QString FloatImageObj::getOriginalFilename()
111 return originalFilename;
114 void FloatImageObj::setVisibility(bool v)
116 LinkableMapObj::setVisibility(v);
118 icon->setVisibility(true);
120 icon->setVisibility(false);
123 void FloatImageObj::move (double x, double y)
126 icon->move (x+4,y+4);
130 void FloatImageObj::move (QPoint p)
135 void FloatImageObj::positionBBox()
140 void FloatImageObj::calcBBoxSize()
145 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
150 attribut("relPosX",QString().setNum(relPos.x(),10)) +
151 attribut("relPosY",QString().setNum(relPos.y(),10));
153 QString useOrientAttr;
155 useOrientAttr=attribut ("useOrientation","true");
157 useOrientAttr=attribut ("useOrientation","false");
159 QString saveInMapAttr;
161 saveInMapAttr=attribut ("saveInMap","true");
164 saveInMapAttr=attribut ("saveInMap","false");
168 exportAttr=attribut ("floatExport","true");
170 exportAttr=attribut ("floatExport","false");
172 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
175 // prevent saving as GIF
179 url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
181 // And really save the image
182 icon->save (tmpdir + "/" + url, filetype);
184 return singleElement ("floatimage",
190 attribut ("href",QString ("file:")+url)
194 void FloatImageObj::resetSaveCounter()
200 QRect FloatImageObj::getTotalBBox()
205 QRect FloatImageObj::getBBoxSizeWithChilds()
207 //FIXME abstract in linkablemapobj.h, not calculated
211 void FloatImageObj::calcBBoxSizeWithChilds()
213 //FIXME abstract in linkablemapobj.h
216 QString FloatImageObj::getSelectString()
221 if (parObj->getDepth()==0)
222 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
224 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));