00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __VTKViewer_InteractorStyle_h
00029 #define __VTKViewer_InteractorStyle_h
00030
00031 #include <vtkInteractorStyle.h>
00032
00033 class vtkCell;
00034 class vtkRenderWindowInteractor;
00035 class vtkTDxInteractorStyle;
00036
00037 #include <QObject>
00038 #include <QCursor>
00039
00040 class QRubberBand;
00041
00042 #include <map>
00043
00044 #include "VTKViewer.h"
00045
00046 #include "VTKViewer_Filter.h"
00047
00048 class VTKViewer_Actor;
00049 class VTKViewer_Trihedron;
00050 class VTKViewer_ViewWindow;
00051 class VTKViewer_RenderWindowInteractor;
00052
00053 #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
00054 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
00055 #define VTK_INTERACTOR_STYLE_CAMERA_PAN 2
00056 #define VTK_INTERACTOR_STYLE_CAMERA_ZOOM 3
00057 #define VTK_INTERACTOR_STYLE_CAMERA_SPIN 4
00058 #define VTK_INTERACTOR_STYLE_CAMERA_FIT 5
00059 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
00060 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
00061
00062 #ifdef WIN32
00063 #pragma warning ( disable:4251 )
00064 #endif
00065
00071 class VTKVIEWER_EXPORT VTKViewer_InteractorStyle : public QObject, public vtkInteractorStyle
00072 {
00073 public:
00074 static VTKViewer_InteractorStyle *New();
00075 vtkTypeMacro(VTKViewer_InteractorStyle, vtkInteractorStyle);
00076
00077 virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
00078 void setViewWnd(VTKViewer_ViewWindow* theViewWnd);
00079 void setGUIWindow(QWidget* theWindow);
00080
00081 void setTriedron(VTKViewer_Trihedron* theTrihedron);
00082 void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1,
00083 const double& theBlue = 1, const int& theWidth = 5);
00084
00085
00086 void OnMouseMove (int ctrl, int shift, int x, int y);
00087 void OnLeftButtonDown(int ctrl, int shift, int x, int y);
00088 void OnLeftButtonUp (int ctrl, int shift, int x, int y);
00089 void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
00090 void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
00091 void OnRightButtonDown(int ctrl, int shift, int x, int y);
00092 void OnRightButtonUp (int ctrl, int shift, int x, int y);
00093
00094 void OnSelectionModeChanged();
00095
00096 void ViewFitAll();
00097
00098 void SetFilter( const Handle( VTKViewer_Filter)& );
00099 Handle(VTKViewer_Filter) GetFilter( const int );
00100 bool IsFilterPresent( const int );
00101 void RemoveFilter( const int );
00102 bool IsValid( VTKViewer_Actor* theActor,
00103 const int theId,
00104 const bool theIsNode = false );
00105
00106 void IncrementalPan ( const int incrX, const int incrY );
00107 void IncrementalZoom ( const int incr );
00108 void IncrementalRotate( const int incrX, const int incrY );
00109
00110 int CurrentState() const { return State; }
00111
00112 protected:
00113 VTKViewer_InteractorStyle();
00114 ~VTKViewer_InteractorStyle();
00115 VTKViewer_InteractorStyle(const VTKViewer_InteractorStyle&) {};
00116 void operator=(const VTKViewer_InteractorStyle&) {};
00117
00118 void RotateXY(int dx, int dy);
00119 void PanXY(int x, int y, int oldX, int oldY);
00120 void DollyXY(int dx, int dy);
00121 void SpinXY(int dx, int dy, int oldX, int oldY);
00122 void fitRect(const int left, const int top, const int right, const int bottom);
00123 void Place(const int theX, const int theY);
00124 void TranslateView(int toX, int toY, int fromX, int fromY);
00125 bool IsInRect(vtkActor* theActor,
00126 const int left, const int top,
00127 const int right, const int bottom);
00128 bool IsInRect(vtkCell* theCell,
00129 const int left, const int top,
00130 const int right, const int bottom);
00131 bool IsInRect(vtkFloatingPointType* thePoint,
00132 const int left, const int top,
00133 const int right, const int bottom);
00134
00135 int State;
00136 vtkFloatingPointType MotionFactor;
00137 vtkFloatingPointType RadianToDegree;
00138 double myScale;
00139
00140 VTKViewer_Actor *myPreViewActor, *myPreSelectionActor, *mySelectedActor;
00141
00142 int myElemId;
00143 int myEdgeId;
00144 int myNodeId;
00145
00146 public:
00147 bool eventFilter(QObject* object, QEvent* event);
00148 void startZoom();
00149 void startPan();
00150 void startGlobalPan();
00151 void startRotate();
00152 void startFitArea();
00153 void startSpin();
00154 void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle) {}
00155 bool needsRedrawing();
00156
00157 protected:
00158 void loadCursors();
00159 void startOperation(int operation);
00160 virtual void onStartOperation();
00161 virtual void onFinishOperation();
00162 virtual void onOperation(QPoint mousePos);
00163 virtual void onCursorMove(QPoint mousePos);
00164 virtual void setCursor(const int operation);
00165
00166 void drawRect();
00167 void endDrawRect();
00168
00169 protected:
00170 QCursor myDefCursor;
00171 QCursor myPanCursor;
00172 QCursor myZoomCursor;
00173 QCursor myRotateCursor;
00174 QCursor mySpinCursor;
00175 QCursor myHandCursor;
00176 QCursor myGlobalPanCursor;
00177 QPoint myPoint;
00178 QPoint myOtherPoint;
00179 bool myCursorState;
00180 bool myShiftState;
00181 int ForcedState;
00182
00183 VTKViewer_RenderWindowInteractor* m_Interactor;
00184 VTKViewer_ViewWindow* m_ViewWnd;
00185 VTKViewer_Trihedron* m_Trihedron;
00186 QWidget* myGUIWindow;
00187
00188 std::map<int, Handle(VTKViewer_Filter) > myFilters;
00189
00190 QRubberBand* myRectBand;
00191
00194 double DeltaElevation;
00195 double DeltaAzimuth;
00196 int LastPos[2];
00198 };
00199
00200 #ifdef WIN32
00201 #pragma warning ( default:4251 )
00202 #endif
00203
00204 #endif