Salome HOME
3bceda6c595b55ebc9593477346daa9eb07c189d
[modules/gui.git] / src / VTKViewer / VTKViewer_ViewWindow.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef VTKVIEWER_VIEWWINDOW_H
23 #define VTKVIEWER_VIEWWINDOW_H
24
25 #include "VTKViewer.h"
26
27 #include "SUIT_ViewWindow.h"
28
29 #include "QtxAction.h"
30
31 class vtkRenderer;
32 class SUIT_Desktop;
33 class VTKViewer_Viewer;
34 class VTKViewer_Trihedron;
35 class VTKViewer_Transform;
36 class VTKViewer_RenderWindow;
37 class VTKViewer_InteractorStyle;
38 class VTKViewer_RenderWindowInteractor;
39 class VTKViewer_Actor;
40
41 #ifdef WIN32
42 #pragma warning( disable:4251 )
43 #endif
44
45 class VTKVIEWER_EXPORT VTKViewer_ViewWindow : public SUIT_ViewWindow
46 {
47   Q_OBJECT
48
49 public:
50   VTKViewer_ViewWindow( SUIT_Desktop*, VTKViewer_Viewer*,
51                         VTKViewer_InteractorStyle* = 0,
52                         VTKViewer_RenderWindowInteractor* = 0 );
53   virtual ~VTKViewer_ViewWindow();
54   
55   /*!Gets tool bar.*/
56   QToolBar*    getToolBar() { return myToolBar; }
57   
58   void         setBackgroundColor( const QColor& );
59   QColor       backgroundColor() const;
60
61   /*!Gets renderer.*/
62   vtkRenderer*                      getRenderer()     { return myRenderer;     }
63   /*!Gets render window.*/
64   VTKViewer_RenderWindow*           getRenderWindow() { return myRenderWindow; }
65   /*!Gets render window interactor.*/
66   VTKViewer_RenderWindowInteractor* getRWInteractor() { return myRWInteractor; }
67   bool                              isTrihedronDisplayed();
68
69   void Repaint( bool theUpdateTrihedron = true );
70   void onAdjustTrihedron();
71   void GetScale( double theScale[3] );
72   void SetScale( double theScale[3] );
73   void AddActor( VTKViewer_Actor*, bool update = false );
74   void RemoveActor( VTKViewer_Actor*, bool update = false);
75
76   virtual QString   getVisualParameters();
77   virtual void      setVisualParameters( const QString& parameters );
78
79 public slots:
80   void onFrontView();
81   void onBackView();
82   void onTopView();
83   void onBottomView();
84   void onLeftView();
85   void onRightView();
86   void onResetView();
87   void onFitAll();
88   void activateZoom();
89   void activateWindowFit();
90   void activateRotation();
91   void activatePanning();
92   void activateGlobalPanning();
93   void onTrihedronShow();
94
95 protected:
96   QImage dumpView();
97
98 protected slots:
99   void onKeyPressed(QKeyEvent* event);
100   void onKeyReleased(QKeyEvent* event);
101   void onMousePressed(QMouseEvent* event);
102   void onMouseDoubleClicked(QMouseEvent* event);
103   void onMouseReleased(QMouseEvent* event);
104   void onMouseMoving(QMouseEvent* event);
105
106 private:
107   void                              InsertActor( VTKViewer_Actor* theActor,
108                                                  bool theMoveInternalActors = false );
109   void                              MoveActor( VTKViewer_Actor* theActor );
110
111 private:
112   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
113          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, TrihedronShowId };
114   typedef QMap<int, QtxAction*> ActionsMap;
115   
116   void    createActions();
117   void    createToolBar();
118   
119   VTKViewer_Viewer*                 myModel;
120  
121   vtkRenderer*                      myRenderer;
122   VTKViewer_RenderWindow*           myRenderWindow;
123   VTKViewer_RenderWindowInteractor* myRWInteractor;
124   
125   VTKViewer_Trihedron*              myTrihedron;  
126   VTKViewer_Transform*              myTransform;
127   
128   QToolBar*                         myToolBar;
129   ActionsMap                        myActionsMap;  
130   
131   double                            myCurScale;
132
133   friend class VTKViewer_RenderWindowInteractor;
134 };
135
136 #ifdef WIN32
137 #pragma warning( default:4251 )
138 #endif
139
140 #endif