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