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