1 // Copyright (C) 2007-2013 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.
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>
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;
69 //class SALOME_Selection;
71 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
76 GEOM_Displayer( SalomeApp_Study* app );
78 virtual ~GEOM_Displayer();
80 virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
82 /* Display/Erase object methods */
83 void Display ( const Handle(SALOME_InteractiveObject)& theIO,
84 const bool updateViewer = true,
85 SALOME_View* theViewFrame = 0 );
87 // This overloaded Display() method can be useful for operations
88 // not using dialog boxes.
89 void Display ( GEOM::GEOM_BaseObject_ptr theObj,
90 const bool updateViewer = true );
92 void Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
93 const bool updateViewer = true,
94 const bool checkActiveViewer = true );
96 void Erase ( const Handle(SALOME_InteractiveObject)& theIO,
97 const bool forced = false,
98 const bool updateViewer = true,
99 SALOME_View* theViewFrame = 0 );
101 void Erase ( GEOM::GEOM_BaseObject_ptr theObj,
102 const bool forced = false,
103 const bool updateViewer = true );
105 void EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
106 const bool eraseOnlyChildren = false);
108 /* Display/Erase list of objects methods */
110 void Display ( const SALOME_ListIO& theIOList,
111 const bool updateViewer = true );
113 void Erase ( const SALOME_ListIO& theIOList,
114 const bool forced = false,
115 const bool updateViewer = true );
117 void Redisplay ( const SALOME_ListIO& theIOList,
118 const bool updateViewer = true,
119 const bool checkActiveViewer = true );
121 /* build presentation accordint to the current viewer type*/
122 SALOME_Prs* BuildPrs ( GEOM::GEOM_Object_ptr );
123 SALOME_Prs* BuildPrs ( const TopoDS_Shape& );
125 /* Set color for shape displaying. If it is equal -1 then default color is used.
126 Available values are from Quantity_NameOfColor enumeration */
127 void SetColor ( const int );
129 int GetColor () const;
130 bool HasColor () const;
132 /* Set texture for shape displaying. */
133 void SetTexture ( const std::string& );
134 bool HasTexture () const;
135 std::string GetTexture () const;
137 /* Set width for shape displaying. If it is equal -1 then default width is used. */
138 void SetWidth ( const double );
140 double GetWidth () const;
141 bool HasWidth () const;
143 /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
144 void SetIsosWidth ( const int );
145 int GetIsosWidth () const;
146 bool HasIsosWidth () const;
148 /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
149 int SetDisplayMode( const int );
150 int GetDisplayMode() const;
151 int UnsetDisplayMode();
152 bool HasDisplayMode() const;
154 /* Sets name - for temporary objects only */
155 void SetName( const char* theName );
158 /* Reimplemented from SALOME_Displayer */
159 virtual void Update( SALOME_OCCPrs* );
160 virtual void Update( SALOME_VTKPrs* );
161 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
162 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
163 virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* );
165 /* This methos is used for activisation/deactivisation of objects to be displayed*/
166 void SetToActivate( const bool );
167 bool ToActivate() const;
169 /* Activate/Deactivate selection*/
170 void LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
171 void LocalSelection( const SALOME_ListIO& theIOList, const int );
172 void GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
173 void GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
175 SalomeApp_Study* getStudy() const;
177 static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
178 static SALOMEDS::Color getPredefinedUniqueColor();
180 /*Get color of the geom object*/
181 static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
183 /* Get minimum or maximum enclosed shape type */
184 static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
186 /* Check if the object is a vertex or a compound of vertices */
187 static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
190 /* Builds presentation of not published object */
191 virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
195 /* Update visibility and parameters of the currently selected field step's color scale */
196 void UpdateColorScale( const bool theIsRedisplayFieldSteps = false, const bool updateViewer = true );
199 /* internal methods */
200 /* Builds presentation according to the current viewer type */
201 virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
203 /* Sets interactive object */
204 void setIO( const Handle(SALOME_InteractiveObject)& theIO );
207 void setShape( const TopoDS_Shape& theShape );
209 /* Sets field step information */
210 void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
211 const int theFieldDimension,
212 const QList<QVariant>& theFieldStepData,
213 const TCollection_AsciiString& theFieldStepName,
214 const double theFieldStepRangeMin,
215 const double theFieldStepRangeMax );
217 /* Resets internal data */
218 void internalReset();
220 void clearTemporary( LightApp_SelectionMgr* theSelMgr );
222 SUIT_SelectionFilter* getFilter( const int theMode );
223 SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
225 Quantity_Color qColorFromResources( const QString&, const QColor& );
226 QColor colorFromResources( const QString&, const QColor& );
227 void updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
228 void updateActorProperties( GEOM_Actor*, bool );
230 PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
231 PropMap getDefaultPropertyMap();
233 /* Methods for reading the field step information */
234 void readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep );
235 QList<QVariant> groupFieldData( const QList<QVariant>& theFieldStepData,
236 const int theFieldNbComponents,
237 const bool theIsString,
238 double& theFieldStepRangeMin,
239 double& theFieldStepRangeMax );
241 // Note: the method is copied from Aspect_ColorScale class
242 static Standard_Integer HueFromValue( const Standard_Integer aValue,
243 const Standard_Integer aMin,
244 const Standard_Integer aMax );
246 // Note: the method is copied from Aspect_ColorScale class
247 static Standard_Boolean FindColor( const Standard_Real aValue,
248 const Standard_Real aMin,
249 const Standard_Real aMax,
250 const Standard_Integer ColorsCount,
251 Quantity_Color& aColor );
254 Handle(SALOME_InteractiveObject) myIO;
255 TopoDS_Shape myShape;
256 GEOM::field_data_type myFieldDataType;
257 int myFieldDimension;
258 QList<QVariant> myFieldStepData;
259 TCollection_AsciiString myFieldStepName;
260 double myFieldStepRangeMin;
261 double myFieldStepRangeMax;
263 std::string myTexture;
265 SALOME_View* myViewFrame;
268 Quantity_Color myShadingColor;
274 bool myHasDisplayMode;
275 Aspect_TypeOfMarker myTypeOfMarker;
276 double myScaleOfMarker;
279 SalomeApp_Application* myApp;
280 friend class GEOM_Swig;
283 #endif // GEOM_DISPLAYER_H