Back to index

salome-gui  6.5.0
Classes | Public Member Functions | Private Types | Private Attributes
SVTK_SelectorDef Class Reference

#include <SVTK_SelectorDef.h>

Collaboration diagram for SVTK_SelectorDef:
Collaboration graph
[legend]

List of all members.

Classes

struct  TIndexedMapOfInteger
struct  TIOLessThan

Public Member Functions

 SVTK_SelectorDef ()
 Default constructor.
virtual ~SVTK_SelectorDef ()
 Destructor.
virtual void SetSelectionMode (Selection_Mode theMode)
 To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
virtual Selection_Mode SelectionMode () const
virtual void ClearIObjects ()
 Clear selection.
virtual SALOME_ActorGetActor (const Handle(SALOME_InteractiveObject)&theIO) const
virtual bool IsSelected (const Handle(SALOME_InteractiveObject)&theIO) const
virtual bool IsSelected (SALOME_Actor *theActor) const
virtual bool AddIObject (const Handle(SALOME_InteractiveObject)&theIO)
 Adds SALOME_InteractiveObject into selection.
virtual bool AddIObject (SALOME_Actor *theActor)
 Adds SALOME_Actor into selection.
virtual bool RemoveIObject (const Handle(SALOME_InteractiveObject)&theIO)
 Removes SALOME_InteractiveObject from selection.
virtual bool RemoveIObject (SALOME_Actor *theActor)
 Removes SALOME_Actor from selection.
virtual const SALOME_ListIOStoredIObjects () const
virtual int IObjectCount () const
virtual bool HasIndex (const Handle(SALOME_InteractiveObject)&theIO) const
virtual void GetIndex (const Handle(SALOME_InteractiveObject)&theIO, TColStd_IndexedMapOfInteger &theIndex)
 Gets indices of subselection for SALOME_InteractiveObject.
virtual bool AddOrRemoveIndex (const Handle(SALOME_InteractiveObject)&theIO, const TColStd_IndexedMapOfInteger &theIndices, bool theIsModeShift)
 Changes indices of subselection for SALOME_InteractiveObject.
virtual bool AddOrRemoveIndex (const Handle(SALOME_InteractiveObject)&theIO, const TColStd_MapOfInteger &theIndices, bool theIsModeShift)
 Changes indices of subselection for SALOME_InteractiveObject.
virtual bool AddOrRemoveIndex (const Handle(SALOME_InteractiveObject)&theIO, int theIndex, bool theIsModeShift)
 Changes indices of subselection for SALOME_InteractiveObject.
virtual void RemoveIndex (const Handle(SALOME_InteractiveObject)&theIO, int theIndex)
 Removes index of subselection for SALOME_InteractiveObject.
virtual bool IsIndexSelected (const Handle(SALOME_InteractiveObject)&theIO, int theIndex) const
virtual void ClearIndex ()
 Clears all indices of subselection.
virtual void SetFilter (const Handle(VTKViewer_Filter)&theFilter)
 To apply a filter on the selection.
virtual Handle (VTKViewer_Filter) GetFilter(const TFilterID theId) const
virtual bool IsFilterPresent (const TFilterID theId) const
virtual void RemoveFilter (const int theId)
 To remove a filter from the selection.
virtual bool IsValid (SALOME_Actor *theActor, const TFilterID theId, const bool theIsNode=false) const
virtual void StartPickCallback ()
 To invoke selectionChanged signals.
virtual void EndPickCallback ()
 To invoke selectionChanged signals.
virtual vtkActorCollection * Pick (const SVTK_SelectionEvent *theEvent, vtkRenderer *theRenderer) const
virtual void SetTolerance (const double &theTolerance)
virtual void SetDynamicPreSelection (bool theIsDynPreselect)
virtual bool GetDynamicPreSelection () const

Private Types

typedef std::set< Handle(SALOME_InteractiveObject),
TIOLessThan
TIObjects
typedef std::map< Handle(SALOME_InteractiveObject),
vtkSmartPointer< SALOME_Actor >
, TIOLessThan
TIO2Actors
typedef std::map< Handle(SALOME_InteractiveObject),
TIndexedMapOfInteger,
TIOLessThan
TMapIOSubIndex
typedef std::map< TFilterID,
Handle(VTKViewer_Filter)> 
TFilters

