// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
// $Header$
+#include "SVTK_SelectorDef.h"
+
+#include "SALOME_Actor.h"
+
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
+#include <vtkCallbackCommand.h>
-#include "SALOME_Actor.h"
-#include "SVTK_ViewModel.h"
-#include "SVTK_ViewWindow.h"
-
-#include "SVTK_SelectorDef.h"
+/*!
+ \return new SVTK_Selector
+*/
+SVTK_Selector*
+SVTK_Selector
+::New()
+{
+ return new SVTK_SelectorDef();
+}
+/*!
+ Default constructor
+*/
SVTK_SelectorDef
::SVTK_SelectorDef()
{
+ mySelectionMode = ActorSelection;
}
+/*!
+ Destructor
+*/
SVTK_SelectorDef
::~SVTK_SelectorDef()
{
}
+/*!
+ To invoke selectionChanged signals
+*/
+void
+SVTK_SelectorDef
+::StartPickCallback()
+{
+ this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
+}
+
+/*!
+ To invoke selectionChanged signals
+*/
+void
+SVTK_SelectorDef
+::EndPickCallback()
+{
+ this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
+}
+
+/*!
+ To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
+*/
void
SVTK_SelectorDef
::SetSelectionMode(Selection_Mode theMode)
{
- mySelectionMode = theMode;
+ if(mySelectionMode != theMode){
+ mySelectionMode = theMode;
+ myMapIOSubIndex.clear();
+ this->EndPickCallback();
+ }
}
+/*!
+ Clear selection
+*/
void
SVTK_SelectorDef
::ClearIObjects()
myMapIOSubIndex.clear();
}
-//----------------------------------------------------------------------------
+/*!
+ \return true if the SALOME_InteractiveObject presents into selection
+*/
bool
SVTK_SelectorDef
::IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const
{
- return myIObjects.find(theIO) != myIObjects.end();
+ return !theIO.IsNull() && (myIObjects.find(theIO) != myIObjects.end());
}
+/*!
+ \return true if the SALOME_Actor presents into selection
+*/
bool
SVTK_SelectorDef
::IsSelected(SALOME_Actor* theActor) const
return IsSelected(anIO) && myIO2Actors.find(anIO) != myIO2Actors.end();
}
+/*!
+ \return corresponding SALOME_Actor for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+*/
SALOME_Actor*
SVTK_SelectorDef
::GetActor(const Handle(SALOME_InteractiveObject)& theIO) const
return NULL;
}
-//----------------------------------------------------------------------------
+/*!
+ Adds SALOME_InteractiveObject into selection
+ \param theIO - SALOME_InteractiveObject
+*/
bool
SVTK_SelectorDef
::AddIObject(const Handle(SALOME_InteractiveObject)& theIO)
return false;
}
+/*!
+ Adds SALOME_Actor into selection
+ \param theActor - SALOME_Actor
+*/
bool
SVTK_SelectorDef
::AddIObject(SALOME_Actor* theActor)
return !anIsIOBound || !anIsActorBound;
}
-//----------------------------------------------------------------------------
+/*!
+ Removes SALOME_InteractiveObject from selection
+ \param theIO - SALOME_InteractiveObject
+*/
bool
SVTK_SelectorDef
::RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO)
return anIsIOBound;
}
+/*!
+ Removes SALOME_Actor from selection
+ \param theActor - SALOME_Actor
+*/
bool
SVTK_SelectorDef
::RemoveIObject(SALOME_Actor* theActor)
return RemoveIObject(anIO) || anIsActorBound;
}
-//----------------------------------------------------------------------------
+/*!
+ \return list of all SALOME_InteractiveObject presenting in selection
+*/
const SALOME_ListIO&
SVTK_SelectorDef
::StoredIObjects() const
return myIObjectList;
}
+/*!
+ \return number of selected objects
+*/
int
SVTK_SelectorDef
::IObjectCount() const
return myIObjects.size();
}
+/*!
+ \return true if the SALOME_InteractiveObject has a subselection
+ \param theIO - SALOME_InteractiveObject
+*/
bool
SVTK_SelectorDef
::HasIndex( const Handle(SALOME_InteractiveObject)& theIO) const
return myMapIOSubIndex.find(theIO) != myMapIOSubIndex.end();
}
+/*!
+ Gets indices of subselection for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+*/
void
SVTK_SelectorDef
::GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
theIndex.Clear();
}
+/*!
+ \return true if the index presents in subselection
+ \param theIO - SALOME_InteractiveObject
+ \param theIndex - index
+*/
bool
SVTK_SelectorDef
::IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
return anId;
}
-
+/*!
+ Changes indices of subselection for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+ \param theIndices - indices
+ \param theIsModeShift - if it is false, then map will be cleared before indices are added
+*/
bool
SVTK_SelectorDef
::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
for(int i = 1, iEnd = theIndices.Extent(); i <= iEnd; i++)
aMapIndex.Add(theIndices(i));
- if(aMapIndex.IsEmpty())
+ if(aMapIndex.IsEmpty()) {
myMapIOSubIndex.erase(theIO);
+ return false;
+ }
- return !aMapIndex.IsEmpty();
+ return true;
}
+/*!
+ Changes indices of subselection for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+ \param theIndices - indices
+ \param theIsModeShift - if it is false, then map will be cleared before indices are added
+*/
bool
SVTK_SelectorDef
::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
for(; anIter.More(); anIter.Next())
aMapIndex.Add(anIter.Key());
- if(aMapIndex.IsEmpty())
+ if(aMapIndex.IsEmpty()) {
myMapIOSubIndex.erase(theIO);
+ return false;
+ }
- return !aMapIndex.IsEmpty();
+ return true;
}
+/*!
+ Changes indices of subselection for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+ \param theIndex - index
+ \param theIsModeShift - if it is false, then map will be cleared before indices are added
+*/
bool
SVTK_SelectorDef
::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
}
+/*!
+ Removes index of subselection for SALOME_InteractiveObject
+ \param theIO - SALOME_InteractiveObject
+ \param theIndex - index
+*/
void
SVTK_SelectorDef
::RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
}
}
+/*!
+ Clears all indices of subselection
+*/
void
SVTK_SelectorDef
::ClearIndex()
{
myMapIOSubIndex.clear();
}
+
+/*!
+ To apply a filter on the selection
+ \param theFilter - new filter
+*/
+void
+SVTK_SelectorDef
+::SetFilter(const Handle(VTKViewer_Filter)& theFilter)
+{
+ myFilters.insert(TFilters::value_type(theFilter->GetId(),theFilter));
+}
+
+/*!
+ \return true if filter with given number is applyed
+ \param theId - filter id
+*/
+bool
+SVTK_SelectorDef
+::IsFilterPresent(const TFilterID theId) const
+{
+ return myFilters.find(theId) != myFilters.end();
+}
+
+/*!
+ To remove a filter from the selection
+ \param theId - filter id
+*/
+void
+SVTK_SelectorDef
+::RemoveFilter(const TFilterID theId)
+{
+ if(IsFilterPresent(theId))
+ myFilters.erase(theId);
+}
+
+/*!
+ \return true if the index satisfy installed filters
+ \param theActor - actor
+ \param theId - filter id
+ \param theIsNode - whether it is node
+*/
+bool
+SVTK_SelectorDef
+::IsValid(SALOME_Actor* theActor,
+ const TFilterID theId,
+ const bool theIsNode) const
+{
+ 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;
+}
+
+/*!
+ \return filter by it's id
+ \param theId - filter id
+*/
+Handle(VTKViewer_Filter)
+SVTK_SelectorDef
+::GetFilter(const TFilterID theId) const
+{
+ TFilters::const_iterator anIter = myFilters.find(theId);
+ if(anIter != myFilters.end()){
+ const Handle(VTKViewer_Filter)& aFilter = anIter->second;
+ return aFilter;
+ }
+ return Handle(VTKViewer_Filter)();
+}
+