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