Salome HOME
Corrected for 0020310.
[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 #include "SMESHGUI_HypothesesUtils.h"
32
33 // Qt includes
34 #include <QtxDialog.h>
35 #include <QVariant>
36
37 // IDL includes
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
40
41 class QEventLoop;
42
43 /*!
44  * \brief Auxiliary class for creation of hypotheses
45 */
46 class SMESHGUI_EXPORT SMESHGUI_GenericHypothesisCreator : public QObject
47 {
48   Q_OBJECT
49
50 public:
51   SMESHGUI_GenericHypothesisCreator( const QString& );
52   virtual ~SMESHGUI_GenericHypothesisCreator();
53
54   void                         create( SMESH::SMESH_Hypothesis_ptr,
55                                        const QString&, QWidget*, QObject*, const QString& );
56   void                         create( bool, const QString&, QWidget*, QObject*, const QString& );
57   void                         edit( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject*, const QString& );
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   QString                      getShapeEntry() const { return myShapeEntry; }
69   void                         setShapeEntry( const QString& theEntry );
70
71 signals:
72   void                         finished( int );
73
74 protected:
75   struct StdParam
76   {
77     QString   myName;
78     QVariant  myValue;
79     bool      isVariable;
80     StdParam(){
81       isVariable = false;
82     }
83   };
84
85   typedef QList<StdParam>      ListOfStdParams;
86   typedef QList<QWidget*>      ListOfWidgets;
87
88   SMESH::SMESH_Hypothesis_var  hypothesis() const;
89   SMESH::SMESH_Hypothesis_var  initParamsHypothesis(const bool strict=false) const;
90   bool                         hasInitParamsHypothesis() const;
91   const ListOfWidgets&         widgets() const;
92   ListOfWidgets&               changeWidgets();
93   QtxDialog*                   dlg() const;
94
95   virtual QFrame*              buildFrame() = 0;
96           QFrame*              buildStdFrame();
97   virtual void                 retrieveParams() const = 0;
98   virtual QString              storeParams() const = 0;
99   virtual bool                 stdParams( ListOfStdParams& ) const;
100   bool                         getStdParamFromDlg( ListOfStdParams& ) const;
101   virtual QStringList          getVariablesFromDlg() const;
102   static  QString              stdParamValues( const ListOfStdParams& );
103   virtual void                 attuneStdWidget( QWidget*, const int ) const;
104   virtual QWidget*             getCustomWidget( const StdParam&, 
105                                                 QWidget*, const int ) const;
106   virtual bool                 getParamFromCustomWidget( StdParam&, QWidget* ) const;
107   virtual void                 valueChanged( QWidget* );
108   virtual QString              caption() const;
109   virtual QPixmap              icon() const;
110   virtual QString              type() const;
111
112 protected slots:
113   virtual void                 onValueChanged();
114
115 private slots:
116   virtual void                 onDialogFinished( int );
117
118 private:
119   void                         editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject* obj, const QString& );
120
121 private:
122   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
123   QString                      myHypName;
124   QString                      myHypType;
125   ListOfWidgets                myParamWidgets;
126   bool                         myIsCreate;
127   QtxDialog*                   myDlg;
128   QString                      myShapeEntry;
129 };
130
131 class SMESHGUI_HypothesisDlg : public QtxDialog
132 {
133   Q_OBJECT
134
135 public:
136   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
137   virtual ~SMESHGUI_HypothesisDlg();
138
139   void setHIcon( const QPixmap& );
140   void setCustomFrame( QFrame* );
141   void setType( const QString& );
142
143 protected slots:
144   virtual void accept();
145   virtual void reject();
146   void onHelp(); 
147
148 private:
149   SMESHGUI_GenericHypothesisCreator* myCreator;
150   QLabel *myIconLabel, *myTypeLabel;
151   QString myHelpFileName;
152 };
153
154 /*!
155  * \brief Class containing information about hypothesis
156 */
157 class HypothesisData
158 {
159 public:
160   HypothesisData( const QString&, const QString&, const QString&,
161                   const QString&, const QString&, const QString&,
162                   const QList<int>&, const bool,
163                   const QStringList&, const QStringList&,
164                   const QStringList&, const QStringList&,
165                   const bool=true, const bool supportSub=false );
166
167   QString TypeName;        //!< hypothesis type name
168   QString PluginName;      //!< plugin name
169   QString ServerLibName;   //!< server library name
170   QString ClientLibName;   //!< client library name
171   QString Label;           //!< label
172   QString IconId;          //!< icon identifier
173   QList<int> Dim;          //!< list of supported dimensions (see SMESH::Dimension enumeration)
174   bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
175   bool IsNeedGeometry;     //!< TRUE if the algorithm works with shapes only, FALSE otherwise
176   bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
177
178   // for algorithm only: dependencies algo <-> algo and algo -> hypos
179   QStringList NeededHypos;  //!< list of obligatory hypotheses
180   QStringList OptionalHypos;//!< list of optional hypotheses
181   QStringList InputTypes;   //!< list of element types required as a prerequisite
182   QStringList OutputTypes;  //!< list of types of generated elements
183 };
184
185 /*!
186  * \brief Class containing set of hypotheses
187  *
188  * Actually it contains list of hypo types
189  */
190 class HypothesesSet
191 {
192 public:
193   HypothesesSet( const QString& );
194   HypothesesSet( const QString&, const QStringList&, const QStringList& );
195
196   QString name() const;
197   void set( bool, const QStringList& );
198   int count( bool ) const;
199
200   bool isAlgo() const;
201
202   //this method sets internal index to -1, thus before any data access it is necessary to call next()
203   void init( bool );
204
205   bool more() const;
206   void next();
207   QString current() const;
208
209 private:
210   QStringList* list(bool) const;
211   QStringList* list() const;
212
213 private:
214   bool myIsAlgo;
215   QString     myHypoSetName;
216   QStringList myHypoList, myAlgoList;
217   int myIndex;
218 };
219
220 #endif // SMESHGUI_HYPOTHESES_H