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