Salome HOME
Merge from V5_1_main branch 24/11/2010
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_ObjectReferenceParamWdg.h
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : StdMeshersGUI_ObjectReferenceParamWdg.h
24 // Author : Open CASCADE S.A.S.
25 //
26 #ifndef STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H
27 #define STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H
28
29 // SMESH includes
30 #include "SMESH_StdMeshersGUI.hxx"
31
32 #include <SMESH_Type.h>
33
34 // Qt includes
35 #include <QWidget>
36
37 // CORBA includes
38 #include <CORBA.h>
39
40 #include CORBA_SERVER_HEADER(SMESH_Mesh)
41
42 class SUIT_SelectionFilter;
43 class SMESHGUI;
44 class LightApp_SelectionMgr;
45 class QLineEdit;
46 class QPushButton;
47
48 /*!
49  *  \brief Widget controlling hypothesis parameter that is an object reference
50  */
51 class STDMESHERSGUI_EXPORT StdMeshersGUI_ObjectReferenceParamWdg : public QWidget
52 {
53   Q_OBJECT
54
55 public:
56   StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, 
57                                          QWidget*              parent,
58                                          bool                  multiSelection=false);
59   StdMeshersGUI_ObjectReferenceParamWdg( MeshObjectType objType,
60                                          QWidget*       parent,
61                                          bool           multiSelection=false);
62   ~StdMeshersGUI_ObjectReferenceParamWdg();
63
64   void SetObject(CORBA::Object_ptr obj);
65
66   void SetObjects(SMESH::string_array_var& objEntries);
67
68   template<class TInterface> 
69     typename TInterface::_var_type GetObject(unsigned i=0) const {
70     if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
71     return TInterface::_nil();
72   }
73
74   int NbObjects() const { return myObjects.size(); }
75
76   QString GetValue() const { return myParamValue; }
77
78   bool IsObjectSelected(unsigned i=0) const
79   { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
80
81   void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
82
83 public slots:
84   /*!
85    * \brief Activates selection (if not yet done), emits selectionActivated()
86     *
87     * Useful to deactivate one Object Reference param widget when an other
88     * one is activated
89    */
90   void activateSelection();
91   void deactivateSelection();
92
93 signals:
94   /*!
95    * \brief Emitted when selection is activated
96     *
97     * Useful to deactivate one Object Reference param widget when an other
98     * one is activated
99    */
100   void selectionActivated();
101   
102 private slots:
103   void onSelectionDone(); 
104
105 private:
106   void init();
107   
108 private:
109
110   bool                                myMultiSelection;
111   std::vector<CORBA::Object_var>      myObjects;
112
113  SUIT_SelectionFilter*  myFilter;
114  bool                   mySelectionActivated;
115
116  SMESHGUI*              mySMESHGUI;
117  LightApp_SelectionMgr* mySelectionMgr;
118
119  QLineEdit*             myObjNameLineEdit;
120  QPushButton*           mySelButton;
121  QString                myParamValue;
122 };
123
124 #endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H