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_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 double aPickPosition[3];
88 thePicker->GetPickPosition(aPickPosition);
89 double 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 double 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->SetInputConnection(myOutline->GetOutputPort());
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 double 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(double _arg1,
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(double _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)
475 vtkDataSet * aDataSet = GetHighlightedDataSet();
476 aDataSet->GetBounds(aBounds);
477 myOutline->SetBounds(aBounds);
479 myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
481 Superclass::highlight(theIsHighlight);
486 To process prehighlight (called from SVTK_InteractorStyle)
490 ::PreHighlight(vtkInteractorStyle *theInteractorStyle,
491 SVTK_SelectionEvent* theSelectionEvent,
494 if ( !GetPickable() )
497 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
499 myPreHighlightActor->SetVisibility( false );
500 bool anIsPreselected = myIsPreselected;
501 SetPreSelected( false );
503 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
504 bool anIsChanged = (mySelectionMode != aSelectionMode);
506 myPreHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
508 double x = theSelectionEvent->myX;
509 double y = theSelectionEvent->myY;
512 if( !theIsHighlight ) {
514 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
515 vtkActorCollection* theActors = aCopy.GetActors();
516 theActors->InitTraversal();
517 while( vtkActor *ac = theActors->GetNextActor() )
518 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
519 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
520 anActor->SetPreSelected( false );
523 switch(aSelectionMode) {
526 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
527 myPointPicker->Pick( x, y, z, aRenderer );
529 int aVtkId = myPointPicker->GetPointId();
530 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
531 int anObjId = GetNodeObjId( aVtkId );
532 myIsPreselected = (anObjId >= 0);
534 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
535 int anExtent = aMapIndex.Extent();
536 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
538 TColStd_IndexedMapOfInteger aMapIndex;
539 aMapIndex.Add( anObjId );
541 myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
542 myPreHighlightActor->MapPoints( this, aMapIndex );
544 myPreHighlightActor->SetVisibility( true );
552 case VolumeSelection:
553 case Elem0DSelection:
556 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
557 myCellPicker->Pick( x, y, z, aRenderer );
559 int aVtkId = myCellPicker->GetCellId();
560 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
561 int anObjId = GetElemObjId (aVtkId );
562 if ( anObjId >= 0 ) {
563 myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
565 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
566 int anExtent = aMapIndex.Extent();
567 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
569 TColStd_IndexedMapOfInteger aMapIndex;
570 aMapIndex.Add( anObjId );
572 myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
573 myPreHighlightActor->MapCells( this, aMapIndex );
575 myPreHighlightActor->SetVisibility( true );
581 case EdgeOfCellSelection:
583 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
584 myCellPicker->Pick( x, y, z, aRenderer );
586 int aVtkId = myCellPicker->GetCellId();
587 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
588 int anObjId = GetElemObjId( aVtkId );
589 if ( anObjId >= 0 ) {
590 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
591 myIsPreselected = anEdgeId < 0;
593 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
594 int anExtent = aMapIndex.Extent();
595 anIsChanged |= (anExtent == 0 || anExtent == 1);
596 anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
598 TColStd_IndexedMapOfInteger aMapIndex;
599 aMapIndex.Add( anObjId );
600 aMapIndex.Add( anEdgeId );
602 myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
603 myPreHighlightActor->MapEdge( this, aMapIndex );
605 myPreHighlightActor->SetVisibility( true );
611 case ActorSelection :
613 if( !mySelector->IsSelected( myIO ) ) {
614 SetPreSelected( true );
617 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
618 vtkActorCollection* theActors = aCopy.GetActors();
619 theActors->InitTraversal();
620 while( vtkActor *anAct = theActors->GetNextActor() ) {
622 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
623 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
624 anActor->SetPreSelected( true );
634 mySelectionMode = aSelectionMode;
635 anIsChanged |= (anIsPreselected != myIsPreselected);
641 To process highlight (called from SVTK_InteractorStyle)
645 ::Highlight(vtkInteractorStyle *theInteractorStyle,
646 SVTK_SelectionEvent* theSelectionEvent,
649 if ( !GetPickable() || !mySelector )
652 myOutlineActor->SetVisibility( false );
653 myHighlightActor->SetVisibility( false );
655 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
657 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
658 bool anIsShift = theSelectionEvent->myIsShift;
659 if( !anIsShift || !theIsHighlight ) {
660 mySelector->RemoveIObject( this );
663 if ( !theIsHighlight )
666 myHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
668 double x = theSelectionEvent->myX;
669 double y = theSelectionEvent->myY;
672 if( !theSelectionEvent->myIsRectangle ) {
673 switch(aSelectionMode){
674 case NodeSelection: {
675 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
676 myPointPicker->Pick( x, y, z, aRenderer );
678 int aVtkId = myPointPicker->GetPointId();
679 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
680 int anObjId = GetNodeObjId( aVtkId );
681 if( hasIO() && anObjId >= 0 ) {
682 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
683 mySelector->AddIObject( this );
691 case VolumeSelection:
692 case Elem0DSelection:
695 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
696 myCellPicker->Pick( x, y, z, aRenderer );
698 int aVtkId = myCellPicker->GetCellId();
699 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
700 int anObjId = GetElemObjId( aVtkId );
702 if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
703 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
704 mySelector->AddIObject( this );
710 case EdgeOfCellSelection:
712 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
713 myCellPicker->Pick( x, y, z, aRenderer );
715 int aVtkId = myCellPicker->GetCellId();
716 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
717 int anObjId = GetElemObjId( aVtkId );
719 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
720 if( hasIO() && anEdgeId < 0 ) {
721 mySelector->AddOrRemoveIndex( myIO, anObjId, false );
722 mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
723 mySelector->AddIObject( this );
729 case ActorSelection :
732 if( mySelector->IsSelected( myIO ) && anIsShift )
733 mySelector->RemoveIObject( this );
735 mySelector->AddIObject( this );
744 double xLast = theSelectionEvent->myLastX;
745 double yLast = theSelectionEvent->myLastY;
748 double x1 = x < xLast ? x : xLast;
749 double y1 = y < yLast ? y : yLast;
750 double z1 = z < zLast ? z : zLast;
751 double x2 = x > xLast ? x : xLast;
752 double y2 = y > yLast ? y : yLast;
753 double z2 = z > zLast ? z : zLast;
755 switch(aSelectionMode){
756 case NodeSelection: {
758 SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
759 myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
761 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
762 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
763 TColStd_MapOfInteger anIndexes;
764 if(aMapIter != aVectorIdsMap.end()){
765 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
766 vtkIdType anEnd = aVectorIds.size();
767 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
768 int aPointId = aVectorIds[anId];
769 if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
770 int anObjId = GetNodeObjId( aPointId );
771 anIndexes.Add( anObjId );
777 if( !anIndexes.IsEmpty() ) {
778 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
779 mySelector->AddIObject( this );
782 else if ( !anIsShift )
783 mySelector->RemoveIObject( this );
787 case ActorSelection :
790 double* aBounds = GetBounds();
792 bool anIsPicked = true;
793 for( int i = 0; i <= 1; i++ ) {
794 for( int j = 2; j <= 3; j++ ) {
795 for( int k = 4; k <= 5; k++ ) {
796 aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
797 aRenderer->WorldToDisplay();
798 aRenderer->GetDisplayPoint( aPnt );
800 if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
809 mySelector->AddIObject(this);
816 case VolumeSelection:
817 case Elem0DSelection:
820 SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
821 myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
823 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
824 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
825 TColStd_MapOfInteger anIndexes;
826 if(aMapIter != aVectorIdsMap.end()){
827 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
828 vtkIdType anEnd = aVectorIds.size();
829 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
830 int aCellId = aVectorIds[anId];
831 if ( !mySelector->IsValid( this, aCellId ) )
834 int anObjId = GetElemObjId( aCellId );
836 if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
837 anIndexes.Add(anObjId);
843 if( !anIndexes.IsEmpty() ) {
844 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
845 mySelector->AddIObject( this );
848 else if ( !anIsShift )
849 mySelector->RemoveIObject( this );
857 mySelectionMode = aSelectionMode;
863 To get flag of displaying of name actor
864 \return flag to display or not to display name actor
868 ::IsDisplayNameActor() const
870 return myIsDisplayNameActor;
874 To set flag of displaying of name actor
875 \param theIsDisplayNameActor flag to display or not to display name actor
879 ::SetIsDisplayNameActor(bool theIsDisplayNameActor)
881 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
882 bool isShowGroupNames = aResourceMgr->booleanValue("VTKViewer", "show_group_names", false);
883 myIsDisplayNameActor = theIsDisplayNameActor && isShowGroupNames;
888 To set text of name actor
889 \param theText - text of name actor
893 ::SetNameActorText(const char* theText)
895 myNameActor->SetText(theText);
899 To set offset of name actor
900 \param theOffset - offset of name actor
904 ::SetNameActorOffset(int theOffset[2])
906 myNameActor->SetOffset(theOffset);
910 To get size of name actor
911 \param theRenderer - renderer
912 \param theSize - size of name actor
916 ::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
918 myNameActor->GetSize(theRenderer, theSize);
922 Update visibility of name actors
928 if( vtkRenderer* aRenderer = GetRenderer() )
930 int anOffset[2] = { 0, 0 };
931 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
932 vtkActorCollection* aCollection = aCopy.GetActors();
933 for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
935 if( SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>( aCollection->GetItemAsObject( anIndex ) ) )
937 if( anActor->IsDisplayNameActor() )
939 anActor->SetNameActorOffset( anOffset );
940 if( anActor->GetVisibility() )
943 anActor->GetNameActorSize( aRenderer, aSize );
944 anOffset[0] = anOffset[0] + aSize[0];
945 anOffset[1] = anOffset[1] + aSize[1];
951 myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() );
955 To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
956 \param thePointPicker - new picker
960 ::SetPointPicker(vtkPointPicker* thePointPicker)
962 myPointPicker = thePointPicker;
966 To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
967 \param theCellPicker - new picker
971 ::SetCellPicker(vtkCellPicker* theCellPicker)
973 myCellPicker = theCellPicker;
977 To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
978 \param theRectPicker - new picker
982 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker)
984 myPointRectPicker = theRectPicker;
988 To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
989 \param theRectPicker - new picker
993 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker)
995 myCellRectPicker = theRectPicker;
999 To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
1003 ::SetPreHighlightProperty(vtkProperty* theProperty)
1005 myPreHighlightActor->SetProperty(theProperty);
1009 To set up a highlight property (initialized by SVTK_Renderer::AddActor)
1013 ::SetHighlightProperty(vtkProperty* theProperty)
1015 myHighlightActor->SetProperty(theProperty);
1019 Set standard point marker
1020 \param theMarkerType type of the marker
1021 \param theMarkerScale scale of the marker
1025 ::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1027 myPreHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1028 myHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1032 Set custom point marker
1033 \param theMarkerId id of the marker texture
1034 \param theMarkerTexture marker texture
1038 ::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1040 myPreHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1041 myHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1045 Get type of the point marker
1046 \return type of the point marker
1052 return myPreHighlightActor->GetMarkerType();
1056 Get scale of the point marker
1057 \return scale of the point marker
1063 return myPreHighlightActor->GetMarkerScale();
1067 Get texture identifier of the point marker
1068 \return texture identifier of the point marker
1072 ::GetMarkerTexture()
1074 return myPreHighlightActor->GetMarkerTexture();