Salome HOME
Fixing a bug : Salome GUI style needs addLibraryPath() method to be called
[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   double GetTrihedronSize() const;
84
85 public slots:
86   void onSelectionChanged();
87
88 signals:
89  void selectionChanged();
90
91 public slots:
92   void onFrontView(); 
93   void onBackView(); 
94   void onTopView();
95   void onBottomView();
96   void onRightView(); 
97   void onLeftView();     
98
99   void onResetView();     
100   void onFitAll();
101
102   void onViewTrihedron(); 
103   void onAdjustTrihedron();
104  
105   void onPanLeft();
106   void onPanRight();
107   void onPanUp();
108   void onPanDown();
109   void onZoomIn();
110   void onZoomOut();
111   void onRotateLeft();
112   void onRotateRight();
113   void onRotateUp();
114   void onRotateDown();
115
116   void activateZoom();
117   void activateWindowFit();
118   void activateRotation();
119   void activatePanning(); 
120   void activateGlobalPanning(); 
121
122 protected:
123   QImage dumpView();
124
125 protected slots:
126   void onKeyPressed(QKeyEvent* event);
127   void onKeyReleased(QKeyEvent* event);
128   void onMousePressed(QMouseEvent* event);
129   void onMouseDoubleClicked(QMouseEvent* event);
130   void onMouseReleased(QMouseEvent* event);
131   void onMouseMoving(QMouseEvent* event);
132
133 private:
134   void InitialSetup();
135   void InsertActor( SALOME_Actor* theActor,
136                     bool theMoveInternalActors = false );
137   void MoveActor( SALOME_Actor* theActor );
138
139 private:  
140   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
141          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
142   typedef QMap<int, QtxAction*> ActionsMap;
143   
144   void createActions();
145   void createToolBar();
146   
147   vtkRenderer* myRenderer;
148
149   SVTK_Viewer* myModel;
150   SVTK_Selector* mySelector;
151
152   SVTK_RenderWindow* myRenderWindow;
153   SVTK_RenderWindowInteractor* myRWInteractor;
154   
155   VTKViewer_Trihedron* myTrihedron;  
156   VTKViewer_Transform* myTransform;
157   
158   QToolBar* myToolBar;
159   ActionsMap myActionsMap;  
160   
161   double myCurScale;
162
163   friend class SVTK_RenderWindowInteractor;
164 };
165
166 #ifdef WIN32
167 #pragma warning( default:4251 )
168 #endif
169
170 #endif