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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 // File : SMESHGUI_SelectionOp.h
23 // Author : Alexander SOLOVYOV
27 #ifndef SMESHGUI_SelectionOp_H
28 #define SMESHGUI_SelectionOp_H
30 #include <SMESHGUI_Operation.h>
31 #include <SMESHGUI_Dialog.h>
32 #include <SVTK_Selection.h>
33 #include <SALOME_InteractiveObject.hxx>
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SMESH_Gen)
39 class SUIT_SelectionFilter;
40 class TColStd_MapOfInteger;
41 class SVTK_ViewWindow;
46 Class : SMESHGUI_SelectionOp
47 Description : Base operation for all operations using object selection in viewer or objectbrowser
48 through common widgets created by LightApp_Dialog::createObject
50 class SMESHGUI_SelectionOp : public SMESHGUI_Operation
55 typedef QValueList<int> IdList; //! List of node or element ids
58 SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection );
59 virtual ~SMESHGUI_SelectionOp();
61 static void extractIds( const QStringList&, IdList&, const QChar );
72 This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements,
73 because node end element ids may overlap
77 virtual void startOperation();
78 virtual void commitOperation();
79 virtual void abortOperation();
80 virtual void selectionDone();
82 //! sets the dialog widgets to state just after operation start
83 virtual void initDialog();
86 * Creates filter being used when certain object selection widget is active
87 * If no filter must be used, then function must return 0
88 * if id is negative, then function must return filter for common using independently of active widget
90 virtual SUIT_SelectionFilter* createFilter( const int ) const;
92 //! Remove only filters set by this operation (they are in map myFilters )
93 void removeCustomFilters();
95 //! Return what selection mode is set in VTK viewer
96 Selection_Mode selectionMode() const;
98 //! Set selection mode in VTK viewer
99 void setSelectionMode( const Selection_Mode );
101 //! Hilight object in VTK viewer
102 void highlight( const Handle( SALOME_InteractiveObject )&,
103 const bool, const bool = true );
105 //! Select some nodes or elements in VTK
106 void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&,
107 const TColStd_MapOfInteger&, const bool );
109 SVTK_ViewWindow* viewWindow() const;
110 SVTK_Selector* selector() const;
112 //! Get names, types and ids of selected objects
113 virtual void selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const;
116 virtual int typeById( const QString&, const EntityType ) const;
118 //! Char using to divide <entry> and <id> in string id representation. By default, '#'
119 virtual QChar idChar() const;
121 //! Try to find in certain object selection widget selected node or element ids and return it
122 void selectedIds( const int, IdList& ) const;
124 //! Find in QStringList correct node or element ids representation and append integer(id) to IdList
125 void extractIds( const QStringList&, IdList& ) const;
127 //! Return selected mesh if selection mode isn't ActorSelection and only one object is selected
128 SMESH::SMESH_Mesh_var mesh() const;
130 //! Return actor according to selected mesh if selection mode isn't ActorSelection
131 SMESH_Actor* actor() const;
134 //! Installs filter corresponding to certain object selection widget
135 virtual void onActivateObject( int );
137 //! Removes filter corresponding to certain object selection widget
138 virtual void onDeactivateObject( int );
141 * Empty default implementation. In successors it may be used for more advanced selection checking.
142 * This slot is connected to signal when the selection changed in some object selection widget
144 virtual void onSelectionChanged( int );
146 /*! Default implementation allowing user to edit selected ids "by hands".
147 In order to run default mechanism, you must set for some
148 object selection widget the "name indication" to "ListOfNames",
149 "read only" state to false and connect the dialog's signal "objectChanged"
151 Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!
153 virtual void onTextChanged( int, const QStringList& );
156 typedef QMap<int, SUIT_SelectionFilter*> Filters;
160 Selection_Mode myDefSelectionMode, myOldSelectionMode;