]> git.sven.stormbind.net Git - sven/vym.git/blob - floatimageobj.cpp
44b189708aad07834c73a61fea26265c8111ad6c
[sven/vym.git] / floatimageobj.cpp
1 #include <QDebug>
2 #include <QImageReader>
3
4 #include "floatimageobj.h"
5 #include "branchobj.h"
6
7
8 /////////////////////////////////////////////////////////////////
9 // FloatImageObj 
10 /////////////////////////////////////////////////////////////////
11
12 FloatImageObj::FloatImageObj (QGraphicsItem * parent,TreeItem *ti):FloatObj(parent,ti)
13 {
14     //qDebug() << "Const FloatImageObj this="<<this<<"  ti="<<ti;
15     icon=new ImageObj (parent);
16     icon->setPos (absPos.x(), absPos.y() );
17     icon->setVisibility (true);
18     clickPoly=bbox;
19     useRelPos=true;
20
21     //Hide flags
22     systemFlags->setShowFlags(false);
23
24 //    setLinkStyle (LinkableMapObj::Parabel);
25 }
26
27 FloatImageObj::~FloatImageObj ()
28 {
29 //  qDebug() << "Destr FloatImageObj "<<this<<"";
30     delete(icon);
31 }
32
33 void FloatImageObj::copy (FloatImageObj* other)
34 {                   
35     FloatObj::copy (other);
36     icon->copy (other->icon);
37     positionBBox();
38 }
39
40 void FloatImageObj::setZValue (const int &i)
41 {
42
43 //    qDebug()<<"FIO::setZValue z="<<i;
44 //    qDebug()<<"  icon="<<icon;
45 //    qDebug()<<"  this="<<this;         
46     icon->setZValue (i);
47 }
48
49 int FloatImageObj::z ()
50 {
51     return qRound (icon->zValue());
52 }
53
54 void FloatImageObj::load (const QImage &img)
55 {
56     icon->load(QPixmap::fromImage(img));
57     if (!icon->parentItem() ) icon->setParentItem(this);  // Add to scene initially
58     bbox.setSize ( QSizeF(
59             icon->boundingRect().width(), 
60             icon->boundingRect().height()));
61     clickPoly=bbox;
62     positionBBox();
63 }
64
65 void FloatImageObj::setParObj (QGraphicsItem *p)
66 {
67     setParentItem (p);
68     icon->setParentItem (p);
69     parObj=(LinkableMapObj*)p;
70 /*
71     qDebug()<<"FIO::setParentItem";
72     qDebug()<<"  this="<<this;
73     qDebug()<<"  icon="<<icon;
74 */
75 }
76
77 void FloatImageObj::setVisibility(bool v)
78 {
79     OrnamentedObj::setVisibility(v);
80     if (v)
81         icon->setVisibility(true);
82     else
83         icon->setVisibility(false);
84 }
85
86 void FloatImageObj::moveCenter (double x, double y)
87 {
88     FloatObj::moveCenter(x, y);
89     icon->setPos(bbox.topLeft() );
90 }
91
92 void FloatImageObj::move (double x, double y)
93 {
94     FloatObj::move(x,y);
95     icon->setPos (x,y); 
96     positionBBox();
97 }
98
99 void FloatImageObj::move (QPointF p)
100 {
101     FloatImageObj::move (p.x(),p.y());
102 }
103
104 void FloatImageObj::positionBBox()
105 {
106     clickPoly=QPolygonF(bbox);
107     setZValue (dZ_FLOATIMG);
108 }
109
110 void FloatImageObj::calcBBoxSize()
111 {
112     // TODO
113 }
114
115 QRectF FloatImageObj::getBBoxSizeWithChildren()
116 {
117     //TODO abstract in linkablemapobj.h, not calculated
118     return bboxTotal;
119 }
120
121 void FloatImageObj::calcBBoxSizeWithChildren()
122 {
123     //TODO abstract in linkablemapobj.h
124 }
125