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
121 //================================================================
122 // Function : getActiveStudy
123 // Purpose : Get active study, returns 0 if no open study frame
124 //================================================================
125 static inline SalomeApp_Study* getActiveStudy()
127 SUIT_Session* session = SUIT_Session::session();
128 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
130 return ( SalomeApp_Study* )app->activeStudy();
134 static inline int getViewManagerId( SALOME_View* theViewFrame) {
135 SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
136 SUIT_ViewManager* aViewMgr = 0;
138 aViewMgr = aModel->getViewManager();
139 return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
142 //================================================================
143 // Function : getTopAbsMode
144 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
145 // one from GEOMImpl_Types.h
146 //================================================================
147 static inline int getTopAbsMode( const int implType )
151 case GEOM_COMPOUND : return TopAbs_COMPOUND;
152 case GEOM_SOLID : return TopAbs_SOLID;
153 case GEOM_SHELL : return TopAbs_SHELL;
154 case GEOM_FACE : return TopAbs_FACE;
155 case GEOM_WIRE : return TopAbs_WIRE;
156 case GEOM_EDGE : return TopAbs_EDGE;
157 case GEOM_POINT : return TopAbs_VERTEX;
162 int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
164 if ( shape.IsNull() )
167 int ret = shape.ShapeType();
169 if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
170 TopoDS_Iterator it(shape, Standard_True, Standard_False);
171 for (; it.More(); it.Next()) {
172 TopoDS_Shape sub_shape = it.Value();
173 if ( sub_shape.IsNull() ) continue;
174 int stype = getMinMaxShapeType( sub_shape, ismin );
175 if ( stype == TopAbs_SHAPE ) continue;
176 if ( ismin && stype > ret )
178 else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) )
186 bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
188 return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
191 //================================================================
192 // Function : getFilter
193 // Purpose : Get filter corresponding to the type of object
194 // from GEOMImpl_Types.h
195 //================================================================
196 SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
198 SUIT_SelectionFilter* aFilter;
200 int aTopAbsMode = getTopAbsMode( theMode );
201 if ( aTopAbsMode != -1 )
202 aFilter = new GEOM_TypeFilter( getStudy(), aTopAbsMode, true ); //@ aFilter = new GEOM_TypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
206 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Line ); break;
207 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Circle ); break;
209 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Plane ); break;
210 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cylinder ); break;
211 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Sphere ); break;
212 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Torus ); break;
213 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Revol ); break;
214 case GEOM_CONE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cone ); break;
216 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter( getStudy() ); break;
218 case GEOM_ALLSHAPES : aFilter = new GEOM_SelectionFilter(getStudy(), true ); break;
219 case GEOM_ALLGEOM : aFilter = new SalomeApp_TypeFilter( getStudy(), "GEOM" ); break;
221 default : aFilter = new GEOM_TypeFilter( getStudy(), theMode ); break;
227 //================================================================
228 // Function : getComplexFilter
229 // Purpose : Get compound filter corresponding to the type of
230 // object from GEOMImpl_Types.h
231 //================================================================
232 SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList<int>* aSubShapes)
234 GEOM_CompoundFilter* aFilter;
236 if(aSubShapes != NULL ) {
237 aFilter = new GEOM_CompoundFilter(getStudy());
238 QList<int> aTopAbsTypes;
239 QList<int>::const_iterator it;
240 for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
241 int topAbsMode = getTopAbsMode(*it);
242 if(topAbsMode != -1 )
243 aTopAbsTypes.append(topAbsMode);
245 aFilter->addSubTypes(aTopAbsTypes);
251 //================================================================
252 // Function : getEntry
254 //================================================================
255 static std::string getEntry( GEOM::GEOM_Object_ptr object )
257 SUIT_Session* session = SUIT_Session::session();
258 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
261 CORBA::String_var IOR = app->orb()->object_to_string( object );
262 if ( strcmp(IOR.in(), "") != 0 )
264 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
265 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
273 //================================================================
274 // Function : getName
276 //================================================================
277 static std::string getName( GEOM::GEOM_Object_ptr object )
279 SUIT_Session* session = SUIT_Session::session();
280 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
283 CORBA::String_var IOR = app->orb()->object_to_string( object );
284 if ( strcmp(IOR.in(), "") != 0 )
286 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
287 _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
289 _PTR(GenericAttribute) anAttr;
291 if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
293 _PTR(AttributeName) aNameAttr( anAttr );
294 return aNameAttr->Value();
302 //=================================================================
304 * GEOM_Displayer::GEOM_Displayer
307 //=================================================================
308 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
311 myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
316 SUIT_Session* session = SUIT_Session::session();
317 SUIT_ResourceMgr* resMgr = session->resourceMgr();
319 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
320 myShadingColor = SalomeApp_Tools::color( col );
322 myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
324 int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
325 myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
326 myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
328 myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
329 myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
330 myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
333 // This color is used for shape displaying. If it is equal -1 then
334 // default color is used.
341 // This parameter is used for activisation/deactivisation of objects to be displayed
343 #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
344 // Activate parallel vizualisation only for testing purpose
345 // and if the corresponding env variable is set to 1
346 char* parallel_visu = getenv("PARALLEL_VISU");
347 if (parallel_visu && atoi(parallel_visu))
349 MESSAGE("Parallel visualisation on");
350 BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
357 //=================================================================
359 * GEOM_Displayer::~GEOM_Displayer
362 //=================================================================
363 GEOM_Displayer::~GEOM_Displayer()
367 //=================================================================
369 * GEOM_Displayer::Display
370 * Display interactive object in the current viewer
372 //=================================================================
373 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
374 const bool updateViewer,
375 SALOME_View* theViewFrame )
377 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
380 SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
384 vf->BeforeDisplay( this, prs );
386 vf->AfterDisplay( this, prs );
391 int aMgrId = getViewManagerId(vf);
392 SalomeApp_Study* aStudy = getStudy();
393 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 );
395 setVisibilityState(theIO->getEntry(), Qtx::ShownState);
397 delete prs; // delete presentation because displayer is its owner
402 //=================================================================
404 * GEOM_Displayer::Display
405 * This overloaded Display() method can be useful for operations
406 * not using dialog boxes.
408 //=================================================================
409 void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateViewer )
411 if ( theObj->_is_nil() )
414 std::string entry = getEntry( theObj );
416 Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
421 //=================================================================
423 * GEOM_Displayer::Erase
424 * Erase interactive object in the current viewer
426 //=================================================================
427 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
429 const bool updateViewer,
430 SALOME_View* theViewFrame )
432 if ( theIO.IsNull() )
435 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
438 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
440 vf->BeforeErase( this, prs );
441 vf->Erase( prs, forced );
442 vf->AfterErase( this, prs );
445 delete prs; // delete presentation because displayer is its owner
447 int aMgrId = getViewManagerId(vf);
448 SalomeApp_Study* aStudy = getStudy();
449 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 );
451 setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
456 //=================================================================
458 * GEOM_Displayer::Erase
459 * Erase geometry object in the current viewer
461 //=================================================================
462 void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj,
464 const bool updateViewer )
466 std::string entry = getEntry( theObj );
469 Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
470 forced, updateViewer);
474 //=================================================================
476 * GEOM_Displayer::Redisplay
477 * Redisplay (erase and then display again) interactive object
478 * in the current viewer
480 //=================================================================
481 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
482 const bool updateViewer )
484 // Remove the object permanently (<forced> == true)
485 SUIT_Session* ses = SUIT_Session::session();
486 SUIT_Application* app = ses->activeApplication();
489 SUIT_Desktop* desk = app->desktop();
490 QList<SUIT_ViewWindow*> wnds = desk->windows();
491 SUIT_ViewWindow* wnd;
492 QListIterator<SUIT_ViewWindow*> it( wnds );
493 while ( it.hasNext() && (wnd = it.next()) )
495 SUIT_ViewManager* vman = wnd->getViewManager();
498 SUIT_ViewModel* vmodel = vman->getViewModel();
501 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
504 if ( view->isVisible( theIO ) || view == GetActiveView() )
506 Erase( theIO, true, false, view );
507 Display( theIO, updateViewer, view );
516 //=================================================================
518 * GEOM_Displayer::Display
519 * Calls Display() method for each object in the given list
521 //=================================================================
522 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
524 SALOME_ListIteratorOfListIO Iter( theIOList );
525 for ( ; Iter.More(); Iter.Next() ) {
526 Display( Iter.Value(), false );
532 //=================================================================
534 * GEOM_Displayer::Erase
535 * Calls Erase() method for each object in the given list
537 //=================================================================
538 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
540 const bool updateViewer )
542 SALOME_ListIteratorOfListIO Iter( theIOList );
543 for ( ; Iter.More(); Iter.Next() )
544 Erase( Iter.Value(), forced, false );
550 //=================================================================
552 * GEOM_Displayer::Redisplay
553 * Calls Redisplay() method for each object in the given list
555 //=================================================================
556 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer )
558 SALOME_ListIteratorOfListIO Iter( theIOList );
559 for ( ; Iter.More(); Iter.Next() )
560 Redisplay( Iter.Value(), false );
566 //=================================================================
568 * GEOM_Displayer::Update
569 * Update OCC presentaion
570 * [ Reimplemented from SALOME_Displayer ]
572 //=================================================================
573 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
575 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
579 if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE )
581 TopoDS_Face aFace = TopoDS::Face( myShape );
582 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
583 if ( !aPlane.IsNull() )
585 gp_Ax3 aPos = aPlane->Pln().Position();
586 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
588 Handle(GEOM_AISTrihedron) aTrh;
590 if ( occPrs->IsNull() )
592 aTrh = new GEOM_AISTrihedron( aPlc );
595 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
598 aTrh->SetWidth( GetWidth() );
600 if ( !myIO.IsNull() )
603 aTrh->SetOwner( myIO );
606 occPrs->AddObject( aTrh );
610 AIS_ListOfInteractive aList;
611 occPrs->GetObjects( aList );
612 AIS_ListIteratorOfListOfInteractive anIter( aList );
613 for ( ; anIter.More(); anIter.Next() )
615 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
616 if ( !aTrh.IsNull() )
618 aTrh->SetComponent( aPlc );
624 occPrs->SetToActivate( ToActivate() );
629 // if presentation is empty we try to create new one
630 if ( occPrs->IsNull() )
632 SalomeApp_Study* aStudy = getStudy();
635 if ( !myShape.IsNull() ) {
637 bool onlyVertex = (myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ));
642 aMgrId = getViewManagerId(myViewFrame);
643 anEntry = myIO->getEntry();
645 bool useStudy = !anEntry.isEmpty() && aMgrId != -1;
646 bool useObjColor = false;
647 bool useObjMarker = false;
652 //Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
653 Handle(GEOM_AISShape) AISShape;
654 if (myType == GEOM_VECTOR)
655 AISShape = new GEOM_AISVector (myShape, "");
657 if (myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points
658 !TopoDS_Iterator(myShape).More())
659 return;// NPAL15983 (Bug when displaying empty groups)
660 AISShape = new GEOM_AISShape (myShape, "");
662 // Temporary staff: vertex must be infinite for correct visualization
663 AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
666 aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
667 aDefPropMap = getDefaultPropertyMap(SOCC_Viewer::Type());
668 Quantity_Color quant_col;
669 if(aPropMap.contains(COLOR_PROP)) {
670 quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
671 AISShape->SetShadingColor( quant_col );
674 MergePropertyMaps(aPropMap, aDefPropMap);
675 if(!useObjColor && aPropMap.contains(COLOR_PROP)) {
676 quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
677 AISShape->SetShadingColor( quant_col );
680 // Setup shape properties here ..., e.g. display mode, color, transparency, etc
681 Standard_Boolean isTopLevel = Standard_False;
682 if(aPropMap.contains(TOP_LEVEL_PROP)) {
683 isTopLevel = aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
685 AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
686 AISShape->setTopLevel(isTopLevel);
688 AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
690 AISShape->SetDisplayMode( myDisplayMode );
691 AISShape->SetShadingColor( myShadingColor );
694 // Set color and number for iso lines
695 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
696 QColor col = aResMgr->colorValue( "Geometry", "isos_color",
697 QColor(int(0.5*255), int(0.5*255), int(0.5*255)) );
698 Quantity_Color aColor = SalomeApp_Tools::color( col );
700 //get the ISOS number, set transparency if need
701 int anUIsoNumber, aVIsoNumber;
703 QString anIsos = aPropMap.value(ISOS_PROP).toString();
704 QStringList uv = anIsos.split(DIGIT_SEPARATOR);
705 anUIsoNumber = uv[0].toInt();
706 aVIsoNumber = uv[1].toInt();
707 AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
709 anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
710 aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
713 Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect();
714 anAspect->SetNumber( anUIsoNumber );
715 anAspect->SetColor( aColor );
718 anAspect->SetWidth( GetIsosWidth() );
719 AISShape->Attributes()->SetUIsoAspect( anAspect );
720 anAspect = AISShape->Attributes()->VIsoAspect();
721 anAspect->SetNumber( aVIsoNumber );
723 anAspect->SetWidth( GetIsosWidth() );
724 anAspect->SetColor( aColor );
725 AISShape->Attributes()->SetVIsoAspect( anAspect );
729 AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
732 if(aPropMap.contains(MARKER_TYPE_PROP)) {
733 QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
734 if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
735 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
736 int aTypeOfMarker = aList[0].toInt();
737 double aScaleOfMarker = aList[1].toDouble();
738 anAspect->SetScale( aScaleOfMarker );
739 anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1));
740 anAspect->SetColor((Quantity_NameOfColor)GetColor());
741 AISShape->Attributes()->SetPointAspect(anAspect);
742 } else { //Custom marker string contains "IdOfTexsture"
743 int textureId = aList[0].toInt();
744 Standard_Integer aWidth, aHeight;
745 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
746 Handle(TColStd_HArray1OfByte) aTexture =
748 Handle(Graphic3d_HArray1OfBytes) aTexture =
750 GeometryGUI::getTexture(aStudy, textureId, aWidth, aHeight);
751 if (!aTexture.IsNull()) {
752 static int TextureId = 0;
753 Handle(Prs3d_PointAspect) aTextureAspect =
754 new Prs3d_PointAspect ((Quantity_NameOfColor)GetColor(),
758 AISShape->Attributes()->SetPointAspect(aTextureAspect);
772 col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
773 aColor = SalomeApp_Tools::color( col );
775 if(aPropMap.contains(MARKER_TYPE_PROP)) {
776 QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
777 if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
778 int aTypeOfMarker = aList[0].toInt();
779 double aScaleOfMarker = aList[1].toDouble();
780 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
781 anAspect->SetScale( aScaleOfMarker );
782 anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1) );
783 anAspect->SetColor( aColor );
784 AISShape->Attributes()->SetPointAspect( anAspect );
785 } else { //Custom marker string contains "IdOfTexsture"
786 int textureId = aList[0].toInt();
787 Standard_Integer aWidth, aHeight;
788 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
789 Handle(TColStd_HArray1OfByte) aTexture =
791 Handle(Graphic3d_HArray1OfBytes) aTexture =
793 GeometryGUI::getTexture(aStudy, textureId, aWidth, aHeight);
794 if (!aTexture.IsNull()) {
795 static int TextureId = 0;
796 Handle(Prs3d_PointAspect) aTextureAspect =
797 new Prs3d_PointAspect (aColor, ++TextureId, aWidth, aHeight, aTexture);
798 AISShape->Attributes()->SetPointAspect( aTextureAspect );
809 col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) );
810 aColor = SalomeApp_Tools::color( col );
812 Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect();
813 anAspect->SetColor( aColor );
814 AISShape->Attributes()->SetLineAspect( anAspect );
816 // Set unfree boundaries aspect
817 anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
818 anAspect->SetColor( aColor );
819 AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
820 AISShape->storeBoundaryColors();
822 // Set free boundaries aspect
823 col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
824 aColor = SalomeApp_Tools::color( col );
826 anAspect = AISShape->Attributes()->FreeBoundaryAspect();
827 anAspect->SetColor( aColor );
828 AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
831 col = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) );
832 aColor = SalomeApp_Tools::color( col );
834 anAspect = AISShape->Attributes()->WireAspect();
835 anAspect->SetColor( aColor );
836 AISShape->Attributes()->SetWireAspect( anAspect );
838 // Set color for edges in shading
839 col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
840 aColor = SalomeApp_Tools::color( col );
841 AISShape->SetEdgesInShadingColor( aColor );
843 // bug [SALOME platform 0019868]
844 // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
845 //AISShape->SetOwnDeviationAngle( 10*PI/180 );
850 aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
851 SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
852 SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
855 aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
858 aDC = std::max( aDC, DEFLECTION_MIN ); // to avoid to small values of the coefficient
859 AISShape->SetOwnDeviationCoefficient(aDC);
865 AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str()));
866 AISShape->SetTextureMapOn();
867 AISShape->DisableTextureModulate();
868 AISShape->SetDisplayMode(3);
872 AISShape->SetWidth( GetWidth() );
874 if ( !myIO.IsNull() )
876 AISShape->setIO( myIO );
877 AISShape->SetOwner( myIO );
879 else if ( !myName.empty() )
881 // Workaround to allow selection of temporary objects
882 static int tempId = 0;
884 sprintf( buf, "TEMP_%d", tempId++ );
885 Handle( SALOME_InteractiveObject ) anObj =
886 new SALOME_InteractiveObject( buf, "GEOM", myName.c_str() );
887 AISShape->setIO( anObj );
888 AISShape->SetOwner( anObj );
891 Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO();
892 if ( !anIO.IsNull() ) {
893 _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
895 // get CORBA reference to data object
896 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
897 if ( !CORBA::is_nil( object ) ) {
898 // downcast to GEOM object
899 GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
900 bool hasColor = false;
901 SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
902 if( hasColor && useObjColor) {
903 Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
904 AISShape->SetColor( aQuanColor );
905 AISShape->SetShadingColor( aQuanColor );
907 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
908 anAspect->SetColor( aQuanColor );
909 anAspect->SetScale( myScaleOfMarker );
910 anAspect->SetTypeOfMarker( myTypeOfMarker );
911 AISShape->Attributes()->SetPointAspect( anAspect );
913 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, SalomeApp_Tools::color( aQuanColor ) );
914 } else if( !hasColor ) {
915 //In case if color wasn't defined in the property map of the object
916 //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
917 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
918 Quantity_Color aQuanColor = SalomeApp_Tools::color( col );
919 AISShape->SetShadingColor( aQuanColor );
920 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, col );
925 GEOM::marker_type aType = aGeomObject->GetMarkerType();
926 GEOM::marker_size aSize = aGeomObject->GetMarkerSize();
927 if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) {
928 Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 );
929 double aMSize = ((int)aSize+1)*0.5;
930 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
931 anAspect->SetScale( aMSize );
932 anAspect->SetTypeOfMarker( aMType );
933 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
935 aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
936 anAspect->SetColor( aQuanColor );
937 AISShape->Attributes()->SetPointAspect( anAspect );
939 else if ( aType == GEOM::MT_USER ) {
940 int aTextureId = aGeomObject->GetMarkerTexture();
941 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
942 if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
943 Standard_Integer aWidth, aHeight;
944 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
945 Handle(TColStd_HArray1OfByte) aTexture =
947 Handle(Graphic3d_HArray1OfBytes) aTexture =
949 GeometryGUI::getTexture(getStudy(), aTextureId, aWidth, aHeight);
950 if (!aTexture.IsNull()) {
951 static int TextureId = 0;
952 Handle(Prs3d_PointAspect) aTextureAspect =
953 new Prs3d_PointAspect(aQuanColor, ++TextureId, aWidth, aHeight, aTexture );
954 AISShape->Attributes()->SetPointAspect( aTextureAspect );
956 } else { //Use marker from the preferences
957 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
958 anAspect->SetScale( myScaleOfMarker );
959 anAspect->SetTypeOfMarker( myTypeOfMarker );
960 Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
962 aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
963 anAspect->SetColor( aQuanColor );
964 AISShape->Attributes()->SetPointAspect( anAspect );
970 // get material properties, set material
971 Material_Model material;
973 // Get material property from study and construct material model
974 material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
976 // Get material property from study and construct material model
977 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
978 material.fromResources( mname );
981 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() );
983 // Set material for the selected shape
984 AISShape->SetMaterial( material.getMaterialOCCAspect() );
986 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
988 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() );
991 // AISShape->SetName(???); ??? necessary to set name ???
992 occPrs->AddObject( AISShape );
994 // In accordance with ToActivate() value object will be activated/deactivated
995 // when it will be displayed
996 occPrs->SetToActivate( ToActivate() );
998 if( AISShape->isTopLevel() && AISShape->topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor) {
999 //21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1000 // Display wireframe presentation additionally
1001 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1002 aWirePrs->SetWidth(AISShape->Width());
1003 if ( !myIO.IsNull() ) {
1004 aWirePrs->setIO( myIO );
1005 aWirePrs->SetOwner( myIO );
1007 occPrs->AddObject(aWirePrs);
1011 // if presentation is found -> set again shape for it
1014 if ( !myShape.IsNull() )
1016 AIS_ListOfInteractive IOList;
1017 occPrs->GetObjects( IOList );
1018 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1019 for ( ; Iter.More(); Iter.Next() )
1021 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1022 if ( AISShape.IsNull() )
1024 if ( AISShape->Shape() != myShape )
1026 AISShape->Set( myShape );
1027 AISShape->UpdateSelection();
1028 AISShape->SetToUpdate();
1030 if ( !myIO.IsNull() )
1032 AISShape->setIO( myIO );
1033 AISShape->SetOwner( myIO );
1041 //=================================================================
1043 * GEOM_Displayer::Update
1044 * Update VTK presentaion
1045 * [ Reimplemented from SALOME_Displayer ]
1047 //=================================================================
1048 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1050 SalomeApp_Study* aStudy = getStudy();
1052 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1054 if ( !vtkPrs || myShape.IsNull() || !aStudy)
1057 bool useStudy = false;
1058 bool useObjCol = false;
1061 vtkActorCollection* theActors = 0;
1064 if(!myIO.IsNull()) {
1065 anEntry = myIO->getEntry();
1068 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) {
1069 //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657)
1070 GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
1073 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1074 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1077 Handle(Geom_Plane) aPlane =
1078 Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( TopoDS::Face( myShape ) ) );
1079 if ( aPlane.IsNull() )
1082 gp_Ax2 anAx2 = aPlane->Pln().Position().Ax2();
1083 aTrh->SetPlacement( new Geom_Axis2Placement( anAx2 ) );
1085 // if ( SVTK_Viewer* vf = dynamic_cast<SVTK_Viewer*>( GetActiveView() ) )
1086 // aTrh->SetSize( 0.5 * vf->GetTrihedronSize() );
1088 vtkPrs->AddObject( aTrh );
1090 theActors = vtkActorCollection::New();
1091 theActors->AddItem( aTrh );
1094 PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
1096 if(!myIO.IsNull()) {
1097 aMgrId = getViewManagerId(myViewFrame);
1099 useStudy = !anEntry.isEmpty() && aMgrId != -1;
1102 theActors = vtkActorCollection::New();
1103 GEOM_Actor* aGeomActor = GEOM_Actor::New();
1104 aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR);
1105 theActors->AddItem(aGeomActor);
1106 aGeomActor->Delete();
1109 aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
1110 if(!aPropMap.contains(COLOR_PROP))
1112 MergePropertyMaps(aPropMap, aDefPropMap);
1116 theActors->InitTraversal();
1118 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
1120 vtkProperty* aProp = 0;
1122 if ( HasColor() || HasWidth() )
1124 aProp = vtkProperty::New();
1125 aProp->SetRepresentationToWireframe();
1130 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1131 aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1134 while ( anActor != NULL )
1136 SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor );
1138 GActor->setIO( myIO );
1142 GActor->SetProperty( aProp );
1143 GActor->SetPreviewProperty( aProp );
1146 GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor );
1147 if ( aGeomGActor != 0 )
1150 aGeomGActor->SetShadingProperty( aProp );
1151 aGeomGActor->SetWireframeProperty( aProp );
1154 // Set color for edges in shading
1155 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1157 QColor c = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
1158 aGeomGActor->SetEdgesInShadingColor( c.red()/255., c.green()/255., c.blue()/255. );
1161 int aIsos[2]= { 1, 1 };
1163 QString anIsos = aPropMap.value(ISOS_PROP).toString();
1164 QStringList uv = anIsos.split(DIGIT_SEPARATOR);
1165 aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt();
1166 aGeomGActor->SetNbIsos(aIsos);
1167 aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
1168 SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
1169 SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
1170 aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
1171 int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
1172 // Specially processing of 'Shading with edges' mode from preferences,
1173 // because there is the following enum in VTK viewer:
1174 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
1175 // (see VTKViewer::Representation enum) and the following enum in GEOM_Actor:
1176 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
1177 if ( aDispModeId == 2 )
1178 // this is 'Shading with edges' mode => do the correct mapping to EDisplayMode
1179 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
1181 aGeomGActor->setDisplayMode(aDispModeId);
1182 aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
1184 // Create material model
1185 Material_Model material;
1186 material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() );
1187 // Set material properties for the object
1188 aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
1189 // Set the same front and back materials for the selected shape
1190 std::vector<vtkProperty*> aProps;
1191 aProps.push_back( material.getMaterialVTKProperty() );
1192 aGeomGActor->SetMaterial(aProps);
1194 vtkFloatingPointType aColor[3] = {1.,0.,0.};
1195 if ( useObjCol ) { //Get Color from geom object
1196 Handle( SALOME_InteractiveObject ) anIO = aGeomGActor->getIO();
1197 if ( !anIO.IsNull() ) {
1198 _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
1200 // get CORBA reference to data object
1201 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1202 if ( !CORBA::is_nil( object ) ) {
1203 // downcast to GEOM object
1204 GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
1205 bool hasColor = false;
1206 SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
1208 aColor[0] = aSColor.R; aColor[1] = aSColor.G; aColor[2] = aSColor.B;
1210 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1212 QColor c = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1213 aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
1216 aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, QColor( aColor[0] *255, aColor[1] * 255, aColor[2]* 255) );
1221 QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
1222 aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
1225 if ( !material.isPhysical() )
1226 aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
1229 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1231 // Create material model
1232 Material_Model material;
1233 // Get material name from resources
1234 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
1235 material.fromResources( mname );
1236 // Set material properties for the object
1237 aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() );
1238 // Set material for the selected shape
1239 std::vector<vtkProperty*> aProps;
1240 aProps.push_back( material.getMaterialVTKProperty() );
1241 aGeomGActor->SetMaterial(aProps);
1248 aGeomGActor->SetWidth( GetWidth() );
1250 if ( HasIsosWidth() )
1251 aGeomGActor->SetIsosWidth( GetIsosWidth() );
1255 GActor->PickableOn();
1257 GActor->PickableOff();
1259 vtkPrs->AddObject( GActor );
1261 anActor = (vtkActor*)theActors->GetNextActor();
1267 theActors->Delete();
1270 //=================================================================
1272 * GEOM_Displayer::BuildPrs
1273 * Build presentation accordint to the current viewer type
1275 //=================================================================
1276 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1278 if ( theObj->_is_nil() )
1281 myViewFrame = GetActiveView();
1282 if ( myViewFrame == 0 )
1285 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1290 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1291 myType = theObj->GetType();
1293 // Update presentation
1299 //=================================================================
1301 * GEOM_Displayer::BuildPrs
1302 * Build presentation accordint to the current viewer type
1304 //=================================================================
1305 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1307 myViewFrame = GetActiveView();
1308 if ( theShape.IsNull() || myViewFrame == 0 )
1311 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1316 setShape( theShape );
1324 //=================================================================
1326 * GEOM_Displayer::buildPresentation
1327 * Builds/finds object's presentation for the current viewer
1328 * Calls corresponding Update() method by means of double dispatch
1331 //=================================================================
1332 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1333 SALOME_View* theViewFrame )
1335 SALOME_Prs* prs = 0;
1338 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1342 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1345 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1346 theIO->setEntry( entry.toLatin1().constData() );
1347 if ( !theIO.IsNull() )
1349 // set interactive object
1351 // Find SOBject (because shape should be published previously)
1352 SUIT_Session* session = SUIT_Session::session();
1353 SUIT_Application* app = session->activeApplication();
1356 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1359 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1362 // get CORBA reference to data object
1363 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1364 if ( !CORBA::is_nil( object ) )
1366 // downcast to GEOM object
1367 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object );
1368 if ( !GeomObject->_is_nil() )
1370 // finally set shape
1371 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1372 myType = GeomObject->GetType();
1379 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1385 //=================================================================
1387 * GEOM_Displayer::buildSubshapePresentation
1388 * Builds/finds object's presentation for the current viewer
1389 * Calls corresponding Update() method by means of double dispatch
1390 * For not published objects (for Mantis issue 0020435)
1392 //=================================================================
1393 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1394 const QString& entry,
1395 SALOME_View* theViewFrame)
1397 SALOME_Prs* prs = 0;
1400 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1404 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1407 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1408 theIO->setEntry(entry.toLatin1().constData());
1409 if (!theIO.IsNull())
1411 // set interactive object
1413 // finally set shape
1415 myType = GEOM_SUBSHAPE;
1417 UpdatePrs(prs); // Update presentation by using of the double dispatch
1423 //=================================================================
1425 * GEOM_Displayer::internalReset
1426 * Resets internal data
1429 //=================================================================
1430 void GEOM_Displayer::internalReset()
1436 //=================================================================
1438 * GEOM_Displayer::LocalSelection
1439 * Activate selection of CAD shapes with activisation of selection
1440 * of their sub-shapes (with opened local context for OCC viewer)
1442 //=================================================================
1443 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1445 SUIT_Session* session = SUIT_Session::session();
1446 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1450 LightApp_SelectionMgr* sm = app->selectionMgr();
1452 // remove all filters from selection
1455 SALOME_View* vf = GetActiveView();
1457 if (!theIO.IsNull() && !vf->isVisible(theIO))
1459 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1460 vf->LocalSelection( prs, theMode );
1461 delete prs; // delete presentation because displayer is its owner
1465 //=================================================================
1467 * GEOM_Displayer::globalSelection
1468 * Activate selection of CAD shapes without activisation of selection
1469 * of their sub-shapes (without opened local context for OCC viewer)
1471 //=================================================================
1472 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1474 TColStd_MapOfInteger aModes;
1475 aModes.Add( theMode );
1476 GlobalSelection( aModes, update );
1479 //=================================================================
1481 * GEOM_Displayer::globalSelection
1482 * Activate selection of CAD shapes without activisation of selection
1483 * of their sub-shapes (without opened local context for OCC viewer)
1485 //=================================================================
1486 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1487 const bool update, const QList<int>* theSubShapes )
1489 SUIT_Session* session = SUIT_Session::session();
1490 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1494 SALOME_View* vf = GetActiveView();
1498 // Close local context
1499 vf->GlobalSelection( update );
1501 // Set selection filters in accordance with current mode
1502 LightApp_SelectionMgr* sm = app->selectionMgr();
1506 // Remove from selection temporary objects if necessary
1507 if ( !theModes.Contains( GEOM_PREVIEW ) )
1508 clearTemporary( sm );
1510 //@ aSel->ClearIndex();
1514 // Remove filters from AIS_InteractiveContext
1515 Handle(AIS_InteractiveContext) ic;
1516 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1519 ic = viewer->getAISContext();
1521 ic->RemoveFilters();
1524 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1527 SUIT_SelectionFilter* aFilter;
1528 if ( theModes.Extent() == 1 )
1530 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1532 if ( aMode == GEOM_COMPOUNDFILTER )
1533 aFilter = getComplexFilter( theSubShapes );
1535 aFilter = getFilter( aMode );
1537 else if ( theModes.Extent() > 1 )
1539 TColStd_MapOfInteger aTopAbsModes;
1540 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1541 QList<SUIT_SelectionFilter*> aListOfFilters;
1542 for ( ; anIter.More(); anIter.Next() )
1544 SUIT_SelectionFilter* aFilter;
1545 int aMode = anIter.Key();
1546 if ( aMode == GEOM_COMPOUNDFILTER )
1547 aFilter = getComplexFilter( theSubShapes );
1549 aFilter = getFilter( aMode );
1552 aListOfFilters.append( aFilter );
1555 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1562 sm->installFilter( aFilter );
1565 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1566 ic->AddFilter( anOCCFilter );
1571 //=================================================================
1573 * GEOM_Displayer::LocalSelection
1574 * Activate selection of CAD shapes with activisation of selection
1575 * of their sub-shapes (with opened local context for OCC viewer)
1577 //=================================================================
1578 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1580 SALOME_ListIteratorOfListIO Iter( theIOList );
1581 for ( ; Iter.More(); Iter.Next() )
1582 LocalSelection( Iter.Value(), theMode );
1585 //=================================================================
1587 * GEOM_Displayer::BeforeDisplay
1588 * Called before displaying of pars. Close local context
1589 * [ Reimplemented from SALOME_Displayer ]
1591 //=================================================================
1592 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1594 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1597 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1600 if ( ic->HasOpenedContext() )
1601 ic->CloseAllContexts();
1606 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1608 SalomeApp_Study* aStudy = getStudy();
1609 if (!aStudy) return;
1610 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1611 if ( vf && !p->IsNull() ) {
1612 int aMgrId = getViewManagerId( vf );
1613 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1614 const SOCC_Prs* prs = dynamic_cast<const SOCC_Prs*>( p );
1615 if ( !ic.IsNull() && prs ) {
1616 AIS_ListOfInteractive objects;
1617 prs->GetObjects( objects );
1618 AIS_ListIteratorOfListOfInteractive it( objects );
1619 for ( ; it.More(); it.Next() ) {
1620 Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() );
1621 if ( sh.IsNull() ) continue;
1622 Handle(SALOME_InteractiveObject) IO = sh->getIO();
1623 if ( IO.IsNull() ) continue;
1624 PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() );
1625 if ( aPropMap.contains( TRANSPARENCY_PROP ) ) {
1626 double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble();
1627 ic->SetTransparency( sh, transparency, true );
1634 //=================================================================
1636 * GEOM_Displayer::SetColor
1637 * Set color for shape displaying. If it is equal -1 then default color is used.
1638 * Available values are from Quantity_NameOfColor enumeration
1640 //=================================================================
1641 void GEOM_Displayer::SetColor( const int color )
1648 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1652 int GEOM_Displayer::GetColor() const
1657 bool GEOM_Displayer::HasColor() const
1659 return myColor != -1;
1662 void GEOM_Displayer::UnsetColor()
1666 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1667 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1668 myShadingColor = SalomeApp_Tools::color( col );
1671 //=================================================================
1673 * GEOM_Displayer::SetTexture
1674 * Set color for shape displaying. If it is equal -1 then default color is used.
1675 * Available values are from Quantity_NameOfColor enumeration
1677 //=================================================================
1678 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1680 if(texureFileName!="")
1682 myTexture = texureFileName;
1686 bool GEOM_Displayer::HasTexture() const
1688 return myTexture != "";
1691 std::string GEOM_Displayer::GetTexture() const
1696 //=================================================================
1698 * GEOM_Displayer::SetWidth
1699 * Set width of shape displaying. If it is equal -1 then default width is used.
1701 //=================================================================
1702 void GEOM_Displayer::SetWidth( const double width )
1707 double GEOM_Displayer::GetWidth() const
1712 bool GEOM_Displayer::HasWidth() const
1714 return myWidth != -1;
1717 void GEOM_Displayer::UnsetWidth()
1723 int GEOM_Displayer::GetIsosWidth() const
1728 void GEOM_Displayer::SetIsosWidth(const int width)
1730 myIsosWidth = width;
1733 bool GEOM_Displayer::HasIsosWidth() const
1735 return myIsosWidth != -1;
1739 //=================================================================
1741 * GEOM_Displayer::SetToActivate
1742 * This method is used for activisation/deactivisation of objects to be displayed
1744 //=================================================================
1745 void GEOM_Displayer::SetToActivate( const bool toActivate )
1747 myToActivate = toActivate;
1749 bool GEOM_Displayer::ToActivate() const
1751 return myToActivate;
1754 //=================================================================
1756 * GEOM_Displayer::clearTemporary
1757 * Removes from selection temporary objects
1759 //=================================================================
1760 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1762 SALOME_ListIO selected, toSelect;
1763 theSelMgr->selectedObjects( selected );
1765 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1766 Handle(SALOME_InteractiveObject) io = it.Value();
1767 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1768 toSelect.Append( it.Value() );
1771 theSelMgr->setSelectedObjects( toSelect, true );
1774 void GEOM_Displayer::SetName( const char* theName )
1779 void GEOM_Displayer::UnsetName()
1784 SalomeApp_Study* GEOM_Displayer::getStudy() const
1786 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1789 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1794 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1799 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
1801 return viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type();
1804 int GEOM_Displayer::SetDisplayMode( const int theMode )
1806 int aPrevMode = myDisplayMode;
1807 if ( theMode != -1 )
1808 myDisplayMode = theMode;
1811 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1812 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
1817 int GEOM_Displayer::GetDisplayMode() const
1819 return myDisplayMode;
1822 int GEOM_Displayer::UnsetDisplayMode()
1824 int aPrevMode = myDisplayMode;
1825 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1826 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
1830 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
1833 int aTolerance = 64;
1834 int anIterations = 0;
1840 if( anIterations % aPeriod == 0 )
1843 if( aTolerance < 1 )
1846 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
1848 aHue = (int)( 360.0 * rand() / RAND_MAX );
1849 //std::cout << "Hue = " << aHue << std::endl;
1851 //std::cout << "Auto colors : ";
1853 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
1854 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
1855 for( ; it != itEnd; ++it )
1857 SALOMEDS::Color anAutoColor = *it;
1858 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
1861 aQColor.getHsv( &h, &s, &v );
1862 //std::cout << h << " ";
1863 if( abs( h - aHue ) < aTolerance )
1866 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
1870 //std::cout << std::endl;
1876 //std::cout << "Hue of the returned color = " << aHue << std::endl;
1878 aColor.setHsv( aHue, 255, 255 );
1880 SALOMEDS::Color aSColor;
1881 aSColor.R = (double)aColor.red() / 255.0;
1882 aSColor.G = (double)aColor.green() / 255.0;
1883 aSColor.B = (double)aColor.blue() / 255.0;
1890 PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
1891 PropMap aDefaultMap;
1892 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1894 aDefaultMap.insert(VISIBILITY_PROP , 1);
1899 if(viewer_type == SOCC_Viewer::Type()) {
1900 anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
1901 aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
1902 } else if( viewer_type==SVTK_Viewer::Type()) {
1903 anUIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1);
1904 aVIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1);
1906 QString anIsos("%1%2%3");
1907 anIsos = anIsos.arg(anUIsoNumber);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(aVIsoNumber);
1908 aDefaultMap.insert(ISOS_PROP , anIsos);
1911 aDefaultMap.insert( TRANSPARENCY_PROP , 0.0 );
1914 aDefaultMap.insert( DISPLAY_MODE_PROP , aResMgr->integerValue("Geometry", "display_mode", 0));
1917 aDefaultMap.insert( VECTOR_MODE_PROP , 0);
1920 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1921 aDefaultMap.insert( COLOR_PROP , col);
1923 //7. Deflection Coeff
1926 if(viewer_type == SOCC_Viewer::Type()) {
1927 aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
1928 } else if( viewer_type==SVTK_Viewer::Type()) {
1932 aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
1935 Material_Model material;
1936 QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" );
1937 material.fromResources( mname );
1938 aDefaultMap.insert( MATERIAL_PROP, material.toProperties() );
1940 //9. Width of the edges
1941 aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
1944 //10. Width of iso-lines
1945 aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
1947 if(viewer_type == SOCC_Viewer::Type()) {
1949 aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
1955 bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault) {
1957 if(!theOrigin.contains(VISIBILITY_PROP)) {
1958 theOrigin.insert(VISIBILITY_PROP, 0);
1961 if(!theOrigin.contains(TRANSPARENCY_PROP)) {
1962 theOrigin.insert(TRANSPARENCY_PROP, theDefault.value(TRANSPARENCY_PROP));
1965 if(!theOrigin.contains(DISPLAY_MODE_PROP)) {
1966 theOrigin.insert(DISPLAY_MODE_PROP, theDefault.value(DISPLAY_MODE_PROP));
1969 if(!theOrigin.contains(ISOS_PROP)) {
1970 theOrigin.insert(ISOS_PROP, theDefault.value(ISOS_PROP));
1973 if(!theOrigin.contains(VECTOR_MODE_PROP)) {
1974 theOrigin.insert(VECTOR_MODE_PROP, theDefault.value(VECTOR_MODE_PROP));
1977 if(!theOrigin.contains(DEFLECTION_COEFF_PROP)) {
1978 theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
1981 if(!theOrigin.contains(MATERIAL_PROP)) {
1982 theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP));
1986 if(!theOrigin.contains(EDGE_WIDTH_PROP)) {
1987 theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP));
1991 if(!theOrigin.contains(ISOS_WIDTH_PROP)) {
1992 theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP));
1996 if(!theOrigin.contains(COLOR_PROP)) {
1997 theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP));
2001 return (nbInserted > 0);
2005 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2006 SALOMEDS::Color aSColor;
2009 SUIT_Session* session = SUIT_Session::session();
2010 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2012 if ( app && !theGeomObject->_is_nil()) {
2013 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2016 _PTR(Study) aStudy = study->studyDS();
2017 aSColor = theGeomObject->GetColor();
2018 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2020 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2021 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2022 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2023 QList<SALOMEDS::Color> aReservedColors;
2024 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2025 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2026 if ( aMainSObject ) {
2027 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2028 for ( ; it->More(); it->Next() ) {
2029 _PTR(SObject) aChildSObject( it->Value() );
2030 GEOM::GEOM_Object_var aChildObject =
2031 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2032 if ( CORBA::is_nil( aChildObject ) )
2035 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2036 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2037 aReservedColors.append( aReservedColor );
2040 aSColor = getUniqueColor( aReservedColors );
2043 #else // auto-color for groups only
2044 if ( theGeomObject->GetType() == GEOM_GROUP ) {
2045 GEOM::GEOM_Gen_var theGeomGen = GeometryGUI::GetGeomGen();
2046 GEOM::GEOM_IGroupOperations_var anOperations = theGeomGen->GetIGroupOperations( study->id() );
2047 GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( theGeomObject );
2048 if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() )
2050 QList<SALOMEDS::Color> aReservedColors;
2052 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2053 if ( strcmp(IOR.in(), "") != 0 )
2055 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) );
2056 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2057 for( ; it->More(); it->Next() )
2059 _PTR(SObject) aChildSObject( it->Value() );
2060 GEOM::GEOM_Object_var aChildObject =
2061 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2062 if( CORBA::is_nil( aChildObject ) )
2065 if( aChildObject->GetType() != GEOM_GROUP )
2068 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2069 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2070 aReservedColors.append( aReservedColor );
2074 aSColor = getUniqueColor( aReservedColors );
2086 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2087 const bool eraseOnlyChildren) {
2088 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2092 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2096 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2101 // Erase from all views
2102 QList<SALOME_View*> views;
2104 ViewManagerList vmans = app->viewManagers();
2105 SUIT_ViewManager* vman;
2106 foreach ( vman, vmans ) {
2107 SUIT_ViewModel* vmod = vman->getViewModel();
2108 view = dynamic_cast<SALOME_View*> ( vmod );
2110 views.append( view );
2113 if( views.count() == 0 )
2116 //Erase childrens w/o update views
2117 DataObjectList listObj = parent->children( true );
2118 SUIT_DataObject* obj;
2119 foreach( obj, listObj ) {
2120 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2122 foreach ( view, views ) {
2123 Handle(SALOME_InteractiveObject) anIO =
2124 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2125 Erase(anIO, false, false, view);
2129 //Erase parent with view update or repaint views
2130 foreach ( view, views ) {
2131 if(!eraseOnlyChildren)
2132 Erase(theIO, false, true, view);