1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GEOM_Displayer.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 #ifndef GEOM_DISPLAYER_H
28 #define GEOM_DISPLAYER_H
30 #include "GEOM_GEOMGUI.hxx"
32 #include <SALOME_InteractiveObject.hxx>
40 class SALOME_OCCViewType;
42 #include <TopoDS_Shape.hxx>
43 #include <Quantity_Color.hxx>
44 #include <LightApp_Displayer.h>
45 #include <LightApp_Study.h>
46 #include <Aspect_TypeOfMarker.hxx>
47 #include <TCollection_AsciiString.hxx>
48 #include <Basics_OCCTVersion.hxx>
53 #include <SALOMEconfig.h>
54 #include CORBA_CLIENT_HEADER(GEOM_Gen)
56 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
57 #define GEOM_PREVIEW -2 // Definition for preview selection
58 #define GEOM_ALLSHAPES -3 // Selection of all shapes is activated
59 #define GEOM_ALLGEOM -4 // Selection of all geom objects is activated
61 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
63 class TColStd_MapOfInteger;
64 class LightApp_SelectionMgr;
65 class SalomeApp_Study;
66 class SalomeApp_Application;
67 class SUIT_SelectionFilter;
68 class Handle_GEOM_AISShape;
70 //class SALOME_Selection;
72 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
77 GEOM_Displayer( SalomeApp_Study* app );
79 virtual ~GEOM_Displayer();
81 virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
83 /* Display/Erase object methods */
84 void Display ( const Handle(SALOME_InteractiveObject)& theIO,
85 const bool updateViewer = true,
86 SALOME_View* theViewFrame = 0 );
88 // This overloaded Display() method can be useful for operations
89 // not using dialog boxes.
90 void Display ( GEOM::GEOM_BaseObject_ptr theObj,
91 const bool updateViewer = true );
93 void Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
94 const bool updateViewer = true,
95 const bool checkActiveViewer = true );
97 void Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
98 const bool theUpdateViewer,
99 SALOME_View* theViewFrame );
101 void Erase ( const Handle(SALOME_InteractiveObject)& theIO,
102 const bool forced = false,
103 const bool updateViewer = true,
104 SALOME_View* theViewFrame = 0 );
106 void Erase ( GEOM::GEOM_BaseObject_ptr theObj,
107 const bool forced = false,
108 const bool updateViewer = true,
109 SALOME_View* theViewFrame = 0);
111 void EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
112 const bool eraseOnlyChildren = false);
114 /* Display/Erase list of objects methods */
116 void Display ( const SALOME_ListIO& theIOList,
117 const bool updateViewer = true );
119 void Erase ( const SALOME_ListIO& theIOList,
120 const bool forced = false,
121 const bool updateViewer = true );
123 void Redisplay ( const SALOME_ListIO& theIOList,
124 const bool updateViewer = true,
125 const bool checkActiveViewer = true );
127 void Redisplay ( const SALOME_ListIO& theIOList,
128 const bool theUpdateViewer,
129 SALOME_View* theViewFrame );
131 /* build presentation accordint to the current viewer type*/
132 SALOME_Prs* BuildPrs ( GEOM::GEOM_Object_ptr );
133 SALOME_Prs* BuildPrs ( const TopoDS_Shape& );
135 /* Set color for shape displaying. If it is equal -1 then default color is used.
136 Available values are from Quantity_NameOfColor enumeration */
137 void SetColor ( const int );
139 int GetColor () const;
140 bool HasColor () const;
142 void SetTransparency ( const double );
143 void UnsetTransparency();
144 double GetTransparency () const;
145 bool HasTransparency () const;
147 /* Set texture for shape displaying. */
148 void SetTexture ( const std::string& );
149 bool HasTexture () const;
150 std::string GetTexture () const;
152 /* Set width for shape displaying. If it is equal -1 then default width is used. */
153 void SetWidth ( const double );
155 double GetWidth () const;
156 bool HasWidth () const;
158 /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
159 void SetIsosWidth ( const int );
160 int GetIsosWidth () const;
161 bool HasIsosWidth () const;
163 /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
164 int SetDisplayMode( const int );
165 int GetDisplayMode() const;
166 int UnsetDisplayMode();
167 bool HasDisplayMode() const;
169 /* Sets name - for temporary objects only */
170 void SetName( const char* theName );
173 /* Reimplemented from SALOME_Displayer */
174 virtual void Update( SALOME_OCCPrs* );
175 virtual void Update( SALOME_VTKPrs* );
176 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
177 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
178 #if OCC_VERSION_LARGE > 0x06070000
179 virtual void BeforeErase ( SALOME_View*, const SALOME_OCCPrs* );
181 virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* );
183 /* This methos is used for activisation/deactivisation of objects to be displayed*/
184 void SetToActivate( const bool );
185 bool ToActivate() const;
187 /* Activate/Deactivate selection*/
188 void LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
189 void LocalSelection( const SALOME_ListIO& theIOList, const int );
190 void GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
191 void GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
193 SalomeApp_Study* getStudy() const;
195 static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
196 static SALOMEDS::Color getPredefinedUniqueColor();
198 /*Get color of the geom object*/
199 static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
201 /* Get minimum or maximum enclosed shape type */
202 static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
204 /* Check if the object is a vertex or a compound of vertices */
205 static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
208 /* Builds presentation of not published object */
209 virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
213 /* Update visibility and parameters of the currently selected field step's color scale */
214 void UpdateColorScale( const bool theIsRedisplayFieldSteps = false, const bool updateViewer = true );
217 /* internal methods */
218 /* Builds presentation according to the current viewer type */
219 virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
221 /* Sets interactive object */
222 void setIO( const Handle(SALOME_InteractiveObject)& theIO );
225 void setShape( const TopoDS_Shape& theShape );
227 /* Sets field step information */
228 void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
229 const int theFieldDimension,
230 const QList<QVariant>& theFieldStepData,
231 const TCollection_AsciiString& theFieldStepName,
232 const double theFieldStepRangeMin,
233 const double theFieldStepRangeMax );
235 /* Resets internal data */
236 void internalReset();
238 void clearTemporary( LightApp_SelectionMgr* theSelMgr );
240 SUIT_SelectionFilter* getFilter( const int theMode );
241 SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
243 Quantity_Color qColorFromResources( const QString&, const QColor& );
244 QColor colorFromResources( const QString&, const QColor& );
245 void updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
246 void updateActorProperties( GEOM_Actor*, bool );
247 void updateDimensions( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
249 PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
250 PropMap getDefaultPropertyMap();
252 /* Methods for reading the field step information */
253 void readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep );
254 QList<QVariant> groupFieldData( const QList<QVariant>& theFieldStepData,
255 const int theFieldNbComponents,
256 const bool theIsString,
257 double& theFieldStepRangeMin,
258 double& theFieldStepRangeMax );
260 // Note: the method is copied from Aspect_ColorScale class
261 static Standard_Integer HueFromValue( const Standard_Integer aValue,
262 const Standard_Integer aMin,
263 const Standard_Integer aMax );
265 // Note: the method is copied from Aspect_ColorScale class
266 static Standard_Boolean FindColor( const Standard_Real aValue,
267 const Standard_Real aMin,
268 const Standard_Real aMax,
269 const Standard_Integer ColorsCount,
270 Quantity_Color& aColor );
273 Handle(SALOME_InteractiveObject) myIO;
274 TopoDS_Shape myShape;
275 GEOM::field_data_type myFieldDataType;
276 int myFieldDimension;
277 QList<QVariant> myFieldStepData;
278 TCollection_AsciiString myFieldStepName;
279 double myFieldStepRangeMin;
280 double myFieldStepRangeMax;
282 std::string myTexture;
284 SALOME_View* myViewFrame;
287 Quantity_Color myShadingColor;
293 bool myHasDisplayMode;
294 Aspect_TypeOfMarker myTypeOfMarker;
295 double myScaleOfMarker;
296 double myTransparency;
299 SalomeApp_Application* myApp;
300 friend class GEOM_Swig;
303 #endif // GEOM_DISPLAYER_H