00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __mitkLineWidgetModel2D_h
00013 #define __mitkLineWidgetModel2D_h
00014
00015 #include "mitkWidgetModel2D.h"
00016 #include <string>
00017
00018 using std::string;
00019
00027 class MITK_VISUALIZATION_API mitkLineWidgetModel2D : public mitkWidgetModel2D
00028 {
00029 public:
00030 MITK_TYPE(mitkLineWidgetModel2D, mitkWidgetModel2D)
00031
00032 virtual void PrintSelf(ostream &os);
00033
00037 mitkLineWidgetModel2D();
00038
00048 mitkLineWidgetModel2D(float startPoint[2]);
00049
00056 virtual int Render(mitkScene *scene);
00057
00063 virtual void Pick(const WidgetNames &names);
00064
00068 virtual void Release();
00069
00074 float GetLineLength();
00075
00081 void SetUnitName(const string &name) { m_UnitName = name; }
00082
00088 const string& GetUnitName() { return m_UnitName; }
00089
00097 void SetStartPoint(float point[2]);
00098
00106 void SetStartPoint(float x, float y);
00107
00124 void SetStartPoint(int sx, int sy);
00125
00133 void SetMovePoint(float point[2]);
00134
00142 void SetMovePoint(float x, float y);
00143
00160 void SetMovePoint(int sx, int sy);
00161
00169 void SetEndPoint(float point[2]);
00170
00178 void SetEndPoint(float x, float y);
00179
00196 void SetEndPoint(int sx, int sy);
00197
00202 int GetPointsSetNum() { return m_PointsSetNum; }
00203
00209 void GetStartPoint(float &tx, float &ty);
00210
00216 void GetStartPoint(int &ix, int &iy);
00217
00223 void GetEndPoint(float &tx, float &ty);
00224
00230 void GetEndPoint(int &ix, int &iy);
00231
00232 protected:
00233 virtual ~mitkLineWidgetModel2D();
00234 virtual float* _getBounds();
00235
00244 virtual void _onMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00245
00254 virtual void _onMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00255
00265 virtual void _onMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY);
00266
00267
00268 void _init();
00269
00270
00271 enum
00272 {
00273 unknown,
00274 arrow0,
00275 arrow1,
00276 line
00277 };
00278
00279 float m_Point0[2];
00280 float m_Point1[2];
00281 float m_ArrowLength;
00282
00283 float m_ArrowColor[4];
00284 float m_LineColor[4];
00285 float m_PickedArrowColor[4];
00286 float m_PickedLineColor[4];
00287
00288 int m_PointsSetNum;
00289
00290 string m_UnitName;
00291
00292 private:
00293 mitkLineWidgetModel2D(const mitkLineWidgetModel2D&);
00294 void operator = (const mitkLineWidgetModel2D&);
00295
00296 };
00297
00298 inline void mitkLineWidgetModel2D::SetStartPoint(float x, float y)
00299 {
00300 this->_getOriginalCoordinates(x, y, m_Point0[0], m_Point0[1]);
00301 m_Point1[0] = m_Point0[0];
00302 m_Point1[1] = m_Point0[1];
00303 m_PointsSetNum = 1;
00304 }
00305 inline void mitkLineWidgetModel2D::SetStartPoint(float point[2])
00306 {
00307 this->SetStartPoint(point[0], point[1]);
00308 }
00309
00310 inline void mitkLineWidgetModel2D::SetStartPoint(int sx, int sy)
00311 {
00312 this->_getOriginalCoordinates(sx, sy, m_Point0[0], m_Point0[1]);
00313 m_Point1[0] = m_Point0[0];
00314 m_Point1[1] = m_Point0[1];
00315 m_PointsSetNum = 1;
00316 }
00317
00318 inline void mitkLineWidgetModel2D::SetMovePoint(float x, float y)
00319 {
00320 this->_getOriginalCoordinates(x, y, m_Point1[0], m_Point1[1]);
00321 }
00322
00323 inline void mitkLineWidgetModel2D::SetMovePoint(float point[2])
00324 {
00325 this->SetMovePoint(point[0], point[1]);
00326 }
00327
00328 inline void mitkLineWidgetModel2D::SetMovePoint(int sx, int sy)
00329 {
00330 this->_getOriginalCoordinates(sx, sy, m_Point1[0], m_Point1[1]);
00331 }
00332
00333 inline void mitkLineWidgetModel2D::SetEndPoint(float x, float y)
00334 {
00335 this->SetMovePoint(x, y);
00336 m_PointsSetNum = 2;
00337 }
00338
00339 inline void mitkLineWidgetModel2D::SetEndPoint(float point[2])
00340 {
00341 this->SetEndPoint(point[0], point[1]);
00342 }
00343
00344 inline void mitkLineWidgetModel2D::SetEndPoint(int sx, int sy)
00345 {
00346 this->SetMovePoint(sx, sy);
00347 m_PointsSetNum = 2;
00348 }
00349
00350
00351
00352
00353
00354
00355 #endif
00356