00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkRectWidgetModel2D_h
00012 #define __mitkRectWidgetModel2D_h
00013
00014 #include "mitkWidgetModel2D.h"
00015 #include <string>
00016
00017 using std::string;
00018
00026 class MITK_VISUALIZATION_API mitkRectWidgetModel2D : public mitkWidgetModel2D
00027 {
00028 public:
00029 MITK_TYPE(mitkRectWidgetModel2D, mitkWidgetModel2D)
00030
00031 virtual void PrintSelf(ostream &os);
00032
00033 mitkRectWidgetModel2D();
00034
00041 virtual int Render(mitkScene *scene);
00042
00048 virtual void Pick(const WidgetNames &names);
00049
00053 virtual void Release();
00054
00064 void SetStartPoint(float point[2]);
00065
00075 void SetStartPoint(float x, float y);
00076
00093 void SetStartPoint(int sx, int sy);
00094
00104 void SetMovePoint(float point[2]);
00105
00115 void SetMovePoint(float x, float y);
00116
00133 void SetMovePoint(int sx, int sy);
00134
00144 void SetEndPoint(float point[2]);
00145
00155 void SetEndPoint(float x, float y);
00156
00173 void SetEndPoint(int sx, int sy);
00174
00180 void SetUnitName(const string &name) { m_UnitName = name; }
00181
00187 const string& GetUnitName() { return m_UnitName; }
00188
00193 int GetWidth();
00194
00199 float GetTrueWidth();
00200
00205 int GetHeight();
00206
00211 float GetTrueHeight();
00212
00217 int GetLeft();
00218
00223 float GetTrueLeft();
00224
00229 int GetRight();
00230
00235 float GetTrueRight();
00236
00241 int GetBottom();
00242
00247 float GetTrueBottom();
00248
00253 int GetTop();
00254
00259 float GetTrueTop();
00260
00266 void GetStartPoint(int &sx, int &sy) { sx = m_StartPoint[0]; sy = m_StartPoint[1]; }
00267
00273 void GetTrueStartPoint(float &sx, float &sy) { sx = m_TrueStartPoint[0]; sy = m_TrueStartPoint[1]; }
00274
00280 void GetStartPoint(int p[2]) { this->GetStartPoint(p[0], p[1]); }
00281
00287 void GetTrueStartPoint(float p[2]) { this->GetTrueStartPoint(p[0], p[1]); }
00288
00294 void GetEndPoint(int &ex, int &ey) { ex = m_EndPoint[0]; ey = m_EndPoint[1]; }
00295
00301 void GetTrueEndPoint(float &ex, float &ey) { ex = m_TrueEndPoint[0]; ey = m_TrueEndPoint[1]; }
00302
00308 void GetEndPoint(int p[2]) { this->GetEndPoint(p[0], p[1]); }
00309
00315 void GetTrueEndPoint(float p[2]) { this->GetTrueEndPoint(p[0], p[1]); }
00316
00321 bool IsValid() { return m_EndPointSet; }
00322
00329 virtual mitkVolume* GetRegionMask();
00330
00331 protected:
00332 virtual ~mitkRectWidgetModel2D();
00333 virtual float* _getBounds();
00334
00343 virtual void _onMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00344
00353 virtual void _onMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00354
00364 virtual void _onMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY);
00365
00366 void _init();
00367
00368 enum
00369 {
00370 unknown,
00371 rect,
00372 hsline,
00373 heline,
00374 vsline,
00375 veline,
00376 ssdot,
00377 esdot,
00378 eedot,
00379 sedot
00380 };
00381
00382 float m_DotColor[4];
00383 float m_LineColor[4];
00384 float m_PickedDotColor[4];
00385 float m_PickedLineColor[4];
00386
00387 float m_DotSize;
00388
00389 int m_StartPoint[2];
00390 int m_EndPoint[2];
00391
00392 float m_TrueStartPoint[2];
00393 float m_TrueEndPoint[2];
00394
00395 float m_ObjStartPoint[2];
00396 float m_ObjEndPoint[2];
00397
00398 bool m_StartPointSet;
00399 bool m_EndPointSet;
00400
00401 string m_UnitName;
00402
00403 private:
00404 mitkRectWidgetModel2D(const mitkRectWidgetModel2D&);
00405 void operator = (const mitkRectWidgetModel2D&);
00406
00407 };
00408
00409 inline void mitkRectWidgetModel2D::SetStartPoint(float point[2])
00410 {
00411 this->SetStartPoint(point[0], point[1]);
00412 }
00413
00414 inline void mitkRectWidgetModel2D::SetMovePoint(float point[2])
00415 {
00416 this->SetMovePoint(point[0], point[1]);
00417 }
00418
00419 inline void mitkRectWidgetModel2D::SetEndPoint(int sx, int sy)
00420 {
00421 this->SetMovePoint(sx, sy);
00422 m_EndPointSet = true;
00423 }
00424
00425 inline void mitkRectWidgetModel2D::SetEndPoint(float x, float y)
00426 {
00427 this->SetMovePoint(x, y);
00428 m_EndPointSet = true;
00429 }
00430
00431 inline void mitkRectWidgetModel2D::SetEndPoint(float point[2])
00432 {
00433 this->SetEndPoint(point[0], point[1]);
00434 }
00435
00436
00437
00438
00439
00440
00441 #endif
00442