From: apo Date: Mon, 19 Sep 2005 11:46:44 +0000 (+0000) Subject: To improve SALOME_Actor interface X-Git-Tag: BR-D5-38-2003_D2005-12-10~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87d49c5fd6536814a441e80848cbe1a5ff535a23;p=modules%2Fgui.git To improve SALOME_Actor interface --- diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 2c427b5c8..67f033ed1 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -73,6 +73,35 @@ using namespace std; #endif int SALOME_POINT_SIZE = 3; +int SALOME_LINE_WIDTH = 2; + +//---------------------------------------------------------------------------- +namespace +{ + int + GetEdgeId(SALOME_Actor* theActor, + vtkPicker* thePicker, + int theObjId) + { + int anEdgeId = -1; + if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) { + float aPickPosition[3]; + thePicker->GetPickPosition(aPickPosition); + float aMinDist = 1000000.0, aDist = 0; + for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){ + if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){ + int subId; float pcoords[3], closestPoint[3], weights[3]; + aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); + if (aDist < aMinDist) { + aMinDist = aDist; + anEdgeId = i; + } + } + } + } + return anEdgeId; + } +} //---------------------------------------------------------------------------- @@ -103,45 +132,51 @@ SALOME_Actor for(int i = 0; i < 6; i++) myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); - // from VISU myPointPicker = vtkPointPicker::New(); + myPointPicker->Delete(); + myCellPicker = vtkCellPicker::New(); - myCellRectPicker = VTKViewer_CellRectPicker::New(); + myCellPicker->Delete(); - myPreHighlightActor = SVTK_Actor::New(); - myPreHighlightActor->GetProperty()->SetColor(0,1,1); - myPreHighlightActor->GetProperty()->SetPointSize(5); - myPreHighlightActor->GetProperty()->SetRepresentationToPoints(); + myCellRectPicker = VTKViewer_CellRectPicker::New(); + myCellRectPicker->Delete(); - myPointProperty = vtkProperty::New(); - myPointProperty->SetColor(1,1,0); - myPointProperty->SetPointSize(5); - myPointProperty->SetRepresentationToPoints(); + myPreHighlightProperty = vtkProperty::New(); + myPreHighlightProperty->Delete(); + myPreHighlightProperty->SetColor(0,1,1); + myPreHighlightProperty->SetPointSize(SALOME_POINT_SIZE); + myPreHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH); + myPreHighlightProperty->SetRepresentationToPoints(); - myCellProperty = vtkProperty::New(); - myCellProperty->SetColor(1,1,0); - myCellProperty->SetPointSize(5); - myCellProperty->SetRepresentationToSurface(); + myPreHighlightActor = SVTK_Actor::New(); + myPreHighlightActor->Delete(); + myPreHighlightActor->SetProperty(myPreHighlightProperty.GetPointer()); + myPreHighlightActor->SetVisibility( false ); - myEdgeProperty = vtkProperty::New(); - myEdgeProperty->SetColor(1,0,0); - myEdgeProperty->SetPointSize(5); - myEdgeProperty->SetRepresentationToWireframe(); + myHighlightProperty = vtkProperty::New(); + myHighlightProperty->Delete(); + myHighlightProperty->SetColor(1,1,0); + myHighlightProperty->SetPointSize(SALOME_POINT_SIZE); + myHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH); + myHighlightProperty->SetRepresentationToPoints(); myHighlightActor = SVTK_Actor::New(); myHighlightActor->PickableOff(); - myHighlightActor->SetProperty( myPointProperty ); - + myHighlightActor->SetProperty(myHighlightProperty.GetPointer()); + myHighlightActor->SetVisibility( false ); myOutline = vtkOutlineSource::New(); + myOutline->Delete(); myOutlineMapper = vtkPolyDataMapper::New(); - myOutlineMapper->SetInput( myOutline->GetOutput() ); + myOutlineMapper->Delete(); + myOutlineMapper->SetInput(myOutline->GetOutput()); myOutlineActor = vtkActor::New(); + myOutlineActor->Delete(); myOutlineActor->PickableOff(); myOutlineActor->DragableOff(); - myOutlineActor->SetMapper( myOutlineMapper ); + myOutlineActor->SetMapper( myOutlineMapper.GetPointer() ); myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0); myOutlineActor->GetProperty()->SetAmbient(1.0); myOutlineActor->GetProperty()->SetDiffuse(0.0); @@ -169,16 +204,75 @@ SALOME_Actor } myProperty->Delete(); +} - // from VISU - myPointPicker->Delete(); - myCellPicker->Delete(); - myCellRectPicker->Delete(); - myHighlightActor->Delete(); - myOutline->Delete(); - myOutlineMapper->Delete(); - myOutlineActor->Delete(); +//---------------------------------------------------------------------------- +Standard_Boolean +SALOME_Actor +::hasIO() +{ + return !myIO.IsNull(); +} + +const Handle(SALOME_InteractiveObject)& +SALOME_Actor +::getIO() +{ + return myIO; +} + +void +SALOME_Actor +::setIO(const Handle(SALOME_InteractiveObject)& theIO) +{ + myIO = theIO; +} + +const char* +SALOME_Actor +::getName() +{ + return myName.c_str(); +} + +void +SALOME_Actor +::setName(const char* theName) +{ + if(hasIO()) + myIO->setName(theName); + myName = theName; +} + + +//---------------------------------------------------------------------------- +bool +SALOME_Actor +::hasHighlight() +{ + return false; +} + +void +SALOME_Actor +::highlight(bool theHighlight) +{ + highlight(theHighlight,ActorSelection); +} + +bool +SALOME_Actor +::isHighlighted() +{ + return myIsHighlighted; +} + +void +SALOME_Actor +::SetPreSelected(bool thePreselect) +{ + myIsPreselected = thePreselect; } @@ -191,9 +285,9 @@ SALOME_Actor theRenderer->AddActor(this); - theRenderer->AddActor( myPreHighlightActor ); - theRenderer->AddActor( myHighlightActor ); - theRenderer->AddActor( myOutlineActor ); + theRenderer->AddActor( myPreHighlightActor.GetPointer() ); + theRenderer->AddActor( myHighlightActor.GetPointer() ); + theRenderer->AddActor( myOutlineActor.GetPointer() ); } void @@ -202,9 +296,9 @@ SALOME_Actor { theRenderer->RemoveActor(this); - theRenderer->RemoveActor( myPreHighlightActor ); - theRenderer->RemoveActor( myHighlightActor ); - theRenderer->RemoveActor( myOutlineActor ); + theRenderer->RemoveActor( myPreHighlightActor.GetPointer() ); + theRenderer->RemoveActor( myHighlightActor.GetPointer() ); + theRenderer->RemoveActor( myOutlineActor.GetPointer() ); } vtkRenderer* @@ -214,6 +308,11 @@ SALOME_Actor return myRenderer; } +void +SALOME_Actor +::GetChildActors(vtkActorCollection*) +{} + //---------------------------------------------------------------------------- void @@ -321,13 +420,47 @@ SALOME_Actor } void -SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units) +SALOME_Actor +::GetPolygonOffsetParameters(float& factor, float& units) { factor = myPolygonOffsetFactor; units = myPolygonOffsetUnits; } +//---------------------------------------------------------------------------- +float +SALOME_Actor +::GetShrinkFactor() +{ + return 1.0; +} + +bool +SALOME_Actor +::IsShrunkable() +{ + return false; +} + +bool +SALOME_Actor +::IsShrunk() +{ + return false; +} + +void +SALOME_Actor +::SetShrink() +{} + +void +SALOME_Actor +::UnShrink() +{} + + //---------------------------------------------------------------------------- vtkDataSet* SALOME_Actor @@ -395,6 +528,20 @@ SALOME_Actor //---------------------------------------------------------------------------- +int +SALOME_Actor +::GetNodeObjId(int theVtkID) +{ + return theVtkID; +} + +float* +SALOME_Actor +::GetNodeCoord(int theObjID) +{ + return GetInput()->GetPoint(theObjID); +} + vtkCell* SALOME_Actor ::GetElemCell(int theObjID) @@ -402,11 +549,11 @@ SALOME_Actor return GetInput()->GetCell(theObjID); } - -float* -SALOME_Actor::GetNodeCoord(int theObjID) -{ - return GetInput()->GetPoint(theObjID); +int +SALOME_Actor +::GetElemObjId(int theVtkID) +{ + return theVtkID; } @@ -466,6 +613,33 @@ SALOME_Actor } +//---------------------------------------------------------------------------- +bool +SALOME_Actor +::IsSetCamera() const +{ + return false; +} + +bool +SALOME_Actor +::IsResizable() const +{ + return false; +} + +void +SALOME_Actor +::SetSize( const float ) +{} + + +void +SALOME_Actor +::SetCamera( vtkCamera* ) +{} + +//---------------------------------------------------------------------------- void SALOME_Actor ::SetOpacity(float theOpacity) @@ -489,6 +663,13 @@ SALOME_Actor GetProperty()->SetColor(r,g,b); } +void +SALOME_Actor +::SetColor(const float theRGB[3]) +{ + SetColor(theRGB[0],theRGB[1],theRGB[2]); +} + void SALOME_Actor ::GetColor(float& r,float& g,float& b) @@ -501,6 +682,7 @@ SALOME_Actor } +//---------------------------------------------------------------------------- int SALOME_Actor ::getDisplayMode() @@ -519,7 +701,8 @@ SALOME_Actor::setDisplayMode(int theMode) //---------------------------------------------------------------- void SALOME_Actor -::highlight( bool theHighlight, int theSelectionMode ) +::highlight(bool theHighlight, + Selection_Mode theSelectionMode) { myIsHighlighted = theHighlight; @@ -545,40 +728,15 @@ SALOME_Actor } -//---------------------------------------------------------------- -int -SALOME_Actor -::GetEdgeId( vtkPicker* thePicker, int theObjId ) -{ - int anEdgeId = -1; - if (vtkCell* aPickedCell = GetElemCell(theObjId)) { - float aPickPosition[3]; - thePicker->GetPickPosition(aPickPosition); - float aMinDist = 1000000.0, aDist = 0; - for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){ - if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){ - int subId; float pcoords[3], closestPoint[3], weights[3]; - aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); - if (aDist < aMinDist) { - aMinDist = aDist; - anEdgeId = i; - } - } - } - } - return anEdgeId; -} - //---------------------------------------------------------------- bool SALOME_Actor -::PreHighlight( SVTK_Selector* theSelector, - //vtkRenderer* theRenderer, - vtkInteractorStyle *theIS, - SVTK_SelectionEvent theSelectionEvent, - bool theIsHighlight ) +::PreHighlight(SVTK_Selector* theSelector, + vtkInteractorStyle *theInteractorStyle, + const SVTK_SelectionEvent& theSelectionEvent, + bool theIsHighlight) { - vtkRenderer *aRenderer=theIS->GetCurrentRenderer(); + vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // myPreHighlightActor->SetVisibility( false ); @@ -655,7 +813,7 @@ SALOME_Actor if ( aVtkId >= 0 && theSelector->IsValid( this, aVtkId ) && hasIO() ) { int anObjId = GetElemObjId( aVtkId ); - int anEdgeId = GetEdgeId( myCellPicker, anObjId ); + int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); TColStd_IndexedMapOfInteger aMapIndex; aMapIndex.Add( anObjId ); aMapIndex.Add( anEdgeId ); @@ -692,16 +850,17 @@ SALOME_Actor return anIsChanged; } + + //---------------------------------------------------------------- bool SALOME_Actor -::Highlight( SVTK_Selector* theSelector, - vtkInteractorStyle* theIS, - SVTK_SelectionEvent theSelectionEvent, - bool theIsHighlight ) +::Highlight(SVTK_Selector* theSelector, + vtkInteractorStyle *theInteractorStyle, + const SVTK_SelectionEvent& theSelectionEvent, + bool theIsHighlight) { - vtkRenderer *aRenderer=theIS->GetCurrentRenderer(); - + vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // int aSelectionMode = theSelectionEvent.mySelectionMode; float x1 = theSelectionEvent.myX; @@ -779,7 +938,7 @@ SALOME_Actor { theSelector->ClearIObjects(); } - int anEdgeId = GetEdgeId( myCellPicker, anObjId ); + int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); if( anEdgeId >= 0 ) { theSelector->AddOrRemoveIndex( myIO, anObjId, false ); @@ -897,18 +1056,18 @@ SALOME_Actor switch( aSelectionMode ) { case NodeSelection: - myHighlightActor->SetProperty( myPointProperty ); + myHighlightProperty->SetRepresentationToPoints(); myHighlightActor->MapPoints( this, aMapIndex ); break; case EdgeOfCellSelection: - myHighlightActor->SetProperty( myEdgeProperty ); + myHighlightProperty->SetRepresentationToWireframe(); myHighlightActor->MapEdge( this, aMapIndex ); break; case CellSelection: case EdgeSelection: case FaceSelection: case VolumeSelection: - myHighlightActor->SetProperty( myCellProperty ); + myHighlightProperty->SetRepresentationToSurface(); myHighlightActor->MapCells( this, aMapIndex ); break; case ActorSelection: @@ -920,3 +1079,38 @@ SALOME_Actor return true; } +//---------------------------------------------------------------------------- +void +SALOME_Actor +::SetSelectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + myHighlightProperty->SetColor( theRed, theGreen, theBlue ); + myHighlightProperty->SetLineWidth( theWidth ); +} + +//---------------------------------------------------------------------------- +void +SALOME_Actor +::SetPreselectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + myPreHighlightProperty->SetColor( theRed, theGreen, theBlue ); + myPreHighlightProperty->SetLineWidth( theWidth ); +} + +//---------------------------------------------------------------------------- +void +SALOME_Actor +::SetSelectionTolerance(const double& theTolNodes, + const double& theTolCell) +{ + myPointPicker->SetTolerance( theTolNodes ); + myCellPicker->SetTolerance( theTolCell ); + myCellRectPicker->SetTolerance( theTolCell ); +} + diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index 082c542c3..b5f3443a5 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -40,6 +40,8 @@ #include #include +#include + class vtkCell; class vtkPicker; class vtkPointPicker; @@ -64,6 +66,7 @@ class SVTK_Actor; class SVTK_InteractorStyle; extern int SALOME_POINT_SIZE; +extern int SALOME_LINE_WIDTH; class SALOME_Actor; @@ -74,69 +77,51 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor vtkTypeMacro(SALOME_Actor,vtkLODActor); + //---------------------------------------------------------------------------- virtual Standard_Boolean - hasIO() - { - return !myIO.IsNull(); - } + hasIO(); virtual const Handle(SALOME_InteractiveObject)& - getIO() - { - return myIO; - } + getIO(); virtual void - setIO(const Handle(SALOME_InteractiveObject)& theIO) - { - myIO = theIO; - } + setIO(const Handle(SALOME_InteractiveObject)& theIO); virtual const char* - getName() - { - return myName.c_str(); - } + getName(); virtual void - setName(const char* theName) - { - if(hasIO()) - myIO->setName(theName); - myName = theName; - } + setName(const char* theName); + //---------------------------------------------------------------------------- // To generate highlight automaticaly virtual bool - hasHighlight() - { - return false; - } + hasHighlight(); virtual void - highlight( bool theHighlight, int theSelectionMode ); + highlight(bool theHighlight, + Selection_Mode theSelectionMode); virtual void - highlight(bool theHighlight) - { - highlight(theHighlight,ActorSelection); - } + highlight(bool theHighlight); virtual bool - isHighlighted() - { - return myIsHighlighted; - } + isHighlighted(); + virtual + void + SetPreSelected(bool thePreselect = false); + + //---------------------------------------------------------------------------- virtual void SetOpacity(float theOpacity); @@ -155,33 +140,13 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor virtual void - SetColor(const float theRGB[3]) - { - SetColor(theRGB[0],theRGB[1],theRGB[2]); - } - - vtkSetObjectMacro(PreviewProperty,vtkProperty); + SetColor(const float theRGB[3]); - virtual - void - SetPreSelected(bool thePreselect = false) - { - myIsPreselected = thePreselect; - } - - // Used to obtain all dependent actors - virtual - void - GetChildActors(vtkActorCollection*) - {}; - + //---------------------------------------------------------------------------- // For selection mapping purpose virtual int - GetNodeObjId(int theVtkID) - { - return theVtkID; - } + GetNodeObjId(int theVtkID); virtual float* @@ -189,15 +154,13 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor virtual int - GetElemObjId(int theVtkID) - { - return theVtkID; - } + GetElemObjId(int theVtkID); virtual vtkCell* GetElemCell(int theObjID); + //---------------------------------------------------------------------------- virtual int GetObjDimension( const int theObjId ); @@ -218,6 +181,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor unsigned long int GetMTime(); + //---------------------------------------------------------------------------- virtual void SetRepresentation(int theMode); @@ -234,6 +198,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void setDisplayMode(int theMode); + //---------------------------------------------------------------------------- // Infinitive means actor without size (point for example), // which is not taken into account in calculation of boundaries of the scene void @@ -250,6 +215,24 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void GetBounds(float bounds[6]); + //---------------------------------------------------------------------------- + virtual + bool + IsSetCamera() const; + + virtual + bool + IsResizable() const; + + virtual + void + SetSize( const float ); + + virtual + void + SetCamera( vtkCamera* ); + + //---------------------------------------------------------------------------- void SetResolveCoincidentTopology(bool theIsResolve); @@ -263,61 +246,28 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void Render(vtkRenderer *, vtkMapper *); + //---------------------------------------------------------------------------- virtual float - GetShrinkFactor() - { - return 1.0; - } + GetShrinkFactor(); virtual bool - IsShrunkable() - { - return false; - } + IsShrunkable(); virtual bool - IsShrunk() - { - return false; - } + IsShrunk(); virtual void - SetShrink() - {} + SetShrink(); virtual void - UnShrink() - {} - - virtual - bool - IsSetCamera() const - { - return false; - } - - virtual - bool - IsResizable() const - { - return false; - } - - virtual - void - SetSize( const float ) - {} - - virtual - void - SetCamera( vtkCamera* ) - {} + UnShrink(); + //---------------------------------------------------------------------------- virtual void SetVisibility( int ); @@ -334,6 +284,11 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor vtkRenderer* GetRenderer(); + // Used to obtain all dependent actors + virtual + void + GetChildActors(vtkActorCollection*); + //---------------------------------------------------------------------------- virtual void @@ -346,55 +301,41 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor //---------------------------------------------------------------------------- virtual bool - PreHighlight( SVTK_Selector*, - vtkInteractorStyle*, - SVTK_SelectionEvent, - bool ); + PreHighlight(SVTK_Selector* theSelector, + vtkInteractorStyle* theInteractorStyle, + const SVTK_SelectionEvent& theSelectionEvent, + bool theIsHighlight); virtual bool - Highlight( SVTK_Selector*, - vtkInteractorStyle*, - SVTK_SelectionEvent, - bool ); - - vtkProperty* - getPointProperty() - { - return myPointProperty; - } - - vtkProperty* - getCellProperty() - { - return myCellProperty; - } - - vtkProperty* - getEdgeProperty() - { - return myEdgeProperty; - } - - vtkPointPicker* - getPointPicker() - { - return myPointPicker; - } - - vtkCellPicker* - getCellPicker() - { - return myCellPicker; - } - - VTKViewer_CellRectPicker* - getCellRectPicker() - { - return myCellRectPicker; - } + Highlight(SVTK_Selector* theSelector, + vtkInteractorStyle* theInteractorStyle, + const SVTK_SelectionEvent& theSelectionEvent, + bool theIsHighlight); + + virtual + void + SetSelectionProp(const double& theRed = 1, + const double& theGreen = 1, + const double& theBlue = 0, + const int& theWidth = 5); + + virtual + void + SetPreselectionProp(const double& theRed = 0, + const double& theGreen = 1, + const double& theBlue = 1, + const int& theWidth = 5); + + virtual + void + SetSelectionTolerance(const double& theTolNodes = 0.025, + const double& theTolCell = 0.001); + + vtkSetObjectMacro(PreviewProperty,vtkProperty); protected: + //---------------------------------------------------------------------------- vtkRenderWindowInteractor* myInteractor; vtkRenderer* myRenderer; @@ -429,22 +370,21 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor ~SALOME_Actor(); protected: - int GetEdgeId( vtkPicker*, int ); - - vtkProperty* myPointProperty; - vtkProperty* myCellProperty; - vtkProperty* myEdgeProperty; + //---------------------------------------------------------------------------- + // Highlight/ Prehighlight devices + vtkSmartPointer myPointPicker; + vtkSmartPointer myCellPicker; + vtkSmartPointer myCellRectPicker; - vtkPointPicker* myPointPicker; - vtkCellPicker* myCellPicker; - VTKViewer_CellRectPicker* myCellRectPicker; + vtkSmartPointer myPreHighlightProperty; + vtkSmartPointer myPreHighlightActor; - SVTK_Actor* myPreHighlightActor; - SVTK_Actor* myHighlightActor; + vtkSmartPointer myHighlightProperty; + vtkSmartPointer myHighlightActor; - vtkActor* myOutlineActor; - vtkOutlineSource* myOutline; - vtkPolyDataMapper* myOutlineMapper; + vtkSmartPointer myOutlineActor; + vtkSmartPointer myOutline; + vtkSmartPointer myOutlineMapper; }; #endif // SALOME_ACTOR_H diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 8a1b758f6..4f7762d01 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -874,7 +874,7 @@ SVTK_InteractorStyle // VSV: LOD actor activisation // rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate()); - int aSelectionMode = GetSelector()->SelectionMode(); + Selection_Mode aSelectionMode = GetSelector()->SelectionMode(); switch (State) { case VTK_INTERACTOR_STYLE_CAMERA_SELECT: diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index f371c025d..e004c782a 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -551,14 +551,14 @@ SVTK_RenderWindowInteractor //---------------------------------------------------------------- void SVTK_RenderWindowInteractor -::SetSelectionMode(int theMode) +::SetSelectionMode(Selection_Mode theMode) { mySelector->SetSelectionMode(theMode); } //---------------------------------------------------------------- -int +Selection_Mode SVTK_RenderWindowInteractor ::SelectionMode() const { diff --git a/src/SVTK/SVTK_SelectionEvent.h b/src/SVTK/SVTK_SelectionEvent.h index 6a349d062..5843597cb 100644 --- a/src/SVTK/SVTK_SelectionEvent.h +++ b/src/SVTK/SVTK_SelectionEvent.h @@ -33,7 +33,7 @@ struct SVTK_SelectionEvent { - int mySelectionMode; + Selection_Mode mySelectionMode; int myX; int myY; int myLastX; diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index c4c85fcb2..54a3ae654 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -76,7 +76,7 @@ SVTK_SelectorDef //---------------------------------------------------------------------------- void SVTK_SelectorDef -::SetSelectionMode(int theMode) +::SetSelectionMode(Selection_Mode theMode) { mySelectionMode = theMode; } diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index af580474a..8f29b3c94 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -50,10 +50,10 @@ public: virtual void - SetSelectionMode( int theMode ) = 0; + SetSelectionMode(Selection_Mode theMode) = 0; virtual - int + Selection_Mode SelectionMode() const = 0; virtual diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index 9150a652a..050a6838a 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -51,10 +51,10 @@ public: virtual void - SetSelectionMode( int theMode ); + SetSelectionMode(Selection_Mode theMode); virtual - int + Selection_Mode SelectionMode() const { return mySelectionMode; } virtual diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index 014ff3834..7e4d6a48b 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -881,19 +881,25 @@ SVTK_View { vtkActorCollection* anActors = getRenderer()->GetActors(); anActors->InitTraversal(); - while( vtkActor* anActor = anActors->GetNextActor() ) - { - if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) ) - { - aSActor->getPointProperty()->SetColor( theRed, theGreen, theBlue ); - aSActor->getPointProperty()->SetLineWidth( theWidth ); - - aSActor->getCellProperty()->SetColor( theRed, theGreen, theBlue ); - aSActor->getCellProperty()->SetLineWidth( theWidth ); + while(vtkActor* anActor = anActors->GetNextActor()){ + if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) + aSActor->SetSelectionProp(theRed,theGreen,theBlue,theWidth); + } +} - aSActor->getEdgeProperty()->SetColor( theRed, theGreen, theBlue ); - aSActor->getEdgeProperty()->SetLineWidth( theWidth ); - } +//---------------------------------------------------------------------------- +void +SVTK_View +::SetPreselectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + vtkActorCollection* anActors = getRenderer()->GetActors(); + anActors->InitTraversal(); + while(vtkActor* anActor = anActors->GetNextActor()){ + if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) + aSActor->SetPreselectionProp(theRed,theGreen,theBlue,theWidth); } } @@ -901,18 +907,13 @@ SVTK_View void SVTK_View ::SetSelectionTolerance(const double& theTolNodes, - const double& theTolItems) + const double& theTolCell) { vtkActorCollection* anActors = getRenderer()->GetActors(); anActors->InitTraversal(); - while( vtkActor* anActor = anActors->GetNextActor() ) - { - if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) ) - { - aSActor->getPointPicker()->SetTolerance( theTolNodes ); - aSActor->getCellPicker()->SetTolerance( theTolItems ); - aSActor->getCellRectPicker()->SetTolerance( theTolItems ); - } + while(vtkActor* anActor = anActors->GetNextActor()){ + if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) + aSActor->SetSelectionTolerance(theTolNodes,theTolCell); } } diff --git a/src/SVTK/SVTK_View.h b/src/SVTK/SVTK_View.h index e99283017..caa7fae7b 100644 --- a/src/SVTK/SVTK_View.h +++ b/src/SVTK/SVTK_View.h @@ -295,6 +295,7 @@ public: rename(const Handle(SALOME_InteractiveObject)& IObject, const QString& newName); + //---------------------------------------------------------------------------- // Displaymode management int GetDisplayMode(); @@ -335,6 +336,7 @@ public: QColor GetColor(const Handle(SALOME_InteractiveObject)& theIObject); + //---------------------------------------------------------------------------- // Erase Display functions void EraseAll(); @@ -371,12 +373,19 @@ public: Remove(SALOME_Actor* SActor, bool updateViewer = true); + //---------------------------------------------------------------------------- void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1, const double& theBlue = 0, const int& theWidth = 5); + void + SetPreselectionProp(const double& theRed = 0, + const double& theGreen = 1, + const double& theBlue = 1, + const int& theWidth = 5); + void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001); diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 180a53a66..e34229ade 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -494,6 +494,17 @@ SVTK_ViewWindow myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth); } +//---------------------------------------------------------------------------- +void +SVTK_ViewWindow +::SetPreselectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth); +} + //---------------------------------------------------------------------------- void SVTK_ViewWindow diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 0cc14a104..17e00f6b3 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -177,6 +177,12 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow virtual void + SetPreselectionProp(const double& theRed = 0, + const double& theGreen = 1, + const double& theBlue = 1, + const int& theWidth = 5); + virtual + void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);