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.cxx
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 #include "GEOM_Displayer.h"
28 #include "GEOMGUI_DimensionProperty.h"
29 #include "GeometryGUI.h"
31 #include <GEOM_Constants.h>
32 #include <GEOM_TypeFilter.h>
33 #include <GEOM_EdgeFilter.h>
34 #include <GEOM_FaceFilter.h>
35 #include <GEOM_CompoundFilter.h>
36 #include <GEOM_PreviewFilter.h>
37 #include <GEOM_LogicalFilter.h>
38 #include <GEOM_OCCFilter.h>
40 #include <GEOM_Actor.h>
41 #include <GEOM_AISShape.hxx>
42 #include <GEOM_AISDimension.hxx>
43 #include <GEOM_TopWireframeShape.hxx>
44 #include <GEOM_AISVector.hxx>
45 #include <GEOM_AISTrihedron.hxx>
46 #include <GEOM_VTKTrihedron.hxx>
47 #include <GEOM_VTKPropertyMaterial.hxx>
49 #include <GEOMUtils.hxx>
51 #include <Material_Model.h>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_ViewWindow.h>
55 #include <SUIT_Session.h>
56 #include <SUIT_ViewManager.h>
57 #include <SUIT_ResourceMgr.h>
59 #include <Basics_OCCTVersion.hxx>
61 #include <SalomeApp_Study.h>
62 #include <SalomeApp_Application.h>
63 #include <LightApp_SelectionMgr.h>
64 #include <LightApp_DataObject.h>
65 #include <SalomeApp_TypeFilter.h>
66 #include <SalomeApp_Tools.h>
68 #include <SALOME_ListIteratorOfListIO.hxx>
69 #include <SALOME_ListIO.hxx>
70 #include <SALOME_Prs.h>
73 #include <SOCC_ViewModel.h>
76 #include <SVTK_ViewModel.h>
78 #include <OCCViewer_ViewWindow.h>
79 #include <OCCViewer_ViewPort3d.h>
82 #include <AIS_Drawer.hxx>
83 #include <AIS_Dimension.hxx>
84 #include <AIS_LengthDimension.hxx>
85 #include <AIS_DiameterDimension.hxx>
86 #include <AIS_AngleDimension.hxx>
87 #include <AIS_ListIteratorOfListOfInteractive.hxx>
88 #include <Aspect_PolygonOffsetMode.hxx>
89 #include <Aspect_ColorScale.hxx>
90 #include <Prs3d_IsoAspect.hxx>
91 #include <Prs3d_PointAspect.hxx>
92 #include <StdSelect_TypeOfEdge.hxx>
93 #include <StdSelect_TypeOfFace.hxx>
94 #include <StdSelect_DisplayMode.hxx>
95 #include <TopoDS_Face.hxx>
96 #include <BRep_Tool.hxx>
97 #include <Geom_Plane.hxx>
98 #include <Geom_Axis2Placement.hxx>
99 #include <Graphic3d_AspectFillArea3d.hxx>
100 #include <gp_Pln.hxx>
101 #include <TColStd_MapOfInteger.hxx>
102 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
103 #include <TopoDS_Iterator.hxx>
104 #include <Graphic3d_AspectMarker3d.hxx>
105 #include <TopTools_MapOfShape.hxx>
106 #include <TopTools_ListOfShape.hxx>
107 #include <TopTools_ListIteratorOfListOfShape.hxx>
108 #include <TopoDS.hxx>
110 #include <Prs3d_ShadingAspect.hxx>
112 #include <BRepMesh_IncrementalMesh.hxx>
115 #include <vtkActorCollection.h>
116 #include <vtkProperty.h>
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
121 #include <GEOMImpl_Types.hxx>
123 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
124 #include <TColStd_HArray1OfByte.hxx>
126 #include <Graphic3d_HArray1OfBytes.hxx>
129 // If the next macro is defined, autocolor feature works for all sub-shapes;
130 // if it is undefined, autocolor feature works for groups only
131 #define GENERAL_AUTOCOLOR
132 // Below macro, when uncommented, switches on simplified (more performant) algorithm
133 // of auto-color picking up
134 #define SIMPLE_AUTOCOLOR
136 // Hard-coded value of shape deflection coefficient for VTK viewer
137 const double VTK_MIN_DEFLECTION = 0.001;
139 //================================================================
140 // Function : getActiveStudy
141 // Purpose : Get active study, returns 0 if no open study frame
142 //================================================================
143 static inline SalomeApp_Study* getActiveStudy()
145 SUIT_Session* session = SUIT_Session::session();
146 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
148 return ( SalomeApp_Study* )app->activeStudy();
152 static inline int getViewManagerId( SALOME_View* theViewFrame) {
153 SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
154 SUIT_ViewManager* aViewMgr = 0;
156 aViewMgr = aModel->getViewManager();
157 return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
160 //================================================================
161 // Function : getTopAbsMode
162 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
163 // one from GEOMImpl_Types.h
164 //================================================================
165 static inline int getTopAbsMode( const int implType )
169 case GEOM_COMPOUND : return TopAbs_COMPOUND;
170 case GEOM_SOLID : return TopAbs_SOLID;
171 case GEOM_SHELL : return TopAbs_SHELL;
172 case GEOM_FACE : return TopAbs_FACE;
173 case GEOM_WIRE : return TopAbs_WIRE;
174 case GEOM_EDGE : return TopAbs_EDGE;
175 case GEOM_POINT : return TopAbs_VERTEX;
180 int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
182 if ( shape.IsNull() )
185 int ret = shape.ShapeType();
187 if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
188 TopoDS_Iterator it(shape, Standard_True, Standard_False);
189 for (; it.More(); it.Next()) {
190 TopoDS_Shape sub_shape = it.Value();
191 if ( sub_shape.IsNull() ) continue;
192 int stype = getMinMaxShapeType( sub_shape, ismin );
193 if ( stype == TopAbs_SHAPE ) continue;
194 if ( ismin && stype > ret )
196 else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) )
204 bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
206 return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
209 //================================================================
210 // Function : getFilter
211 // Purpose : Get filter corresponding to the type of object
212 // from GEOMImpl_Types.h
213 //================================================================
214 SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
216 SUIT_SelectionFilter* aFilter;
218 int aTopAbsMode = getTopAbsMode( theMode );
219 if ( aTopAbsMode != -1 )
220 aFilter = new GEOM_TypeFilter( getStudy(), aTopAbsMode, true ); //@ aFilter = new GEOM_TypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
224 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Line ); break;
225 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Circle ); break;
227 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Plane ); break;
228 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cylinder ); break;
229 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Sphere ); break;
230 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Torus ); break;
231 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Revol ); break;
232 case GEOM_CONE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cone ); break;
234 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter( getStudy() ); break;
236 case GEOM_ALLSHAPES : aFilter = new GEOM_SelectionFilter(getStudy(), true ); break;
237 case GEOM_ALLGEOM : aFilter = new SalomeApp_TypeFilter( getStudy(), "GEOM" ); break;
239 default : aFilter = new GEOM_TypeFilter( getStudy(), theMode ); break;
245 //================================================================
246 // Function : getComplexFilter
247 // Purpose : Get compound filter corresponding to the type of
248 // object from GEOMImpl_Types.h
249 //================================================================
250 SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList<int>* aSubShapes)
252 GEOM_CompoundFilter* aFilter;
254 if(aSubShapes != NULL ) {
255 aFilter = new GEOM_CompoundFilter(getStudy());
256 QList<int> aTopAbsTypes;
257 QList<int>::const_iterator it;
258 for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
259 int topAbsMode = getTopAbsMode(*it);
260 if(topAbsMode != -1 )
261 aTopAbsTypes.append(topAbsMode);
263 aFilter->addSubTypes(aTopAbsTypes);
269 //================================================================
270 // Function : getEntry
272 //================================================================
273 static std::string getEntry( GEOM::GEOM_BaseObject_ptr object )
275 SUIT_Session* session = SUIT_Session::session();
276 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
279 CORBA::String_var IOR = app->orb()->object_to_string( object );
280 if ( strcmp(IOR.in(), "") != 0 )
282 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
283 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
291 //================================================================
292 // Function : getName
294 //================================================================
295 static std::string getName( GEOM::GEOM_BaseObject_ptr object )
297 SUIT_Session* session = SUIT_Session::session();
298 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
301 CORBA::String_var IOR = app->orb()->object_to_string( object );
302 if ( strcmp(IOR.in(), "") != 0 )
304 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
305 _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
307 _PTR(GenericAttribute) anAttr;
309 if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
311 _PTR(AttributeName) aNameAttr( anAttr );
312 return aNameAttr->Value();
320 //=================================================================
322 * GEOM_Displayer::GEOM_Displayer
325 //=================================================================
326 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
329 myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
334 SUIT_Session* session = SUIT_Session::session();
335 SUIT_ResourceMgr* resMgr = session->resourceMgr();
337 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
338 myShadingColor = SalomeApp_Tools::color( col );
340 myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
341 myHasDisplayMode = false;
343 int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
344 myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
345 myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
347 myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
348 myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
349 myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
352 // This color is used for shape displaying. If it is equal -1 then
353 // default color is used.
360 // This parameter is used for activisation/deactivisation of objects to be displayed
362 #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
363 // Activate parallel vizualisation only for testing purpose
364 // and if the corresponding env variable is set to 1
365 char* parallel_visu = getenv("PARALLEL_VISU");
366 if (parallel_visu && atoi(parallel_visu))
368 MESSAGE("Parallel visualisation on");
369 BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
375 myFieldDataType = GEOM::FDT_Double;
376 myFieldDimension = 0;
377 myFieldStepRangeMin = 0;
378 myFieldStepRangeMax = 0;
381 //=================================================================
383 * GEOM_Displayer::~GEOM_Displayer
386 //=================================================================
387 GEOM_Displayer::~GEOM_Displayer()
391 //=================================================================
393 * GEOM_Displayer::Display
394 * Display interactive object in the current viewer
396 //=================================================================
397 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
398 const bool updateViewer,
399 SALOME_View* theViewFrame )
401 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
404 SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
408 vf->BeforeDisplay( this, prs );
410 vf->AfterDisplay( this, prs );
415 int aMgrId = getViewManagerId(vf);
416 SalomeApp_Study* aStudy = getStudy();
417 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 );
419 setVisibilityState(theIO->getEntry(), Qtx::ShownState);
421 delete prs; // delete presentation because displayer is its owner
426 //=================================================================
428 * GEOM_Displayer::Display
429 * This overloaded Display() method can be useful for operations
430 * not using dialog boxes.
432 //=================================================================
433 void GEOM_Displayer::Display( GEOM::GEOM_BaseObject_ptr theObj, const bool updateViewer )
435 if ( theObj->_is_nil() )
438 std::string entry = getEntry( theObj );
440 Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
445 //=================================================================
447 * GEOM_Displayer::Erase
448 * Erase interactive object in the current viewer
450 //=================================================================
451 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
453 const bool updateViewer,
454 SALOME_View* theViewFrame )
456 if ( theIO.IsNull() )
459 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
462 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
464 vf->BeforeErase( this, prs );
465 vf->Erase( prs, forced );
466 vf->AfterErase( this, prs );
469 delete prs; // delete presentation because displayer is its owner
471 int aMgrId = getViewManagerId(vf);
472 SalomeApp_Study* aStudy = getStudy();
473 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 );
475 setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
480 //=================================================================
482 * GEOM_Displayer::Erase
483 * Erase geometry object in the current viewer
485 //=================================================================
486 void GEOM_Displayer::Erase( GEOM::GEOM_BaseObject_ptr theObj,
488 const bool updateViewer,
489 SALOME_View* theViewFrame)
491 std::string entry = getEntry( theObj );
494 Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
495 forced, updateViewer, theViewFrame);
499 //=================================================================
501 * GEOM_Displayer::Redisplay
502 * Redisplay (erase and then display again) interactive object
503 * in the current viewer
505 //=================================================================
506 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
507 const bool updateViewer,
508 const bool checkActiveViewer )
510 // Remove the object permanently (<forced> == true)
511 SUIT_Session* ses = SUIT_Session::session();
512 SUIT_Application* app = ses->activeApplication();
515 SUIT_Desktop* desk = app->desktop();
516 QList<SUIT_ViewWindow*> wnds = desk->windows();
517 SUIT_ViewWindow* wnd;
518 QListIterator<SUIT_ViewWindow*> it( wnds );
519 while ( it.hasNext() && (wnd = it.next()) )
521 SUIT_ViewManager* vman = wnd->getViewManager();
524 SUIT_ViewModel* vmodel = vman->getViewModel();
527 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
530 if ( view->isVisible( theIO ) || ( checkActiveViewer && view == GetActiveView() ) )
532 Redisplay( theIO, updateViewer, view );
541 //=================================================================
543 * GEOM_Displayer::Redisplay
544 * Redisplay (erase and then display again) interactive object
545 * in the specified view
547 //=================================================================
548 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
549 const bool theUpdateViewer,
550 SALOME_View* theViewFrame )
552 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
558 Erase( theIO, true, false, theViewFrame );
559 Display( theIO, theUpdateViewer, theViewFrame );
562 //=================================================================
564 * GEOM_Displayer::Display
565 * Calls Display() method for each object in the given list
567 //=================================================================
568 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
570 SALOME_ListIteratorOfListIO Iter( theIOList );
571 for ( ; Iter.More(); Iter.Next() ) {
572 Display( Iter.Value(), false );
578 Quantity_Color GEOM_Displayer::qColorFromResources( const QString& property, const QColor& defColor )
580 // VSR: this method can be improved in future:
581 // to improve performance, the default values from resource manager should be cached in the displayer
582 return SalomeApp_Tools::color( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ) );
585 QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor& defColor )
587 // VSR: this method can be improved in future:
588 // to improve performance, the default values from resource manager should be cached in the displayer
589 return SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor );
592 void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create )
594 // check that shape is not null
595 if ( AISShape.IsNull() ) return;
597 // check that study is active
598 SalomeApp_Study* study = getStudy();
599 if ( !study ) return;
601 if ( myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points
602 !TopoDS_Iterator(myShape).More() )
603 return; // NPAL15983 (Bug when displaying empty groups)
605 // set interactive object
607 Handle( SALOME_InteractiveObject ) anIO;
609 if ( !myIO.IsNull() ) {
610 AISShape->setIO( myIO );
611 AISShape->SetOwner( myIO );
614 else if ( !myName.empty() ) {
615 // workaround to allow selection of temporary objects
616 static int tempId = 0;
617 anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
618 AISShape->setIO( anIO );
619 AISShape->SetOwner( anIO );
622 // flag: only vertex or compound of vertices is processed (specific handling)
623 bool onlyVertex = myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape );
624 // presentation study entry (empty for temporary objects like preview)
625 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
626 // flag: temporary object
627 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
628 // currently active view window's ID (-1 if no active view)
629 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
631 // get presentation properties
632 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
634 // Temporary staff: vertex must be infinite for correct visualization
635 AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
638 Material_Model material;
639 // if predefined color isn't set in displayer(via GEOM_Displayer::SetColor() function)
641 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
642 // - set front material properties
643 AISShape->SetCurrentFacingModel( Aspect_TOFM_FRONT_SIDE );
644 AISShape->SetMaterial( material.getMaterialOCCAspect( true ) );
645 // - set back material properties
646 AISShape->SetCurrentFacingModel( Aspect_TOFM_BACK_SIDE );
647 AISShape->SetMaterial( material.getMaterialOCCAspect( false ) );
648 // - switch to default (both sides) facing mode
649 AISShape->SetCurrentFacingModel( Aspect_TOFM_BOTH_SIDE );
655 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function;
656 // we set it to the shape not taking into account material properties
657 AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() );
659 else if ( !material.isPhysical() ) {
660 // shading color from properties is used only for non-physical materials
661 AISShape->SetShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>() ) );
665 Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect();
666 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
667 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
668 AISShape->Attributes()->SetLineAspect( anAspect );
670 // - unfree boundaries color
671 anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
672 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
673 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
674 AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
676 // - free boundaries color
677 anAspect = AISShape->Attributes()->FreeBoundaryAspect();
678 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
679 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>() ) );
680 AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
682 // - standalone edges color
683 anAspect = AISShape->Attributes()->WireAspect();
684 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
685 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::LineColor ) ).value<QColor>() ) );
686 AISShape->Attributes()->SetWireAspect( anAspect );
688 // - color for edges in shading+edges mode
689 AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>() ) );
692 AISShape->storeBoundaryColors();
695 AISShape->SetDisplayMode( HasDisplayMode() ?
696 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
698 // display mode from properties
699 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() );
701 // set display vectors flag
702 AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
705 AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
707 // set iso properties
708 int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt();
709 int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt();
710 Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>() );
711 int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt();
712 Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect();
713 Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect();
714 uIsoAspect->SetColor( isosColor );
715 uIsoAspect->SetWidth( isosWidth );
716 uIsoAspect->SetNumber( uIsos );
717 vIsoAspect->SetColor( isosColor );
718 vIsoAspect->SetWidth( isosWidth );
719 vIsoAspect->SetNumber( vIsos );
720 AISShape->Attributes()->SetUIsoAspect( uIsoAspect );
721 AISShape->Attributes()->SetVIsoAspect( vIsoAspect );
723 // set deflection coefficient
724 // ... to avoid to small values of the coefficient, its lower value is limited
725 AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) );
728 bool textureAdded = false;
729 if ( HasTexture() ) {
730 // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function
731 AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) );
732 if ( ! entry.isEmpty() ) {
733 // check that study is active
734 SalomeApp_Study* study = getActiveStudy();
736 // Store the texture in object properties for next displays
737 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
738 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
740 // Update porpeties map
741 propMap = getObjectProperties( study, entry, myViewFrame );
747 // Texture from properties
748 QString aTexture = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
749 if ( !aTexture.isEmpty() ) {
750 AISShape->SetTextureFileName( TCollection_AsciiString( aTexture.toStdString().c_str() ) );
756 AISShape->SetTextureMapOn();
757 AISShape->DisableTextureModulate();
761 AISShape->SetWidth( HasWidth() ?
762 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
764 // libe width from properties
765 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
767 // set top-level flag
768 AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() );
770 // set point marker (for vertex / compound of vertices only)
772 QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() );
773 if ( aList.size() == 2 ) {
774 // standard marker string contains "TypeOfMarker:ScaleOfMarker"
775 int aTypeOfMarker = aList[0].toInt();
776 double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5;
777 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
778 anAspect->SetScale( aScaleOfMarker );
779 anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) );
780 anAspect->SetColor( HasColor() ?
781 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
782 (Quantity_NameOfColor)GetColor() :
783 // color from properties
784 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ) );
785 AISShape->Attributes()->SetPointAspect( anAspect );
787 else if ( aList.size() == 1 ) {
788 // custom marker string contains "IdOfTexture"
789 int textureId = aList[0].toInt();
790 Standard_Integer aWidth, aHeight;
791 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
792 Handle(TColStd_HArray1OfByte) aTexture =
794 Handle(Graphic3d_HArray1OfBytes) aTexture =
796 GeometryGUI::getTexture( study, textureId, aWidth, aHeight );
797 if ( !aTexture.IsNull() ) {
798 #if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version
799 Handle(Prs3d_PointAspect) aTextureAspect =
800 new Prs3d_PointAspect( HasColor() ?
801 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
802 (Quantity_NameOfColor)GetColor() :
803 // color from properties
804 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
809 Handle(Prs3d_PointAspect) aTextureAspect =
810 new Prs3d_PointAspect( HasColor() ?
811 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
812 (Quantity_NameOfColor)GetColor() :
813 // color from properties
814 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
819 AISShape->Attributes()->SetPointAspect( aTextureAspect );
824 // set field step data
825 AISShape->setFieldStepInfo( myFieldDataType,
830 myFieldStepRangeMax );
832 if ( create && !isTemporary && aMgrId != -1 ) {
833 // set properties to the study
834 study->setObjectPropMap( aMgrId, entry, propMap );
837 // AISShape->SetName(???); ??? necessary to set name ???
840 void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
842 // check that actor is not null
843 if ( !actor ) return;
845 // check that study is active
846 SalomeApp_Study* study = getStudy();
847 if ( !study ) return;
849 // set interactive object
851 Handle( SALOME_InteractiveObject ) anIO;
853 if ( !myIO.IsNull() ) {
854 actor->setIO( myIO );
857 else if ( !myName.empty() ) {
858 // workaround to allow selection of temporary objects
859 static int tempId = 0;
860 anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
861 actor->setIO( anIO );
864 // presentation study entry (empty for temporary objects like preview)
865 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
866 // flag: temporary object
867 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
868 // currently active view window's ID (-1 if no active view)
869 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
871 // get presentation properties
872 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
875 /////////////////////////////////////////////////////////////////////////
876 // VSR: for VTK viewer currently deflection coefficient is hardcoded
877 // due to performance problem
878 // actor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR);
879 /////////////////////////////////////////////////////////////////////////
880 if ( !actor->getTopo().IsSame( myShape ) )
881 actor->SetShape( myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR );
884 Material_Model material;
885 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
886 std::vector<vtkProperty*> mprops;
887 mprops.push_back( material.getMaterialVTKProperty( true ) );
888 mprops.push_back( material.getMaterialVTKProperty( false) );
889 actor->SetMaterial( mprops );
891 // set iso-lines properties
893 // - set number of iso-lines
894 int nbIsos[2]= { 1, 1 };
895 QStringList isos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() );
896 nbIsos[0] = isos[0].toInt();
897 nbIsos[1] = isos[1].toInt();
898 actor->SetNbIsos( nbIsos );
900 // - set iso-lines width
901 actor->SetIsosWidth( propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt() );
903 // - set iso-lines color
904 c = propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>();
905 actor->SetIsosColor( c.redF(), c.greenF(), c.blueF() );
910 // - same color for all sub-actors
911 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
912 actor->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
915 // shading color (for non-physical materials)
916 if ( !material.isPhysical() ) {
917 c = propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>();
918 actor->GetFrontMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
919 actor->GetBackMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
922 // - standalone edge color
923 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
924 actor->SetIsolatedEdgeColor( c.redF(), c.greenF(), c.blueF() );
926 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
927 // - shared edges color ???
928 actor->SetSharedEdgeColor( c.redF(), c.greenF(), c.blueF() );
930 c = propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>();
931 // - free edges color ???
932 actor->SetFreeEdgeColor( c.redF(), c.greenF(), c.blueF() );
935 c = propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>();
936 actor->SetPointColor( c.redF(), c.greenF(), c.blueF() );
939 // - color for edges in shading+edges mode
940 c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>();
941 actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() );
944 actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
947 actor->SetWidth( HasWidth() ?
948 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
950 // libe width from properties
951 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
953 // set display vectors flag
954 actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
957 int displayMode = HasDisplayMode() ?
958 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
960 // display mode from properties
961 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt();
963 // specific processing of 'shading with edges' mode, as VTK provides only the following standard display modes:
964 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
965 // GEOM actor allows alternative display modes (see VTKViewer::Representation enum) and enum in GEOM_Actor:
966 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
968 if ( displayMode == 2 )
969 // this is 'Shading with edges' mode => we have to do the correct mapping to EDisplayMode
970 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
972 actor->setDisplayMode( displayMode );
977 actor->PickableOff();
979 if ( create && !isTemporary && aMgrId != -1 ) {
980 // set properties to the study
981 study->setObjectPropMap( aMgrId, entry, propMap );
985 //=================================================================
987 * GEOM_Displayer::updateDimensions
988 * Creates or renews dimension presentation for the IO.
990 //=================================================================
991 void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& theIO,
992 SALOME_OCCPrs* thePrs,
993 const gp_Ax3& theShapeLCS )
995 SalomeApp_Study* aStudy = getStudy();
1001 if ( theIO.IsNull() )
1006 SOCC_Prs* anOccPrs = dynamic_cast<SOCC_Prs*>( thePrs );
1008 AIS_ListOfInteractive aListOfIO;
1010 anOccPrs->GetObjects( aListOfIO );
1012 AIS_ListIteratorOfListOfInteractive aIterateIO( aListOfIO );
1014 // remove outdated presentations of dimensions
1015 for ( ; aIterateIO.More(); aIterateIO.Next() )
1017 const Handle(AIS_InteractiveObject)& anIO = aIterateIO.Value();
1018 if ( !anIO->IsKind( STANDARD_TYPE( AIS_Dimension ) ) )
1023 aListOfIO.Remove( aIterateIO );
1026 // prepare dimension styling
1027 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1029 QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
1030 int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
1031 double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
1032 double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
1033 bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
1034 QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
1035 QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
1037 // restore dimension presentation from saved attribute or property data
1038 AIS_ListOfInteractive aRestoredDimensions;
1040 QVariant aProperty = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
1042 GEOM::propertyName( GEOM::Dimensions ),
1045 GEOMGUI_DimensionProperty aRecords;
1047 if ( aProperty.isValid() && aProperty.canConvert<GEOMGUI_DimensionProperty>() )
1049 aRecords = aProperty.value<GEOMGUI_DimensionProperty>();
1053 aRecords.LoadFromAttribute( getStudy(), theIO->getEntry() );
1056 // create up-to-date dimension presentations
1057 for ( int aPrsIt = 0; aPrsIt < aRecords.GetNumber(); ++aPrsIt )
1059 if ( !aRecords.IsVisible( aPrsIt ) )
1064 // init dimension by type
1065 Handle(AIS_Dimension) aPrs;
1066 switch( aRecords.GetType( aPrsIt ) )
1068 case GEOMGUI_DimensionProperty::DimensionType_Length :
1070 Handle(GEOM_AISLength) aLength = new GEOM_AISLength( aPrsIt );
1071 aRecords.GetRecord( aPrsIt )->AsLength()->Update( aLength, theShapeLCS );
1076 case GEOMGUI_DimensionProperty::DimensionType_Diameter :
1078 Handle(GEOM_AISDiameter) aDiam = new GEOM_AISDiameter( aPrsIt );
1079 aRecords.GetRecord( aPrsIt )->AsDiameter()->Update( aDiam, theShapeLCS );
1084 case GEOMGUI_DimensionProperty::DimensionType_Angle :
1086 Handle(GEOM_AISAngle) anAng = new GEOM_AISAngle( aPrsIt );
1087 aRecords.GetRecord( aPrsIt )->AsAngle()->Update( anAng, theShapeLCS );
1093 aPrs->SetOwner( theIO );
1095 Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
1097 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
1099 aStyle->SetCommonColor( aColor );
1100 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1101 aStyle->MakeText3d( Standard_True );
1102 aStyle->MakeTextShaded( Standard_True );
1103 aStyle->TextAspect()->SetHeight( aFontHeight );
1104 aStyle->ArrowAspect()->SetLength( anArrowLength );
1105 aStyle->LineAspect()->SetWidth( aLineWidth );
1106 aStyle->SetTextHorizontalPosition( aPrs->DimensionAspect()->TextHorizontalPosition() );
1107 aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() );
1108 aPrs->SetDimensionAspect( aStyle );
1109 aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
1111 aListOfIO.Append( aPrs );
1114 // update presentation
1117 for ( aIterateIO.Initialize( aListOfIO ); aIterateIO.More(); aIterateIO.Next() )
1119 anOccPrs->AddObject( aIterateIO.Value() );
1123 //=================================================================
1125 * GEOM_Displayer::Erase
1126 * Calls Erase() method for each object in the given list
1128 //=================================================================
1129 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
1131 const bool updateViewer )
1133 SALOME_ListIteratorOfListIO Iter( theIOList );
1134 for ( ; Iter.More(); Iter.Next() )
1135 Erase( Iter.Value(), forced, false );
1141 //=================================================================
1143 * GEOM_Displayer::Redisplay
1144 * Calls Redisplay() method for each object in the given list
1146 //=================================================================
1147 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1148 const bool updateViewer,
1149 const bool checkActiveViewer )
1151 SALOME_ListIteratorOfListIO Iter( theIOList );
1152 for ( ; Iter.More(); Iter.Next() )
1153 Redisplay( Iter.Value(), false, checkActiveViewer );
1159 //=================================================================
1161 * GEOM_Displayer::Redisplay
1162 * Calls Redisplay() method for each object in the given list
1164 //=================================================================
1165 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1166 const bool theUpdateViewer,
1167 SALOME_View* theViewFrame )
1169 SALOME_ListIteratorOfListIO anIter( theIOList );
1170 for ( ; anIter.More(); anIter.Next() )
1172 Redisplay( anIter.Value(), false, theViewFrame );
1175 if ( theUpdateViewer )
1181 //=================================================================
1183 * GEOM_Displayer::Update
1184 * Update OCC presentaion
1185 * [ Reimplemented from SALOME_Displayer ]
1187 //=================================================================
1188 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
1190 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
1191 SalomeApp_Study* study = getStudy();
1193 if ( !occPrs || myShape.IsNull() || !study )
1196 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1199 // specific processing for local coordinate system presentation
1202 TopoDS_Face aFace = TopoDS::Face( myShape );
1203 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1204 if ( !aPlane.IsNull() )
1206 gp_Ax3 aPos = aPlane->Pln().Position();
1207 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1209 Handle(GEOM_AISTrihedron) aTrh;
1211 if ( occPrs->IsNull() )
1213 // new presentation is being created
1214 aTrh = new GEOM_AISTrihedron( aPlc );
1215 occPrs->AddObject( aTrh );
1219 // presentation is being updated
1220 AIS_ListOfInteractive aList;
1221 occPrs->GetObjects( aList );
1222 AIS_ListIteratorOfListOfInteractive anIter( aList );
1223 for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) {
1224 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
1228 if ( !aTrh.IsNull() ) {
1229 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1231 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
1232 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1234 aTrh->SetWidth( GetWidth() );
1236 if ( !myIO.IsNull() )
1238 aTrh->setIO( myIO );
1239 aTrh->SetOwner( myIO );
1241 aTrh->SetComponent( aPlc );
1242 aTrh->SetToUpdate();
1244 occPrs->SetToActivate( ToActivate() );
1250 // processing for usual geometry presentation
1253 // if presentation is empty we try to create new one
1254 if ( occPrs->IsNull() )
1256 // create presentation (specific for vectors)
1257 Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" )
1258 : new GEOM_AISShape ( myShape, "" );
1260 if( myType == GEOM_FIELD_STEP )
1261 AISShape->SetHilightMode( GEOM_AISShape::CustomHighlight );
1262 // update shape properties
1263 updateShapeProperties( AISShape, true );
1265 // add shape to the presentation
1266 occPrs->AddObject( AISShape );
1268 // In accordance with ToActivate() value object will be activated/deactivated
1269 // when it will be displayed
1270 occPrs->SetToActivate( ToActivate() );
1272 if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) {
1273 // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1275 // create additional wireframe shape
1276 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1277 aWirePrs->SetWidth(AISShape->Width());
1278 if ( !myIO.IsNull() ) {
1279 aWirePrs->setIO( myIO );
1280 aWirePrs->SetOwner( myIO );
1283 // add shape to the presentation
1284 occPrs->AddObject( aWirePrs );
1287 // if presentation is found -> set again shape for it
1290 AIS_ListOfInteractive IOList;
1291 occPrs->GetObjects( IOList );
1292 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1293 for ( ; Iter.More(); Iter.Next() )
1295 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1296 if ( AISShape.IsNull() )
1299 // re-set shape (it might be changed)
1300 if ( AISShape->Shape() != myShape )
1301 AISShape->Set( myShape );
1303 // update shape properties
1304 updateShapeProperties( AISShape, false );
1307 AISShape->UpdateSelection();
1308 AISShape->SetToUpdate();
1312 updateDimensions( myIO, occPrs, GEOMUtils::GetPosition( myShape ) );
1316 //=================================================================
1318 * GEOM_Displayer::Update
1319 * Update VTK presentaion
1320 * [ Reimplemented from SALOME_Displayer ]
1322 //=================================================================
1323 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1325 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1326 SalomeApp_Study* study = getStudy();
1328 if ( !vtkPrs || myShape.IsNull() || !study )
1331 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1334 // specific processing for local coordinate system presentation
1337 TopoDS_Face aFace = TopoDS::Face( myShape );
1338 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1339 if ( !aPlane.IsNull() ) {
1340 gp_Ax3 aPos = aPlane->Pln().Position();
1341 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1343 GEOM_VTKTrihedron* aTrh = 0;
1345 if ( vtkPrs->IsNull() ) {
1346 // new presentation is being created
1347 aTrh = GEOM_VTKTrihedron::New();
1348 vtkPrs->AddObject( aTrh );
1351 // presentation is being updated
1352 vtkActorCollection* actors = vtkPrs->GetObjects();
1354 actors->InitTraversal();
1355 vtkActor* a = actors->GetNextActor();
1356 while ( a && !aTrh ) {
1357 aTrh = GEOM_VTKTrihedron::SafeDownCast( a );
1358 a = actors->GetNextActor();
1364 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1366 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1367 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1369 #ifdef VTK_TRIHEDRON_WIDTH
1371 // VSR: currently isn't supported
1373 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1375 aTrh->SetWidth( GetWidth() );
1378 if ( !myIO.IsNull() )
1379 aTrh->setIO( myIO );
1381 aTrh->SetPlacement( aPlc );
1388 // processing for usual geometry presentation
1391 // if presentation is empty we try to create new one
1392 if ( vtkPrs->IsNull() )
1395 GEOM_Actor* actor = GEOM_Actor::New();
1396 // update actor properties
1397 updateActorProperties( actor, true );
1398 // add actor to the presentation
1399 vtkPrs->AddObject( actor );
1402 // presentation is being updated
1403 vtkActorCollection* actors = vtkPrs->GetObjects();
1405 actors->InitTraversal();
1406 vtkActor* a = actors->GetNextActor();
1408 GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a );
1410 // update actor properties
1411 updateActorProperties( actor, false );
1412 a = actors->GetNextActor();
1420 //=================================================================
1422 * GEOM_Displayer::BuildPrs
1423 * Build presentation accordint to the current viewer type
1425 //=================================================================
1426 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1428 if ( theObj->_is_nil() )
1431 myViewFrame = GetActiveView();
1432 if ( myViewFrame == 0 )
1435 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1440 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1441 myType = theObj->GetType();
1443 // Update presentation
1449 //=================================================================
1451 * GEOM_Displayer::BuildPrs
1452 * Build presentation accordint to the current viewer type
1454 //=================================================================
1455 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1457 myViewFrame = GetActiveView();
1458 if ( theShape.IsNull() || myViewFrame == 0 )
1461 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1466 setShape( theShape );
1474 //=================================================================
1476 * GEOM_Displayer::buildPresentation
1477 * Builds/finds object's presentation for the current viewer
1478 * Calls corresponding Update() method by means of double dispatch
1481 //=================================================================
1482 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1483 SALOME_View* theViewFrame )
1485 SALOME_Prs* prs = 0;
1488 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1492 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1495 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1496 theIO->setEntry( entry.toLatin1().constData() );
1497 if ( !theIO.IsNull() )
1499 // set interactive object
1501 // Find SOBject (because shape should be published previously)
1502 SUIT_Session* session = SUIT_Session::session();
1503 SUIT_Application* app = session->activeApplication();
1506 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1509 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1512 // get CORBA reference to data object
1513 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1514 if ( !CORBA::is_nil( object ) )
1516 // downcast to GEOM base object
1517 GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
1518 if ( !GeomBaseObject->_is_nil() )
1520 myType = GeomBaseObject->GetType();
1522 // downcast to GEOM object
1523 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
1524 if ( myType == GEOM_FIELD_STEP )
1526 // get the GEOM object from the field's shape
1527 GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
1528 if ( !GeomFieldStep->_is_nil() )
1530 GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
1531 if ( !GeomField->_is_nil() )
1532 GeomObject = GeomField->GetShape();
1535 // read the field step information
1536 readFieldStepInfo( GeomFieldStep );
1539 if ( !GeomObject->_is_nil() )
1541 // finally set shape
1542 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1550 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1556 //=================================================================
1558 * GEOM_Displayer::buildSubshapePresentation
1559 * Builds/finds object's presentation for the current viewer
1560 * Calls corresponding Update() method by means of double dispatch
1561 * For not published objects (for Mantis issue 0020435)
1563 //=================================================================
1564 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1565 const QString& entry,
1566 SALOME_View* theViewFrame)
1568 SALOME_Prs* prs = 0;
1571 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1575 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1578 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1579 theIO->setEntry(entry.toLatin1().constData());
1580 if (!theIO.IsNull())
1582 // set interactive object
1584 // finally set shape
1586 myType = GEOM_SUBSHAPE;
1588 UpdatePrs(prs); // Update presentation by using of the double dispatch
1594 //=================================================================
1596 * GEOM_Displayer::internalReset
1597 * Resets internal data
1600 //=================================================================
1601 void GEOM_Displayer::internalReset()
1606 myFieldDataType = GEOM::FDT_Double;
1607 myFieldDimension = 0;
1608 myFieldStepData.clear();
1609 myFieldStepName.Clear();
1610 myFieldStepRangeMin = 0;
1611 myFieldStepRangeMax = 0;
1614 //=================================================================
1616 * GEOM_Displayer::LocalSelection
1617 * Activate selection of CAD shapes with activisation of selection
1618 * of their sub-shapes (with opened local context for OCC viewer)
1620 //=================================================================
1621 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1623 SUIT_Session* session = SUIT_Session::session();
1624 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1628 LightApp_SelectionMgr* sm = app->selectionMgr();
1630 // remove all filters from selection
1633 SALOME_View* vf = GetActiveView();
1635 if (!theIO.IsNull() && !vf->isVisible(theIO))
1637 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1638 vf->LocalSelection( prs, theMode );
1639 delete prs; // delete presentation because displayer is its owner
1643 //=================================================================
1645 * GEOM_Displayer::globalSelection
1646 * Activate selection of CAD shapes without activisation of selection
1647 * of their sub-shapes (without opened local context for OCC viewer)
1649 //=================================================================
1650 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1652 TColStd_MapOfInteger aModes;
1653 aModes.Add( theMode );
1654 GlobalSelection( aModes, update );
1657 //=================================================================
1659 * GEOM_Displayer::globalSelection
1660 * Activate selection of CAD shapes without activisation of selection
1661 * of their sub-shapes (without opened local context for OCC viewer)
1663 //=================================================================
1664 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1665 const bool update, const QList<int>* theSubShapes )
1667 SUIT_Session* session = SUIT_Session::session();
1668 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1672 SALOME_View* vf = GetActiveView();
1676 // Close local context
1677 vf->GlobalSelection( update );
1679 // Set selection filters in accordance with current mode
1680 LightApp_SelectionMgr* sm = app->selectionMgr();
1684 // Remove from selection temporary objects if necessary
1685 if ( !theModes.Contains( GEOM_PREVIEW ) )
1686 clearTemporary( sm );
1688 //@ aSel->ClearIndex();
1692 // Remove filters from AIS_InteractiveContext
1693 Handle(AIS_InteractiveContext) ic;
1694 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1697 ic = viewer->getAISContext();
1699 ic->RemoveFilters();
1702 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1705 SUIT_SelectionFilter* aFilter;
1706 if ( theModes.Extent() == 1 )
1708 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1710 if ( aMode == GEOM_COMPOUNDFILTER )
1711 aFilter = getComplexFilter( theSubShapes );
1713 aFilter = getFilter( aMode );
1715 else if ( theModes.Extent() > 1 )
1717 TColStd_MapOfInteger aTopAbsModes;
1718 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1719 QList<SUIT_SelectionFilter*> aListOfFilters;
1720 for ( ; anIter.More(); anIter.Next() )
1722 SUIT_SelectionFilter* aFilter;
1723 int aMode = anIter.Key();
1724 if ( aMode == GEOM_COMPOUNDFILTER )
1725 aFilter = getComplexFilter( theSubShapes );
1727 aFilter = getFilter( aMode );
1730 aListOfFilters.append( aFilter );
1733 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1740 sm->installFilter( aFilter );
1743 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1744 ic->AddFilter( anOCCFilter );
1749 //=================================================================
1751 * GEOM_Displayer::LocalSelection
1752 * Activate selection of CAD shapes with activisation of selection
1753 * of their sub-shapes (with opened local context for OCC viewer)
1755 //=================================================================
1756 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1758 SALOME_ListIteratorOfListIO Iter( theIOList );
1759 for ( ; Iter.More(); Iter.Next() )
1760 LocalSelection( Iter.Value(), theMode );
1763 //=================================================================
1765 * GEOM_Displayer::BeforeDisplay
1766 * Called before displaying of pars. Close local context
1767 * [ Reimplemented from SALOME_Displayer ]
1769 //=================================================================
1770 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1772 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1775 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1778 if ( ic->HasOpenedContext() )
1779 ic->CloseAllContexts();
1784 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1786 UpdateColorScale(false,false);
1789 void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
1791 LightApp_Displayer::AfterErase( v, p );
1792 UpdateColorScale(false,false);
1795 //=================================================================
1797 * GEOM_Displayer::SetColor
1798 * Set color for shape displaying. If it is equal -1 then default color is used.
1799 * Available values are from Quantity_NameOfColor enumeration
1801 //=================================================================
1802 void GEOM_Displayer::SetColor( const int color )
1809 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1813 int GEOM_Displayer::GetColor() const
1818 bool GEOM_Displayer::HasColor() const
1820 return myColor != -1;
1823 void GEOM_Displayer::UnsetColor()
1827 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1828 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1829 myShadingColor = SalomeApp_Tools::color( col );
1832 //=================================================================
1834 * GEOM_Displayer::SetTexture
1835 * Set color for shape displaying. If it is equal -1 then default color is used.
1836 * Available values are from Quantity_NameOfColor enumeration
1838 //=================================================================
1839 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1841 if(texureFileName!="")
1843 myTexture = texureFileName;
1847 bool GEOM_Displayer::HasTexture() const
1849 return myTexture != "";
1852 std::string GEOM_Displayer::GetTexture() const
1857 //=================================================================
1859 * GEOM_Displayer::SetWidth
1860 * Set width of shape displaying. If it is equal -1 then default width is used.
1862 //=================================================================
1863 void GEOM_Displayer::SetWidth( const double width )
1868 double GEOM_Displayer::GetWidth() const
1873 bool GEOM_Displayer::HasWidth() const
1875 return myWidth != -1;
1878 void GEOM_Displayer::UnsetWidth()
1884 int GEOM_Displayer::GetIsosWidth() const
1889 void GEOM_Displayer::SetIsosWidth(const int width)
1891 myIsosWidth = width;
1894 bool GEOM_Displayer::HasIsosWidth() const
1896 return myIsosWidth != -1;
1900 //=================================================================
1902 * GEOM_Displayer::SetToActivate
1903 * This method is used for activisation/deactivisation of objects to be displayed
1905 //=================================================================
1906 void GEOM_Displayer::SetToActivate( const bool toActivate )
1908 myToActivate = toActivate;
1910 bool GEOM_Displayer::ToActivate() const
1912 return myToActivate;
1915 //=================================================================
1917 * GEOM_Displayer::clearTemporary
1918 * Removes from selection temporary objects
1920 //=================================================================
1921 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1923 SALOME_ListIO selected, toSelect;
1924 theSelMgr->selectedObjects( selected );
1926 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1927 Handle(SALOME_InteractiveObject) io = it.Value();
1928 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1929 toSelect.Append( it.Value() );
1932 theSelMgr->setSelectedObjects( toSelect, true );
1935 void GEOM_Displayer::SetName( const char* theName )
1940 void GEOM_Displayer::UnsetName()
1945 SalomeApp_Study* GEOM_Displayer::getStudy() const
1947 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1950 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1955 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1960 void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
1961 const int theFieldDimension,
1962 const QList<QVariant>& theFieldStepData,
1963 const TCollection_AsciiString& theFieldStepName,
1964 const double theFieldStepRangeMin,
1965 const double theFieldStepRangeMax )
1967 myFieldDataType = theFieldDataType;
1968 myFieldDimension = theFieldDimension;
1969 myFieldStepData = theFieldStepData;
1970 myFieldStepName = theFieldStepName;
1971 myFieldStepRangeMin = theFieldStepRangeMin;
1972 myFieldStepRangeMax = theFieldStepRangeMax;
1975 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
1977 _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
1978 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects
1979 GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps
1980 GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component
1981 return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) &&
1982 (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type());
1985 int GEOM_Displayer::SetDisplayMode( const int theMode )
1987 int aPrevMode = myDisplayMode;
1988 if ( theMode != -1 ) {
1989 myDisplayMode = theMode;
1990 myHasDisplayMode = true;
1998 int GEOM_Displayer::GetDisplayMode() const
2000 return myDisplayMode;
2003 int GEOM_Displayer::UnsetDisplayMode()
2005 int aPrevMode = myDisplayMode;
2006 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2007 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
2008 myHasDisplayMode = false;
2012 bool GEOM_Displayer::HasDisplayMode() const
2014 return myHasDisplayMode;
2017 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
2019 static QList<QColor> colors;
2021 if ( colors.isEmpty() ) {
2023 for (int s = 0; s < 2 ; s++)
2025 for (int v = 100; v >= 40; v = v - 20)
2027 for (int h = 0; h < 359 ; h = h + 60)
2029 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
2035 static int currentColor = 0;
2037 SALOMEDS::Color color;
2038 color.R = (double)colors[currentColor].red() / 255.0;
2039 color.G = (double)colors[currentColor].green() / 255.0;
2040 color.B = (double)colors[currentColor].blue() / 255.0;
2042 currentColor = (currentColor+1) % colors.count();
2047 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
2050 int aTolerance = 64;
2051 int anIterations = 0;
2057 if( anIterations % aPeriod == 0 )
2060 if( aTolerance < 1 )
2063 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
2065 aHue = (int)( 360.0 * rand() / RAND_MAX );
2066 //std::cout << "Hue = " << aHue << std::endl;
2068 //std::cout << "Auto colors : ";
2070 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
2071 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
2072 for( ; it != itEnd; ++it )
2074 SALOMEDS::Color anAutoColor = *it;
2075 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
2078 aQColor.getHsv( &h, &s, &v );
2079 //std::cout << h << " ";
2080 if( abs( h - aHue ) < aTolerance )
2083 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
2087 //std::cout << std::endl;
2093 //std::cout << "Hue of the returned color = " << aHue << std::endl;
2095 aColor.setHsv( aHue, 255, 255 );
2097 SALOMEDS::Color aSColor;
2098 aSColor.R = (double)aColor.red() / 255.0;
2099 aSColor.G = (double)aColor.green() / 255.0;
2100 aSColor.B = (double)aColor.blue() / 255.0;
2105 PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
2106 const QString& entry,
2109 // get default properties for the explicitly specified default view type
2110 PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
2112 if ( study && view ) {
2113 SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
2114 SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
2115 int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
2117 if ( viewModel && viewId != -1 ) {
2118 // get properties from the study
2119 PropMap storedMap = study->getObjectPropMap( viewId, entry );
2120 // overwrite default properties from stored ones (that are specified)
2121 for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
2122 if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
2123 propMap.insert( GEOM::propertyName( (GEOM::Property)prop ),
2124 storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) );
2126 // ... specific processing for color
2127 // ... current implementation is to use same stored color for all aspects
2128 // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2129 if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2130 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2131 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2132 propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2133 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2134 propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2137 if ( !entry.isEmpty() ) {
2138 // get CORBA reference to geom object
2139 _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
2141 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
2142 if ( !CORBA::is_nil( object ) ) {
2143 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object );
2144 if ( !CORBA::is_nil( geomObject ) ) { // to check
2145 // check that geom object has color properly set
2146 bool hasColor = false;
2147 SALOMEDS::Color aSColor = getColor( geomObject, hasColor );
2148 // set color from geometry object (only once, if it is not yet set in GUI)
2149 // current implementation is to use same color for all aspects
2150 // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2151 if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2152 QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B );
2153 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor );
2154 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor );
2155 propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor );
2156 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor );
2157 propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor );
2159 // check that object has point marker properly set
2160 GEOM::marker_type mType = geomObject->GetMarkerType();
2161 GEOM::marker_size mSize = geomObject->GetMarkerSize();
2162 int mTextureId = geomObject->GetMarkerTexture();
2163 bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) ||
2164 ( mType == GEOM::MT_USER && mTextureId > 0 );
2165 // set point marker from geometry object (only once, if it is not yet set in GUI)
2166 if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) {
2167 if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) {
2169 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2170 QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) );
2172 else if ( mType == GEOM::MT_USER ) {
2174 propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) );
2186 PropMap GEOM_Displayer::getDefaultPropertyMap()
2190 // get resource manager
2191 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2193 // fill in the properties map with default values
2195 // - visibility (false by default)
2196 propMap.insert( GEOM::propertyName( GEOM::Visibility ), false );
2198 // - nb isos (take default value from preferences)
2199 propMap.insert( GEOM::propertyName( GEOM::NbIsos ),
2200 QString( "%1%2%3" ).
2201 arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ).
2202 arg( GEOM::subSectionSeparator() ).
2203 arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) );
2205 // - transparency (opacity = 1-transparency)
2206 propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 );
2208 // - display mode (take default value from preferences)
2209 propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
2210 resMgr->integerValue( "Geometry", "display_mode", 0 ) );
2212 // - show edges direction flag (false by default)
2213 propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false );
2215 // - shading color (take default value from preferences)
2216 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
2217 colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
2219 // - wireframe color (take default value from preferences)
2220 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ),
2221 colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) );
2223 // - standalone edges color (take default value from preferences)
2224 propMap.insert( GEOM::propertyName( GEOM::LineColor ),
2225 colorFromResources( "line_color", QColor( 255, 0, 0 ) ) );
2227 // - free boundaries color (take default value from preferences)
2228 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ),
2229 colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) );
2231 // - points color (take default value from preferences)
2232 propMap.insert( GEOM::propertyName( GEOM::PointColor ),
2233 colorFromResources( "point_color", QColor( 255, 255, 0 ) ) );
2235 // - isos color (take default value from preferences)
2236 propMap.insert( GEOM::propertyName( GEOM::IsosColor ),
2237 colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) );
2239 // - outlines color (take default value from preferences)
2240 propMap.insert( GEOM::propertyName( GEOM::OutlineColor ),
2241 colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) );
2243 // - deflection coefficient (take default value from preferences)
2244 propMap.insert( GEOM::propertyName( GEOM::Deflection ),
2245 resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) );
2247 // - material (take default value from preferences)
2248 Material_Model material;
2249 material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
2250 propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() );
2252 // - edge width (take default value from preferences)
2253 propMap.insert( GEOM::propertyName( GEOM::LineWidth ),
2254 resMgr->integerValue( "Geometry", "edge_width", 1 ) );
2256 // - isos width (take default value from preferences)
2257 propMap.insert( GEOM::propertyName( GEOM::IsosWidth ),
2258 resMgr->integerValue( "Geometry", "isolines_width", 1 ) );
2260 // - point marker (take default value from preferences)
2261 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2262 QString( "%1%2%3" ).
2263 arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ).
2264 arg( GEOM::subSectionSeparator() ).
2265 arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) );
2267 // - top-level flag (false by default)
2268 propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false );
2273 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2274 SALOMEDS::Color aSColor;
2277 SUIT_Session* session = SUIT_Session::session();
2278 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2280 if ( app && !theGeomObject->_is_nil()) {
2281 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2284 _PTR(Study) aStudy = study->studyDS();
2285 aSColor = theGeomObject->GetColor();
2286 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2288 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2289 bool general_autocolor = true;
2290 #else // auto-color for groups only
2291 bool general_autocolor = false;
2292 #endif // GENERAL_AUTOCOLOR
2293 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2294 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2295 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2296 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2297 aSColor = getPredefinedUniqueColor();
2299 #else // old algorithm for auto-colors
2300 QList<SALOMEDS::Color> aReservedColors;
2301 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2302 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2303 if ( aMainSObject ) {
2304 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2305 for ( ; it->More(); it->Next() ) {
2306 _PTR(SObject) aChildSObject( it->Value() );
2307 GEOM::GEOM_Object_var aChildObject =
2308 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2309 if ( CORBA::is_nil( aChildObject ) )
2312 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2313 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2314 aReservedColors.append( aReservedColor );
2317 aSColor = getUniqueColor( aReservedColors );
2319 #endif // SIMPLE_AUTOCOLOR
2329 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2330 const bool eraseOnlyChildren) {
2331 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2335 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2339 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2344 // Erase from all views
2345 QList<SALOME_View*> views;
2347 ViewManagerList vmans = app->viewManagers();
2348 SUIT_ViewManager* vman;
2349 foreach ( vman, vmans ) {
2350 SUIT_ViewModel* vmod = vman->getViewModel();
2351 view = dynamic_cast<SALOME_View*> ( vmod );
2353 views.append( view );
2356 if( views.count() == 0 )
2359 //Erase childrens w/o update views
2360 DataObjectList listObj = parent->children( true );
2361 SUIT_DataObject* obj;
2362 foreach( obj, listObj ) {
2363 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2365 foreach ( view, views ) {
2366 Handle(SALOME_InteractiveObject) anIO =
2367 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2368 Erase(anIO, false, false, view);
2372 //Erase parent with view update or repaint views
2373 foreach ( view, views ) {
2374 if(!eraseOnlyChildren)
2375 Erase(theIO, false, true, view);
2381 void GEOM_Displayer::readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep )
2383 if( theGeomFieldStep->_is_nil() )
2386 GEOM::GEOM_Field_var aGeomField = theGeomFieldStep->GetField();
2387 if( aGeomField->_is_nil() )
2390 GEOM::GEOM_Object_var aGeomFieldShape = aGeomField->GetShape();
2391 if( aGeomFieldShape->_is_nil() )
2394 TCollection_AsciiString aFieldStepName( theGeomFieldStep->GetName() );
2395 TCollection_AsciiString aFieldName( aGeomField->GetName() );
2396 TCollection_AsciiString aShapeName( aGeomFieldShape->GetName() );
2398 aFieldStepName = aShapeName + "\n" + aFieldName + "\n" + aFieldStepName;
2400 GEOM::field_data_type aFieldDataType = aGeomField->GetDataType();
2402 int aFieldDimension = aGeomField->GetDimension();
2404 GEOM::string_array_var aFieldComponents = aGeomField->GetComponents();
2405 int aFieldNbComponents = aFieldComponents->length();
2407 QList<QVariant> aFieldStepData;
2408 if( aFieldDataType == GEOM::FDT_Bool )
2410 GEOM::GEOM_BoolFieldStep_var aGeomBoolFieldStep = GEOM::GEOM_BoolFieldStep::_narrow( theGeomFieldStep );
2411 if ( !aGeomBoolFieldStep->_is_nil() )
2413 GEOM::short_array_var aValues = aGeomBoolFieldStep->GetValues();
2414 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2415 aFieldStepData << (bool)aValues[i];
2418 else if( aFieldDataType == GEOM::FDT_Int )
2420 GEOM::GEOM_IntFieldStep_var aGeomIntFieldStep = GEOM::GEOM_IntFieldStep::_narrow( theGeomFieldStep );
2421 if ( !aGeomIntFieldStep->_is_nil() )
2423 GEOM::ListOfLong_var aValues = aGeomIntFieldStep->GetValues();
2424 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2425 aFieldStepData << (qlonglong)aValues[i];
2428 else if( aFieldDataType == GEOM::FDT_Double )
2430 GEOM::GEOM_DoubleFieldStep_var aGeomDoubleFieldStep = GEOM::GEOM_DoubleFieldStep::_narrow( theGeomFieldStep );
2431 if ( !aGeomDoubleFieldStep->_is_nil() )
2433 GEOM::ListOfDouble_var aValues = aGeomDoubleFieldStep->GetValues();
2434 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2435 aFieldStepData << (double)aValues[i];
2438 else if( aFieldDataType == GEOM::FDT_String )
2440 GEOM::GEOM_StringFieldStep_var aGeomStringFieldStep = GEOM::GEOM_StringFieldStep::_narrow( theGeomFieldStep );
2441 if ( !aGeomStringFieldStep->_is_nil() )
2443 GEOM::string_array_var aValues = aGeomStringFieldStep->GetValues();
2444 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2445 aFieldStepData << QString( aValues[i] );
2449 double aFieldStepRangeMin = 0, aFieldStepRangeMax = 0;
2450 aFieldStepData = groupFieldData( aFieldStepData,
2452 aFieldDataType == GEOM::FDT_String,
2454 aFieldStepRangeMax );
2456 setFieldStepInfo( aFieldDataType,
2461 aFieldStepRangeMax );
2464 QList<QVariant> GEOM_Displayer::groupFieldData( const QList<QVariant>& theFieldStepData,
2465 const int theFieldNbComponents,
2466 const bool theIsString,
2467 double& theFieldStepRangeMin,
2468 double& theFieldStepRangeMax )
2470 QList<QVariant> aResultList;
2471 theFieldStepRangeMin = 0;
2472 theFieldStepRangeMax = 0;
2474 if( theFieldStepData.isEmpty() || theFieldNbComponents < 1 )
2477 int aNbSubShapes = theFieldStepData.count() / theFieldNbComponents;
2479 QList<QVariant> aGroupedList;
2481 bool anIsBoolean = false;
2482 for( int aSubShape = 0; aSubShape < aNbSubShapes; aSubShape++ )
2485 QStringList aStringList;
2487 int aBaseIndex = aSubShape * theFieldNbComponents;
2488 for( int aComponent = 0; aComponent < theFieldNbComponents; aComponent++ )
2490 int anIndex = aComponent + aBaseIndex;
2492 const QVariant& aVariant = theFieldStepData[ anIndex ];
2495 if( aVariant.type() == QVariant::String )
2496 aStringList << aVariant.toString();
2501 if( aVariant.type() == QVariant::Bool )
2503 aValue = aVariant.toBool() ? 1.0 : 0.0;
2509 if( aVariant.type() == QVariant::Int )
2510 aValue = double( aVariant.toInt() );
2511 else if( aVariant.type() == QVariant::Double )
2512 aValue = aVariant.toDouble();
2513 aNorm += aValue * aValue;
2519 aGroupedList << aStringList.join( "\n" );
2523 aNorm /= theFieldNbComponents;
2525 aNorm = pow( aNorm, 0.5 );
2527 if( aGroupedList.isEmpty() )
2528 theFieldStepRangeMin = theFieldStepRangeMax = aNorm;
2531 theFieldStepRangeMin = Min( theFieldStepRangeMin, aNorm );
2532 theFieldStepRangeMax = Max( theFieldStepRangeMax, aNorm );
2535 aGroupedList << aNorm;
2541 theFieldStepRangeMin = 0.0;
2542 theFieldStepRangeMax = 1.0;
2545 SUIT_Session* session = SUIT_Session::session();
2546 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2547 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2549 QListIterator<QVariant> anIter( aGroupedList );
2550 while( anIter.hasNext() )
2552 const QVariant& aVariant = anIter.next();
2554 aResultList << aVariant;
2558 Quantity_Color aColor;
2559 if( FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
2560 aQColor = QColor::fromRgbF( aColor.Red(), aColor.Green(), aColor.Blue() );
2561 aResultList << aQColor;
2567 // Note: the method is copied from Aspect_ColorScale class
2568 Standard_Integer GEOM_Displayer::HueFromValue( const Standard_Integer aValue,
2569 const Standard_Integer aMin,
2570 const Standard_Integer aMax )
2572 Standard_Integer minLimit( 0 ), maxLimit( 230 );
2574 Standard_Integer aHue = maxLimit;
2576 aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( aValue - aMin ) / ( aMax - aMin ) );
2578 aHue = Min( Max( minLimit, aHue ), maxLimit );
2583 // Note: the method is copied from Aspect_ColorScale class
2584 Standard_Boolean GEOM_Displayer::FindColor( const Standard_Real aValue,
2585 const Standard_Real aMin,
2586 const Standard_Real aMax,
2587 const Standard_Integer ColorsCount,
2588 Quantity_Color& aColor )
2590 if( aValue<aMin || aValue>aMax || aMax<aMin )
2591 return Standard_False;
2595 Standard_Real IntervNumber = 0;
2598 else if( aValue>aMax )
2599 IntervNumber = ColorsCount-1;
2600 else if( Abs( aMax-aMin ) > Precision::Approximation() )
2601 IntervNumber = Floor( Standard_Real( ColorsCount ) * ( aValue - aMin ) / ( aMax - aMin ) ); // 'Ceiling' replaced with 'Floor'
2603 Standard_Integer Interv = Standard_Integer( IntervNumber );
2605 aColor = Quantity_Color( HueFromValue( Interv, 0, ColorsCount - 1 ), 1.0, 1.0, Quantity_TOC_HLS );
2607 return Standard_True;
2611 void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, const bool updateViewer )
2613 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
2617 SOCC_Viewer* aViewModel = dynamic_cast<SOCC_Viewer*>( GetActiveView() );
2621 Handle(V3d_Viewer) aViewer = aViewModel->getViewer3d();
2622 if( aViewer.IsNull() )
2625 aViewer->InitActiveViews();
2626 if( !aViewer->MoreActiveViews() )
2629 Handle(V3d_View) aView = aViewer->ActiveView();
2630 if( aView.IsNull() )
2633 Standard_Boolean anIsDisplayColorScale = Standard_False;
2634 TCollection_AsciiString aColorScaleTitle;
2635 Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
2636 Standard_Boolean anIsBoolean = Standard_False;
2638 SALOME_ListIO aSelectedObjects;
2639 myApp->selectionMgr()->selectedObjects( aSelectedObjects );
2640 if( aSelectedObjects.Extent() == 1 )
2642 Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
2643 if( !anIO.IsNull() )
2645 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
2648 AIS_ListOfInteractive aList;
2649 aPrs->GetObjects( aList );
2650 AIS_ListIteratorOfListOfInteractive anIter( aList );
2651 for( ; anIter.More(); anIter.Next() )
2653 Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
2654 if( !aShape.IsNull() )
2656 GEOM::field_data_type aFieldDataType;
2657 int aFieldDimension;
2658 QList<QVariant> aFieldStepData;
2659 TCollection_AsciiString aFieldStepName;
2660 double aFieldStepRangeMin, aFieldStepRangeMax;
2661 aShape->getFieldStepInfo( aFieldDataType,
2666 aFieldStepRangeMax );
2667 if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
2669 anIsDisplayColorScale = Standard_True;
2670 aColorScaleTitle = aFieldStepName;
2671 aColorScaleMin = aFieldStepRangeMin;
2672 aColorScaleMax = aFieldStepRangeMax;
2673 anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
2681 if( anIsDisplayColorScale )
2683 Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
2684 if( !aColorScale.IsNull() )
2686 SUIT_Session* session = SUIT_Session::session();
2687 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2689 Standard_Real anXPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
2690 Standard_Real anYPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
2691 Standard_Real aWidth = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
2692 Standard_Real aHeight = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
2693 Standard_Integer aTextHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
2694 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2696 aColorScale->SetXPosition( anXPos );
2697 aColorScale->SetYPosition( anYPos );
2698 aColorScale->SetWidth( aWidth );
2699 aColorScale->SetHeight( aHeight );
2701 aColorScale->SetTextHeight( aTextHeight );
2702 aColorScale->SetNumberOfIntervals( anIsBoolean ? 2 : aNbIntervals );
2704 aColorScale->SetTitle( aColorScaleTitle );
2705 aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
2707 if( !aView->ColorScaleIsDisplayed() )
2708 aView->ColorScaleDisplay();
2712 if( aView->ColorScaleIsDisplayed() )
2713 aView->ColorScaleErase();
2716 if( theIsRedisplayFieldSteps )
2718 _PTR(Study) aStudyDS = aStudy->studyDS();
2719 QList<SUIT_ViewManager*> vmList;
2720 myApp->viewManagers( vmList );
2721 for( QList<SUIT_ViewManager*>::Iterator vmIt = vmList.begin(); vmIt != vmList.end(); vmIt++ )
2723 if( SUIT_ViewManager* aViewManager = *vmIt )
2725 const ObjMap anObjects = aStudy->getObjectMap( aViewManager->getGlobalId() );
2726 for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ )
2728 _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) );
2731 CORBA::Object_var anObject = GeometryGUI::ClientSObjectToObject( aSObj );
2732 if( !CORBA::is_nil( anObject ) )
2734 GEOM::GEOM_FieldStep_var aFieldStep = GEOM::GEOM_FieldStep::_narrow( anObject );
2735 if( !aFieldStep->_is_nil() )
2737 CORBA::String_var aStepEntry = aFieldStep->GetStudyEntry();
2738 Handle(SALOME_InteractiveObject) aStepIO =
2739 new SALOME_InteractiveObject( aStepEntry.in(), "GEOM", "TEMP_IO" );
2740 Redisplay( aStepIO, false, false );