Salome HOME
549518dc447763af298aba1bd7d7767f0cad9e8f
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.h
1 #ifndef SVTK_VIEWWINDOW_H
2 #define SVTK_VIEWWINDOW_H
3
4 #ifdef WIN32
5 #pragma warning( disable:4251 )
6 #endif
7
8 #include "SVTK.h"
9 #include "SUIT_ViewWindow.h"
10
11 #include "SVTK_Selection.h"
12 #include "SALOME_InteractiveObject.hxx"
13
14 class vtkRenderer;
15
16 class QtxAction;
17 class SUIT_Desktop;
18
19 class VTKViewer_Trihedron;
20 class VTKViewer_Transform;
21
22 class SALOME_Actor;
23
24 class SVTK_Viewer;
25 class SVTK_Selector;
26 class SVTK_CubeAxesActor2D;
27
28 class SVTK_RenderWindow;
29 class SVTK_InteractorStyle;
30 class SVTK_RenderWindowInteractor;
31
32 class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
33 {
34   Q_OBJECT;
35
36 public:
37   SVTK_ViewWindow( SUIT_Desktop*, SVTK_Viewer* );
38   virtual ~SVTK_ViewWindow();
39   
40   QToolBar* getToolBar() { return myToolBar; }
41   
42   void setBackgroundColor( const QColor& );
43   QColor backgroundColor() const;
44
45   vtkRenderer* getRenderer() {return myRenderer;}
46   SVTK_Selector* GetSelector() {return mySelector;}
47   SVTK_RenderWindow* getRenderWindow() {return myRenderWindow;}
48   SVTK_RenderWindowInteractor* getRWInteractor() {return myRWInteractor;}
49   Selection_Mode SelectionMode() const;
50   void SetSelectionMode(Selection_Mode theMode);
51
52   bool isTrihedronDisplayed();
53   bool isCubeAxesDisplayed();
54  
55   /*  interactive object management */
56   void highlight( const Handle(SALOME_InteractiveObject)& IObject, 
57                   bool highlight, bool immediatly = true );
58   void unHighlightAll();
59   bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
60   bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
61
62   /* selection */
63   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
64   
65   /* display */         
66   void Display( const Handle(SALOME_InteractiveObject)& IObject,
67                 bool immediatly = true );
68   void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
69   void Erase( const Handle(SALOME_InteractiveObject)& IObject,
70               bool immediatly = true );
71   void DisplayAll();
72   void EraseAll();
73   void Repaint( bool theUpdateTrihedron );
74   void Repaint() { Repaint(true); }
75
76   //apply existing transformation on adding SALOME_Actor
77   void SetScale( double theScale[3] );
78   void GetScale( double theScale[3] );
79   void AddActor( SALOME_Actor*, bool update = false );
80   void RemoveActor(SALOME_Actor*, bool update = false);
81
82   void AdjustTrihedrons( const bool forced );
83   //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
84   //merge with V2_2_0_VISU_improvements:                          double& theOldSize );
85
86   int  GetTrihedronSize() const;
87   void SetTrihedronSize( const int );
88
89   VTKViewer_Trihedron*  GetTrihedron() {return this->myTrihedron;};
90   SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;};
91
92 public slots:
93   void onSelectionChanged();
94
95 signals:
96  void selectionChanged();
97
98 public slots:
99   void onFrontView(); 
100   void onBackView(); 
101   void onTopView();
102   void onBottomView();
103   void onRightView(); 
104   void onLeftView();     
105
106   void onResetView();     
107   void onFitAll();
108
109   void onViewTrihedron(); 
110   void onViewCubeAxes();
111
112   void onAdjustTrihedron();
113   void onAdjustCubeAxes();
114  
115   void onPanLeft();
116   void onPanRight();
117   void onPanUp();
118   void onPanDown();
119   void onZoomIn();
120   void onZoomOut();
121   void onRotateLeft();
122   void onRotateRight();
123   void onRotateUp();
124   void onRotateDown();
125
126   void activateZoom();
127   void activateWindowFit();
128   void activateRotation();
129   void activatePanning(); 
130   void activateGlobalPanning(); 
131
132 protected:
133   QImage dumpView();
134   virtual void      action( const int );
135
136 protected slots:
137   void onKeyPressed(QKeyEvent* event);
138   void onKeyReleased(QKeyEvent* event);
139   void onMousePressed(QMouseEvent* event);
140   void onMouseDoubleClicked(QMouseEvent* event);
141   void onMouseReleased(QMouseEvent* event);
142   void onMouseMoving(QMouseEvent* event);
143
144 private:
145   void InitialSetup();
146   void InsertActor( SALOME_Actor* theActor,
147                     bool theMoveInternalActors = false );
148   void MoveActor( SALOME_Actor* theActor );
149
150 private:  
151   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
152          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
153   typedef QMap<int, QtxAction*> ActionsMap;
154   
155   void createActions();
156   void createToolBar();
157   
158   vtkRenderer* myRenderer;
159
160   SVTK_Viewer* myModel;
161   SVTK_Selector* mySelector;
162
163   SVTK_RenderWindow* myRenderWindow;
164   SVTK_RenderWindowInteractor* myRWInteractor;
165
166   VTKViewer_Transform*  myTransform;
167   VTKViewer_Trihedron*  myTrihedron;  
168   int                   myTrihedronSize;
169   SVTK_CubeAxesActor2D* myCubeAxes;
170   
171   QToolBar* myToolBar;
172   ActionsMap myActionsMap;  
173   
174   double myCurScale;
175
176   friend class SVTK_RenderWindowInteractor;
177 };
178
179 #ifdef WIN32
180 #pragma warning( default:4251 )
181 #endif
182
183 #endif