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 );
1025 if ( !aIterateIO.More() )
1031 // prepare dimension styling
1032 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1034 QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
1035 int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
1036 double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
1037 double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
1038 bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
1039 QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
1040 QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
1042 // restore dimension presentation from saved attribute or property data
1043 AIS_ListOfInteractive aRestoredDimensions;
1045 QVariant aProperty = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
1047 GEOM::propertyName( GEOM::Dimensions ),
1050 GEOMGUI_DimensionProperty aRecords;
1052 if ( aProperty.isValid() && aProperty.canConvert<GEOMGUI_DimensionProperty>() )
1054 aRecords = aProperty.value<GEOMGUI_DimensionProperty>();
1058 aRecords.LoadFromAttribute( getStudy(), theIO->getEntry() );
1061 // create up-to-date dimension presentations
1062 for ( int aPrsIt = 0; aPrsIt < aRecords.GetNumber(); ++aPrsIt )
1064 if ( !aRecords.IsVisible( aPrsIt ) )
1069 // init dimension by type
1070 Handle(AIS_Dimension) aPrs;
1071 switch( aRecords.GetType( aPrsIt ) )
1073 case GEOMGUI_DimensionProperty::DimensionType_Length :
1075 Handle(GEOM_AISLength) aLength = new GEOM_AISLength( aPrsIt );
1076 aRecords.GetRecord( aPrsIt )->AsLength()->Update( aLength, theShapeLCS );
1081 case GEOMGUI_DimensionProperty::DimensionType_Diameter :
1083 Handle(GEOM_AISDiameter) aDiam = new GEOM_AISDiameter( aPrsIt );
1084 aRecords.GetRecord( aPrsIt )->AsDiameter()->Update( aDiam, theShapeLCS );
1089 case GEOMGUI_DimensionProperty::DimensionType_Angle :
1091 Handle(GEOM_AISAngle) anAng = new GEOM_AISAngle( aPrsIt );
1092 aRecords.GetRecord( aPrsIt )->AsAngle()->Update( anAng, theShapeLCS );
1098 aPrs->SetOwner( theIO );
1100 Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
1102 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
1104 aStyle->SetCommonColor( aColor );
1105 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1106 aStyle->MakeText3d( Standard_True );
1107 aStyle->MakeTextShaded( Standard_True );
1108 aStyle->SetExtensionSize( aFontHeight * 0.5 );
1109 aStyle->TextAspect()->SetHeight( aFontHeight );
1110 aStyle->ArrowAspect()->SetLength( anArrowLength );
1111 aStyle->LineAspect()->SetWidth( aLineWidth );
1112 aStyle->SetTextHorizontalPosition( aPrs->DimensionAspect()->TextHorizontalPosition() );
1113 aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() );
1114 aStyle->SetArrowOrientation( aPrs->DimensionAspect()->ArrowOrientation() );
1115 aPrs->SetDimensionAspect( aStyle );
1116 aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
1117 aPrs->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
1118 aPrs->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
1120 if ( aPrs->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
1122 // show degree symbol for dimension instead of label "deg"
1123 if ( aUnitsAngle == "deg" )
1125 aPrs->SetSpecialSymbol(0xB0);
1126 aPrs->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
1127 aStyle->MakeUnitsDisplayed(Standard_False);
1131 aPrs->SetDisplaySpecialSymbol(AIS_DSS_No);
1132 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1137 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1140 aListOfIO.Append( aPrs );
1143 // update presentation
1146 for ( aIterateIO.Initialize( aListOfIO ); aIterateIO.More(); aIterateIO.Next() )
1148 anOccPrs->AddObject( aIterateIO.Value() );
1152 //=================================================================
1154 * GEOM_Displayer::Erase
1155 * Calls Erase() method for each object in the given list
1157 //=================================================================
1158 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
1160 const bool updateViewer )
1162 SALOME_ListIteratorOfListIO Iter( theIOList );
1163 for ( ; Iter.More(); Iter.Next() )
1164 Erase( Iter.Value(), forced, false );
1170 //=================================================================
1172 * GEOM_Displayer::Redisplay
1173 * Calls Redisplay() method for each object in the given list
1175 //=================================================================
1176 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1177 const bool updateViewer,
1178 const bool checkActiveViewer )
1180 SALOME_ListIteratorOfListIO Iter( theIOList );
1181 for ( ; Iter.More(); Iter.Next() )
1182 Redisplay( Iter.Value(), false, checkActiveViewer );
1188 //=================================================================
1190 * GEOM_Displayer::Redisplay
1191 * Calls Redisplay() method for each object in the given list
1193 //=================================================================
1194 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1195 const bool theUpdateViewer,
1196 SALOME_View* theViewFrame )
1198 SALOME_ListIteratorOfListIO anIter( theIOList );
1199 for ( ; anIter.More(); anIter.Next() )
1201 Redisplay( anIter.Value(), false, theViewFrame );
1204 if ( theUpdateViewer )
1210 //=================================================================
1212 * GEOM_Displayer::Update
1213 * Update OCC presentaion
1214 * [ Reimplemented from SALOME_Displayer ]
1216 //=================================================================
1217 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
1219 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
1220 SalomeApp_Study* study = getStudy();
1222 if ( !occPrs || myShape.IsNull() || !study )
1225 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1228 // specific processing for local coordinate system presentation
1231 TopoDS_Face aFace = TopoDS::Face( myShape );
1232 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1233 if ( !aPlane.IsNull() )
1235 gp_Ax3 aPos = aPlane->Pln().Position();
1236 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1238 Handle(GEOM_AISTrihedron) aTrh;
1240 if ( occPrs->IsNull() )
1242 // new presentation is being created
1243 aTrh = new GEOM_AISTrihedron( aPlc );
1244 occPrs->AddObject( aTrh );
1248 // presentation is being updated
1249 AIS_ListOfInteractive aList;
1250 occPrs->GetObjects( aList );
1251 AIS_ListIteratorOfListOfInteractive anIter( aList );
1252 for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) {
1253 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
1257 if ( !aTrh.IsNull() ) {
1258 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1260 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
1261 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1263 aTrh->SetWidth( GetWidth() );
1265 if ( !myIO.IsNull() )
1267 aTrh->setIO( myIO );
1268 aTrh->SetOwner( myIO );
1270 aTrh->SetComponent( aPlc );
1271 aTrh->SetToUpdate();
1273 occPrs->SetToActivate( ToActivate() );
1279 // processing for usual geometry presentation
1282 // if presentation is empty we try to create new one
1283 if ( occPrs->IsNull() )
1285 // create presentation (specific for vectors)
1286 Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" )
1287 : new GEOM_AISShape ( myShape, "" );
1289 if( myType == GEOM_FIELD_STEP )
1290 AISShape->SetHilightMode( GEOM_AISShape::CustomHighlight );
1291 // update shape properties
1292 updateShapeProperties( AISShape, true );
1294 // add shape to the presentation
1295 occPrs->AddObject( AISShape );
1297 // In accordance with ToActivate() value object will be activated/deactivated
1298 // when it will be displayed
1299 occPrs->SetToActivate( ToActivate() );
1301 if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) {
1302 // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1304 // create additional wireframe shape
1305 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1306 aWirePrs->SetWidth(AISShape->Width());
1307 if ( !myIO.IsNull() ) {
1308 aWirePrs->setIO( myIO );
1309 aWirePrs->SetOwner( myIO );
1312 // add shape to the presentation
1313 occPrs->AddObject( aWirePrs );
1316 // if presentation is found -> set again shape for it
1319 AIS_ListOfInteractive IOList;
1320 occPrs->GetObjects( IOList );
1321 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1322 for ( ; Iter.More(); Iter.Next() )
1324 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1325 if ( AISShape.IsNull() )
1328 // re-set shape (it might be changed)
1329 if ( AISShape->Shape() != myShape )
1330 AISShape->Set( myShape );
1332 // update shape properties
1333 updateShapeProperties( AISShape, false );
1336 AISShape->UpdateSelection();
1337 AISShape->SetToUpdate();
1341 updateDimensions( myIO, occPrs, gp_Ax3().Transformed( myShape.Location().Transformation() ) );
1345 //=================================================================
1347 * GEOM_Displayer::Update
1348 * Update VTK presentaion
1349 * [ Reimplemented from SALOME_Displayer ]
1351 //=================================================================
1352 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1354 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1355 SalomeApp_Study* study = getStudy();
1357 if ( !vtkPrs || myShape.IsNull() || !study )
1360 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1363 // specific processing for local coordinate system presentation
1366 TopoDS_Face aFace = TopoDS::Face( myShape );
1367 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1368 if ( !aPlane.IsNull() ) {
1369 gp_Ax3 aPos = aPlane->Pln().Position();
1370 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1372 GEOM_VTKTrihedron* aTrh = 0;
1374 if ( vtkPrs->IsNull() ) {
1375 // new presentation is being created
1376 aTrh = GEOM_VTKTrihedron::New();
1377 vtkPrs->AddObject( aTrh );
1380 // presentation is being updated
1381 vtkActorCollection* actors = vtkPrs->GetObjects();
1383 actors->InitTraversal();
1384 vtkActor* a = actors->GetNextActor();
1385 while ( a && !aTrh ) {
1386 aTrh = GEOM_VTKTrihedron::SafeDownCast( a );
1387 a = actors->GetNextActor();
1393 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1395 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1396 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1398 #ifdef VTK_TRIHEDRON_WIDTH
1400 // VSR: currently isn't supported
1402 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1404 aTrh->SetWidth( GetWidth() );
1407 if ( !myIO.IsNull() )
1408 aTrh->setIO( myIO );
1410 aTrh->SetPlacement( aPlc );
1417 // processing for usual geometry presentation
1420 // if presentation is empty we try to create new one
1421 if ( vtkPrs->IsNull() )
1424 GEOM_Actor* actor = GEOM_Actor::New();
1425 // update actor properties
1426 updateActorProperties( actor, true );
1427 // add actor to the presentation
1428 vtkPrs->AddObject( actor );
1431 // presentation is being updated
1432 vtkActorCollection* actors = vtkPrs->GetObjects();
1434 actors->InitTraversal();
1435 vtkActor* a = actors->GetNextActor();
1437 GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a );
1439 // update actor properties
1440 updateActorProperties( actor, false );
1441 a = actors->GetNextActor();
1449 //=================================================================
1451 * GEOM_Displayer::BuildPrs
1452 * Build presentation accordint to the current viewer type
1454 //=================================================================
1455 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1457 if ( theObj->_is_nil() )
1460 myViewFrame = GetActiveView();
1461 if ( myViewFrame == 0 )
1464 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1469 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1470 myType = theObj->GetType();
1472 // Update presentation
1478 //=================================================================
1480 * GEOM_Displayer::BuildPrs
1481 * Build presentation accordint to the current viewer type
1483 //=================================================================
1484 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1486 myViewFrame = GetActiveView();
1487 if ( theShape.IsNull() || myViewFrame == 0 )
1490 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1495 setShape( theShape );
1503 //=================================================================
1505 * GEOM_Displayer::buildPresentation
1506 * Builds/finds object's presentation for the current viewer
1507 * Calls corresponding Update() method by means of double dispatch
1510 //=================================================================
1511 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1512 SALOME_View* theViewFrame )
1514 SALOME_Prs* prs = 0;
1517 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1521 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1524 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1525 theIO->setEntry( entry.toLatin1().constData() );
1526 if ( !theIO.IsNull() )
1528 // set interactive object
1530 // Find SOBject (because shape should be published previously)
1531 SUIT_Session* session = SUIT_Session::session();
1532 SUIT_Application* app = session->activeApplication();
1535 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1538 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1541 // get CORBA reference to data object
1542 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1543 if ( !CORBA::is_nil( object ) )
1545 // downcast to GEOM base object
1546 GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
1547 if ( !GeomBaseObject->_is_nil() )
1549 myType = GeomBaseObject->GetType();
1551 // downcast to GEOM object
1552 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
1553 if ( myType == GEOM_FIELD_STEP )
1555 // get the GEOM object from the field's shape
1556 GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
1557 if ( !GeomFieldStep->_is_nil() )
1559 GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
1560 if ( !GeomField->_is_nil() )
1561 GeomObject = GeomField->GetShape();
1564 // read the field step information
1565 readFieldStepInfo( GeomFieldStep );
1568 if ( !GeomObject->_is_nil() )
1570 // finally set shape
1571 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1579 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1585 //=================================================================
1587 * GEOM_Displayer::buildSubshapePresentation
1588 * Builds/finds object's presentation for the current viewer
1589 * Calls corresponding Update() method by means of double dispatch
1590 * For not published objects (for Mantis issue 0020435)
1592 //=================================================================
1593 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1594 const QString& entry,
1595 SALOME_View* theViewFrame)
1597 SALOME_Prs* prs = 0;
1600 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1604 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1607 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1608 theIO->setEntry(entry.toLatin1().constData());
1609 if (!theIO.IsNull())
1611 // set interactive object
1613 // finally set shape
1615 myType = GEOM_SUBSHAPE;
1617 UpdatePrs(prs); // Update presentation by using of the double dispatch
1623 //=================================================================
1625 * GEOM_Displayer::internalReset
1626 * Resets internal data
1629 //=================================================================
1630 void GEOM_Displayer::internalReset()
1635 myFieldDataType = GEOM::FDT_Double;
1636 myFieldDimension = 0;
1637 myFieldStepData.clear();
1638 myFieldStepName.Clear();
1639 myFieldStepRangeMin = 0;
1640 myFieldStepRangeMax = 0;
1643 //=================================================================
1645 * GEOM_Displayer::LocalSelection
1646 * Activate selection of CAD shapes with activisation of selection
1647 * of their sub-shapes (with opened local context for OCC viewer)
1649 //=================================================================
1650 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1652 SUIT_Session* session = SUIT_Session::session();
1653 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1657 LightApp_SelectionMgr* sm = app->selectionMgr();
1659 // remove all filters from selection
1662 SALOME_View* vf = GetActiveView();
1664 if (!theIO.IsNull() && !vf->isVisible(theIO))
1666 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1667 vf->LocalSelection( prs, theMode );
1668 delete prs; // delete presentation because displayer is its owner
1672 //=================================================================
1674 * GEOM_Displayer::globalSelection
1675 * Activate selection of CAD shapes without activisation of selection
1676 * of their sub-shapes (without opened local context for OCC viewer)
1678 //=================================================================
1679 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1681 TColStd_MapOfInteger aModes;
1682 aModes.Add( theMode );
1683 GlobalSelection( aModes, update );
1686 //=================================================================
1688 * GEOM_Displayer::globalSelection
1689 * Activate selection of CAD shapes without activisation of selection
1690 * of their sub-shapes (without opened local context for OCC viewer)
1692 //=================================================================
1693 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1694 const bool update, const QList<int>* theSubShapes )
1696 SUIT_Session* session = SUIT_Session::session();
1697 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1701 SALOME_View* vf = GetActiveView();
1705 // Close local context
1706 vf->GlobalSelection( update );
1708 // Set selection filters in accordance with current mode
1709 LightApp_SelectionMgr* sm = app->selectionMgr();
1713 // Remove from selection temporary objects if necessary
1714 if ( !theModes.Contains( GEOM_PREVIEW ) )
1715 clearTemporary( sm );
1717 //@ aSel->ClearIndex();
1721 // Remove filters from AIS_InteractiveContext
1722 Handle(AIS_InteractiveContext) ic;
1723 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1726 ic = viewer->getAISContext();
1728 ic->RemoveFilters();
1731 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1734 SUIT_SelectionFilter* aFilter;
1735 if ( theModes.Extent() == 1 )
1737 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1739 if ( aMode == GEOM_COMPOUNDFILTER )
1740 aFilter = getComplexFilter( theSubShapes );
1742 aFilter = getFilter( aMode );
1744 else if ( theModes.Extent() > 1 )
1746 TColStd_MapOfInteger aTopAbsModes;
1747 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1748 QList<SUIT_SelectionFilter*> aListOfFilters;
1749 for ( ; anIter.More(); anIter.Next() )
1751 SUIT_SelectionFilter* aFilter;
1752 int aMode = anIter.Key();
1753 if ( aMode == GEOM_COMPOUNDFILTER )
1754 aFilter = getComplexFilter( theSubShapes );
1756 aFilter = getFilter( aMode );
1759 aListOfFilters.append( aFilter );
1762 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1769 sm->installFilter( aFilter );
1772 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1773 ic->AddFilter( anOCCFilter );
1778 //=================================================================
1780 * GEOM_Displayer::LocalSelection
1781 * Activate selection of CAD shapes with activisation of selection
1782 * of their sub-shapes (with opened local context for OCC viewer)
1784 //=================================================================
1785 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1787 SALOME_ListIteratorOfListIO Iter( theIOList );
1788 for ( ; Iter.More(); Iter.Next() )
1789 LocalSelection( Iter.Value(), theMode );
1792 //=================================================================
1794 * GEOM_Displayer::BeforeDisplay
1795 * Called before displaying of pars. Close local context
1796 * [ Reimplemented from SALOME_Displayer ]
1798 //=================================================================
1799 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1801 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1804 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1807 if ( ic->HasOpenedContext() )
1808 ic->CloseAllContexts();
1813 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1815 UpdateColorScale(false,false);
1818 void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
1820 LightApp_Displayer::AfterErase( v, p );
1821 UpdateColorScale(false,false);
1824 //=================================================================
1826 * GEOM_Displayer::SetColor
1827 * Set color for shape displaying. If it is equal -1 then default color is used.
1828 * Available values are from Quantity_NameOfColor enumeration
1830 //=================================================================
1831 void GEOM_Displayer::SetColor( const int color )
1838 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1842 int GEOM_Displayer::GetColor() const
1847 bool GEOM_Displayer::HasColor() const
1849 return myColor != -1;
1852 void GEOM_Displayer::UnsetColor()
1856 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1857 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1858 myShadingColor = SalomeApp_Tools::color( col );
1861 //=================================================================
1863 * GEOM_Displayer::SetTexture
1864 * Set color for shape displaying. If it is equal -1 then default color is used.
1865 * Available values are from Quantity_NameOfColor enumeration
1867 //=================================================================
1868 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1870 if(texureFileName!="")
1872 myTexture = texureFileName;
1876 bool GEOM_Displayer::HasTexture() const
1878 return myTexture != "";
1881 std::string GEOM_Displayer::GetTexture() const
1886 //=================================================================
1888 * GEOM_Displayer::SetWidth
1889 * Set width of shape displaying. If it is equal -1 then default width is used.
1891 //=================================================================
1892 void GEOM_Displayer::SetWidth( const double width )
1897 double GEOM_Displayer::GetWidth() const
1902 bool GEOM_Displayer::HasWidth() const
1904 return myWidth != -1;
1907 void GEOM_Displayer::UnsetWidth()
1913 int GEOM_Displayer::GetIsosWidth() const
1918 void GEOM_Displayer::SetIsosWidth(const int width)
1920 myIsosWidth = width;
1923 bool GEOM_Displayer::HasIsosWidth() const
1925 return myIsosWidth != -1;
1929 //=================================================================
1931 * GEOM_Displayer::SetToActivate
1932 * This method is used for activisation/deactivisation of objects to be displayed
1934 //=================================================================
1935 void GEOM_Displayer::SetToActivate( const bool toActivate )
1937 myToActivate = toActivate;
1939 bool GEOM_Displayer::ToActivate() const
1941 return myToActivate;
1944 //=================================================================
1946 * GEOM_Displayer::clearTemporary
1947 * Removes from selection temporary objects
1949 //=================================================================
1950 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1952 SALOME_ListIO selected, toSelect;
1953 theSelMgr->selectedObjects( selected );
1955 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1956 Handle(SALOME_InteractiveObject) io = it.Value();
1957 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1958 toSelect.Append( it.Value() );
1961 theSelMgr->setSelectedObjects( toSelect, true );
1964 void GEOM_Displayer::SetName( const char* theName )
1969 void GEOM_Displayer::UnsetName()
1974 SalomeApp_Study* GEOM_Displayer::getStudy() const
1976 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
1979 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
1984 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
1989 void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
1990 const int theFieldDimension,
1991 const QList<QVariant>& theFieldStepData,
1992 const TCollection_AsciiString& theFieldStepName,
1993 const double theFieldStepRangeMin,
1994 const double theFieldStepRangeMax )
1996 myFieldDataType = theFieldDataType;
1997 myFieldDimension = theFieldDimension;
1998 myFieldStepData = theFieldStepData;
1999 myFieldStepName = theFieldStepName;
2000 myFieldStepRangeMin = theFieldStepRangeMin;
2001 myFieldStepRangeMax = theFieldStepRangeMax;
2004 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
2006 _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
2007 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects
2008 GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps
2009 GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component
2010 return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) &&
2011 (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type());
2014 int GEOM_Displayer::SetDisplayMode( const int theMode )
2016 int aPrevMode = myDisplayMode;
2017 if ( theMode != -1 ) {
2018 myDisplayMode = theMode;
2019 myHasDisplayMode = true;
2027 int GEOM_Displayer::GetDisplayMode() const
2029 return myDisplayMode;
2032 int GEOM_Displayer::UnsetDisplayMode()
2034 int aPrevMode = myDisplayMode;
2035 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2036 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
2037 myHasDisplayMode = false;
2041 bool GEOM_Displayer::HasDisplayMode() const
2043 return myHasDisplayMode;
2046 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
2048 static QList<QColor> colors;
2050 if ( colors.isEmpty() ) {
2052 for (int s = 0; s < 2 ; s++)
2054 for (int v = 100; v >= 40; v = v - 20)
2056 for (int h = 0; h < 359 ; h = h + 60)
2058 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
2064 static int currentColor = 0;
2066 SALOMEDS::Color color;
2067 color.R = (double)colors[currentColor].red() / 255.0;
2068 color.G = (double)colors[currentColor].green() / 255.0;
2069 color.B = (double)colors[currentColor].blue() / 255.0;
2071 currentColor = (currentColor+1) % colors.count();
2076 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
2079 int aTolerance = 64;
2080 int anIterations = 0;
2086 if( anIterations % aPeriod == 0 )
2089 if( aTolerance < 1 )
2092 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
2094 aHue = (int)( 360.0 * rand() / RAND_MAX );
2095 //std::cout << "Hue = " << aHue << std::endl;
2097 //std::cout << "Auto colors : ";
2099 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
2100 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
2101 for( ; it != itEnd; ++it )
2103 SALOMEDS::Color anAutoColor = *it;
2104 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
2107 aQColor.getHsv( &h, &s, &v );
2108 //std::cout << h << " ";
2109 if( abs( h - aHue ) < aTolerance )
2112 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
2116 //std::cout << std::endl;
2122 //std::cout << "Hue of the returned color = " << aHue << std::endl;
2124 aColor.setHsv( aHue, 255, 255 );
2126 SALOMEDS::Color aSColor;
2127 aSColor.R = (double)aColor.red() / 255.0;
2128 aSColor.G = (double)aColor.green() / 255.0;
2129 aSColor.B = (double)aColor.blue() / 255.0;
2134 PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
2135 const QString& entry,
2138 // get default properties for the explicitly specified default view type
2139 PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
2141 if ( study && view ) {
2142 SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
2143 SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
2144 int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
2146 if ( viewModel && viewId != -1 ) {
2147 // get properties from the study
2148 PropMap storedMap = study->getObjectPropMap( viewId, entry );
2149 // overwrite default properties from stored ones (that are specified)
2150 for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
2151 if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
2152 propMap.insert( GEOM::propertyName( (GEOM::Property)prop ),
2153 storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) );
2155 // ... specific processing for color
2156 // ... current implementation is to use same stored color for all aspects
2157 // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2158 if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2159 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2160 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2161 propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2162 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2163 propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2166 if ( !entry.isEmpty() ) {
2167 // get CORBA reference to geom object
2168 _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
2170 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
2171 if ( !CORBA::is_nil( object ) ) {
2172 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object );
2173 if ( !CORBA::is_nil( geomObject ) ) { // to check
2174 // check that geom object has color properly set
2175 bool hasColor = false;
2176 SALOMEDS::Color aSColor = getColor( geomObject, hasColor );
2177 // set color from geometry object (only once, if it is not yet set in GUI)
2178 // current implementation is to use same color for all aspects
2179 // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2180 if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2181 QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B );
2182 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor );
2183 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor );
2184 propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor );
2185 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor );
2186 propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor );
2188 // check that object has point marker properly set
2189 GEOM::marker_type mType = geomObject->GetMarkerType();
2190 GEOM::marker_size mSize = geomObject->GetMarkerSize();
2191 int mTextureId = geomObject->GetMarkerTexture();
2192 bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) ||
2193 ( mType == GEOM::MT_USER && mTextureId > 0 );
2194 // set point marker from geometry object (only once, if it is not yet set in GUI)
2195 if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) {
2196 if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) {
2198 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2199 QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) );
2201 else if ( mType == GEOM::MT_USER ) {
2203 propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) );
2215 PropMap GEOM_Displayer::getDefaultPropertyMap()
2219 // get resource manager
2220 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2222 // fill in the properties map with default values
2224 // - visibility (false by default)
2225 propMap.insert( GEOM::propertyName( GEOM::Visibility ), false );
2227 // - nb isos (take default value from preferences)
2228 propMap.insert( GEOM::propertyName( GEOM::NbIsos ),
2229 QString( "%1%2%3" ).
2230 arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ).
2231 arg( GEOM::subSectionSeparator() ).
2232 arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) );
2234 // - transparency (opacity = 1-transparency)
2235 propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 );
2237 // - display mode (take default value from preferences)
2238 propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
2239 resMgr->integerValue( "Geometry", "display_mode", 0 ) );
2241 // - show edges direction flag (false by default)
2242 propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false );
2244 // - shading color (take default value from preferences)
2245 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
2246 colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
2248 // - wireframe color (take default value from preferences)
2249 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ),
2250 colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) );
2252 // - standalone edges color (take default value from preferences)
2253 propMap.insert( GEOM::propertyName( GEOM::LineColor ),
2254 colorFromResources( "line_color", QColor( 255, 0, 0 ) ) );
2256 // - free boundaries color (take default value from preferences)
2257 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ),
2258 colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) );
2260 // - points color (take default value from preferences)
2261 propMap.insert( GEOM::propertyName( GEOM::PointColor ),
2262 colorFromResources( "point_color", QColor( 255, 255, 0 ) ) );
2264 // - isos color (take default value from preferences)
2265 propMap.insert( GEOM::propertyName( GEOM::IsosColor ),
2266 colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) );
2268 // - outlines color (take default value from preferences)
2269 propMap.insert( GEOM::propertyName( GEOM::OutlineColor ),
2270 colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) );
2272 // - deflection coefficient (take default value from preferences)
2273 propMap.insert( GEOM::propertyName( GEOM::Deflection ),
2274 resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) );
2276 // - material (take default value from preferences)
2277 Material_Model material;
2278 material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
2279 propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() );
2281 // - edge width (take default value from preferences)
2282 propMap.insert( GEOM::propertyName( GEOM::LineWidth ),
2283 resMgr->integerValue( "Geometry", "edge_width", 1 ) );
2285 // - isos width (take default value from preferences)
2286 propMap.insert( GEOM::propertyName( GEOM::IsosWidth ),
2287 resMgr->integerValue( "Geometry", "isolines_width", 1 ) );
2289 // - point marker (take default value from preferences)
2290 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2291 QString( "%1%2%3" ).
2292 arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ).
2293 arg( GEOM::subSectionSeparator() ).
2294 arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) );
2296 // - top-level flag (false by default)
2297 propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false );
2302 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2303 SALOMEDS::Color aSColor;
2306 SUIT_Session* session = SUIT_Session::session();
2307 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2309 if ( app && !theGeomObject->_is_nil()) {
2310 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2313 _PTR(Study) aStudy = study->studyDS();
2314 aSColor = theGeomObject->GetColor();
2315 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2317 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2318 bool general_autocolor = true;
2319 #else // auto-color for groups only
2320 bool general_autocolor = false;
2321 #endif // GENERAL_AUTOCOLOR
2322 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2323 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2324 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2325 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2326 aSColor = getPredefinedUniqueColor();
2328 #else // old algorithm for auto-colors
2329 QList<SALOMEDS::Color> aReservedColors;
2330 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2331 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2332 if ( aMainSObject ) {
2333 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2334 for ( ; it->More(); it->Next() ) {
2335 _PTR(SObject) aChildSObject( it->Value() );
2336 GEOM::GEOM_Object_var aChildObject =
2337 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2338 if ( CORBA::is_nil( aChildObject ) )
2341 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2342 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2343 aReservedColors.append( aReservedColor );
2346 aSColor = getUniqueColor( aReservedColors );
2348 #endif // SIMPLE_AUTOCOLOR
2358 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2359 const bool eraseOnlyChildren) {
2360 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2364 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2368 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2373 // Erase from all views
2374 QList<SALOME_View*> views;
2376 ViewManagerList vmans = app->viewManagers();
2377 SUIT_ViewManager* vman;
2378 foreach ( vman, vmans ) {
2379 SUIT_ViewModel* vmod = vman->getViewModel();
2380 view = dynamic_cast<SALOME_View*> ( vmod );
2382 views.append( view );
2385 if( views.count() == 0 )
2388 //Erase childrens w/o update views
2389 DataObjectList listObj = parent->children( true );
2390 SUIT_DataObject* obj;
2391 foreach( obj, listObj ) {
2392 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2394 foreach ( view, views ) {
2395 Handle(SALOME_InteractiveObject) anIO =
2396 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2397 Erase(anIO, false, false, view);
2401 //Erase parent with view update or repaint views
2402 foreach ( view, views ) {
2403 if(!eraseOnlyChildren)
2404 Erase(theIO, false, true, view);
2410 void GEOM_Displayer::readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep )
2412 if( theGeomFieldStep->_is_nil() )
2415 GEOM::GEOM_Field_var aGeomField = theGeomFieldStep->GetField();
2416 if( aGeomField->_is_nil() )
2419 GEOM::GEOM_Object_var aGeomFieldShape = aGeomField->GetShape();
2420 if( aGeomFieldShape->_is_nil() )
2423 TCollection_AsciiString aFieldStepName( theGeomFieldStep->GetName() );
2424 TCollection_AsciiString aFieldName( aGeomField->GetName() );
2425 TCollection_AsciiString aShapeName( aGeomFieldShape->GetName() );
2427 aFieldStepName = aShapeName + "\n" + aFieldName + "\n" + aFieldStepName;
2429 GEOM::field_data_type aFieldDataType = aGeomField->GetDataType();
2431 int aFieldDimension = aGeomField->GetDimension();
2433 GEOM::string_array_var aFieldComponents = aGeomField->GetComponents();
2434 int aFieldNbComponents = aFieldComponents->length();
2436 QList<QVariant> aFieldStepData;
2437 if( aFieldDataType == GEOM::FDT_Bool )
2439 GEOM::GEOM_BoolFieldStep_var aGeomBoolFieldStep = GEOM::GEOM_BoolFieldStep::_narrow( theGeomFieldStep );
2440 if ( !aGeomBoolFieldStep->_is_nil() )
2442 GEOM::short_array_var aValues = aGeomBoolFieldStep->GetValues();
2443 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2444 aFieldStepData << (bool)aValues[i];
2447 else if( aFieldDataType == GEOM::FDT_Int )
2449 GEOM::GEOM_IntFieldStep_var aGeomIntFieldStep = GEOM::GEOM_IntFieldStep::_narrow( theGeomFieldStep );
2450 if ( !aGeomIntFieldStep->_is_nil() )
2452 GEOM::ListOfLong_var aValues = aGeomIntFieldStep->GetValues();
2453 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2454 aFieldStepData << (qlonglong)aValues[i];
2457 else if( aFieldDataType == GEOM::FDT_Double )
2459 GEOM::GEOM_DoubleFieldStep_var aGeomDoubleFieldStep = GEOM::GEOM_DoubleFieldStep::_narrow( theGeomFieldStep );
2460 if ( !aGeomDoubleFieldStep->_is_nil() )
2462 GEOM::ListOfDouble_var aValues = aGeomDoubleFieldStep->GetValues();
2463 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2464 aFieldStepData << (double)aValues[i];
2467 else if( aFieldDataType == GEOM::FDT_String )
2469 GEOM::GEOM_StringFieldStep_var aGeomStringFieldStep = GEOM::GEOM_StringFieldStep::_narrow( theGeomFieldStep );
2470 if ( !aGeomStringFieldStep->_is_nil() )
2472 GEOM::string_array_var aValues = aGeomStringFieldStep->GetValues();
2473 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2474 aFieldStepData << QString( aValues[i] );
2478 double aFieldStepRangeMin = 0, aFieldStepRangeMax = 0;
2479 aFieldStepData = groupFieldData( aFieldStepData,
2481 aFieldDataType == GEOM::FDT_String,
2483 aFieldStepRangeMax );
2485 setFieldStepInfo( aFieldDataType,
2490 aFieldStepRangeMax );
2493 QList<QVariant> GEOM_Displayer::groupFieldData( const QList<QVariant>& theFieldStepData,
2494 const int theFieldNbComponents,
2495 const bool theIsString,
2496 double& theFieldStepRangeMin,
2497 double& theFieldStepRangeMax )
2499 QList<QVariant> aResultList;
2500 theFieldStepRangeMin = 0;
2501 theFieldStepRangeMax = 0;
2503 if( theFieldStepData.isEmpty() || theFieldNbComponents < 1 )
2506 int aNbSubShapes = theFieldStepData.count() / theFieldNbComponents;
2508 QList<QVariant> aGroupedList;
2510 bool anIsBoolean = false;
2511 for( int aSubShape = 0; aSubShape < aNbSubShapes; aSubShape++ )
2514 QStringList aStringList;
2516 int aBaseIndex = aSubShape * theFieldNbComponents;
2517 for( int aComponent = 0; aComponent < theFieldNbComponents; aComponent++ )
2519 int anIndex = aComponent + aBaseIndex;
2521 const QVariant& aVariant = theFieldStepData[ anIndex ];
2524 if( aVariant.type() == QVariant::String )
2525 aStringList << aVariant.toString();
2530 if( aVariant.type() == QVariant::Bool )
2532 aValue = aVariant.toBool() ? 1.0 : 0.0;
2538 if( aVariant.type() == QVariant::Int )
2539 aValue = double( aVariant.toInt() );
2540 else if( aVariant.type() == QVariant::Double )
2541 aValue = aVariant.toDouble();
2542 aNorm += aValue * aValue;
2548 aGroupedList << aStringList.join( "\n" );
2552 aNorm /= theFieldNbComponents;
2554 aNorm = pow( aNorm, 0.5 );
2556 if( aGroupedList.isEmpty() )
2557 theFieldStepRangeMin = theFieldStepRangeMax = aNorm;
2560 theFieldStepRangeMin = Min( theFieldStepRangeMin, aNorm );
2561 theFieldStepRangeMax = Max( theFieldStepRangeMax, aNorm );
2564 aGroupedList << aNorm;
2570 theFieldStepRangeMin = 0.0;
2571 theFieldStepRangeMax = 1.0;
2574 SUIT_Session* session = SUIT_Session::session();
2575 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2576 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2578 QListIterator<QVariant> anIter( aGroupedList );
2579 while( anIter.hasNext() )
2581 const QVariant& aVariant = anIter.next();
2583 aResultList << aVariant;
2587 Quantity_Color aColor;
2588 if( FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
2589 aQColor = QColor::fromRgbF( aColor.Red(), aColor.Green(), aColor.Blue() );
2590 aResultList << aQColor;
2596 // Note: the method is copied from Aspect_ColorScale class
2597 Standard_Integer GEOM_Displayer::HueFromValue( const Standard_Integer aValue,
2598 const Standard_Integer aMin,
2599 const Standard_Integer aMax )
2601 Standard_Integer minLimit( 0 ), maxLimit( 230 );
2603 Standard_Integer aHue = maxLimit;
2605 aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( aValue - aMin ) / ( aMax - aMin ) );
2607 aHue = Min( Max( minLimit, aHue ), maxLimit );
2612 // Note: the method is copied from Aspect_ColorScale class
2613 Standard_Boolean GEOM_Displayer::FindColor( const Standard_Real aValue,
2614 const Standard_Real aMin,
2615 const Standard_Real aMax,
2616 const Standard_Integer ColorsCount,
2617 Quantity_Color& aColor )
2619 if( aValue<aMin || aValue>aMax || aMax<aMin )
2620 return Standard_False;
2624 Standard_Real IntervNumber = 0;
2627 else if( aValue>aMax )
2628 IntervNumber = ColorsCount-1;
2629 else if( Abs( aMax-aMin ) > Precision::Approximation() )
2630 IntervNumber = Floor( Standard_Real( ColorsCount ) * ( aValue - aMin ) / ( aMax - aMin ) ); // 'Ceiling' replaced with 'Floor'
2632 Standard_Integer Interv = Standard_Integer( IntervNumber );
2634 aColor = Quantity_Color( HueFromValue( Interv, 0, ColorsCount - 1 ), 1.0, 1.0, Quantity_TOC_HLS );
2636 return Standard_True;
2640 void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, const bool updateViewer )
2642 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
2646 SOCC_Viewer* aViewModel = dynamic_cast<SOCC_Viewer*>( GetActiveView() );
2650 Handle(V3d_Viewer) aViewer = aViewModel->getViewer3d();
2651 if( aViewer.IsNull() )
2654 aViewer->InitActiveViews();
2655 if( !aViewer->MoreActiveViews() )
2658 Handle(V3d_View) aView = aViewer->ActiveView();
2659 if( aView.IsNull() )
2662 Standard_Boolean anIsDisplayColorScale = Standard_False;
2663 TCollection_AsciiString aColorScaleTitle;
2664 Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
2665 Standard_Boolean anIsBoolean = Standard_False;
2667 SALOME_ListIO aSelectedObjects;
2668 myApp->selectionMgr()->selectedObjects( aSelectedObjects );
2669 if( aSelectedObjects.Extent() == 1 )
2671 Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
2672 if( !anIO.IsNull() )
2674 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
2677 AIS_ListOfInteractive aList;
2678 aPrs->GetObjects( aList );
2679 AIS_ListIteratorOfListOfInteractive anIter( aList );
2680 for( ; anIter.More(); anIter.Next() )
2682 Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
2683 if( !aShape.IsNull() )
2685 GEOM::field_data_type aFieldDataType;
2686 int aFieldDimension;
2687 QList<QVariant> aFieldStepData;
2688 TCollection_AsciiString aFieldStepName;
2689 double aFieldStepRangeMin, aFieldStepRangeMax;
2690 aShape->getFieldStepInfo( aFieldDataType,
2695 aFieldStepRangeMax );
2696 if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
2698 anIsDisplayColorScale = Standard_True;
2699 aColorScaleTitle = aFieldStepName;
2700 aColorScaleMin = aFieldStepRangeMin;
2701 aColorScaleMax = aFieldStepRangeMax;
2702 anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
2710 if( anIsDisplayColorScale )
2712 Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
2713 if( !aColorScale.IsNull() )
2715 SUIT_Session* session = SUIT_Session::session();
2716 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2718 Standard_Real anXPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
2719 Standard_Real anYPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
2720 Standard_Real aWidth = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
2721 Standard_Real aHeight = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
2722 Standard_Integer aTextHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
2723 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2725 aColorScale->SetXPosition( anXPos );
2726 aColorScale->SetYPosition( anYPos );
2727 aColorScale->SetWidth( aWidth );
2728 aColorScale->SetHeight( aHeight );
2730 aColorScale->SetTextHeight( aTextHeight );
2731 aColorScale->SetNumberOfIntervals( anIsBoolean ? 2 : aNbIntervals );
2733 aColorScale->SetTitle( aColorScaleTitle );
2734 aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
2736 if( !aView->ColorScaleIsDisplayed() )
2737 aView->ColorScaleDisplay();
2741 if( aView->ColorScaleIsDisplayed() )
2742 aView->ColorScaleErase();
2745 if( theIsRedisplayFieldSteps )
2747 _PTR(Study) aStudyDS = aStudy->studyDS();
2748 QList<SUIT_ViewManager*> vmList;
2749 myApp->viewManagers( vmList );
2750 for( QList<SUIT_ViewManager*>::Iterator vmIt = vmList.begin(); vmIt != vmList.end(); vmIt++ )
2752 if( SUIT_ViewManager* aViewManager = *vmIt )
2754 const ObjMap anObjects = aStudy->getObjectMap( aViewManager->getGlobalId() );
2755 for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ )
2757 _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) );
2760 CORBA::Object_var anObject = GeometryGUI::ClientSObjectToObject( aSObj );
2761 if( !CORBA::is_nil( anObject ) )
2763 GEOM::GEOM_FieldStep_var aFieldStep = GEOM::GEOM_FieldStep::_narrow( anObject );
2764 if( !aFieldStep->_is_nil() )
2766 CORBA::String_var aStepEntry = aFieldStep->GetStudyEntry();
2767 Handle(SALOME_InteractiveObject) aStepIO =
2768 new SALOME_InteractiveObject( aStepEntry.in(), "GEOM", "TEMP_IO" );
2769 Redisplay( aStepIO, false, false );