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