Back to index

salome-smesh  6.5.0
StdMeshersGUI_ObjectReferenceParamWdg.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File   : StdMeshersGUI_ObjectReferenceParamWdg.h
00024 // Author : Open CASCADE S.A.S.
00025 //
00026 #ifndef STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H
00027 #define STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H
00028 
00029 // SMESH includes
00030 #include "SMESH_StdMeshersGUI.hxx"
00031 
00032 #include <SMESH_Type.h>
00033 
00034 // Qt includes
00035 #include <QWidget>
00036 
00037 // CORBA includes
00038 #include <CORBA.h>
00039 
00040 #include <SALOMEconfig.h>
00041 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00042 
00043 class SUIT_SelectionFilter;
00044 class SMESHGUI;
00045 class LightApp_SelectionMgr;
00046 class QLineEdit;
00047 class QPushButton;
00048 
00052 class STDMESHERSGUI_EXPORT StdMeshersGUI_ObjectReferenceParamWdg : public QWidget
00053 {
00054   Q_OBJECT
00055 
00056 public:
00057   StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, 
00058                                          QWidget*              parent,
00059                                          bool                  multiSelection=false,
00060                                          bool                  stretch=true);
00061   StdMeshersGUI_ObjectReferenceParamWdg( MeshObjectType objType,
00062                                          QWidget*       parent,
00063                                          bool           multiSelection=false);
00064   ~StdMeshersGUI_ObjectReferenceParamWdg();
00065 
00066   void SetObject(CORBA::Object_ptr obj);
00067 
00068   void SetObjects(SMESH::string_array_var& objEntries);
00069 
00070   template<class TInterface> 
00071     typename TInterface::_var_type GetObject(unsigned i=0) const {
00072     if ( IsObjectSelected(i) ) return TInterface::_narrow(myObjects[i]);
00073     return TInterface::_nil();
00074   }
00075 
00076   int NbObjects() const { return myObjects.size(); }
00077 
00078   QString GetValue() const { return myParamValue; }
00079 
00080   bool IsObjectSelected(unsigned i=0) const
00081   { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
00082 
00083   void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
00084   
00085   void SetDefaultText(QString defaultText="", QString styleSheet="");
00086 
00087 public slots:
00094   void activateSelection();
00095   void deactivateSelection();
00096 
00097 signals:
00104   void selectionActivated();
00105   void contentModified();
00106   
00107 private slots:
00108   void onSelectionDone(); 
00109 
00110 private:
00111   void init();
00112   
00113 private:
00114 
00115   bool                                myMultiSelection;
00116   std::vector<CORBA::Object_var>      myObjects;
00117 
00118  SUIT_SelectionFilter*  myFilter;
00119  bool                   mySelectionActivated;
00120  bool                   myStretchActivated;
00121 
00122  SMESHGUI*              mySMESHGUI;
00123  LightApp_SelectionMgr* mySelectionMgr;
00124 
00125  QLineEdit*             myObjNameLineEdit;
00126  QPushButton*           mySelButton;
00127  QString                myParamValue;
00128  QString                myEmptyText;
00129  QString                myEmptyStyleSheet;
00130 };
00131 
00132 #endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H