From 591583f233aa5b5323fb531415247f2bdce8a966 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 3 Jun 2005 09:50:22 +0000 Subject: [PATCH] To change CASCADE's collections to STL ones (first step) --- src/SVTK/SVTK_InteractorStyle.cxx | 3 +- src/SVTK/SVTK_Selector.cxx | 50 +++++------ src/SVTK/SVTK_Selector.h | 85 ++++++++++-------- src/SVTK/SVTK_SelectorDef.h | 143 ++++++++++++++++++++++++++++++ src/SVTK/SVTK_ViewWindow.cxx | 8 +- 5 files changed, 222 insertions(+), 67 deletions(-) create mode 100644 src/SVTK/SVTK_SelectorDef.h diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 8ffb553e1..2508794c3 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -959,7 +959,7 @@ SVTK_InteractorStyle if (anEdgeId >= 0) { if(MYDEBUG) INFOS(" CellId : "<AddOrRemoveIndex(anIO,anObjId,false); - GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,false); + GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,true); GetSelector()->AddIObject(aSActor); } } @@ -1361,7 +1361,6 @@ SVTK_InteractorStyle } } } - //if(MYDEBUG) INFOS ( " NAME PREVIEW " << aSActor->getName() ); } } } diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index cacf00081..e88d96bb9 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -36,38 +36,38 @@ #include "SVTK_ViewWindow.h" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SVTK_Selector.h" +#include "SVTK_SelectorDef.h" #include "utilities.h" -SVTK_Selector -::SVTK_Selector() +SVTK_SelectorDef +::SVTK_SelectorDef() { } -SVTK_Selector -::~SVTK_Selector() +SVTK_SelectorDef +::~SVTK_SelectorDef() { } void -SVTK_Selector +SVTK_SelectorDef ::SetSelectionMode(Selection_Mode theMode) { mySelectionMode = theMode; } void -SVTK_Selector +SVTK_SelectorDef ::ClearIObjects() { myIO2Actors.Clear(); myIObjects.Clear(); - myMapIOSubIndex.Clear(); + //myMapIOSubIndex.Clear(); } //---------------------------------------------------------------------------- bool -SVTK_Selector +SVTK_SelectorDef ::IsSelected(const Handle(SALOME_InteractiveObject)& theObject) const { SALOME_ListIteratorOfListIO anIter(myIObjects); @@ -80,7 +80,7 @@ SVTK_Selector } bool -SVTK_Selector +SVTK_SelectorDef ::IsSelected(SALOME_Actor* theActor) const { const Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); @@ -88,7 +88,7 @@ SVTK_Selector } SALOME_Actor* -SVTK_Selector +SVTK_SelectorDef ::GetActor(const Handle(SALOME_InteractiveObject)& theIO) const { if(myIO2Actors.IsBound(theIO)) @@ -98,7 +98,7 @@ SVTK_Selector //---------------------------------------------------------------------------- bool -SVTK_Selector +SVTK_SelectorDef ::AddIObject(const Handle(SALOME_InteractiveObject)& theIO) { if(!IsSelected(theIO)){ @@ -109,7 +109,7 @@ SVTK_Selector } bool -SVTK_Selector +SVTK_SelectorDef ::AddIObject(SALOME_Actor* theActor) { const Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); @@ -127,7 +127,7 @@ SVTK_Selector //---------------------------------------------------------------------------- bool -SVTK_Selector +SVTK_SelectorDef ::RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) { bool anIsIOBound = false; @@ -149,7 +149,7 @@ SVTK_Selector } bool -SVTK_Selector +SVTK_SelectorDef ::RemoveIObject(SALOME_Actor* theActor) { const Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); @@ -174,28 +174,28 @@ SVTK_Selector //---------------------------------------------------------------------------- const SALOME_ListIO& -SVTK_Selector +SVTK_SelectorDef ::StoredIObjects() const { return myIObjects; } int -SVTK_Selector +SVTK_SelectorDef ::IObjectCount() const { return myIObjects.Extent(); } bool -SVTK_Selector +SVTK_SelectorDef ::HasIndex( const Handle(SALOME_InteractiveObject)& theIO) const { return myMapIOSubIndex.IsBound(theIO); } void -SVTK_Selector +SVTK_SelectorDef ::GetIndex( const Handle(SALOME_InteractiveObject)& theIO, TColStd_IndexedMapOfInteger& theIndex) { @@ -206,7 +206,7 @@ SVTK_Selector } bool -SVTK_Selector +SVTK_SelectorDef ::IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, int theIndex) const { @@ -244,7 +244,7 @@ removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, bool -SVTK_Selector +SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, const TColStd_IndexedMapOfInteger& theIndices, bool theIsModeShift) @@ -269,7 +269,7 @@ SVTK_Selector bool -SVTK_Selector +SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, const TColStd_MapOfInteger& theIndices, bool theIsModeShift) @@ -296,7 +296,7 @@ SVTK_Selector bool -SVTK_Selector +SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, int theIndex, bool theIsModeShift) @@ -328,7 +328,7 @@ SVTK_Selector void -SVTK_Selector +SVTK_SelectorDef ::RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, int theIndex) { @@ -339,7 +339,7 @@ SVTK_Selector } void -SVTK_Selector +SVTK_SelectorDef ::ClearIndex() { myMapIOSubIndex.Clear(); diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index 548fd0963..0bcd90bc7 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -28,91 +28,104 @@ #ifndef SVTK_SELECTOR_H #define SVTK_SELECTOR_H -#include -#include + #include #include "SVTK_Selection.h" - #include "SALOME_ListIO.hxx" #include "SALOME_InteractiveObject.hxx" #include "SALOME_DataMapOfIOMapOfInteger.hxx" class SALOME_Actor; -class SVTK_Viewer; -class SVTK_ViewWindow; - class SVTK_Selector { public: - SVTK_Selector(); - virtual ~SVTK_Selector(); + virtual ~SVTK_Selector() = 0; + + virtual + void + SetSelectionMode( Selection_Mode theMode ) = 0; - void SetSelectionMode( Selection_Mode theMode ); - Selection_Mode SelectionMode() const { return mySelectionMode; } + virtual + Selection_Mode + SelectionMode() const = 0; + virtual void - ClearIObjects(); + ClearIObjects() = 0; + virtual SALOME_Actor* - GetActor(const Handle(SALOME_InteractiveObject)& theIO) const; + GetActor(const Handle(SALOME_InteractiveObject)& theIO) const = 0; + + virtual bool - IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const; + IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const = 0; + + virtual bool - IsSelected(SALOME_Actor* theActor) const; + IsSelected(SALOME_Actor* theActor) const = 0; + virtual bool - AddIObject(const Handle(SALOME_InteractiveObject)& theIO); + AddIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0; + + virtual bool - AddIObject(SALOME_Actor* theActor); + AddIObject(SALOME_Actor* theActor) = 0; + virtual bool - RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO); + RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0; + + virtual bool - RemoveIObject(SALOME_Actor* theActor); + RemoveIObject(SALOME_Actor* theActor) = 0; + virtual const SALOME_ListIO& - StoredIObjects() const; + StoredIObjects() const = 0; + virtual int - IObjectCount() const; + IObjectCount() const = 0; + virtual bool - HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const; + HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0; + virtual void GetIndex( const Handle(SALOME_InteractiveObject)& theIO, - TColStd_IndexedMapOfInteger& theIndex ); + TColStd_IndexedMapOfInteger& theIndex ) = 0; + virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, const TColStd_IndexedMapOfInteger& theIndices, - bool theIsModeShift); + bool theIsModeShift) = 0; + virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, const TColStd_MapOfInteger& theIndices, - bool theIsModeShift); + bool theIsModeShift) = 0; + virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, int theIndex, - bool theIsModeShift); + bool theIsModeShift) = 0; + virtual void RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - int theIndex); + int theIndex) = 0; + virtual bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, - int theIndex) const; + int theIndex) const = 0; + virtual void - ClearIndex(); - -private: - typedef NCollection_DataMap > TIO2Actors; - TIO2Actors myIO2Actors; - Selection_Mode mySelectionMode; - SALOME_ListIO myIObjects; - SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex; + ClearIndex() = 0; }; diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h new file mode 100644 index 000000000..ec7ae91aa --- /dev/null +++ b/src/SVTK/SVTK_SelectorDef.h @@ -0,0 +1,143 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Selection.h +// Author : Nicolas REJNERI +// Module : SALOME +// $Header$ + +#ifndef SVTK_SELECTORDEF_H +#define SVTK_SELECTORDEF_H + +#include +#include +#include + +#include "SVTK_Selector.h" + +class SALOME_Actor; + +class SVTK_Viewer; +class SVTK_ViewWindow; + +class SVTK_SelectorDef: public SVTK_Selector +{ +public: + SVTK_SelectorDef(); + virtual ~SVTK_SelectorDef(); + + virtual + void + SetSelectionMode( Selection_Mode theMode ); + + virtual + Selection_Mode + SelectionMode() const { return mySelectionMode; } + + virtual + void + ClearIObjects(); + + virtual + SALOME_Actor* + GetActor(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); + + virtual + bool + AddIObject(SALOME_Actor* theActor); + + virtual + bool + RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO); + + virtual + bool + RemoveIObject(SALOME_Actor* theActor); + + virtual + const SALOME_ListIO& + StoredIObjects() 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 ); + + virtual + bool + AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, + const TColStd_IndexedMapOfInteger& theIndices, + bool theIsModeShift); + virtual + bool + AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, + const TColStd_MapOfInteger& theIndices, + bool theIsModeShift); + virtual + bool + AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, + int theIndex, + bool theIsModeShift); + virtual + void + RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, + int theIndex); + virtual + bool + IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, + int theIndex) const; + virtual + void + ClearIndex(); + +private: + typedef NCollection_DataMap > TIO2Actors; + TIO2Actors myIO2Actors; + Selection_Mode mySelectionMode; + SALOME_ListIO myIObjects; + SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex; +}; + + +#endif diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index a6d58a5c2..693412c17 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -1,6 +1,3 @@ -#include "SVTK_Selector.h" -#include "SALOME_Actor.h" - #include #include @@ -30,6 +27,9 @@ #include "SALOME_ListIteratorOfListIO.hxx" +#include "SVTK_SelectorDef.h" +#include "SALOME_Actor.h" + #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" @@ -40,7 +40,7 @@ SVTK_ViewWindow : SUIT_ViewWindow(theDesktop) { myModel = theModel; - mySelector = new SVTK_Selector(); + mySelector = new SVTK_SelectorDef(); connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged())); myTransform = VTKViewer_Transform::New(); -- 2.39.2