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