Private Attributes

int mySelectionMode
bool myDynamicPreselection
SALOME_ListIO myIObjectList
TIObjects myIObjects
TIO2Actors myIO2Actors
TMapIOSubIndex myMapIOSubIndex
TFilters myFilters
vtkSmartPointer< vtkPicker > myPicker
vtkSmartPointer< vtkCellPicker > myCellPicker

Detailed Description

Definition at line 48 of file SVTK_SelectorDef.h.


Member Typedef Documentation

typedef std::map<TFilterID,Handle(VTKViewer_Filter)> SVTK_SelectorDef::TFilters [private]

Definition at line 228 of file SVTK_SelectorDef.h.

typedef std::map<Handle(SALOME_InteractiveObject), vtkSmartPointer<SALOME_Actor>, TIOLessThan> SVTK_SelectorDef::TIO2Actors [private]

Definition at line 220 of file SVTK_SelectorDef.h.

Definition at line 215 of file SVTK_SelectorDef.h.

Definition at line 225 of file SVTK_SelectorDef.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 58 of file SVTK_Selector.cxx.

                  :
  myPicker(vtkPicker::New()),
  myCellPicker(vtkCellPicker::New())
{
  mySelectionMode = ActorSelection;
  myDynamicPreselection = true;

  myPicker->Delete();
  myCellPicker->Delete();
}

Destructor.

Definition at line 73 of file SVTK_Selector.cxx.

{
}

Member Function Documentation

Adds SALOME_InteractiveObject into selection.

Parameters:
theIO- SALOME_InteractiveObject

Definition at line 164 of file SVTK_Selector.cxx.

{
  if(!IsSelected(theIO)){
    myIObjects.insert(theIO);
    return true;
  }
  return false;
}
bool SVTK_SelectorDef::AddIObject ( SALOME_Actor theActor) [virtual]

Adds SALOME_Actor into selection.

Parameters:
theActor- SALOME_Actor

Definition at line 179 of file SVTK_Selector.cxx.

{
  const Handle(SALOME_InteractiveObject) anIO = theActor->getIO();

  bool anIsIOBound = IsSelected(anIO);
  if(!anIsIOBound)
    myIObjects.insert(anIO);

  bool anIsActorBound = myIO2Actors.find(anIO) != myIO2Actors.end();
  if(!anIsActorBound)
    myIO2Actors[anIO] = theActor;
  
  return !anIsIOBound || !anIsActorBound;
}

Here is the call graph for this function:

bool SVTK_SelectorDef::AddOrRemoveIndex ( const Handle(SALOME_InteractiveObject)&  theIO,
const TColStd_IndexedMapOfInteger &  theIndices,
bool  theIsModeShift 
) [virtual]

Changes indices of subselection for SALOME_InteractiveObject.

Parameters:
theIO- SALOME_InteractiveObject
theIndices- indices
theIsModeShift- if it is false, then map will be cleared before indices are added

Definition at line 330 of file SVTK_Selector.cxx.

{
  TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO);
  if(aMapIter == myMapIOSubIndex.end()){
    TIndexedMapOfInteger anEmpty;
    aMapIter = myMapIOSubIndex.
      insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first;
  }
  TColStd_IndexedMapOfInteger& aMapIndex = aMapIter->second.myMap;

  if(!theIsModeShift)
    aMapIndex.Clear();
  
  for(int i = 1, iEnd = theIndices.Extent(); i <= iEnd; i++)
    aMapIndex.Add(theIndices(i));
  
  if(aMapIndex.IsEmpty()) {
    myMapIOSubIndex.erase(theIO);
    return false;
  }

  return true;
}
bool SVTK_SelectorDef::AddOrRemoveIndex ( const Handle(SALOME_InteractiveObject)&  theIO,
const TColStd_MapOfInteger &  theIndices,
bool  theIsModeShift 
) [virtual]

Changes indices of subselection for SALOME_InteractiveObject.

