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