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