Parameters:
theIO- SALOME_InteractiveObject
theIndices- indices
theIsModeShift- if it is false, then map will be cleared before indices are added

Definition at line 365 of file SVTK_Selector.cxx.

{
  TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO);
  if(aMapIter == myMapIOSubIndex.end()){
    TIndexedMapOfInteger anEmpty;
    aMapIter = myMapIOSubIndex.
      insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first;
  }
  TColStd_IndexedMapOfInteger& aMapIndex = aMapIter->second.myMap;

  if(!theIsModeShift)
    aMapIndex.Clear();
  
  TColStd_MapIteratorOfMapOfInteger anIter(theIndices);
  for(; anIter.More(); anIter.Next())
    aMapIndex.Add(anIter.Key());
  
  if(aMapIndex.IsEmpty()) {
    myMapIOSubIndex.erase(theIO);
    return false;
  }

  return true;
}
bool SVTK_SelectorDef::AddOrRemoveIndex ( const Handle(SALOME_InteractiveObject)&  theIO,
int  theIndex,
bool  theIsModeShift 
) [virtual]

Changes indices of subselection for SALOME_InteractiveObject.

Parameters:
theIO- SALOME_InteractiveObject
theIndex- index
theIsModeShift- if it is false, then map will be cleared before indices are added

Definition at line 401 of file SVTK_Selector.cxx.

{
  TMapIOSubIndex::iterator anIter = myMapIOSubIndex.find(theIO);
  if(anIter == myMapIOSubIndex.end()){
    TIndexedMapOfInteger anEmpty;
    anIter = myMapIOSubIndex.
      insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first;
  }
  TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap;

  bool anIsConatains = aMapIndex.Contains( theIndex ) == Standard_True;
  if ( anIsConatains )
    removeIndex( aMapIndex, theIndex );
  
  if ( !theIsModeShift )
    aMapIndex.Clear();
  
  if ( !anIsConatains )
    aMapIndex.Add( theIndex );

  if ( aMapIndex.IsEmpty() )
    myMapIOSubIndex.erase( theIO );

  return false;
}

Here is the call graph for this function:

Clears all indices of subselection.

Definition at line 452 of file SVTK_Selector.cxx.

{
  myMapIOSubIndex.clear();  
}

Clear selection.

Definition at line 116 of file SVTK_Selector.cxx.

{
  myIO2Actors.clear();
  myIObjects.clear();
  myMapIOSubIndex.clear();
}

To invoke selectionChanged signals.

Definition at line 92 of file SVTK_Selector.cxx.

{
  this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
}
Returns:
corresponding SALOME_Actor for SALOME_InteractiveObject
Parameters:
theIO- SALOME_InteractiveObject

Definition at line 150 of file SVTK_Selector.cxx.

{
  TIO2Actors::const_iterator anIter = myIO2Actors.find(theIO);
  if(anIter != myIO2Actors.end())
    return anIter->second.GetPointer();
  return NULL;
}
bool SVTK_SelectorDef::GetDynamicPreSelection ( ) const [virtual]

Definition at line 572 of file SVTK_Selector.cxx.

void SVTK_SelectorDef::GetIndex ( const Handle(SALOME_InteractiveObject)&  theIO,
TColStd_IndexedMapOfInteger &  theIndex 
) [virtual]

Gets indices of subselection for SALOME_InteractiveObject.

Parameters:
theIO- SALOME_InteractiveObject

Definition at line 271 of file SVTK_Selector.cxx.

{
  TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO);
  if(anIter != myMapIOSubIndex.end())
    theIndex = anIter->second.myMap;
  else
    theIndex.Clear();
}
virtual SVTK_SelectorDef::Handle ( VTKViewer_Filter  ) const [virtual]
bool SVTK_SelectorDef::HasIndex ( const Handle(SALOME_InteractiveObject)&  theIO) const [virtual]
Returns:
true if the SALOME_InteractiveObject has a subselection
Parameters:
theIO- SALOME_InteractiveObject

Definition at line 260 of file SVTK_Selector.cxx.

