From 6d06313695b08b46989753b55c9f063552789d97 Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 18 Dec 2017 20:09:18 +0300 Subject: [PATCH] Merge ASERIS development. --- src/SALOME_SWIG/SALOMEGUI_Swig.cxx | 4 +- src/SVTK/CMakeLists.txt | 1 + src/SVTK/SALOME_Actor.cxx | 103 ++++++++++++++---- src/SVTK/SVTK_Actor.cxx | 36 +++++++ src/SVTK/SVTK_Actor.h | 13 ++- src/SVTK/SVTK_Hash.h | 57 ++++++++++ src/SVTK/SVTK_Selector.cxx | 168 ++++++++++++++++++++++++++++- src/SVTK/SVTK_Selector.h | 44 ++++++++ src/SVTK/SVTK_SelectorDef.h | 46 +++++++- src/VTKViewer/VTKViewer_Actor.cxx | 11 ++ src/VTKViewer/VTKViewer_Actor.h | 5 + 11 files changed, 459 insertions(+), 29 deletions(-) create mode 100644 src/SVTK/SVTK_Hash.h diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index c6b25bdad..32178b894 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -628,7 +628,7 @@ public: if (!viewMgr) return; SUIT_ViewWindow* window = viewMgr->getActiveView(); if ( window ) { - SALOME_View* view = dynamic_cast( window->getViewManager()->getActiveView() ); + SALOME_View* view = dynamic_cast( window->getViewManager()->getViewModel() ); if ( view ) { SALOME_Prs* aPrs = view->CreatePrs( myEntry.toLatin1() ); myResult = !aPrs->IsNull(); @@ -658,7 +658,7 @@ void SALOMEGUI_Swig::UpdateView() if (!viewMgr) return; SUIT_ViewWindow* window = viewMgr->getActiveView(); if ( window ) { - SALOME_View* view = dynamic_cast( window->getViewManager()->getActiveView() ); + SALOME_View* view = dynamic_cast( window->getViewManager()->getViewModel() ); if ( view ) view->Repaint(); } diff --git a/src/SVTK/CMakeLists.txt b/src/SVTK/CMakeLists.txt index 493e5651c..611319e14 100755 --- a/src/SVTK/CMakeLists.txt +++ b/src/SVTK/CMakeLists.txt @@ -99,6 +99,7 @@ SET(_other_HEADERS SVTK_Selector.h SVTK_SpaceMouse.h SVTK_Utils.h + SVTK_Hash.h ) # header files / no moc processing / internal diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index eafd19747..b0e88eca6 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -84,9 +84,11 @@ int SALOME_LINE_WIDTH = 3; namespace { int - GetEdgeId(SALOME_Actor* theActor, - vtkPicker* thePicker, - int theObjId) + GetEdgeAndNodesId(SALOME_Actor* theActor, + vtkPicker* thePicker, + int theObjId, + int& theFirstNodeId, + int& theSecondNodeId) { int anEdgeId = 0; if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) { @@ -104,6 +106,8 @@ namespace if (aDist < aMinDist) { aMinDist = aDist; anEdgeId = -1 - i; + theFirstNodeId = aSelEdge->GetPointId(0); + theSecondNodeId = aSelEdge->GetPointId(1); } } } @@ -447,15 +451,11 @@ SALOME_Actor if(mySelectionMode != ActorSelection){ TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); - switch( mySelectionMode ){ + switch( mySelectionMode ) { case NodeSelection: myHighlightActor->GetProperty()->SetRepresentationToPoints(); myHighlightActor->MapPoints( this, aMapIndex ); break; - case EdgeOfCellSelection: - myHighlightActor->GetProperty()->SetRepresentationToWireframe(); - myHighlightActor->MapEdge( this, aMapIndex ); - break; case CellSelection: case EdgeSelection: case FaceSelection: @@ -465,6 +465,12 @@ SALOME_Actor myHighlightActor->GetProperty()->SetRepresentationToSurface(); myHighlightActor->MapCells( this, aMapIndex ); break; + case EdgeOfCellSelection: + SVTK_IndexedMapOfIds aMapCompositeIndex; + mySelector->GetCompositeIndex( getIO(), aMapCompositeIndex ); + myHighlightActor->GetProperty()->SetRepresentationToWireframe(); + myHighlightActor->MapEdge( this, aMapCompositeIndex ); + break; } myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight ); } @@ -597,20 +603,24 @@ SALOME_Actor if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) { int anObjId = GetElemObjId( aVtkId ); if ( anObjId >= 0 ) { - int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); + int aFNId, aSNId; + int anEdgeId = GetEdgeAndNodesId(this,myCellPicker.GetPointer(),anObjId,aFNId,aSNId); myIsPreselected = anEdgeId < 0; if(myIsPreselected){ - const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); - int anExtent = aMapIndex.Extent(); - anIsChanged |= (anExtent == 0 || anExtent == 1); - anIsChanged |= (anExtent == 2 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2))); - if(anIsChanged){ - TColStd_IndexedMapOfInteger aMapIndex; - aMapIndex.Add( anObjId ); - aMapIndex.Add( anEdgeId ); - + int aFNObjId = GetNodeObjId( aFNId ); + int aSNObjId = GetNodeObjId( aSNId ); + const SVTK_IndexedMapOfIds& aMapIds = myPreHighlightActor->GetMapCompositeIndex(); + int anExtent = aMapIds.Extent(); + anIsChanged |= (anExtent == 0 || (anExtent > 0 && aMapIds(1).size() == 2 && + (aFNObjId != aMapIds(1)[0] || aSNObjId != aMapIds(1)[1] ) ) ); + if( anIsChanged ) { + SVTK_IndexedMapOfIds aMapIds; + SVTK_ListOfInteger aCompositeID; + aCompositeID.push_back( aFNObjId ); + aCompositeID.push_back( aSNObjId ); + aMapIds.Add( aCompositeID ); myPreHighlightActor->GetProperty()->SetRepresentationToWireframe(); - myPreHighlightActor->MapEdge( this, aMapIndex ); + myPreHighlightActor->MapEdge( this, aMapIds ); } myPreHighlightActor->SetVisibility( true ); } @@ -798,6 +808,50 @@ SALOME_Actor else if ( !anIsShift ) mySelector->RemoveIObject( this ); } + break; + } + case EdgeOfCellSelection: + { + SVTK::TPickLimiter aPickLimiter( myCellAreaPicker, this ); + if( theSelectionEvent->myIsRectangle ) + myCellAreaPicker->Pick( x1, y1, x2, y2, aRenderer, SVTK_AreaPicker::RectangleMode ); + else if( theSelectionEvent->myIsPolygon ) + myCellAreaPicker->Pick( theSelectionEvent->myPolygonPoints, aRenderer, SVTK_AreaPicker::PolygonMode ); + + const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myCellAreaPicker->GetCellIdsMap(); + SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this); + SVTK_IndexedMapOfIds anIndexes; + if(aMapIter != aVectorIdsMap.end()){ + const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second; + vtkIdType anEnd = aVectorIds.size(); + for(vtkIdType anId = 0; anId < anEnd; anId++ ) { + int aCellId = aVectorIds[anId]; + if ( !mySelector->IsValid( this, aCellId ) ) + continue; + + int anObjId = GetElemObjId( aCellId ); + if( anObjId != -1 ) { + int aFNId, aSNId; + int anEdgeId = GetEdgeAndNodesId(this,myCellPicker.GetPointer(),anObjId,aFNId,aSNId); + if( anEdgeId < 0 ) { + SVTK_ListOfInteger aCompositeID; + aCompositeID.push_back( GetNodeObjId( aFNId ) ); + aCompositeID.push_back( GetNodeObjId( aSNId ) ); + anIndexes.Add( aCompositeID ); + } + } + } + } + + if ( hasIO() ) { + if( !anIndexes.IsEmpty() ) { + mySelector->AddOrRemoveCompositeIndex( myIO, anIndexes, anIsShift ); + mySelector->AddIObject( this ); + anIndexes.Clear(); + } + else if ( !anIsShift ) + mySelector->RemoveIObject( this ); + } } default: break; @@ -850,11 +904,14 @@ SALOME_Actor if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) { int anObjId = GetElemObjId( aVtkId ); if( anObjId >= 0 ) { - int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); + int aFNId, aSNId; + int anEdgeId = GetEdgeAndNodesId(this,myCellPicker.GetPointer(),anObjId,aFNId,aSNId); if( hasIO() && anEdgeId < 0 ) { - mySelector->AddOrRemoveIndex( myIO, anObjId, false ); - mySelector->AddOrRemoveIndex( myIO, anEdgeId, true ); - mySelector->AddIObject( this ); + SVTK_ListOfInteger aCompositeID; + aCompositeID.push_back( GetNodeObjId( aFNId ) ); + aCompositeID.push_back( GetNodeObjId( aSNId ) ); + mySelector->AddOrRemoveCompositeIndex( myIO, aCompositeID, anIsShift ); + mySelector->AddIObject( this ); } } } diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index a4e404ee6..d41044469 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -103,6 +103,14 @@ SVTK_Actor return myMapIndex; } + +const SVTK_IndexedMapOfIds& +SVTK_Actor +::GetMapCompositeIndex() const +{ + return myMapCompositeIndex; +} + void SVTK_Actor ::MapCells(SALOME_Actor* theMapActor, @@ -213,6 +221,34 @@ SVTK_Actor myMapIndex = theMapIndex; } +void +SVTK_Actor +::MapEdge( SALOME_Actor* theMapActor, + const SVTK_IndexedMapOfIds& theMapCompositeIndex) { + myUnstructuredGrid->Initialize(); + myUnstructuredGrid->Allocate(); + + vtkUnstructuredGrid * aSourceGrid = ( vtkUnstructuredGrid * )theMapActor->GetInput(); + GetSource()->SetPoints( aSourceGrid->GetPoints() ); + + int aNbOfParts = theMapCompositeIndex.Extent(); + for(int ind = 1; ind <= aNbOfParts; ind++){ + std::vector aNodesIds = theMapCompositeIndex( ind ); + vtkSmartPointer ids = vtkSmartPointer::New(); + ids->InsertNextId(theMapActor->GetNodeVtkId( aNodesIds[0] ) ); + ids->InsertNextId(theMapActor->GetNodeVtkId( aNodesIds[1] ) ); + myUnstructuredGrid->InsertNextCell(VTK_LINE,ids); + } + + UnShrink(); + if(theMapActor->IsShrunk()){ + SetShrinkFactor(theMapActor->GetShrinkFactor()); + SetShrink(); + } + + myMapCompositeIndex = theMapCompositeIndex; +} + /*! To publish the actor an all its internal devices */ diff --git a/src/SVTK/SVTK_Actor.h b/src/SVTK/SVTK_Actor.h index 3b18d036b..5b27bffeb 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -23,6 +23,7 @@ #ifndef SVTK_ACTOR_H #define SVTK_ACTOR_H +#include "SVTK_Selector.h" #include class vtkRenderer; @@ -32,7 +33,7 @@ class vtkUnstructuredGrid; #include "SVTK.h" #include "SVTK_DeviceActor.h" - +#include "SVTK_Hash.h" #include class SALOME_Actor; @@ -83,11 +84,21 @@ public: MapEdge(SALOME_Actor* theMapActor, const TColStd_IndexedMapOfInteger& theMapIndex); +//! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes using corner node ids + virtual void + MapEdge(SALOME_Actor* theMapActor, + const SVTK_IndexedMapOfIds& theMapCompositeIndex); + + const TColStd_IndexedMapOfInteger& GetMapIndex() const; + const SVTK_IndexedMapOfIds& + GetMapCompositeIndex() const; + protected: TColStd_IndexedMapOfInteger myMapIndex; + SVTK_IndexedMapOfIds myMapCompositeIndex; vtkSmartPointer myUnstructuredGrid; diff --git a/src/SVTK/SVTK_Hash.h b/src/SVTK/SVTK_Hash.h new file mode 100644 index 000000000..4f045d510 --- /dev/null +++ b/src/SVTK/SVTK_Hash.h @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SALOME SALOMEGUI : +// File : SVTK_Hash.h +// Author : Roman NIKOLAEV + +#ifndef SVTK_HASH_H +#define SVTK_HASH_H + +#include +#include +#include + +typedef std::vector SVTK_ListOfInteger; + +class SVTK_Hasher { + +public: + static Standard_Integer HashCode(const std::vector ids, + const Standard_Integer upper) { + Standard_Integer seed = ids.size(); + for( Standard_Integer i = 0; i < (Standard_Integer) ids.size(); i++ ) { + Standard_Integer v = ids[i]; + seed ^= v + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 ); + } + return ::HashCode(seed,upper); + } + + static Standard_Boolean IsEqual(const SVTK_ListOfInteger& theKey1, + const SVTK_ListOfInteger& theKey2) { + return theKey1 == theKey2; + } +}; + +typedef NCollection_IndexedMap SVTK_IndexedMapOfIds; + +#endif // SVTK_HASH_H diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 51b32f21e..885f3485d 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -23,7 +23,6 @@ // SALOME SALOMEGUI : implementation of desktop and GUI kernel // File : SALOME_Selection.cxx // Author : Nicolas REJNERI - #include "SVTK_SelectorDef.h" #include @@ -106,6 +105,7 @@ SVTK_SelectorDef if(mySelectionMode != theMode){ mySelectionMode = theMode; myMapIOSubIndex.clear(); + myMapIOSubCompositeIndex.clear(); this->EndPickCallback(); } } @@ -120,6 +120,7 @@ SVTK_SelectorDef myIO2Actors.clear(); myIObjects.clear(); myMapIOSubIndex.clear(); + myMapIOSubCompositeIndex.clear(); } /*! @@ -206,6 +207,7 @@ SVTK_SelectorDef myIObjects.erase(theIO); myIO2Actors.erase(theIO); myMapIOSubIndex.erase(theIO); + myMapIOSubCompositeIndex.erase(theIO); return anIsIOBound; } @@ -321,6 +323,29 @@ static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theI return anId != 0; } +static bool removeCompositeIndex( SVTK_IndexedMapOfIds& theMapIndex, const SVTK_ListOfInteger theIds ) +{ + int anId = theMapIndex.FindIndex( theIds ); // i==0 if Index is not in the MapIndex + if( anId ) { + // only the last key can be removed + SVTK_ListOfInteger aLastIds = theMapIndex.FindKey( theMapIndex.Extent() ); + if( aLastIds == theIds ) + theMapIndex.RemoveLast(); + else { + SVTK_IndexedMapOfIds aNewMap; + aNewMap.ReSize(theMapIndex.Extent()-1); + for( int j = 1; j <= theMapIndex.Extent(); j++ ){ + SVTK_ListOfInteger anIds = theMapIndex( j ); + if ( anIds != theIds ) + aNewMap.Add( anIds ); + } + theMapIndex = aNewMap; + } + } + return anId != 0; +} + + /*! Changes indices of subselection for SALOME_InteractiveObject \param theIO - SALOME_InteractiveObject @@ -456,6 +481,147 @@ SVTK_SelectorDef myMapIOSubIndex.clear(); } +/*! + \return true if the SALOME_InteractiveObject has a composite index subselection + \param theIO - SALOME_InteractiveObject +*/ +bool +SVTK_SelectorDef +::HasCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO ) const +{ + return myMapIOSubCompositeIndex.find( theIO ) != myMapIOSubCompositeIndex.end(); +} + +/*! + Gets composite indices of subselection for SALOME_InteractiveObject + \param theIO - SALOME_InteractiveObject +*/ +void +SVTK_SelectorDef +::GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_IndexedMapOfIds& theIds ) +{ + TMapIOSubCompositeIndex::const_iterator anIter = myMapIOSubCompositeIndex.find( theIO ); + if( anIter != myMapIOSubCompositeIndex.end() ) + theIds = anIter->second; + else + theIds.Clear(); +} + +/*! + Changes composite indices of subselection for SALOME_InteractiveObject + \param theIO - SALOME_InteractiveObject + \param theIndices - composite id + \param theIsModeShift - if it is false, then map will be cleared before indices are added +*/ +bool +SVTK_SelectorDef +::AddOrRemoveCompositeIndex( const Handle( SALOME_InteractiveObject )& theIO, + const SVTK_IndexedMapOfIds& theIds, + bool theIsModeShift) +{ + TMapIOSubCompositeIndex::iterator aMapIter = myMapIOSubCompositeIndex.find( theIO ); + if( aMapIter == myMapIOSubCompositeIndex.end() ) { + SVTK_IndexedMapOfIds anEmpty; + aMapIter = myMapIOSubCompositeIndex.insert( TMapIOSubCompositeIndex::value_type( theIO, anEmpty ) ).first; + } + SVTK_IndexedMapOfIds& aMapIndex = aMapIter->second; + + if( !theIsModeShift ) + aMapIndex.Clear(); + + for( int i = 1, iEnd = theIds.Extent(); i <= iEnd; i++ ) + aMapIndex.Add( theIds( i ) ); + + if( aMapIndex.IsEmpty() ) { + myMapIOSubCompositeIndex.erase( theIO ); + return false; + } + return true; +} + +/*! + Changes indices of subselection for SALOME_InteractiveObject + \param theIO - SALOME_InteractiveObject + \param theIds - composite ids + \param theIsModeShift - if it is false, then map will be cleared before indices are added +*/ +bool +SVTK_SelectorDef +::AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds, + bool theIsModeShift) +{ + TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); + if( anIter == myMapIOSubCompositeIndex.end() ) { + SVTK_IndexedMapOfIds anEmpty; + anIter = myMapIOSubCompositeIndex.insert(TMapIOSubCompositeIndex::value_type( theIO,anEmpty ) ).first; + } + + SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + + bool anIsContains = aMapIndex.Contains( theIds ) == Standard_True; + if ( anIsContains ) + removeCompositeIndex( aMapIndex, theIds ); + + if ( !theIsModeShift ) + aMapIndex.Clear(); + + if ( !anIsContains ) + aMapIndex.Add( theIds ); + + if ( aMapIndex.IsEmpty() ) + myMapIOSubIndex.erase( theIO ); + + return false; +} + +/*! + Removes composite index of subselection for SALOME_InteractiveObject + \param theIO - SALOME_InteractiveObject + \param theIds - index +*/ +void +SVTK_SelectorDef +::RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds ) +{ + if(IsCompositeIndexSelected( theIO, theIds ) ) { + TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); + SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + removeCompositeIndex( aMapIndex,theIds ); + } +} + +/*! + \return true if the composite index presents in subselection + \param theIO - SALOME_InteractiveObject + \param theIds - index +*/ +bool +SVTK_SelectorDef +::IsCompositeIndexSelected( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds ) const +{ + TMapIOSubCompositeIndex::const_iterator anIter = myMapIOSubCompositeIndex.find( theIO ); + if( anIter != myMapIOSubCompositeIndex.end() ) { + const SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + return aMapIndex.Contains( theIds ) == Standard_True; + } + return false; +} + +/*! + Clears all composite indices of subselection +*/ +void +SVTK_SelectorDef +::ClearCompositeIndex() +{ + myMapIOSubCompositeIndex.clear(); +} + + /*! To apply a filter on the selection \param theFilter - new filter diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index c5c9831a5..7b33b3d36 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -29,6 +29,8 @@ #include "SVTK.h" #include "SVTK_Selection.h" +#include "SVTK_Hash.h" + #include "SALOME_ListIO.hxx" #include @@ -168,6 +170,48 @@ public: void ClearIndex() = 0; + /// ! Composite indexes + virtual + bool + HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0; + + //! Get composite indexes of subslection for given #SALOME_InteractiveObject + virtual + void + GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_IndexedMapOfIds& theIds ) = 0; + + //! Change composite indices of subselection for given #SALOME_InteractiveObject + virtual + bool + AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + const SVTK_IndexedMapOfIds& theIds, + bool theIsModeShift) = 0; + + //! Change composite index of subslection for given #SALOME_InteractiveObject + virtual + bool + AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger ids, + bool theIsModeShift) = 0; + + //! Change composite index of subslection for given #SALOME_InteractiveObject + virtual + void + RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger ids ) = 0; + + //! Check, if the given composite index is present in subselection + virtual + bool + IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger ids ) const = 0; + + //! Clear composite indexes subselection + virtual + void + ClearCompositeIndex() = 0; + //---------------------------------------------------------------------------- typedef int TFilterID; diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index 2bec20757..c2e60309b 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -27,6 +27,8 @@ #ifndef SVTK_SELECTORDEF_H #define SVTK_SELECTORDEF_H +#include "SVTK_Selector.h" + #include #include @@ -36,8 +38,6 @@ #include "SALOME_InteractiveObject.hxx" -#include "SVTK_Selector.h" - class SALOME_Actor; class SVTK_Viewer; @@ -135,6 +135,42 @@ public: void ClearIndex(); + //---------------------------------------------------------------------------- + /// ! Composite indexes + virtual + bool + HasCompositeIndex(const Handle(SALOME_InteractiveObject)& theIO ) const; + + virtual + void + GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_IndexedMapOfIds& theIds ); + virtual + bool + AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + const SVTK_IndexedMapOfIds& theIds, + bool theIsModeShift); + + virtual + bool + AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds, + bool theIsModeShift); + + virtual + void + RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds ); + + virtual + bool + IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ListOfInteger theIds ) const; + + virtual + void + ClearCompositeIndex(); + //---------------------------------------------------------------------------- virtual void @@ -243,6 +279,12 @@ private: TIOLessThan> TMapIOSubIndex; TMapIOSubIndex myMapIOSubIndex; + typedef std::map TMapIOSubCompositeIndex; + TMapIOSubCompositeIndex myMapIOSubCompositeIndex; + + typedef std::map TFilters; TFilters myFilters; diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index 56312d57d..c3f17f6e0 100755 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -450,6 +450,17 @@ VTKViewer_Actor return GetInput()->GetPoint(theObjID); } +/*! + Maps object index of a node to corresponding VTK index +*/ +int +VTKViewer_Actor +::GetNodeVtkId( int theObjID ) +{ + return theObjID; +} + + /*! Get corresponding #vtkCell for given object index */ diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index 306578bec..478623638 100755 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -146,6 +146,11 @@ class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor double* GetNodeCoord(int theObjID); + //! Maps object index of a node to corresponding VTK index + virtual + int + GetNodeVtkId(int theObjID); + //! Maps VTK index of a cell to corresponding object index virtual int -- 2.39.2