00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkReslicePlaneWidgetModel_h
00012 #define __mitkReslicePlaneWidgetModel_h
00013
00014 #include "mitkWidgetModel3D.h"
00015 #include "mitkMatrix.h"
00016 #include "mitkTrackBall.h"
00017 #include "mitkColorTable.h"
00018 #include "mitkRCPtr.h"
00019
00020 class mitkVolume;
00021
00031 class MITK_VISUALIZATION_API mitkReslicePlaneWidgetModel : public mitkWidgetModel3D
00032 {
00033 public:
00034 typedef float coord_type;
00035
00036 MITK_TYPE(mitkReslicePlaneWidgetModel, mitkWidgetModel3D)
00037
00038 virtual void PrintSelf(ostream &os);
00039
00053 mitkReslicePlaneWidgetModel(coord_type v0x, coord_type v0y, coord_type v0z,
00054 coord_type v1x, coord_type v1y, coord_type v1z,
00055 coord_type cx, coord_type cy, coord_type cz);
00056
00063 virtual int Render(mitkScene *scene);
00064
00070 virtual void Pick(const WidgetNames &names);
00071
00075 virtual void Release();
00076
00084 virtual void SetSourceModel(mitkDataModel *model);
00085
00100 void SetPlanePosition(coord_type v0x, coord_type v0y, coord_type v0z,
00101 coord_type v1x, coord_type v1y, coord_type v1z,
00102 coord_type cx, coord_type cy, coord_type cz);
00103
00109 void SetPlaneOpacity(float opacity);
00110
00116 void SetSliceOpacity(float opacity);
00117
00123 float GetPlaneOpacity() { return m_PlaneOpacity;}
00124
00130 float GetSliceOpacity() { return m_SliceOpacity;}
00131
00136 void SetVolumeData(mitkVolume *vol);
00137
00142 mitkVolume* GetVolumeData() { return m_VolData; }
00143
00148 void SetSliceImageWidth(int width);
00149
00154 void SetSliceImageHeight(int height);
00155
00160 int GetSliceImageWidth() { return m_SliceImgWidth; }
00161
00166 int GetSliceImageHeight() { return m_SliceImgHeight; }
00167
00175 void GetLeftBottomPoint(coord_type &x, coord_type &y, coord_type &z)
00176 {
00177 x = m_LeftBottom->ele[0];
00178 y = m_LeftBottom->ele[1];
00179 z = m_LeftBottom->ele[2];
00180 }
00181
00188 mitkVector const * GetLeftBottomPoint() { return m_LeftBottom; }
00189
00197 void GetRightBottomPoint(coord_type &x, coord_type &y, coord_type &z)
00198 {
00199 x = m_RightBottom->ele[0];
00200 y = m_RightBottom->ele[1];
00201 z = m_RightBottom->ele[2];
00202 }
00203
00210 mitkVector const * GetRightBottomPoint() { return m_RightBottom; }
00211
00219 void GetRightTopPoint(coord_type &x, coord_type &y, coord_type &z)
00220 {
00221 x = m_RightTop->ele[0];
00222 y = m_RightTop->ele[1];
00223 z = m_RightTop->ele[2];
00224 }
00225
00232 mitkVector const * GetRightTopPoint() { return m_RightTop; }
00233
00241 void GetLeftTopPoint(coord_type &x, coord_type &y, coord_type &z)
00242 {
00243 x = m_LeftTop->ele[0];
00244 y = m_LeftTop->ele[1];
00245 z = m_LeftTop->ele[2];
00246 }
00247
00254 mitkVector const * GetLeftTopPoint() { return m_LeftTop; }
00255
00259 virtual void Update();
00260
00267 void EnableReslice(bool enable = true);
00268
00272 void DisableReslice() { this->EnableReslice(false); }
00273
00278 void SetColorTable(mitkColorTable *ct) { m_ColorTable = ct; }
00279
00284 mitkColorTable* GetColorTable();
00285
00291 void EnablePseudocolor(bool enable = true);
00292
00296 void DisablePseudocolor() { this->EnablePseudocolor(false); }
00297
00301 bool IsResliceEnabled() { return m_EnableReslice; }
00302
00306 bool IsPseudocolorEnabled() { return m_EnableColor; }
00307
00313 void StoreEnableState()
00314 {
00315 m_ResliceStore = m_EnableReslice;
00316 m_ColorStore = m_EnableColor;
00317 m_NeedRestore = true;
00318 }
00319
00326 mitkVolume* GetReslicedImage();
00327
00346 void RotateRadAroundXAxisOfPlane(float angle);
00347
00366 void RotateRadAroundYAxisOfPlane(float angle);
00367
00386 void RotateRadAroundZAxisOfPlane(float angle);
00387
00395 void RotateDegAroundXAxisOfPlane(float angle);
00396
00404 void RotateDegAroundYAxisOfPlane(float angle);
00405
00413 void RotateDegAroundZAxisOfPlane(float angle);
00414
00421 void TranslatePlane(float tx, float ty, float tz);
00422
00429 void SetPlaneCenter(float ox, float oy, float oz);
00430
00437 void GetPlaneNormal(float &nx, float &ny, float &nz);
00438
00445 void GetPlaneNormal(float n[3]) { this->GetPlaneNormal(n[0], n[1], n[2]); }
00446
00452 void SetUnitName(const string &name) { m_UnitName = name; }
00453
00457
00459 const string& GetUnitName() { return m_UnitName; }
00460
00466 float GetRotatedAngleRad();
00467
00473 float GetRotatedAngleDeg();
00474
00479 float GetMovedDistance();
00480
00485 float GetVertMoveFromStart();
00486
00491 float const * GetStartOrigin() { return m_StartOrigin; }
00492
00499 void GetStartOrigin(float so[3])
00500 {
00501 so[0] = m_StartOrigin[0];
00502 so[1] = m_StartOrigin[1];
00503 so[2] = m_StartOrigin[2];
00504 }
00505
00510 bool IsBallSelected();
00511
00516 bool IsLineSelected();
00517
00518 protected:
00519 virtual ~mitkReslicePlaneWidgetModel();
00520
00521 virtual float* _getBounds();
00522
00531 virtual void _onMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00532
00541 virtual void _onMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00542
00552 virtual void _onMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY);
00553
00554
00555 void _init();
00556
00557 bool _reslice();
00558 bool _mapColor();
00559 bool _setDummyTexture();
00560 bool _updateTexture();
00561 void _deleteTexture();
00562
00563
00564 void _rotate();
00565
00566
00567 enum
00568 {
00569 unknown,
00570 lbball,
00571 ltball,
00572 rbball,
00573 rtball,
00574 lline,
00575 tline,
00576 rline,
00577 bline,
00578 plane
00579 };
00580
00581 mitkRCPtr<mitkColorTable> m_ColorTable;
00582
00583 mitkVolume *m_VolData;
00584 mitkPlane *m_Plane;
00585
00586 mitkVector *m_LeftBottom;
00587 mitkVector *m_RightBottom;
00588 mitkVector *m_RightTop;
00589 mitkVector *m_LeftTop;
00590 mitkVector *m_Normal;
00591 mitkVector *m_OldNormal;
00592 mitkMatrix *m_InvMVMatrix;
00593 mitkMatrix *m_RotateMatrix;
00594
00595 mitkTrackBall m_TrackBall;
00596
00597 float m_ArrowLength;
00598
00599 float m_ArrowColor[4];
00600 float m_BallColor[4];
00601 float m_LineColor[4];
00602 float m_PickedBallColor[4];
00603 float m_PickedLineColor[4];
00604
00605 float m_OldOrigin[3];
00606 float m_StartOrigin[3];
00607
00608 float m_PlaneOpacity;
00609 float m_SliceOpacity;
00610
00611 float m_SpacingX;
00612 float m_SpacingY;
00613
00614 float m_MoveUnit;
00615
00616 float m_ChangingValue;
00617
00618 GLuint m_TexID;
00619 int m_DummyTexWidth;
00620 int m_DummyTexHeight;
00621 int m_SliceImgWidth;
00622 int m_SliceImgHeight;
00623
00624 unsigned int m_BufLen;
00625 unsigned int m_ClrBufLen;
00626 unsigned char *m_TexBuf;
00627 unsigned char *m_ClrTexBuf;
00628
00629 bool m_NeedSetDummyTexture;
00630 bool m_NeedUpdateTexture;
00631 bool m_BufSizeChanged;
00632 bool m_TexNotUpdate;
00633 bool m_EnableReslice;
00634 bool m_EnableColor;
00635
00636 bool m_ResliceStore;
00637 bool m_ColorStore;
00638 bool m_NeedRestore;
00639
00640 string m_UnitName;
00641
00642 private:
00643 mitkReslicePlaneWidgetModel(const mitkReslicePlaneWidgetModel&);
00644 void operator = (const mitkReslicePlaneWidgetModel&);
00645
00646 };
00647
00648
00649
00650
00651
00652
00653 #endif
00654