{
  return myMapIOSubIndex.find(theIO) != myMapIOSubIndex.end();
}
int SVTK_SelectorDef::IObjectCount ( ) const [virtual]
Returns:
number of selected objects

Definition at line 249 of file SVTK_Selector.cxx.

{
  return myIObjects.size();
}
bool SVTK_SelectorDef::IsFilterPresent ( const TFilterID  theId) const [virtual]
Returns:
true if filter with given number is applyed
Parameters:
theId- filter id

Definition at line 474 of file SVTK_Selector.cxx.

{
  return myFilters.find(theId) != myFilters.end();
}
bool SVTK_SelectorDef::IsIndexSelected ( const Handle(SALOME_InteractiveObject)&  theIO,
int  theIndex 
) const [virtual]
Returns:
true if the index presents in subselection
Parameters:
theIO- SALOME_InteractiveObject
theIndex- index

Definition at line 288 of file SVTK_Selector.cxx.

{
  TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO);
  if(anIter != myMapIOSubIndex.end()){
    const TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap;
    return aMapIndex.Contains( theIndex ) == Standard_True;
  }

  return false;
}
bool SVTK_SelectorDef::IsSelected ( const Handle(SALOME_InteractiveObject)&  theIO) const [virtual]
Returns:
true if the SALOME_InteractiveObject presents into selection

Definition at line 128 of file SVTK_Selector.cxx.

{
  return !theIO.IsNull() && (myIObjects.find(theIO) != myIObjects.end());
}
bool SVTK_SelectorDef::IsSelected ( SALOME_Actor theActor) const [virtual]
Returns:
true if the SALOME_Actor presents into selection

Definition at line 138 of file SVTK_Selector.cxx.

{
  const Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
  return IsSelected(anIO) && myIO2Actors.find(anIO) != myIO2Actors.end();
}

Here is the call graph for this function:

bool SVTK_SelectorDef::IsValid ( SALOME_Actor theActor,
const TFilterID  theId,
const bool  theIsNode = false 
) const [virtual]
Returns:
true if the index satisfy installed filters
Parameters:
theActor- actor
theId- filter id
theIsNode- whether it is node

Definition at line 499 of file SVTK_Selector.cxx.

{
  TFilters::const_iterator anIter = myFilters.begin();
  for(; anIter != myFilters.end(); ++anIter){
    const Handle(VTKViewer_Filter)& aFilter = anIter->second;
    if(theIsNode == aFilter->IsNodeFilter() &&
       !aFilter->IsValid(theActor,theId))
      return false;
  }
  return true;
}

Here is the call graph for this function:

vtkActorCollection * SVTK_SelectorDef::Pick ( const SVTK_SelectionEvent theEvent,
vtkRenderer *  theRenderer 
) const [virtual]

Definition at line 531 of file SVTK_Selector.cxx.

{
  vtkActorCollection* aListActors = NULL;

  if ( GetDynamicPreSelection() ) {
    myCellPicker->Pick(theEvent->myX,
                       theEvent->myY, 
                       0.0,
                       theRenderer);
  
    aListActors = myCellPicker->GetActors();
  }

  if ( !aListActors || !aListActors->GetNumberOfItems() ) {
    myPicker->Pick(theEvent->myX,
                   theEvent->myY, 
                   0.0,
                   theRenderer);
    aListActors = myPicker->GetActors();
  }
  
  return aListActors;
}
void SVTK_SelectorDef::RemoveFilter ( const int  theId) [virtual]

To remove a filter from the selection.

Parameters:
theId- filter id

Definition at line 485 of file SVTK_Selector.cxx.

{
  if(IsFilterPresent(theId))
    myFilters.erase(theId);
}
void SVTK_SelectorDef::RemoveIndex ( const Handle(SALOME_InteractiveObject)&  theIO,
int  theIndex 
) [virtual]

Removes index of subselection for SALOME_InteractiveObject.

Parameters:
theIO- SALOME_InteractiveObject
theIndex- index

Definition at line 437 of file SVTK_Selector.cxx.

