Salome HOME
Dump Python Extension
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.h
1 // SMESH SMESHGUI : GUI for SMESH component
2 //
3 // Copyright (C) 2003  CEA
4 //
5 // This library is free software; you can redistribute it and/or 
6 // modify it under the terms of the GNU Lesser General Public 
7 // License as published by the Free Software Foundation; either 
8 // version 2.1 of the License. 
9 //
10 // This library is distributed in the hope that it will be useful, 
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 // Lesser General Public License for more details. 
14 //
15 // You should have received a copy of the GNU Lesser General Public 
16 // License along with this library; if not, write to the Free Software 
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 // File   : SMESHGUI_Hypotheses.h
22 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
23 //
24
25 #ifndef SMESHGUI_HYPOTHESES_H
26 #define SMESHGUI_HYPOTHESES_H
27
28 // SMESH includes
29 #include "SMESH_SMESHGUI.hxx"
30
31 // Qt includes
32 #include <QtxDialog.h>
33 #include <QVariant>
34
35 // IDL includes
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
38
39 class QEventLoop;
40
41 /*!
42  * \brief Auxiliary class for creation of hypotheses
43 */
44 class SMESHGUI_EXPORT SMESHGUI_GenericHypothesisCreator : public QObject
45 {
46   Q_OBJECT
47
48 public:
49   SMESHGUI_GenericHypothesisCreator( const QString& );
50   virtual ~SMESHGUI_GenericHypothesisCreator();
51
52   void                         create( SMESH::SMESH_Hypothesis_ptr,
53                                        const QString&, QWidget* );
54   void                         create( bool, const QString&, QWidget* );
55   void                         edit( SMESH::SMESH_Hypothesis_ptr,
56                                      const QString&, QWidget* );
57
58   virtual bool                 checkParams() const;
59   virtual void                 onReject();
60   virtual QString              helpPage() const;
61
62   QString                      hypType() const;
63   QString                      hypName() const;
64   bool                         isCreation() const;
65
66 protected:
67   typedef struct
68   {
69     QString   myName;
70     QVariant  myValue;
71
72   } StdParam;
73
74   typedef QList<StdParam>      ListOfStdParams;
75   typedef QList<QWidget*>      ListOfWidgets;
76
77   SMESH::SMESH_Hypothesis_var  hypothesis() const;
78   SMESH::SMESH_Hypothesis_var  initParamsHypothesis() const;
79   const ListOfWidgets&         widgets() const;
80   ListOfWidgets&               changeWidgets();
81   QtxDialog*                   dlg() const;
82
83   virtual QFrame*              buildFrame() = 0;
84           QFrame*              buildStdFrame();
85   virtual void                 retrieveParams() const = 0;
86   virtual QString              storeParams() const = 0;
87   virtual bool                 stdParams( ListOfStdParams& ) const;
88   bool                         getStdParamFromDlg( ListOfStdParams& ) const;
89   static  QString              stdParamValues( const ListOfStdParams& );
90   virtual void                 attuneStdWidget( QWidget*, const int ) const;
91   virtual QWidget*             getCustomWidget( const StdParam&, 
92                                                 QWidget*, const int ) const;
93   virtual bool                 getParamFromCustomWidget( StdParam&, QWidget* ) const;
94   virtual QString              caption() const;
95   virtual QPixmap              icon() const;
96   virtual QString              type() const;
97
98 protected slots:
99   virtual void                 onValueChanged();
100
101 private slots:
102   virtual void                 onDialogFinished( int );
103
104 private:
105   bool                         editHypothesis( SMESH::SMESH_Hypothesis_ptr,
106                                                const QString&, QWidget* );
107
108 private:
109   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
110   QString                      myHypName;
111   QString                      myHypType;
112   ListOfWidgets                myParamWidgets;
113   bool                         myIsCreate;
114   QtxDialog*                   myDlg;
115   QEventLoop*                  myEventLoop;
116 };
117
118 class SMESHGUI_HypothesisDlg : public QtxDialog
119 {
120   Q_OBJECT
121
122 public:
123   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
124   virtual ~SMESHGUI_HypothesisDlg();
125
126   void                                 setHIcon( const QPixmap& );
127   void                                 setCustomFrame( QFrame* );
128   void                                 setType( const QString& );
129
130 protected slots:
131   virtual void                         accept();
132   virtual void                         reject();
133   void                                 onHelp(); 
134
135 private:
136   SMESHGUI_GenericHypothesisCreator*   myCreator;
137   QLabel*                              myIconLabel;
138   QLabel*                              myTypeLabel;
139   QString                              myHelpFileName;
140 };
141
142 /*!
143  * \brief Class containing information about hypothesis
144 */
145 class HypothesisData
146 {
147 public:
148   HypothesisData( const QString&, const QString&, const QString&,
149                   const QString&, const QString&, const QString&,
150                   const QList<int>&, const bool,
151                   const QStringList&, const QStringList&,
152                   const QStringList&, const QStringList&,
153                   const bool=true, const bool supportSub=false );
154
155   QString TypeName;        //!< hypothesis type name
156   QString PluginName;      //!< plugin name
157   QString ServerLibName;   //!< server library name
158   QString ClientLibName;   //!< client library name
159   QString Label;           //!< label
160   QString IconId;          //!< icon identifier
161   QList<int> Dim;          //!< list of supported dimensions (see SMESH::Dimension enumeration)
162   bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
163   bool IsNeedGeometry;     //!< TRUE if the algorithm works with shapes only, FALSE otherwise
164   bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
165
166   // for algorithm only: dependencies algo <-> algo and algo -> hypos
167   QStringList NeededHypos;  //!< list of obligatory hypotheses
168   QStringList OptionalHypos;//!< list of optional hypotheses
169   QStringList InputTypes;   //!< list of element types required as a prerequisite
170   QStringList OutputTypes;  //!< list of types of generated elements
171 };
172
173 /*!
174  * \brief Class containing set of hypotheses
175  *
176  * Actually it contains list of hypo types
177  */
178 class HypothesesSet
179 {
180 public:
181   HypothesesSet( const QString& );
182   HypothesesSet( const QString&, const QStringList&, const QStringList& );
183
184   QString     HypoSetName;
185   QStringList HypoList, AlgoList;
186 };
187
188 #endif // SMESHGUI_HYPOTHESES_H