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 <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>
63 #include <vtkInteractorStyle.h>
64 #include <vtkRenderWindowInteractor.h>
65 #include <vtkPassThroughFilter.h>
67 #include <TColStd_MapOfInteger.hxx>
68 #include <TColStd_IndexedMapOfInteger.hxx>
76 int SALOME_POINT_SIZE = 5;
77 int SALOME_LINE_WIDTH = 3;
82 GetEdgeId(SALOME_Actor* theActor,
87 if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
88 double aPickPosition[3];
89 thePicker->GetPickPosition(aPickPosition);
90 double aMinDist = 1000000.0, aDist = 0;
92 for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
93 aSelEdge = aPickedCell->GetEdge(i);
94 if(vtkLine::SafeDownCast(aPickedCell->GetEdge(i)) ||
95 vtkQuadraticEdge::SafeDownCast(aPickedCell->GetEdge(i))){
97 double pcoords[3], closestPoint[3], weights[3];
98 aSelEdge->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
99 if (aDist < aMinDist) {
111 CheckDimensionId(Selection_Mode theMode,
112 SALOME_Actor *theActor,
119 return ( theActor->GetObjDimension( theObjId ) == 1 );
121 return ( theActor->GetObjDimension( theObjId ) == 2 );
122 case VolumeSelection:
123 return ( theActor->GetObjDimension( theObjId ) == 3 );
124 case Elem0DSelection:
125 return ((theActor->GetObjDimension( theObjId ) == 0) &&
126 theActor->GetElemCell(theObjId) &&
127 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_VERTEX));
129 return ((theActor->GetObjDimension( theObjId ) == 0) &&
130 theActor->GetElemCell(theObjId) &&
131 (theActor->GetElemCell(theObjId)->GetCellType() == VTK_POLY_VERTEX));
141 Make picker work with this actor only
143 TPickLimiter::TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
145 myPicker->InitializePickList();
146 myPicker->AddPickList( actor );
147 myPicker->SetPickFromList( true );
152 TPickLimiter::~TPickLimiter()
154 myPicker->SetPickFromList( false );
155 myPicker->InitializePickList();
160 vtkStandardNewMacro(SALOME_Actor);
169 mySelectionMode(ActorSelection),
170 myPreHighlightActor(SVTK_Actor::New()),
171 myHighlightActor(SVTK_Actor::New()),
172 myOutline(vtkOutlineSource::New()),
173 myOutlineActor(VTKViewer_Actor::New()),
174 myIsDisplayNameActor(false),
175 myNameActor(VTKViewer_FramedTextActor::New())
177 myPreHighlightActor->Delete();
178 myPreHighlightActor->Initialize();
179 myPreHighlightActor->PickableOff();
180 myPreHighlightActor->SetVisibility( false );
181 myPreHighlightActor->SetCoincident3DAllowed(true);
183 myHighlightActor->Delete();
184 myHighlightActor->Initialize();
185 myHighlightActor->PickableOff();
186 myHighlightActor->SetVisibility( false );
187 myHighlightActor->SetCoincident3DAllowed(true);
191 vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
192 anOutlineMapper->SetInputConnection(myOutline->GetOutputPort());
194 myOutlineActor->Delete();
195 myOutlineActor->SetMapper( anOutlineMapper );
196 anOutlineMapper->Delete();
198 myOutlineActor->PickableOff();
199 myOutlineActor->DragableOff();
200 myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
201 myOutlineActor->GetProperty()->SetAmbient(1.0);
202 myOutlineActor->GetProperty()->SetDiffuse(0.0);
203 myOutlineActor->SetVisibility( false );
206 myNameActor->Delete();
207 myNameActor->SetVisibility(false);
208 myNameActor->SetPickable(false);
209 myNameActor->SetModePosition(VTKViewer_FramedTextActor::TopRight);
210 myNameActor->SetLayoutType(VTKViewer_FramedTextActor::Vertical);
212 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
214 QColor aForegroundColor = aResourceMgr->colorValue( "VTKViewer", "group_names_text_color", Qt::white );
215 myNameActor->SetForegroundColor(aForegroundColor.redF(),
216 aForegroundColor.greenF(),
217 aForegroundColor.blueF());
219 double aGroupNamesTransparency = 0.5;
220 aGroupNamesTransparency = aResourceMgr->doubleValue( "VTKViewer", "group_names_transparency", aGroupNamesTransparency );
221 myNameActor->SetTransparency(aGroupNamesTransparency);
233 \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
239 return !myIO.IsNull();
243 \return correspoinding reference to SALOME_InteractiveObject
245 const Handle(SALOME_InteractiveObject)&
253 Sets reference to SALOME_InteractiveObject
254 \param theIO - new SALOME_InteractiveObject
258 ::setIO(const Handle(SALOME_InteractiveObject)& theIO)
264 Sets name the SALOME_Actor
265 \param theName - new name
269 ::setName(const char* theName)
272 myIO->setName(theName);
273 myNameActor->SetText(theName);
274 Superclass::setName(theName);
279 Publishes the actor in all its internal devices
283 ::AddToRender(vtkRenderer* theRenderer)
285 Superclass::AddToRender(theRenderer);
287 myRenderer = theRenderer;
289 myHighlightActor->AddToRender(theRenderer);
290 myPreHighlightActor->AddToRender(theRenderer);
291 theRenderer->AddActor( myOutlineActor.GetPointer() );
292 theRenderer->AddActor( myNameActor.GetPointer() );
296 Removes the actor from all its internal devices
300 ::RemoveFromRender(vtkRenderer* theRenderer)
302 Superclass::RemoveFromRender(theRenderer);
304 myHighlightActor->RemoveFromRender(theRenderer);
305 myPreHighlightActor->RemoveFromRender(theRenderer);
307 theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
308 theRenderer->RemoveActor( myHighlightActor.GetPointer() );
309 theRenderer->RemoveActor( myOutlineActor.GetPointer() );
310 theRenderer->RemoveActor( myNameActor.GetPointer() );
314 \return reference on renderer where it is published
324 Sets interactor in order to use vtkInteractorObserver devices
325 \param theInteractor - new interactor
329 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
331 myInteractor = theInteractor;
335 Put a request to redraw the view
341 myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
345 Apply view transformation
346 \param theTransform - transformation
350 ::SetTransform(VTKViewer_Transform* theTransform)
352 Superclass::SetTransform(theTransform);
354 myPreHighlightActor->SetTransform(theTransform);
355 myHighlightActor->SetTransform(theTransform);
356 myOutlineActor->SetTransform(theTransform);
360 Apply additional position
364 ::SetPosition(double _arg1,
368 Superclass::SetPosition(_arg1,_arg2,_arg3);
370 myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
371 myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
372 myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
376 Apply additional position
380 ::SetPosition(double _arg[3])
382 SetPosition(_arg[0],_arg[1],_arg[2]);
387 \param theVisibility - new visibility state
391 ::SetVisibility( int theVisibility )
393 Superclass::SetVisibility( theVisibility );
395 myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
397 myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
399 if(mySelector.GetPointer() && hasIO()){
400 if(mySelector->SelectionMode() != ActorSelection){
401 int aHasIndex = mySelector->HasIndex( getIO() );
402 myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
410 Gets know whether the actor should be displayed or not
414 ::ShouldBeDisplayed()
420 Set selector in order to the actor at any time can restore current selection
421 \param theSelector - new selector
425 ::SetSelector(SVTK_Selector* theSelector)
427 mySelector = theSelector;
431 To map current selection to VTK representation
435 ::Highlight(bool theIsHighlight)
437 mySelectionMode = mySelector->SelectionMode();
438 myHighlightActor->SetVisibility( false );
439 myOutlineActor->SetVisibility( false );
441 if(mySelector.GetPointer()){
442 if(mySelectionMode != ActorSelection){
443 TColStd_IndexedMapOfInteger aMapIndex;
444 mySelector->GetIndex( getIO(), aMapIndex );
445 switch( mySelectionMode ){
447 myHighlightActor->GetProperty()->SetRepresentationToPoints();
448 myHighlightActor->MapPoints( this, aMapIndex );
450 case EdgeOfCellSelection:
451 myHighlightActor->GetProperty()->SetRepresentationToWireframe();
452 myHighlightActor->MapEdge( this, aMapIndex );
457 case VolumeSelection:
458 case Elem0DSelection:
460 myHighlightActor->GetProperty()->SetRepresentationToSurface();
461 myHighlightActor->MapCells( this, aMapIndex );
464 myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
468 highlight(theIsHighlight);
472 Updates visibility of the highlight devices
476 ::highlight(bool theIsHighlight)
479 vtkDataSet * aDataSet = GetHighlightedDataSet();
480 aDataSet->GetBounds(aBounds);
481 myOutline->SetBounds(aBounds);
483 myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
485 Superclass::highlight(theIsHighlight);
490 To process prehighlight (called from SVTK_InteractorStyle)
494 ::PreHighlight(vtkInteractorStyle *theInteractorStyle,
495 SVTK_SelectionEvent* theSelectionEvent,
498 if ( !GetPickable() )
501 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
503 myPreHighlightActor->SetVisibility( false );
504 bool anIsPreselected = myIsPreselected;
505 SetPreSelected( false );
507 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
508 bool anIsChanged = (mySelectionMode != aSelectionMode);
510 myPreHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
512 double x = theSelectionEvent->myX;
513 double y = theSelectionEvent->myY;
516 if( !theIsHighlight ) {
518 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
519 vtkActorCollection* theActors = aCopy.GetActors();
520 theActors->InitTraversal();
521 while( vtkActor *ac = theActors->GetNextActor() )
522 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
523 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
524 anActor->SetPreSelected( false );
527 switch(aSelectionMode) {
530 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
531 myPointPicker->Pick( x, y, z, aRenderer );
533 int aVtkId = myPointPicker->GetPointId();
534 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
535 int anObjId = GetNodeObjId( aVtkId );
536 myIsPreselected = (anObjId >= 0);
538 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
539 int anExtent = aMapIndex.Extent();
540 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
542 TColStd_IndexedMapOfInteger aMapIndex;
543 aMapIndex.Add( anObjId );
545 myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
546 myPreHighlightActor->MapPoints( this, aMapIndex );
548 myPreHighlightActor->SetVisibility( true );
556 case VolumeSelection:
557 case Elem0DSelection:
560 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
561 myCellPicker->Pick( x, y, z, aRenderer );
563 int aVtkId = myCellPicker->GetCellId();
564 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
565 int anObjId = GetElemObjId (aVtkId );
566 if ( anObjId >= 0 ) {
567 myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
569 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
570 int anExtent = aMapIndex.Extent();
571 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
573 TColStd_IndexedMapOfInteger aMapIndex;
574 aMapIndex.Add( anObjId );
576 myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
577 myPreHighlightActor->MapCells( this, aMapIndex );
579 myPreHighlightActor->SetVisibility( true );
585 case EdgeOfCellSelection:
587 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
588 myCellPicker->Pick( x, y, z, aRenderer );
590 int aVtkId = myCellPicker->GetCellId();
591 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
592 int anObjId = GetElemObjId( aVtkId );
593 if ( anObjId >= 0 ) {
594 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
595 myIsPreselected = anEdgeId < 0;
597 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
598 int anExtent = aMapIndex.Extent();
599 anIsChanged |= (anExtent == 0 || anExtent == 1);
600 anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
602 TColStd_IndexedMapOfInteger aMapIndex;
603 aMapIndex.Add( anObjId );
604 aMapIndex.Add( anEdgeId );
606 myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
607 myPreHighlightActor->MapEdge( this, aMapIndex );
609 myPreHighlightActor->SetVisibility( true );
615 case ActorSelection :
617 if( !mySelector->IsSelected( myIO ) ) {
618 SetPreSelected( true );
621 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
622 vtkActorCollection* theActors = aCopy.GetActors();
623 theActors->InitTraversal();
624 while( vtkActor *anAct = theActors->GetNextActor() ) {
626 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
627 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
628 anActor->SetPreSelected( true );
638 mySelectionMode = aSelectionMode;
639 anIsChanged |= (anIsPreselected != myIsPreselected);
645 To process highlight (called from SVTK_InteractorStyle)
649 ::Highlight(vtkInteractorStyle *theInteractorStyle,
650 SVTK_SelectionEvent* theSelectionEvent,
653 if ( !GetPickable() || !mySelector )
656 myOutlineActor->SetVisibility( false );
657 myHighlightActor->SetVisibility( false );
659 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
661 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
662 bool anIsShift = theSelectionEvent->myIsShift;
663 if( !anIsShift || !theIsHighlight ) {
664 mySelector->RemoveIObject( this );
667 if ( !theIsHighlight )
670 myHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
672 double x = theSelectionEvent->myX;
673 double y = theSelectionEvent->myY;
676 if( !theSelectionEvent->myIsRectangle ) {
677 switch(aSelectionMode){
678 case NodeSelection: {
679 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
680 myPointPicker->Pick( x, y, z, aRenderer );
682 int aVtkId = myPointPicker->GetPointId();
683 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
684 int anObjId = GetNodeObjId( aVtkId );
685 if( hasIO() && anObjId >= 0 ) {
686 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
687 mySelector->AddIObject( this );
695 case VolumeSelection:
696 case Elem0DSelection:
699 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
700 myCellPicker->Pick( x, y, z, aRenderer );
702 int aVtkId = myCellPicker->GetCellId();
703 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
704 int anObjId = GetElemObjId( aVtkId );
706 if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
707 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
708 mySelector->AddIObject( this );
714 case EdgeOfCellSelection:
716 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
717 myCellPicker->Pick( x, y, z, aRenderer );
719 int aVtkId = myCellPicker->GetCellId();
720 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
721 int anObjId = GetElemObjId( aVtkId );
723 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
724 if( hasIO() && anEdgeId < 0 ) {
725 mySelector->AddOrRemoveIndex( myIO, anObjId, false );
726 mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
727 mySelector->AddIObject( this );
733 case ActorSelection :
736 if( mySelector->IsSelected( myIO ) && anIsShift )
737 mySelector->RemoveIObject( this );
739 mySelector->AddIObject( this );
748 double xLast = theSelectionEvent->myLastX;
749 double yLast = theSelectionEvent->myLastY;
752 double x1 = x < xLast ? x : xLast;
753 double y1 = y < yLast ? y : yLast;
754 double z1 = z < zLast ? z : zLast;
755 double x2 = x > xLast ? x : xLast;
756 double y2 = y > yLast ? y : yLast;
757 double z2 = z > zLast ? z : zLast;
759 switch(aSelectionMode){
760 case NodeSelection: {
762 SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
763 myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
765 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
766 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
767 TColStd_MapOfInteger anIndexes;
768 if(aMapIter != aVectorIdsMap.end()){
769 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
770 vtkIdType anEnd = aVectorIds.size();
771 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
772 int aPointId = aVectorIds[anId];
773 if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
774 int anObjId = GetNodeObjId( aPointId );
775 anIndexes.Add( anObjId );
781 if( !anIndexes.IsEmpty() ) {
782 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
783 mySelector->AddIObject( this );
786 else if ( !anIsShift )
787 mySelector->RemoveIObject( this );
791 case ActorSelection :
794 double* aBounds = GetBounds();
796 bool anIsPicked = true;
797 for( int i = 0; i <= 1; i++ ) {
798 for( int j = 2; j <= 3; j++ ) {
799 for( int k = 4; k <= 5; k++ ) {
800 aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
801 aRenderer->WorldToDisplay();
802 aRenderer->GetDisplayPoint( aPnt );
804 if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
813 mySelector->AddIObject(this);
820 case VolumeSelection:
821 case Elem0DSelection:
824 SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
825 myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
827 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
828 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
829 TColStd_MapOfInteger anIndexes;
830 if(aMapIter != aVectorIdsMap.end()){
831 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
832 vtkIdType anEnd = aVectorIds.size();
833 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
834 int aCellId = aVectorIds[anId];
835 if ( !mySelector->IsValid( this, aCellId ) )
838 int anObjId = GetElemObjId( aCellId );
840 if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
841 anIndexes.Add(anObjId);
847 if( !anIndexes.IsEmpty() ) {
848 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
849 mySelector->AddIObject( this );
852 else if ( !anIsShift )
853 mySelector->RemoveIObject( this );
861 mySelectionMode = aSelectionMode;
867 To get flag of displaying of name actor
868 \return flag to display or not to display name actor
872 ::IsDisplayNameActor() const
874 return myIsDisplayNameActor;
878 To set flag of displaying of name actor
879 \param theIsDisplayNameActor flag to display or not to display name actor
883 ::SetIsDisplayNameActor(bool theIsDisplayNameActor)
885 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
886 bool isShowGroupNames = aResourceMgr->booleanValue("VTKViewer", "show_group_names", false);
887 myIsDisplayNameActor = theIsDisplayNameActor && isShowGroupNames;
892 To set text of name actor
893 \param theText - text of name actor
897 ::SetNameActorText(const char* theText)
899 myNameActor->SetText(theText);
903 To set offset of name actor
904 \param theOffset - offset of name actor
908 ::SetNameActorOffset(int theOffset[2])
910 myNameActor->SetOffset(theOffset);
914 To get size of name actor
915 \param theRenderer - renderer
916 \param theSize - size of name actor
920 ::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
922 myNameActor->GetSize(theRenderer, theSize);
926 Update visibility of name actors
932 if( vtkRenderer* aRenderer = GetRenderer() )
934 int anOffset[2] = { 0, 0 };
935 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
936 vtkActorCollection* aCollection = aCopy.GetActors();
937 for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
939 if( SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>( aCollection->GetItemAsObject( anIndex ) ) )
941 if( anActor->IsDisplayNameActor() )
943 anActor->SetNameActorOffset( anOffset );
944 if( anActor->GetVisibility() )
947 anActor->GetNameActorSize( aRenderer, aSize );
948 anOffset[0] = anOffset[0] + aSize[0];
949 anOffset[1] = anOffset[1] + aSize[1];
955 myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() );
959 To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
960 \param thePointPicker - new picker
964 ::SetPointPicker(vtkPointPicker* thePointPicker)
966 myPointPicker = thePointPicker;
970 To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
971 \param theCellPicker - new picker
975 ::SetCellPicker(vtkCellPicker* theCellPicker)
977 myCellPicker = theCellPicker;
981 To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
982 \param theRectPicker - new picker
986 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker)
988 myPointRectPicker = theRectPicker;
992 To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
993 \param theRectPicker - new picker
997 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker)
999 myCellRectPicker = theRectPicker;
1003 To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
1007 ::SetPreHighlightProperty(vtkProperty* theProperty)
1009 myPreHighlightActor->SetProperty(theProperty);
1013 To set up a highlight property (initialized by SVTK_Renderer::AddActor)
1017 ::SetHighlightProperty(vtkProperty* theProperty)
1019 myHighlightActor->SetProperty(theProperty);
1023 Set standard point marker
1024 \param theMarkerType type of the marker
1025 \param theMarkerScale scale of the marker
1029 ::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1031 myPreHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1032 myHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1036 Set custom point marker
1037 \param theMarkerId id of the marker texture
1038 \param theMarkerTexture marker texture
1042 ::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1044 myPreHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1045 myHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1049 Get type of the point marker
1050 \return type of the point marker
1056 return myPreHighlightActor->GetMarkerType();
1060 Get scale of the point marker
1061 \return scale of the point marker
1067 return myPreHighlightActor->GetMarkerScale();
1071 Get texture identifier of the point marker
1072 \return texture identifier of the point marker
1076 ::GetMarkerTexture()
1078 return myPreHighlightActor->GetMarkerTexture();