Back to index

salome-smesh  6.5.0
SMESHGUI_Hypotheses.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 // SMESH SMESHGUI : GUI for SMESH component
00024 // File   : SMESHGUI_Hypotheses.h
00025 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
00026 //
00027 #ifndef SMESHGUI_HYPOTHESES_H
00028 #define SMESHGUI_HYPOTHESES_H
00029 
00030 // SMESH includes
00031 #include "SMESH_SMESHGUI.hxx"
00032 #include "SMESHGUI_HypothesesUtils.h"
00033 
00034 // Qt includes
00035 #include <QtxDialog.h>
00036 #include <QVariant>
00037 
00038 // IDL includes
00039 #include <SALOMEconfig.h>
00040 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00041 
00042 class QEventLoop;
00043 
00047 class SMESHGUI_EXPORT SMESHGUI_GenericHypothesisCreator : public QObject
00048 {
00049   Q_OBJECT
00050 
00051 public:
00052   SMESHGUI_GenericHypothesisCreator( const QString& );
00053   virtual ~SMESHGUI_GenericHypothesisCreator();
00054 
00055   void                         create( SMESH::SMESH_Hypothesis_ptr,
00056                                        const QString&, QWidget*, QObject*, const QString& );
00057   void                         create( bool, const QString&, QWidget*, QObject*, const QString& );
00058   void                         edit( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject*, const QString& );
00059   void                         setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
00060 
00061   virtual bool                 checkParams( QString& ) const;
00062   virtual void                 onReject();
00063   virtual QString              helpPage() const;
00064 
00065   QString                      hypType() const;
00066   QString                      hypName() const;
00067   bool                         isCreation() const;
00068   
00069   QString                      getShapeEntry() const { return myShapeEntry; }
00070   void                         setShapeEntry( const QString& theEntry );
00071 
00072   QString                      getMainShapeEntry() const { return myMainShapeEntry; }
00073   void                         setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; }
00074 
00075 signals:
00076   void                         finished( int );
00077 
00078 protected:
00079   struct StdParam
00080   {
00081     QString   myName;
00082     QVariant  myValue;
00083     bool      isVariable;
00084     QString   myText;
00085     StdParam(){
00086       isVariable = false;
00087     }
00088     const char* text() const { return myText.toLatin1().constData(); }
00089   };
00090 
00091   typedef QList<StdParam>      ListOfStdParams;
00092   typedef QList<QWidget*>      ListOfWidgets;
00093 
00094   SMESH::SMESH_Hypothesis_var  hypothesis() const;
00095   SMESH::SMESH_Hypothesis_var  initParamsHypothesis(const bool strict=false) const;
00096   bool                         hasInitParamsHypothesis() const;
00097   const ListOfWidgets&         widgets() const;
00098   ListOfWidgets&               changeWidgets();
00099   QtxDialog*                   dlg() const;
00100   QString                      getVariableName(const char* methodName) const;
00101 
00102   virtual QFrame*              buildFrame() = 0;
00103           QFrame*              buildStdFrame();
00104   virtual void                 retrieveParams() const = 0;
00105   virtual QString              storeParams() const = 0;
00106   virtual bool                 stdParams( ListOfStdParams& ) const;
00107   bool                         getStdParamFromDlg( ListOfStdParams& ) const;
00108   virtual QStringList          getVariablesFromDlg() const;
00109   static  QString              stdParamValues( const ListOfStdParams& );
00110   virtual void                 attuneStdWidget( QWidget*, const int ) const;
00111   virtual QWidget*             getCustomWidget( const StdParam&, 
00112                                                 QWidget*, const int ) const;
00113   virtual bool                 getParamFromCustomWidget( StdParam&, QWidget* ) const;
00114   virtual void                 valueChanged( QWidget* );
00115   virtual QString              caption() const;
00116   virtual QPixmap              icon() const;
00117   virtual QString              type() const;
00118 
00119 protected slots:
00120   virtual void                 onValueChanged();
00121 
00122 private slots:
00123   virtual void                 onDialogFinished( int );
00124 
00125 private:
00126   void                         editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject* obj, const QString& );
00127 
00128 private:
00129   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
00130   QString                      myHypName;
00131   QString                      myHypType;
00132   ListOfWidgets                myParamWidgets;
00133   bool                         myIsCreate;
00134   QtxDialog*                   myDlg;
00135   QString                      myShapeEntry;
00136   QString                      myMainShapeEntry;
00137 };
00138 
00139 class SMESHGUI_HypothesisDlg : public QtxDialog
00140 {
00141   Q_OBJECT
00142 
00143 public:
00144   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
00145   virtual ~SMESHGUI_HypothesisDlg();
00146 
00147   void setHIcon( const QPixmap& );
00148   void setCustomFrame( QFrame* );
00149   void setType( const QString& );
00150 
00151 protected slots:
00152   virtual void accept();
00153   virtual void reject();
00154   void onHelp(); 
00155 
00156 private:
00157   SMESHGUI_GenericHypothesisCreator* myCreator;
00158   QLabel *myIconLabel, *myTypeLabel;
00159   QString myHelpFileName;
00160 };
00161 
00165 class HypothesisData
00166 {
00167 public:
00168   HypothesisData( const QString&, const QString&, const QString&,
00169                   const QString&, const QString&, const QString&,
00170                   const QList<int>&, const bool,
00171                   const QStringList&, const QStringList&,
00172                   const QStringList&, const QStringList&,
00173                   const bool=true, const bool supportSub=false );
00174 
00175   QString TypeName;        
00176   QString PluginName;      
00177   QString ServerLibName;   
00178   QString ClientLibName;   
00179   QString Label;           
00180   QString IconId;          
00181   QList<int> Dim;          
00182   bool IsAux;              
00183   bool IsNeedGeometry;     
00184   bool IsSupportSubmeshes; 
00185 
00186   // for algorithm only: dependencies algo <-> algo and algo -> hypos
00187   QStringList NeededHypos;  
00188   QStringList OptionalHypos;
00189   QStringList InputTypes;   
00190   QStringList OutputTypes;  
00191 };
00192 
00198 class HypothesesSet
00199 {
00200 public:
00201   HypothesesSet( const QString& );
00202   HypothesesSet( const QString&, const QStringList&, const QStringList& );
00203 
00204   QString name() const;
00205   void set( bool, const QStringList& );
00206   int count( bool ) const;
00207 
00208   void setIsCustom( bool );
00209   bool getIsCustom() const;
00210   int maxDim() const;
00211 
00212   bool isAlgo() const;
00213 
00214   //this method sets internal index to -1, thus before any data access it is necessary to call next()
00215   void init( bool );
00216 
00217   bool more() const;
00218   void next();
00219   QString current() const;
00220 
00221 private:
00222   QStringList* list(bool) const;
00223   QStringList* list() const;
00224 
00225 private:
00226   QString     myHypoSetName;
00227   QStringList myHypoList, myAlgoList;
00228   bool myIsAlgo, myIsCustom;
00229   int myIndex;
00230 };
00231 
00232 #endif // SMESHGUI_HYPOTHESES_H