author | insilmaril |
Wed, 01 Feb 2006 16:39:06 +0000 | |
changeset 202 | c6945404eb48 |
parent 140 | cf1e44192f1e |
child 366 | e95081c21da2 |
permissions | -rw-r--r-- |
insilmaril@0 | 1 |
#include "frameobj.h" |
insilmaril@0 | 2 |
|
insilmaril@0 | 3 |
#include <qcolor.h> |
insilmaril@0 | 4 |
|
insilmaril@0 | 5 |
///////////////////////////////////////////////////////////////// |
insilmaril@0 | 6 |
// FrameObj |
insilmaril@0 | 7 |
///////////////////////////////////////////////////////////////// |
insilmaril@0 | 8 |
FrameObj::FrameObj() : MapObj() |
insilmaril@0 | 9 |
{ |
insilmaril@0 | 10 |
// cout << "Const FrameObj ()\n"; |
insilmaril@0 | 11 |
init (); |
insilmaril@0 | 12 |
} |
insilmaril@0 | 13 |
|
insilmaril@0 | 14 |
FrameObj::FrameObj(QCanvas* c) :MapObj(c) |
insilmaril@0 | 15 |
{ |
insilmaril@0 | 16 |
// cout << "Const FrameObj\n"; |
insilmaril@0 | 17 |
init (); |
insilmaril@0 | 18 |
} |
insilmaril@0 | 19 |
|
insilmaril@0 | 20 |
FrameObj::~FrameObj() |
insilmaril@0 | 21 |
{ |
insilmaril@0 | 22 |
clear(); |
insilmaril@0 | 23 |
} |
insilmaril@0 | 24 |
|
insilmaril@0 | 25 |
void FrameObj::init() |
insilmaril@0 | 26 |
{ |
insilmaril@0 | 27 |
type=NoFrame; |
insilmaril@0 | 28 |
border=0; |
insilmaril@0 | 29 |
} |
insilmaril@0 | 30 |
|
insilmaril@0 | 31 |
void FrameObj::clear() |
insilmaril@0 | 32 |
{ |
insilmaril@0 | 33 |
switch (type) |
insilmaril@0 | 34 |
{ |
insilmaril@0 | 35 |
case NoFrame: |
insilmaril@0 | 36 |
break; |
insilmaril@0 | 37 |
case Rectangle: |
insilmaril@0 | 38 |
delete rectFrame; |
insilmaril@0 | 39 |
break; |
insilmaril@0 | 40 |
} |
insilmaril@0 | 41 |
type=NoFrame; |
insilmaril@0 | 42 |
border=0; |
insilmaril@0 | 43 |
} |
insilmaril@0 | 44 |
|
insilmaril@0 | 45 |
void FrameObj::move(double x, double y) |
insilmaril@0 | 46 |
{ |
insilmaril@0 | 47 |
switch (type) |
insilmaril@0 | 48 |
{ |
insilmaril@0 | 49 |
case NoFrame: |
insilmaril@0 | 50 |
break; |
insilmaril@0 | 51 |
case Rectangle: |
insilmaril@0 | 52 |
rectFrame->move (x,y); |
insilmaril@0 | 53 |
break; |
insilmaril@0 | 54 |
} |
insilmaril@0 | 55 |
} |
insilmaril@0 | 56 |
|
insilmaril@0 | 57 |
void FrameObj::moveBy(double x, double y) |
insilmaril@0 | 58 |
{ |
insilmaril@0 | 59 |
MapObj::moveBy (x,y); |
insilmaril@0 | 60 |
} |
insilmaril@0 | 61 |
|
insilmaril@0 | 62 |
void FrameObj::positionBBox() |
insilmaril@0 | 63 |
{ |
insilmaril@0 | 64 |
} |
insilmaril@0 | 65 |
|
insilmaril@0 | 66 |
void FrameObj::calcBBoxSize() |
insilmaril@0 | 67 |
{ |
insilmaril@0 | 68 |
} |
insilmaril@0 | 69 |
|
insilmaril@0 | 70 |
void FrameObj::setRect(const QRect &r) |
insilmaril@0 | 71 |
{ |
insilmaril@0 | 72 |
bbox=r; |
insilmaril@0 | 73 |
switch (type) |
insilmaril@0 | 74 |
{ |
insilmaril@0 | 75 |
case NoFrame: |
insilmaril@0 | 76 |
break; |
insilmaril@0 | 77 |
case Rectangle: |
insilmaril@0 | 78 |
rectFrame->setX (bbox.x() ); |
insilmaril@0 | 79 |
rectFrame->setY (bbox.y() ); |
insilmaril@0 | 80 |
rectFrame->setSize (bbox.width(),bbox.height() ); |
insilmaril@0 | 81 |
break; |
insilmaril@0 | 82 |
} |
insilmaril@0 | 83 |
} |
insilmaril@0 | 84 |
|
insilmaril@0 | 85 |
int FrameObj::getBorder() |
insilmaril@0 | 86 |
{ |
insilmaril@0 | 87 |
return border; |
insilmaril@0 | 88 |
} |
insilmaril@0 | 89 |
|
insilmaril@0 | 90 |
FrameType FrameObj::getFrameType() |
insilmaril@0 | 91 |
{ |
insilmaril@0 | 92 |
return type; |
insilmaril@0 | 93 |
} |
insilmaril@0 | 94 |
|
insilmaril@0 | 95 |
QString FrameObj::getFrameTypeName() |
insilmaril@0 | 96 |
{ |
insilmaril@0 | 97 |
switch (type) |
insilmaril@0 | 98 |
{ |
insilmaril@0 | 99 |
case Rectangle: |
insilmaril@0 | 100 |
return "Rectangle"; |
insilmaril@0 | 101 |
break; |
insilmaril@0 | 102 |
default: |
insilmaril@0 | 103 |
return "NoFrame"; |
insilmaril@0 | 104 |
} |
insilmaril@0 | 105 |
} |
insilmaril@0 | 106 |
|
insilmaril@0 | 107 |
void FrameObj::setFrameType(const FrameType &t) |
insilmaril@0 | 108 |
{ |
insilmaril@0 | 109 |
if (t!=type) |
insilmaril@0 | 110 |
{ |
insilmaril@0 | 111 |
clear(); |
insilmaril@0 | 112 |
type=t; |
insilmaril@0 | 113 |
switch (type) |
insilmaril@0 | 114 |
{ |
insilmaril@0 | 115 |
case NoFrame: |
insilmaril@0 | 116 |
border=0; |
insilmaril@0 | 117 |
break; |
insilmaril@0 | 118 |
case Rectangle: |
insilmaril@0 | 119 |
border=10; |
insilmaril@0 | 120 |
rectFrame = new QCanvasRectangle (canvas); |
insilmaril@0 | 121 |
rectFrame->setZ(Z_FRAME); |
insilmaril@0 | 122 |
rectFrame->setBrush( QColor("white") ); |
insilmaril@0 | 123 |
rectFrame->setPen( QPen(QColor("black") )); |
insilmaril@0 | 124 |
break; |
insilmaril@0 | 125 |
} |
insilmaril@140 | 126 |
setVisibility (visible); |
insilmaril@0 | 127 |
} |
insilmaril@0 | 128 |
} |
insilmaril@0 | 129 |
|
insilmaril@0 | 130 |
void FrameObj::setFrameType(const QString &t) |
insilmaril@0 | 131 |
{ |
insilmaril@0 | 132 |
if (t=="Rectangle") |
insilmaril@0 | 133 |
FrameObj::setFrameType (Rectangle); |
insilmaril@0 | 134 |
else |
insilmaril@0 | 135 |
FrameObj::setFrameType (NoFrame); |
insilmaril@0 | 136 |
} |
insilmaril@0 | 137 |
|
insilmaril@0 | 138 |
void FrameObj::setVisibility (bool v) |
insilmaril@0 | 139 |
{ |
insilmaril@0 | 140 |
MapObj::setVisibility(v); |
insilmaril@140 | 141 |
switch (type) |
insilmaril@140 | 142 |
{ |
insilmaril@140 | 143 |
case NoFrame: |
insilmaril@140 | 144 |
break; |
insilmaril@140 | 145 |
case Rectangle: |
insilmaril@140 | 146 |
if (visible) |
insilmaril@140 | 147 |
rectFrame->show(); |
insilmaril@140 | 148 |
else |
insilmaril@140 | 149 |
rectFrame->hide(); |
insilmaril@140 | 150 |
break; |
insilmaril@140 | 151 |
} |
insilmaril@0 | 152 |
} |
insilmaril@0 | 153 |