1 // Copyright (C) 2007-2012 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_RectPicker.h"
43 #include "SVTK_Actor.h"
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
51 #include <vtkPicker.h>
52 #include <vtkPointPicker.h>
53 #include <vtkCellPicker.h>
54 #include <vtkRenderer.h>
55 #include <vtkPolyData.h>
56 #include <vtkObjectFactory.h>
57 #include <vtkDataSetMapper.h>
58 #include <vtkPolyDataMapper.h>
59 #include <vtkProperty.h>
60 #include <vtkOutlineSource.h>
62 #include <vtkInteractorStyle.h>
63 #include <vtkRenderWindowInteractor.h>
64 #include <vtkPassThroughFilter.h>
66 #include <TColStd_MapOfInteger.hxx>
67 #include <TColStd_IndexedMapOfInteger.hxx>
75 int SALOME_POINT_SIZE = 5;
76 int SALOME_LINE_WIDTH = 3;
81 GetEdgeId(SALOME_Actor* theActor,
86 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
87 vtkFloatingPointType aPickPosition[3];
88 thePicker->GetPickPosition(aPickPosition);
89 vtkFloatingPointType aMinDist = 1000000.0, aDist = 0;
90 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
91 if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
93 vtkFloatingPointType pcoords[3], closestPoint[3], weights[3];
94 aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
95 if (aDist < aMinDist) {
107 CheckDimensionId(Selection_Mode theMode,
108 SALOME_Actor *theActor,
115 return ( theActor->GetObjDimension( theObjId ) == 1 );
117 return ( theActor->GetObjDimension( theObjId ) == 2 );
118 case VolumeSelection:
119 return ( theActor->GetObjDimension( theObjId ) == 3 );
120 case Elem0DSelection:
121 return ((theActor->GetObjDimension( theObjId ) == 0) &&
122 theActor->GetElemCell(theObjId) &&
123 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_VERTEX));
125 return ((theActor->GetObjDimension( theObjId ) == 0) &&
126 theActor->GetElemCell(theObjId) &&
127 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_POLY_VERTEX));
137 Make picker work with this actor only
139 TPickLimiter::TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
141 myPicker->InitializePickList();
142 myPicker->AddPickList( actor );
143 myPicker->SetPickFromList( true );
148 TPickLimiter::~TPickLimiter()
150 myPicker->SetPickFromList( false );
151 myPicker->InitializePickList();
156 vtkStandardNewMacro(SALOME_Actor);
165 mySelectionMode(ActorSelection),
166 myPreHighlightActor(SVTK_Actor::New()),
167 myHighlightActor(SVTK_Actor::New()),
168 myOutline(vtkOutlineSource::New()),
169 myOutlineActor(VTKViewer_Actor::New()),
170 myIsDisplayNameActor(false),
171 myNameActor(VTKViewer_FramedTextActor::New())
173 myPreHighlightActor->Delete();
174 myPreHighlightActor->Initialize();
175 myPreHighlightActor->PickableOff();
176 myPreHighlightActor->SetVisibility( false );
177 myPreHighlightActor->SetCoincident3DAllowed(true);
179 myHighlightActor->Delete();
180 myHighlightActor->Initialize();
181 myHighlightActor->PickableOff();
182 myHighlightActor->SetVisibility( false );
183 myHighlightActor->SetCoincident3DAllowed(true);
187 vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
188 anOutlineMapper->SetInput(myOutline->GetOutput());
190 myOutlineActor->Delete();
191 myOutlineActor->SetMapper( anOutlineMapper );
192 anOutlineMapper->Delete();
194 myOutlineActor->PickableOff();
195 myOutlineActor->DragableOff();
196 myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
197 myOutlineActor->GetProperty()->SetAmbient(1.0);
198 myOutlineActor->GetProperty()->SetDiffuse(0.0);
199 myOutlineActor->SetVisibility( false );
202 myNameActor->Delete();
203 myNameActor->SetVisibility(false);
204 myNameActor->SetPickable(false);
205 myNameActor->SetModePosition(VTKViewer_FramedTextActor::TopRight);
206 myNameActor->SetLayoutType(VTKViewer_FramedTextActor::Vertical);
208 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
210 QColor aForegroundColor = aResourceMgr->colorValue( "VTKViewer", "group_names_text_color", Qt::white );
211 myNameActor->SetForegroundColor(aForegroundColor.redF(),
212 aForegroundColor.greenF(),
213 aForegroundColor.blueF());
215 vtkFloatingPointType aGroupNamesTransparency = 0.5;
216 aGroupNamesTransparency = aResourceMgr->doubleValue( "VTKViewer", "group_names_transparency", aGroupNamesTransparency );
217 myNameActor->SetTransparency(aGroupNamesTransparency);
229 \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
235 return !myIO.IsNull();
239 \return correspoinding reference to SALOME_InteractiveObject
241 const Handle(SALOME_InteractiveObject)&
249 Sets reference to SALOME_InteractiveObject
250 \param theIO - new SALOME_InteractiveObject
254 ::setIO(const Handle(SALOME_InteractiveObject)& theIO)
260 Sets name the SALOME_Actor
261 \param theName - new name
265 ::setName(const char* theName)
268 myIO->setName(theName);
269 myNameActor->SetText(theName);
270 Superclass::setName(theName);
275 Publishes the actor in all its internal devices
279 ::AddToRender(vtkRenderer* theRenderer)
281 Superclass::AddToRender(theRenderer);
283 myRenderer = theRenderer;
285 myHighlightActor->AddToRender(theRenderer);
286 myPreHighlightActor->AddToRender(theRenderer);
287 theRenderer->AddActor( myOutlineActor.GetPointer() );
288 theRenderer->AddActor( myNameActor.GetPointer() );
292 Removes the actor from all its internal devices
296 ::RemoveFromRender(vtkRenderer* theRenderer)
298 Superclass::RemoveFromRender(theRenderer);
300 myHighlightActor->RemoveFromRender(theRenderer);
301 myPreHighlightActor->RemoveFromRender(theRenderer);
303 theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
304 theRenderer->RemoveActor( myHighlightActor.GetPointer() );
305 theRenderer->RemoveActor( myOutlineActor.GetPointer() );
306 theRenderer->RemoveActor( myNameActor.GetPointer() );
310 \return reference on renderer where it is published
320 Sets interactor in order to use vtkInteractorObserver devices
321 \param theInteractor - new interactor
325 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
327 myInteractor = theInteractor;
331 Put a request to redraw the view
337 myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
341 Apply view transformation
342 \param theTransform - transformation
346 ::SetTransform(VTKViewer_Transform* theTransform)
348 Superclass::SetTransform(theTransform);
350 myPreHighlightActor->SetTransform(theTransform);
351 myHighlightActor->SetTransform(theTransform);
352 myOutlineActor->SetTransform(theTransform);
356 Apply additional position
360 ::SetPosition(vtkFloatingPointType _arg1,
361 vtkFloatingPointType _arg2,
362 vtkFloatingPointType _arg3)
364 Superclass::SetPosition(_arg1,_arg2,_arg3);
366 myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
367 myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
368 myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
372 Apply additional position
376 ::SetPosition(vtkFloatingPointType _arg[3])
378 SetPosition(_arg[0],_arg[1],_arg[2]);
383 \param theVisibility - new visibility state
387 ::SetVisibility( int theVisibility )
389 Superclass::SetVisibility( theVisibility );
391 myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
393 myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
395 if(mySelector.GetPointer() && hasIO()){
396 if(mySelector->SelectionMode() != ActorSelection){
397 int aHasIndex = mySelector->HasIndex( getIO() );
398 myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
406 Gets know whether the actor should be displayed or not
410 ::ShouldBeDisplayed()
416 Set selector in order to the actor at any time can restore current selection
417 \param theSelector - new selector
421 ::SetSelector(SVTK_Selector* theSelector)
423 mySelector = theSelector;
427 To map current selection to VTK representation
431 ::Highlight(bool theIsHighlight)
433 mySelectionMode = mySelector->SelectionMode();
434 myHighlightActor->SetVisibility( false );
435 myOutlineActor->SetVisibility( false );
437 if(mySelector.GetPointer()){
438 if(mySelectionMode != ActorSelection){
439 TColStd_IndexedMapOfInteger aMapIndex;
440 mySelector->GetIndex( getIO(), aMapIndex );
441 switch( mySelectionMode ){
443 myHighlightActor->GetProperty()->SetRepresentationToPoints();
444 myHighlightActor->MapPoints( this, aMapIndex );
446 case EdgeOfCellSelection:
447 myHighlightActor->GetProperty()->SetRepresentationToWireframe();
448 myHighlightActor->MapEdge( this, aMapIndex );
453 case VolumeSelection:
454 case Elem0DSelection:
456 myHighlightActor->GetProperty()->SetRepresentationToSurface();
457 myHighlightActor->MapCells( this, aMapIndex );
460 myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
464 highlight(theIsHighlight);
468 Updates visibility of the highlight devices
472 ::highlight(bool theIsHighlight)
474 vtkFloatingPointType aBounds[6];
475 vtkDataSet * aDataSet = GetHighlightedDataSet();
476 aDataSet->GetBounds(aBounds);
477 myOutline->SetBounds(aBounds);
478 myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
480 Superclass::highlight(theIsHighlight);
485 To process prehighlight (called from SVTK_InteractorStyle)
489 ::PreHighlight(vtkInteractorStyle *theInteractorStyle,
490 SVTK_SelectionEvent* theSelectionEvent,
493 if ( !GetPickable() )
496 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
498 myPreHighlightActor->SetVisibility( false );
499 bool anIsPreselected = myIsPreselected;
500 SetPreSelected( false );
502 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
503 bool anIsChanged = (mySelectionMode != aSelectionMode);
505 myPreHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
507 vtkFloatingPointType x = theSelectionEvent->myX;
508 vtkFloatingPointType y = theSelectionEvent->myY;
509 vtkFloatingPointType z = 0.0;
511 if( !theIsHighlight ) {
513 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
514 vtkActorCollection* theActors = aCopy.GetActors();
515 theActors->InitTraversal();
516 while( vtkActor *ac = theActors->GetNextActor() )
517 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
518 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
519 anActor->SetPreSelected( false );
522 switch(aSelectionMode) {
525 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
526 myPointPicker->Pick( x, y, z, aRenderer );
528 int aVtkId = myPointPicker->GetPointId();
529 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
530 int anObjId = GetNodeObjId( aVtkId );
531 myIsPreselected = (anObjId >= 0);
533 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
534 int anExtent = aMapIndex.Extent();
535 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
537 TColStd_IndexedMapOfInteger aMapIndex;
538 aMapIndex.Add( anObjId );
540 myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
541 myPreHighlightActor->MapPoints( this, aMapIndex );
543 myPreHighlightActor->SetVisibility( true );
551 case VolumeSelection:
552 case Elem0DSelection:
555 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
556 myCellPicker->Pick( x, y, z, aRenderer );
558 int aVtkId = myCellPicker->GetCellId();
559 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
560 int anObjId = GetElemObjId (aVtkId );
561 if ( anObjId >= 0 ) {
562 myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
564 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
565 int anExtent = aMapIndex.Extent();
566 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
568 TColStd_IndexedMapOfInteger aMapIndex;
569 aMapIndex.Add( anObjId );
571 myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
572 myPreHighlightActor->MapCells( this, aMapIndex );
574 myPreHighlightActor->SetVisibility( true );
580 case EdgeOfCellSelection:
582 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
583 myCellPicker->Pick( x, y, z, aRenderer );
585 int aVtkId = myCellPicker->GetCellId();
586 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
587 int anObjId = GetElemObjId( aVtkId );
588 if ( anObjId >= 0 ) {
589 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
590 myIsPreselected = anEdgeId < 0;
592 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
593 int anExtent = aMapIndex.Extent();
594 anIsChanged |= (anExtent == 0 || anExtent == 1);
595 anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
597 TColStd_IndexedMapOfInteger aMapIndex;
598 aMapIndex.Add( anObjId );
599 aMapIndex.Add( anEdgeId );
601 myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
602 myPreHighlightActor->MapEdge( this, aMapIndex );
604 myPreHighlightActor->SetVisibility( true );
610 case ActorSelection :
612 if( !mySelector->IsSelected( myIO ) ) {
613 SetPreSelected( true );
616 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
617 vtkActorCollection* theActors = aCopy.GetActors();
618 theActors->InitTraversal();
619 while( vtkActor *anAct = theActors->GetNextActor() ) {
621 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
622 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
623 anActor->SetPreSelected( true );
633 mySelectionMode = aSelectionMode;
634 anIsChanged |= (anIsPreselected != myIsPreselected);
640 To process highlight (called from SVTK_InteractorStyle)
644 ::Highlight(vtkInteractorStyle *theInteractorStyle,
645 SVTK_SelectionEvent* theSelectionEvent,
648 if ( !GetPickable() || !mySelector )
651 myOutlineActor->SetVisibility( false );
652 myHighlightActor->SetVisibility( false );
654 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
656 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
657 bool anIsShift = theSelectionEvent->myIsShift;
658 if( !anIsShift || !theIsHighlight ) {
659 mySelector->RemoveIObject( this );
662 if ( !theIsHighlight )
665 myHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
667 vtkFloatingPointType x = theSelectionEvent->myX;
668 vtkFloatingPointType y = theSelectionEvent->myY;
669 vtkFloatingPointType z = 0.0;
671 if( !theSelectionEvent->myIsRectangle ) {
672 switch(aSelectionMode){
673 case NodeSelection: {
674 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
675 myPointPicker->Pick( x, y, z, aRenderer );
677 int aVtkId = myPointPicker->GetPointId();
678 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
679 int anObjId = GetNodeObjId( aVtkId );
680 if( hasIO() && anObjId >= 0 ) {
681 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
682 mySelector->AddIObject( this );
690 case VolumeSelection:
691 case Elem0DSelection:
694 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
695 myCellPicker->Pick( x, y, z, aRenderer );
697 int aVtkId = myCellPicker->GetCellId();
698 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
699 int anObjId = GetElemObjId( aVtkId );
701 if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
702 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
703 mySelector->AddIObject( this );
709 case EdgeOfCellSelection:
711 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
712 myCellPicker->Pick( x, y, z, aRenderer );
714 int aVtkId = myCellPicker->GetCellId();
715 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
716 int anObjId = GetElemObjId( aVtkId );
718 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
719 if( hasIO() && anEdgeId < 0 ) {
720 mySelector->AddOrRemoveIndex( myIO, anObjId, false );
721 mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
722 mySelector->AddIObject( this );
728 case ActorSelection :
731 if( mySelector->IsSelected( myIO ) && anIsShift )
732 mySelector->RemoveIObject( this );
734 mySelector->AddIObject( this );
743 vtkFloatingPointType xLast = theSelectionEvent->myLastX;
744 vtkFloatingPointType yLast = theSelectionEvent->myLastY;
745 vtkFloatingPointType zLast = 0.0;
747 vtkFloatingPointType x1 = x < xLast ? x : xLast;
748 vtkFloatingPointType y1 = y < yLast ? y : yLast;
749 vtkFloatingPointType z1 = z < zLast ? z : zLast;
750 vtkFloatingPointType x2 = x > xLast ? x : xLast;
751 vtkFloatingPointType y2 = y > yLast ? y : yLast;
752 vtkFloatingPointType z2 = z > zLast ? z : zLast;
754 switch(aSelectionMode){
755 case NodeSelection: {
757 SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
758 myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
760 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
761 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
762 TColStd_MapOfInteger anIndexes;
763 if(aMapIter != aVectorIdsMap.end()){
764 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
765 vtkIdType anEnd = aVectorIds.size();
766 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
767 int aPointId = aVectorIds[anId];
768 if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
769 int anObjId = GetNodeObjId( aPointId );
770 anIndexes.Add( anObjId );
776 if( !anIndexes.IsEmpty() ) {
777 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
778 mySelector->AddIObject( this );
781 else if ( !anIsShift )
782 mySelector->RemoveIObject( this );
786 case ActorSelection :
788 vtkFloatingPointType aPnt[3];
789 vtkFloatingPointType* aBounds = GetBounds();
791 bool anIsPicked = true;
792 for( int i = 0; i <= 1; i++ ) {
793 for( int j = 2; j <= 3; j++ ) {
794 for( int k = 4; k <= 5; k++ ) {
795 aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
796 aRenderer->WorldToDisplay();
797 aRenderer->GetDisplayPoint( aPnt );
799 if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
808 mySelector->AddIObject(this);
815 case VolumeSelection:
816 case Elem0DSelection:
819 SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
820 myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
822 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
823 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
824 TColStd_MapOfInteger anIndexes;
825 if(aMapIter != aVectorIdsMap.end()){
826 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
827 vtkIdType anEnd = aVectorIds.size();
828 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
829 int aCellId = aVectorIds[anId];
830 if ( !mySelector->IsValid( this, aCellId ) )
833 int anObjId = GetElemObjId( aCellId );
835 if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
836 anIndexes.Add(anObjId);
842 if( !anIndexes.IsEmpty() ) {
843 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
844 mySelector->AddIObject( this );
847 else if ( !anIsShift )
848 mySelector->RemoveIObject( this );
856 mySelectionMode = aSelectionMode;
862 To get flag of displaying of name actor
863 \return flag to display or not to display name actor
867 ::IsDisplayNameActor() const
869 return myIsDisplayNameActor;
873 To set flag of displaying of name actor
874 \param theIsDisplayNameActor flag to display or not to display name actor
878 ::SetIsDisplayNameActor(bool theIsDisplayNameActor)
880 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
881 bool isShowGroupNames = aResourceMgr->booleanValue("VTKViewer", "show_group_names", false);
882 myIsDisplayNameActor = theIsDisplayNameActor && isShowGroupNames;
887 To set text of name actor
888 \param theText - text of name actor
892 ::SetNameActorText(const char* theText)
894 myNameActor->SetText(theText);
898 To set offset of name actor
899 \param theOffset - offset of name actor
903 ::SetNameActorOffset(int theOffset[2])
905 myNameActor->SetOffset(theOffset);
909 To get size of name actor
910 \param theRenderer - renderer
911 \param theSize - size of name actor
915 ::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
917 myNameActor->GetSize(theRenderer, theSize);
921 Update visibility of name actors
927 if( vtkRenderer* aRenderer = GetRenderer() )
929 int anOffset[2] = { 0, 0 };
930 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
931 vtkActorCollection* aCollection = aCopy.GetActors();
932 for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
934 if( SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>( aCollection->GetItemAsObject( anIndex ) ) )
936 if( anActor->IsDisplayNameActor() )
938 anActor->SetNameActorOffset( anOffset );
939 if( anActor->GetVisibility() )
942 anActor->GetNameActorSize( aRenderer, aSize );
943 anOffset[0] = anOffset[0] + aSize[0];
944 anOffset[1] = anOffset[1] + aSize[1];
950 myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() );
954 To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
955 \param thePointPicker - new picker
959 ::SetPointPicker(vtkPointPicker* thePointPicker)
961 myPointPicker = thePointPicker;
965 To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
966 \param theCellPicker - new picker
970 ::SetCellPicker(vtkCellPicker* theCellPicker)
972 myCellPicker = theCellPicker;
976 To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
977 \param theRectPicker - new picker
981 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker)
983 myPointRectPicker = theRectPicker;
987 To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
988 \param theRectPicker - new picker
992 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker)
994 myCellRectPicker = theRectPicker;
998 To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
1002 ::SetPreHighlightProperty(vtkProperty* theProperty)
1004 myPreHighlightActor->SetProperty(theProperty);
1008 To set up a highlight property (initialized by SVTK_Renderer::AddActor)
1012 ::SetHighlightProperty(vtkProperty* theProperty)
1014 myHighlightActor->SetProperty(theProperty);
1018 Set standard point marker
1019 \param theMarkerType type of the marker
1020 \param theMarkerScale scale of the marker
1024 ::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1026 myPreHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1027 myHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1031 Set custom point marker
1032 \param theMarkerId id of the marker texture
1033 \param theMarkerTexture marker texture
1037 ::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1039 myPreHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1040 myHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1044 Get type of the point marker
1045 \return type of the point marker
1051 return myPreHighlightActor->GetMarkerType();
1055 Get scale of the point marker
1056 \return scale of the point marker
1062 return myPreHighlightActor->GetMarkerScale();
1066 Get texture identifier of the point marker
1067 \return texture identifier of the point marker
1071 ::GetMarkerTexture()
1073 return myPreHighlightActor->GetMarkerTexture();