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, 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()));
46 clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
48 originalFilename="no original name available";
54 void FloatImageObj::copy (FloatImageObj* other)
56 FloatObj::copy (other);
57 icon->copy (other->icon);
58 filetype=other->filetype;
59 filename=other->filename;
60 originalFilename=other->originalFilename;
61 saveInMap=other->saveInMap;
65 void FloatImageObj::setZ (const int &i)
71 int FloatImageObj::z ()
73 return qRound (icon->z());
76 void FloatImageObj::load (const QPixmap &pixmap)
79 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
80 clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
83 filename="noname.png";
86 bool FloatImageObj::load (const QString &fn)
90 bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
93 filetype=QPixmap::imageFormat (fn);
100 void FloatImageObj::save (const QString &fn, const char *format)
102 icon->save (fn,format);
105 void FloatImageObj::setOriginalFilename(const QString & fn)
110 QString FloatImageObj::getOriginalFilename()
112 return originalFilename;
115 void FloatImageObj::setVisibility(bool v)
117 LinkableMapObj::setVisibility(v);
119 icon->setVisibility(true);
121 icon->setVisibility(false);
124 void FloatImageObj::move (double x, double y)
127 icon->move (x+4,y+4);
131 void FloatImageObj::move (QPoint p)
136 void FloatImageObj::positionBBox()
141 void FloatImageObj::calcBBoxSize()
146 QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
151 attribut("relPosX",QString().setNum(relPos.x(),10)) +
152 attribut("relPosY",QString().setNum(relPos.y(),10));
154 QString linkAttr=getLinkAttr();
156 QString useOrientAttr;
158 useOrientAttr=attribut ("useOrientation","true");
160 useOrientAttr=attribut ("useOrientation","false");
162 QString saveInMapAttr;
164 saveInMapAttr=attribut ("saveInMap","true");
167 saveInMapAttr=attribut ("saveInMap","false");
171 exportAttr=attribut ("floatExport","true");
173 exportAttr=attribut ("floatExport","false");
175 QString zAttr=attribut ("zPlane",QString().setNum(zPlane));
178 // prevent saving as GIF
182 url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
184 // And really save the image
185 icon->save (tmpdir + "/" + url, filetype);
187 return singleElement ("floatimage",
194 attribut ("href",QString ("file:")+url)
198 void FloatImageObj::resetSaveCounter()
204 QRect FloatImageObj::getTotalBBox()
209 QRect FloatImageObj::getBBoxSizeWithChilds()
211 //FIXME abstract in linkablemapobj.h, not calculated
215 void FloatImageObj::calcBBoxSizeWithChilds()
217 //FIXME abstract in linkablemapobj.h
220 QString FloatImageObj::getSelectString()
225 if (parObj->getDepth()==0)
226 s= "fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));
228 s= ((BranchObj*)(parObj))->getSelectString() + ",fi:" + QString("%1").arg( ((BranchObj*)(parObj))->getFloatImageNum(this));