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 );
128 Make picker work with this actor only
130 TPickLimiter::TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
132 myPicker->InitializePickList();
133 myPicker->AddPickList( actor );
134 myPicker->SetPickFromList( true );
139 TPickLimiter::~TPickLimiter()
141 myPicker->SetPickFromList( false );
142 myPicker->InitializePickList();
147 vtkStandardNewMacro(SALOME_Actor);
156 mySelectionMode(ActorSelection),
157 myPreHighlightActor(SVTK_Actor::New()),
158 myHighlightActor(SVTK_Actor::New()),
159 myOutline(vtkOutlineSource::New()),
160 myOutlineActor(VTKViewer_Actor::New()),
161 myIsDisplayNameActor(false),
162 myNameActor(VTKViewer_FramedTextActor::New())
164 myPreHighlightActor->Delete();
165 myPreHighlightActor->Initialize();
166 myPreHighlightActor->PickableOff();
167 myPreHighlightActor->SetVisibility( false );
168 myPreHighlightActor->SetCoincident3DAllowed(true);
170 myHighlightActor->Delete();
171 myHighlightActor->Initialize();
172 myHighlightActor->PickableOff();
173 myHighlightActor->SetVisibility( false );
174 myHighlightActor->SetCoincident3DAllowed(true);
178 vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
179 anOutlineMapper->SetInput(myOutline->GetOutput());
181 myOutlineActor->Delete();
182 myOutlineActor->SetMapper( anOutlineMapper );
183 anOutlineMapper->Delete();
185 myOutlineActor->PickableOff();
186 myOutlineActor->DragableOff();
187 myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
188 myOutlineActor->GetProperty()->SetAmbient(1.0);
189 myOutlineActor->GetProperty()->SetDiffuse(0.0);
190 myOutlineActor->SetVisibility( false );
193 myNameActor->Delete();
194 myNameActor->SetVisibility(false);
195 myNameActor->SetPickable(false);
196 myNameActor->SetModePosition(VTKViewer_FramedTextActor::TopRight);
197 myNameActor->SetLayoutType(VTKViewer_FramedTextActor::Vertical);
199 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
201 QColor aForegroundColor = aResourceMgr->colorValue( "VTKViewer", "group_names_text_color", Qt::white );
202 myNameActor->SetForegroundColor(aForegroundColor.redF(),
203 aForegroundColor.greenF(),
204 aForegroundColor.blueF());
206 vtkFloatingPointType aGroupNamesTransparency = 0.5;
207 aGroupNamesTransparency = aResourceMgr->doubleValue( "VTKViewer", "group_names_transparency", aGroupNamesTransparency );
208 myNameActor->SetTransparency(aGroupNamesTransparency);
220 \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
226 return !myIO.IsNull();
230 \return correspoinding reference to SALOME_InteractiveObject
232 const Handle(SALOME_InteractiveObject)&
240 Sets reference to SALOME_InteractiveObject
241 \param theIO - new SALOME_InteractiveObject
245 ::setIO(const Handle(SALOME_InteractiveObject)& theIO)
251 Sets name the SALOME_Actor
252 \param theName - new name
256 ::setName(const char* theName)
259 myIO->setName(theName);
260 myNameActor->SetText(theName);
261 Superclass::setName(theName);
266 Publishes the actor in all its internal devices
270 ::AddToRender(vtkRenderer* theRenderer)
272 Superclass::AddToRender(theRenderer);
274 myRenderer = theRenderer;
276 theRenderer->AddActor( myPreHighlightActor.GetPointer() );
277 theRenderer->AddActor( myHighlightActor.GetPointer() );
278 theRenderer->AddActor( myOutlineActor.GetPointer() );
279 theRenderer->AddActor( myNameActor.GetPointer() );
283 Removes the actor from all its internal devices
287 ::RemoveFromRender(vtkRenderer* theRenderer)
289 Superclass::RemoveFromRender(theRenderer);
291 theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
292 theRenderer->RemoveActor( myHighlightActor.GetPointer() );
293 theRenderer->RemoveActor( myOutlineActor.GetPointer() );
294 theRenderer->RemoveActor( myNameActor.GetPointer() );
298 \return reference on renderer where it is published
308 Sets interactor in order to use vtkInteractorObserver devices
309 \param theInteractor - new interactor
313 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
315 myInteractor = theInteractor;
319 Put a request to redraw the view
325 myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
329 Apply view transformation
330 \param theTransform - transformation
334 ::SetTransform(VTKViewer_Transform* theTransform)
336 Superclass::SetTransform(theTransform);
338 myPreHighlightActor->SetTransform(theTransform);
339 myHighlightActor->SetTransform(theTransform);
340 myOutlineActor->SetTransform(theTransform);
344 Apply additional position
348 ::SetPosition(vtkFloatingPointType _arg1,
349 vtkFloatingPointType _arg2,
350 vtkFloatingPointType _arg3)
352 Superclass::SetPosition(_arg1,_arg2,_arg3);
354 myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
355 myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
356 myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
360 Apply additional position
364 ::SetPosition(vtkFloatingPointType _arg[3])
366 SetPosition(_arg[0],_arg[1],_arg[2]);
371 \param theVisibility - new visibility state
375 ::SetVisibility( int theVisibility )
377 Superclass::SetVisibility( theVisibility );
379 myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
381 myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
383 if(mySelector.GetPointer() && hasIO()){
384 if(mySelector->SelectionMode() != ActorSelection){
385 int aHasIndex = mySelector->HasIndex( getIO() );
386 myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
394 Gets know whether the actor should be displayed or not
398 ::ShouldBeDisplayed()
404 Set selector in order to the actor at any time can restore current selection
405 \param theSelector - new selector
409 ::SetSelector(SVTK_Selector* theSelector)
411 mySelector = theSelector;
415 To map current selection to VTK representation
419 ::Highlight(bool theIsHighlight)
421 mySelectionMode = mySelector->SelectionMode();
422 myHighlightActor->SetVisibility( false );
423 myOutlineActor->SetVisibility( false );
425 if(mySelector.GetPointer()){
426 if(mySelectionMode != ActorSelection){
427 TColStd_IndexedMapOfInteger aMapIndex;
428 mySelector->GetIndex( getIO(), aMapIndex );
429 switch( mySelectionMode ){
431 myHighlightActor->GetProperty()->SetRepresentationToPoints();
432 myHighlightActor->MapPoints( this, aMapIndex );
434 case EdgeOfCellSelection:
435 myHighlightActor->GetProperty()->SetRepresentationToWireframe();
436 myHighlightActor->MapEdge( this, aMapIndex );
441 case VolumeSelection:
442 myHighlightActor->GetProperty()->SetRepresentationToSurface();
443 myHighlightActor->MapCells( this, aMapIndex );
446 myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
450 highlight(theIsHighlight);
454 Updates visibility of the highlight devices
458 ::highlight(bool theIsHighlight)
460 vtkFloatingPointType aBounds[6];
461 vtkDataSet * aDataSet = GetHighlightedDataSet();
462 aDataSet->GetBounds(aBounds);
463 myOutline->SetBounds(aBounds);
464 myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
466 Superclass::highlight(theIsHighlight);
471 To process prehighlight (called from SVTK_InteractorStyle)
475 ::PreHighlight(vtkInteractorStyle *theInteractorStyle,
476 SVTK_SelectionEvent* theSelectionEvent,
479 if ( !GetPickable() )
482 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
484 myPreHighlightActor->SetVisibility( false );
485 bool anIsPreselected = myIsPreselected;
486 SetPreSelected( false );
488 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
489 bool anIsChanged = (mySelectionMode != aSelectionMode);
491 myPreHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
493 vtkFloatingPointType x = theSelectionEvent->myX;
494 vtkFloatingPointType y = theSelectionEvent->myY;
495 vtkFloatingPointType z = 0.0;
497 if( !theIsHighlight ) {
499 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
500 vtkActorCollection* theActors = aCopy.GetActors();
501 theActors->InitTraversal();
502 while( vtkActor *ac = theActors->GetNextActor() )
503 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
504 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
505 anActor->SetPreSelected( false );
508 switch(aSelectionMode) {
511 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
512 myPointPicker->Pick( x, y, z, aRenderer );
514 int aVtkId = myPointPicker->GetPointId();
515 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
516 int anObjId = GetNodeObjId( aVtkId );
517 myIsPreselected = (anObjId >= 0);
519 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
520 int anExtent = aMapIndex.Extent();
521 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
523 TColStd_IndexedMapOfInteger aMapIndex;
524 aMapIndex.Add( anObjId );
526 myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
527 myPreHighlightActor->MapPoints( this, aMapIndex );
529 myPreHighlightActor->SetVisibility( true );
537 case VolumeSelection:
539 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
540 myCellPicker->Pick( x, y, z, aRenderer );
542 int aVtkId = myCellPicker->GetCellId();
543 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
544 int anObjId = GetElemObjId (aVtkId );
545 if ( anObjId >= 0 ) {
546 myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
548 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
549 int anExtent = aMapIndex.Extent();
550 anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1)));
552 TColStd_IndexedMapOfInteger aMapIndex;
553 aMapIndex.Add( anObjId );
555 myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
556 myPreHighlightActor->MapCells( this, aMapIndex );
558 myPreHighlightActor->SetVisibility( true );
564 case EdgeOfCellSelection:
566 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
567 myCellPicker->Pick( x, y, z, aRenderer );
569 int aVtkId = myCellPicker->GetCellId();
570 if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
571 int anObjId = GetElemObjId( aVtkId );
572 if ( anObjId >= 0 ) {
573 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
574 myIsPreselected = anEdgeId < 0;
576 const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
577 int anExtent = aMapIndex.Extent();
578 anIsChanged |= (anExtent == 0 || anExtent == 1);
579 anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
581 TColStd_IndexedMapOfInteger aMapIndex;
582 aMapIndex.Add( anObjId );
583 aMapIndex.Add( anEdgeId );
585 myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
586 myPreHighlightActor->MapEdge( this, aMapIndex );
588 myPreHighlightActor->SetVisibility( true );
594 case ActorSelection :
596 if( !mySelector->IsSelected( myIO ) ) {
597 SetPreSelected( true );
600 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
601 vtkActorCollection* theActors = aCopy.GetActors();
602 theActors->InitTraversal();
603 while( vtkActor *anAct = theActors->GetNextActor() ) {
605 if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
606 if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
607 anActor->SetPreSelected( true );
617 mySelectionMode = aSelectionMode;
618 anIsChanged |= (anIsPreselected != myIsPreselected);
624 To process highlight (called from SVTK_InteractorStyle)
628 ::Highlight(vtkInteractorStyle *theInteractorStyle,
629 SVTK_SelectionEvent* theSelectionEvent,
632 if ( !GetPickable() || !mySelector )
635 myOutlineActor->SetVisibility( false );
636 myHighlightActor->SetVisibility( false );
638 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
640 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
641 bool anIsShift = theSelectionEvent->myIsShift;
642 if( !anIsShift || !theIsHighlight ) {
643 mySelector->RemoveIObject( this );
646 if ( !theIsHighlight )
649 myHighlightActor->SetMarkerEnabled( aSelectionMode == NodeSelection );
651 vtkFloatingPointType x = theSelectionEvent->myX;
652 vtkFloatingPointType y = theSelectionEvent->myY;
653 vtkFloatingPointType z = 0.0;
655 if( !theSelectionEvent->myIsRectangle ) {
656 switch(aSelectionMode){
657 case NodeSelection: {
658 SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
659 myPointPicker->Pick( x, y, z, aRenderer );
661 int aVtkId = myPointPicker->GetPointId();
662 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
663 int anObjId = GetNodeObjId( aVtkId );
664 if( hasIO() && anObjId >= 0 ) {
665 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
666 mySelector->AddIObject( this );
674 case VolumeSelection:
676 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
677 myCellPicker->Pick( x, y, z, aRenderer );
679 int aVtkId = myCellPicker->GetCellId();
680 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
681 int anObjId = GetElemObjId( aVtkId );
683 if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) {
684 mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift );
685 mySelector->AddIObject( this );
691 case EdgeOfCellSelection:
693 SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
694 myCellPicker->Pick( x, y, z, aRenderer );
696 int aVtkId = myCellPicker->GetCellId();
697 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
698 int anObjId = GetElemObjId( aVtkId );
700 int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
701 if( hasIO() && anEdgeId < 0 ) {
702 mySelector->AddOrRemoveIndex( myIO, anObjId, false );
703 mySelector->AddOrRemoveIndex( myIO, anEdgeId, true );
704 mySelector->AddIObject( this );
710 case ActorSelection :
713 if( mySelector->IsSelected( myIO ) && anIsShift )
714 mySelector->RemoveIObject( this );
716 mySelector->AddIObject( this );
725 vtkFloatingPointType xLast = theSelectionEvent->myLastX;
726 vtkFloatingPointType yLast = theSelectionEvent->myLastY;
727 vtkFloatingPointType zLast = 0.0;
729 vtkFloatingPointType x1 = x < xLast ? x : xLast;
730 vtkFloatingPointType y1 = y < yLast ? y : yLast;
731 vtkFloatingPointType z1 = z < zLast ? z : zLast;
732 vtkFloatingPointType x2 = x > xLast ? x : xLast;
733 vtkFloatingPointType y2 = y > yLast ? y : yLast;
734 vtkFloatingPointType z2 = z > zLast ? z : zLast;
736 switch(aSelectionMode){
737 case NodeSelection: {
739 SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
740 myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
742 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
743 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
744 TColStd_MapOfInteger anIndexes;
745 if(aMapIter != aVectorIdsMap.end()){
746 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
747 vtkIdType anEnd = aVectorIds.size();
748 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
749 int aPointId = aVectorIds[anId];
750 if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
751 int anObjId = GetNodeObjId( aPointId );
752 anIndexes.Add( anObjId );
758 if( !anIndexes.IsEmpty() ) {
759 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
760 mySelector->AddIObject( this );
763 else if ( !anIsShift )
764 mySelector->RemoveIObject( this );
768 case ActorSelection :
770 vtkFloatingPointType aPnt[3];
771 vtkFloatingPointType* aBounds = GetBounds();
773 bool anIsPicked = true;
774 for( int i = 0; i <= 1; i++ ) {
775 for( int j = 2; j <= 3; j++ ) {
776 for( int k = 4; k <= 5; k++ ) {
777 aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
778 aRenderer->WorldToDisplay();
779 aRenderer->GetDisplayPoint( aPnt );
781 if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
790 mySelector->AddIObject(this);
797 case VolumeSelection:
799 SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
800 myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
802 const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
803 SVTK_RectPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this);
804 TColStd_MapOfInteger anIndexes;
805 if(aMapIter != aVectorIdsMap.end()){
806 const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
807 vtkIdType anEnd = aVectorIds.size();
808 for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
809 int aCellId = aVectorIds[anId];
810 if ( !mySelector->IsValid( this, aCellId ) )
813 int anObjId = GetElemObjId( aCellId );
815 if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
816 anIndexes.Add(anObjId);
822 if( !anIndexes.IsEmpty() ) {
823 mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift );
824 mySelector->AddIObject( this );
827 else if ( !anIsShift )
828 mySelector->RemoveIObject( this );
836 mySelectionMode = aSelectionMode;
842 To get flag of displaying of name actor
843 \return flag to display or not to display name actor
847 ::IsDisplayNameActor() const
849 return myIsDisplayNameActor;
853 To set flag of displaying of name actor
854 \param theIsDisplayNameActor flag to display or not to display name actor
858 ::SetIsDisplayNameActor(bool theIsDisplayNameActor)
860 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
861 bool isShowGroupNames = aResourceMgr->booleanValue("VTKViewer", "show_group_names", false);
862 myIsDisplayNameActor = theIsDisplayNameActor && isShowGroupNames;
867 To set text of name actor
868 \param theText - text of name actor
872 ::SetNameActorText(const char* theText)
874 myNameActor->SetText(theText);
878 To set offset of name actor
879 \param theOffset - offset of name actor
883 ::SetNameActorOffset(int theOffset[2])
885 myNameActor->SetOffset(theOffset);
889 To get size of name actor
890 \param theRenderer - renderer
891 \param theSize - size of name actor
895 ::GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const
897 myNameActor->GetSize(theRenderer, theSize);
901 Update visibility of name actors
907 if( vtkRenderer* aRenderer = GetRenderer() )
909 int anOffset[2] = { 0, 0 };
910 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
911 vtkActorCollection* aCollection = aCopy.GetActors();
912 for( int anIndex = 0, aNbItems = aCollection->GetNumberOfItems(); anIndex < aNbItems; anIndex++ )
914 if( SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>( aCollection->GetItemAsObject( anIndex ) ) )
916 if( anActor->IsDisplayNameActor() )
918 anActor->SetNameActorOffset( anOffset );
919 if( anActor->GetVisibility() )
922 anActor->GetNameActorSize( aRenderer, aSize );
923 anOffset[0] = anOffset[0] + aSize[0];
924 anOffset[1] = anOffset[1] + aSize[1];
930 myNameActor->SetVisibility( GetVisibility() && IsDisplayNameActor() );
934 To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
935 \param thePointPicker - new picker
939 ::SetPointPicker(vtkPointPicker* thePointPicker)
941 myPointPicker = thePointPicker;
945 To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
946 \param theCellPicker - new picker
950 ::SetCellPicker(vtkCellPicker* theCellPicker)
952 myCellPicker = theCellPicker;
956 To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
957 \param theRectPicker - new picker
961 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker)
963 myPointRectPicker = theRectPicker;
967 To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
968 \param theRectPicker - new picker
972 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker)
974 myCellRectPicker = theRectPicker;
978 To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
982 ::SetPreHighlightProperty(vtkProperty* theProperty)
984 myPreHighlightActor->SetProperty(theProperty);
988 To set up a highlight property (initialized by SVTK_Renderer::AddActor)
992 ::SetHighlightProperty(vtkProperty* theProperty)
994 myHighlightActor->SetProperty(theProperty);
998 Set standard point marker
999 \param theMarkerType type of the marker
1000 \param theMarkerScale scale of the marker
1004 ::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
1006 myPreHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1007 myHighlightActor->SetMarkerStd( theMarkerType, theMarkerScale );
1011 Set custom point marker
1012 \param theMarkerId id of the marker texture
1013 \param theMarkerTexture marker texture
1017 ::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
1019 myPreHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1020 myHighlightActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
1024 Get type of the point marker
1025 \return type of the point marker
1031 return myPreHighlightActor->GetMarkerType();
1035 Get scale of the point marker
1036 \return scale of the point marker
1042 return myPreHighlightActor->GetMarkerScale();
1046 Get texture identifier of the point marker
1047 \return texture identifier of the point marker
1051 ::GetMarkerTexture()
1053 return myPreHighlightActor->GetMarkerTexture();