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