Salome HOME
NRI : Add KERNEL_ROOT_DIR in addition to SALOME_[ROOT, SITE]_DIR.
[modules/kernel.git] / src / VTKViewer / VTKViewer_ViewFrame.h
1 //  File      : VTKViewer_ViewFrame.h
2 //  Created   : Wed Mar 20 11:27:26 2002
3 //  Author    : Nicolas REJNERI
4 //  Project   : SALOME
5 //  Module    : VTKViewer
6 //  Copyright : Open CASCADE 2002
7 //  $Header$
8
9 #ifndef VTKViewer_ViewFrame_H
10 #define VTKViewer_ViewFrame_H
11
12 #include "VTKViewer_RenderWindowInteractor.h"
13 #include "VTKViewer_RenderWindow.h"
14 #include "VTKViewer_NonIsometricTransform.h"
15
16 #include "QAD.h"
17 #include "QAD_ViewFrame.h"
18
19 // VTK Includes
20 #include <vtkAxes.h>
21 #include <vtkPolyDataMapper.h>
22 #include <vtkActor.h>
23 #include <vtkRenderer.h>
24
25 class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame
26 {
27   Q_OBJECT
28
29     public:
30   VTKViewer_ViewFrame(QWidget* parent, const char* name=0 );
31   ~VTKViewer_ViewFrame();
32
33   ViewType                       getTypeView() const{ return VIEW_VTK;};
34   QWidget*                       getViewWidget();
35   vtkRenderer*                   getRenderer() {return m_Renderer;}
36
37   void                               setRW(VTKViewer_RenderWindow* rw);
38   VTKViewer_RenderWindow*            getRW() {return m_RW;}
39   VTKViewer_RenderWindowInteractor*  getRWInteractor() {return m_RWInteractor;}
40
41   bool                           isTrihedronDisplayed();
42   void                           SetTrihedronSize( int dim );
43
44   void                           setBackgroundColor( const QColor& );
45   QColor                         backgroundColor() const;
46   
47   void                           SetSelectionMode( int mode );
48
49   /*  popup management */
50   void                           setPopupServer( QAD_Application* );
51
52   /*  interactive object management */
53   void                           highlight( const Handle(SALOME_InteractiveObject)& IObject, 
54                                             bool highlight, bool immediatly = true );
55   void                           unHighlightAll();
56   void                           rename( const Handle(SALOME_InteractiveObject)& IObject,
57                                          QString newName );
58   bool                           isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
59   bool                           isVisible( const Handle(SALOME_InteractiveObject)& IObject );
60
61   /*  undo/redo management */
62   void              undo(SALOMEDS::Study_var aStudy,
63                          const char* StudyFrameEntry);
64   void              redo(SALOMEDS::Study_var aStudy,
65                          const char* StudyFrameEntry);
66
67
68   /* selection */
69   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
70   
71   /* display */         
72   void           Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true);
73   void           DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
74   void           Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true);
75   void           DisplayAll();
76   void           EraseAll();
77   void           Repaint();
78
79   /* non-isometric transformation */
80   void setNonIsometricTransform (VTKViewer_NonIsometricTransform *NonIsometricTransform)
81     {
82       m_NonIsometricTransform = NonIsometricTransform;
83     }
84   VTKViewer_NonIsometricTransform * getNonIsometricTransform () 
85     { 
86       if ( m_NonIsometricTransform == NULL )
87         m_NonIsometricTransform = VTKViewer_NonIsometricTransform::New();
88       return m_NonIsometricTransform; 
89     }
90   //apply existing transformation on adding SALOME_Actor
91   void AddActor(SALOME_Actor*, bool update = false);
92
93  private:
94   void AddVector(float* o,float* p,vtkRenderer* renderer);
95   void AddAxis(vtkRenderer* renderer);
96  
97  public slots:
98   void           onViewPan(); 
99   void           onViewZoom();
100   void           onViewFitAll();
101   void           onViewFitArea();
102   void           onViewGlobalPan(); 
103   void           onViewRotate();
104   void           onViewReset();     
105   void           onViewFront(); 
106   void           onViewBack(); 
107   void           onViewRight(); 
108   void           onViewLeft();     
109   void           onViewBottom();
110   void           onViewTop();
111   void           onViewTrihedron(); 
112  
113  private:
114   double                        m_ViewUp[3];
115   double                        m_ViewNormal[3];
116
117   void                          InitialSetup();
118
119   vtkRenderer*                      m_Renderer;
120   VTKViewer_RenderWindow*           m_RW;
121   VTKViewer_RenderWindowInteractor* m_RWInteractor;
122
123   Standard_Boolean              m_TriedronVisible;
124   vtkActorCollection*           m_Triedron;  
125
126   VTKViewer_NonIsometricTransform *m_NonIsometricTransform;
127
128 };
129 #endif