1 // Copyright (C) 2007-2012 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 //================================================================
125 // Function : getActiveStudy
126 // Purpose : Get active study, returns 0 if no open study frame
127 //================================================================
128 static inline SalomeApp_Study* getActiveStudy()
130 SUIT_Session* session = SUIT_Session::session();
131 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
133 return ( SalomeApp_Study* )app->activeStudy();
137 static inline int getViewManagerId( SALOME_View* theViewFrame) {
138 SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
139 SUIT_ViewManager* aViewMgr = 0;
141 aViewMgr = aModel->getViewManager();
142 return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
145 //================================================================
146 // Function : getTopAbsMode
147 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
148 // one from GEOMImpl_Types.h
149 //================================================================
150 static inline int getTopAbsMode( const int implType )
154 case GEOM_COMPOUND : return TopAbs_COMPOUND;
155 case GEOM_SOLID : return TopAbs_SOLID;
156 case GEOM_SHELL : return TopAbs_SHELL;
157 case GEOM_FACE : return TopAbs_FACE;
158 case GEOM_WIRE : return TopAbs_WIRE;
159 case GEOM_EDGE : return TopAbs_EDGE;
160 case GEOM_POINT : return TopAbs_VERTEX;
165 int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
167 if ( shape.IsNull() )
170 int ret = shape.ShapeType();
172 if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
173 TopoDS_Iterator it(shape, Standard_True, Standard_False);
174 for (; it.More(); it.Next()) {
175 TopoDS_Shape sub_shape = it.Value();
176 if ( sub_shape.IsNull() ) continue;
177 int stype = getMinMaxShapeType( sub_shape, ismin );
178 if ( stype == TopAbs_SHAPE ) continue;
179 if ( ismin && stype > ret )
181 else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) )
189 bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
191 return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
194 //================================================================
195 // Function : getFilter
196 // Purpose : Get filter corresponding to the type of object
197 // from GEOMImpl_Types.h
198 //================================================================
199 SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
201 SUIT_SelectionFilter* aFilter;
203 int aTopAbsMode = getTopAbsMode( theMode );
204 if ( aTopAbsMode != -1 )
205 aFilter = new GEOM_TypeFilter( getStudy(), aTopAbsMode, true ); //@ aFilter = new GEOM_TypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
209 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Line ); break;
210 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Circle ); break;
212 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Plane ); break;
213 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cylinder ); break;
214 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Sphere ); break;
215 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Torus ); break;
216 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Revol ); break;
217 case GEOM_CONE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cone ); break;
219 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter( getStudy() ); break;
221 case GEOM_ALLSHAPES : aFilter = new GEOM_SelectionFilter(getStudy(), true ); break;
222 case GEOM_ALLGEOM : aFilter = new SalomeApp_TypeFilter( getStudy(), "GEOM" ); break;
224 default : aFilter = new GEOM_TypeFilter( getStudy(), theMode ); break;
230 //================================================================
231 // Function : getComplexFilter
232 // Purpose : Get compound filter corresponding to the type of
233 // object from GEOMImpl_Types.h
234 //================================================================
235 SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList<int>* aSubShapes)
237 GEOM_CompoundFilter* aFilter;
239 if(aSubShapes != NULL ) {
240 aFilter = new GEOM_CompoundFilter(getStudy());
241 QList<int> aTopAbsTypes;
242 QList<int>::const_iterator it;
243 for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
244 int topAbsMode = getTopAbsMode(*it);
245 if(topAbsMode != -1 )
246 aTopAbsTypes.append(topAbsMode);
248 aFilter->addSubTypes(aTopAbsTypes);
254 //================================================================
255 // Function : getEntry
257 //================================================================
258 static std::string getEntry( GEOM::GEOM_Object_ptr object )
260 SUIT_Session* session = SUIT_Session::session();
261 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
264 CORBA::String_var IOR = app->orb()->object_to_string( object );
265 if ( strcmp(IOR.in(), "") != 0 )
267 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
268 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
276 //================================================================
277 // Function : getName
279 //================================================================
280 static std::string getName( GEOM::GEOM_Object_ptr object )
282 SUIT_Session* session = SUIT_Session::session();
283 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
286 CORBA::String_var IOR = app->orb()->object_to_string( object );
287 if ( strcmp(IOR.in(), "") != 0 )
289 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
290 _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
292 _PTR(GenericAttribute) anAttr;
294 if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
296 _PTR(AttributeName) aNameAttr( anAttr );
297 return aNameAttr->Value();
305 //=================================================================
307 * GEOM_Displayer::GEOM_Displayer
310 //=================================================================
311 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
314 myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
319 SUIT_Session* session = SUIT_Session::session();
320 SUIT_ResourceMgr* resMgr = session->resourceMgr();
322 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
323 myShadingColor = SalomeApp_Tools::color( col );
325 myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
327 int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
328 myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
329 myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
331 myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
332 myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
333 myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
336 // This color is used for shape displaying. If it is equal -1 then
337 // default color is used.
344 // This parameter is used for activisation/deactivisation of objects to be displayed
346 #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
347 // Activate parallel vizualisation only for testing purpose
348 // and if the corresponding env variable is set to 1
349 char* parallel_visu = getenv("PARALLEL_VISU");
350 if (parallel_visu && atoi(parallel_visu))
352 MESSAGE("Parallel visualisation on");
353 BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
360 //=================================================================
362 * GEOM_Displayer::~GEOM_Displayer
365 //=================================================================
366 GEOM_Displayer::~GEOM_Displayer()
370 //=================================================================
372 * GEOM_Displayer::Display
373 * Display interactive object in the current viewer
375 //=================================================================
376 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
377 const bool updateViewer,
378 SALOME_View* theViewFrame )
380 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
383 SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
387 vf->BeforeDisplay( this, prs );
389 vf->AfterDisplay( this, prs );
394 int aMgrId = getViewManagerId(vf);
395 SalomeApp_Study* aStudy = getStudy();
396 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 );
398 setVisibilityState(theIO->getEntry(), Qtx::ShownState);
400 delete prs; // delete presentation because displayer is its owner
405 //=================================================================
407 * GEOM_Displayer::Display
408 * This overloaded Display() method can be useful for operations
409 * not using dialog boxes.
411 //=================================================================
412 void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateViewer )
414 if ( theObj->_is_nil() )
417 std::string entry = getEntry( theObj );
419 Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
424 //=================================================================
426 * GEOM_Displayer::Erase
427 * Erase interactive object in the current viewer
429 //=================================================================
430 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
432 const bool updateViewer,
433 SALOME_View* theViewFrame )
435 if ( theIO.IsNull() )
438 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
441 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
443 vf->BeforeErase( this, prs );
444 vf->Erase( prs, forced );
445 vf->AfterErase( this, prs );
448 delete prs; // delete presentation because displayer is its owner
450 int aMgrId = getViewManagerId(vf);
451 SalomeApp_Study* aStudy = getStudy();
452 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 );
454 setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
459 //=================================================================
461 * GEOM_Displayer::Erase
462 * Erase geometry object in the current viewer
464 //=================================================================
465 void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj,
467 const bool updateViewer )
469 std::string entry = getEntry( theObj );
472 Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
473 forced, updateViewer);
477 //=================================================================
479 * GEOM_Displayer::Redisplay
480 * Redisplay (erase and then display again) interactive object
481 * in the current viewer
483 //=================================================================
484 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
485 const bool updateViewer )
487 // Remove the object permanently (<forced> == true)
488 SUIT_Session* ses = SUIT_Session::session();
489 SUIT_Application* app = ses->activeApplication();
492 SUIT_Desktop* desk = app->desktop();
493 QList<SUIT_ViewWindow*> wnds = desk->windows();
494 SUIT_ViewWindow* wnd;
495 QListIterator<SUIT_ViewWindow*> it( wnds );
496 while ( it.hasNext() && (wnd = it.next()) )
498 SUIT_ViewManager* vman = wnd->getViewManager();
501 SUIT_ViewModel* vmodel = vman->getViewModel();
504 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
507 if ( view->isVisible( theIO ) || view == GetActiveView() )
509 Erase( theIO, true, false, view );
510 Display( theIO, updateViewer, view );
519 //=================================================================
521 * GEOM_Displayer::Display
522 * Calls Display() method for each object in the given list
524 //=================================================================
525 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
527 SALOME_ListIteratorOfListIO Iter( theIOList );
528 for ( ; Iter.More(); Iter.Next() ) {
529 Display( Iter.Value(), false );
535 //=================================================================
537 * GEOM_Displayer::Erase
538 * Calls Erase() method for each object in the given list
540 //=================================================================
541 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
543 const bool updateViewer )
545 SALOME_ListIteratorOfListIO Iter( theIOList );
546 for ( ; Iter.More(); Iter.Next() )
547 Erase( Iter.Value(), forced, false );
553 //=================================================================
555 * GEOM_Displayer::Redisplay
556 * Calls Redisplay() method for each object in the given list
558 //=================================================================
559 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer )
561 SALOME_ListIteratorOfListIO Iter( theIOList );
562 for ( ; Iter.More(); Iter.Next() )
563 Redisplay( Iter.Value(), false );
569 //=================================================================
571 * GEOM_Displayer::Update
572 * Update OCC presentaion
573 * [ Reimplemented from SALOME_Displayer ]
575 //=================================================================
576 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
578 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
582 if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE )
584 TopoDS_Face aFace = TopoDS::Face( myShape );
585 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
586 if ( !aPlane.IsNull() )
588 gp_Ax3 aPos = aPlane->Pln().Position();
589 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
591 Handle(GEOM_AISTrihedron) aTrh;
593 if ( occPrs->IsNull() )
595 aTrh = new GEOM_AISTrihedron( aPlc );
598 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
601 aTrh->SetWidth( GetWidth() );
603 if ( !myIO.IsNull() )
606 aTrh->SetOwner( myIO );
609 occPrs->AddObject( aTrh );
613 AIS_ListOfInteractive aList;
614 occPrs->GetObjects( aList );
615 AIS_ListIteratorOfListOfInteractive anIter( aList );
616 for ( ; anIter.More(); anIter.Next() )
618 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
619 if ( !aTrh.IsNull() )
621 aTrh->SetComponent( aPlc );
627 occPrs->SetToActivate( ToActivate() );
632 // if presentation is empty we try to create new one
633 if ( occPrs->IsNull() )
635 SalomeApp_Study* aStudy = getStudy();
638 if ( !myShape.IsNull() ) {
640 bool onlyVertex = (myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ));
645 aMgrId = getViewManagerId(myViewFrame);
646 anEntry = myIO->getEntry();
648 bool useStudy = !anEntry.isEmpty() && aMgrId != -1;
649 bool useObjColor = false;
650 bool useObjMarker = false;
655 //Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
656 Handle(GEOM_AISShape) AISShape;
657 if (myType == GEOM_VECTOR)
658 AISShape = new GEOM_AISVector (myShape, "");
660 if (myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points
661 !TopoDS_Iterator(myShape).More())
662 return;// NPAL15983 (Bug when displaying empty groups)
663 AISShape = new GEOM_AISShape (myShape, "");
665 // Temporary staff: vertex must be infinite for correct visualization
666 AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
669 aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
670 aDefPropMap = getDefaultPropertyMap(SOCC_Viewer::Type());
671 Quantity_Color quant_col;
672 if(aPropMap.contains(COLOR_PROP)) {
673 quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
674 AISShape->SetShadingColor( quant_col );
677 MergePropertyMaps(aPropMap, aDefPropMap);
678 if(!useObjColor && aPropMap.contains(COLOR_PROP)) {
679 quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
680 AISShape->SetShadingColor( quant_col );
683 // Setup shape properties here ..., e.g. display mode, color, transparency, etc
684 Standard_Boolean isTopLevel = Standard_False;
685 if(aPropMap.contains(TOP_LEVEL_PROP)) {
686 isTopLevel = aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
688 AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
689 AISShape->setTopLevel(isTopLevel);
691 AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
693 AISShape->SetDisplayMode( myDisplayMode );
694 AISShape->SetShadingColor( myShadingColor );
697 // Set color and number for iso lines
698 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
699 QColor col = aResMgr->colorValue( "Geometry", "isos_color",
700 QColor(int(0.5*255), int(0.5*255), int(0.5*255)) );
701 Quantity_Color aColor = SalomeApp_Tools::color( col );
703 //get the ISOS number, set transparency if need
704 int anUIsoNumber, aVIsoNumber;
706 QString anIsos = aPropMap.value(ISOS_PROP).toString();
707 QStringList uv = anIsos.split(DIGIT_SEPARATOR);
708 anUIsoNumber = uv[0].toInt();
709 aVIsoNumber = uv[1].toInt();
710 AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
712 anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
713 aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
716 Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect();
717 anAspect->SetNumber( anUIsoNumber );
718 anAspect->SetColor( aColor );
721 anAspect->SetWidth( GetIsosWidth() );
722 AISShape->Attributes()->SetUIsoAspect( anAspect );
723 anAspect = AISShape->Attributes()->VIsoAspect();
724 anAspect->SetNumber( aVIsoNumber );
726 anAspect->SetWidth( GetIsosWidth() );
727 anAspect->SetColor( aColor );
728 AISShape->Attributes()->SetVIsoAspect( anAspect );
732 AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
735 if(aPropMap.contains(MARKER_TYPE_PROP)) {
736 QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
737 if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
738 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
739 int aTypeOfMarker = aList[0].toInt();
740 double aScaleOfMarker = aList[1].toDouble();
741 anAspect->SetScale( aScaleOfMarker );
742 anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1));
743 anAspect->SetColor((Quantity_NameOfColor)GetColor());
744 AISShape->Attributes()->SetPointAspect(anAspect);
745 } else { //Custom marker string contains "IdOfTexsture"
746 int textureId = aList[0].toInt();
747 Standard_Integer aWidth, aHeight;
748 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
749 Handle(TColStd_HArray1OfByte) aTexture =
751 Handle(Graphic3d_HArray1OfBytes) aTexture =
753 GeometryGUI::getTexture(aStudy, textureId, aWidth, aHeight);
754 if (!aTexture.IsNull()) {
755 static int TextureId = 0;
756 Handle(Prs3d_PointAspect) aTextureAspect =
757 new Prs3d_PointAspect ((Quantity_NameOfColor)GetColor(),
761 AISShape->Attributes()->SetPointAspect(aTextureAspect);
775 col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
776 aColor = SalomeApp_Tools::color( col );
778 if(aPropMap.contains(MARKER_TYPE_PROP)) {
779 QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
780 if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
781 int aTypeOfMarker = aList[0].toInt();
782 double aScaleOfMarker = aList[1].toDouble();
783 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
784 anAspect->SetScale( aScaleOfMarker );
785 anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1) );
786 anAspect->SetColor( aColor );
787 AISShape->Attributes()->SetPointAspect( anAspect );
788 } else { //Custom marker string contains "IdOfTexsture"
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(aStudy, textureId, aWidth, aHeight);
797 if (!aTexture.IsNull()) {
798 static int TextureId = 0;
799 Handle(Prs3d_PointAspect) aTextureAspect =
800 new Prs3d_PointAspect (aColor, ++TextureId, aWidth, aHeight, aTexture);
801 AISShape->Attributes()->SetPointAspect( aTextureAspect );
812 col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) );
813 aColor = SalomeApp_Tools::color( col );
815 Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect();
816 anAspect->SetColor( aColor );
817 AISShape->Attributes()->SetLineAspect( anAspect );
819 // Set unfree boundaries aspect
820 anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
821 anAspect->SetColor( aColor );
822 AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
823 AISShape->storeBoundaryColors();
825 // Set free boundaries aspect
826 col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
827 aColor = SalomeApp_Tools::color( col );
829 anAspect = AISShape->Attributes()->FreeBoundaryAspect();
830 anAspect->SetColor( aColor );
831 AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
834 col = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) );
835 aColor = SalomeApp_Tools::color( col );
837 anAspect = AISShape->Attributes()->WireAspect();
838 anAspect->SetColor( aColor );
839 AISShape->Attributes()->SetWireAspect( anAspect );
841 // Set color for edges in shading
842 col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
843 aColor = SalomeApp_Tools::color( col );
844 AISShape->SetEdgesInShadingColor( aColor );
846 // bug [SALOME platform 0019868]
847 // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
848 //AISShape->SetOwnDeviationAngle( 10*PI/180 );
853 aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
854 SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
855 SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
858 aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
861 aDC = std::max( aDC, DEFLECTION_MIN ); // to avoid to small values of the coefficient
862 AISShape->SetOwnDeviationCoefficient(aDC);
868 AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str()));
869 AISShape->SetTextureMapOn();
870 AISShape->DisableTextureModulate();
871 AISShape->SetDisplayMode(3);
875 AISShape->SetWidth( GetWidth() );
877 if ( !myIO.IsNull() )
879 AISShape->setIO( myIO );
880 AISShape->SetOwner( myIO );
882 else if ( !myName.empty() )
884 // Workaround to allow selection of temporary objects
885 static int tempId = 0;
887 sprintf( buf, "TEMP_%d", tempId++ );
888 Handle( SALOME_InteractiveObject ) anObj =
889 new SALOME_InteractiveObject( buf, "GEOM", myName.c_str() );
890 AISShape->setIO( anObj );
891 AISShape->SetOwner( anObj );
894 Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO();
895 if ( !anIO.IsNull() ) {
896 _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
898 // get CORBA reference to data object
899 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
900 if ( !CORBA::is_nil( object ) ) {
901 // downcast to GEOM object
902 GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
903 bool hasColor = false;
904 SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
905 if( hasColor && useObjColor) {
906 Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
907 AISShape->SetColor( aQuanColor );
908 AISShape->SetShadingColor( aQuanColor );
910 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
911 anAspect->SetColor( aQuanColor );
912 anAspect->SetScale( myScaleOfMarker );
913 anAspect->SetTypeOfMarker( myTypeOfMarker );
914 AISShape->Attributes()->SetPointAspect( anAspect );
916 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, SalomeApp_Tools::color( aQuanColor ) );
917 } else if( !hasColor ) {
918 //In case if color wasn't defined in the property map of the object
919 //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
920 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
921 Quantity_Color aQuanColor = SalomeApp_Tools::color( col );
922 AISShape->SetShadingColor( aQuanColor );
923 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, col );
928 GEOM::marker_type aType = aGeomObject->GetMarkerType();
929 GEOM::marker_size aSize = aGeomObject->GetMarkerSize();
930 if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) {
931 Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 );
932 double aMSize = ((int)aSize+1)*0.5;
933 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
934 anAspect->SetScale( aMSize );
935 anAspect->SetTypeOfMarker( aMType );
936 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
938 aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
939 anAspect->SetColor( aQuanColor );
940 AISShape->Attributes()->SetPointAspect( anAspect );
942 else if ( aType == GEOM::MT_USER ) {
943 int aTextureId = aGeomObject->GetMarkerTexture();
944 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
945 if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
946 Standard_Integer aWidth, aHeight;
947 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
948 Handle(TColStd_HArray1OfByte) aTexture =
950 Handle(Graphic3d_HArray1OfBytes) aTexture =
952 GeometryGUI::getTexture(getStudy(), aTextureId, aWidth, aHeight);
953 if (!aTexture.IsNull()) {
954 static int TextureId = 0;
955 Handle(Prs3d_PointAspect) aTextureAspect =
956 new Prs3d_PointAspect(aQuanColor, ++TextureId, aWidth, aHeight, aTexture );
957 AISShape->Attributes()->SetPointAspect( aTextureAspect );
959 } else { //Use marker from the preferences
960 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
961 anAspect->SetScale( myScaleOfMarker );
962 anAspect->SetTypeOfMarker( myTypeOfMarker );
963 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
965 aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
966 anAspect->SetColor( aQuanColor );
967 AISShape->Attributes()->SetPointAspect( anAspect );
973 // get material properties, set material
974 Material_Model material;
976 // Get material property from study and construct material model
977 material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
979 // Get material property from study and construct material model
980 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
981 material.fromResources( mname );
984 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() );
986 // Set material for the selected shape
987 AISShape->SetMaterial( material.getMaterialOCCAspect() );
989 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
991 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() );
994 // AISShape->SetName(???); ??? necessary to set name ???
995 occPrs->AddObject( AISShape );
997 // In accordance with ToActivate() value object will be activated/deactivated
998 // when it will be displayed
999 occPrs->SetToActivate( ToActivate() );
1001 if( AISShape->isTopLevel() && AISShape->topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor) {
1002 //21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1003 // Display wireframe presentation additionally
1004 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1005 aWirePrs->SetWidth(AISShape->Width());
1006 if ( !myIO.IsNull() ) {
1007 aWirePrs->setIO( myIO );
1008 aWirePrs->SetOwner( myIO );
1010 occPrs->AddObject(aWirePrs);
1014 // if presentation is found -> set again shape for it
1017 if ( !myShape.IsNull() )
1019 AIS_ListOfInteractive IOList;
1020 occPrs->GetObjects( IOList );
1021 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1022 for ( ; Iter.More(); Iter.Next() )
1024 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1025 if ( AISShape.IsNull() )
1027 if ( AISShape->Shape() != myShape )
1029 AISShape->Set( myShape );
1030 AISShape->UpdateSelection();
1031 AISShape->SetToUpdate();
1033 if ( !myIO.IsNull() )
1035 AISShape->setIO( myIO );
1036 AISShape->SetOwner( myIO );
1044 //=================================================================
1046 * GEOM_Displayer::Update
1047 * Update VTK presentaion
1048 * [ Reimplemented from SALOME_Displayer ]
1050 //=================================================================
1051 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1053 SalomeApp_Study* aStudy = getStudy();
1055 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1057 if ( !vtkPrs || myShape.IsNull() || !aStudy)
1060 bool useStudy = false;
1061 bool useObjCol = false;
1064 vtkActorCollection* theActors = 0;
1067 if(!myIO.IsNull()) {
1068 anEntry = myIO->getEntry();
1071 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) {
1072 //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657)
1073 GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
1076 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1077 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1080 Handle(Geom_Plane) aPlane =
1081 Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( TopoDS::Face( myShape ) ) );
1082 if ( aPlane.IsNull() )
1085 gp_Ax2 anAx2 = aPlane->Pln().Position().Ax2();
1086 aTrh->SetPlacement( new Geom_Axis2Placement( anAx2 ) );
1088 // if ( SVTK_Viewer* vf = dynamic_cast<SVTK_Viewer*>( GetActiveView() ) )
1089 // aTrh->SetSize( 0.5 * vf->GetTrihedronSize() );
1091 vtkPrs->AddObject( aTrh );
1093 theActors = vtkActorCollection::New();
1094 theActors->AddItem( aTrh );
1097 PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
1099 if(!myIO.IsNull()) {
1100 aMgrId = getViewManagerId(myViewFrame);
1102 useStudy = !anEntry.isEmpty() && aMgrId != -1;
1105 theActors = vtkActorCollection::New();
1106 GEOM_Actor* aGeomActor = GEOM_Actor::New();
1107 aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR);
1108 theActors->AddItem(aGeomActor);
1109 aGeomActor->Delete();
1112 aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
1113 if(!aPropMap.contains(COLOR_PROP))
1115 MergePropertyMaps(aPropMap, aDefPropMap);
1119 theActors->InitTraversal();
1121 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
1123 vtkProperty* aProp = 0;
1125 if ( HasColor() || HasWidth() )
1127 aProp = vtkProperty::New();
1128 aProp->SetRepresentationToWireframe();
1133 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1134 aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1137 while ( anActor != NULL )
1139 SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor );
1141 GActor->setIO( myIO );
1145 GActor->SetProperty( aProp );
1146 GActor->SetPreviewProperty( aProp );
1149 GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor );
1150 if ( aGeomGActor != 0 )
1153 aGeomGActor->SetShadingProperty( aProp );
1154 aGeomGActor->SetWireframeProperty( aProp );
1157 // Set color for edges in shading
1158 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1160 QColor c = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
1161 aGeomGActor->SetEdgesInShadingColor( c.red()/255., c.green()/255., c.blue()/255. );
1164 int aIsos[2]= { 1, 1 };
1166 QString anIsos = aPropMap.value(ISOS_PROP).toString();
1167 QStringList uv = anIsos.split(DIGIT_SEPARATOR);
1168 aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt();
1169 aGeomGActor->SetNbIsos(aIsos);
1170 aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
1171 SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
1172 SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
1173 aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
1174 int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
1175 // Specially processing of 'Shading with edges' mode from preferences,
1176 // because there is the following enum in VTK viewer:
1177 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
1178 // (see VTKViewer::Representation enum) and the following enum in GEOM_Actor:
1179 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
1180 if ( aDispModeId == 2 )
1181 // this is 'Shading with edges' mode => do the correct mapping to EDisplayMode
1182 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
1184 aGeomGActor->setDisplayMode(aDispModeId);
1185 aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
1187 // Create material model
1188 Material_Model material;
1189 material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
1190 // Set material properties for the object
1191 aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
1192 // Set the same front and back materials for the selected shape
1193 std::vector<vtkProperty*> aProps;
1194 aProps.push_back( material.getMaterialVTKProperty() );
1195 aGeomGActor->SetMaterial(aProps);
1197 vtkFloatingPointType aColor[3] = {1.,0.,0.};
1198 if ( useObjCol ) { //Get Color from geom object
1199 Handle( SALOME_InteractiveObject ) anIO = aGeomGActor->getIO();
1200 if ( !anIO.IsNull() ) {
1201 _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
1203 // get CORBA reference to data object
1204 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1205 if ( !CORBA::is_nil( object ) ) {
1206 // downcast to GEOM object
1207 GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
1208 bool hasColor = false;
1209 SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
1211 aColor[0] = aSColor.R; aColor[1] = aSColor.G; aColor[2] = aSColor.B;
1213 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1215 QColor c = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1216 aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
1219 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, QColor( aColor[0] *255, aColor[1] * 255, aColor[2]* 255) );
1224 QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
1225 aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
1228 if ( !material.isPhysical() )
1229 aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
1232 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1234 // Create material model
1235 Material_Model material;
1236 // Get material name from resources
1237 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
1238 material.fromResources( mname );
1239 // Set material properties for the object
1240 aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
1241 // Set material for the selected shape
1242 std::vector<vtkProperty*> aProps;
1243 aProps.push_back( material.getMaterialVTKProperty() );
1244 aGeomGActor->SetMaterial(aProps);
1251 aGeomGActor->SetWidth( GetWidth() );
1253 if ( HasIsosWidth() )
1254 aGeomGActor->SetIsosWidth( GetIsosWidth() );
1258 GActor->PickableOn();
1260 GActor->PickableOff();
1262 vtkPrs->AddObject( GActor );
1264 anActor = (vtkActor*)theActors->GetNextActor();
1270 theActors->Delete();
1273 //=================================================================
1275 * GEOM_Displayer::BuildPrs
1276 * Build presentation accordint to the current viewer type
1278 //=================================================================
1279 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1281 if ( theObj->_is_nil() )
1284 myViewFrame = GetActiveView();
1285 if ( myViewFrame == 0 )
1288 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1293 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1294 myType = theObj->GetType();
1296 // Update presentation
1302 //=================================================================
1304 * GEOM_Displayer::BuildPrs
1305 * Build presentation accordint to the current viewer type
1307 //=================================================================
1308 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1310 myViewFrame = GetActiveView();
1311 if ( theShape.IsNull() || myViewFrame == 0 )
1314 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1319 setShape( theShape );
1327 //=================================================================
1329 * GEOM_Displayer::buildPresentation
1330 * Builds/finds object's presentation for the current viewer
1331 * Calls corresponding Update() method by means of double dispatch
1334 //=================================================================
1335 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1336 SALOME_View* theViewFrame )
1338 SALOME_Prs* prs = 0;
1341 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1345 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1348 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1349 theIO->setEntry( entry.toLatin1().constData() );
1350 if ( !theIO.IsNull() )
1352 // set interactive object
1354 // Find SOBject (because shape should be published previously)
1355 SUIT_Session* session = SUIT_Session::session();
1356 SUIT_Application* app = session->activeApplication();
1359 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1362 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1365 // get CORBA reference to data object
1366 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1367 if ( !CORBA::is_nil( object ) )
1369 // downcast to GEOM object
1370 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object );
1371 if ( !GeomObject->_is_nil() )
1373 // finally set shape
1374 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1375 myType = GeomObject->GetType();
1382 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1388 //=================================================================
1390 * GEOM_Displayer::buildSubshapePresentation
1391 * Builds/finds object's presentation for the current viewer
1392 * Calls corresponding Update() method by means of double dispatch
1393 * For not published objects (for Mantis issue 0020435)
1395 //=================================================================
1396 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1397 const QString& entry,
1398 SALOME_View* theViewFrame)
1400 SALOME_Prs* prs = 0;
1403 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1407 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1410 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1411 theIO->setEntry(entry.toLatin1().constData());
1412 if (!theIO.IsNull())
1414 // set interactive object
1416 // finally set shape
1418 myType = GEOM_SUBSHAPE;
1420 UpdatePrs(prs); // Update presentation by using of the double dispatch
1426 //=================================================================
1428 * GEOM_Displayer::internalReset
1429 * Resets internal data
1432 //=================================================================
1433 void GEOM_Displayer::internalReset()
1439 //=================================================================
1441 * GEOM_Displayer::LocalSelection
1442 * Activate selection of CAD shapes with activisation of selection
1443 * of their sub-shapes (with opened local context for OCC viewer)
1445 //=================================================================
1446 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1448 SUIT_Session* session = SUIT_Session::session();
1449 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1453 LightApp_SelectionMgr* sm = app->selectionMgr();
1455 // remove all filters from selection
1458 SALOME_View* vf = GetActiveView();
1460 if (!theIO.IsNull() && !vf->isVisible(theIO))
1462 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1463 vf->LocalSelection( prs, theMode );
1464 delete prs; // delete presentation because displayer is its owner
1468 //=================================================================
1470 * GEOM_Displayer::globalSelection
1471 * Activate selection of CAD shapes without activisation of selection
1472 * of their sub-shapes (without opened local context for OCC viewer)
1474 //=================================================================
1475 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1477 TColStd_MapOfInteger aModes;
1478 aModes.Add( theMode );
1479 GlobalSelection( aModes, update );
1482 //=================================================================
1484 * GEOM_Displayer::globalSelection
1485 * Activate selection of CAD shapes without activisation of selection
1486 * of their sub-shapes (without opened local context for OCC viewer)
1488 //=================================================================
1489 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1490 const bool update, const QList<int>* theSubShapes )
1492 SUIT_Session* session = SUIT_Session::session();
1493 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1497 SALOME_View* vf = GetActiveView();
1501 // Close local context
1502 vf->GlobalSelection( update );
1504 // Set selection filters in accordance with current mode
1505 LightApp_SelectionMgr* sm = app->selectionMgr();
1509 // Remove from selection temporary objects if necessary
1510 if ( !theModes.Contains( GEOM_PREVIEW ) )
1511 clearTemporary( sm );
1513 //@ aSel->ClearIndex();
1517 // Remove filters from AIS_InteractiveContext
1518 Handle(AIS_InteractiveContext) ic;
1519 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1522 ic = viewer->getAISContext();
1524 ic->RemoveFilters();
1527 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1530 SUIT_SelectionFilter* aFilter;
1531 if ( theModes.Extent() == 1 )
1533 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1535 if ( aMode == GEOM_COMPOUNDFILTER )
1536 aFilter = getComplexFilter( theSubShapes );
1538 aFilter = getFilter( aMode );
1540 else if ( theModes.Extent() > 1 )
1542 TColStd_MapOfInteger aTopAbsModes;
1543 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1544 QList<SUIT_SelectionFilter*> aListOfFilters;
1545 for ( ; anIter.More(); anIter.Next() )
1547 SUIT_SelectionFilter* aFilter;
1548 int aMode = anIter.Key();
1549 if ( aMode == GEOM_COMPOUNDFILTER )
1550 aFilter = getComplexFilter( theSubShapes );
1552 aFilter = getFilter( aMode );
1555 aListOfFilters.append( aFilter );
1558 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1565 sm->installFilter( aFilter );
1568 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1569 ic->AddFilter( anOCCFilter );
1574 //=================================================================
1576 * GEOM_Displayer::LocalSelection
1577 * Activate selection of CAD shapes with activisation of selection
1578 * of their sub-shapes (with opened local context for OCC viewer)
1580 //=================================================================
1581 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1583 SALOME_ListIteratorOfListIO Iter( theIOList );
1584 for ( ; Iter.More(); Iter.Next() )
1585 LocalSelection( Iter.Value(), theMode );
1588 //=================================================================
1590 * GEOM_Displayer::BeforeDisplay
1591 * Called before displaying of pars. Close local context
1592 * [ Reimplemented from SALOME_Displayer ]
1594 //=================================================================
1595 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1597 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1600 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1603 if ( ic->HasOpenedContext() )
1604 ic->CloseAllContexts();
1609 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1611 SalomeApp_Study* aStudy = getStudy();
1612 if (!aStudy) return;
1613 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1614 if ( vf && !p->IsNull() ) {
1615 int aMgrId = getViewManagerId( vf );
1616 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1617 const SOCC_Prs* prs = dynamic_cast<const SOCC_Prs*>( p );
1618 if ( !ic.IsNull() && prs ) {
1619 AIS_ListOfInteractive objects;
1620 prs->GetObjects( objects );
1621 AIS_ListIteratorOfListOfInteractive it( objects );
1622 for ( ; it.More(); it.Next() ) {
1623 Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() );
1624 if ( sh.IsNull() ) continue;
1625 Handle(SALOME_InteractiveObject) IO = sh->getIO();
1626 if ( IO.IsNull() ) continue;
1627 PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() );
1628 if ( aPropMap.contains( TRANSPARENCY_PROP ) ) {
1629 double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble();
1630 ic->SetTransparency( sh, transparency, true );
1637 //=================================================================
1639 * GEOM_Displayer::SetColor
1640 * Set color for shape displaying. If it is equal -1 then default color is used.
1641 * Available values are from Quantity_NameOfColor enumeration
1643 //=================================================================
1644 void GEOM_Displayer::SetColor( const int color )
1651 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1655 int GEOM_Displayer::GetColor() const
1660 bool GEOM_Displayer::HasColor() const
1662 return myColor != -1;
1665 void GEOM_Displayer::UnsetColor()
1669 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1670 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1671 myShadingColor = SalomeApp_Tools::color( col );
1674 //=================================================================
1676 * GEOM_Displayer::SetTexture
1677 * Set color for shape displaying. If it is equal -1 then default color is used.
1678 * Available values are from Quantity_NameOfColor enumeration
1680 //=================================================================
1681 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1683 if(texureFileName!="")
1685 myTexture = texureFileName;
1689 bool GEOM_Displayer::HasTexture() const
1691 return myTexture != "";
1694 std::string GEOM_Displayer::GetTexture() const
1699 //=================================================================
1701 * GEOM_Displayer::SetWidth
1702 * Set width of shape displaying. If it is equal -1 then default width is used.
1704 //=================================================================
1705 void GEOM_Displayer::SetWidth( const double width )
1710 double GEOM_Displayer::GetWidth() const
1715 bool GEOM_Displayer::HasWidth() const
1717 return myWidth != -1;
1720 void GEOM_Displayer::UnsetWidth()
1726 int GEOM_Displayer::GetIsosWidth() const
1731 void GEOM_Displayer::SetIsosWidth(const int width)
1733 myIsosWidth = width;
1736 bool GEOM_Displayer::HasIsosWidth() const
1738 return myIsosWidth != -1;
1742 //=================================================================
1744 * GEOM_Displayer::SetToActivate
1745 * This method is used for activisation/deactivisation of objects to be displayed
1747 //=================================================================
1748 void GEOM_Displayer::SetToActivate( const bool toActivate )
1750 myToActivate = toActivate;
1752 bool GEOM_Displayer::ToActivate() const
1754 return myToActivate;
1757 //=================================================================
1759 * GEOM_Displayer::clearTemporary
1760 * Removes from selection temporary objects
1762 //=================================================================
1763 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1765 SALOME_ListIO selected, toSelect;
1766 theSelMgr->selectedObjects( selected );
1768 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1769 Handle(SALOME_InteractiveObject) io = it.Value();
1770 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1771 toSelect.Append( it.Value() );
1774 theSelMgr->setSelectedObjects( toSelect, true );
1777 void GEOM_Displayer::SetName( const char* theName )
1782 void GEOM_Displayer::UnsetName()
1787 SalomeApp_Study* GEOM_Displayer::getStudy() const
1789 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1792 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1797 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1802 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
1804 return viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type();
1807 int GEOM_Displayer::SetDisplayMode( const int theMode )
1809 int aPrevMode = myDisplayMode;
1810 if ( theMode != -1 )
1811 myDisplayMode = theMode;
1814 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1815 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
1820 int GEOM_Displayer::GetDisplayMode() const
1822 return myDisplayMode;
1825 int GEOM_Displayer::UnsetDisplayMode()
1827 int aPrevMode = myDisplayMode;
1828 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1829 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
1833 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
1835 static QList<QColor> colors;
1837 if ( colors.isEmpty() ) {
1838 const int rfactor = 4; // red color component split factor, must be > 0
1839 const int gfactor = 4; // green color component split factor, must be > 0
1840 const int bfactor = 3; // blue color component split factor, must be > 0
1842 // total number of pre-defined colors is defined as
1843 // nbcolors = rfactor * gfactor * bfactor
1844 // NB: all three factors should not have same values
1845 // otherwise all colors will be greyish
1847 for ( int g = 0; g < gfactor; g++ ) {
1848 for ( int r = 0; r < rfactor; r++ ) {
1849 for ( int b = 0; b < bfactor; b++ )
1850 colors.append( QColor( qRgb( r * 255 / (rfactor-1), g * 255 / (gfactor-1), b * 255 / (bfactor-1) ) ) );
1855 static int currentColor = 0;
1857 SALOMEDS::Color color;
1858 color.R = (double)colors[currentColor].red() / 255.0;
1859 color.G = (double)colors[currentColor].green() / 255.0;
1860 color.B = (double)colors[currentColor].blue() / 255.0;
1862 currentColor = (currentColor+1) % colors.count();
1867 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
1870 int aTolerance = 64;
1871 int anIterations = 0;
1877 if( anIterations % aPeriod == 0 )
1880 if( aTolerance < 1 )
1883 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
1885 aHue = (int)( 360.0 * rand() / RAND_MAX );
1886 //std::cout << "Hue = " << aHue << std::endl;
1888 //std::cout << "Auto colors : ";
1890 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
1891 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
1892 for( ; it != itEnd; ++it )
1894 SALOMEDS::Color anAutoColor = *it;
1895 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
1898 aQColor.getHsv( &h, &s, &v );
1899 //std::cout << h << " ";
1900 if( abs( h - aHue ) < aTolerance )
1903 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
1907 //std::cout << std::endl;
1913 //std::cout << "Hue of the returned color = " << aHue << std::endl;
1915 aColor.setHsv( aHue, 255, 255 );
1917 SALOMEDS::Color aSColor;
1918 aSColor.R = (double)aColor.red() / 255.0;
1919 aSColor.G = (double)aColor.green() / 255.0;
1920 aSColor.B = (double)aColor.blue() / 255.0;
1927 PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
1928 PropMap aDefaultMap;
1929 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1931 aDefaultMap.insert(VISIBILITY_PROP , 1);
1936 if(viewer_type == SOCC_Viewer::Type()) {
1937 anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
1938 aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
1939 } else if( viewer_type==SVTK_Viewer::Type()) {
1940 anUIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1);
1941 aVIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1);
1943 QString anIsos("%1%2%3");
1944 anIsos = anIsos.arg(anUIsoNumber);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(aVIsoNumber);
1945 aDefaultMap.insert(ISOS_PROP , anIsos);
1948 aDefaultMap.insert( TRANSPARENCY_PROP , 0.0 );
1951 aDefaultMap.insert( DISPLAY_MODE_PROP , aResMgr->integerValue("Geometry", "display_mode", 0));
1954 aDefaultMap.insert( VECTOR_MODE_PROP , 0);
1957 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1958 aDefaultMap.insert( COLOR_PROP , col);
1960 //7. Deflection Coeff
1963 if(viewer_type == SOCC_Viewer::Type()) {
1964 aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
1965 } else if( viewer_type==SVTK_Viewer::Type()) {
1969 aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
1972 Material_Model material;
1973 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
1974 material.fromResources( mname );
1975 aDefaultMap.insert( MATERIAL_PROP, material.toProperties() );
1977 //9. Width of the edges
1978 aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
1981 //10. Width of iso-lines
1982 aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
1984 if(viewer_type == SOCC_Viewer::Type()) {
1986 aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
1992 bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault) {
1994 if(!theOrigin.contains(VISIBILITY_PROP)) {
1995 theOrigin.insert(VISIBILITY_PROP, 0);
1998 if(!theOrigin.contains(TRANSPARENCY_PROP)) {
1999 theOrigin.insert(TRANSPARENCY_PROP, theDefault.value(TRANSPARENCY_PROP));
2002 if(!theOrigin.contains(DISPLAY_MODE_PROP)) {
2003 theOrigin.insert(DISPLAY_MODE_PROP, theDefault.value(DISPLAY_MODE_PROP));
2006 if(!theOrigin.contains(ISOS_PROP)) {
2007 theOrigin.insert(ISOS_PROP, theDefault.value(ISOS_PROP));
2010 if(!theOrigin.contains(VECTOR_MODE_PROP)) {
2011 theOrigin.insert(VECTOR_MODE_PROP, theDefault.value(VECTOR_MODE_PROP));
2014 if(!theOrigin.contains(DEFLECTION_COEFF_PROP)) {
2015 theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
2018 if(!theOrigin.contains(MATERIAL_PROP)) {
2019 theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP));
2023 if(!theOrigin.contains(EDGE_WIDTH_PROP)) {
2024 theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP));
2028 if(!theOrigin.contains(ISOS_WIDTH_PROP)) {
2029 theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP));
2033 if(!theOrigin.contains(COLOR_PROP)) {
2034 theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP));
2038 return (nbInserted > 0);
2042 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2043 SALOMEDS::Color aSColor;
2046 SUIT_Session* session = SUIT_Session::session();
2047 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2049 if ( app && !theGeomObject->_is_nil()) {
2050 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2053 _PTR(Study) aStudy = study->studyDS();
2054 aSColor = theGeomObject->GetColor();
2055 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2057 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2058 bool general_autocolor = true;
2059 #else // auto-color for groups only
2060 bool general_autocolor = false;
2061 #endif // GENERAL_AUTOCOLOR
2062 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2063 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2064 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2065 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2066 aSColor = getPredefinedUniqueColor();
2068 #else // old algorithm for auto-colors
2069 QList<SALOMEDS::Color> aReservedColors;
2070 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2071 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2072 if ( aMainSObject ) {
2073 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2074 for ( ; it->More(); it->Next() ) {
2075 _PTR(SObject) aChildSObject( it->Value() );
2076 GEOM::GEOM_Object_var aChildObject =
2077 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2078 if ( CORBA::is_nil( aChildObject ) )
2081 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2082 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2083 aReservedColors.append( aReservedColor );
2086 aSColor = getUniqueColor( aReservedColors );
2088 #endif // SIMPLE_AUTOCOLOR
2098 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2099 const bool eraseOnlyChildren) {
2100 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2104 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2108 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2113 // Erase from all views
2114 QList<SALOME_View*> views;
2116 ViewManagerList vmans = app->viewManagers();
2117 SUIT_ViewManager* vman;
2118 foreach ( vman, vmans ) {
2119 SUIT_ViewModel* vmod = vman->getViewModel();
2120 view = dynamic_cast<SALOME_View*> ( vmod );
2122 views.append( view );
2125 if( views.count() == 0 )
2128 //Erase childrens w/o update views
2129 DataObjectList listObj = parent->children( true );
2130 SUIT_DataObject* obj;
2131 foreach( obj, listObj ) {
2132 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2134 foreach ( view, views ) {
2135 Handle(SALOME_InteractiveObject) anIO =
2136 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2137 Erase(anIO, false, false, view);
2141 //Erase parent with view update or repaint views
2142 foreach ( view, views ) {
2143 if(!eraseOnlyChildren)
2144 Erase(theIO, false, true, view);