1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GEOM_Displayer.cxx
25 // Author : Vadim SANDLER
29 #include "GEOM_Displayer.h"
30 #include "GEOM_ShapeTypeFilter.hxx"
31 #include "GEOM_TypeFilter.hxx"
32 #include "QAD_Desktop.h"
33 #include "QAD_Application.h"
34 #include "QAD_Study.h"
35 #include "QAD_StudyFrame.h"
36 #include "QAD_RightFrame.h"
37 #include "QAD_ViewFrame.h"
38 #include "QAD_Config.h"
39 #include "SALOME_ListIteratorOfListIO.hxx"
40 #include "OCCViewer_Prs.h"
41 #include "OCCViewer_ViewFrame.h"
42 #include "OCCViewer_Viewer3d.h"
43 #include "VTKViewer_Prs.h"
44 #include "VTKViewer_ViewFrame.h"
45 #include "GEOMImpl_Types.hxx"
46 #include "TColStd_MapOfInteger.hxx"
47 #include "TColStd_MapIteratorOfMapOfInteger.hxx"
48 #include "GEOM_EdgeFilter.hxx"
49 #include "GEOM_FaceFilter.hxx"
50 #include "GEOM_PreviewFilter.hxx"
51 #include "GEOM_LogicalFilter.hxx"
52 #include "GEOM_AssemblyBuilder.h"
53 #include "GEOM_Actor.h"
54 #include "GEOM_AISTrihedron.hxx"
55 #include "GEOM_VTKTrihedron.hxx"
57 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
59 #include "GeometryGUI.h"
60 #include "GEOM_AISShape.hxx"
61 #include <AIS_ListIteratorOfListOfInteractive.hxx>
62 #include <AIS_Drawer.hxx>
63 #include <Prs3d_PointAspect.hxx>
64 #include <Graphic3d_AspectMarker3d.hxx>
65 #include <Geom_Plane.hxx>
66 #include <TopoDS_Face.hxx>
67 #include <BRep_Tool.hxx>
69 #include <Geom_Axis2Placement.hxx>
71 #include <vtkActorCollection.h>
77 //================================================================
78 // Function : getActiveStudy
79 // Purpose : Get active study, returns 0 if no open study frame
80 //================================================================
81 static inline QAD_Study* getActiveStudy()
83 QAD_Desktop* desktop = QAD_Application::getDesktop();
85 QAD_Application* app = desktop->getActiveApp();
87 return app->getActiveStudy();
92 //================================================================
93 // Function : getTopAbsMode
94 // Purpose : Get TopAbs_ShapeEnum value corresponding to the
95 // one from GEOMImpl_Types.h
96 //================================================================
97 static inline int getTopAbsMode( const int implType )
101 case GEOM_COMPOUND : return TopAbs_COMPOUND;
102 case GEOM_SOLID : return TopAbs_SOLID;
103 case GEOM_SHELL : return TopAbs_SHELL;
104 case GEOM_FACE : return TopAbs_FACE;
105 case GEOM_WIRE : return TopAbs_WIRE;
106 case GEOM_EDGE : return TopAbs_EDGE;
107 case GEOM_POINT : return TopAbs_VERTEX;
112 //================================================================
113 // Function : getTopAbsMode
114 // Purpose : Get filter corresponding to the type of object
115 // from GEOMImpl_Types.h
116 //================================================================
117 static inline Handle(SALOME_Filter) getFilter( const int theMode )
119 Handle(SALOME_Filter) aFilter;
121 int aTopAbsMode = getTopAbsMode( theMode );
122 if ( aTopAbsMode != -1 )
123 aFilter = new GEOM_ShapeTypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode );
127 case GEOM_LINE : aFilter = new GEOM_EdgeFilter( StdSelect_Line ); break;
128 case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( StdSelect_Circle ); break;
130 case GEOM_PLANE : aFilter = new GEOM_FaceFilter( StdSelect_Plane ); break;
131 case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( StdSelect_Cylinder ); break;
132 case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( StdSelect_Sphere ); break;
133 case GEOM_TORUS : aFilter = new GEOM_FaceFilter( StdSelect_Torus ); break;
134 case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( StdSelect_Revol ); break;
135 case GEOM_CONE : aFilter = new GEOM_FaceFilter( StdSelect_Cone ); break;
137 case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter(); break;
139 default : aFilter = new GEOM_TypeFilter( theMode ); break;
145 //================================================================
146 // Function : getEntry
148 //================================================================
149 static char* getEntry( GEOM::GEOM_Object_ptr object )
151 QAD_Study* study = getActiveStudy();
153 string IOR = GeometryGUI::GetORB()->object_to_string( object );
155 SALOMEDS::SObject_var SO = study->getStudyDocument()->FindObjectIOR( IOR.c_str() );
156 if ( !SO->_is_nil() ) {
164 //================================================================
165 // Function : getName
167 //================================================================
168 static const char* getName( GEOM::GEOM_Object_ptr theObj )
170 QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
174 string anIOR = GeometryGUI::GetORB()->object_to_string( theObj );
177 SALOMEDS::SObject_var aSObj = aStudy->getStudyDocument()->FindObjectIOR( anIOR.c_str() );
178 SALOMEDS::GenericAttribute_var anAttr;
180 if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") )
182 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
183 return aNameAttr->Value();
191 //=================================================================
193 * GEOM_Displayer::GEOM_Displayer
196 //=================================================================
197 GEOM_Displayer::GEOM_Displayer()
200 QString SCr = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorRed" );
201 QString SCg = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorGreen" );
202 QString SCb = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorBlue" );
203 if ( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
204 myShadingColor = Quantity_Color(
205 SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB );
207 myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
210 // This color is used for shape displaying. If it is equal -1 then
211 // default color is used.
217 // This parameter is used for activisation/deactivisation of objects to be displayed
222 //=================================================================
224 * GEOM_Displayer::~GEOM_Displayer
227 //=================================================================
228 GEOM_Displayer::~GEOM_Displayer()
232 //=================================================================
235 * Get active study frame, returns 0 if no open study frame
237 //=================================================================
238 QAD_ViewFrame* GEOM_Displayer::GetActiveView()
240 QAD_Study* activeStudy = getActiveStudy();
243 QAD_StudyFrame* sf = activeStudy->getActiveStudyFrame();
246 return sf->getRightFrame()->getViewFrame();
252 //=================================================================
254 * GEOM_Displayer::Display
255 * Display interactive object in the current viewer
257 //=================================================================
258 void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer,
259 QAD_ViewFrame* theViewFrame )
261 QAD_ViewFrame* vf = theViewFrame;
263 vf = GetActiveView();
267 SALOME_Prs* prs = buildPresentation( theIO, vf );
271 vf->BeforeDisplay( this );
272 ((SALOME_View*)vf)->Display( prs );
273 vf->AfterDisplay( this );
278 delete prs; // delete presentation because displayer is its owner
283 //=================================================================
285 * GEOM_Displayer::Display
286 * This overloaded Display() method can be useful for operations
287 * not using dialog boxes.
289 //=================================================================
290 void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateViewer )
292 if ( theObj->_is_nil() )
295 string entry = getEntry( theObj );
297 Display( new SALOME_InteractiveObject(
298 entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), updateViewer );
302 //=================================================================
304 * GEOM_Displayer::Erase
305 * Erase interactive object in the current viewer
307 //=================================================================
308 void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO,
310 const bool updateViewer,
311 QAD_ViewFrame* theViewFrame )
313 if ( theIO.IsNull() )
316 QAD_ViewFrame* vf = theViewFrame;
318 vf = GetActiveView();
321 SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() );
323 ((SALOME_View*)vf)->Erase( prs, forced );
326 delete prs; // delete presentation because displayer is its owner
331 //=================================================================
333 * GEOM_Displayer::Erase
334 * Erase geometry object in the current viewer
336 //=================================================================
337 void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj,
339 const bool updateViewer )
341 string entry = getEntry( theObj );
344 Erase( new SALOME_InteractiveObject(
345 entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), forced, updateViewer );
349 //=================================================================
351 * GEOM_Displayer::Redisplay
352 * Redisplay (erase and then display again) interactive object
353 * in the current viewer
355 //=================================================================
356 void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
357 const bool updateViewer )
359 // Remove the object permanently (<forced> == true)
361 QAD_Study* activeStudy = getActiveStudy();
365 int aNbFrames = activeStudy->getStudyFramesCount();
366 for (int i = 0; i < aNbFrames; i++)
368 QAD_StudyFrame* sf = activeStudy->getStudyFrame(i);
372 QAD_ViewFrame* vf = sf->getRightFrame()->getViewFrame();
376 if ( vf->isVisible(theIO) || vf == GetActiveView() )
378 Erase( theIO, true, false, vf );
379 Display( theIO, updateViewer, vf );
384 //=================================================================
386 * GEOM_Displayer::Display
387 * Calls Display() method for each object in the given list
389 //=================================================================
390 void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer )
392 SALOME_ListIteratorOfListIO Iter( theIOList );
393 for ( ; Iter.More(); Iter.Next() ) {
394 Display( Iter.Value(), false );
400 //=================================================================
402 * GEOM_Displayer::Erase
403 * Calls Erase() method for each object in the given list
405 //=================================================================
406 void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList,
408 const bool updateViewer )
410 SALOME_ListIteratorOfListIO Iter( theIOList );
411 for ( ; Iter.More(); Iter.Next() )
412 Erase( Iter.Value(), forced, false );
418 //=================================================================
420 * GEOM_Displayer::Redisplay
421 * Calls Redisplay() method for each object in the given list
423 //=================================================================
424 void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer )
426 SALOME_ListIteratorOfListIO Iter( theIOList );
427 for ( ; Iter.More(); Iter.Next() ) {
428 Redisplay( Iter.Value(), false );
434 //=================================================================
436 * GEOM_Displayer::UpdateViewer
437 * Update current viewer
439 //=================================================================
440 void GEOM_Displayer::UpdateViewer()
442 QAD_ViewFrame* vf = GetActiveView();
447 //=================================================================
449 * GEOM_Displayer::Update
450 * Update OCC presentaion
451 * [ Reimplemented from SALOME_Displayer ]
453 //=================================================================
454 void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
456 OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( prs );
460 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( myViewFrame );
464 if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE )
466 TopoDS_Face aFace = TopoDS::Face( myShape );
467 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
468 if ( !aPlane.IsNull() )
470 gp_Ax3 aPos = aPlane->Pln().Position();
471 Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() );
473 Handle(GEOM_AISTrihedron) aTrh;
475 if ( occPrs->IsNull() )
477 aTrh = new GEOM_AISTrihedron( aPlc );
480 aTrh->SetColor( (Quantity_NameOfColor)GetColor() );
483 aTrh->SetWidth( GetWidth() );
485 if ( !myIO.IsNull() )
488 aTrh->SetOwner( myIO );
491 occPrs->AddObject( aTrh );
495 AIS_ListOfInteractive aList;
496 occPrs->GetObjects( aList );
497 AIS_ListIteratorOfListOfInteractive anIter( aList );
498 for ( ; anIter.More(); anIter.Next() )
500 aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() );
501 if ( !aTrh.IsNull() )
503 aTrh->SetComponent( aPlc );
509 occPrs->SetToActivate( ToActivate() );
514 // if presentation is empty we try to create new one
515 if ( occPrs->IsNull() )
517 if ( !myShape.IsNull() )
519 Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
520 // Temporary staff: vertex must be infinite for correct visualization
521 AISShape->SetInfiniteState( myShape.Infinite() || myShape.ShapeType() == TopAbs_VERTEX );
523 // Setup shape properties here ..., e.g. display mode, color, transparency, etc
524 AISShape->SetShadingColor( myShadingColor );
527 if ( myShape.ShapeType() == TopAbs_VERTEX )
529 AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
530 Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
531 anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
532 AISShape->Attributes()->SetPointAspect( anAspect );
535 AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
539 AISShape->SetWidth( GetWidth() );
541 if ( !myIO.IsNull() )
543 AISShape->setIO( myIO );
544 AISShape->SetOwner( myIO );
546 else if ( !myName.empty() )
548 // Workaround to allow selection of temporary objects
549 static int tempId = 0;
551 sprintf( buf, "TEMP_%d", tempId++ );
552 Handle( SALOME_InteractiveObject ) anObj =
553 new SALOME_InteractiveObject( buf, "GEOM", myName.c_str() );
554 AISShape->setIO( anObj );
555 AISShape->SetOwner( anObj );
557 // AISShape->SetName(???); ??? necessary to set name ???
558 occPrs->AddObject( AISShape );
560 // In accordance with ToActivate() value object will be activated/deactivated
561 // when it will be displayed
562 occPrs->SetToActivate( ToActivate() );
565 // if presentation is found -> set again shape for it
568 if ( !myShape.IsNull() )
570 AIS_ListOfInteractive IOList;
571 occPrs->GetObjects( IOList );
572 AIS_ListIteratorOfListOfInteractive Iter( IOList );
574 for ( ; Iter.More(); Iter.Next() )
576 Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() );
577 if ( AISShape.IsNull() )
579 if ( AISShape->Shape() != myShape )
581 AISShape->Set( myShape );
582 AISShape->UpdateSelection();
583 AISShape->SetToUpdate();
585 if ( !myIO.IsNull() )
587 AISShape->setIO( myIO );
588 AISShape->SetOwner( myIO );
596 //=================================================================
598 * GEOM_Displayer::Update
599 * Update VTK presentaion
600 * [ Reimplemented from SALOME_Displayer ]
602 //=================================================================
603 void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
605 VTKViewer_Prs* vtkPrs = dynamic_cast<VTKViewer_Prs*>( prs );
606 if ( !vtkPrs || myShape.IsNull() )
609 vtkActorCollection* theActors = 0;
611 if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE )
613 myToActivate = false;
614 GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
618 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
619 aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
622 Handle(Geom_Plane) aPlane =
623 Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( TopoDS::Face( myShape ) ) );
624 if ( aPlane.IsNull() )
627 gp_Ax2 anAx2 = aPlane->Pln().Position().Ax2();
629 aTrh->SetPlacement( new Geom_Axis2Placement( anAx2 ) );
631 if ( VTKViewer_ViewFrame* vf = dynamic_cast<VTKViewer_ViewFrame*>( GetActiveView() ) )
632 aTrh->SetSize( 0.5 * vf->GetTrihedronSize() );
634 vtkPrs->AddObject( aTrh );
636 theActors = vtkActorCollection::New();
637 theActors->AddItem( aTrh );
640 theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True );
642 theActors->InitTraversal();
644 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
646 vtkProperty* aProp = 0;
648 if ( HasColor() || HasWidth() )
650 aProp = vtkProperty::New();
651 aProp->SetRepresentationToWireframe();
656 Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
657 aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
662 aProp->SetLineWidth( GetWidth() );
665 while ( anActor != NULL )
667 SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor );
669 GActor->setIO( myIO );
673 GActor->SetProperty( aProp );
674 GActor->SetPreviewProperty( aProp );
676 GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor );
677 if ( aGeomGActor != 0 )
679 aGeomGActor->SetShadingProperty( aProp );
680 aGeomGActor->SetWireframeProperty( aProp );
685 GActor->PickableOn();
687 GActor->PickableOff();
689 vtkPrs->AddObject( GActor );
691 anActor = (vtkActor*)theActors->GetNextActor();
700 //=================================================================
702 * GEOM_Displayer::BuildPrs
703 * Build presentation accordint to the current viewer type
705 //=================================================================
706 SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
708 if ( theObj->_is_nil() )
711 GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI();
713 myViewFrame = GetActiveView();
714 if ( myViewFrame == 0 )
717 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
722 setShape( geomGUI->GetShapeReader().GetShape( geomGUI->GetGeomGen(), theObj ) );
723 myType = theObj->GetType();
725 // Update presentation
731 //=================================================================
733 * GEOM_Displayer::BuildPrs
734 * Build presentation accordint to the current viewer type
736 //=================================================================
737 SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape )
739 myViewFrame = GetActiveView();
740 if ( theShape.IsNull() || myViewFrame == 0 )
743 SALOME_Prs* aPrs = myViewFrame->CreatePrs();
748 setShape( theShape );
756 //=================================================================
758 * GEOM_Displayer::buildPresentation
759 * Builds/finds object's presentation for the current viewer
760 * Calls corresponding Update() method by means of double dispatch
763 //=================================================================
764 SALOME_Prs* GEOM_Displayer::buildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
765 QAD_ViewFrame* theViewFrame )
770 GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI();
772 myViewFrame = theViewFrame; // no dynamic_cast here to use double dispatch
774 myViewFrame = GetActiveView();
777 prs = myViewFrame->CreatePrs( !theIO.IsNull() ? theIO->getEntry() : 0 );
779 if ( !theIO.IsNull() ) {
780 // set interactive object
782 // Find SOBject (because shape should be published previously)
783 SALOMEDS::SObject_var SO = getActiveStudy()->getStudyDocument()->FindObjectID( theIO->getEntry() );
784 if ( !SO->_is_nil() ) {
785 // get CORBA reference to data object
786 CORBA::Object_var object = SO->GetObject();
787 if ( !CORBA::is_nil( object ) ) {
788 // downcast to GEOM object
789 GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object );
790 if ( !GeomObject->_is_nil() ) {
792 setShape( geomGUI->GetShapeReader().GetShape( geomGUI->GetGeomGen(), GeomObject ) );
793 myType = GeomObject->GetType();
798 UpdatePrs( prs ); // Update presentation by using of the double dispatch
804 //=================================================================
806 * GEOM_Displayer::internalReset
807 * Resets internal data
810 //=================================================================
811 void GEOM_Displayer::internalReset()
817 //=================================================================
819 * GEOM_Displayer::LocalSelection
820 * Activate selection of CAD shapes with activisation of selection
821 * of their sub-shapes (with opened local context for OCC viewer)
823 //=================================================================
824 void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode )
826 // remove all filters from selection
827 SALOME_Selection* aSel = SALOME_Selection::Selection(
828 QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
830 aSel->ClearFilters();
832 QAD_ViewFrame* vf = GetActiveView();
835 SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() );
836 ((SALOME_View*)vf)->LocalSelection( prs, theMode );
837 delete prs; // delete presentation because displayer is its owner
841 //=================================================================
843 * GEOM_Displayer::globalSelection
844 * Activate selection of CAD shapes without activisation of selection
845 * of their sub-shapes (without opened local context for OCC viewer)
847 //=================================================================
848 void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
850 TColStd_MapOfInteger aModes;
851 aModes.Add( theMode );
852 GlobalSelection( aModes, update );
855 //=================================================================
857 * GEOM_Displayer::globalSelection
858 * Activate selection of CAD shapes without activisation of selection
859 * of their sub-shapes (without opened local context for OCC viewer)
861 //=================================================================
862 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
865 QAD_ViewFrame* vf = GetActiveView();
869 // Close local context
870 vf->GlobalSelection( update );
872 // Set selection filters in accordance with current mode
873 SALOME_Selection* aSel = SALOME_Selection::Selection(
874 QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
876 // Remove from selection temporary objects if necessary
877 if ( !theModes.Contains( GEOM_PREVIEW ) )
878 clearTemporary( aSel );
882 aSel->ClearFilters();
883 Handle(SALOME_Filter) aFilter;
884 if ( theModes.Extent() == 1 )
886 int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
887 int aTopAbsMode = getTopAbsMode( aMode );
888 if ( aTopAbsMode != -1 )
889 aFilter = getFilter( aMode );
891 else if ( theModes.Extent() > 1 )
893 TColStd_MapOfInteger aTopAbsModes;
894 TColStd_MapIteratorOfMapOfInteger anIter( theModes );
895 GEOM_ListOfFilter aListOfFilters;
896 for ( ; anIter.More(); anIter.Next() )
898 Handle(SALOME_Filter) aFilter = getFilter( anIter.Key() );
899 if ( !aFilter.IsNull() )
900 aListOfFilters.Append( aFilter );
903 aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR );
908 if ( !aFilter.IsNull() )
909 aSel->AddFilter( aFilter );
912 //=================================================================
914 * GEOM_Displayer::LocalSelection
915 * Activate selection of CAD shapes with activisation of selection
916 * of their sub-shapes (with opened local context for OCC viewer)
918 //=================================================================
919 void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode )
921 SALOME_ListIteratorOfListIO Iter( theIOList );
922 for ( ; Iter.More(); Iter.Next() )
923 LocalSelection( Iter.Value(), theMode );
926 //=================================================================
928 * GEOM_Displayer::BeforeDisplay
929 * Called before displaying of pars. Close local context
930 * [ Reimplemented from SALOME_Displayer ]
932 //=================================================================
933 void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCViewType& )
935 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( v );
939 Handle(AIS_InteractiveContext) ic = vf->getViewer()->getAISContext();
943 if ( ic->HasOpenedContext() )
944 ic->CloseAllContexts();
947 void GEOM_Displayer::AfterDisplay( SALOME_View*, const SALOME_OCCViewType& )
952 //=================================================================
954 * GEOM_Displayer::SetColor
955 * Set color for shape displaying. If it is equal -1 then default color is used.
956 * Available values are from Quantity_NameOfColor enumeration
958 //=================================================================
959 void GEOM_Displayer::SetColor( const int color )
964 int GEOM_Displayer::GetColor() const
969 bool GEOM_Displayer::HasColor() const
971 return myColor != -1;
974 void GEOM_Displayer::UnsetColor()
979 //=================================================================
981 * GEOM_Displayer::SetWidth
982 * Set width of shape displaying. If it is equal -1 then default width is used.
984 //=================================================================
985 void GEOM_Displayer::SetWidth( const double width )
990 double GEOM_Displayer::GetWidth() const
995 bool GEOM_Displayer::HasWidth() const
997 return myWidth != -1;
1000 void GEOM_Displayer::UnsetWidth()
1005 //=================================================================
1007 * GEOM_Displayer::SetToActivate
1008 * This method is used for activisation/deactivisation of objects to be displayed
1010 //=================================================================
1011 void GEOM_Displayer::SetToActivate( const bool toActivate )
1013 myToActivate = toActivate;
1015 bool GEOM_Displayer::ToActivate() const
1017 return myToActivate;
1020 //=================================================================
1022 * GEOM_Displayer::clearTemporary
1023 * Removes from selection temporary objects
1025 //=================================================================
1026 void GEOM_Displayer::clearTemporary( SALOME_Selection* theSel )
1028 SALOME_ListIO toBeRemoved;
1029 SALOME_ListIteratorOfListIO anIter( theSel->StoredIObjects() );
1030 for ( ; anIter.More(); anIter.Next() )
1032 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1033 if ( anIO->hasEntry() && ( strncmp( anIO->getEntry(), "TEMP_", 5 ) == 0 ) )
1034 toBeRemoved.Append( anIO );
1037 SALOME_ListIteratorOfListIO anIter2( toBeRemoved );
1038 for ( ; anIter2.More(); anIter2.Next() )
1039 theSel->RemoveIObject( anIter2.Value(), false );