{
  if(IsIndexSelected(theIO,theIndex)){
    TMapIOSubIndex::iterator anIter = myMapIOSubIndex.find(theIO);
    TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap;
    removeIndex(aMapIndex,theIndex);
  }
}

Here is the call graph for this function:

Removes SALOME_InteractiveObject from selection.

Parameters:
theIO- SALOME_InteractiveObject

Definition at line 200 of file SVTK_Selector.cxx.

{
  bool anIsIOBound = myIObjects.find(theIO) != myIObjects.end();

  myIObjects.erase(theIO);
  myIO2Actors.erase(theIO);
  myMapIOSubIndex.erase(theIO);

  return anIsIOBound;
}
bool SVTK_SelectorDef::RemoveIObject ( SALOME_Actor theActor) [virtual]

Removes SALOME_Actor from selection.

Parameters:
theActor- SALOME_Actor

Definition at line 217 of file SVTK_Selector.cxx.

{
  const Handle(SALOME_InteractiveObject) anIO = theActor->getIO();

  bool anIsActorBound = myIO2Actors.find(anIO) != myIO2Actors.end();
  if(anIsActorBound)
    myIO2Actors.erase(anIO);

  return RemoveIObject(anIO) || anIsActorBound;
}

Here is the call graph for this function:

virtual Selection_Mode SVTK_SelectorDef::SelectionMode ( ) const [inline, virtual]

Definition at line 60 of file SVTK_SelectorDef.h.

{ return mySelectionMode; }
void SVTK_SelectorDef::SetDynamicPreSelection ( bool  theIsDynPreselect) [virtual]

Definition at line 565 of file SVTK_Selector.cxx.

{
  myDynamicPreselection = theIsDynPreselect;
}
void SVTK_SelectorDef::SetFilter ( const Handle(VTKViewer_Filter)&  theFilter) [virtual]

To apply a filter on the selection.

Parameters:
theFilter- new filter

Definition at line 463 of file SVTK_Selector.cxx.

{
  myFilters.insert(TFilters::value_type(theFilter->GetId(),theFilter));
}

Here is the call graph for this function:

To change current Selection_Mode (as outside effect, it invokes selectionChange signal)

Definition at line 102 of file SVTK_Selector.cxx.

{
  if(mySelectionMode != theMode){
    mySelectionMode = theMode;
    myMapIOSubIndex.clear();
    this->EndPickCallback();
  }
}
void SVTK_SelectorDef::SetTolerance ( const double &  theTolerance) [virtual]

Definition at line 557 of file SVTK_Selector.cxx.

{
  myPicker->SetTolerance(theTolerance);         
  myCellPicker->SetTolerance(theTolerance);
}

To invoke selectionChanged signals.

Definition at line 82 of file SVTK_Selector.cxx.

{
  this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
}
const SALOME_ListIO & SVTK_SelectorDef::StoredIObjects ( ) const [virtual]
Returns:
list of all SALOME_InteractiveObject presenting in selection

Definition at line 233 of file SVTK_Selector.cxx.

{
  myIObjectList.Clear();
  TIObjects::const_iterator anIter = myIObjects.begin();
  TIObjects::const_iterator anIterEnd = myIObjects.end();
  for(; anIter != anIterEnd; anIter++)
    myIObjectList.Append(*anIter);

  return myIObjectList;
}

Here is the call graph for this function:


Member Data Documentation

vtkSmartPointer<vtkCellPicker> SVTK_SelectorDef::myCellPicker [private]

Definition at line 232 of file SVTK_SelectorDef.h.

Definition at line 190 of file SVTK_SelectorDef.h.

Definition at line 229 of file SVTK_SelectorDef.h.

Definition at line 221 of file SVTK_SelectorDef.h.

Definition at line 213 of file SVTK_SelectorDef.h.

Definition at line 216 of file SVTK_SelectorDef.h.

Definition at line 226 of file SVTK_SelectorDef.h.

vtkSmartPointer<vtkPicker> SVTK_SelectorDef::myPicker [private]

Definition at line 231 of file SVTK_SelectorDef.h.

Definition at line 188 of file SVTK_SelectorDef.h.


The documentation for this class was generated from the following files: