1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GEOM_Displayer.cxx
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 #include "GEOM_Displayer.h"
28 #include "GEOMGUI_DimensionProperty.h"
29 #include "GeometryGUI.h"
31 #include <GEOM_Constants.h>
32 #include <GEOM_TypeFilter.h>
33 #include <GEOM_EdgeFilter.h>
34 #include <GEOM_FaceFilter.h>
35 #include <GEOM_CompoundFilter.h>
36 #include <GEOM_PreviewFilter.h>
37 #include <GEOM_LogicalFilter.h>
38 #include <GEOM_OCCFilter.h>
40 #include <GEOM_Actor.h>
41 #include <GEOM_AISShape.hxx>
42 #include <GEOM_AISDimension.hxx>
43 #include <GEOM_TopWireframeShape.hxx>
44 #include <GEOM_AISVector.hxx>
45 #include <GEOM_AISTrihedron.hxx>
46 #include <GEOM_VTKTrihedron.hxx>
47 #include <GEOM_VTKPropertyMaterial.hxx>
49 #include <GEOMUtils.hxx>
51 #include <Material_Model.h>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_ViewWindow.h>
55 #include <SUIT_Session.h>
56 #include <SUIT_ViewManager.h>
57 #include <SUIT_ResourceMgr.h>
59 #include <Basics_OCCTVersion.hxx>
61 #include <SalomeApp_Study.h>
62 #include <SalomeApp_Application.h>
63 #include <LightApp_SelectionMgr.h>
64 #include <LightApp_DataObject.h>
65 #include <SalomeApp_TypeFilter.h>
66 #include <SalomeApp_Tools.h>
68 #include <SALOME_ListIteratorOfListIO.hxx>
69 #include <SALOME_ListIO.hxx>
70 #include <SALOME_Prs.h>
73 #include <SOCC_ViewModel.h>
76 #include <SVTK_ViewModel.h>
78 #include <OCCViewer_ViewWindow.h>
79 #include <OCCViewer_ViewPort3d.h>
82 #include <AIS_Drawer.hxx>
83 #include <AIS_Dimension.hxx>
84 #include <AIS_LengthDimension.hxx>
85 #include <AIS_DiameterDimension.hxx>
86 #include <AIS_AngleDimension.hxx>
87 #include <AIS_ListIteratorOfListOfInteractive.hxx>
88 #include <Aspect_PolygonOffsetMode.hxx>
89 #include <Aspect_ColorScale.hxx>
90 #include <Prs3d_IsoAspect.hxx>
91 #include <Prs3d_PointAspect.hxx>
92 #include <StdSelect_TypeOfEdge.hxx>
93 #include <StdSelect_TypeOfFace.hxx>
94 #include <StdSelect_DisplayMode.hxx>
95 #include <TopoDS_Face.hxx>
96 #include <BRep_Tool.hxx>
97 #include <Geom_Plane.hxx>
98 #include <Geom_Axis2Placement.hxx>
99 #include <Graphic3d_AspectFillArea3d.hxx>
100 #include <gp_Pln.hxx>
101 #include <TColStd_MapOfInteger.hxx>
102 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
103 #include <TopoDS_Iterator.hxx>
104 #include <Graphic3d_AspectMarker3d.hxx>
105 #include <TopTools_MapOfShape.hxx>
106 #include <TopTools_ListOfShape.hxx>
107 #include <TopTools_ListIteratorOfListOfShape.hxx>
108 #include <TopoDS.hxx>
110 #include <Prs3d_ShadingAspect.hxx>
112 #include <BRepMesh_IncrementalMesh.hxx>
115 #include <vtkActorCollection.h>
116 #include <vtkProperty.h>
119 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
121 #include <GEOMImpl_Types.hxx>
123 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
124 #include <TColStd_HArray1OfByte.hxx>
126 #include <Graphic3d_HArray1OfBytes.hxx>
129 // If the next macro is defined, autocolor feature works for all sub-shapes;
130 // if it is undefined, autocolor feature works for groups only
131 #define GENERAL_AUTOCOLOR
132 // Below macro, when uncommented, switches on simplified (more performant) algorithm
133 // of auto-color picking up
134 #define SIMPLE_AUTOCOLOR
136 // Hard-coded value of shape deflection coefficient for VTK viewer
137 const double VTK_MIN_DEFLECTION = 0.001;
139 //================================================================
140 // Function : getActiveStudy
141 // Purpose : Get active study, returns 0 if no open study frame
142 //================================================================
143 static inline SalomeApp_Study* getActiveStudy()
145 SUIT_Session* session = SUIT_Session::session();
146 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
148 return ( SalomeApp_Study* )app->activeStudy();
152 static inline int getViewManagerId( SALOME_View* theViewFrame) {
153 SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
154 SUIT_ViewManager* aViewMgr = 0;
156 aViewMgr = aModel->getViewManager();
157 return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
160 //================================================================
161 // Function : getTopAbsMode
162 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
163 // one from GEOMImpl_Types.h
164 //================================================================
165 static inline int getTopAbsMode( const int implType )
169 case GEOM_COMPOUND : return TopAbs_COMPOUND;
170 case GEOM_SOLID : return TopAbs_SOLID;
171 case GEOM_SHELL : return TopAbs_SHELL;
172 case GEOM_FACE : return TopAbs_FACE;
173 case GEOM_WIRE : return TopAbs_WIRE;
174 case GEOM_EDGE : return TopAbs_EDGE;
175 case GEOM_POINT : return TopAbs_VERTEX;
180 int GEOM_Displayer::getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin )
182 if ( shape.IsNull() )
185 int ret = shape.ShapeType();
187 if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
188 TopoDS_Iterator it(shape, Standard_True, Standard_False);
189 for (; it.More(); it.Next()) {
190 TopoDS_Shape sub_shape = it.Value();
191 if ( sub_shape.IsNull() ) continue;
192 int stype = getMinMaxShapeType( sub_shape, ismin );
193 if ( stype == TopAbs_SHAPE ) continue;
194 if ( ismin && stype > ret )
196 else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) )
204 bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape )
206 return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX;
209 //================================================================
210 // Function : getFilter
211 // Purpose : Get filter corresponding to the type of object
212 // from GEOMImpl_Types.h
213 //================================================================
214 SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
216 SUIT_SelectionFilter* aFilter;
218 int aTopAbsMode = getTopAbsMode( theMode );
219 if ( aTopAbsMode != -1 )
220 aFilter = new GEOM_TypeFilter( getStudy(), aTopAbsMode, true ); //@ aFilter = new GEOM_TypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
224 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Line ); break;
225 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( getStudy(), StdSelect_Circle ); break;
227 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Plane ); break;
228 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cylinder ); break;
229 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Sphere ); break;
230 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Torus ); break;
231 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Revol ); break;
232 case GEOM_CONE : aFilter = new GEOM_FaceFilter( getStudy(), StdSelect_Cone ); break;
234 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter( getStudy() ); break;
236 case GEOM_ALLSHAPES : aFilter = new GEOM_SelectionFilter(getStudy(), true ); break;
237 case GEOM_ALLGEOM : aFilter = new SalomeApp_TypeFilter( getStudy(), "GEOM" ); break;
239 default : aFilter = new GEOM_TypeFilter( getStudy(), theMode ); break;
245 //================================================================
246 // Function : getComplexFilter
247 // Purpose : Get compound filter corresponding to the type of
248 // object from GEOMImpl_Types.h
249 //================================================================
250 SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList<int>* aSubShapes)
252 GEOM_CompoundFilter* aFilter;
254 if(aSubShapes != NULL ) {
255 aFilter = new GEOM_CompoundFilter(getStudy());
256 QList<int> aTopAbsTypes;
257 QList<int>::const_iterator it;
258 for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
259 int topAbsMode = getTopAbsMode(*it);
260 if(topAbsMode != -1 )
261 aTopAbsTypes.append(topAbsMode);
263 aFilter->addSubTypes(aTopAbsTypes);
269 //================================================================
270 // Function : getEntry
272 //================================================================
273 static std::string getEntry( GEOM::GEOM_BaseObject_ptr object )
275 SUIT_Session* session = SUIT_Session::session();
276 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
279 CORBA::String_var IOR = app->orb()->object_to_string( object );
280 if ( strcmp(IOR.in(), "") != 0 )
282 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
283 _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
291 //================================================================
292 // Function : getName
294 //================================================================
295 static std::string getName( GEOM::GEOM_BaseObject_ptr object )
297 SUIT_Session* session = SUIT_Session::session();
298 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
301 CORBA::String_var IOR = app->orb()->object_to_string( object );
302 if ( strcmp(IOR.in(), "") != 0 )
304 SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
305 _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
307 _PTR(GenericAttribute) anAttr;
309 if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
311 _PTR(AttributeName) aNameAttr( anAttr );
312 return aNameAttr->Value();
320 //=================================================================
322 * GEOM_Displayer::GEOM_Displayer
325 //=================================================================
326 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
329 myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
334 SUIT_Session* session = SUIT_Session::session();
335 SUIT_ResourceMgr* resMgr = session->resourceMgr();
337 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
338 myShadingColor = SalomeApp_Tools::color( col );
340 myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
341 myHasDisplayMode = false;
343 int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
344 myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
345 myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
347 myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
348 myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
349 myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
352 // This color is used for shape displaying. If it is equal -1 then
353 // default color is used.
360 // This parameter is used for activisation/deactivisation of objects to be displayed
362 #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
363 // Activate parallel vizualisation only for testing purpose
364 // and if the corresponding env variable is set to 1
365 char* parallel_visu = getenv("PARALLEL_VISU");
366 if (parallel_visu && atoi(parallel_visu))
368 MESSAGE("Parallel visualisation on");
369 BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
375 myFieldDataType = GEOM::FDT_Double;
376 myFieldDimension = 0;
377 myFieldStepRangeMin = 0;
378 myFieldStepRangeMax = 0;
381 //=================================================================
383 * GEOM_Displayer::~GEOM_Displayer
386 //=================================================================
387 GEOM_Displayer::~GEOM_Displayer()
391 //=================================================================
393 * GEOM_Displayer::Display
394 * Display interactive object in the current viewer
396 //=================================================================
397 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
398 const bool updateViewer,
399 SALOME_View* theViewFrame )
401 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
404 SALOME_Prs* prs = buildPresentation( theIO->getEntry(), vf );
408 vf->BeforeDisplay( this, prs );
410 vf->AfterDisplay( this, prs );
415 int aMgrId = getViewManagerId(vf);
416 SalomeApp_Study* aStudy = getStudy();
417 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 );
419 setVisibilityState(theIO->getEntry(), Qtx::ShownState);
421 delete prs; // delete presentation because displayer is its owner
426 //=================================================================
428 * GEOM_Displayer::Display
429 * This overloaded Display() method can be useful for operations
430 * not using dialog boxes.
432 //=================================================================
433 void GEOM_Displayer::Display( GEOM::GEOM_BaseObject_ptr theObj, const bool updateViewer )
435 if ( theObj->_is_nil() )
438 std::string entry = getEntry( theObj );
440 Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
445 //=================================================================
447 * GEOM_Displayer::Erase
448 * Erase interactive object in the current viewer
450 //=================================================================
451 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
453 const bool updateViewer,
454 SALOME_View* theViewFrame )
456 if ( theIO.IsNull() )
459 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
462 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
464 vf->BeforeErase( this, prs );
465 vf->Erase( prs, forced );
466 vf->AfterErase( this, prs );
469 delete prs; // delete presentation because displayer is its owner
471 int aMgrId = getViewManagerId(vf);
472 SalomeApp_Study* aStudy = getStudy();
473 aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 );
475 setVisibilityState(theIO->getEntry(), Qtx::HiddenState);
480 //=================================================================
482 * GEOM_Displayer::Erase
483 * Erase geometry object in the current viewer
485 //=================================================================
486 void GEOM_Displayer::Erase( GEOM::GEOM_BaseObject_ptr theObj,
488 const bool updateViewer,
489 SALOME_View* theViewFrame)
491 std::string entry = getEntry( theObj );
494 Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
495 forced, updateViewer, theViewFrame);
499 //=================================================================
501 * GEOM_Displayer::Redisplay
502 * Redisplay (erase and then display again) interactive object
503 * in the current viewer
505 //=================================================================
506 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
507 const bool updateViewer,
508 const bool checkActiveViewer )
510 // Remove the object permanently (<forced> == true)
511 SUIT_Session* ses = SUIT_Session::session();
512 SUIT_Application* app = ses->activeApplication();
515 SUIT_Desktop* desk = app->desktop();
516 QList<SUIT_ViewWindow*> wnds = desk->windows();
517 SUIT_ViewWindow* wnd;
518 QListIterator<SUIT_ViewWindow*> it( wnds );
519 while ( it.hasNext() && (wnd = it.next()) )
521 SUIT_ViewManager* vman = wnd->getViewManager();
524 SUIT_ViewModel* vmodel = vman->getViewModel();
527 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
530 if ( view->isVisible( theIO ) || ( checkActiveViewer && view == GetActiveView() ) )
532 Redisplay( theIO, updateViewer, view );
541 //=================================================================
543 * GEOM_Displayer::Redisplay
544 * Redisplay (erase and then display again) interactive object
545 * in the specified view
547 //=================================================================
548 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
549 const bool theUpdateViewer,
550 SALOME_View* theViewFrame )
552 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
558 Erase( theIO, true, false, theViewFrame );
559 Display( theIO, theUpdateViewer, theViewFrame );
562 //=================================================================
564 * GEOM_Displayer::Display
565 * Calls Display() method for each object in the given list
567 //=================================================================
568 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
570 SALOME_ListIteratorOfListIO Iter( theIOList );
571 for ( ; Iter.More(); Iter.Next() ) {
572 Display( Iter.Value(), false );
578 Quantity_Color GEOM_Displayer::qColorFromResources( const QString& property, const QColor& defColor )
580 // VSR: this method can be improved in future:
581 // to improve performance, the default values from resource manager should be cached in the displayer
582 return SalomeApp_Tools::color( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ) );
585 QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor& defColor )
587 // VSR: this method can be improved in future:
588 // to improve performance, the default values from resource manager should be cached in the displayer
589 return SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor );
592 void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create )
594 // check that shape is not null
595 if ( AISShape.IsNull() ) return;
597 // check that study is active
598 SalomeApp_Study* study = getStudy();
599 if ( !study ) return;
601 if ( myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points
602 !TopoDS_Iterator(myShape).More() )
603 return; // NPAL15983 (Bug when displaying empty groups)
605 // set interactive object
607 Handle( SALOME_InteractiveObject ) anIO;
609 if ( !myIO.IsNull() ) {
610 AISShape->setIO( myIO );
611 AISShape->SetOwner( myIO );
614 else if ( !myName.empty() ) {
615 // workaround to allow selection of temporary objects
616 static int tempId = 0;
617 anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
618 AISShape->setIO( anIO );
619 AISShape->SetOwner( anIO );
622 // flag: only vertex or compound of vertices is processed (specific handling)
623 bool onlyVertex = myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape );
624 // presentation study entry (empty for temporary objects like preview)
625 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
626 // flag: temporary object
627 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
628 // currently active view window's ID (-1 if no active view)
629 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
631 // get presentation properties
632 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
634 // Temporary staff: vertex must be infinite for correct visualization
635 AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
638 Material_Model material;
639 // if predefined color isn't set in displayer(via GEOM_Displayer::SetColor() function)
641 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
642 // - set front material properties
643 AISShape->SetCurrentFacingModel( Aspect_TOFM_FRONT_SIDE );
644 AISShape->SetMaterial( material.getMaterialOCCAspect( true ) );
645 // - set back material properties
646 AISShape->SetCurrentFacingModel( Aspect_TOFM_BACK_SIDE );
647 AISShape->SetMaterial( material.getMaterialOCCAspect( false ) );
648 // - switch to default (both sides) facing mode
649 AISShape->SetCurrentFacingModel( Aspect_TOFM_BOTH_SIDE );
655 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function;
656 // we set it to the shape not taking into account material properties
657 AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() );
659 else if ( !material.isPhysical() ) {
660 // shading color from properties is used only for non-physical materials
661 AISShape->SetShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>() ) );
665 Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect();
666 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
667 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
668 AISShape->Attributes()->SetLineAspect( anAspect );
670 // - unfree boundaries color
671 anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
672 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
673 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>() ) );
674 AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
676 // - free boundaries color
677 anAspect = AISShape->Attributes()->FreeBoundaryAspect();
678 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
679 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>() ) );
680 AISShape->Attributes()->SetFreeBoundaryAspect( anAspect );
682 // - standalone edges color
683 anAspect = AISShape->Attributes()->WireAspect();
684 anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() :
685 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::LineColor ) ).value<QColor>() ) );
686 AISShape->Attributes()->SetWireAspect( anAspect );
688 // - color for edges in shading+edges mode
689 AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>() ) );
692 AISShape->storeBoundaryColors();
695 AISShape->SetDisplayMode( HasDisplayMode() ?
696 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
698 // display mode from properties
699 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() );
701 // set display vectors flag
702 AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
705 AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
707 // set iso properties
708 int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt();
709 int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt();
710 Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>() );
711 int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt();
712 Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect();
713 Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect();
714 uIsoAspect->SetColor( isosColor );
715 uIsoAspect->SetWidth( isosWidth );
716 uIsoAspect->SetNumber( uIsos );
717 vIsoAspect->SetColor( isosColor );
718 vIsoAspect->SetWidth( isosWidth );
719 vIsoAspect->SetNumber( vIsos );
720 AISShape->Attributes()->SetUIsoAspect( uIsoAspect );
721 AISShape->Attributes()->SetVIsoAspect( vIsoAspect );
723 // set deflection coefficient
724 // ... to avoid to small values of the coefficient, its lower value is limited
725 AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) );
728 bool textureAdded = false;
729 if ( HasTexture() ) {
730 // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function
731 AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) );
732 if ( ! entry.isEmpty() ) {
733 // check that study is active
734 SalomeApp_Study* study = getActiveStudy();
736 // Store the texture in object properties for next displays
737 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
738 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
740 // Update porpeties map
741 propMap = getObjectProperties( study, entry, myViewFrame );
747 // Texture from properties
748 QString aTexture = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
749 if ( !aTexture.isEmpty() ) {
750 AISShape->SetTextureFileName( TCollection_AsciiString( aTexture.toStdString().c_str() ) );
756 AISShape->SetTextureMapOn();
757 AISShape->DisableTextureModulate();
761 AISShape->SetWidth( HasWidth() ?
762 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
764 // libe width from properties
765 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
767 // set top-level flag
768 AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() );
770 // set point marker (for vertex / compound of vertices only)
772 QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() );
773 if ( aList.size() == 2 ) {
774 // standard marker string contains "TypeOfMarker:ScaleOfMarker"
775 int aTypeOfMarker = aList[0].toInt();
776 double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5;
777 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
778 anAspect->SetScale( aScaleOfMarker );
779 anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) );
780 anAspect->SetColor( HasColor() ?
781 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
782 (Quantity_NameOfColor)GetColor() :
783 // color from properties
784 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ) );
785 AISShape->Attributes()->SetPointAspect( anAspect );
787 else if ( aList.size() == 1 ) {
788 // custom marker string contains "IdOfTexture"
789 int textureId = aList[0].toInt();
790 Standard_Integer aWidth, aHeight;
791 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
792 Handle(TColStd_HArray1OfByte) aTexture =
794 Handle(Graphic3d_HArray1OfBytes) aTexture =
796 GeometryGUI::getTexture( study, textureId, aWidth, aHeight );
797 if ( !aTexture.IsNull() ) {
798 #if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version
799 Handle(Prs3d_PointAspect) aTextureAspect =
800 new Prs3d_PointAspect( HasColor() ?
801 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
802 (Quantity_NameOfColor)GetColor() :
803 // color from properties
804 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
809 Handle(Prs3d_PointAspect) aTextureAspect =
810 new Prs3d_PointAspect( HasColor() ?
811 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
812 (Quantity_NameOfColor)GetColor() :
813 // color from properties
814 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
819 AISShape->Attributes()->SetPointAspect( aTextureAspect );
824 // set field step data
825 AISShape->setFieldStepInfo( myFieldDataType,
830 myFieldStepRangeMax );
832 if ( create && !isTemporary && aMgrId != -1 ) {
833 // set properties to the study
834 study->setObjectPropMap( aMgrId, entry, propMap );
837 // AISShape->SetName(???); ??? necessary to set name ???
840 void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
842 // check that actor is not null
843 if ( !actor ) return;
845 // check that study is active
846 SalomeApp_Study* study = getStudy();
847 if ( !study ) return;
849 // set interactive object
851 Handle( SALOME_InteractiveObject ) anIO;
853 if ( !myIO.IsNull() ) {
854 actor->setIO( myIO );
857 else if ( !myName.empty() ) {
858 // workaround to allow selection of temporary objects
859 static int tempId = 0;
860 anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
861 actor->setIO( anIO );
864 // presentation study entry (empty for temporary objects like preview)
865 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
866 // flag: temporary object
867 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
868 // currently active view window's ID (-1 if no active view)
869 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
871 // get presentation properties
872 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
875 /////////////////////////////////////////////////////////////////////////
876 // VSR: for VTK viewer currently deflection coefficient is hardcoded
877 // due to performance problem
878 // actor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR);
879 /////////////////////////////////////////////////////////////////////////
880 if ( !actor->getTopo().IsSame( myShape ) )
881 actor->SetShape( myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR );
884 Material_Model material;
885 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
886 std::vector<vtkProperty*> mprops;
887 mprops.push_back( material.getMaterialVTKProperty( true ) );
888 mprops.push_back( material.getMaterialVTKProperty( false) );
889 actor->SetMaterial( mprops );
891 // set iso-lines properties
893 // - set number of iso-lines
894 int nbIsos[2]= { 1, 1 };
895 QStringList isos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() );
896 nbIsos[0] = isos[0].toInt();
897 nbIsos[1] = isos[1].toInt();
898 actor->SetNbIsos( nbIsos );
900 // - set iso-lines width
901 actor->SetIsosWidth( propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt() );
903 // - set iso-lines color
904 c = propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>();
905 actor->SetIsosColor( c.redF(), c.greenF(), c.blueF() );
910 // - same color for all sub-actors
911 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
912 actor->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
915 // shading color (for non-physical materials)
916 if ( !material.isPhysical() ) {
917 c = propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>();
918 actor->GetFrontMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
919 actor->GetBackMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
922 // - standalone edge color
923 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
924 actor->SetIsolatedEdgeColor( c.redF(), c.greenF(), c.blueF() );
926 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
927 // - shared edges color ???
928 actor->SetSharedEdgeColor( c.redF(), c.greenF(), c.blueF() );
930 c = propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>();
931 // - free edges color ???
932 actor->SetFreeEdgeColor( c.redF(), c.greenF(), c.blueF() );
935 c = propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>();
936 actor->SetPointColor( c.redF(), c.greenF(), c.blueF() );
939 // - color for edges in shading+edges mode
940 c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>();
941 actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() );
944 actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
947 actor->SetWidth( HasWidth() ?
948 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
950 // libe width from properties
951 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
953 // set display vectors flag
954 actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
957 int displayMode = HasDisplayMode() ?
958 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
960 // display mode from properties
961 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt();
963 // specific processing of 'shading with edges' mode, as VTK provides only the following standard display modes:
964 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
965 // GEOM actor allows alternative display modes (see VTKViewer::Representation enum) and enum in GEOM_Actor:
966 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
968 if ( displayMode == 2 )
969 // this is 'Shading with edges' mode => we have to do the correct mapping to EDisplayMode
970 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
972 actor->setDisplayMode( displayMode );
977 actor->PickableOff();
979 if ( create && !isTemporary && aMgrId != -1 ) {
980 // set properties to the study
981 study->setObjectPropMap( aMgrId, entry, propMap );
985 //=================================================================
987 * GEOM_Displayer::updateDimensions
988 * Creates or renews dimension presentation for the IO.
990 //=================================================================
991 void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& theIO,
992 SALOME_OCCPrs* thePrs,
993 const gp_Ax3& theShapeLCS )
995 SalomeApp_Study* aStudy = getStudy();
1001 if ( theIO.IsNull() )
1006 SOCC_Prs* anOccPrs = dynamic_cast<SOCC_Prs*>( thePrs );
1008 AIS_ListOfInteractive aListOfIO;
1010 anOccPrs->GetObjects( aListOfIO );
1012 AIS_ListIteratorOfListOfInteractive aIterateIO( aListOfIO );
1014 // remove outdated presentations of dimensions
1015 for ( ; aIterateIO.More(); aIterateIO.Next() )
1017 const Handle(AIS_InteractiveObject)& anIO = aIterateIO.Value();
1018 if ( !anIO->IsKind( STANDARD_TYPE( AIS_Dimension ) ) )
1023 aListOfIO.Remove( aIterateIO );
1026 // prepare dimension styling
1027 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1029 QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
1030 int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
1031 double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
1032 double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
1033 bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
1034 QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
1035 QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
1037 // restore dimension presentation from saved attribute or property data
1038 AIS_ListOfInteractive aRestoredDimensions;
1040 QVariant aProperty = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
1042 GEOM::propertyName( GEOM::Dimensions ),
1045 GEOMGUI_DimensionProperty aRecords;
1047 if ( aProperty.isValid() && aProperty.canConvert<GEOMGUI_DimensionProperty>() )
1049 aRecords = aProperty.value<GEOMGUI_DimensionProperty>();
1053 aRecords.LoadFromAttribute( getStudy(), theIO->getEntry() );
1056 // create up-to-date dimension presentations
1057 for ( int aPrsIt = 0; aPrsIt < aRecords.GetNumber(); ++aPrsIt )
1059 if ( !aRecords.IsVisible( aPrsIt ) )
1064 // init dimension by type
1065 Handle(AIS_Dimension) aPrs;
1066 switch( aRecords.GetType( aPrsIt ) )
1068 case GEOMGUI_DimensionProperty::DimensionType_Length :
1070 Handle(GEOM_AISLength) aLength = new GEOM_AISLength( aPrsIt );
1071 aRecords.GetRecord( aPrsIt )->AsLength()->Update( aLength, theShapeLCS );
1076 case GEOMGUI_DimensionProperty::DimensionType_Diameter :
1078 Handle(GEOM_AISDiameter) aDiam = new GEOM_AISDiameter( aPrsIt );
1079 aRecords.GetRecord( aPrsIt )->AsDiameter()->Update( aDiam, theShapeLCS );
1084 case GEOMGUI_DimensionProperty::DimensionType_Angle :
1086 Handle(GEOM_AISAngle) anAng = new GEOM_AISAngle( aPrsIt );
1087 aRecords.GetRecord( aPrsIt )->AsAngle()->Update( anAng, theShapeLCS );
1093 aPrs->SetOwner( theIO );
1095 Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
1097 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
1099 aStyle->SetCommonColor( aColor );
1100 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1101 aStyle->MakeText3d( Standard_True );
1102 aStyle->MakeTextShaded( Standard_True );
1103 aStyle->SetExtensionSize( aFontHeight * 0.5 );
1104 aStyle->TextAspect()->SetHeight( aFontHeight );
1105 aStyle->ArrowAspect()->SetLength( anArrowLength );
1106 aStyle->LineAspect()->SetWidth( aLineWidth );
1107 aStyle->SetTextHorizontalPosition( aPrs->DimensionAspect()->TextHorizontalPosition() );
1108 aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() );
1109 aStyle->SetArrowOrientation( aPrs->DimensionAspect()->ArrowOrientation() );
1110 aPrs->SetDimensionAspect( aStyle );
1111 aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
1112 aPrs->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
1113 aPrs->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
1115 if ( aPrs->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
1117 // show degree symbol for dimension instead of label "deg"
1118 if ( aUnitsAngle == "deg" )
1120 aPrs->SetSpecialSymbol(0xB0);
1121 aPrs->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
1122 aStyle->MakeUnitsDisplayed(Standard_False);
1126 aPrs->SetDisplaySpecialSymbol(AIS_DSS_No);
1127 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1132 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1135 aListOfIO.Append( aPrs );
1138 // update presentation
1141 for ( aIterateIO.Initialize( aListOfIO ); aIterateIO.More(); aIterateIO.Next() )
1143 anOccPrs->AddObject( aIterateIO.Value() );
1147 //=================================================================
1149 * GEOM_Displayer::Erase
1150 * Calls Erase() method for each object in the given list
1152 //=================================================================
1153 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
1155 const bool updateViewer )
1157 SALOME_ListIteratorOfListIO Iter( theIOList );
1158 for ( ; Iter.More(); Iter.Next() )
1159 Erase( Iter.Value(), forced, false );
1165 //=================================================================
1167 * GEOM_Displayer::Redisplay
1168 * Calls Redisplay() method for each object in the given list
1170 //=================================================================
1171 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1172 const bool updateViewer,
1173 const bool checkActiveViewer )
1175 SALOME_ListIteratorOfListIO Iter( theIOList );
1176 for ( ; Iter.More(); Iter.Next() )
1177 Redisplay( Iter.Value(), false, checkActiveViewer );
1183 //=================================================================
1185 * GEOM_Displayer::Redisplay
1186 * Calls Redisplay() method for each object in the given list
1188 //=================================================================
1189 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1190 const bool theUpdateViewer,
1191 SALOME_View* theViewFrame )
1193 SALOME_ListIteratorOfListIO anIter( theIOList );
1194 for ( ; anIter.More(); anIter.Next() )
1196 Redisplay( anIter.Value(), false, theViewFrame );
1199 if ( theUpdateViewer )
1205 //=================================================================
1207 * GEOM_Displayer::Update
1208 * Update OCC presentaion
1209 * [ Reimplemented from SALOME_Displayer ]
1211 //=================================================================
1212 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
1214 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
1215 SalomeApp_Study* study = getStudy();
1217 if ( !occPrs || myShape.IsNull() || !study )
1220 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1223 // specific processing for local coordinate system presentation
1226 TopoDS_Face aFace = TopoDS::Face( myShape );
1227 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1228 if ( !aPlane.IsNull() )
1230 gp_Ax3 aPos = aPlane->Pln().Position();
1231 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1233 Handle(GEOM_AISTrihedron) aTrh;
1235 if ( occPrs->IsNull() )
1237 // new presentation is being created
1238 aTrh = new GEOM_AISTrihedron( aPlc );
1239 occPrs->AddObject( aTrh );
1243 // presentation is being updated
1244 AIS_ListOfInteractive aList;
1245 occPrs->GetObjects( aList );
1246 AIS_ListIteratorOfListOfInteractive anIter( aList );
1247 for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) {
1248 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
1252 if ( !aTrh.IsNull() ) {
1253 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1255 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
1256 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1258 aTrh->SetWidth( GetWidth() );
1260 if ( !myIO.IsNull() )
1262 aTrh->setIO( myIO );
1263 aTrh->SetOwner( myIO );
1265 aTrh->SetComponent( aPlc );
1266 aTrh->SetToUpdate();
1268 occPrs->SetToActivate( ToActivate() );
1274 // processing for usual geometry presentation
1277 // if presentation is empty we try to create new one
1278 if ( occPrs->IsNull() )
1280 // create presentation (specific for vectors)
1281 Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" )
1282 : new GEOM_AISShape ( myShape, "" );
1284 if( myType == GEOM_FIELD_STEP )
1285 AISShape->SetHilightMode( GEOM_AISShape::CustomHighlight );
1286 // update shape properties
1287 updateShapeProperties( AISShape, true );
1289 // add shape to the presentation
1290 occPrs->AddObject( AISShape );
1292 // In accordance with ToActivate() value object will be activated/deactivated
1293 // when it will be displayed
1294 occPrs->SetToActivate( ToActivate() );
1296 if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) {
1297 // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1299 // create additional wireframe shape
1300 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1301 aWirePrs->SetWidth(AISShape->Width());
1302 if ( !myIO.IsNull() ) {
1303 aWirePrs->setIO( myIO );
1304 aWirePrs->SetOwner( myIO );
1307 // add shape to the presentation
1308 occPrs->AddObject( aWirePrs );
1311 // if presentation is found -> set again shape for it
1314 AIS_ListOfInteractive IOList;
1315 occPrs->GetObjects( IOList );
1316 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1317 for ( ; Iter.More(); Iter.Next() )
1319 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1320 if ( AISShape.IsNull() )
1323 // re-set shape (it might be changed)
1324 if ( AISShape->Shape() != myShape )
1325 AISShape->Set( myShape );
1327 // update shape properties
1328 updateShapeProperties( AISShape, false );
1331 AISShape->UpdateSelection();
1332 AISShape->SetToUpdate();
1336 updateDimensions( myIO, occPrs, GEOMUtils::GetPosition( myShape ) );
1340 //=================================================================
1342 * GEOM_Displayer::Update
1343 * Update VTK presentaion
1344 * [ Reimplemented from SALOME_Displayer ]
1346 //=================================================================
1347 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1349 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1350 SalomeApp_Study* study = getStudy();
1352 if ( !vtkPrs || myShape.IsNull() || !study )
1355 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1358 // specific processing for local coordinate system presentation
1361 TopoDS_Face aFace = TopoDS::Face( myShape );
1362 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1363 if ( !aPlane.IsNull() ) {
1364 gp_Ax3 aPos = aPlane->Pln().Position();
1365 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1367 GEOM_VTKTrihedron* aTrh = 0;
1369 if ( vtkPrs->IsNull() ) {
1370 // new presentation is being created
1371 aTrh = GEOM_VTKTrihedron::New();
1372 vtkPrs->AddObject( aTrh );
1375 // presentation is being updated
1376 vtkActorCollection* actors = vtkPrs->GetObjects();
1378 actors->InitTraversal();
1379 vtkActor* a = actors->GetNextActor();
1380 while ( a && !aTrh ) {
1381 aTrh = GEOM_VTKTrihedron::SafeDownCast( a );
1382 a = actors->GetNextActor();
1388 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1390 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1391 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1393 #ifdef VTK_TRIHEDRON_WIDTH
1395 // VSR: currently isn't supported
1397 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1399 aTrh->SetWidth( GetWidth() );
1402 if ( !myIO.IsNull() )
1403 aTrh->setIO( myIO );
1405 aTrh->SetPlacement( aPlc );
1412 // processing for usual geometry presentation
1415 // if presentation is empty we try to create new one
1416 if ( vtkPrs->IsNull() )
1419 GEOM_Actor* actor = GEOM_Actor::New();
1420 // update actor properties
1421 updateActorProperties( actor, true );
1422 // add actor to the presentation
1423 vtkPrs->AddObject( actor );
1426 // presentation is being updated
1427 vtkActorCollection* actors = vtkPrs->GetObjects();
1429 actors->InitTraversal();
1430 vtkActor* a = actors->GetNextActor();
1432 GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a );
1434 // update actor properties
1435 updateActorProperties( actor, false );
1436 a = actors->GetNextActor();
1444 //=================================================================
1446 * GEOM_Displayer::BuildPrs
1447 * Build presentation accordint to the current viewer type
1449 //=================================================================
1450 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1452 if ( theObj->_is_nil() )
1455 myViewFrame = GetActiveView();
1456 if ( myViewFrame == 0 )
1459 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1464 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1465 myType = theObj->GetType();
1467 // Update presentation
1473 //=================================================================
1475 * GEOM_Displayer::BuildPrs
1476 * Build presentation accordint to the current viewer type
1478 //=================================================================
1479 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1481 myViewFrame = GetActiveView();
1482 if ( theShape.IsNull() || myViewFrame == 0 )
1485 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1490 setShape( theShape );
1498 //=================================================================
1500 * GEOM_Displayer::buildPresentation
1501 * Builds/finds object's presentation for the current viewer
1502 * Calls corresponding Update() method by means of double dispatch
1505 //=================================================================
1506 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1507 SALOME_View* theViewFrame )
1509 SALOME_Prs* prs = 0;
1512 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1516 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1519 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1520 theIO->setEntry( entry.toLatin1().constData() );
1521 if ( !theIO.IsNull() )
1523 // set interactive object
1525 // Find SOBject (because shape should be published previously)
1526 SUIT_Session* session = SUIT_Session::session();
1527 SUIT_Application* app = session->activeApplication();
1530 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1533 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1536 // get CORBA reference to data object
1537 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1538 if ( !CORBA::is_nil( object ) )
1540 // downcast to GEOM base object
1541 GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
1542 if ( !GeomBaseObject->_is_nil() )
1544 myType = GeomBaseObject->GetType();
1546 // downcast to GEOM object
1547 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
1548 if ( myType == GEOM_FIELD_STEP )
1550 // get the GEOM object from the field's shape
1551 GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
1552 if ( !GeomFieldStep->_is_nil() )
1554 GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
1555 if ( !GeomField->_is_nil() )
1556 GeomObject = GeomField->GetShape();
1559 // read the field step information
1560 readFieldStepInfo( GeomFieldStep );
1563 if ( !GeomObject->_is_nil() )
1565 // finally set shape
1566 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1574 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1580 //=================================================================
1582 * GEOM_Displayer::buildSubshapePresentation
1583 * Builds/finds object's presentation for the current viewer
1584 * Calls corresponding Update() method by means of double dispatch
1585 * For not published objects (for Mantis issue 0020435)
1587 //=================================================================
1588 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1589 const QString& entry,
1590 SALOME_View* theViewFrame)
1592 SALOME_Prs* prs = 0;
1595 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1599 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1602 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1603 theIO->setEntry(entry.toLatin1().constData());
1604 if (!theIO.IsNull())
1606 // set interactive object
1608 // finally set shape
1610 myType = GEOM_SUBSHAPE;
1612 UpdatePrs(prs); // Update presentation by using of the double dispatch
1618 //=================================================================
1620 * GEOM_Displayer::internalReset
1621 * Resets internal data
1624 //=================================================================
1625 void GEOM_Displayer::internalReset()
1630 myFieldDataType = GEOM::FDT_Double;
1631 myFieldDimension = 0;
1632 myFieldStepData.clear();
1633 myFieldStepName.Clear();
1634 myFieldStepRangeMin = 0;
1635 myFieldStepRangeMax = 0;
1638 //=================================================================
1640 * GEOM_Displayer::LocalSelection
1641 * Activate selection of CAD shapes with activisation of selection
1642 * of their sub-shapes (with opened local context for OCC viewer)
1644 //=================================================================
1645 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1647 SUIT_Session* session = SUIT_Session::session();
1648 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1652 LightApp_SelectionMgr* sm = app->selectionMgr();
1654 // remove all filters from selection
1657 SALOME_View* vf = GetActiveView();
1659 if (!theIO.IsNull() && !vf->isVisible(theIO))
1661 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1662 vf->LocalSelection( prs, theMode );
1663 delete prs; // delete presentation because displayer is its owner
1667 //=================================================================
1669 * GEOM_Displayer::globalSelection
1670 * Activate selection of CAD shapes without activisation of selection
1671 * of their sub-shapes (without opened local context for OCC viewer)
1673 //=================================================================
1674 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1676 TColStd_MapOfInteger aModes;
1677 aModes.Add( theMode );
1678 GlobalSelection( aModes, update );
1681 //=================================================================
1683 * GEOM_Displayer::globalSelection
1684 * Activate selection of CAD shapes without activisation of selection
1685 * of their sub-shapes (without opened local context for OCC viewer)
1687 //=================================================================
1688 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1689 const bool update, const QList<int>* theSubShapes )
1691 SUIT_Session* session = SUIT_Session::session();
1692 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1696 SALOME_View* vf = GetActiveView();
1700 // Close local context
1701 vf->GlobalSelection( update );
1703 // Set selection filters in accordance with current mode
1704 LightApp_SelectionMgr* sm = app->selectionMgr();
1708 // Remove from selection temporary objects if necessary
1709 if ( !theModes.Contains( GEOM_PREVIEW ) )
1710 clearTemporary( sm );
1712 //@ aSel->ClearIndex();
1716 // Remove filters from AIS_InteractiveContext
1717 Handle(AIS_InteractiveContext) ic;
1718 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1721 ic = viewer->getAISContext();
1723 ic->RemoveFilters();
1726 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1729 SUIT_SelectionFilter* aFilter;
1730 if ( theModes.Extent() == 1 )
1732 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1734 if ( aMode == GEOM_COMPOUNDFILTER )
1735 aFilter = getComplexFilter( theSubShapes );
1737 aFilter = getFilter( aMode );
1739 else if ( theModes.Extent() > 1 )
1741 TColStd_MapOfInteger aTopAbsModes;
1742 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1743 QList<SUIT_SelectionFilter*> aListOfFilters;
1744 for ( ; anIter.More(); anIter.Next() )
1746 SUIT_SelectionFilter* aFilter;
1747 int aMode = anIter.Key();
1748 if ( aMode == GEOM_COMPOUNDFILTER )
1749 aFilter = getComplexFilter( theSubShapes );
1751 aFilter = getFilter( aMode );
1754 aListOfFilters.append( aFilter );
1757 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1764 sm->installFilter( aFilter );
1767 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1768 ic->AddFilter( anOCCFilter );
1773 //=================================================================
1775 * GEOM_Displayer::LocalSelection
1776 * Activate selection of CAD shapes with activisation of selection
1777 * of their sub-shapes (with opened local context for OCC viewer)
1779 //=================================================================
1780 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1782 SALOME_ListIteratorOfListIO Iter( theIOList );
1783 for ( ; Iter.More(); Iter.Next() )
1784 LocalSelection( Iter.Value(), theMode );
1787 //=================================================================
1789 * GEOM_Displayer::BeforeDisplay
1790 * Called before displaying of pars. Close local context
1791 * [ Reimplemented from SALOME_Displayer ]
1793 //=================================================================
1794 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1796 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1799 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1802 if ( ic->HasOpenedContext() )
1803 ic->CloseAllContexts();
1808 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1810 UpdateColorScale(false,false);
1813 void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
1815 LightApp_Displayer::AfterErase( v, p );
1816 UpdateColorScale(false,false);
1819 //=================================================================
1821 * GEOM_Displayer::SetColor
1822 * Set color for shape displaying. If it is equal -1 then default color is used.
1823 * Available values are from Quantity_NameOfColor enumeration
1825 //=================================================================
1826 void GEOM_Displayer::SetColor( const int color )
1833 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1837 int GEOM_Displayer::GetColor() const
1842 bool GEOM_Displayer::HasColor() const
1844 return myColor != -1;
1847 void GEOM_Displayer::UnsetColor()
1851 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1852 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1853 myShadingColor = SalomeApp_Tools::color( col );
1856 //=================================================================
1858 * GEOM_Displayer::SetTexture
1859 * Set color for shape displaying. If it is equal -1 then default color is used.
1860 * Available values are from Quantity_NameOfColor enumeration
1862 //=================================================================
1863 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1865 if(texureFileName!="")
1867 myTexture = texureFileName;
1871 bool GEOM_Displayer::HasTexture() const
1873 return myTexture != "";
1876 std::string GEOM_Displayer::GetTexture() const
1881 //=================================================================
1883 * GEOM_Displayer::SetWidth
1884 * Set width of shape displaying. If it is equal -1 then default width is used.
1886 //=================================================================
1887 void GEOM_Displayer::SetWidth( const double width )
1892 double GEOM_Displayer::GetWidth() const
1897 bool GEOM_Displayer::HasWidth() const
1899 return myWidth != -1;
1902 void GEOM_Displayer::UnsetWidth()
1908 int GEOM_Displayer::GetIsosWidth() const
1913 void GEOM_Displayer::SetIsosWidth(const int width)
1915 myIsosWidth = width;
1918 bool GEOM_Displayer::HasIsosWidth() const
1920 return myIsosWidth != -1;
1924 //=================================================================
1926 * GEOM_Displayer::SetToActivate
1927 * This method is used for activisation/deactivisation of objects to be displayed
1929 //=================================================================
1930 void GEOM_Displayer::SetToActivate( const bool toActivate )
1932 myToActivate = toActivate;
1934 bool GEOM_Displayer::ToActivate() const
1936 return myToActivate;
1939 //=================================================================
1941 * GEOM_Displayer::clearTemporary
1942 * Removes from selection temporary objects
1944 //=================================================================
1945 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1947 SALOME_ListIO selected, toSelect;
1948 theSelMgr->selectedObjects( selected );
1950 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1951 Handle(SALOME_InteractiveObject) io = it.Value();
1952 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1953 toSelect.Append( it.Value() );
1956 theSelMgr->setSelectedObjects( toSelect, true );
1959 void GEOM_Displayer::SetName( const char* theName )
1964 void GEOM_Displayer::UnsetName()
1969 SalomeApp_Study* GEOM_Displayer::getStudy() const
1971 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1974 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1979 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1984 void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
1985 const int theFieldDimension,
1986 const QList<QVariant>& theFieldStepData,
1987 const TCollection_AsciiString& theFieldStepName,
1988 const double theFieldStepRangeMin,
1989 const double theFieldStepRangeMax )
1991 myFieldDataType = theFieldDataType;
1992 myFieldDimension = theFieldDimension;
1993 myFieldStepData = theFieldStepData;
1994 myFieldStepName = theFieldStepName;
1995 myFieldStepRangeMin = theFieldStepRangeMin;
1996 myFieldStepRangeMax = theFieldStepRangeMax;
1999 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
2001 _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
2002 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects
2003 GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps
2004 GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component
2005 return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) &&
2006 (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type());
2009 int GEOM_Displayer::SetDisplayMode( const int theMode )
2011 int aPrevMode = myDisplayMode;
2012 if ( theMode != -1 ) {
2013 myDisplayMode = theMode;
2014 myHasDisplayMode = true;
2022 int GEOM_Displayer::GetDisplayMode() const
2024 return myDisplayMode;
2027 int GEOM_Displayer::UnsetDisplayMode()
2029 int aPrevMode = myDisplayMode;
2030 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2031 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
2032 myHasDisplayMode = false;
2036 bool GEOM_Displayer::HasDisplayMode() const
2038 return myHasDisplayMode;
2041 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
2043 static QList<QColor> colors;
2045 if ( colors.isEmpty() ) {
2047 for (int s = 0; s < 2 ; s++)
2049 for (int v = 100; v >= 40; v = v - 20)
2051 for (int h = 0; h < 359 ; h = h + 60)
2053 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
2059 static int currentColor = 0;
2061 SALOMEDS::Color color;
2062 color.R = (double)colors[currentColor].red() / 255.0;
2063 color.G = (double)colors[currentColor].green() / 255.0;
2064 color.B = (double)colors[currentColor].blue() / 255.0;
2066 currentColor = (currentColor+1) % colors.count();
2071 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
2074 int aTolerance = 64;
2075 int anIterations = 0;
2081 if( anIterations % aPeriod == 0 )
2084 if( aTolerance < 1 )
2087 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
2089 aHue = (int)( 360.0 * rand() / RAND_MAX );
2090 //std::cout << "Hue = " << aHue << std::endl;
2092 //std::cout << "Auto colors : ";
2094 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
2095 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
2096 for( ; it != itEnd; ++it )
2098 SALOMEDS::Color anAutoColor = *it;
2099 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
2102 aQColor.getHsv( &h, &s, &v );
2103 //std::cout << h << " ";
2104 if( abs( h - aHue ) < aTolerance )
2107 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
2111 //std::cout << std::endl;
2117 //std::cout << "Hue of the returned color = " << aHue << std::endl;
2119 aColor.setHsv( aHue, 255, 255 );
2121 SALOMEDS::Color aSColor;
2122 aSColor.R = (double)aColor.red() / 255.0;
2123 aSColor.G = (double)aColor.green() / 255.0;
2124 aSColor.B = (double)aColor.blue() / 255.0;
2129 PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
2130 const QString& entry,
2133 // get default properties for the explicitly specified default view type
2134 PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
2136 if ( study && view ) {
2137 SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
2138 SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
2139 int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
2141 if ( viewModel && viewId != -1 ) {
2142 // get properties from the study
2143 PropMap storedMap = study->getObjectPropMap( viewId, entry );
2144 // overwrite default properties from stored ones (that are specified)
2145 for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
2146 if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
2147 propMap.insert( GEOM::propertyName( (GEOM::Property)prop ),
2148 storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) );
2150 // ... specific processing for color
2151 // ... current implementation is to use same stored color for all aspects
2152 // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2153 if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2154 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2155 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2156 propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2157 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2158 propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2161 if ( !entry.isEmpty() ) {
2162 // get CORBA reference to geom object
2163 _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
2165 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
2166 if ( !CORBA::is_nil( object ) ) {
2167 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object );
2168 if ( !CORBA::is_nil( geomObject ) ) { // to check
2169 // check that geom object has color properly set
2170 bool hasColor = false;
2171 SALOMEDS::Color aSColor = getColor( geomObject, hasColor );
2172 // set color from geometry object (only once, if it is not yet set in GUI)
2173 // current implementation is to use same color for all aspects
2174 // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2175 if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2176 QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B );
2177 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor );
2178 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor );
2179 propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor );
2180 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor );
2181 propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor );
2183 // check that object has point marker properly set
2184 GEOM::marker_type mType = geomObject->GetMarkerType();
2185 GEOM::marker_size mSize = geomObject->GetMarkerSize();
2186 int mTextureId = geomObject->GetMarkerTexture();
2187 bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) ||
2188 ( mType == GEOM::MT_USER && mTextureId > 0 );
2189 // set point marker from geometry object (only once, if it is not yet set in GUI)
2190 if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) {
2191 if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) {
2193 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2194 QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) );
2196 else if ( mType == GEOM::MT_USER ) {
2198 propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) );
2210 PropMap GEOM_Displayer::getDefaultPropertyMap()
2214 // get resource manager
2215 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2217 // fill in the properties map with default values
2219 // - visibility (false by default)
2220 propMap.insert( GEOM::propertyName( GEOM::Visibility ), false );
2222 // - nb isos (take default value from preferences)
2223 propMap.insert( GEOM::propertyName( GEOM::NbIsos ),
2224 QString( "%1%2%3" ).
2225 arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ).
2226 arg( GEOM::subSectionSeparator() ).
2227 arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) );
2229 // - transparency (opacity = 1-transparency)
2230 propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 );
2232 // - display mode (take default value from preferences)
2233 propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
2234 resMgr->integerValue( "Geometry", "display_mode", 0 ) );
2236 // - show edges direction flag (false by default)
2237 propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false );
2239 // - shading color (take default value from preferences)
2240 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
2241 colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
2243 // - wireframe color (take default value from preferences)
2244 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ),
2245 colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) );
2247 // - standalone edges color (take default value from preferences)
2248 propMap.insert( GEOM::propertyName( GEOM::LineColor ),
2249 colorFromResources( "line_color", QColor( 255, 0, 0 ) ) );
2251 // - free boundaries color (take default value from preferences)
2252 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ),
2253 colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) );
2255 // - points color (take default value from preferences)
2256 propMap.insert( GEOM::propertyName( GEOM::PointColor ),
2257 colorFromResources( "point_color", QColor( 255, 255, 0 ) ) );
2259 // - isos color (take default value from preferences)
2260 propMap.insert( GEOM::propertyName( GEOM::IsosColor ),
2261 colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) );
2263 // - outlines color (take default value from preferences)
2264 propMap.insert( GEOM::propertyName( GEOM::OutlineColor ),
2265 colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) );
2267 // - deflection coefficient (take default value from preferences)
2268 propMap.insert( GEOM::propertyName( GEOM::Deflection ),
2269 resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) );
2271 // - material (take default value from preferences)
2272 Material_Model material;
2273 material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
2274 propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() );
2276 // - edge width (take default value from preferences)
2277 propMap.insert( GEOM::propertyName( GEOM::LineWidth ),
2278 resMgr->integerValue( "Geometry", "edge_width", 1 ) );
2280 // - isos width (take default value from preferences)
2281 propMap.insert( GEOM::propertyName( GEOM::IsosWidth ),
2282 resMgr->integerValue( "Geometry", "isolines_width", 1 ) );
2284 // - point marker (take default value from preferences)
2285 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2286 QString( "%1%2%3" ).
2287 arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ).
2288 arg( GEOM::subSectionSeparator() ).
2289 arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) );
2291 // - top-level flag (false by default)
2292 propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false );
2297 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2298 SALOMEDS::Color aSColor;
2301 SUIT_Session* session = SUIT_Session::session();
2302 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2304 if ( app && !theGeomObject->_is_nil()) {
2305 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2308 _PTR(Study) aStudy = study->studyDS();
2309 aSColor = theGeomObject->GetColor();
2310 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2312 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2313 bool general_autocolor = true;
2314 #else // auto-color for groups only
2315 bool general_autocolor = false;
2316 #endif // GENERAL_AUTOCOLOR
2317 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2318 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2319 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2320 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2321 aSColor = getPredefinedUniqueColor();
2323 #else // old algorithm for auto-colors
2324 QList<SALOMEDS::Color> aReservedColors;
2325 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2326 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2327 if ( aMainSObject ) {
2328 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2329 for ( ; it->More(); it->Next() ) {
2330 _PTR(SObject) aChildSObject( it->Value() );
2331 GEOM::GEOM_Object_var aChildObject =
2332 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2333 if ( CORBA::is_nil( aChildObject ) )
2336 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2337 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2338 aReservedColors.append( aReservedColor );
2341 aSColor = getUniqueColor( aReservedColors );
2343 #endif // SIMPLE_AUTOCOLOR
2353 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2354 const bool eraseOnlyChildren) {
2355 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2359 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2363 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2368 // Erase from all views
2369 QList<SALOME_View*> views;
2371 ViewManagerList vmans = app->viewManagers();
2372 SUIT_ViewManager* vman;
2373 foreach ( vman, vmans ) {
2374 SUIT_ViewModel* vmod = vman->getViewModel();
2375 view = dynamic_cast<SALOME_View*> ( vmod );
2377 views.append( view );
2380 if( views.count() == 0 )
2383 //Erase childrens w/o update views
2384 DataObjectList listObj = parent->children( true );
2385 SUIT_DataObject* obj;
2386 foreach( obj, listObj ) {
2387 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2389 foreach ( view, views ) {
2390 Handle(SALOME_InteractiveObject) anIO =
2391 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2392 Erase(anIO, false, false, view);
2396 //Erase parent with view update or repaint views
2397 foreach ( view, views ) {
2398 if(!eraseOnlyChildren)
2399 Erase(theIO, false, true, view);
2405 void GEOM_Displayer::readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep )
2407 if( theGeomFieldStep->_is_nil() )
2410 GEOM::GEOM_Field_var aGeomField = theGeomFieldStep->GetField();
2411 if( aGeomField->_is_nil() )
2414 GEOM::GEOM_Object_var aGeomFieldShape = aGeomField->GetShape();
2415 if( aGeomFieldShape->_is_nil() )
2418 TCollection_AsciiString aFieldStepName( theGeomFieldStep->GetName() );
2419 TCollection_AsciiString aFieldName( aGeomField->GetName() );
2420 TCollection_AsciiString aShapeName( aGeomFieldShape->GetName() );
2422 aFieldStepName = aShapeName + "\n" + aFieldName + "\n" + aFieldStepName;
2424 GEOM::field_data_type aFieldDataType = aGeomField->GetDataType();
2426 int aFieldDimension = aGeomField->GetDimension();
2428 GEOM::string_array_var aFieldComponents = aGeomField->GetComponents();
2429 int aFieldNbComponents = aFieldComponents->length();
2431 QList<QVariant> aFieldStepData;
2432 if( aFieldDataType == GEOM::FDT_Bool )
2434 GEOM::GEOM_BoolFieldStep_var aGeomBoolFieldStep = GEOM::GEOM_BoolFieldStep::_narrow( theGeomFieldStep );
2435 if ( !aGeomBoolFieldStep->_is_nil() )
2437 GEOM::short_array_var aValues = aGeomBoolFieldStep->GetValues();
2438 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2439 aFieldStepData << (bool)aValues[i];
2442 else if( aFieldDataType == GEOM::FDT_Int )
2444 GEOM::GEOM_IntFieldStep_var aGeomIntFieldStep = GEOM::GEOM_IntFieldStep::_narrow( theGeomFieldStep );
2445 if ( !aGeomIntFieldStep->_is_nil() )
2447 GEOM::ListOfLong_var aValues = aGeomIntFieldStep->GetValues();
2448 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2449 aFieldStepData << (qlonglong)aValues[i];
2452 else if( aFieldDataType == GEOM::FDT_Double )
2454 GEOM::GEOM_DoubleFieldStep_var aGeomDoubleFieldStep = GEOM::GEOM_DoubleFieldStep::_narrow( theGeomFieldStep );
2455 if ( !aGeomDoubleFieldStep->_is_nil() )
2457 GEOM::ListOfDouble_var aValues = aGeomDoubleFieldStep->GetValues();
2458 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2459 aFieldStepData << (double)aValues[i];
2462 else if( aFieldDataType == GEOM::FDT_String )
2464 GEOM::GEOM_StringFieldStep_var aGeomStringFieldStep = GEOM::GEOM_StringFieldStep::_narrow( theGeomFieldStep );
2465 if ( !aGeomStringFieldStep->_is_nil() )
2467 GEOM::string_array_var aValues = aGeomStringFieldStep->GetValues();
2468 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2469 aFieldStepData << QString( aValues[i] );
2473 double aFieldStepRangeMin = 0, aFieldStepRangeMax = 0;
2474 aFieldStepData = groupFieldData( aFieldStepData,
2476 aFieldDataType == GEOM::FDT_String,
2478 aFieldStepRangeMax );
2480 setFieldStepInfo( aFieldDataType,
2485 aFieldStepRangeMax );
2488 QList<QVariant> GEOM_Displayer::groupFieldData( const QList<QVariant>& theFieldStepData,
2489 const int theFieldNbComponents,
2490 const bool theIsString,
2491 double& theFieldStepRangeMin,
2492 double& theFieldStepRangeMax )
2494 QList<QVariant> aResultList;
2495 theFieldStepRangeMin = 0;
2496 theFieldStepRangeMax = 0;
2498 if( theFieldStepData.isEmpty() || theFieldNbComponents < 1 )
2501 int aNbSubShapes = theFieldStepData.count() / theFieldNbComponents;
2503 QList<QVariant> aGroupedList;
2505 bool anIsBoolean = false;
2506 for( int aSubShape = 0; aSubShape < aNbSubShapes; aSubShape++ )
2509 QStringList aStringList;
2511 int aBaseIndex = aSubShape * theFieldNbComponents;
2512 for( int aComponent = 0; aComponent < theFieldNbComponents; aComponent++ )
2514 int anIndex = aComponent + aBaseIndex;
2516 const QVariant& aVariant = theFieldStepData[ anIndex ];
2519 if( aVariant.type() == QVariant::String )
2520 aStringList << aVariant.toString();
2525 if( aVariant.type() == QVariant::Bool )
2527 aValue = aVariant.toBool() ? 1.0 : 0.0;
2533 if( aVariant.type() == QVariant::Int )
2534 aValue = double( aVariant.toInt() );
2535 else if( aVariant.type() == QVariant::Double )
2536 aValue = aVariant.toDouble();
2537 aNorm += aValue * aValue;
2543 aGroupedList << aStringList.join( "\n" );
2547 aNorm /= theFieldNbComponents;
2549 aNorm = pow( aNorm, 0.5 );
2551 if( aGroupedList.isEmpty() )
2552 theFieldStepRangeMin = theFieldStepRangeMax = aNorm;
2555 theFieldStepRangeMin = Min( theFieldStepRangeMin, aNorm );
2556 theFieldStepRangeMax = Max( theFieldStepRangeMax, aNorm );
2559 aGroupedList << aNorm;
2565 theFieldStepRangeMin = 0.0;
2566 theFieldStepRangeMax = 1.0;
2569 SUIT_Session* session = SUIT_Session::session();
2570 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2571 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2573 QListIterator<QVariant> anIter( aGroupedList );
2574 while( anIter.hasNext() )
2576 const QVariant& aVariant = anIter.next();
2578 aResultList << aVariant;
2582 Quantity_Color aColor;
2583 if( FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
2584 aQColor = QColor::fromRgbF( aColor.Red(), aColor.Green(), aColor.Blue() );
2585 aResultList << aQColor;
2591 // Note: the method is copied from Aspect_ColorScale class
2592 Standard_Integer GEOM_Displayer::HueFromValue( const Standard_Integer aValue,
2593 const Standard_Integer aMin,
2594 const Standard_Integer aMax )
2596 Standard_Integer minLimit( 0 ), maxLimit( 230 );
2598 Standard_Integer aHue = maxLimit;
2600 aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( aValue - aMin ) / ( aMax - aMin ) );
2602 aHue = Min( Max( minLimit, aHue ), maxLimit );
2607 // Note: the method is copied from Aspect_ColorScale class
2608 Standard_Boolean GEOM_Displayer::FindColor( const Standard_Real aValue,
2609 const Standard_Real aMin,
2610 const Standard_Real aMax,
2611 const Standard_Integer ColorsCount,
2612 Quantity_Color& aColor )
2614 if( aValue<aMin || aValue>aMax || aMax<aMin )
2615 return Standard_False;
2619 Standard_Real IntervNumber = 0;
2622 else if( aValue>aMax )
2623 IntervNumber = ColorsCount-1;
2624 else if( Abs( aMax-aMin ) > Precision::Approximation() )
2625 IntervNumber = Floor( Standard_Real( ColorsCount ) * ( aValue - aMin ) / ( aMax - aMin ) ); // 'Ceiling' replaced with 'Floor'
2627 Standard_Integer Interv = Standard_Integer( IntervNumber );
2629 aColor = Quantity_Color( HueFromValue( Interv, 0, ColorsCount - 1 ), 1.0, 1.0, Quantity_TOC_HLS );
2631 return Standard_True;
2635 void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, const bool updateViewer )
2637 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
2641 SOCC_Viewer* aViewModel = dynamic_cast<SOCC_Viewer*>( GetActiveView() );
2645 Handle(V3d_Viewer) aViewer = aViewModel->getViewer3d();
2646 if( aViewer.IsNull() )
2649 aViewer->InitActiveViews();
2650 if( !aViewer->MoreActiveViews() )
2653 Handle(V3d_View) aView = aViewer->ActiveView();
2654 if( aView.IsNull() )
2657 Standard_Boolean anIsDisplayColorScale = Standard_False;
2658 TCollection_AsciiString aColorScaleTitle;
2659 Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
2660 Standard_Boolean anIsBoolean = Standard_False;
2662 SALOME_ListIO aSelectedObjects;
2663 myApp->selectionMgr()->selectedObjects( aSelectedObjects );
2664 if( aSelectedObjects.Extent() == 1 )
2666 Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
2667 if( !anIO.IsNull() )
2669 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
2672 AIS_ListOfInteractive aList;
2673 aPrs->GetObjects( aList );
2674 AIS_ListIteratorOfListOfInteractive anIter( aList );
2675 for( ; anIter.More(); anIter.Next() )
2677 Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
2678 if( !aShape.IsNull() )
2680 GEOM::field_data_type aFieldDataType;
2681 int aFieldDimension;
2682 QList<QVariant> aFieldStepData;
2683 TCollection_AsciiString aFieldStepName;
2684 double aFieldStepRangeMin, aFieldStepRangeMax;
2685 aShape->getFieldStepInfo( aFieldDataType,
2690 aFieldStepRangeMax );
2691 if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
2693 anIsDisplayColorScale = Standard_True;
2694 aColorScaleTitle = aFieldStepName;
2695 aColorScaleMin = aFieldStepRangeMin;
2696 aColorScaleMax = aFieldStepRangeMax;
2697 anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
2705 if( anIsDisplayColorScale )
2707 Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
2708 if( !aColorScale.IsNull() )
2710 SUIT_Session* session = SUIT_Session::session();
2711 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2713 Standard_Real anXPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
2714 Standard_Real anYPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
2715 Standard_Real aWidth = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
2716 Standard_Real aHeight = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
2717 Standard_Integer aTextHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
2718 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2720 aColorScale->SetXPosition( anXPos );
2721 aColorScale->SetYPosition( anYPos );
2722 aColorScale->SetWidth( aWidth );
2723 aColorScale->SetHeight( aHeight );
2725 aColorScale->SetTextHeight( aTextHeight );
2726 aColorScale->SetNumberOfIntervals( anIsBoolean ? 2 : aNbIntervals );
2728 aColorScale->SetTitle( aColorScaleTitle );
2729 aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
2731 if( !aView->ColorScaleIsDisplayed() )
2732 aView->ColorScaleDisplay();
2736 if( aView->ColorScaleIsDisplayed() )
2737 aView->ColorScaleErase();
2740 if( theIsRedisplayFieldSteps )
2742 _PTR(Study) aStudyDS = aStudy->studyDS();
2743 QList<SUIT_ViewManager*> vmList;
2744 myApp->viewManagers( vmList );
2745 for( QList<SUIT_ViewManager*>::Iterator vmIt = vmList.begin(); vmIt != vmList.end(); vmIt++ )
2747 if( SUIT_ViewManager* aViewManager = *vmIt )
2749 const ObjMap anObjects = aStudy->getObjectMap( aViewManager->getGlobalId() );
2750 for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ )
2752 _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) );
2755 CORBA::Object_var anObject = GeometryGUI::ClientSObjectToObject( aSObj );
2756 if( !CORBA::is_nil( anObject ) )
2758 GEOM::GEOM_FieldStep_var aFieldStep = GEOM::GEOM_FieldStep::_narrow( anObject );
2759 if( !aFieldStep->_is_nil() )
2761 CORBA::String_var aStepEntry = aFieldStep->GetStudyEntry();
2762 Handle(SALOME_InteractiveObject) aStepIO =
2763 new SALOME_InteractiveObject( aStepEntry.in(), "GEOM", "TEMP_IO" );
2764 Redisplay( aStepIO, false, false );