Salome HOME
Update copyright information
[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
59   virtual bool                 checkParams() const = 0;
60   virtual void                 onReject();
61   virtual QString              helpPage() const;
62
63   QString                      hypType() const;
64   QString                      hypName() const;
65   bool                         isCreation() const;
66
67 protected:
68   typedef struct
69   {
70     QString   myName;
71     QVariant  myValue;
72
73   } StdParam;
74
75   typedef QList<StdParam>      ListOfStdParams;
76   typedef QList<QWidget*>      ListOfWidgets;
77
78   SMESH::SMESH_Hypothesis_var  hypothesis() const;
79   SMESH::SMESH_Hypothesis_var  initParamsHypothesis() const;
80   const ListOfWidgets&         widgets() const;
81   ListOfWidgets&               changeWidgets();
82   QtxDialog*                   dlg() const;
83
84   virtual QFrame*              buildFrame() = 0;
85           QFrame*              buildStdFrame();
86   virtual void                 retrieveParams() const = 0;
87   virtual QString              storeParams() const = 0;
88   virtual bool                 stdParams( ListOfStdParams& ) const;
89   bool                         getStdParamFromDlg( ListOfStdParams& ) const;
90   static  QString              stdParamValues( const ListOfStdParams& );
91   virtual void                 attuneStdWidget( QWidget*, const int ) const;
92   virtual QWidget*             getCustomWidget( const StdParam&, 
93                                                 QWidget*, const int ) const;
94   virtual bool                 getParamFromCustomWidget( StdParam&, QWidget* ) const;
95   virtual QString              caption() const;
96   virtual QPixmap              icon() const;
97   virtual QString              type() const;
98
99 protected slots:
100   virtual void                 onValueChanged();
101
102 private slots:
103   virtual void                 onDialogFinished( int );
104
105 private:
106   bool                         editHypothesis( SMESH::SMESH_Hypothesis_ptr,
107                                                const QString&, QWidget* );
108
109 private:
110   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
111   QString                      myHypName;
112   QString                      myHypType;
113   ListOfWidgets                myParamWidgets;
114   bool                         myIsCreate;
115   QtxDialog*                   myDlg;
116   QEventLoop*                  myEventLoop;
117 };
118
119 class SMESHGUI_HypothesisDlg : public QtxDialog
120 {
121   Q_OBJECT
122
123 public:
124   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
125   virtual ~SMESHGUI_HypothesisDlg();
126
127   void                                 setHIcon( const QPixmap& );
128   void                                 setCustomFrame( QFrame* );
129   void                                 setType( const QString& );
130
131 protected slots:
132   virtual void                         accept();
133   virtual void                         reject();
134   void                                 onHelp(); 
135
136 private:
137   SMESHGUI_GenericHypothesisCreator*   myCreator;
138   QLabel*                              myIconLabel;
139   QLabel*                              myTypeLabel;
140   QString                              myHelpFileName;
141 };
142
143 /*!
144  * \brief Class containing information about hypothesis
145 */
146 class HypothesisData
147 {
148 public:
149   HypothesisData( const QString&, const QString&, const QString&,
150                   const QString&, const QString&, const QString&,
151                   const QList<int>&, const bool,
152                   const QStringList&, const QStringList&,
153                   const QStringList&, const QStringList&,
154                   const bool=true, const bool supportSub=false );
155
156   QString TypeName;        //!< hypothesis type name
157   QString PluginName;      //!< plugin name
158   QString ServerLibName;   //!< server library name
159   QString ClientLibName;   //!< client library name
160   QString Label;           //!< label
161   QString IconId;          //!< icon identifier
162   QList<int> Dim;          //!< list of supported dimensions (see SMESH::Dimension enumeration)
163   bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
164   bool IsNeedGeometry;     //!< TRUE if the algorithm works with shapes only, FALSE otherwise
165   bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
166
167   // for algorithm only: dependencies algo <-> algo and algo -> hypos
168   QStringList NeededHypos;  //!< list of obligatory hypotheses
169   QStringList OptionalHypos;//!< list of optional hypotheses
170   QStringList InputTypes;   //!< list of element types required as a prerequisite
171   QStringList OutputTypes;  //!< list of types of generated elements
172 };
173
174 /*!
175  * \brief Class containing set of hypotheses
176  *
177  * Actually it contains list of hypo types
178  */
179 class HypothesesSet
180 {
181 public:
182   HypothesesSet( const QString& );
183   HypothesesSet( const QString&, const QStringList&, const QStringList& );
184
185   QString     HypoSetName;
186   QStringList HypoList, AlgoList;
187 };
188
189 #endif // SMESHGUI_HYPOTHESES_H