Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.h
1 //  Copyright (C) 2007-2008  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 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_Hypotheses.h
24 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
25 //
26 #ifndef SMESHGUI_HYPOTHESES_H
27 #define SMESHGUI_HYPOTHESES_H
28
29 // SMESH includes
30 #include "SMESH_SMESHGUI.hxx"
31
32 // Qt includes
33 #include <QtxDialog.h>
34 #include <QVariant>
35
36 // IDL includes
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
39
40 class QEventLoop;
41
42 /*!
43  * \brief Auxiliary class for creation of hypotheses
44 */
45 class SMESHGUI_EXPORT SMESHGUI_GenericHypothesisCreator : public QObject
46 {
47   Q_OBJECT
48
49 public:
50   SMESHGUI_GenericHypothesisCreator( const QString& );
51   virtual ~SMESHGUI_GenericHypothesisCreator();
52
53   void                         create( SMESH::SMESH_Hypothesis_ptr,
54                                        const QString&, QWidget* );
55   void                         create( bool, const QString&, QWidget* );
56   void                         edit( SMESH::SMESH_Hypothesis_ptr,
57                                      const QString&, QWidget* );
58   void                         setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
59
60   virtual bool                 checkParams( QString& ) const;
61   virtual void                 onReject();
62   virtual QString              helpPage() const;
63
64   QString                      hypType() const;
65   QString                      hypName() const;
66   bool                         isCreation() const;
67
68 protected:
69   struct StdParam
70   {
71     QString   myName;
72     QVariant  myValue;
73     bool      isVariable;
74     StdParam(){
75       isVariable = false;
76     }
77   };
78
79   typedef QList<StdParam>      ListOfStdParams;
80   typedef QList<QWidget*>      ListOfWidgets;
81
82   SMESH::SMESH_Hypothesis_var  hypothesis() const;
83   SMESH::SMESH_Hypothesis_var  initParamsHypothesis(const bool strict=false) const;
84   bool                         hasInitParamsHypothesis() const;
85   const ListOfWidgets&         widgets() const;
86   ListOfWidgets&               changeWidgets();
87   QtxDialog*                   dlg() const;
88
89   virtual QFrame*              buildFrame() = 0;
90           QFrame*              buildStdFrame();
91   virtual void                 retrieveParams() const = 0;
92   virtual QString              storeParams() const = 0;
93   virtual bool                 stdParams( ListOfStdParams& ) const;
94   bool                         getStdParamFromDlg( ListOfStdParams& ) const;
95   virtual QStringList          getVariablesFromDlg() const;
96   static  QString              stdParamValues( const ListOfStdParams& );
97   virtual void                 attuneStdWidget( QWidget*, const int ) const;
98   virtual QWidget*             getCustomWidget( const StdParam&, 
99                                                 QWidget*, const int ) const;
100   virtual bool                 getParamFromCustomWidget( StdParam&, QWidget* ) const;
101   virtual void                 valueChanged( QWidget* );
102   virtual QString              caption() const;
103   virtual QPixmap              icon() const;
104   virtual QString              type() const;
105
106 protected slots:
107   virtual void                 onValueChanged();
108
109 private slots:
110   virtual void                 onDialogFinished( int );
111
112 private:
113   bool                         editHypothesis( SMESH::SMESH_Hypothesis_ptr,
114                                                const QString&, QWidget* );
115
116 private:
117   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
118   QString                      myHypName;
119   QString                      myHypType;
120   ListOfWidgets                myParamWidgets;
121   bool                         myIsCreate;
122   QtxDialog*                   myDlg;
123   QEventLoop*                  myEventLoop;
124 };
125
126 class SMESHGUI_HypothesisDlg : public QtxDialog
127 {
128   Q_OBJECT
129
130 public:
131   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
132   virtual ~SMESHGUI_HypothesisDlg();
133
134   void                                 setHIcon( const QPixmap& );
135   void                                 setCustomFrame( QFrame* );
136   void                                 setType( const QString& );
137
138 protected slots:
139   virtual void                         accept();
140   virtual void                         reject();
141   void                                 onHelp(); 
142
143 private:
144   SMESHGUI_GenericHypothesisCreator*   myCreator;
145   QLabel*                              myIconLabel;
146   QLabel*                              myTypeLabel;
147   QString                              myHelpFileName;
148 };
149
150 /*!
151  * \brief Class containing information about hypothesis
152 */
153 class HypothesisData
154 {
155 public:
156   HypothesisData( const QString&, const QString&, const QString&,
157                   const QString&, const QString&, const QString&,
158                   const QList<int>&, const bool,
159                   const QStringList&, const QStringList&,
160                   const QStringList&, const QStringList&,
161                   const bool=true, const bool supportSub=false );
162
163   QString TypeName;        //!< hypothesis type name
164   QString PluginName;      //!< plugin name
165   QString ServerLibName;   //!< server library name
166   QString ClientLibName;   //!< client library name
167   QString Label;           //!< label
168   QString IconId;          //!< icon identifier
169   QList<int> Dim;          //!< list of supported dimensions (see SMESH::Dimension enumeration)
170   bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
171   bool IsNeedGeometry;     //!< TRUE if the algorithm works with shapes only, FALSE otherwise
172   bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
173
174   // for algorithm only: dependencies algo <-> algo and algo -> hypos
175   QStringList NeededHypos;  //!< list of obligatory hypotheses
176   QStringList OptionalHypos;//!< list of optional hypotheses
177   QStringList InputTypes;   //!< list of element types required as a prerequisite
178   QStringList OutputTypes;  //!< list of types of generated elements
179 };
180
181 /*!
182  * \brief Class containing set of hypotheses
183  *
184  * Actually it contains list of hypo types
185  */
186 class HypothesesSet
187 {
188 public:
189   HypothesesSet( const QString& );
190   HypothesesSet( const QString&, const QStringList&, const QStringList& );
191
192   QString     HypoSetName;
193   QStringList HypoList, AlgoList;
194 };
195
196 #endif // SMESHGUI_HYPOTHESES_H