Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkEllipseWidgetModel2D.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef __mitkEllipseWidgetModel2D_h
00012 #define __mitkEllipseWidgetModel2D_h
00013 
00014 #include "mitkWidgetModel2D.h"
00015 #include <string>
00016 
00017 using std::string;
00018 
00026 class MITK_VISUALIZATION_API mitkEllipseWidgetModel2D : public mitkWidgetModel2D
00027 {
00028 public:
00029     MITK_TYPE(mitkEllipseWidgetModel2D, mitkWidgetModel2D)
00030 
00031     virtual void PrintSelf(ostream &os);
00032 
00033     mitkEllipseWidgetModel2D();
00034 
00041     virtual int Render(mitkScene *scene);
00042 
00048     virtual void Pick(const WidgetNames &names);
00049 
00053     virtual void Release();
00054 
00071     void SetCenterPoint(int scx, int scy);
00072 
00078     void SetCenterPoint(float cx, float cy);
00079 
00085     void SetCenterPoint(float p[2]) { this->SetCenterPoint(p[0], p[1]); }
00086 
00092     void SetRadius(float xr, float yr);
00093 
00099     void SetRadius(float r);
00100 
00110     void SetStartPoint(float point[2]);
00111 
00121     void SetStartPoint(float x, float y);
00122 
00139     void SetStartPoint(int sx, int sy);
00140 
00150     void SetMovePoint(float point[2]);
00151 
00161     void SetMovePoint(float x, float y);
00162 
00179     void SetMovePoint(int sx, int sy);
00180 
00190     void SetEndPoint(float point[2]);
00191     
00201     void SetEndPoint(float x, float y);
00202 
00219     void SetEndPoint(int sx, int sy);
00220 
00226     void SetUnitName(const string &name) { m_UnitName = name; }
00227 
00233     const string& GetUnitName() { return m_UnitName; }
00234 
00239     float GetArea();
00240 
00251     float GetPerimeter();
00252 
00258     void GetCenterPoint(float &tx, float &ty);
00259 
00265     void GetCenterPoint(int &ix, int &iy);
00266 
00274     void GetSemiMajorMinorAxis(float &ta, float &tb);
00275 
00282     void GetSemiMajorMinorAxis(int &a, int &b);
00283 
00290     virtual mitkVolume* GetRegionMask();
00291 
00292 protected:
00293     virtual ~mitkEllipseWidgetModel2D();
00294     virtual float* _getBounds();
00295 
00304     virtual void _onMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00305 
00314     virtual void _onMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00315 
00325     virtual void _onMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY);
00326 
00327     enum
00328     {
00329         unknown,
00330         ellipse,
00331         hsline,
00332         heline,
00333         vsline,
00334         veline,
00335         ssdot,
00336         esdot,
00337         eedot,
00338         sedot
00339     };
00340 
00341     // Initialize.
00342     void _init();
00343     
00344     float m_DotColor[4];
00345     float m_LineColor[4];
00346     float m_PickedLineColor[4];
00347     float m_PickedDotColor[4];
00348     float m_PickedEllipseColor[4];
00349     float m_PickedCircleColor[4];
00350 
00351     float m_CenterPoint[2];
00352     float m_XRadius;
00353     float m_YRadius;
00354     
00355     float m_StartPoint[2];
00356     float m_EndPoint[2];
00357 
00358     float m_DotSize;
00359 
00360     bool m_StartPointSet;
00361     bool m_EndPointSet;
00362 
00363     string m_UnitName;
00364 
00365 private:
00366     mitkEllipseWidgetModel2D(const mitkEllipseWidgetModel2D&);
00367     void operator = (const mitkEllipseWidgetModel2D&);
00368 
00369 };
00370 
00371 inline void mitkEllipseWidgetModel2D::SetStartPoint(float x, float y)
00372 {
00373     this->_getOriginalCoordinates(x, y, m_StartPoint[0], m_StartPoint[1]);
00374     m_CenterPoint[0] = m_EndPoint[0] = m_StartPoint[0];
00375     m_CenterPoint[1] = m_EndPoint[1] = m_StartPoint[1];
00376     m_XRadius = m_YRadius = 0.0f;
00377     m_StartPointSet = true;
00378 }
00379 inline void mitkEllipseWidgetModel2D::SetStartPoint(float point[2])
00380 {
00381     this->SetStartPoint(point[0], point[1]);
00382 }
00383 
00384 inline void mitkEllipseWidgetModel2D::SetStartPoint(int sx, int sy)
00385 {
00386     this->_getOriginalCoordinates(sx, sy, m_StartPoint[0], m_StartPoint[1]);
00387     m_CenterPoint[0] = m_EndPoint[0] = m_StartPoint[0];
00388     m_CenterPoint[1] = m_EndPoint[1] = m_StartPoint[1];
00389     m_XRadius = m_YRadius = 0.0f;
00390     m_StartPointSet = true;
00391 }
00392 
00393 inline void mitkEllipseWidgetModel2D::SetMovePoint(float x, float y)
00394 {
00395     this->_getOriginalCoordinates(x, y, m_EndPoint[0], m_EndPoint[1]);
00396     m_CenterPoint[0] = (m_StartPoint[0] + m_EndPoint[0]) * 0.5f;
00397     m_CenterPoint[1] = (m_StartPoint[1] + m_EndPoint[1]) * 0.5f;
00398     m_XRadius = m_StartPoint[0]>m_CenterPoint[0] ? m_StartPoint[0]-m_CenterPoint[0] : m_CenterPoint[0]-m_StartPoint[0];
00399     m_YRadius = m_StartPoint[1]>m_CenterPoint[1] ? m_StartPoint[1]-m_CenterPoint[1] : m_CenterPoint[1]-m_StartPoint[1];
00400 }
00401 
00402 inline void mitkEllipseWidgetModel2D::SetMovePoint(float point[2])
00403 {
00404     this->SetMovePoint(point[0], point[1]);
00405 }
00406 
00407 inline void mitkEllipseWidgetModel2D::SetMovePoint(int sx, int sy)
00408 {
00409     this->_getOriginalCoordinates(sx, sy, m_EndPoint[0], m_EndPoint[1]);
00410     m_CenterPoint[0] = (m_StartPoint[0] + m_EndPoint[0]) * 0.5f;
00411     m_CenterPoint[1] = (m_StartPoint[1] + m_EndPoint[1]) * 0.5f;
00412     m_XRadius = m_StartPoint[0]>m_CenterPoint[0] ? m_StartPoint[0]-m_CenterPoint[0] : m_CenterPoint[0]-m_StartPoint[0];
00413     m_YRadius = m_StartPoint[1]>m_CenterPoint[1] ? m_StartPoint[1]-m_CenterPoint[1] : m_CenterPoint[1]-m_StartPoint[1];
00414 }
00415 
00416 inline void mitkEllipseWidgetModel2D::SetEndPoint(float x, float y)
00417 {
00418     this->SetMovePoint(x, y);
00419     m_EndPointSet = true;
00420 }
00421 
00422 inline void mitkEllipseWidgetModel2D::SetEndPoint(float point[2])
00423 {
00424     this->SetEndPoint(point[0], point[1]);
00425 }
00426 
00427 inline void mitkEllipseWidgetModel2D::SetEndPoint(int sx, int sy)
00428 {
00429     this->SetMovePoint(sx, sy);
00430     m_EndPointSet = true;
00431 }
00432 
00433 inline void mitkEllipseWidgetModel2D::SetCenterPoint(int scx, int scy)
00434 {
00435     this->_getOriginalCoordinates(scx, scy, m_CenterPoint[0], m_CenterPoint[1]);
00436 }
00437 
00438 inline void mitkEllipseWidgetModel2D::SetCenterPoint(float cx, float cy)
00439 {
00440     this->_getOriginalCoordinates(cx, cy, m_CenterPoint[0], m_CenterPoint[1]);
00441 }
00442 
00443 inline void mitkEllipseWidgetModel2D::SetRadius(float xr, float yr)
00444 {
00445     m_XRadius = (xr < 0) ? -xr : xr;
00446     m_YRadius = (yr < 0) ? -yr : yr;
00447 }
00448 
00449 inline void mitkEllipseWidgetModel2D::SetRadius(float r)
00450 {
00451     m_XRadius = m_YRadius = (r < 0) ? -r : r;
00452 }
00453 
00454 
00455 //#define DEFINED_mitkEllipseWidgetModel2D
00456 
00457 
00458 
00459 #endif
00460 

Generated on Tue Feb 25 15:00:36 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3