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