Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_ObjectReferenceParamWdg.h
1 // Copyright (C) 2007-2011  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                                          bool                  stretch=true);
60   StdMeshersGUI_ObjectReferenceParamWdg( MeshObjectType objType,
61                                          QWidget*       parent,
62                                          bool           multiSelection=false);
63   ~StdMeshersGUI_ObjectReferenceParamWdg();
64
65   void SetObject(CORBA::Object_ptr obj);
66
67   void SetObjects(SMESH::string_array_var& objEntries);
68
69   template<class TInterface> 
70     typename TInterface::_var_type GetObject(unsigned i=0) const {
71     if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
72     return TInterface::_nil();
73   }
74
75   int NbObjects() const { return myObjects.size(); }
76
77   QString GetValue() const { return myParamValue; }
78
79   bool IsObjectSelected(unsigned i=0) const
80   { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
81
82   void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
83   
84   void SetDefaultText(QString defaultText="", QString styleSheet="");
85
86 public slots:
87   /*!
88    * \brief Activates selection (if not yet done), emits selectionActivated()
89     *
90     * Useful to deactivate one Object Reference param widget when an other
91     * one is activated
92    */
93   void activateSelection();
94   void deactivateSelection();
95
96 signals:
97   /*!
98    * \brief Emitted when selection is activated
99     *
100     * Useful to deactivate one Object Reference param widget when an other
101     * one is activated
102    */
103   void selectionActivated();
104   void contentModified();
105   
106 private slots:
107   void onSelectionDone(); 
108
109 private:
110   void init();
111   
112 private:
113
114   bool                                myMultiSelection;
115   std::vector<CORBA::Object_var>      myObjects;
116
117  SUIT_SelectionFilter*  myFilter;
118  bool                   mySelectionActivated;
119  bool                   myStretchActivated;
120
121  SMESHGUI*              mySMESHGUI;
122  LightApp_SelectionMgr* mySelectionMgr;
123
124  QLineEdit*             myObjNameLineEdit;
125  QPushButton*           mySelButton;
126  QString                myParamValue;
127  QString                myEmptyText;
128  QString                myEmptyStyleSheet;
129 };
130
131 #endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H