frameobj.cpp
author insilmaril
Fri, 29 Dec 2006 13:52:17 +0000
changeset 413 c3f7beb4e9f4
parent 408 c2a05fa925a1
child 421 5522d1da7e37
permissions -rw-r--r--
Removed some FIXMEs. Added translations
     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(QGraphicsScene *s) :MapObj(s)
    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->setPos (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 QRectF &r)
    71 {
    72 	bbox=r;
    73     switch (type)
    74     {
    75 		case NoFrame:
    76 			break;
    77 		case Rectangle:
    78 			rectFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ));
    79 			break;
    80     }
    81 }
    82 
    83 int FrameObj::getBorder()
    84 {
    85 	return border;
    86 }
    87 
    88 FrameType FrameObj::getFrameType()
    89 {
    90 	return type;
    91 }
    92 
    93 QString FrameObj::getFrameTypeName()
    94 {
    95     switch (type)
    96     {
    97 		case Rectangle:
    98 			return "Rectangle";
    99 			break;
   100 		default:
   101 			return "NoFrame";
   102     }
   103 }
   104 
   105 void FrameObj::setFrameType(const FrameType &t)
   106 {
   107 	if (t!=type)
   108 	{
   109 		clear();
   110 		type=t;
   111 		switch (type)
   112 		{
   113 			case NoFrame:
   114 				border=0;
   115 				break;
   116 			case Rectangle:
   117 				border=10;
   118 				rectFrame = scene->addRect(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white"));
   119 				rectFrame->setZValue(Z_FRAME);
   120 
   121 				break;
   122 		}
   123 		setVisibility (visible);
   124 	}
   125 }
   126 
   127 void FrameObj::setFrameType(const QString &t)
   128 {
   129 	if (t=="Rectangle")
   130 		FrameObj::setFrameType (Rectangle);
   131 	else	
   132 		FrameObj::setFrameType (NoFrame);
   133 }
   134 
   135 void FrameObj::setVisibility (bool v)
   136 {
   137     MapObj::setVisibility(v);
   138 	switch (type)
   139 	{
   140 		case NoFrame:
   141 			break;
   142 		case Rectangle:
   143 			if (visible)
   144 				rectFrame->show();
   145 			else    
   146 				rectFrame->hide();
   147 			break;
   148 	}
   149 }
   150