]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GEOM_Displayer.h
Salome HOME
8d081a0ddd5f261637fa8c7730a185b4888ddf10
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.h
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : GEOM_Displayer.h
25 //  Author : Vadim SANDLER
26 //  Module : GEOM
27 //  $Header$
28
29 #if !defined (__GEOM_DISPLAYER_H)
30 #define __GEOM_DISPLAYER_H
31
32 #include "SALOME_Prs.h"
33 #include "SALOME_InteractiveObject.hxx"
34 #include "SALOME_ListIO.hxx"
35 #include <TopoDS_Shape.hxx>
36 #include <Quantity_Color.hxx>
37 #include <LightApp_Displayer.h>
38
39 #include <list>
40
41 #include <SALOMEconfig.h>
42 #include CORBA_CLIENT_HEADER(GEOM_Gen)
43
44 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
45 #define GEOM_PREVIEW    -2 // Definition for preview selection
46 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
47 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
48
49 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
50
51 class TColStd_MapOfInteger;
52 class LightApp_SelectionMgr;
53 class SalomeApp_Study;
54 class SalomeApp_Application;
55 class SUIT_SelectionFilter;
56 //class SALOME_Selection;
57
58 //#ifdef WNT
59 //#include <SALOME_WNT.hxx>
60 //#else
61 //#define SALOME_WNT_EXPORT
62 //#endif
63 #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
64 #define GEOMGUI_WNT_EXPORT __declspec( dllexport )
65 #else
66 #define GEOMGUI_WNT_EXPORT
67 #endif
68
69 class GEOMGUI_WNT_EXPORT GEOM_Displayer : public LightApp_Displayer
70 {
71     
72 public:
73   /* Constructor */
74   GEOM_Displayer( SalomeApp_Study* app );
75   /* Destructor */
76   virtual ~GEOM_Displayer();
77
78   /* Display/Erase object methods */
79
80   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
81                             const bool updateViewer = true,
82                             SALOME_View* theViewFrame = 0 );
83
84   // This overloaded Display() method can be useful for operations
85   // not using dialog boxes.
86   void          Display   ( GEOM::GEOM_Object_ptr theObj, 
87                             const bool updateViewer = true );
88                          
89   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
90                             const bool updateViewer = true );
91
92   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
93                             const bool forced = false,
94                             const bool updateViewer = true,
95                             SALOME_View* theViewFrame = 0 );
96
97   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
98                             const bool forced = false,
99                             const bool updateViewer = true );                            
100
101   /* Display/Erase list of objects methods */
102   
103   void          Display   ( const SALOME_ListIO& theIOList,
104                             const bool updateViewer = true );
105                             
106   void          Erase     ( const SALOME_ListIO& theIOList,
107                             const bool forced = false,
108                             const bool updateViewer = true );
109                             
110   void          Redisplay ( const SALOME_ListIO& theIOList,
111                             const bool updateViewer = true );
112
113   /* build presentation accordint to the current viewer type*/
114   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
115   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
116
117   /* Set color for shape displaying. If it is equal -1 then default color is used.
118      Available values are from Quantity_NameOfColor enumeration */
119   void          SetColor  ( const int );
120   void          UnsetColor();
121   int           GetColor  () const;
122   bool          HasColor  () const;
123
124   /* Set width for shape displaying. If it is equal -1 then default width is used. */
125   void          SetWidth  ( const double );
126   void          UnsetWidth();
127   double        GetWidth  () const;
128   bool          HasWidth  () const;
129
130
131   /* Sets name - for temporary objects only */
132   void          SetName( const char* theName );
133   void          UnsetName();
134
135   /* Reimplemented from SALOME_Displayer */
136   virtual void  Update( SALOME_OCCPrs* );
137   virtual void  Update( SALOME_VTKPrs* );
138   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& );
139   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& );
140
141   /* This methos is used for activisation/deactivisation of objects to be displayed*/
142   void          SetToActivate( const bool );
143   bool          ToActivate() const;
144
145   /* Activate/Deactivate selection*/
146   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
147   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
148   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
149   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false );
150
151   SalomeApp_Study* getStudy() const;
152
153 protected:
154   /* internal methods */
155   /* Builds presentation accordint to the current viewer type */
156   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
157   
158   /* Sets interactive object */
159   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
160   
161   /* Sets shape */
162   void        setShape( const TopoDS_Shape& theShape );
163   
164   /* Resets internal data */
165   void        internalReset();
166
167   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
168
169   SUIT_SelectionFilter* getFilter( const int theMode );
170   
171 protected:
172   Handle(SALOME_InteractiveObject) myIO;
173   TopoDS_Shape                     myShape;
174   string                           myName;
175   int                              myType;
176   SALOME_View*                     myViewFrame;
177
178   // Attributes
179   Quantity_Color                   myShadingColor;
180   int                              myColor;
181   double                           myWidth;
182   bool                             myToActivate;
183   int                              myDisplayMode;
184
185 private:
186   SalomeApp_Application* myApp;
187 };
188
189 #endif // __GEOM_DISPLAYER_H
190