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