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