From 6ae40676310b4521457096dd6df456210c71451d Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 17 Oct 2005 06:14:06 +0000 Subject: [PATCH] To improve selection management. 1. Now internal highlight/prehighlight actors use the same position as its container - SALOME_Actor 2. All SALOME_Actor share the same instances of pickers and highlight/prehighlight properties that is stored into SVTK_Renderer --- src/SVTK/SALOME_Actor.cxx | 194 ++++++++++++++++++++------------------ src/SVTK/SALOME_Actor.h | 37 ++++---- 2 files changed, 123 insertions(+), 108 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index f94dd6f4f..43d8236af 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -66,6 +66,12 @@ using namespace std; +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -144,59 +150,39 @@ SALOME_Actor myIsResolveCoincidentTopology(true), myStoreMapping(false), myGeomFilter(VTKViewer_GeometryFilter::New()), - myTransformFilter(VTKViewer_TransformFilter::New()) + myTransformFilter(VTKViewer_TransformFilter::New()), + myPreHighlightActor(SVTK_Actor::New()), + myHighlightActor(SVTK_Actor::New()), + myOutline(vtkOutlineSource::New()), + myOutlineActor(VTKViewer_Actor::New()) { + if(MYDEBUG) MESSAGE("SALOME_Actor::SALOME_Actor - this = "<Delete(); - - myCellPicker = vtkCellPicker::New(); - myCellPicker->Delete(); - - myCellRectPicker = VTKViewer_CellRectPicker::New(); - myCellRectPicker->Delete(); - - myPreHighlightProperty = vtkProperty::New(); - myPreHighlightProperty->Delete(); - myPreHighlightProperty->SetColor(0,1,1); - myPreHighlightProperty->SetPointSize(SALOME_POINT_SIZE); - myPreHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH); - myPreHighlightProperty->SetRepresentationToPoints(); - - myPreHighlightActor = SVTK_Actor::New(); myPreHighlightActor->Delete(); - myPreHighlightActor->SetProperty(myPreHighlightProperty.GetPointer()); + myPreHighlightActor->PickableOff(); myPreHighlightActor->SetVisibility( false ); - 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->Delete(); myHighlightActor->PickableOff(); - myHighlightActor->SetProperty(myHighlightProperty.GetPointer()); myHighlightActor->SetVisibility( false ); - myOutline = vtkOutlineSource::New(); myOutline->Delete(); - vtkSmartPointer anOutlineMapper = vtkPolyDataMapper::New(); - anOutlineMapper->Delete(); + vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New(); anOutlineMapper->SetInput(myOutline->GetOutput()); - myOutlineActor = VTKViewer_Actor::New(); myOutlineActor->Delete(); + myOutlineActor->SetMapper( anOutlineMapper ); + anOutlineMapper->Delete(); + myOutlineActor->PickableOff(); myOutlineActor->DragableOff(); - myOutlineActor->SetMapper( anOutlineMapper.GetPointer() ); myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0); myOutlineActor->GetProperty()->SetAmbient(1.0); myOutlineActor->GetProperty()->SetDiffuse(0.0); @@ -208,6 +194,8 @@ SALOME_Actor SALOME_Actor ::~SALOME_Actor() { + if(MYDEBUG) MESSAGE("SALOME_Actor::~SALOME_Actor - this = "<UnRegisterAllOutputs(); @@ -308,8 +296,6 @@ SALOME_Actor theRenderer->AddActor( myPreHighlightActor.GetPointer() ); theRenderer->AddActor( myHighlightActor.GetPointer() ); theRenderer->AddActor( myOutlineActor.GetPointer() ); - - this->SetSelectionTolerance( 0.005 ); } void @@ -365,6 +351,26 @@ SALOME_Actor } +void +SALOME_Actor +::SetPosition(float _arg1, float _arg2, float _arg3) +{ + Superclass::SetPosition(_arg1,_arg2,_arg3); + + myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3); + myHighlightActor->SetPosition(_arg1,_arg2,_arg3); + myOutlineActor->SetPosition(_arg1,_arg2,_arg3); +} + + +void +SALOME_Actor +::SetPosition(float _arg[3]) +{ + SetPosition(_arg[0],_arg[1],_arg[2]); +} + + void SALOME_Actor ::SetMapper(vtkMapper* theMapper) @@ -715,6 +721,19 @@ SALOME_Actor::setDisplayMode(int theMode) } +//---------------------------------------------------------------- +void +SALOME_Actor +::SetVisibility( int theVisibility ) +{ + Superclass::SetVisibility( theVisibility ); + + myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() ); + myHighlightActor->SetVisibility( theVisibility && isHighlighted() ); + myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected ); +} + + //---------------------------------------------------------------- void SALOME_Actor @@ -740,16 +759,41 @@ SALOME_Actor } } -//---------------------------------------------------------------- void SALOME_Actor -::SetVisibility( int theVisibility ) +::highlight(bool theIsHighlight, + SVTK_Selector* theSelector) { - Superclass::SetVisibility( theVisibility ); + TColStd_IndexedMapOfInteger aMapIndex; + theSelector->GetIndex( getIO(), aMapIndex ); + mySelectionMode = theSelector->SelectionMode(); - myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() ); - myHighlightActor->SetVisibility( theVisibility && isHighlighted() ); - myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected ); + if(MYDEBUG) MESSAGE("SALOME_Actor::highlight - this = "<