Salome HOME
5c02b79a6ecdabda7a25679a9522553b174c777a
[modules/gui.git] / src / VTKViewer / VTKViewer_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 VTKVIEWER_VIEWWINDOW_H
20 #define VTKVIEWER_VIEWWINDOW_H
21
22 #include "VTKViewer.h"
23
24 #include "SUIT_ViewWindow.h"
25
26 #include "QtxAction.h"
27
28 class vtkRenderer;
29 class SUIT_Desktop;
30 class VTKViewer_Viewer;
31 class VTKViewer_Trihedron;
32 class VTKViewer_Transform;
33 class VTKViewer_RenderWindow;
34 class VTKViewer_InteractorStyle;
35 class VTKViewer_RenderWindowInteractor;
36 class VTKViewer_Actor;
37
38 #ifdef WIN32
39 #pragma warning( disable:4251 )
40 #endif
41
42 class VTKVIEWER_EXPORT VTKViewer_ViewWindow : public SUIT_ViewWindow
43 {
44   Q_OBJECT
45
46 public:
47   VTKViewer_ViewWindow( SUIT_Desktop*, VTKViewer_Viewer*,
48                         VTKViewer_InteractorStyle* = 0,
49                         VTKViewer_RenderWindowInteractor* = 0 );
50   virtual ~VTKViewer_ViewWindow();
51   
52   /*!Gets tool bar.*/
53   QToolBar*    getToolBar() { return myToolBar; }
54   
55   void         setBackgroundColor( const QColor& );
56   QColor       backgroundColor() const;
57
58   /*!Gets renderer.*/
59   vtkRenderer*                      getRenderer()     { return myRenderer;     }
60   /*!Gets render window.*/
61   VTKViewer_RenderWindow*           getRenderWindow() { return myRenderWindow; }
62   /*!Gets render window interactor.*/
63   VTKViewer_RenderWindowInteractor* getRWInteractor() { return myRWInteractor; }
64   bool                              isTrihedronDisplayed();
65
66   void Repaint( bool theUpdateTrihedron = true );
67   void onAdjustTrihedron();
68   void GetScale( double theScale[3] );
69   void SetScale( double theScale[3] );
70   void AddActor( VTKViewer_Actor*, bool update = false );
71   void RemoveActor( VTKViewer_Actor*, bool update = false);
72
73   virtual QString   getVisualParameters();
74   virtual void      setVisualParameters( const QString& parameters );
75
76 public slots:
77   void onFrontView();
78   void onBackView();
79   void onTopView();
80   void onBottomView();
81   void onLeftView();
82   void onRightView();
83   void onResetView();
84   void onFitAll();
85   void activateZoom();
86   void activateWindowFit();
87   void activateRotation();
88   void activatePanning();
89   void activateGlobalPanning();
90   void onTrihedronShow();
91
92 protected:
93   QImage dumpView();
94
95 protected slots:
96   void onKeyPressed(QKeyEvent* event);
97   void onKeyReleased(QKeyEvent* event);
98   void onMousePressed(QMouseEvent* event);
99   void onMouseDoubleClicked(QMouseEvent* event);
100   void onMouseReleased(QMouseEvent* event);
101   void onMouseMoving(QMouseEvent* event);
102
103 private:
104   void                              InsertActor( VTKViewer_Actor* theActor,
105                                                  bool theMoveInternalActors = false );
106   void                              MoveActor( VTKViewer_Actor* theActor );
107
108 private:
109   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
110          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, TrihedronShowId };
111   typedef QMap<int, QtxAction*> ActionsMap;
112   
113   void    createActions();
114   void    createToolBar();
115   
116   VTKViewer_Viewer*                 myModel;
117  
118   vtkRenderer*                      myRenderer;
119   VTKViewer_RenderWindow*           myRenderWindow;
120   VTKViewer_RenderWindowInteractor* myRWInteractor;
121   
122   VTKViewer_Trihedron*              myTrihedron;  
123   VTKViewer_Transform*              myTransform;
124   
125   QToolBar*                         myToolBar;
126   ActionsMap                        myActionsMap;  
127   
128   double                            myCurScale;
129
130   friend class VTKViewer_RenderWindowInteractor;
131 };
132
133 #ifdef WIN32
134 #pragma warning( default:4251 )
135 #endif
136
137 #endif