Salome HOME
*** empty log message ***
[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   void onDumpView();
102
103   void onViewTrihedron(); 
104   void onAdjustTrihedron();
105  
106   void onPanLeft();
107   void onPanRight();
108   void onPanUp();
109   void onPanDown();
110   void onZoomIn();
111   void onZoomOut();
112   void onRotateLeft();
113   void onRotateRight();
114   void onRotateUp();
115   void onRotateDown();
116
117   void activateZoom();
118   void activateWindowFit();
119   void activateRotation();
120   void activatePanning(); 
121   void activateGlobalPanning(); 
122
123 protected slots:
124   void onKeyPressed(QKeyEvent* event);
125   void onKeyReleased(QKeyEvent* event);
126   void onMousePressed(QMouseEvent* event);
127   void onMouseDoubleClicked(QMouseEvent* event);
128   void onMouseReleased(QMouseEvent* event);
129   void onMouseMoving(QMouseEvent* event);
130
131 private:
132   void InitialSetup();
133   void InsertActor( SALOME_Actor* theActor,
134                     bool theMoveInternalActors = false );
135   void MoveActor( SALOME_Actor* theActor );
136
137 private:  
138   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
139          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId };
140   typedef QMap<int, QtxAction*> ActionsMap;
141   
142   void createActions();
143   void createToolBar();
144   
145   vtkRenderer* myRenderer;
146
147   SVTK_Viewer* myModel;
148   SVTK_Selector* mySelector;
149
150   SVTK_RenderWindow* myRenderWindow;
151   SVTK_RenderWindowInteractor* myRWInteractor;
152   
153   VTKViewer_Trihedron* myTrihedron;  
154   VTKViewer_Transform* myTransform;
155   
156   QToolBar* myToolBar;
157   ActionsMap myActionsMap;  
158   
159   double myCurScale;
160
161   friend class SVTK_RenderWindowInteractor;
162 };
163
164 #ifdef WIN32
165 #pragma warning( default:4251 )
166 #endif
167
168 #endif