Salome HOME
Update comments
[modules/gui.git] / src / Prs / SALOME_Prs.h
1 #ifndef SALOME_PRS_H
2 #define SALOME_PRS_H
3
4 #ifdef WNT
5 #ifdef PRS_EXPORTS
6 #define PRS_EXPORT __declspec(dllexport)
7 #else
8 #define PRS_EXPORT __declspec(dllimport)
9 #endif
10 #else
11 #define PRS_EXPORT
12 #endif
13
14 class SALOME_View;
15 class SALOME_Displayer;
16 class Handle_SALOME_InteractiveObject;
17
18 //===========================================================
19 /*!
20  *  Class:       SALOME_Prs \n
21  *  Description: Base class for SALOME graphic object wrappers - presentations.\n
22  *  Presentations are temporary objects, so they can be created on the stack.
23  */
24 //===========================================================
25
26 class PRS_EXPORT SALOME_Prs
27 {
28 public:
29   //! Destructor
30   virtual ~SALOME_Prs() {}
31
32   //! Key method for double dispatch of display operation
33   virtual void DisplayIn( SALOME_View* ) const = 0;
34
35   //! Key method for double dispatch of erase operation
36   virtual void EraseIn( SALOME_View*, const bool = false ) const = 0;
37
38   //! Key method for double dispatch of update operation
39   virtual void Update( SALOME_Displayer* ) = 0;
40
41   //! Should return true, if this presentation contains a graphic object
42   virtual bool IsNull() const = 0;
43
44   //! Key method for double dispatch of activation of subshapes selection
45   virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0;
46 };
47
48 //===========================================================
49 /*!
50  *  Class: SALOME_OCCPrs \n
51  *  Description: Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.\n
52  *  This intermediate class is necessary to avoid dependencies from OCC libs.
53  */
54 //===========================================================
55
56 class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs
57 {
58 public:
59   //! It uses double dispatch in order to \n
60   //! invoke Display() method corresponding to the actual type of presentation.
61   virtual void DisplayIn( SALOME_View* ) const;
62
63   //! It uses double dispatch in order to \n
64   //! invoke Erase() method corresponding to the actual type of presentation.
65   virtual void EraseIn( SALOME_View*, const bool = false ) const;
66
67   //! It uses double dispatch in order to \n
68   //! invoke Update() method corresponding to the actual type of presentation.
69   virtual void Update( SALOME_Displayer* );
70
71   //! Key method for double dispatch of activation of subshapes selection
72   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
73 };
74
75 //===========================================================
76 /*!
77  *  Class:       SALOME_VTKPrs \n
78  *  Description: Base class for VTK graphic object (vtkActor) wrappers \n
79  *               This intermediate class is necessary to avoid dependencies from VTK libs.
80  */
81 //===========================================================
82 class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs
83 {
84 public:
85   //! It uses double dispatch in order to \n
86   //! invoke Display() method corresponding to the actual type of presentation.
87   virtual void DisplayIn( SALOME_View* ) const;
88
89   //! It uses double dispatch in order to \n
90   //! invoke Erase() method corresponding to the actual type of presentation.
91   virtual void EraseIn( SALOME_View*, const bool = false ) const;
92
93   //! It uses double dispatch in order to \n
94   //! invoke Update() method corresponding to the actual type of presentation.
95   virtual void Update( SALOME_Displayer* );
96
97   //! Key method for double dispatch of activation of subshapes selection
98   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
99 };
100
101 //===========================================================
102 /*!
103  *  Class:       SALOME_Prs2d \n
104  *  Description: Base class for Plot2d graphic object (Plot2d_Curve) wrappers.
105  */
106 //===========================================================
107
108 class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs
109 {
110 public:
111   //! It uses double dispatch in order to
112   //! invoke Display() method corresponding to the actual type of presentation.
113   virtual void DisplayIn( SALOME_View* ) const;
114
115   //! It uses double dispatch in order to
116   //! invoke Erase() method corresponding to the actual type of presentation.
117   virtual void EraseIn( SALOME_View*, const bool = false ) const;
118
119   //! It uses double dispatch in order to
120   //! invoke Update() method corresponding to the actual type of presentation.
121   virtual void Update( SALOME_Displayer* );
122
123   //! Key method for double dispatch of activation of subshapes selection
124   virtual void LocalSelectionIn( SALOME_View*, const int ) const;
125 };
126
127 /////////////////////////////////////////////////////////////////////////
128 // Base classes for object wrappers for any other visualization libraries
129 // should be added here!
130 /////////////////////////////////////////////////////////////////////////
131
132 //===========================================================
133 /*!
134  *  Class:       SALOME_View \n
135  *  Description: Base class for SALOME views (or view frames)
136  */
137 //===========================================================
138
139 class PRS_EXPORT SALOME_View
140 {
141 public:
142   //! Destructor
143   virtual ~SALOME_View() {}
144
145   //! This Display() method should be called to display given presentation \n
146   //! created anywhere by anybody. It simply passes control to SALOME_Prs object \n
147   //! so that it could perform double dispatch.
148   void Display( const SALOME_Prs* );
149
150   //! This Erase() method should be called to erase given presentation \n
151   //! created anywhere by anybody. It simply passes control to SALOME_Prs object \n
152   //! so that it could perform double dispatch.
153   void Erase( const SALOME_Prs*, const bool = false );
154
155   //! This LocalSelection() method should be called to activate sub-shapes selection \n
156   //! created anywhere by anybody. It simply passes control to SALOME_Prs object \n
157   //! so that it could perform double dispatch.
158   void LocalSelection( const SALOME_Prs*, const int );
159
160   // Interface for derived views
161
162   // Display() methods for ALL kinds of presentation should appear here
163   virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation.
164   virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation.
165   virtual void Display( const SALOME_Prs2d* );//!< Display SALOME_Prs2d presentation.
166   // Add new Display() methods here...
167
168   // Erase() methods for ALL kinds of presentation should appear here
169   virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs
170   virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs
171   virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d
172   virtual void EraseAll( const bool = false );
173   // Add new Erase() methods here...
174
175   // LocalSelection() methods for ALL kinds of presentation should appear here
176   virtual void LocalSelection( const SALOME_OCCPrs*, const int );//!< Local selection SALOME_OCCPrs
177   virtual void LocalSelection( const SALOME_VTKPrs*, const int );//!< Local selection SALOME_VTKPrs
178   virtual void LocalSelection( const SALOME_Prs2d* , const int );//!< Local selection SALOME_Prs2d
179
180   //! Deactivates selection of sub-shapes (must be redefined with OCC viewer)
181   virtual void GlobalSelection( const bool = false ) const;
182
183   //! Creates empty presenation of corresponding type
184   virtual SALOME_Prs* CreatePrs( const char* entry = 0 ) { return 0; }
185
186   // Axiluary methods called before and after displaying of objects
187   virtual void BeforeDisplay( SALOME_Displayer* d ) {} //!< Null body here
188   virtual void AfterDisplay ( SALOME_Displayer* d ) {} //!< Null body here
189
190   // New methods (asv)
191   //! \retval Return false.
192   virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
193   virtual void Repaint() {} //!< Null body here.
194 };
195
196 //===========================================================
197 /*
198  *  Classes:     SALOME_Displayer
199  *  Description: These classes are used to specify type of view
200  *               VTK, OCC or Plot2d
201  */
202 //===========================================================
203 class PRS_EXPORT SALOME_OCCViewType    {};
204 class PRS_EXPORT SALOME_VTKViewType    {};
205 class PRS_EXPORT SALOME_Plot2dViewType {};
206
207 //===========================================================
208 /*!
209  *  Class:       SALOME_Displayer \n
210  *  Description: Base class for SALOME displayers
211  */
212 //===========================================================
213
214 class PRS_EXPORT SALOME_Displayer
215 {
216 public:
217   //! Destructor
218   virtual ~SALOME_Displayer() {/*! Null body here*/}
219
220   //! This Update() method should be called to update given presentation \n
221   //! created anywhere by anybody. It simply passes control to SALOME_Prs object \n
222   //! so that it could perform double dispatch.
223   void UpdatePrs( SALOME_Prs* );
224
225   // Interface for derived displayers
226
227   // Update() methods for ALL kinds of presentation should appear here
228   virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation.
229   virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation.
230   virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation.
231   // Add new Update() methods here...
232
233   // Axiluary methods called before and after displaying of objects
234   virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCViewType&    ){/*! Null body here*/};
235   virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCViewType&    ){/*! Null body here*/};
236   virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKViewType&    ){/*! Null body here*/};
237   virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKViewType&    ){/*! Null body here*/};
238   virtual void BeforeDisplay( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/};
239   virtual void AfterDisplay ( SALOME_View*, const SALOME_Plot2dViewType& ){/*! Null body here*/};
240 };
241
242 #endif