]> SALOME platform Git repositories - modules/kernel.git/blob - src/VTKViewer/VTKViewer_ViewFrame.h
Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / VTKViewer / VTKViewer_ViewFrame.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VTKViewer_ViewFrame.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef VTKViewer_ViewFrame_H
30 #define VTKViewer_ViewFrame_H
31
32 #include "QAD.h"
33 #include "QAD_ViewFrame.h"
34
35 class vtkRenderer;
36
37 class SALOME_Actor;
38 class SALOME_Transform;
39
40 class VTKViewer_Trihedron;
41 class SALOME_CubeAxesActor2D;
42 class VTKViewer_RenderWindow;
43 class VTKViewer_RenderWindowInteractor;
44
45
46 class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame
47 {
48   Q_OBJECT;
49
50 public:
51                                     VTKViewer_ViewFrame(QWidget* parent, const char* name=0 );
52                                     ~VTKViewer_ViewFrame();
53   
54   ViewType                          getTypeView() const{ return VIEW_VTK;};
55   QWidget*                          getViewWidget();
56   vtkRenderer*                      getRenderer() {return m_Renderer;}
57
58   VTKViewer_RenderWindow*                 getRW() {return m_RW;}
59   VTKViewer_RenderWindowInteractor* getRWInteractor() {return m_RWInteractor;}
60
61   bool                              isTrihedronDisplayed();
62   bool                              isCubeAxesDisplayed();
63  
64   void                              setBackgroundColor( const QColor& );
65   QColor                            backgroundColor() const;
66   
67   void                              SetSelectionMode( Selection_Mode mode );
68
69   /*  popup management */
70   void                              setPopupServer( QAD_Application* );
71
72   /*  interactive object management */
73   void                              highlight( const Handle(SALOME_InteractiveObject)& IObject, 
74                                                bool highlight, bool immediatly = true );
75   void                              unHighlightAll();
76   void                              rename( const Handle(SALOME_InteractiveObject)& IObject,
77                                             QString newName );
78   bool                              isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
79   bool                              isVisible( const Handle(SALOME_InteractiveObject)& IObject );
80
81   /* selection */
82   Handle(SALOME_InteractiveObject)  FindIObject(const char* Entry);
83   
84   /* display */         
85   void                              Display( const Handle(SALOME_InteractiveObject)& IObject,
86                                              bool immediatly = true );
87   void                              DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
88   void                              Erase( const Handle(SALOME_InteractiveObject)& IObject,
89                                            bool immediatly = true );
90   void                              DisplayAll();
91   void                              EraseAll();
92   void                              Repaint( bool theUpdateTrihedron );
93   void                              Repaint() { Repaint(true); }
94
95   virtual void                      undo( QAD_Study* aStudy, const char* StudyFrameEntry );
96   virtual void                      redo( QAD_Study* aStudy, const char* StudyFrameEntry );
97
98   /* Reimplemented from SALOME_View */
99   void                              Display( const SALOME_VTKPrs* );
100   void                              Erase( const SALOME_VTKPrs*, const bool = false );
101   SALOME_Prs*                       CreatePrs( const char* entry = 0 );
102   virtual void                      BeforeDisplay( SALOME_Displayer* d );
103   virtual void                      AfterDisplay ( SALOME_Displayer* d );
104
105   //apply existing transformation on adding SALOME_Actor
106   void                              SetScale( double theScale[3] );
107   void                              GetScale( double theScale[3] );
108   void                              AddActor( SALOME_Actor*, bool update = false );
109   void                              RemoveActor(SALOME_Actor*, bool update = false);
110
111   void                              AdjustTrihedrons( const bool forced );
112   double                            GetTrihedronSize() const;
113
114   VTKViewer_Trihedron*              GetTrihedron() {return this->m_Triedron;};
115   SALOME_CubeAxesActor2D*           GetCubeAxes() {return this->m_CubeAxes;};
116   
117 public slots:
118   void                              onViewPan(); 
119   void                              onViewZoom();
120   void                              onViewFitAll();
121   void                              onViewFitArea();
122   void                              onViewGlobalPan(); 
123   void                              onViewRotate();
124   void                              onViewReset();     
125   void                              onViewFront(); 
126   void                              onViewBack(); 
127   void                              onViewRight(); 
128   void                              onViewLeft();     
129   void                              onViewBottom();
130   void                              onViewTop();
131   void                              onViewTrihedron();
132   void                              onViewCubeAxes();
133
134   void                              onAdjustTrihedron();
135   void                              onAdjustCubeAxes();
136  
137   void                              onPanLeft();
138   void                              onPanRight();
139   void                              onPanUp();
140   void                              onPanDown();
141   void                              onZoomIn();
142   void                              onZoomOut();
143   void                              onRotateLeft();
144   void                              onRotateRight();
145   void                              onRotateUp();
146   void                              onRotateDown();
147
148 private:
149   void                              InitialSetup();
150   void                              redisplayAll( QAD_Study*, const bool = true );
151   void                              InsertActor( SALOME_Actor* theActor,
152                                                  bool theMoveInternalActors = false );
153   void                              MoveActor( SALOME_Actor* theActor );
154
155 private:  
156   double                            m_ViewUp[ 3 ];
157   double                            m_ViewNormal[ 3 ];
158   vtkRenderer*                      m_Renderer;
159   VTKViewer_RenderWindow*           m_RW;
160   VTKViewer_RenderWindowInteractor* m_RWInteractor;
161   VTKViewer_Trihedron*              m_Triedron;  
162   SALOME_CubeAxesActor2D*           m_CubeAxes;
163   SALOME_Transform*                 m_Transform;
164
165   friend class                      VTKViewer_RenderWindowInteractor;
166 };
167 #endif