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