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.
358 myTransparency = -1.0;
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 if( HasTransparency() ) {
706 AISShape->SetTransparency( GetTransparency() );
708 AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
711 // set iso properties
712 int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt();
713 int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt();
714 Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>() );
715 int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt();
716 Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect();
717 Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect();
718 uIsoAspect->SetColor( isosColor );
719 uIsoAspect->SetWidth( isosWidth );
720 uIsoAspect->SetNumber( uIsos );
721 vIsoAspect->SetColor( isosColor );
722 vIsoAspect->SetWidth( isosWidth );
723 vIsoAspect->SetNumber( vIsos );
724 AISShape->Attributes()->SetUIsoAspect( uIsoAspect );
725 AISShape->Attributes()->SetVIsoAspect( vIsoAspect );
727 // set deflection coefficient
728 // ... to avoid to small values of the coefficient, its lower value is limited
729 AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) );
732 bool textureAdded = false;
733 if ( HasTexture() ) {
734 // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function
735 AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) );
736 if ( ! entry.isEmpty() ) {
737 // check that study is active
738 SalomeApp_Study* study = getActiveStudy();
740 // Store the texture in object properties for next displays
741 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::Texture ), QString( GetTexture().c_str() ) );
742 study->setObjectProperty( aMgrId, entry, GEOM::propertyName( GEOM::DisplayMode ), 3 );
744 // Update porpeties map
745 propMap = getObjectProperties( study, entry, myViewFrame );
751 // Texture from properties
752 QString aTexture = propMap.value( GEOM::propertyName( GEOM::Texture ) ).toString();
753 if ( !aTexture.isEmpty() ) {
754 AISShape->SetTextureFileName( TCollection_AsciiString( aTexture.toUtf8().constData() ) );
760 AISShape->SetTextureMapOn();
761 AISShape->DisableTextureModulate();
765 AISShape->SetWidth( HasWidth() ?
766 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
768 // libe width from properties
769 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
771 // set top-level flag
772 AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() );
774 // set point marker (for vertex / compound of vertices only)
776 QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() );
777 if ( aList.size() == 2 ) {
778 // standard marker string contains "TypeOfMarker:ScaleOfMarker"
779 int aTypeOfMarker = aList[0].toInt();
780 double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5;
781 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
782 anAspect->SetScale( aScaleOfMarker );
783 anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) );
784 anAspect->SetColor( HasColor() ?
785 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
786 (Quantity_NameOfColor)GetColor() :
787 // color from properties
788 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ) );
789 AISShape->Attributes()->SetPointAspect( anAspect );
791 else if ( aList.size() == 1 ) {
792 // custom marker string contains "IdOfTexture"
793 int textureId = aList[0].toInt();
794 Standard_Integer aWidth, aHeight;
795 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
796 Handle(TColStd_HArray1OfByte) aTexture =
798 Handle(Graphic3d_HArray1OfBytes) aTexture =
800 GeometryGUI::getTexture( study, textureId, aWidth, aHeight );
801 if ( !aTexture.IsNull() ) {
802 #if OCC_VERSION_LARGE > 0x06060000 // Porting to OCCT higher 6.6.0 version
803 Handle(Prs3d_PointAspect) aTextureAspect =
804 new Prs3d_PointAspect( HasColor() ?
805 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
806 (Quantity_NameOfColor)GetColor() :
807 // color from properties
808 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
813 Handle(Prs3d_PointAspect) aTextureAspect =
814 new Prs3d_PointAspect( HasColor() ?
815 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
816 (Quantity_NameOfColor)GetColor() :
817 // color from properties
818 SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
823 AISShape->Attributes()->SetPointAspect( aTextureAspect );
828 // set field step data
829 AISShape->setFieldStepInfo( myFieldDataType,
834 myFieldStepRangeMax );
836 if ( create && !isTemporary && aMgrId != -1 ) {
837 // set properties to the study
838 study->setObjectPropMap( aMgrId, entry, propMap );
841 // AISShape->SetName(???); ??? necessary to set name ???
844 void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
846 // check that actor is not null
847 if ( !actor ) return;
849 // check that study is active
850 SalomeApp_Study* study = getStudy();
851 if ( !study ) return;
853 // set interactive object
855 Handle( SALOME_InteractiveObject ) anIO;
857 if ( !myIO.IsNull() ) {
858 actor->setIO( myIO );
861 else if ( !myName.empty() ) {
862 // workaround to allow selection of temporary objects
863 static int tempId = 0;
864 anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() );
865 actor->setIO( anIO );
868 // presentation study entry (empty for temporary objects like preview)
869 QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString();
870 // flag: temporary object
871 bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" );
872 // currently active view window's ID (-1 if no active view)
873 int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1;
875 // get presentation properties
876 PropMap propMap = getObjectProperties( study, entry, myViewFrame );
879 /////////////////////////////////////////////////////////////////////////
880 // VSR: for VTK viewer currently deflection coefficient is hardcoded
881 // due to performance problem
882 // actor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR);
883 /////////////////////////////////////////////////////////////////////////
884 if ( !actor->getTopo().IsSame( myShape ) )
885 actor->SetShape( myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR );
888 Material_Model material;
889 material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() );
890 std::vector<vtkProperty*> mprops;
891 mprops.push_back( material.getMaterialVTKProperty( true ) );
892 mprops.push_back( material.getMaterialVTKProperty( false) );
893 actor->SetMaterial( mprops );
895 // set iso-lines properties
897 // - set number of iso-lines
898 int nbIsos[2]= { 1, 1 };
899 QStringList isos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() );
900 nbIsos[0] = isos[0].toInt();
901 nbIsos[1] = isos[1].toInt();
902 actor->SetNbIsos( nbIsos );
904 // - set iso-lines width
905 actor->SetIsosWidth( propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt() );
907 // - set iso-lines color
908 c = propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value<QColor>();
909 actor->SetIsosColor( c.redF(), c.greenF(), c.blueF() );
914 // - same color for all sub-actors
915 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
916 actor->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
919 // shading color (for non-physical materials)
920 if ( !material.isPhysical() ) {
921 c = propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value<QColor>();
922 actor->GetFrontMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
923 actor->GetBackMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() );
926 // - standalone edge color
927 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
928 actor->SetIsolatedEdgeColor( c.redF(), c.greenF(), c.blueF() );
930 c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value<QColor>();
931 // - shared edges color ???
932 actor->SetSharedEdgeColor( c.redF(), c.greenF(), c.blueF() );
934 c = propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value<QColor>();
935 // - free edges color ???
936 actor->SetFreeEdgeColor( c.redF(), c.greenF(), c.blueF() );
939 c = propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>();
940 actor->SetPointColor( c.redF(), c.greenF(), c.blueF() );
943 // - color for edges in shading+edges mode
944 c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>();
945 actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() );
948 if( HasTransparency() ) {
949 actor->SetOpacity( 1.0 - GetTransparency() );
951 actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() );
955 actor->SetWidth( HasWidth() ?
956 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
958 // libe width from properties
959 propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() );
961 // set display vectors flag
962 actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() );
965 int displayMode = HasDisplayMode() ?
966 // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function
968 // display mode from properties
969 propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt();
971 // specific processing of 'shading with edges' mode, as VTK provides only the following standard display modes:
972 // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
973 // GEOM actor allows alternative display modes (see VTKViewer::Representation enum) and enum in GEOM_Actor:
974 // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
976 if ( displayMode == 2 )
977 // this is 'Shading with edges' mode => we have to do the correct mapping to EDisplayMode
978 // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
980 actor->setDisplayMode( displayMode );
985 actor->PickableOff();
987 if ( create && !isTemporary && aMgrId != -1 ) {
988 // set properties to the study
989 study->setObjectPropMap( aMgrId, entry, propMap );
993 //=================================================================
995 * GEOM_Displayer::updateDimensions
996 * Creates or renews dimension presentation for the IO.
998 //=================================================================
999 void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& theIO,
1000 SALOME_OCCPrs* thePrs,
1001 const gp_Ax3& theShapeLCS )
1003 SalomeApp_Study* aStudy = getStudy();
1009 if ( theIO.IsNull() )
1014 SOCC_Prs* anOccPrs = dynamic_cast<SOCC_Prs*>( thePrs );
1016 AIS_ListOfInteractive aListOfIO;
1018 anOccPrs->GetObjects( aListOfIO );
1020 AIS_ListIteratorOfListOfInteractive aIterateIO( aListOfIO );
1022 // remove outdated presentations of dimensions
1023 for ( ; aIterateIO.More(); aIterateIO.Next() )
1025 const Handle(AIS_InteractiveObject)& anIO = aIterateIO.Value();
1026 if ( !anIO->IsKind( STANDARD_TYPE( AIS_Dimension ) ) )
1031 aListOfIO.Remove( aIterateIO );
1033 if ( !aIterateIO.More() )
1039 // prepare dimension styling
1040 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1042 QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
1043 int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
1044 double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
1045 double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
1046 bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
1047 QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
1048 QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
1050 // restore dimension presentation from saved attribute or property data
1051 AIS_ListOfInteractive aRestoredDimensions;
1053 QVariant aProperty = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
1055 GEOM::propertyName( GEOM::Dimensions ),
1058 GEOMGUI_DimensionProperty aRecords;
1060 if ( aProperty.isValid() && aProperty.canConvert<GEOMGUI_DimensionProperty>() )
1062 aRecords = aProperty.value<GEOMGUI_DimensionProperty>();
1066 aRecords.LoadFromAttribute( getStudy(), theIO->getEntry() );
1069 // create up-to-date dimension presentations
1070 for ( int aPrsIt = 0; aPrsIt < aRecords.GetNumber(); ++aPrsIt )
1072 if ( !aRecords.IsVisible( aPrsIt ) )
1077 // init dimension by type
1078 Handle(AIS_Dimension) aPrs;
1079 switch( aRecords.GetType( aPrsIt ) )
1081 case GEOMGUI_DimensionProperty::DimensionType_Length :
1083 Handle(GEOM_AISLength) aLength = new GEOM_AISLength( aPrsIt );
1084 aRecords.GetRecord( aPrsIt )->AsLength()->Update( aLength, theShapeLCS );
1089 case GEOMGUI_DimensionProperty::DimensionType_Diameter :
1091 Handle(GEOM_AISDiameter) aDiam = new GEOM_AISDiameter( aPrsIt );
1092 aRecords.GetRecord( aPrsIt )->AsDiameter()->Update( aDiam, theShapeLCS );
1097 case GEOMGUI_DimensionProperty::DimensionType_Angle :
1099 Handle(GEOM_AISAngle) anAng = new GEOM_AISAngle( aPrsIt );
1100 aRecords.GetRecord( aPrsIt )->AsAngle()->Update( anAng, theShapeLCS );
1106 aPrs->SetOwner( theIO );
1108 Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
1110 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
1112 aStyle->SetCommonColor( aColor );
1113 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1114 aStyle->MakeText3d( Standard_True );
1115 aStyle->MakeTextShaded( Standard_True );
1116 aStyle->SetExtensionSize( aFontHeight * 0.5 );
1117 aStyle->TextAspect()->SetHeight( aFontHeight );
1118 aStyle->ArrowAspect()->SetLength( anArrowLength );
1119 aStyle->LineAspect()->SetWidth( aLineWidth );
1120 aStyle->SetTextHorizontalPosition( aPrs->DimensionAspect()->TextHorizontalPosition() );
1121 aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() );
1122 aStyle->SetArrowOrientation( aPrs->DimensionAspect()->ArrowOrientation() );
1123 aPrs->SetDimensionAspect( aStyle );
1124 aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
1125 aPrs->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
1126 aPrs->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
1128 if ( aPrs->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
1130 // show degree symbol for dimension instead of label "deg"
1131 if ( aUnitsAngle == "deg" )
1133 aPrs->SetSpecialSymbol(0xB0);
1134 aPrs->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
1135 aStyle->MakeUnitsDisplayed(Standard_False);
1139 aPrs->SetDisplaySpecialSymbol(AIS_DSS_No);
1140 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1145 aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
1148 aListOfIO.Append( aPrs );
1151 // update presentation
1154 for ( aIterateIO.Initialize( aListOfIO ); aIterateIO.More(); aIterateIO.Next() )
1156 anOccPrs->AddObject( aIterateIO.Value() );
1160 //=================================================================
1162 * GEOM_Displayer::Erase
1163 * Calls Erase() method for each object in the given list
1165 //=================================================================
1166 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
1168 const bool updateViewer )
1170 SALOME_ListIteratorOfListIO Iter( theIOList );
1171 for ( ; Iter.More(); Iter.Next() )
1172 Erase( Iter.Value(), forced, false );
1178 //=================================================================
1180 * GEOM_Displayer::Redisplay
1181 * Calls Redisplay() method for each object in the given list
1183 //=================================================================
1184 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1185 const bool updateViewer,
1186 const bool checkActiveViewer )
1188 SALOME_ListIteratorOfListIO Iter( theIOList );
1189 for ( ; Iter.More(); Iter.Next() )
1190 Redisplay( Iter.Value(), false, checkActiveViewer );
1196 //=================================================================
1198 * GEOM_Displayer::Redisplay
1199 * Calls Redisplay() method for each object in the given list
1201 //=================================================================
1202 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList,
1203 const bool theUpdateViewer,
1204 SALOME_View* theViewFrame )
1206 SALOME_ListIteratorOfListIO anIter( theIOList );
1207 for ( ; anIter.More(); anIter.Next() )
1209 Redisplay( anIter.Value(), false, theViewFrame );
1212 if ( theUpdateViewer )
1218 //=================================================================
1220 * GEOM_Displayer::Update
1221 * Update OCC presentaion
1222 * [ Reimplemented from SALOME_Displayer ]
1224 //=================================================================
1225 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
1227 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
1228 SalomeApp_Study* study = getStudy();
1230 if ( !occPrs || myShape.IsNull() || !study )
1233 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1236 // specific processing for local coordinate system presentation
1239 TopoDS_Face aFace = TopoDS::Face( myShape );
1240 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1241 if ( !aPlane.IsNull() )
1243 gp_Ax3 aPos = aPlane->Pln().Position();
1244 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1246 Handle(GEOM_AISTrihedron) aTrh;
1248 if ( occPrs->IsNull() )
1250 // new presentation is being created
1251 aTrh = new GEOM_AISTrihedron( aPlc );
1252 occPrs->AddObject( aTrh );
1256 // presentation is being updated
1257 AIS_ListOfInteractive aList;
1258 occPrs->GetObjects( aList );
1259 AIS_ListIteratorOfListOfInteractive anIter( aList );
1260 for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) {
1261 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
1265 if ( !aTrh.IsNull() ) {
1266 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1268 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
1269 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1271 aTrh->SetWidth( GetWidth() );
1273 if ( !myIO.IsNull() )
1275 aTrh->setIO( myIO );
1276 aTrh->SetOwner( myIO );
1278 aTrh->SetComponent( aPlc );
1279 aTrh->SetToUpdate();
1281 occPrs->SetToActivate( ToActivate() );
1287 // processing for usual geometry presentation
1290 // if presentation is empty we try to create new one
1291 if ( occPrs->IsNull() )
1293 // create presentation (specific for vectors)
1294 Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" )
1295 : new GEOM_AISShape ( myShape, "" );
1297 if( myType == GEOM_FIELD_STEP )
1298 AISShape->SetHilightMode( GEOM_AISShape::CustomHighlight );
1299 // update shape properties
1300 updateShapeProperties( AISShape, true );
1302 // add shape to the presentation
1303 occPrs->AddObject( AISShape );
1305 // In accordance with ToActivate() value object will be activated/deactivated
1306 // when it will be displayed
1307 occPrs->SetToActivate( ToActivate() );
1309 if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) {
1310 // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation):
1312 // create additional wireframe shape
1313 Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape);
1314 aWirePrs->SetWidth(AISShape->Width());
1315 if ( !myIO.IsNull() ) {
1316 aWirePrs->setIO( myIO );
1317 aWirePrs->SetOwner( myIO );
1320 // add shape to the presentation
1321 occPrs->AddObject( aWirePrs );
1324 // if presentation is found -> set again shape for it
1327 AIS_ListOfInteractive IOList;
1328 occPrs->GetObjects( IOList );
1329 AIS_ListIteratorOfListOfInteractive Iter( IOList );
1330 for ( ; Iter.More(); Iter.Next() )
1332 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
1333 if ( AISShape.IsNull() )
1336 // re-set shape (it might be changed)
1337 if ( AISShape->Shape() != myShape )
1338 AISShape->Set( myShape );
1340 // update shape properties
1341 updateShapeProperties( AISShape, false );
1344 AISShape->UpdateSelection();
1345 AISShape->SetToUpdate();
1349 updateDimensions( myIO, occPrs, gp_Ax3().Transformed( myShape.Location().Transformation() ) );
1353 //=================================================================
1355 * GEOM_Displayer::Update
1356 * Update VTK presentaion
1357 * [ Reimplemented from SALOME_Displayer ]
1359 //=================================================================
1360 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
1362 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1363 SalomeApp_Study* study = getStudy();
1365 if ( !vtkPrs || myShape.IsNull() || !study )
1368 if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
1371 // specific processing for local coordinate system presentation
1374 TopoDS_Face aFace = TopoDS::Face( myShape );
1375 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
1376 if ( !aPlane.IsNull() ) {
1377 gp_Ax3 aPos = aPlane->Pln().Position();
1378 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
1380 GEOM_VTKTrihedron* aTrh = 0;
1382 if ( vtkPrs->IsNull() ) {
1383 // new presentation is being created
1384 aTrh = GEOM_VTKTrihedron::New();
1385 vtkPrs->AddObject( aTrh );
1388 // presentation is being updated
1389 vtkActorCollection* actors = vtkPrs->GetObjects();
1391 actors->InitTraversal();
1392 vtkActor* a = actors->GetNextActor();
1393 while ( a && !aTrh ) {
1394 aTrh = GEOM_VTKTrihedron::SafeDownCast( a );
1395 a = actors->GetNextActor();
1401 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
1403 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
1404 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
1406 #ifdef VTK_TRIHEDRON_WIDTH
1408 // VSR: currently isn't supported
1410 // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function
1412 aTrh->SetWidth( GetWidth() );
1415 if ( !myIO.IsNull() )
1416 aTrh->setIO( myIO );
1418 aTrh->SetPlacement( aPlc );
1425 // processing for usual geometry presentation
1428 // if presentation is empty we try to create new one
1429 if ( vtkPrs->IsNull() )
1432 GEOM_Actor* actor = GEOM_Actor::New();
1433 // update actor properties
1434 updateActorProperties( actor, true );
1435 // add actor to the presentation
1436 vtkPrs->AddObject( actor );
1439 // presentation is being updated
1440 vtkActorCollection* actors = vtkPrs->GetObjects();
1442 actors->InitTraversal();
1443 vtkActor* a = actors->GetNextActor();
1445 GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a );
1447 // update actor properties
1448 updateActorProperties( actor, false );
1449 a = actors->GetNextActor();
1457 //=================================================================
1459 * GEOM_Displayer::BuildPrs
1460 * Build presentation accordint to the current viewer type
1462 //=================================================================
1463 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
1465 if ( theObj->_is_nil() )
1468 myViewFrame = GetActiveView();
1469 if ( myViewFrame == 0 )
1472 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1477 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
1478 myType = theObj->GetType();
1480 // Update presentation
1486 //=================================================================
1488 * GEOM_Displayer::BuildPrs
1489 * Build presentation accordint to the current viewer type
1491 //=================================================================
1492 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
1494 myViewFrame = GetActiveView();
1495 if ( theShape.IsNull() || myViewFrame == 0 )
1498 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
1503 setShape( theShape );
1511 //=================================================================
1513 * GEOM_Displayer::buildPresentation
1514 * Builds/finds object's presentation for the current viewer
1515 * Calls corresponding Update() method by means of double dispatch
1518 //=================================================================
1519 SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
1520 SALOME_View* theViewFrame )
1522 SALOME_Prs* prs = 0;
1525 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1529 prs = LightApp_Displayer::buildPresentation( entry, theViewFrame );
1532 Handle( SALOME_InteractiveObject ) theIO = new SALOME_InteractiveObject();
1533 theIO->setEntry( entry.toLatin1().constData() );
1534 if ( !theIO.IsNull() )
1536 // set interactive object
1538 // Find SOBject (because shape should be published previously)
1539 SUIT_Session* session = SUIT_Session::session();
1540 SUIT_Application* app = session->activeApplication();
1543 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1546 _PTR(SObject) SO ( study->studyDS()->FindObjectID( theIO->getEntry() ) );
1549 // get CORBA reference to data object
1550 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
1551 if ( !CORBA::is_nil( object ) )
1553 // downcast to GEOM base object
1554 GEOM::GEOM_BaseObject_var GeomBaseObject = GEOM::GEOM_BaseObject::_narrow( object );
1555 if ( !GeomBaseObject->_is_nil() )
1557 myType = GeomBaseObject->GetType();
1559 // downcast to GEOM object
1560 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( GeomBaseObject );
1561 if ( myType == GEOM_FIELD_STEP )
1563 // get the GEOM object from the field's shape
1564 GEOM::GEOM_FieldStep_var GeomFieldStep = GEOM::GEOM_FieldStep::_narrow( GeomBaseObject );
1565 if ( !GeomFieldStep->_is_nil() )
1567 GEOM::GEOM_Field_var GeomField = GeomFieldStep->GetField();
1568 if ( !GeomField->_is_nil() )
1569 GeomObject = GeomField->GetShape();
1572 // read the field step information
1573 readFieldStepInfo( GeomFieldStep );
1576 if ( !GeomObject->_is_nil() )
1578 // finally set shape
1579 setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
1587 UpdatePrs( prs ); // Update presentation by using of the double dispatch
1593 //=================================================================
1595 * GEOM_Displayer::buildSubshapePresentation
1596 * Builds/finds object's presentation for the current viewer
1597 * Calls corresponding Update() method by means of double dispatch
1598 * For not published objects (for Mantis issue 0020435)
1600 //=================================================================
1601 SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape,
1602 const QString& entry,
1603 SALOME_View* theViewFrame)
1605 SALOME_Prs* prs = 0;
1608 myViewFrame = theViewFrame ? theViewFrame : GetActiveView();
1612 prs = LightApp_Displayer::buildPresentation(entry, theViewFrame);
1615 Handle(SALOME_InteractiveObject) theIO = new SALOME_InteractiveObject();
1616 theIO->setEntry(entry.toLatin1().constData());
1617 if (!theIO.IsNull())
1619 // set interactive object
1621 // finally set shape
1623 myType = GEOM_SUBSHAPE;
1625 UpdatePrs(prs); // Update presentation by using of the double dispatch
1631 //=================================================================
1633 * GEOM_Displayer::internalReset
1634 * Resets internal data
1637 //=================================================================
1638 void GEOM_Displayer::internalReset()
1643 myFieldDataType = GEOM::FDT_Double;
1644 myFieldDimension = 0;
1645 myFieldStepData.clear();
1646 myFieldStepName.Clear();
1647 myFieldStepRangeMin = 0;
1648 myFieldStepRangeMax = 0;
1651 //=================================================================
1653 * GEOM_Displayer::LocalSelection
1654 * Activate selection of CAD shapes with activisation of selection
1655 * of their sub-shapes (with opened local context for OCC viewer)
1657 //=================================================================
1658 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
1660 SUIT_Session* session = SUIT_Session::session();
1661 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1665 LightApp_SelectionMgr* sm = app->selectionMgr();
1667 // remove all filters from selection
1670 SALOME_View* vf = GetActiveView();
1672 if (!theIO.IsNull() && !vf->isVisible(theIO))
1674 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
1675 vf->LocalSelection( prs, theMode );
1676 delete prs; // delete presentation because displayer is its owner
1680 //=================================================================
1682 * GEOM_Displayer::globalSelection
1683 * Activate selection of CAD shapes without activisation of selection
1684 * of their sub-shapes (without opened local context for OCC viewer)
1686 //=================================================================
1687 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
1689 TColStd_MapOfInteger aModes;
1690 aModes.Add( theMode );
1691 GlobalSelection( aModes, update );
1694 //=================================================================
1696 * GEOM_Displayer::globalSelection
1697 * Activate selection of CAD shapes without activisation of selection
1698 * of their sub-shapes (without opened local context for OCC viewer)
1700 //=================================================================
1701 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
1702 const bool update, const QList<int>* theSubShapes )
1704 SUIT_Session* session = SUIT_Session::session();
1705 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1709 SALOME_View* vf = GetActiveView();
1713 // Close local context
1714 vf->GlobalSelection( update );
1716 // Set selection filters in accordance with current mode
1717 LightApp_SelectionMgr* sm = app->selectionMgr();
1721 // Remove from selection temporary objects if necessary
1722 if ( !theModes.Contains( GEOM_PREVIEW ) )
1723 clearTemporary( sm );
1725 //@ aSel->ClearIndex();
1729 // Remove filters from AIS_InteractiveContext
1730 Handle(AIS_InteractiveContext) ic;
1731 SOCC_Viewer* viewer = dynamic_cast<SOCC_Viewer*>( vf );
1734 ic = viewer->getAISContext();
1736 ic->RemoveFilters();
1739 if ( theModes.Contains( GEOM_ALLOBJECTS ) )
1742 SUIT_SelectionFilter* aFilter;
1743 if ( theModes.Extent() == 1 )
1745 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
1747 if ( aMode == GEOM_COMPOUNDFILTER )
1748 aFilter = getComplexFilter( theSubShapes );
1750 aFilter = getFilter( aMode );
1752 else if ( theModes.Extent() > 1 )
1754 TColStd_MapOfInteger aTopAbsModes;
1755 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
1756 QList<SUIT_SelectionFilter*> aListOfFilters;
1757 for ( ; anIter.More(); anIter.Next() )
1759 SUIT_SelectionFilter* aFilter;
1760 int aMode = anIter.Key();
1761 if ( aMode == GEOM_COMPOUNDFILTER )
1762 aFilter = getComplexFilter( theSubShapes );
1764 aFilter = getFilter( aMode );
1767 aListOfFilters.append( aFilter );
1770 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
1777 sm->installFilter( aFilter );
1780 Handle(GEOM_OCCFilter) anOCCFilter = new GEOM_OCCFilter( sm );
1781 ic->AddFilter( anOCCFilter );
1786 //=================================================================
1788 * GEOM_Displayer::LocalSelection
1789 * Activate selection of CAD shapes with activisation of selection
1790 * of their sub-shapes (with opened local context for OCC viewer)
1792 //=================================================================
1793 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
1795 SALOME_ListIteratorOfListIO Iter( theIOList );
1796 for ( ; Iter.More(); Iter.Next() )
1797 LocalSelection( Iter.Value(), theMode );
1800 //=================================================================
1802 * GEOM_Displayer::BeforeDisplay
1803 * Called before displaying of pars. Close local context
1804 * [ Reimplemented from SALOME_Displayer ]
1806 //=================================================================
1807 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
1809 SOCC_Viewer* vf = dynamic_cast<SOCC_Viewer*>( v );
1812 Handle(AIS_InteractiveContext) ic = vf->getAISContext();
1815 if ( ic->HasOpenedContext() )
1816 ic->CloseAllContexts();
1821 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
1823 UpdateColorScale(false,false);
1826 void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
1828 LightApp_Displayer::AfterErase( v, p );
1829 UpdateColorScale(false,false);
1832 //=================================================================
1834 * GEOM_Displayer::SetColor
1835 * Set color for shape displaying. If it is equal -1 then default color is used.
1836 * Available values are from Quantity_NameOfColor enumeration
1838 //=================================================================
1839 void GEOM_Displayer::SetColor( const int color )
1846 myShadingColor = Quantity_Color( (Quantity_NameOfColor)color );
1850 int GEOM_Displayer::GetColor() const
1855 bool GEOM_Displayer::HasColor() const
1857 return myColor != -1;
1860 void GEOM_Displayer::UnsetColor()
1864 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1865 QColor col = resMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
1866 myShadingColor = SalomeApp_Tools::color( col );
1869 //=================================================================
1871 * GEOM_Displayer::SetTransparency
1872 * Set transparency for shape displaying.
1874 //=================================================================
1875 void GEOM_Displayer::SetTransparency( const double transparency )
1877 myTransparency = transparency;
1880 double GEOM_Displayer::GetTransparency() const
1882 return myTransparency;
1885 bool GEOM_Displayer::HasTransparency() const
1887 return myTransparency != -1.0;
1890 void GEOM_Displayer::UnsetTransparency()
1892 myTransparency = -1.0;
1896 //=================================================================
1898 * GEOM_Displayer::SetTexture
1899 * Set color for shape displaying. If it is equal -1 then default color is used.
1900 * Available values are from Quantity_NameOfColor enumeration
1902 //=================================================================
1903 void GEOM_Displayer::SetTexture( const std::string& texureFileName )
1905 if(texureFileName!="")
1907 myTexture = texureFileName;
1911 bool GEOM_Displayer::HasTexture() const
1913 return myTexture != "";
1916 std::string GEOM_Displayer::GetTexture() const
1921 //=================================================================
1923 * GEOM_Displayer::SetWidth
1924 * Set width of shape displaying. If it is equal -1 then default width is used.
1926 //=================================================================
1927 void GEOM_Displayer::SetWidth( const double width )
1932 double GEOM_Displayer::GetWidth() const
1937 bool GEOM_Displayer::HasWidth() const
1939 return myWidth != -1;
1942 void GEOM_Displayer::UnsetWidth()
1948 int GEOM_Displayer::GetIsosWidth() const
1953 void GEOM_Displayer::SetIsosWidth(const int width)
1955 myIsosWidth = width;
1958 bool GEOM_Displayer::HasIsosWidth() const
1960 return myIsosWidth != -1;
1964 //=================================================================
1966 * GEOM_Displayer::SetToActivate
1967 * This method is used for activisation/deactivisation of objects to be displayed
1969 //=================================================================
1970 void GEOM_Displayer::SetToActivate( const bool toActivate )
1972 myToActivate = toActivate;
1974 bool GEOM_Displayer::ToActivate() const
1976 return myToActivate;
1979 //=================================================================
1981 * GEOM_Displayer::clearTemporary
1982 * Removes from selection temporary objects
1984 //=================================================================
1985 void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr )
1987 SALOME_ListIO selected, toSelect;
1988 theSelMgr->selectedObjects( selected );
1990 for ( SALOME_ListIteratorOfListIO it( selected ) ; it.More(); it.Next() ) {
1991 Handle(SALOME_InteractiveObject) io = it.Value();
1992 if ( !io.IsNull() && io->hasEntry() && strncmp( io->getEntry(), "TEMP_", 5 ) != 0 )
1993 toSelect.Append( it.Value() );
1996 theSelMgr->setSelectedObjects( toSelect, true );
1999 void GEOM_Displayer::SetName( const char* theName )
2004 void GEOM_Displayer::UnsetName()
2009 SalomeApp_Study* GEOM_Displayer::getStudy() const
2011 return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
2014 void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO )
2019 void GEOM_Displayer::setShape( const TopoDS_Shape& theShape )
2024 void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
2025 const int theFieldDimension,
2026 const QList<QVariant>& theFieldStepData,
2027 const TCollection_AsciiString& theFieldStepName,
2028 const double theFieldStepRangeMin,
2029 const double theFieldStepRangeMax )
2031 myFieldDataType = theFieldDataType;
2032 myFieldDimension = theFieldDimension;
2033 myFieldStepData = theFieldStepData;
2034 myFieldStepName = theFieldStepName;
2035 myFieldStepRangeMin = theFieldStepRangeMin;
2036 myFieldStepRangeMax = theFieldStepRangeMax;
2039 bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const
2041 _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toLatin1() );
2042 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects
2043 GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps
2044 GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component
2045 return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) &&
2046 (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type());
2049 int GEOM_Displayer::SetDisplayMode( const int theMode )
2051 int aPrevMode = myDisplayMode;
2052 if ( theMode != -1 ) {
2053 myDisplayMode = theMode;
2054 myHasDisplayMode = true;
2062 int GEOM_Displayer::GetDisplayMode() const
2064 return myDisplayMode;
2067 int GEOM_Displayer::UnsetDisplayMode()
2069 int aPrevMode = myDisplayMode;
2070 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2071 myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
2072 myHasDisplayMode = false;
2076 bool GEOM_Displayer::HasDisplayMode() const
2078 return myHasDisplayMode;
2081 SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
2083 static QList<QColor> colors;
2085 if ( colors.isEmpty() ) {
2087 for (int s = 0; s < 2 ; s++)
2089 for (int v = 100; v >= 40; v = v - 20)
2091 for (int h = 0; h < 359 ; h = h + 60)
2093 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
2099 static int currentColor = 0;
2101 SALOMEDS::Color color;
2102 color.R = (double)colors[currentColor].red() / 255.0;
2103 color.G = (double)colors[currentColor].green() / 255.0;
2104 color.B = (double)colors[currentColor].blue() / 255.0;
2106 currentColor = (currentColor+1) % colors.count();
2111 SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
2114 int aTolerance = 64;
2115 int anIterations = 0;
2121 if( anIterations % aPeriod == 0 )
2124 if( aTolerance < 1 )
2127 //std::cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< std::endl;
2129 aHue = (int)( 360.0 * rand() / RAND_MAX );
2130 //std::cout << "Hue = " << aHue << std::endl;
2132 //std::cout << "Auto colors : ";
2134 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
2135 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
2136 for( ; it != itEnd; ++it )
2138 SALOMEDS::Color anAutoColor = *it;
2139 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
2142 aQColor.getHsv( &h, &s, &v );
2143 //std::cout << h << " ";
2144 if( abs( h - aHue ) < aTolerance )
2147 //std::cout << "break (diff = " << abs( h - aHue ) << ")";
2151 //std::cout << std::endl;
2157 //std::cout << "Hue of the returned color = " << aHue << std::endl;
2159 aColor.setHsv( aHue, 255, 255 );
2161 SALOMEDS::Color aSColor;
2162 aSColor.R = (double)aColor.red() / 255.0;
2163 aSColor.G = (double)aColor.green() / 255.0;
2164 aSColor.B = (double)aColor.blue() / 255.0;
2169 PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study,
2170 const QString& entry,
2173 // get default properties for the explicitly specified default view type
2174 PropMap propMap = GEOM_Displayer::getDefaultPropertyMap();
2176 if ( study && view ) {
2177 SUIT_ViewModel* viewModel = dynamic_cast<SUIT_ViewModel*>( view );
2178 SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0;
2179 int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1;
2181 if ( viewModel && viewId != -1 ) {
2182 // get properties from the study
2183 PropMap storedMap = study->getObjectPropMap( viewId, entry );
2184 // overwrite default properties from stored ones (that are specified)
2185 for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) {
2186 if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) )
2187 propMap.insert( GEOM::propertyName( (GEOM::Property)prop ),
2188 storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) );
2190 // ... specific processing for color
2191 // ... current implementation is to use same stored color for all aspects
2192 // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2193 if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2194 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2195 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2196 propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2197 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2198 propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) );
2201 if ( !entry.isEmpty() ) {
2202 // get CORBA reference to geom object
2203 _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) );
2205 CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO );
2206 if ( !CORBA::is_nil( object ) ) {
2207 GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object );
2208 if ( !CORBA::is_nil( geomObject ) ) { // to check
2209 // check that geom object has color properly set
2210 bool hasColor = false;
2211 SALOMEDS::Color aSColor = getColor( geomObject, hasColor );
2212 // set color from geometry object (only once, if it is not yet set in GUI)
2213 // current implementation is to use same color for all aspects
2214 // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here
2215 if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) {
2216 QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B );
2217 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor );
2218 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor );
2219 propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor );
2220 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor );
2221 propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor );
2223 // check that object has point marker properly set
2224 GEOM::marker_type mType = geomObject->GetMarkerType();
2225 GEOM::marker_size mSize = geomObject->GetMarkerSize();
2226 int mTextureId = geomObject->GetMarkerTexture();
2227 bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) ||
2228 ( mType == GEOM::MT_USER && mTextureId > 0 );
2229 // set point marker from geometry object (only once, if it is not yet set in GUI)
2230 if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) {
2231 if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) {
2233 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2234 QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) );
2236 else if ( mType == GEOM::MT_USER ) {
2238 propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) );
2250 PropMap GEOM_Displayer::getDefaultPropertyMap()
2254 // get resource manager
2255 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2257 // fill in the properties map with default values
2259 // - visibility (false by default)
2260 propMap.insert( GEOM::propertyName( GEOM::Visibility ), false );
2262 // - nb isos (take default value from preferences)
2263 propMap.insert( GEOM::propertyName( GEOM::NbIsos ),
2264 QString( "%1%2%3" ).
2265 arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ).
2266 arg( GEOM::subSectionSeparator() ).
2267 arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) );
2269 // - transparency (opacity = 1-transparency)
2270 propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 );
2272 // - display mode (take default value from preferences)
2273 propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
2274 resMgr->integerValue( "Geometry", "display_mode", 0 ) );
2276 // - show edges direction flag (false by default)
2277 propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false );
2279 // - shading color (take default value from preferences)
2280 propMap.insert( GEOM::propertyName( GEOM::ShadingColor ),
2281 colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) );
2283 // - wireframe color (take default value from preferences)
2284 propMap.insert( GEOM::propertyName( GEOM::WireframeColor ),
2285 colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) );
2287 // - standalone edges color (take default value from preferences)
2288 propMap.insert( GEOM::propertyName( GEOM::LineColor ),
2289 colorFromResources( "line_color", QColor( 255, 0, 0 ) ) );
2291 // - free boundaries color (take default value from preferences)
2292 propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ),
2293 colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) );
2295 // - points color (take default value from preferences)
2296 propMap.insert( GEOM::propertyName( GEOM::PointColor ),
2297 colorFromResources( "point_color", QColor( 255, 255, 0 ) ) );
2299 // - isos color (take default value from preferences)
2300 propMap.insert( GEOM::propertyName( GEOM::IsosColor ),
2301 colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) );
2303 // - outlines color (take default value from preferences)
2304 propMap.insert( GEOM::propertyName( GEOM::OutlineColor ),
2305 colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) );
2307 // - deflection coefficient (take default value from preferences)
2308 propMap.insert( GEOM::propertyName( GEOM::Deflection ),
2309 resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) );
2311 // - material (take default value from preferences)
2312 Material_Model material;
2313 material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) );
2314 propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() );
2316 // - edge width (take default value from preferences)
2317 propMap.insert( GEOM::propertyName( GEOM::LineWidth ),
2318 resMgr->integerValue( "Geometry", "edge_width", 1 ) );
2320 // - isos width (take default value from preferences)
2321 propMap.insert( GEOM::propertyName( GEOM::IsosWidth ),
2322 resMgr->integerValue( "Geometry", "isolines_width", 1 ) );
2324 // - point marker (take default value from preferences)
2325 propMap.insert( GEOM::propertyName( GEOM::PointMarker ),
2326 QString( "%1%2%3" ).
2327 arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ).
2328 arg( GEOM::subSectionSeparator() ).
2329 arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) );
2331 // - top-level flag (false by default)
2332 propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false );
2337 SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
2338 SALOMEDS::Color aSColor;
2341 SUIT_Session* session = SUIT_Session::session();
2342 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
2344 if ( app && !theGeomObject->_is_nil()) {
2345 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2348 _PTR(Study) aStudy = study->studyDS();
2349 aSColor = theGeomObject->GetColor();
2350 hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
2352 #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
2353 bool general_autocolor = true;
2354 #else // auto-color for groups only
2355 bool general_autocolor = false;
2356 #endif // GENERAL_AUTOCOLOR
2357 if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
2358 GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
2359 if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
2360 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
2361 aSColor = getPredefinedUniqueColor();
2363 #else // old algorithm for auto-colors
2364 QList<SALOMEDS::Color> aReservedColors;
2365 CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
2366 _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
2367 if ( aMainSObject ) {
2368 _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
2369 for ( ; it->More(); it->Next() ) {
2370 _PTR(SObject) aChildSObject( it->Value() );
2371 GEOM::GEOM_Object_var aChildObject =
2372 GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
2373 if ( CORBA::is_nil( aChildObject ) )
2376 SALOMEDS::Color aReservedColor = aChildObject->GetColor();
2377 if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
2378 aReservedColors.append( aReservedColor );
2381 aSColor = getUniqueColor( aReservedColors );
2383 #endif // SIMPLE_AUTOCOLOR
2393 void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
2394 const bool eraseOnlyChildren) {
2395 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2399 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2403 LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
2408 // Erase from all views
2409 QList<SALOME_View*> views;
2411 ViewManagerList vmans = app->viewManagers();
2412 SUIT_ViewManager* vman;
2413 foreach ( vman, vmans ) {
2414 SUIT_ViewModel* vmod = vman->getViewModel();
2415 view = dynamic_cast<SALOME_View*> ( vmod );
2417 views.append( view );
2420 if( views.count() == 0 )
2423 //Erase childrens w/o update views
2424 DataObjectList listObj = parent->children( true );
2425 SUIT_DataObject* obj;
2426 foreach( obj, listObj ) {
2427 LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
2429 foreach ( view, views ) {
2430 Handle(SALOME_InteractiveObject) anIO =
2431 new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
2432 Erase(anIO, false, false, view);
2436 //Erase parent with view update or repaint views
2437 foreach ( view, views ) {
2438 if(!eraseOnlyChildren)
2439 Erase(theIO, false, true, view);
2445 void GEOM_Displayer::readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep )
2447 if( theGeomFieldStep->_is_nil() )
2450 GEOM::GEOM_Field_var aGeomField = theGeomFieldStep->GetField();
2451 if( aGeomField->_is_nil() )
2454 GEOM::GEOM_Object_var aGeomFieldShape = aGeomField->GetShape();
2455 if( aGeomFieldShape->_is_nil() )
2458 TCollection_AsciiString aFieldStepName( theGeomFieldStep->GetName() );
2459 TCollection_AsciiString aFieldName( aGeomField->GetName() );
2460 TCollection_AsciiString aShapeName( aGeomFieldShape->GetName() );
2462 aFieldStepName = aShapeName + "\n" + aFieldName + "\n" + aFieldStepName;
2464 GEOM::field_data_type aFieldDataType = aGeomField->GetDataType();
2466 int aFieldDimension = aGeomField->GetDimension();
2468 GEOM::string_array_var aFieldComponents = aGeomField->GetComponents();
2469 int aFieldNbComponents = aFieldComponents->length();
2471 QList<QVariant> aFieldStepData;
2472 if( aFieldDataType == GEOM::FDT_Bool )
2474 GEOM::GEOM_BoolFieldStep_var aGeomBoolFieldStep = GEOM::GEOM_BoolFieldStep::_narrow( theGeomFieldStep );
2475 if ( !aGeomBoolFieldStep->_is_nil() )
2477 GEOM::short_array_var aValues = aGeomBoolFieldStep->GetValues();
2478 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2479 aFieldStepData << (bool)aValues[i];
2482 else if( aFieldDataType == GEOM::FDT_Int )
2484 GEOM::GEOM_IntFieldStep_var aGeomIntFieldStep = GEOM::GEOM_IntFieldStep::_narrow( theGeomFieldStep );
2485 if ( !aGeomIntFieldStep->_is_nil() )
2487 GEOM::ListOfLong_var aValues = aGeomIntFieldStep->GetValues();
2488 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2489 aFieldStepData << (qlonglong)aValues[i];
2492 else if( aFieldDataType == GEOM::FDT_Double )
2494 GEOM::GEOM_DoubleFieldStep_var aGeomDoubleFieldStep = GEOM::GEOM_DoubleFieldStep::_narrow( theGeomFieldStep );
2495 if ( !aGeomDoubleFieldStep->_is_nil() )
2497 GEOM::ListOfDouble_var aValues = aGeomDoubleFieldStep->GetValues();
2498 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2499 aFieldStepData << (double)aValues[i];
2502 else if( aFieldDataType == GEOM::FDT_String )
2504 GEOM::GEOM_StringFieldStep_var aGeomStringFieldStep = GEOM::GEOM_StringFieldStep::_narrow( theGeomFieldStep );
2505 if ( !aGeomStringFieldStep->_is_nil() )
2507 GEOM::string_array_var aValues = aGeomStringFieldStep->GetValues();
2508 for( size_t i = 0, n = aValues->length(); i < n; i++ )
2509 aFieldStepData << QString( aValues[i] );
2513 double aFieldStepRangeMin = 0, aFieldStepRangeMax = 0;
2514 aFieldStepData = groupFieldData( aFieldStepData,
2516 aFieldDataType == GEOM::FDT_String,
2518 aFieldStepRangeMax );
2520 setFieldStepInfo( aFieldDataType,
2525 aFieldStepRangeMax );
2528 QList<QVariant> GEOM_Displayer::groupFieldData( const QList<QVariant>& theFieldStepData,
2529 const int theFieldNbComponents,
2530 const bool theIsString,
2531 double& theFieldStepRangeMin,
2532 double& theFieldStepRangeMax )
2534 QList<QVariant> aResultList;
2535 theFieldStepRangeMin = 0;
2536 theFieldStepRangeMax = 0;
2538 if( theFieldStepData.isEmpty() || theFieldNbComponents < 1 )
2541 int aNbSubShapes = theFieldStepData.count() / theFieldNbComponents;
2543 QList<QVariant> aGroupedList;
2545 bool anIsBoolean = false;
2546 for( int aSubShape = 0; aSubShape < aNbSubShapes; aSubShape++ )
2549 QStringList aStringList;
2551 int aBaseIndex = aSubShape * theFieldNbComponents;
2552 for( int aComponent = 0; aComponent < theFieldNbComponents; aComponent++ )
2554 int anIndex = aComponent + aBaseIndex;
2556 const QVariant& aVariant = theFieldStepData[ anIndex ];
2559 if( aVariant.type() == QVariant::String )
2560 aStringList << aVariant.toString();
2565 if( aVariant.type() == QVariant::Bool )
2567 aValue = aVariant.toBool() ? 1.0 : 0.0;
2573 if( aVariant.type() == QVariant::LongLong )
2574 aValue = double( aVariant.toLongLong() );
2575 else if( aVariant.type() == QVariant::Double )
2576 aValue = aVariant.toDouble();
2577 aNorm += aValue * aValue;
2583 aGroupedList << aStringList.join( "\n" );
2587 aNorm /= theFieldNbComponents;
2589 aNorm = pow( aNorm, 0.5 );
2591 if( aGroupedList.isEmpty() )
2592 theFieldStepRangeMin = theFieldStepRangeMax = aNorm;
2595 theFieldStepRangeMin = Min( theFieldStepRangeMin, aNorm );
2596 theFieldStepRangeMax = Max( theFieldStepRangeMax, aNorm );
2599 aGroupedList << aNorm;
2605 theFieldStepRangeMin = 0.0;
2606 theFieldStepRangeMax = 1.0;
2609 SUIT_Session* session = SUIT_Session::session();
2610 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2611 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2613 QListIterator<QVariant> anIter( aGroupedList );
2614 while( anIter.hasNext() )
2616 const QVariant& aVariant = anIter.next();
2618 aResultList << aVariant;
2622 Quantity_Color aColor;
2623 if( FindColor( aVariant.toDouble(), theFieldStepRangeMin, theFieldStepRangeMax, anIsBoolean ? 2 : aNbIntervals, aColor ) )
2624 aQColor = QColor::fromRgbF( aColor.Red(), aColor.Green(), aColor.Blue() );
2625 aResultList << aQColor;
2631 // Note: the method is copied from Aspect_ColorScale class
2632 Standard_Integer GEOM_Displayer::HueFromValue( const Standard_Integer aValue,
2633 const Standard_Integer aMin,
2634 const Standard_Integer aMax )
2636 Standard_Integer minLimit( 0 ), maxLimit( 230 );
2638 Standard_Integer aHue = maxLimit;
2640 aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( aValue - aMin ) / ( aMax - aMin ) );
2642 aHue = Min( Max( minLimit, aHue ), maxLimit );
2647 // Note: the method is copied from Aspect_ColorScale class
2648 Standard_Boolean GEOM_Displayer::FindColor( const Standard_Real aValue,
2649 const Standard_Real aMin,
2650 const Standard_Real aMax,
2651 const Standard_Integer ColorsCount,
2652 Quantity_Color& aColor )
2654 if( aValue<aMin || aValue>aMax || aMax<aMin )
2655 return Standard_False;
2659 Standard_Real IntervNumber = 0;
2662 else if( aValue>aMax )
2663 IntervNumber = ColorsCount-1;
2664 else if( Abs( aMax-aMin ) > Precision::Approximation() )
2665 IntervNumber = Floor( Standard_Real( ColorsCount ) * ( aValue - aMin ) / ( aMax - aMin ) ); // 'Ceiling' replaced with 'Floor'
2667 Standard_Integer Interv = Standard_Integer( IntervNumber );
2669 aColor = Quantity_Color( HueFromValue( Interv, 0, ColorsCount - 1 ), 1.0, 1.0, Quantity_TOC_HLS );
2671 return Standard_True;
2675 void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, const bool updateViewer )
2677 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
2681 SOCC_Viewer* aViewModel = dynamic_cast<SOCC_Viewer*>( GetActiveView() );
2685 Handle(V3d_Viewer) aViewer = aViewModel->getViewer3d();
2686 if( aViewer.IsNull() )
2689 aViewer->InitActiveViews();
2690 if( !aViewer->MoreActiveViews() )
2693 Handle(V3d_View) aView = aViewer->ActiveView();
2694 if( aView.IsNull() )
2697 Standard_Boolean anIsDisplayColorScale = Standard_False;
2698 TCollection_AsciiString aColorScaleTitle;
2699 Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
2700 Standard_Boolean anIsBoolean = Standard_False;
2702 SALOME_ListIO aSelectedObjects;
2703 myApp->selectionMgr()->selectedObjects( aSelectedObjects );
2704 if( aSelectedObjects.Extent() == 1 )
2706 Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
2707 if( !anIO.IsNull() )
2709 SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
2712 AIS_ListOfInteractive aList;
2713 aPrs->GetObjects( aList );
2714 AIS_ListIteratorOfListOfInteractive anIter( aList );
2715 for( ; anIter.More(); anIter.Next() )
2717 Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
2718 if( !aShape.IsNull() )
2720 GEOM::field_data_type aFieldDataType;
2721 int aFieldDimension;
2722 QList<QVariant> aFieldStepData;
2723 TCollection_AsciiString aFieldStepName;
2724 double aFieldStepRangeMin, aFieldStepRangeMax;
2725 aShape->getFieldStepInfo( aFieldDataType,
2730 aFieldStepRangeMax );
2731 if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
2733 anIsDisplayColorScale = Standard_True;
2734 aColorScaleTitle = aFieldStepName;
2735 aColorScaleMin = aFieldStepRangeMin;
2736 aColorScaleMax = aFieldStepRangeMax;
2737 anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
2745 if( anIsDisplayColorScale )
2747 Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
2748 if( !aColorScale.IsNull() )
2750 SUIT_Session* session = SUIT_Session::session();
2751 SUIT_ResourceMgr* resMgr = session->resourceMgr();
2753 Standard_Real anXPos = resMgr->doubleValue( "Geometry", "scalar_bar_x_position", 0.05 );
2754 Standard_Real anYPos = resMgr->doubleValue( "Geometry", "scalar_bar_y_position", 0.1 );
2755 Standard_Real aWidth = resMgr->doubleValue( "Geometry", "scalar_bar_width", 0.2 );
2756 Standard_Real aHeight = resMgr->doubleValue( "Geometry", "scalar_bar_height", 0.5 );
2757 Standard_Integer aTextHeight = resMgr->integerValue( "Geometry", "scalar_bar_text_height", 14 );
2758 Standard_Integer aNbIntervals = resMgr->integerValue( "Geometry", "scalar_bar_nb_intervals", 20 );
2760 aColorScale->SetXPosition( anXPos );
2761 aColorScale->SetYPosition( anYPos );
2762 aColorScale->SetWidth( aWidth );
2763 aColorScale->SetHeight( aHeight );
2765 aColorScale->SetTextHeight( aTextHeight );
2766 aColorScale->SetNumberOfIntervals( anIsBoolean ? 2 : aNbIntervals );
2768 aColorScale->SetTitle( aColorScaleTitle );
2769 aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
2771 if( !aView->ColorScaleIsDisplayed() )
2772 aView->ColorScaleDisplay();
2776 if( aView->ColorScaleIsDisplayed() )
2777 aView->ColorScaleErase();
2780 if( theIsRedisplayFieldSteps )
2782 _PTR(Study) aStudyDS = aStudy->studyDS();
2783 QList<SUIT_ViewManager*> vmList;
2784 myApp->viewManagers( vmList );
2785 for( QList<SUIT_ViewManager*>::Iterator vmIt = vmList.begin(); vmIt != vmList.end(); vmIt++ )
2787 if( SUIT_ViewManager* aViewManager = *vmIt )
2789 const ObjMap anObjects = aStudy->getObjectMap( aViewManager->getGlobalId() );
2790 for( ObjMap::ConstIterator objIt = anObjects.begin(); objIt != anObjects.end(); objIt++ )
2792 _PTR(SObject) aSObj( aStudyDS->FindObjectID( objIt.key().toLatin1().constData() ) );
2795 CORBA::Object_var anObject = GeometryGUI::ClientSObjectToObject( aSObj );
2796 if( !CORBA::is_nil( anObject ) )
2798 GEOM::GEOM_FieldStep_var aFieldStep = GEOM::GEOM_FieldStep::_narrow( anObject );
2799 if( !aFieldStep->_is_nil() )
2801 CORBA::String_var aStepEntry = aFieldStep->GetStudyEntry();
2802 Handle(SALOME_InteractiveObject) aStepIO =
2803 new SALOME_InteractiveObject( aStepEntry.in(), "GEOM", "TEMP_IO" );
2804 Redisplay( aStepIO, false, false );