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 bool FloatImageObj::load (const QString &fn)
76 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
79 filetype=QPixmap::imageFormat (fn);
86 void FloatImageObj::save (const QString &fn, const char *format)
88 icon->save (fn,format);
91 void FloatImageObj::setOriginalFilename(const QString & fn)
96 QString FloatImageObj::getOriginalFilename()
98 return originalFilename;
101 void FloatImageObj::setVisibility(bool v)
103 LinkableMapObj::setVisibility(v);
105 icon->setVisibility(true);
107 icon->setVisibility(false);
110 void FloatImageObj::move (double x, double y)
113 icon->move (x+4,y+4);
117 void FloatImageObj::move (QPoint p)
122 void FloatImageObj::positionBBox()
127 void FloatImageObj::calcBBoxSize()
132 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
137 attribut("relPosX",QString().setNum(relPos.x(),10)) +
138 attribut("relPosY",QString().setNum(relPos.y(),10));
140 QString useOrientAttr;
142 useOrientAttr=attribut ("useOrientation","true");
144 useOrientAttr=attribut ("useOrientation","false");
146 QString saveInMapAttr;
148 saveInMapAttr=attribut ("saveInMap","true");
151 saveInMapAttr=attribut ("saveInMap","false");
155 exportAttr=attribut ("floatExport","true");
157 exportAttr=attribut ("floatExport","false");
159 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
162 // prevent saving as GIF
166 url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
168 // And really save the image
169 icon->save (tmpdir + "/" + url, filetype);
171 return singleElement ("floatimage",
177 attribut ("href",QString ("file:")+url)
181 void FloatImageObj::resetSaveCounter()
187 QRect FloatImageObj::getTotalBBox()
192 QRect FloatImageObj::getBBoxSizeWithChilds()
194 //FIXME abstract in linkablemapobj.h, not calculated
198 void FloatImageObj::calcBBoxSizeWithChilds()
200 //FIXME abstract in linkablemapobj.h
203 QString FloatImageObj::getSelectString()
208 if (parObj->getDepth()==0)
209 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
211 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));