]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_ViewWindow.h
Salome HOME
Copyrights update
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef SVTK_VIEWWINDOW_H
20 #define SVTK_VIEWWINDOW_H
21
22 #ifdef WIN32
23 #pragma warning( disable:4251 )
24 #endif
25
26 #include "SVTK.h"
27 #include "SUIT_ViewWindow.h"
28
29 #include "SVTK_Selection.h"
30 #include "SALOME_InteractiveObject.hxx"
31
32 class vtkRenderer;
33
34 class QtxAction;
35 class SUIT_Desktop;
36
37 class VTKViewer_Trihedron;
38 class VTKViewer_Transform;
39
40 class SALOME_Actor;
41
42 class SVTK_Viewer;
43 class SVTK_Selector;
44 class SVTK_CubeAxesActor2D;
45
46 class SVTK_RenderWindow;
47 class SVTK_InteractorStyle;
48 class SVTK_RenderWindowInteractor;
49
50 class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
51 {
52   Q_OBJECT;
53
54 public:
55   SVTK_ViewWindow( SUIT_Desktop*, SVTK_Viewer* );
56   virtual ~SVTK_ViewWindow();
57   
58   QToolBar* getToolBar() { return myToolBar; }
59   
60   void setBackgroundColor( const QColor& );
61   QColor backgroundColor() const;
62
63   vtkRenderer* getRenderer() {return myRenderer;}
64   SVTK_Selector* GetSelector() {return mySelector;}
65   SVTK_RenderWindow* getRenderWindow() {return myRenderWindow;}
66   SVTK_RenderWindowInteractor* getRWInteractor() {return myRWInteractor;}
67   Selection_Mode SelectionMode() const;
68   void SetSelectionMode(Selection_Mode theMode);
69
70   bool isTrihedronDisplayed();
71   bool isCubeAxesDisplayed();
72  
73   /*  interactive object management */
74   void highlight( const Handle(SALOME_InteractiveObject)& IObject, 
75                   bool highlight, bool immediatly = true );
76   void unHighlightAll();
77   bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
78   bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
79
80   /* selection */
81   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
82   
83   /* display */         
84   void Display( const Handle(SALOME_InteractiveObject)& IObject,
85                 bool immediatly = true );
86   void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
87   void Erase( const Handle(SALOME_InteractiveObject)& IObject,
88               bool immediatly = true );
89   void DisplayAll();
90   void EraseAll();
91   void Repaint( bool theUpdateTrihedron );
92   void Repaint() { Repaint(true); }
93
94   //apply existing transformation on adding SALOME_Actor
95   void SetScale( double theScale[3] );
96   void GetScale( double theScale[3] );
97   void AddActor( SALOME_Actor*, bool update = false );
98   void RemoveActor(SALOME_Actor*, bool update = false);
99
100   void AdjustTrihedrons( const bool forced );
101   //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
102   //merge with V2_2_0_VISU_improvements:                          double& theOldSize );
103
104   int  GetTrihedronSize() const;
105   void SetTrihedronSize( const int );
106
107   VTKViewer_Trihedron*  GetTrihedron() {return this->myTrihedron;};
108   SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;};
109
110 public slots:
111   void onSelectionChanged();
112
113 signals:
114  void selectionChanged();
115
116 public slots:
117   void onFrontView(); 
118   void onBackView(); 
119   void onTopView();
120   void onBottomView();
121   void onRightView(); 
122   void onLeftView();     
123
124   void onResetView();     
125   void onFitAll();
126
127   void onViewTrihedron(); 
128   void onViewCubeAxes();
129
130   void onAdjustTrihedron();
131   void onAdjustCubeAxes();
132  
133   void onPanLeft();
134   void onPanRight();
135   void onPanUp();
136   void onPanDown();
137   void onZoomIn();
138   void onZoomOut();
139   void onRotateLeft();
140   void onRotateRight();
141   void onRotateUp();
142   void onRotateDown();
143
144   void activateZoom();
145   void activateWindowFit();
146   void activateRotation();
147   void activatePanning(); 
148   void activateGlobalPanning(); 
149
150 protected:
151   QImage dumpView();
152   virtual void      action( const int );
153
154 protected slots:
155   void onKeyPressed(QKeyEvent* event);
156   void onKeyReleased(QKeyEvent* event);
157   void onMousePressed(QMouseEvent* event);
158   void onMouseDoubleClicked(QMouseEvent* event);
159   void onMouseReleased(QMouseEvent* event);
160   void onMouseMoving(QMouseEvent* event);
161
162 private:
163   void InitialSetup();
164   void InsertActor( SALOME_Actor* theActor,
165                     bool theMoveInternalActors = false );
166   void MoveActor( SALOME_Actor* theActor );
167
168 private:  
169   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
170          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
171   typedef QMap<int, QtxAction*> ActionsMap;
172   
173   void createActions();
174   void createToolBar();
175   
176   vtkRenderer* myRenderer;
177
178   SVTK_Viewer* myModel;
179   SVTK_Selector* mySelector;
180
181   SVTK_RenderWindow* myRenderWindow;
182   SVTK_RenderWindowInteractor* myRWInteractor;
183
184   VTKViewer_Transform*  myTransform;
185   VTKViewer_Trihedron*  myTrihedron;  
186   int                   myTrihedronSize;
187   SVTK_CubeAxesActor2D* myCubeAxes;
188   
189   QToolBar* myToolBar;
190   ActionsMap myActionsMap;  
191   
192   double myCurScale;
193
194   friend class SVTK_RenderWindowInteractor;
195 };
196
197 #ifdef WIN32
198 #pragma warning( default:4251 )
199 #endif
200
201 #endif