1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_SelectionOp.h
23 // Author : Alexander SOLOVYOV
27 #ifndef SMESHGUI_SelectionOp_H
28 #define SMESHGUI_SelectionOp_H
30 #include "SMESH_SMESHGUI.hxx"
32 #include <SMESHGUI_Operation.h>
33 #include <SMESHGUI_Dialog.h>
34 #include <SVTK_Selection.h>
35 #include <SALOME_InteractiveObject.hxx>
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Gen)
41 class SUIT_SelectionFilter;
42 class TColStd_MapOfInteger;
43 class SVTK_ViewWindow;
48 Class : SMESHGUI_SelectionOp
49 Description : Base operation for all operations using object selection in viewer or objectbrowser
50 through common widgets created by LightApp_Dialog::createObject
52 class SMESHGUI_EXPORT SMESHGUI_SelectionOp : public SMESHGUI_Operation
57 typedef QValueList<int> IdList; //! List of node or element ids
60 SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
61 virtual ~SMESHGUI_SelectionOp();
63 static void extractIds( const QStringList&, IdList&, const QChar );
74 This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements,
75 because node end element ids may overlap
79 virtual void startOperation();
80 virtual void commitOperation();
81 virtual void abortOperation();
82 virtual void selectionDone();
84 //! sets the dialog widgets to state just after operation start
85 virtual void initDialog();
88 * Creates filter being used when certain object selection widget is active
89 * If no filter must be used, then function must return 0
90 * if id is negative, then function must return filter for common using independently of active widget
92 virtual SUIT_SelectionFilter* createFilter( const int ) const;
94 //! Remove only filters set by this operation (they are in map myFilters )
95 void removeCustomFilters();
97 //! Return what selection mode is set in VTK viewer
98 Selection_Mode selectionMode() const;
100 //! Set selection mode in VTK viewer
101 void setSelectionMode( const Selection_Mode );
103 //! Hilight object in VTK viewer
104 void highlight( const Handle( SALOME_InteractiveObject )&,
105 const bool, const bool = true );
107 //! Select some nodes or elements in VTK
108 void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
109 const TColStd_MapOfInteger&, const bool );
111 SVTK_ViewWindow* viewWindow() const;
112 SVTK_Selector* selector() const;
114 //! Get names, types and ids of selected objects
115 virtual void selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
118 virtual int typeById( const QString&, const EntityType ) const;
120 //! Char using to divide <entry> and <id> in string id representation. By default, '#'
121 virtual QChar idChar() const;
123 //! Try to find in certain object selection widget selected node or element ids and return it
124 void selectedIds( const int, IdList& ) const;
126 //! Find in QStringList correct node or element ids representation and append integer(id) to IdList
127 void extractIds( const QStringList&, IdList& ) const;
129 //! Return selected mesh if selection mode isn't ActorSelection and only one object is selected
130 SMESH::SMESH_Mesh_var mesh() const;
132 //! Return actor according to selected mesh if selection mode isn't ActorSelection
133 SMESH_Actor* actor() const;
136 //! Installs filter corresponding to certain object selection widget
137 virtual void onActivateObject( int );
139 //! Removes filter corresponding to certain object selection widget
140 virtual void onDeactivateObject( int );
143 * Empty default implementation. In successors it may be used for more advanced selection checking.
144 * This slot is connected to signal when the selection changed in some object selection widget
146 virtual void onSelectionChanged( int );
148 /*! Default implementation allowing user to edit selected ids "by hands".
149 In order to run default mechanism, you must set for some
150 object selection widget the "name indication" to "ListOfNames",
151 "read only" state to false and connect the dialog's signal "objectChanged"
153 Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!
155 virtual void onTextChanged( int, const QStringList& );
158 typedef QMap<int, SUIT_SelectionFilter*> Filters;
162 Selection_Mode myDefSelectionMode, myOldSelectionMode;