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 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
24 // File : SALOME_Actor.cxx
25 // Author : Nicolas REJNERI
28 \class SALOME_Actor SALOME_Actor.h
29 \brief Abstract class of SALOME Objects in VTK.
33 #include "SALOME_Actor.h"
34 #include "SALOME_InteractiveObject.hxx"
36 #include "VTKViewer_Algorithm.h"
37 #include "VTKViewer_Transform.h"
38 #include "VTKViewer_TransformFilter.h"
39 #include "VTKViewer_GeometryFilter.h"
40 #include "VTKViewer_FramedTextActor.h"
41 #include "SVTK_AreaPicker.h"
43 #include "SVTK_Actor.h"
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
51 #include <vtkQuadraticEdge.h>
52 #include <vtkPicker.h>
53 #include <vtkPointPicker.h>
54 #include <vtkCellPicker.h>
55 #include <vtkRenderer.h>
56 #include <vtkPolyData.h>
57 #include <vtkObjectFactory.h>
58 #include <vtkDataSetMapper.h>
59 #include <vtkPolyDataMapper.h>
60 #include <vtkProperty.h>
61 #include <vtkOutlineSource.h>
62 #include <vtkPolygon.h>
64 #include <vtkInteractorStyle.h>
65 #include <vtkRenderWindowInteractor.h>
66 #include <vtkPassThroughFilter.h>
68 #include <TColStd_MapOfInteger.hxx>
69 #include <TColStd_IndexedMapOfInteger.hxx>
81 int SALOME_POINT_SIZE = 5;
82 int SALOME_LINE_WIDTH = 3;
87 GetEdgeId(SALOME_Actor* theActor,
92 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
93 double aPickPosition[3];
94 thePicker->GetPickPosition(aPickPosition);
95 double aMinDist = 1000000.0, aDist = 0;
97 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
98 aSelEdge = aPickedCell->GetEdge(i);
99 if(vtkLine::SafeDownCast(aPickedCell->GetEdge(i)) ||
100 vtkQuadraticEdge::SafeDownCast(aPickedCell->GetEdge(i))){
102 double pcoords[3], closestPoint[3], weights[3];
103 aSelEdge->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
104 if (aDist < aMinDist) {
116 CheckDimensionId(Selection_Mode theMode,
117 SALOME_Actor *theActor,
124 return ( theActor->GetObjDimension( theObjId ) == 1 );
126 return ( theActor->GetObjDimension( theObjId ) == 2 );
127 case VolumeSelection:
128 return ( theActor->GetObjDimension( theObjId ) == 3 );
129 case Elem0DSelection:
130 return ((theActor->GetObjDimension( theObjId ) == 0) &&
131 theActor->GetElemCell(theObjId) &&
132 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_VERTEX));
134 return ((theActor->GetObjDimension( theObjId ) == 0) &&
135 theActor->GetElemCell(theObjId) &&
136 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_POLY_VERTEX));
146 Make picker work with this actor only
148 TPickLimiter::TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
150 myPicker->InitializePickList();
151 myPicker->AddPickList( actor );
152 myPicker->SetPickFromList( true );
157 TPickLimiter::~TPickLimiter()
159 myPicker->SetPickFromList( false );
160 myPicker->InitializePickList();
165 vtkStandardNewMacro(SALOME_Actor);
174 mySelectionMode(ActorSelection),
175 myPreHighlightActor(SVTK_Actor::New()),
176 myHighlightActor(SVTK_Actor::New()),
177 myOutline(vtkOutlineSource::New()),
178 myOutlineActor(VTKViewer_Actor::New()),
179 myIsDisplayNameActor(false),
180 myNameActor(VTKViewer_FramedTextActor::New())
182 myPreHighlightActor->Delete();
183 myPreHighlightActor->Initialize();
184 myPreHighlightActor->PickableOff();
185 myPreHighlightActor->SetVisibility( false );
186 myPreHighlightActor->SetCoincident3DAllowed(true);
188 myHighlightActor->Delete();
189 myHighlightActor->Initialize();
190 myHighlightActor->PickableOff();
191 myHighlightActor->SetVisibility( false );
192 myHighlightActor->SetCoincident3DAllowed(true);
196 vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
197 anOutlineMapper->SetInputConnection(myOutline->GetOutputPort());
199 myOutlineActor->Delete();
200 myOutlineActor->SetMapper( anOutlineMapper );
201 anOutlineMapper->Delete();
203 myOutlineActor->PickableOff();
204 myOutlineActor->DragableOff();
205 myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
206 myOutlineActor->GetProperty()->SetAmbient(1.0);
207 myOutlineActor->GetProperty()->SetDiffuse(0.0);
208 myOutlineActor->SetVisibility( false );
211 myNameActor->Delete();
212 myNameActor->SetVisibility(false);
213 myNameActor->SetPickable(false);
214 myNameActor->SetModePosition(VTKViewer_FramedTextActor::TopRight);
215 myNameActor->SetLayoutType(VTKViewer_FramedTextActor::Vertical);
217 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
219 QColor aForegroundColor = aResourceMgr->colorValue( "VTKViewer", "group_names_text_color", Qt::white );
220 myNameActor->SetForegroundColor(aForegroundColor.redF(),
221 aForegroundColor.greenF(),
222 aForegroundColor.blueF());
224 double aGroupNamesTransparency = 0.5;
225 aGroupNamesTransparency = aResourceMgr->doubleValue( "VTKViewer", "group_names_transparency", aGroupNamesTransparency );
226 myNameActor->SetTransparency(aGroupNamesTransparency);
238 \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
244 return !myIO.IsNull();
248 \return correspoinding reference to SALOME_InteractiveObject
250 const Handle(SALOME_InteractiveObject)&
258 Sets reference to SALOME_InteractiveObject
259 \param theIO - new SALOME_InteractiveObject
263 ::setIO(const Handle(SALOME_InteractiveObject)& theIO)
269 Sets name the SALOME_Actor
270 \param theName - new name
274 ::setName(const char* theName)
277 myIO->setName(theName);
278 myNameActor->SetText(theName);
279 Superclass::setName(theName);
284 Publishes the actor in all its internal devices
288 ::AddToRender(vtkRenderer* theRenderer)
290 Superclass::AddToRender(theRenderer);
292 myRenderer = theRenderer;
294 myHighlightActor->AddToRender(theRenderer);
295 myPreHighlightActor->AddToRender(theRenderer);
296 theRenderer->AddActor( myOutlineActor.GetPointer() );
297 theRenderer->AddActor( myNameActor.GetPointer() );
301 Removes the actor from all its internal devices
305 ::RemoveFromRender(vtkRenderer* theRenderer)
307 Superclass::RemoveFromRender(theRenderer);
309 myHighlightActor->RemoveFromRender(theRenderer);
310 myPreHighlightActor->RemoveFromRender(theRenderer);
312 theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
313 theRenderer->RemoveActor( myHighlightActor.GetPointer() );
314 theRenderer->RemoveActor( myOutlineActor.GetPointer() );
315 theRenderer->RemoveActor( myNameActor.GetPointer() );
319 \return reference on renderer where it is published
329 Sets interactor in order to use vtkInteractorObserver devices
330 \param theInteractor - new interactor
334 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
336 myInteractor = theInteractor;
340 Put a request to redraw the view
346 myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
350 Apply view transformation
351 \param theTransform - transformation
355 ::SetTransform(VTKViewer_Transform* theTransform)
357 Superclass::SetTransform(theTransform);
359 myPreHighlightActor->SetTransform(theTransform);
360 myHighlightActor->SetTransform(theTransform);
361 myOutlineActor->SetTransform(theTransform);
365 Apply additional position
369 ::SetPosition(double _arg1,
373 Superclass::SetPosition(_arg1,_arg2,_arg3);
375 myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
376 myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
377 myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
381 Apply additional position
385 ::SetPosition(double _arg[3])
387 SetPosition(_arg[0],_arg[1],_arg[2]);
392 \param theVisibility - new visibility state
396 ::SetVisibility( int theVisibility )
398 Superclass::SetVisibility( theVisibility );
400 myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
402 myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
404 if(mySelector.GetPointer() && hasIO()){
405 if(mySelector->SelectionMode() != ActorSelection){
406 int aHasIndex = mySelector->HasIndex( getIO() );
407 myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
415 Gets know whether the actor should be displayed or not
419 ::ShouldBeDisplayed()
425 Set selector in order to the actor at any time can restore current selection
426 \param theSelector - new selector
430 ::SetSelector(SVTK_Selector* theSelector)
432 mySelector = theSelector;
436 To map current selection to VTK representation
440 ::Highlight(bool theIsHighlight)
442 mySelectionMode = mySelector->SelectionMode();
443 myHighlightActor->SetVisibility( false );
444 myOutlineActor->SetVisibility( false );
446 if(mySelector.GetPointer()){
447 if(mySelectionMode != ActorSelection){
448 TColStd_IndexedMapOfInteger aMapIndex;
449 mySelector->GetIndex( getIO(), aMapIndex );
450 switch( mySelectionMode ){
452 myHighlightActor->GetProperty()->SetRepresentationToPoints();
453 myHighlightActor->MapPoints( this, aMapIndex );
455 case EdgeOfCellSelection:
456 myHighlightActor->GetProperty()->SetRepresentationToWireframe();
457 myHighlightActor->MapEdge( this, aMapIndex );
462 case VolumeSelection:
463 case Elem0DSelection:
465 myHighlightActor->GetProperty()->SetRepresentationToSurface();
466 myHighlightActor->MapCells( this, aMapIndex );
469 myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
473 highlight(theIsHighlight);
477 Updates visibility of the highlight devices
481 ::highlight(bool theIsHighlight)
484 vtkDataSet * aDataSet = GetHighlightedDataSet();
485 aDataSet->GetBounds(aBounds);
486 myOutline->SetBounds(aBounds);
488 myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
490 Superclass::highlight(theIsHighlight);
495 To process prehighlight (called from SVTK_InteractorStyle)
499 ::PreHighlight(vtkInteractorStyle *theInteractorStyle,
500 SVTK_SelectionEvent* theSelectionEvent,
503 if ( !GetPickable() )
506 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
508 myPreHighlightActor->SetVisibility( false );
509 bool anIsPreselected = myIsPreselected;
510 SetPreSelected( false );
512 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
513 bool anIsChanged = (mySelectionMode != aSelectionMode);
515 myPreHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
517 double x = theSelectionEvent->myX;
518 double y = theSelectionEvent->myY;
521 if( !theIsHighlight ) {
523 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
524 vtkActorCollection* theActors = aCopy.GetActors();
525 theActors->InitTraversal();
526 while( vtkActor *ac = theActors->GetNextActor() )
527 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
528 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
529 anActor->SetPreSelected( false );
532 switch(aSelectionMode) {
535 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
536 myPointPicker->Pick( x, y, z, aRenderer );
538 int aVtkId = myPointPicker->GetPointId();
539 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
540 int anObjId = GetNodeObjId( aVtkId );
541 myIsPreselected = (anObjId >= 0);
543 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
544 int anExtent = aMapIndex.Extent();
545 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
547 TColStd_IndexedMapOfInteger aMapIndex;
548 aMapIndex.Add( anObjId );
550 myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
551 myPreHighlightActor->MapPoints( this, aMapIndex );
553 myPreHighlightActor->SetVisibility( true );
561 case VolumeSelection:
562 case Elem0DSelection:
565 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
566 myCellPicker->Pick( x, y, z, aRenderer );
568 int aVtkId = myCellPicker->GetCellId();
569 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
570 int anObjId = GetElemObjId (aVtkId );
571 if ( anObjId >= 0 ) {
572 myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
574 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
575 int anExtent = aMapIndex.Extent();
576 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
578 TColStd_IndexedMapOfInteger aMapIndex;
579 aMapIndex.Add( anObjId );
581 myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
582 myPreHighlightActor->MapCells( this, aMapIndex );
584 myPreHighlightActor->SetVisibility( true );
590 case EdgeOfCellSelection:
592 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
593 myCellPicker->Pick( x, y, z, aRenderer );
595 int aVtkId = myCellPicker->GetCellId();
596 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
597 int anObjId = GetElemObjId( aVtkId );
598 if ( anObjId >= 0 ) {
599 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
600 myIsPreselected = anEdgeId < 0;
602 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
603 int anExtent = aMapIndex.Extent();
604 anIsChanged |= (anExtent == 0 || anExtent == 1);
605 anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
607 TColStd_IndexedMapOfInteger aMapIndex;
608 aMapIndex.Add( anObjId );
609 aMapIndex.Add( anEdgeId );
611 myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
612 myPreHighlightActor->MapEdge( this, aMapIndex );
614 myPreHighlightActor->SetVisibility( true );
620 case ActorSelection :
622 if( !mySelector->IsSelected( myIO ) ) {
623 SetPreSelected( true );
626 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
627 vtkActorCollection* theActors = aCopy.GetActors();
628 theActors->InitTraversal();
629 while( vtkActor *anAct = theActors->GetNextActor() ) {
631 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
632 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
633 anActor->SetPreSelected( true );
643 mySelectionMode = aSelectionMode;
644 anIsChanged |= (anIsPreselected != myIsPreselected);
650 To process highlight (called from SVTK_InteractorStyle)
654 ::Highlight(vtkInteractorStyle *theInteractorStyle,
655 SVTK_SelectionEvent* theSelectionEvent,
658 if ( !GetPickable() || !mySelector )
661 myOutlineActor->SetVisibility( false );
662 myHighlightActor->SetVisibility( false );
664 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
666 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
667 bool anIsShift = theSelectionEvent->myIsShift;
668 if( !anIsShift || !theIsHighlight ) {
669 mySelector->RemoveIObject( this );
672 if ( !theIsHighlight )
675 myHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
677 double x = theSelectionEvent->myX;
678 double y = theSelectionEvent->myY;
680 if( theSelectionEvent->myIsRectangle || theSelectionEvent->myIsPolygon ) {
681 double xLast = theSelectionEvent->myLastX;
682 double yLast = theSelectionEvent->myLastY;
684 double x1 = x < xLast ? x : xLast;
685 double y1 = y < yLast ? y : yLast;
686 double x2 = x > xLast ? x : xLast;
687 double y2 = y > yLast ? y : yLast;
689 switch(aSelectionMode){
690 case NodeSelection: {
692 SVTK::TPickLimiter aPickLimiter( myPointAreaPicker, this );
693 if ( theSelectionEvent->myIsRectangle )
694 myPointAreaPicker->Pick( x1, y1, x2, y2, aRenderer, SVTK_AreaPicker::RectangleMode );
695 else if( theSelectionEvent->myIsPolygon )
696 myPointAreaPicker->Pick( theSelectionEvent->myPolygonPoints, aRenderer, SVTK_AreaPicker::PolygonMode );
698 const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myPointAreaPicker->GetPointIdsMap();
699 SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
700 TColStd_MapOfInteger anIndexes;
701 if(aMapIter != aVectorIdsMap.end()){
702 const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second;
703 vtkIdType anEnd = aVectorIds.size();
704 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
705 int aPointId = aVectorIds[anId];
706 if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
707 int anObjId = GetNodeObjId( aPointId );
708 anIndexes.Add( anObjId );
714 if( !anIndexes.IsEmpty() ) {
715 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
716 mySelector->AddIObject( this );
719 else if ( !anIsShift )
720 mySelector->RemoveIObject( this );
724 case ActorSelection :
727 double* aBounds = GetBounds();
729 bool anIsPicked = true;
730 for( int i = 0; i <= 1; i++ ) {
731 for( int j = 2; j <= 3; j++ ) {
732 for( int k = 4; k <= 5; k++ ) {
733 aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
734 aRenderer->WorldToDisplay();
735 aRenderer->GetDisplayPoint( aPnt );
736 bool anIsPointInSelection;
737 if( theSelectionEvent->myIsRectangle )
738 anIsPointInSelection = aPnt[0] > x1 && aPnt[0] < x2 && aPnt[1] > y1 && aPnt[1] < y2;
739 else if( theSelectionEvent->myIsPolygon )
740 anIsPointInSelection = myPointAreaPicker->isPointInPolygon( QPoint( aPnt[0], aPnt[1] ),
741 theSelectionEvent->myPolygonPoints );
743 if( !anIsPointInSelection ) {
752 if( anIsPicked && mySelector->IsSelected( myIO ) && anIsShift )
753 mySelector->RemoveIObject( this );
754 else if ( anIsPicked ){
755 mySelector->AddIObject( this );
764 case VolumeSelection:
765 case Elem0DSelection:
768 SVTK::TPickLimiter aPickLimiter( myCellAreaPicker, this );
769 if( theSelectionEvent->myIsRectangle )
770 myCellAreaPicker->Pick( x1, y1, x2, y2, aRenderer, SVTK_AreaPicker::RectangleMode );
771 else if( theSelectionEvent->myIsPolygon )
772 myCellAreaPicker->Pick( theSelectionEvent->myPolygonPoints, aRenderer, SVTK_AreaPicker::PolygonMode );
774 const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myCellAreaPicker->GetCellIdsMap();
775 SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
776 TColStd_MapOfInteger anIndexes;
777 if(aMapIter != aVectorIdsMap.end()){
778 const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second;
779 vtkIdType anEnd = aVectorIds.size();
780 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
781 int aCellId = aVectorIds[anId];
782 if ( !mySelector->IsValid( this, aCellId ) )
785 int anObjId = GetElemObjId( aCellId );
787 if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
788 anIndexes.Add(anObjId);
794 if( !anIndexes.IsEmpty() ) {
795 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
796 mySelector->AddIObject( this );
799 else if ( !anIsShift )
800 mySelector->RemoveIObject( this );
808 switch(aSelectionMode){
809 case NodeSelection: {
810 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
811 myPointPicker->Pick( x, y, 0.0, aRenderer );
813 int aVtkId = myPointPicker->GetPointId();
814 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
815 int anObjId = GetNodeObjId( aVtkId );
816 if( hasIO() && anObjId >= 0 ) {
817 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
818 mySelector->AddIObject( this );
826 case VolumeSelection:
827 case Elem0DSelection:
830 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
831 myCellPicker->Pick( x, y, 0.0, aRenderer );
833 int aVtkId = myCellPicker->GetCellId();
834 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
835 int anObjId = GetElemObjId( aVtkId );
837 if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
838 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
839 mySelector->AddIObject( this );
845 case EdgeOfCellSelection:
847 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
848 myCellPicker->Pick( x, y, 0.0, aRenderer );
850 int aVtkId = myCellPicker->GetCellId();
851 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
852 int anObjId = GetElemObjId( aVtkId );
854 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
855 if( hasIO() && anEdgeId < 0 ) {
856 mySelector->AddOrRemoveIndex( myIO, anObjId, false );
857 mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
858 mySelector->AddIObject( this );
864 case ActorSelection :
867 if( mySelector->IsSelected( myIO ) && anIsShift )
868 mySelector->RemoveIObject( this );
870 mySelector->AddIObject( this );
880 mySelectionMode = aSelectionMode;
886 To get flag of displaying of name actor
887 \return flag to display or not to display name actor
891 ::IsDisplayNameActor() const
893 return myIsDisplayNameActor;
897 To set flag of displaying of name actor
898 \param theIsDisplayNameActor flag to display or not to display name actor
902 ::SetIsDisplayNameActor(bool theIsDisplayNameActor)
904 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
905 bool isShowGroupNames = aResourceMgr->booleanValue("VTKViewer", "show_group_names", false);
906 myIsDisplayNameActor = theIsDisplayNameActor && isShowGroupNames;
911 To set text of name actor
912 \param theText - text of name actor
916 ::SetNameActorText(const char* theText)
918 myNameActor->SetText(theText);
922 To set offset of name actor
923 \param theOffset - offset of name actor
927 ::SetNameActorOffset(int theOffset[2])
929 myNameActor->SetOffset(theOffset);
933 To get size of name actor
934 \param theRenderer - renderer
935 \param theSize - size of name actor
939 ::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
941 myNameActor->GetSize(theRenderer, theSize);
945 Update visibility of name actors
951 if( vtkRenderer* aRenderer = GetRenderer() )
953 int anOffset[2] = { 0, 0 };
954 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
955 vtkActorCollection* aCollection = aCopy.GetActors();
956 for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
958 if( SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>( aCollection->GetItemAsObject( anIndex ) ) )
960 if( anActor->IsDisplayNameActor() )
962 anActor->SetNameActorOffset( anOffset );
963 if( anActor->GetVisibility() )
966 anActor->GetNameActorSize( aRenderer, aSize );
967 anOffset[0] = anOffset[0] + aSize[0];
968 anOffset[1] = anOffset[1] + aSize[1];
974 myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() );
978 To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
979 \param thePointPicker - new picker
983 ::SetPointPicker(vtkPointPicker* thePointPicker)
985 myPointPicker = thePointPicker;
989 To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
990 \param theCellPicker - new picker
994 ::SetCellPicker(vtkCellPicker* theCellPicker)
996 myCellPicker = theCellPicker;
1000 To set up a picker for point rectangle or polygonal selection (initialized by SVTK_Renderer::AddActor)
1001 \param theAreaPicker - new picker
1005 ::SetPointAreaPicker(SVTK_AreaPicker* theAreaPicker)
1007 myPointAreaPicker = theAreaPicker;
1011 To set up a picker for cell rectangle of polygonal selection (initialized by SVTK_Renderer::AddActor)
1012 \param theAreaPicker - new picker
1016 ::SetCellAreaPicker(SVTK_AreaPicker* theAreaPicker)
1018 myCellAreaPicker = theAreaPicker;
1022 To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
1026 ::SetPreHighlightProperty(vtkProperty* theProperty)
1028 myPreHighlightActor->SetProperty(theProperty);
1032 To set up a highlight property (initialized by SVTK_Renderer::AddActor)
1036 ::SetHighlightProperty(vtkProperty* theProperty)
1038 myHighlightActor->SetProperty(theProperty);
1042 Set standard point marker
1043 \param theMarkerType type of the marker
1044 \param theMarkerScale scale of the marker
1048 ::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1050 myPreHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1051 myHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1055 Set custom point marker
1056 \param theMarkerId id of the marker texture
1057 \param theMarkerTexture marker texture
1061 ::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1063 myPreHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1064 myHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1068 Get type of the point marker
1069 \return type of the point marker
1075 return myPreHighlightActor->GetMarkerType();
1079 Get scale of the point marker
1080 \return scale of the point marker
1086 return myPreHighlightActor->GetMarkerScale();
1090 Get texture identifier of the point marker
1091 \return texture identifier of the point marker
1095 ::GetMarkerTexture()
1097 return myPreHighlightActor->GetMarkerTexture();