Salome HOME
Porting to Mandrake 10.1 and new products:
[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 VTKViewer_RenderWindow;
42 class VTKViewer_RenderWindowInteractor;
43
44
45 class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame
46 {
47   Q_OBJECT;
48
49 public:
50                                     VTKViewer_ViewFrame(QWidget* parent, const char* name=0 );
51                                     ~VTKViewer_ViewFrame();
52   
53   ViewType                          getTypeView() const{ return VIEW_VTK;};
54   QWidget*                          getViewWidget();
55   vtkRenderer*                      getRenderer() {return m_Renderer;}
56
57   VTKViewer_RenderWindow*                 getRW() {return m_RW;}
58   VTKViewer_RenderWindowInteractor* getRWInteractor() {return m_RWInteractor;}
59
60   bool                              isTrihedronDisplayed();
61  
62   void                              setBackgroundColor( const QColor& );
63   QColor                            backgroundColor() const;
64   
65   void                              SetSelectionMode( Selection_Mode mode );
66
67   /*  popup management */
68   void                              setPopupServer( QAD_Application* );
69
70   /*  interactive object management */
71   void                              highlight( const Handle(SALOME_InteractiveObject)& IObject, 
72                                                bool highlight, bool immediatly = true );
73   void                              unHighlightAll();
74   void                              rename( const Handle(SALOME_InteractiveObject)& IObject,
75                                             QString newName );
76   bool                              isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
77   bool                              isVisible( const Handle(SALOME_InteractiveObject)& IObject );
78
79   /* selection */
80   Handle(SALOME_InteractiveObject)  FindIObject(const char* Entry);
81   
82   /* display */         
83   void                              Display( const Handle(SALOME_InteractiveObject)& IObject,
84                                              bool immediatly = true );
85   void                              DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
86   void                              Erase( const Handle(SALOME_InteractiveObject)& IObject,
87                                            bool immediatly = true );
88   void                              DisplayAll();
89   void                              EraseAll();
90   void                              Repaint( bool theUpdateTrihedron );
91   void                              Repaint() { Repaint(true); }
92
93   virtual void                      undo( QAD_Study* aStudy, const char* StudyFrameEntry );
94   virtual void                      redo( QAD_Study* aStudy, const char* StudyFrameEntry );
95
96   /* Reimplemented from SALOME_View */
97   void                              Display( const SALOME_VTKPrs* );
98   void                              Erase( const SALOME_VTKPrs*, const bool = false );
99   SALOME_Prs*                       CreatePrs( const char* entry = 0 );
100   virtual void                      BeforeDisplay( SALOME_Displayer* d );
101   virtual void                      AfterDisplay ( SALOME_Displayer* d );
102
103   //apply existing transformation on adding SALOME_Actor
104   void                              SetScale( double theScale[3] );
105   void                              GetScale( double theScale[3] );
106   void                              AddActor( SALOME_Actor*, bool update = false );
107   void                              RemoveActor(SALOME_Actor*, bool update = false);
108
109   void                              AdjustTrihedrons( const bool forced );
110   bool                              ComputeTrihedronSize( double& theNewSize,
111                                                           double& theOldSize );
112   double                            GetTrihedronSize() const;
113   
114 public slots:
115   void                              onViewPan(); 
116   void                              onViewZoom();
117   void                              onViewFitAll();
118   void                              onViewFitArea();
119   void                              onViewGlobalPan(); 
120   void                              onViewRotate();
121   void                              onViewReset();     
122   void                              onViewFront(); 
123   void                              onViewBack(); 
124   void                              onViewRight(); 
125   void                              onViewLeft();     
126   void                              onViewBottom();
127   void                              onViewTop();
128   void                              onViewTrihedron(); 
129   void                              onAdjustTrihedron();
130  
131   void                              onPanLeft();
132   void                              onPanRight();
133   void                              onPanUp();
134   void                              onPanDown();
135   void                              onZoomIn();
136   void                              onZoomOut();
137   void                              onRotateLeft();
138   void                              onRotateRight();
139   void                              onRotateUp();
140   void                              onRotateDown();
141
142 private:
143   void                              InitialSetup();
144   void                              redisplayAll( QAD_Study*, const bool = true );
145   void                              InsertActor( SALOME_Actor* theActor,
146                                                  bool theMoveInternalActors = false );
147   void                              MoveActor( SALOME_Actor* theActor );
148
149 private:  
150   double                            m_ViewUp[ 3 ];
151   double                            m_ViewNormal[ 3 ];
152   vtkRenderer*                      m_Renderer;
153   VTKViewer_RenderWindow*           m_RW;
154   VTKViewer_RenderWindowInteractor* m_RWInteractor;
155   VTKViewer_Trihedron*              m_Triedron;  
156   SALOME_Transform*                 m_Transform;
157
158   friend class                      VTKViewer_RenderWindowInteractor;
159 };
160 #endif