Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[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 #include "VTKViewer_RenderWindowInteractor.h"
36 #include "VTKViewer_RenderWindow.h"
37
38 // VTK Includes
39 class vtkRenderer;
40 class vtkActorCollection;
41 class vtkTransform;
42
43 class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame{
44   Q_OBJECT;
45  public:
46   VTKViewer_ViewFrame(QWidget* parent, const char* name=0 );
47   ~VTKViewer_ViewFrame();
48   
49   ViewType                       getTypeView() const{ return VIEW_VTK;};
50   QWidget*                       getViewWidget();
51   vtkRenderer*                   getRenderer() {return m_Renderer;}
52
53   VTKViewer_RenderWindow*        getRW() {return m_RW;}
54   VTKViewer_RenderWindowInteractor* getRWInteractor() {return m_RWInteractor;}
55
56   bool                           isTrihedronDisplayed();
57   void                           SetTrihedronSize( int dim );
58
59   void                           setBackgroundColor( const QColor& );
60   QColor                         backgroundColor() const;
61   
62   void                           SetSelectionMode( int mode );
63
64   /*  popup management */
65   void                           setPopupServer( QAD_Application* );
66
67   /*  interactive object management */
68   void                           highlight( const Handle(SALOME_InteractiveObject)& IObject, 
69                                             bool highlight, bool immediatly = true );
70   void                           unHighlightAll();
71   void                           rename( const Handle(SALOME_InteractiveObject)& IObject,
72                                          QString newName );
73   bool                           isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
74   bool                           isVisible( const Handle(SALOME_InteractiveObject)& IObject );
75
76   /*  undo/redo management */
77   void              undo(SALOMEDS::Study_var aStudy,
78                          const char* StudyFrameEntry);
79   void              redo(SALOMEDS::Study_var aStudy,
80                          const char* StudyFrameEntry);
81
82
83   /* selection */
84   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
85   
86   /* display */         
87   void           Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true);
88   void           DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
89   void           Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true);
90   void           DisplayAll();
91   void           EraseAll();
92   void           Repaint();
93
94   //apply existing transformation on adding SALOME_Actor
95   void SetScale(double theScale[3]);
96   void GetScale(double theScale[3]);
97   void AddActor(SALOME_Actor*, bool update = false);
98   void RemoveActor(SALOME_Actor*, bool update = false);
99
100  private:
101   void AddVector(float* o,float* p,vtkRenderer* renderer, float aSize);
102   void AddAxis(vtkRenderer* renderer);
103  
104  public slots:
105   void           onViewPan(); 
106   void           onViewZoom();
107   void           onViewFitAll();
108   void           onViewFitArea();
109   void           onViewGlobalPan(); 
110   void           onViewRotate();
111   void           onViewReset();     
112   void           onViewFront(); 
113   void           onViewBack(); 
114   void           onViewRight(); 
115   void           onViewLeft();     
116   void           onViewBottom();
117   void           onViewTop();
118   void           onViewTrihedron(); 
119  
120  private:
121   double                        m_ViewUp[3];
122   double                        m_ViewNormal[3];
123
124   void                          InitialSetup();
125
126   vtkRenderer*                      m_Renderer;
127   VTKViewer_RenderWindow*           m_RW;
128   VTKViewer_RenderWindowInteractor* m_RWInteractor;
129
130   Standard_Boolean              m_TriedronVisible;
131   vtkActorCollection*           m_Triedron;  
132
133   SALOME_Transform *m_Transform;
134 };
135 #endif