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"
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_TopWireframeShape.hxx>
43 #include <GEOM_AISVector.hxx>
44 #include <GEOM_AISTrihedron.hxx>
45 #include <GEOM_VTKTrihedron.hxx>
46 #include <GEOM_VTKPropertyMaterial.hxx>
48 #include <Material_Model.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_ViewWindow.h>
52 #include <SUIT_Session.h>
53 #include <SUIT_ViewManager.h>
54 #include <SUIT_ResourceMgr.h>
56 #include <Basics_OCCTVersion.hxx>
58 #include <SalomeApp_Study.h>
59 #include <SalomeApp_Application.h>
60 #include <LightApp_SelectionMgr.h>
61 #include <LightApp_DataObject.h>
62 #include <SalomeApp_TypeFilter.h>
63 #include <SalomeApp_Tools.h>
65 #include <SALOME_ListIteratorOfListIO.hxx>
66 #include <SALOME_ListIO.hxx>
67 #include <SALOME_Prs.h>
70 #include <SOCC_ViewModel.h>
73 #include <SVTK_ViewModel.h>
76 #include <AIS_Drawer.hxx>
77 #include <AIS_ListIteratorOfListOfInteractive.hxx>
78 #include <Prs3d_IsoAspect.hxx>
79 #include <Prs3d_PointAspect.hxx>
80 #include <StdSelect_TypeOfEdge.hxx>
81 #include <StdSelect_TypeOfFace.hxx>
82 #include <StdSelect_DisplayMode.hxx>
83 #include <TopoDS_Face.hxx>
84 #include <BRep_Tool.hxx>
85 #include <Geom_Plane.hxx>
86 #include <Geom_Axis2Placement.hxx>
87 #include <Graphic3d_AspectFillArea3d.hxx>
89 #include <TColStd_MapOfInteger.hxx>
90 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
91 #include <TopoDS_Iterator.hxx>
92 #include <Graphic3d_AspectMarker3d.hxx>
93 #include <TopTools_MapOfShape.hxx>
94 #include <TopTools_ListOfShape.hxx>
95 #include <TopTools_ListIteratorOfListOfShape.hxx>
98 #include <Prs3d_ShadingAspect.hxx>
100 #include <BRepMesh_IncrementalMesh.hxx>
103 #include <vtkActorCollection.h>
104 #include <vtkProperty.h>
107 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
109 #include <GEOMImpl_Types.hxx>
111 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
112 #include <TColStd_HArray1OfByte.hxx>
114 #include <Graphic3d_HArray1OfBytes.hxx>
117 // If the next macro is defined, autocolor feature works for all sub-shapes;
118 // if it is undefined, autocolor feature works for groups only
119 #define GENERAL_AUTOCOLOR
120 // Below macro, when uncommented, switches on simplified (more performant) algorithm
121 // of auto-color picking up
122 #define SIMPLE_AUTOCOLOR
124 // Hard-coded value of shape deflection coefficient for VTK viewer
125 const double VTK_MIN_DEFLECTION = 0.001;
127 //================================================================
128 // Function : getActiveStudy
129 // Purpose : Get active study, returns 0 if no open study frame
130 //================================================================
131 static inline SalomeApp_Study* getActiveStudy()
133 SUIT_Session* session = SUIT_Session::session();
134 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
136 return ( SalomeApp_Study* )app->activeStudy();
140 static inline int getViewManagerId( SALOME_View* theViewFrame) {
141 SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
142 SUIT_ViewManager* aViewMgr = 0;
144 aViewMgr = aModel->getViewManager();
145 return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
148 //================================================================
149 // Function : getTopAbsMode
150 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
151 // one from GEOMImpl_Types.h
152 //================================================================
153 static inline int getTopAbsMode( const int implType )
157 case GEOM_COMPOUND : return TopAbs_COMPOUND;
158 case GEOM_SOLID : return TopAbs_SOLID;
159 case GEOM_SHELL : return TopAbs_SHELL;
160 case GEOM_FACE : return TopAbs_FACE;
161 case GEOM_WIRE : return TopAbs_WIRE;
162 case GEOM_EDGE : return TopAbs_EDGE;
163 case GEOM_POINT : return TopAbs_VERTEX;
168 int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
170 if ( shape.IsNull() )
173 int ret = shape.ShapeType();
175 if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
176 TopoDS_Iterator it(shape, Standard_True, Standard_False);
177 for (; it.More(); it.Next()) {
178 TopoDS_Shape sub_shape = it.Value();
179 if ( sub_shape.IsNull() ) continue;
180 int stype = getMinMaxShapeType( sub_shape, ismin );
181 if ( stype == TopAbs_SHAPE ) continue;
182 if ( ismin && stype > ret )
184 else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) )
192 bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
194 return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
197 //================================================================
198 // Function : getFilter
199 // Purpose : Get filter corresponding to the type of object
200 // from GEOMImpl_Types.h
201 //================================================================
202 SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
204 SUIT_SelectionFilter* aFilter;
206 int aTopAbsMode = getTopAbsMode( theMode );
207 if ( aTopAbsMode != -1 )
208 aFilter = new GEOM_TypeFilter( getStudy(), aTopAbsMode, true ); //@ aFilter = new GEOM_TypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
212 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Line ); break;
213 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Circle ); break;
215 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Plane ); break;
216 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cylinder ); break;
217 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Sphere ); break;
218 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Torus ); break;
219 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Revol ); break;
220 case GEOM_CONE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cone ); break;
222 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter( getStudy() ); break;
224 case GEOM_ALLSHAPES : aFilter = new GEOM_SelectionFilter(getStudy(), true ); break;
225 case GEOM_ALLGEOM : aFilter = new SalomeApp_TypeFilter( getStudy(), "GEOM" ); break;
227 default : aFilter = new GEOM_TypeFilter( getStudy(), theMode ); break;
233 //================================================================
234 // Function : getComplexFilter
235 // Purpose : Get compound filter corresponding to the type of
236 // object from GEOMImpl_Types.h
237 //================================================================
238 SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList<int>* aSubShapes)
240 GEOM_CompoundFilter* aFilter;
242 if(aSubShapes != NULL ) {
243 aFilter = new GEOM_CompoundFilter(getStudy());
244 QList<int> aTopAbsTypes;
245 QList<int>::const_iterator it;
246 for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
247 int topAbsMode = getTopAbsMode(*it);
248 if(topAbsMode != -1 )
249 aTopAbsTypes.append(topAbsMode);
251 aFilter->addSubTypes(aTopAbsTypes);
257 //================================================================
258 // Function : getEntry
260 //================================================================
261 static std::string getEntry( GEOM::GEOM_Object_ptr object )
263 SUIT_Session* session = SUIT_Session::session();
264 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
267 CORBA::String_var IOR = app->orb()->object_to_string( object );
268 if ( strcmp(IOR.in(), "") != 0 )
270 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
271 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
279 //================================================================
280 // Function : getName
282 //================================================================
283 static std::string getName( GEOM::GEOM_Object_ptr object )
285 SUIT_Session* session = SUIT_Session::session();
286 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
289 CORBA::String_var IOR = app->orb()->object_to_string( object );
290 if ( strcmp(IOR.in(), "") != 0 )
292 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
293 _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
295 _PTR(GenericAttribute) anAttr;
297 if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
299 _PTR(AttributeName) aNameAttr( anAttr );
300 return aNameAttr->Value();
308 //=================================================================
310 * GEOM_Displayer::GEOM_Displayer
313 //=================================================================
314 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
317 myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
322 SUIT_Session* session = SUIT_Session::session();
323 SUIT_ResourceMgr* resMgr = session->resourceMgr();
325 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
326 myShadingColor = SalomeApp_Tools::color( col );
328 myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
329 myHasDisplayMode = false;
331 int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
332 myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
333 myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
335 myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
336 myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
337 myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
340 // This color is used for shape displaying. If it is equal -1 then
341 // default color is used.
348 // This parameter is used for activisation/deactivisation of objects to be displayed
350 #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
351 // Activate parallel vizualisation only for testing purpose
352 // and if the corresponding env variable is set to 1
353 char* parallel_visu = getenv("PARALLEL_VISU");
354 if (parallel_visu && atoi(parallel_visu))
356 MESSAGE("Parallel visualisation on");
357 BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
364 //=================================================================
366 * GEOM_Displayer::~GEOM_Displayer
369 //=================================================================
370 GEOM_Displayer::~GEOM_Displayer()
374 //=================================================================
376 * GEOM_Displayer::Display
377 * Display interactive object in the current viewer
379 //=================================================================
380 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
381 const bool updateViewer,
382 SALOME_View* theViewFrame )
384 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
387 SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
391 vf->BeforeDisplay( this, prs );
393 vf->AfterDisplay( this, prs );
398 int aMgrId = getViewManagerId(vf);
399 SalomeApp_Study* aStudy = getStudy();
400 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 );
402 setVisibilityState(theIO->getEntry(), Qtx::ShownState);
404 delete prs; // delete presentation because displayer is its owner
409 //=================================================================
411 * GEOM_Displayer::Display
412 * This overloaded Display() method can be useful for operations
413 * not using dialog boxes.
415 //=================================================================
416 void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateViewer )
418 if ( theObj->_is_nil() )
421 std::string entry = getEntry( theObj );
423 Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
428 //=================================================================
430 * GEOM_Displayer::Erase
431 * Erase interactive object in the current viewer
433 //=================================================================
434 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
436 const bool updateViewer,
437 SALOME_View* theViewFrame )
439 if ( theIO.IsNull() )
442 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
445 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
447 vf->BeforeErase( this, prs );
448 vf->Erase( prs, forced );
449 vf->AfterErase( this, prs );
452 delete prs; // delete presentation because displayer is its owner
454 int aMgrId = getViewManagerId(vf);
455 SalomeApp_Study* aStudy = getStudy();
456 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 );
458 setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
463 //=================================================================
465 * GEOM_Displayer::Erase
466 * Erase geometry object in the current viewer
468 //=================================================================
469 void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj,
471 const bool updateViewer )
473 std::string entry = getEntry( theObj );
476 Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
477 forced, updateViewer);
481 //=================================================================
483 * GEOM_Displayer::Redisplay
484 * Redisplay (erase and then display again) interactive object
485 * in the current viewer
487 //=================================================================
488 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
489 const bool updateViewer )
491 // Remove the object permanently (<forced> == true)
492 SUIT_Session* ses = SUIT_Session::session();
493 SUIT_Application* app = ses->activeApplication();
496 SUIT_Desktop* desk = app->desktop();
497 QList<SUIT_ViewWindow*> wnds = desk->windows();
498 SUIT_ViewWindow* wnd;
499 QListIterator<SUIT_ViewWindow*> it( wnds );
500 while ( it.hasNext() && (wnd = it.next()) )
502 SUIT_ViewManager* vman = wnd->getViewManager();
505 SUIT_ViewModel* vmodel = vman->getViewModel();
508 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
511 if ( view->isVisible( theIO ) || view == GetActiveView() )
513 Erase( theIO, true, false, view );
514 Display( theIO, updateViewer, view );
523 //=================================================================
525 * GEOM_Displayer::Display
526 * Calls Display() method for each object in the given list
528 //=================================================================
529 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
531 SALOME_ListIteratorOfListIO Iter( theIOList );
532 for ( ; Iter.More(); Iter.Next() ) {
533 Display( Iter.Value(), false );
539 Quantity_Color GEOM_Displayer::qColorFromResources( const QString& property, const QColor& defColor )
541 // VSR: this method can be improved in future:
542 // to improve performance, the default values from resource manager should be cached in the displayer
543 return SalomeApp_Tools::color( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ) );
546 QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor& defColor )
548 // VSR: this method can be improved in future:
549 // to improve performance, the default values from resource manager should be cached in the displayer
550 return SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor );
553 void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create )
555 // check that shape is not null
556 if ( AISShape.IsNull() ) return;
558 // check that study is active
559 SalomeApp_Study* study = getStudy();
560 if ( !study ) return;
562 if ( myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points
563 !TopoDS_Iterator(myShape).More() )
564 return; // NPAL15983 (Bug when displaying empty groups)
566 // set interactive object
568 Handle( SALOME_InteractiveObject ) anIO;
570 if ( !myIO.IsNull() ) {
571 AISShape->setIO( myIO );
572 AISShape->SetOwner( myIO );
575 else if ( !myName.empty() ) {
576 // workaround to allow selection of temporary objects
577 static int tempId = 0;
578 anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
579 AISShape->setIO( anIO );
580 AISShape->SetOwner( anIO );
583 // flag: only vertex or compound of vertices is processed (specific handling)
584 bool onlyVertex = myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape );
585 // presentation study entry (empty for temporary objects like preview)
586 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
587 // flag: temporary object
588 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
589 // currently active view window's ID (-1 if no active view)
590 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
592 // get presentation properties
593 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
595 // Temporary staff: vertex must be infinite for correct visualization
596 AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
599 Material_Model material;
600 // if predefined color isn't set in displayer(via GEOM_Displayer::SetColor() function)
602 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
603 // - set front material properties
604 AISShape->SetCurrentFacingModel( Aspect_TOFM_FRONT_SIDE );
605 AISShape->SetMaterial( material.getMaterialOCCAspect( true ) );
606 // - set back material properties
607 AISShape->SetCurrentFacingModel( Aspect_TOFM_BACK_SIDE );
608 AISShape->SetMaterial( material.getMaterialOCCAspect( false ) );
609 // - switch to default (both sides) facing mode
610 AISShape->SetCurrentFacingModel( Aspect_TOFM_BOTH_SIDE );
616 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function;
617 // we set it to the shape not taking into account material properties
618 AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() );
620 else if ( !material.isPhysical() ) {
621 // shading color from properties is used only for non-physical materials
622 AISShape->SetShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>() ) );
626 Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect();
627 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
628 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
629 AISShape->Attributes()->SetLineAspect( anAspect );
631 // - unfree boundaries color
632 anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
633 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
634 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
635 AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
637 // - free boundaries color
638 anAspect = AISShape->Attributes()->FreeBoundaryAspect();
639 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
640 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>() ) );
641 AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
643 // - standalone edges color
644 anAspect = AISShape->Attributes()->WireAspect();
645 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
646 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::LineColor ) ).value<QColor>() ) );
647 AISShape->Attributes()->SetWireAspect( anAspect );
649 // - color for edges in shading+edges mode
650 AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>() ) );
653 AISShape->storeBoundaryColors();
656 AISShape->SetDisplayMode( HasDisplayMode() ?
657 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
659 // display mode from properties
660 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() );
662 // set display vectors flag
663 AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
666 // VSR: ??? next line is commented: transparency property is set in the AfterDisplay() function
667 //AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
669 // set iso properties
670 int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt();
671 int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt();
672 Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>() );
673 int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt();
674 Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect();
675 Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect();
676 uIsoAspect->SetColor( isosColor );
677 uIsoAspect->SetWidth( isosWidth );
678 uIsoAspect->SetNumber( uIsos );
679 vIsoAspect->SetColor( isosColor );
680 vIsoAspect->SetWidth( isosWidth );
681 vIsoAspect->SetNumber( vIsos );
682 AISShape->Attributes()->SetUIsoAspect( uIsoAspect );
683 AISShape->Attributes()->SetVIsoAspect( vIsoAspect );
685 // set deflection coefficient
686 // ... to avoid to small values of the coefficient, its lower value is limited
687 AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) );
690 if ( HasTexture() ) {
691 // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function
692 AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) );
693 AISShape->SetTextureMapOn();
694 AISShape->DisableTextureModulate();
695 AISShape->SetDisplayMode( 3 );
699 AISShape->SetWidth( HasWidth() ?
700 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
702 // libe width from properties
703 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
705 // set top-level flag
706 AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() );
708 // set point marker (for vertex / compound of vertices only)
710 QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() );
711 if ( aList.size() == 2 ) {
712 // standard marker string contains "TypeOfMarker:ScaleOfMarker"
713 int aTypeOfMarker = aList[0].toInt();
714 double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5;
715 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
716 anAspect->SetScale( aScaleOfMarker );
717 anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) );
718 anAspect->SetColor( HasColor() ?
719 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
720 (Quantity_NameOfColor)GetColor() :
721 // color from properties
722 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ) );
723 AISShape->Attributes()->SetPointAspect( anAspect );
725 else if ( aList.size() == 1 ) {
726 // custom marker string contains "IdOfTexture"
727 int textureId = aList[0].toInt();
728 Standard_Integer aWidth, aHeight;
729 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
730 Handle(TColStd_HArray1OfByte) aTexture =
732 Handle(Graphic3d_HArray1OfBytes) aTexture =
734 GeometryGUI::getTexture( study, textureId, aWidth, aHeight );
735 if ( !aTexture.IsNull() ) {
736 static int TextureId = 0;
737 Handle(Prs3d_PointAspect) aTextureAspect =
738 new Prs3d_PointAspect( HasColor() ?
739 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
740 (Quantity_NameOfColor)GetColor() :
741 // color from properties
742 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
746 AISShape->Attributes()->SetPointAspect( aTextureAspect );
751 if ( create && !isTemporary && aMgrId != -1 ) {
752 // set properties to the study
753 study->setObjectPropMap( aMgrId, entry, propMap );
756 // AISShape->SetName(???); ??? necessary to set name ???
759 void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
761 // check that actor is not null
762 if ( !actor ) return;
764 // check that study is active
765 SalomeApp_Study* study = getStudy();
766 if ( !study ) return;
768 // set interactive object
770 Handle( SALOME_InteractiveObject ) anIO;
772 if ( !myIO.IsNull() ) {
773 actor->setIO( myIO );
776 else if ( !myName.empty() ) {
777 // workaround to allow selection of temporary objects
778 static int tempId = 0;
779 anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
780 actor->setIO( anIO );
783 // presentation study entry (empty for temporary objects like preview)
784 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
785 // flag: temporary object
786 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
787 // currently active view window's ID (-1 if no active view)
788 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
790 // get presentation properties
791 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
794 /////////////////////////////////////////////////////////////////////////
795 // VSR: for VTK viewer currently deflection coefficient is hardcoded
796 // due to performance problem
797 // actor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR);
798 /////////////////////////////////////////////////////////////////////////
799 if ( !actor->getTopo().IsSame( myShape ) )
800 actor->SetShape( myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR );
803 Material_Model material;
804 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
805 std::vector<vtkProperty*> mprops;
806 mprops.push_back( material.getMaterialVTKProperty( true ) );
807 mprops.push_back( material.getMaterialVTKProperty( false) );
808 actor->SetMaterial( mprops );
810 // set iso-lines properties
812 // - set number of iso-lines
813 int nbIsos[2]= { 1, 1 };
814 QStringList isos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() );
815 nbIsos[0] = isos[0].toInt();
816 nbIsos[1] = isos[1].toInt();
817 actor->SetNbIsos( nbIsos );
819 // - set iso-lines width
820 actor->SetIsosWidth( propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt() );
822 // - set iso-lines color
823 c = propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>();
824 actor->SetIsosColor( c.redF(), c.greenF(), c.blueF() );
829 // - same color for all sub-actors
830 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
831 actor->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
834 // shading color (for non-physical materials)
835 if ( !material.isPhysical() ) {
836 c = propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>();
837 actor->GetFrontMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
838 actor->GetBackMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
841 // - standalone edge color
842 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
843 actor->SetIsolatedEdgeColor( c.redF(), c.greenF(), c.blueF() );
845 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
846 // - shared edges color ???
847 actor->SetSharedEdgeColor( c.redF(), c.greenF(), c.blueF() );
849 c = propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>();
850 // - free edges color ???
851 actor->SetFreeEdgeColor( c.redF(), c.greenF(), c.blueF() );
854 c = propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>();
855 actor->SetPointColor( c.redF(), c.greenF(), c.blueF() );
858 // - color for edges in shading+edges mode
859 c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>();
860 actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() );
863 actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
866 actor->SetWidth( HasWidth() ?
867 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
869 // libe width from properties
870 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
872 // set display vectors flag
873 actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
876 int displayMode = HasDisplayMode() ?
877 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
879 // display mode from properties
880 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt();
882 // specific processing of 'shading with edges' mode, as VTK provides only the following standard display modes:
883 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
884 // GEOM actor allows alternative display modes (see VTKViewer::Representation enum) and enum in GEOM_Actor:
885 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
887 if ( displayMode == 2 )
888 // this is 'Shading with edges' mode => we have to do the correct mapping to EDisplayMode
889 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
891 actor->setDisplayMode( displayMode );
896 actor->PickableOff();
898 if ( create && !isTemporary && aMgrId != -1 ) {
899 // set properties to the study
900 study->setObjectPropMap( aMgrId, entry, propMap );
904 //=================================================================
906 * GEOM_Displayer::Erase
907 * Calls Erase() method for each object in the given list
909 //=================================================================
910 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
912 const bool updateViewer )
914 SALOME_ListIteratorOfListIO Iter( theIOList );
915 for ( ; Iter.More(); Iter.Next() )
916 Erase( Iter.Value(), forced, false );
922 //=================================================================
924 * GEOM_Displayer::Redisplay
925 * Calls Redisplay() method for each object in the given list
927 //=================================================================
928 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer )
930 SALOME_ListIteratorOfListIO Iter( theIOList );
931 for ( ; Iter.More(); Iter.Next() )
932 Redisplay( Iter.Value(), false );
938 //=================================================================
940 * GEOM_Displayer::Update
941 * Update OCC presentaion
942 * [ Reimplemented from SALOME_Displayer ]
944 //=================================================================
945 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
947 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
948 SalomeApp_Study* study = getStudy();
950 if ( !occPrs || myShape.IsNull() || !study )
953 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
956 // specific processing for local coordinate system presentation
959 TopoDS_Face aFace = TopoDS::Face( myShape );
960 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
961 if ( !aPlane.IsNull() )
963 gp_Ax3 aPos = aPlane->Pln().Position();
964 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
966 Handle(GEOM_AISTrihedron) aTrh;
968 if ( occPrs->IsNull() )
970 // new presentation is being created
971 aTrh = new GEOM_AISTrihedron( aPlc );
972 occPrs->AddObject( aTrh );
976 // presentation is being updated
977 AIS_ListOfInteractive aList;
978 occPrs->GetObjects( aList );
979 AIS_ListIteratorOfListOfInteractive anIter( aList );
980 for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) {
981 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
985 if ( !aTrh.IsNull() ) {
986 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
988 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
989 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
991 aTrh->SetWidth( GetWidth() );
993 if ( !myIO.IsNull() )
996 aTrh->SetOwner( myIO );
998 aTrh->SetComponent( aPlc );
1001 occPrs->SetToActivate( ToActivate() );
1007 // processing for usual geometry presentation
1010 // if presentation is empty we try to create new one
1011 if ( occPrs->IsNull() )
1013 // create presentation (specific for vectors)
1014 Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" )
1015 : new GEOM_AISShape ( myShape, "" );
1016 // update shape properties
1017 updateShapeProperties( AISShape, true );
1019 // add shape to the presentation
1020 occPrs->AddObject( AISShape );
1022 // In accordance with ToActivate() value object will be activated/deactivated
1023 // when it will be displayed
1024 occPrs->SetToActivate( ToActivate() );
1026 if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) {
1027 // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1029 // create additional wireframe shape
1030 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1031 aWirePrs->SetWidth(AISShape->Width());
1032 if ( !myIO.IsNull() ) {
1033 aWirePrs->setIO( myIO );
1034 aWirePrs->SetOwner( myIO );
1037 // add shape to the presentation
1038 occPrs->AddObject( aWirePrs );
1041 // if presentation is found -> set again shape for it
1044 AIS_ListOfInteractive IOList;
1045 occPrs->GetObjects( IOList );
1046 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1047 for ( ; Iter.More(); Iter.Next() )
1049 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1050 if ( AISShape.IsNull() )
1053 // re-set shape (it might be changed)
1054 if ( AISShape->Shape() != myShape )
1055 AISShape->Set( myShape );
1057 // update shape properties
1058 updateShapeProperties( AISShape, false );
1061 AISShape->UpdateSelection();
1062 AISShape->SetToUpdate();
1068 //=================================================================
1070 * GEOM_Displayer::Update
1071 * Update VTK presentaion
1072 * [ Reimplemented from SALOME_Displayer ]
1074 //=================================================================
1075 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1077 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1078 SalomeApp_Study* study = getStudy();
1080 if ( !vtkPrs || myShape.IsNull() || !study )
1083 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1086 // specific processing for local coordinate system presentation
1089 TopoDS_Face aFace = TopoDS::Face( myShape );
1090 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1091 if ( !aPlane.IsNull() ) {
1092 gp_Ax3 aPos = aPlane->Pln().Position();
1093 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1095 GEOM_VTKTrihedron* aTrh = 0;
1097 if ( vtkPrs->IsNull() ) {
1098 // new presentation is being created
1099 aTrh = GEOM_VTKTrihedron::New();
1100 vtkPrs->AddObject( aTrh );
1103 // presentation is being updated
1104 vtkActorCollection* actors = vtkPrs->GetObjects();
1106 actors->InitTraversal();
1107 vtkActor* a = actors->GetNextActor();
1108 while ( a && !aTrh ) {
1109 aTrh = GEOM_VTKTrihedron::SafeDownCast( a );
1110 a = actors->GetNextActor();
1116 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1118 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1119 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1121 #ifdef VTK_TRIHEDRON_WIDTH
1123 // VSR: currently isn't supported
1125 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1127 aTrh->SetWidth( GetWidth() );
1130 if ( !myIO.IsNull() )
1131 aTrh->setIO( myIO );
1133 aTrh->SetPlacement( aPlc );
1140 // processing for usual geometry presentation
1143 // if presentation is empty we try to create new one
1144 if ( vtkPrs->IsNull() )
1147 GEOM_Actor* actor = GEOM_Actor::New();
1148 // update actor properties
1149 updateActorProperties( actor, true );
1150 // add actor to the presentation
1151 vtkPrs->AddObject( actor );
1154 // presentation is being updated
1155 vtkActorCollection* actors = vtkPrs->GetObjects();
1157 actors->InitTraversal();
1158 vtkActor* a = actors->GetNextActor();
1160 GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a );
1162 // update actor properties
1163 updateActorProperties( actor, false );
1164 a = actors->GetNextActor();
1172 //=================================================================
1174 * GEOM_Displayer::BuildPrs
1175 * Build presentation accordint to the current viewer type
1177 //=================================================================
1178 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1180 if ( theObj->_is_nil() )
1183 myViewFrame = GetActiveView();
1184 if ( myViewFrame == 0 )
1187 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1192 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1193 myType = theObj->GetType();
1195 // Update presentation
1201 //=================================================================
1203 * GEOM_Displayer::BuildPrs
1204 * Build presentation accordint to the current viewer type
1206 //=================================================================
1207 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1209 myViewFrame = GetActiveView();
1210 if ( theShape.IsNull() || myViewFrame == 0 )
1213 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1218 setShape( theShape );
1226 //=================================================================
1228 * GEOM_Displayer::buildPresentation
1229 * Builds/finds object's presentation for the current viewer
1230 * Calls corresponding Update() method by means of double dispatch
1233 //=================================================================
1234 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1235 SALOME_View* theViewFrame )
1237 SALOME_Prs* prs = 0;
1240 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1244 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1247 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1248 theIO->setEntry( entry.toLatin1().constData() );
1249 if ( !theIO.IsNull() )
1251 // set interactive object
1253 // Find SOBject (because shape should be published previously)
1254 SUIT_Session* session = SUIT_Session::session();
1255 SUIT_Application* app = session->activeApplication();
1258 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1261 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1264 // get CORBA reference to data object
1265 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1266 if ( !CORBA::is_nil( object ) )
1268 // downcast to GEOM object
1269 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object );
1270 if ( !GeomObject->_is_nil() )
1272 // finally set shape
1273 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1274 myType = GeomObject->GetType();
1281 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1287 //=================================================================
1289 * GEOM_Displayer::buildSubshapePresentation
1290 * Builds/finds object's presentation for the current viewer
1291 * Calls corresponding Update() method by means of double dispatch
1292 * For not published objects (for Mantis issue 0020435)
1294 //=================================================================
1295 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1296 const QString& entry,
1297 SALOME_View* theViewFrame)
1299 SALOME_Prs* prs = 0;
1302 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1306 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1309 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1310 theIO->setEntry(entry.toLatin1().constData());
1311 if (!theIO.IsNull())
1313 // set interactive object
1315 // finally set shape
1317 myType = GEOM_SUBSHAPE;
1319 UpdatePrs(prs); // Update presentation by using of the double dispatch
1325 //=================================================================
1327 * GEOM_Displayer::internalReset
1328 * Resets internal data
1331 //=================================================================
1332 void GEOM_Displayer::internalReset()
1338 //=================================================================
1340 * GEOM_Displayer::LocalSelection
1341 * Activate selection of CAD shapes with activisation of selection
1342 * of their sub-shapes (with opened local context for OCC viewer)
1344 //=================================================================
1345 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1347 SUIT_Session* session = SUIT_Session::session();
1348 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1352 LightApp_SelectionMgr* sm = app->selectionMgr();
1354 // remove all filters from selection
1357 SALOME_View* vf = GetActiveView();
1359 if (!theIO.IsNull() && !vf->isVisible(theIO))
1361 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1362 vf->LocalSelection( prs, theMode );
1363 delete prs; // delete presentation because displayer is its owner
1367 //=================================================================
1369 * GEOM_Displayer::globalSelection
1370 * Activate selection of CAD shapes without activisation of selection
1371 * of their sub-shapes (without opened local context for OCC viewer)
1373 //=================================================================
1374 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1376 TColStd_MapOfInteger aModes;
1377 aModes.Add( theMode );
1378 GlobalSelection( aModes, update );
1381 //=================================================================
1383 * GEOM_Displayer::globalSelection
1384 * Activate selection of CAD shapes without activisation of selection
1385 * of their sub-shapes (without opened local context for OCC viewer)
1387 //=================================================================
1388 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1389 const bool update, const QList<int>* theSubShapes )
1391 SUIT_Session* session = SUIT_Session::session();
1392 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1396 SALOME_View* vf = GetActiveView();
1400 // Close local context
1401 vf->GlobalSelection( update );
1403 // Set selection filters in accordance with current mode
1404 LightApp_SelectionMgr* sm = app->selectionMgr();
1408 // Remove from selection temporary objects if necessary
1409 if ( !theModes.Contains( GEOM_PREVIEW ) )
1410 clearTemporary( sm );
1412 //@ aSel->ClearIndex();
1416 // Remove filters from AIS_InteractiveContext
1417 Handle(AIS_InteractiveContext) ic;
1418 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1421 ic = viewer->getAISContext();
1423 ic->RemoveFilters();
1426 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1429 SUIT_SelectionFilter* aFilter;
1430 if ( theModes.Extent() == 1 )
1432 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1434 if ( aMode == GEOM_COMPOUNDFILTER )
1435 aFilter = getComplexFilter( theSubShapes );
1437 aFilter = getFilter( aMode );
1439 else if ( theModes.Extent() > 1 )
1441 TColStd_MapOfInteger aTopAbsModes;
1442 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1443 QList<SUIT_SelectionFilter*> aListOfFilters;
1444 for ( ; anIter.More(); anIter.Next() )
1446 SUIT_SelectionFilter* aFilter;
1447 int aMode = anIter.Key();
1448 if ( aMode == GEOM_COMPOUNDFILTER )
1449 aFilter = getComplexFilter( theSubShapes );
1451 aFilter = getFilter( aMode );
1454 aListOfFilters.append( aFilter );
1457 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1464 sm->installFilter( aFilter );
1467 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1468 ic->AddFilter( anOCCFilter );
1473 //=================================================================
1475 * GEOM_Displayer::LocalSelection
1476 * Activate selection of CAD shapes with activisation of selection
1477 * of their sub-shapes (with opened local context for OCC viewer)
1479 //=================================================================
1480 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1482 SALOME_ListIteratorOfListIO Iter( theIOList );
1483 for ( ; Iter.More(); Iter.Next() )
1484 LocalSelection( Iter.Value(), theMode );
1487 //=================================================================
1489 * GEOM_Displayer::BeforeDisplay
1490 * Called before displaying of pars. Close local context
1491 * [ Reimplemented from SALOME_Displayer ]
1493 //=================================================================
1494 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1496 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1499 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1502 if ( ic->HasOpenedContext() )
1503 ic->CloseAllContexts();
1508 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1510 SalomeApp_Study* aStudy = getStudy();
1511 if (!aStudy) return;
1512 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1513 if ( vf && !p->IsNull() ) {
1514 int aMgrId = getViewManagerId( vf );
1515 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1516 const SOCC_Prs* prs = dynamic_cast<const SOCC_Prs*>( p );
1517 if ( !ic.IsNull() && prs ) {
1518 AIS_ListOfInteractive objects;
1519 prs->GetObjects( objects );
1520 AIS_ListIteratorOfListOfInteractive it( objects );
1521 for ( ; it.More(); it.Next() ) {
1522 Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() );
1523 if ( sh.IsNull() ) continue;
1524 Handle(SALOME_InteractiveObject) IO = sh->getIO();
1525 if ( IO.IsNull() ) continue;
1526 PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() );
1527 if ( aPropMap.contains( GEOM::propertyName( GEOM::Transparency ) ) ) {
1528 double transparency = aPropMap.value(GEOM::propertyName( GEOM::Transparency )).toDouble();
1529 ic->SetTransparency( sh, transparency, true );
1536 //=================================================================
1538 * GEOM_Displayer::SetColor
1539 * Set color for shape displaying. If it is equal -1 then default color is used.
1540 * Available values are from Quantity_NameOfColor enumeration
1542 //=================================================================
1543 void GEOM_Displayer::SetColor( const int color )
1550 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1554 int GEOM_Displayer::GetColor() const
1559 bool GEOM_Displayer::HasColor() const
1561 return myColor != -1;
1564 void GEOM_Displayer::UnsetColor()
1568 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1569 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1570 myShadingColor = SalomeApp_Tools::color( col );
1573 //=================================================================
1575 * GEOM_Displayer::SetTexture
1576 * Set color for shape displaying. If it is equal -1 then default color is used.
1577 * Available values are from Quantity_NameOfColor enumeration
1579 //=================================================================
1580 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1582 if(texureFileName!="")
1584 myTexture = texureFileName;
1588 bool GEOM_Displayer::HasTexture() const
1590 return myTexture != "";
1593 std::string GEOM_Displayer::GetTexture() const
1598 //=================================================================
1600 * GEOM_Displayer::SetWidth
1601 * Set width of shape displaying. If it is equal -1 then default width is used.
1603 //=================================================================
1604 void GEOM_Displayer::SetWidth( const double width )
1609 double GEOM_Displayer::GetWidth() const
1614 bool GEOM_Displayer::HasWidth() const
1616 return myWidth != -1;
1619 void GEOM_Displayer::UnsetWidth()
1625 int GEOM_Displayer::GetIsosWidth() const
1630 void GEOM_Displayer::SetIsosWidth(const int width)
1632 myIsosWidth = width;
1635 bool GEOM_Displayer::HasIsosWidth() const
1637 return myIsosWidth != -1;
1641 //=================================================================
1643 * GEOM_Displayer::SetToActivate
1644 * This method is used for activisation/deactivisation of objects to be displayed
1646 //=================================================================
1647 void GEOM_Displayer::SetToActivate( const bool toActivate )
1649 myToActivate = toActivate;
1651 bool GEOM_Displayer::ToActivate() const
1653 return myToActivate;
1656 //=================================================================
1658 * GEOM_Displayer::clearTemporary
1659 * Removes from selection temporary objects
1661 //=================================================================
1662 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1664 SALOME_ListIO selected, toSelect;
1665 theSelMgr->selectedObjects( selected );
1667 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1668 Handle(SALOME_InteractiveObject) io = it.Value();
1669 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1670 toSelect.Append( it.Value() );
1673 theSelMgr->setSelectedObjects( toSelect, true );
1676 void GEOM_Displayer::SetName( const char* theName )
1681 void GEOM_Displayer::UnsetName()
1686 SalomeApp_Study* GEOM_Displayer::getStudy() const
1688 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1691 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1696 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1701 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
1703 return viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type();
1706 int GEOM_Displayer::SetDisplayMode( const int theMode )
1708 int aPrevMode = myDisplayMode;
1709 if ( theMode != -1 ) {
1710 myDisplayMode = theMode;
1711 myHasDisplayMode = true;
1719 int GEOM_Displayer::GetDisplayMode() const
1721 return myDisplayMode;
1724 int GEOM_Displayer::UnsetDisplayMode()
1726 int aPrevMode = myDisplayMode;
1727 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1728 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
1729 myHasDisplayMode = false;
1733 bool GEOM_Displayer::HasDisplayMode() const
1735 return myHasDisplayMode;
1738 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
1740 static QList<QColor> colors;
1742 if ( colors.isEmpty() ) {
1744 for (int s = 0; s < 2 ; s++)
1746 for (int v = 100; v >= 40; v = v - 20)
1748 for (int h = 0; h < 359 ; h = h + 60)
1750 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
1756 static int currentColor = 0;
1758 SALOMEDS::Color color;
1759 color.R = (double)colors[currentColor].red() / 255.0;
1760 color.G = (double)colors[currentColor].green() / 255.0;
1761 color.B = (double)colors[currentColor].blue() / 255.0;
1763 currentColor = (currentColor+1) % colors.count();
1768 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
1771 int aTolerance = 64;
1772 int anIterations = 0;
1778 if( anIterations % aPeriod == 0 )
1781 if( aTolerance < 1 )
1784 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
1786 aHue = (int)( 360.0 * rand() / RAND_MAX );
1787 //std::cout << "Hue = " << aHue << std::endl;
1789 //std::cout << "Auto colors : ";
1791 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
1792 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
1793 for( ; it != itEnd; ++it )
1795 SALOMEDS::Color anAutoColor = *it;
1796 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
1799 aQColor.getHsv( &h, &s, &v );
1800 //std::cout << h << " ";
1801 if( abs( h - aHue ) < aTolerance )
1804 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
1808 //std::cout << std::endl;
1814 //std::cout << "Hue of the returned color = " << aHue << std::endl;
1816 aColor.setHsv( aHue, 255, 255 );
1818 SALOMEDS::Color aSColor;
1819 aSColor.R = (double)aColor.red() / 255.0;
1820 aSColor.G = (double)aColor.green() / 255.0;
1821 aSColor.B = (double)aColor.blue() / 255.0;
1826 PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
1827 const QString& entry,
1830 // get default properties for the explicitly specified default view type
1831 PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
1833 if ( study && view ) {
1834 SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
1835 SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
1836 int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
1838 if ( viewModel && viewId != -1 ) {
1839 // get properties from the study
1840 PropMap storedMap = study->getObjectPropMap( viewId, entry );
1841 // overwrite default properties from stored ones (that are specified)
1842 for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
1843 if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
1844 propMap.insert( GEOM::propertyName( (GEOM::Property)prop ),
1845 storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) );
1847 // ... specific processing for color
1848 // ... current implementation is to use same stored color for all aspects
1849 // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
1850 if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
1851 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
1852 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
1853 propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
1854 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
1855 propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
1858 if ( !entry.isEmpty() ) {
1859 // get CORBA reference to geom object
1860 _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
1862 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
1863 if ( !CORBA::is_nil( object ) ) {
1864 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object );
1865 // check that geom object has color properly set
1866 bool hasColor = false;
1867 SALOMEDS::Color aSColor = getColor( geomObject, hasColor );
1868 // set color from geometry object (only once, if it is not yet set in GUI)
1869 // current implementation is to use same color for all aspects
1870 // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
1871 if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
1872 QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B );
1873 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor );
1874 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor );
1875 propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor );
1876 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor );
1877 propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor );
1879 // check that object has point marker properly set
1880 GEOM::marker_type mType = geomObject->GetMarkerType();
1881 GEOM::marker_size mSize = geomObject->GetMarkerSize();
1882 int mTextureId = geomObject->GetMarkerTexture();
1883 bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) ||
1884 ( mType == GEOM::MT_USER && mTextureId > 0 );
1885 // set point marker from geometry object (only once, if it is not yet set in GUI)
1886 if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) {
1887 if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) {
1889 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
1890 QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) );
1892 else if ( mType == GEOM::MT_USER ) {
1894 propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) );
1905 PropMap GEOM_Displayer::getDefaultPropertyMap()
1909 // get resource manager
1910 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1912 // fill in the properties map with default values
1914 // - visibility (false by default)
1915 propMap.insert( GEOM::propertyName( GEOM::Visibility ), false );
1917 // - nb isos (take default value from preferences)
1918 propMap.insert( GEOM::propertyName( GEOM::NbIsos ),
1919 QString( "%1%2%3" ).
1920 arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ).
1921 arg( GEOM::subSectionSeparator() ).
1922 arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) );
1924 // - transparency (opacity = 1-transparency)
1925 propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 );
1927 // - display mode (take default value from preferences)
1928 propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
1929 resMgr->integerValue( "Geometry", "display_mode", 0 ) );
1931 // - show edges direction flag (false by default)
1932 propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false );
1934 // - shading color (take default value from preferences)
1935 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
1936 colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
1938 // - wireframe color (take default value from preferences)
1939 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ),
1940 colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) );
1942 // - standalone edges color (take default value from preferences)
1943 propMap.insert( GEOM::propertyName( GEOM::LineColor ),
1944 colorFromResources( "line_color", QColor( 255, 0, 0 ) ) );
1946 // - free boundaries color (take default value from preferences)
1947 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ),
1948 colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) );
1950 // - points color (take default value from preferences)
1951 propMap.insert( GEOM::propertyName( GEOM::PointColor ),
1952 colorFromResources( "point_color", QColor( 255, 255, 0 ) ) );
1954 // - isos color (take default value from preferences)
1955 propMap.insert( GEOM::propertyName( GEOM::IsosColor ),
1956 colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) );
1958 // - outlines color (take default value from preferences)
1959 propMap.insert( GEOM::propertyName( GEOM::OutlineColor ),
1960 colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) );
1962 // - deflection coefficient (take default value from preferences)
1963 propMap.insert( GEOM::propertyName( GEOM::Deflection ),
1964 resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) );
1966 // - material (take default value from preferences)
1967 Material_Model material;
1968 material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
1969 propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() );
1971 // - edge width (take default value from preferences)
1972 propMap.insert( GEOM::propertyName( GEOM::LineWidth ),
1973 resMgr->integerValue( "Geometry", "edge_width", 1 ) );
1975 // - isos width (take default value from preferences)
1976 propMap.insert( GEOM::propertyName( GEOM::IsosWidth ),
1977 resMgr->integerValue( "Geometry", "isolines_width", 1 ) );
1979 // - point marker (take default value from preferences)
1980 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
1981 QString( "%1%2%3" ).
1982 arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ).
1983 arg( GEOM::subSectionSeparator() ).
1984 arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) );
1986 // - top-level flag (false by default)
1987 propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false );
1992 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
1993 SALOMEDS::Color aSColor;
1996 SUIT_Session* session = SUIT_Session::session();
1997 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1999 if ( app && !theGeomObject->_is_nil()) {
2000 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2003 _PTR(Study) aStudy = study->studyDS();
2004 aSColor = theGeomObject->GetColor();
2005 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2007 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2008 bool general_autocolor = true;
2009 #else // auto-color for groups only
2010 bool general_autocolor = false;
2011 #endif // GENERAL_AUTOCOLOR
2012 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2013 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2014 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2015 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2016 aSColor = getPredefinedUniqueColor();
2018 #else // old algorithm for auto-colors
2019 QList<SALOMEDS::Color> aReservedColors;
2020 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2021 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2022 if ( aMainSObject ) {
2023 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2024 for ( ; it->More(); it->Next() ) {
2025 _PTR(SObject) aChildSObject( it->Value() );
2026 GEOM::GEOM_Object_var aChildObject =
2027 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2028 if ( CORBA::is_nil( aChildObject ) )
2031 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2032 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2033 aReservedColors.append( aReservedColor );
2036 aSColor = getUniqueColor( aReservedColors );
2038 #endif // SIMPLE_AUTOCOLOR
2048 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2049 const bool eraseOnlyChildren) {
2050 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2054 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2058 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2063 // Erase from all views
2064 QList<SALOME_View*> views;
2066 ViewManagerList vmans = app->viewManagers();
2067 SUIT_ViewManager* vman;
2068 foreach ( vman, vmans ) {
2069 SUIT_ViewModel* vmod = vman->getViewModel();
2070 view = dynamic_cast<SALOME_View*> ( vmod );
2072 views.append( view );
2075 if( views.count() == 0 )
2078 //Erase childrens w/o update views
2079 DataObjectList listObj = parent->children( true );
2080 SUIT_DataObject* obj;
2081 foreach( obj, listObj ) {
2082 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2084 foreach ( view, views ) {
2085 Handle(SALOME_InteractiveObject) anIO =
2086 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2087 Erase(anIO, false, false, view);
2091 //Erase parent with view update or repaint views
2092 foreach ( view, views ) {
2093 if(!eraseOnlyChildren)
2094 Erase(theIO, false, true, view);