Salome HOME
PAL13473 (Build repetitive mesh):
[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 //
22 //
23 //  File   : SMESHGUI_Hypotheses.h
24 //  Author : Julia DOROVSKIKH
25 //  Module : SMESH
26 //  $Header$
27
28 #ifndef SMESHGUI_Hypotheses_HeaderFile
29 #define SMESHGUI_Hypotheses_HeaderFile
30
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
33
34 #include <QtxDialog.h>
35 #include <qvariant.h>
36
37 class QVBoxLayout;
38 class QPixmap;
39
40 /*!
41  * \brief Auxiliary class for creation of hypotheses
42 */
43 class SMESHGUI_GenericHypothesisCreator : public QObject
44 {
45   Q_OBJECT
46
47 public:
48   SMESHGUI_GenericHypothesisCreator( const QString& );
49   virtual ~SMESHGUI_GenericHypothesisCreator();
50
51           void create( const bool isAlgo, QWidget* );
52           void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
53           void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
54
55   virtual bool checkParams() const = 0;
56   virtual void onReject();
57
58   QString                     hypType() const;
59   bool                        isCreation() const;
60
61 protected:
62   typedef struct
63   {
64     QString   myName;
65     QVariant  myValue;
66
67   } StdParam;
68
69   typedef QValueList<StdParam>   ListOfStdParams;
70   typedef QPtrList<QWidget>      ListOfWidgets;
71
72   SMESH::SMESH_Hypothesis_var hypothesis() const;
73   SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
74   const ListOfWidgets&        widgets() const;
75   ListOfWidgets&              changeWidgets();
76   QtxDialog*                  dlg() const { return myDlg; }
77
78   virtual QFrame*  buildFrame    () = 0;
79           QFrame*  buildStdFrame ();
80   virtual void     retrieveParams() const = 0;
81   virtual QString  storeParams   () const = 0;
82   virtual bool     stdParams     ( ListOfStdParams& ) const;
83           bool     getStdParamFromDlg( ListOfStdParams& ) const;
84   static  QString  stdParamValues( const ListOfStdParams& );
85   virtual void     attuneStdWidget( QWidget*, const int ) const;
86   virtual QWidget* getCustomWidget( const StdParam &, QWidget*, const int ) const;
87   virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
88   virtual QString  caption() const;
89   virtual QPixmap  icon() const;
90   virtual QString  type() const;
91
92 protected slots:
93   virtual void onValueChanged();
94
95 private:
96           bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
97
98 private:
99   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
100   QString                      myHypType;
101   ListOfWidgets                myParamWidgets;
102   bool                         myIsCreate;
103   QtxDialog*                   myDlg;
104 };
105
106 class SMESHGUI_HypothesisDlg : public QtxDialog
107 {
108   Q_OBJECT
109
110 public:
111   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
112   virtual ~SMESHGUI_HypothesisDlg();
113
114           void setHIcon( const QPixmap& );
115           void setCustomFrame( QFrame* );
116           void setType( const QString& );
117
118 protected slots:
119   virtual void accept();
120   virtual void reject();
121   void onHelp(); 
122
123 private:
124   SMESHGUI_GenericHypothesisCreator*   myCreator;
125   QVBoxLayout*                         myLayout;
126   QLabel                              *myIconLabel, *myTypeLabel;
127   QString                              myHelpFileName;
128 };
129
130 /*!
131  * \brief Class containing information about hypothesis
132 */
133 class HypothesisData
134 {
135  public:
136   HypothesisData( const QString& theTypeName,
137                   const QString& thePluginName,
138                   const QString& theServerLibName,
139                   const QString& theClientLibName,
140                   const QString& theLabel,
141                   const QString& theIconId,
142                   const QValueList<int>& theDim,
143                   const bool theIsAux,
144                   const QStringList& theNeededHypos,
145                   const QStringList& theOptionalHypos,
146                   const QStringList& theInputTypes,
147                   const QStringList& theOutputTypes)
148     : TypeName( theTypeName ),
149     PluginName( thePluginName ),
150     ServerLibName( theServerLibName ),
151     ClientLibName( theClientLibName ),
152     Label( theLabel ),
153     IconId( theIconId ),
154     Dim( theDim ),
155     IsAux( theIsAux ),
156     NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ),
157     InputTypes( theInputTypes ), OutputTypes( theOutputTypes )
158     {};
159
160  QString TypeName;        //!< hypothesis type name
161  QString PluginName;      //!< plugin name
162  QString ServerLibName;   //!< server library name
163  QString ClientLibName;   //!< client library name
164  QString Label;           //!< label
165  QString IconId;          //!< icon identifier
166  QValueList<int> Dim;     //!< list of supported dimensions (see SMESH::Dimension enumeration)
167  bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
168
169  // for algorithm only: dependencies algo <-> algo and algo -> hypos
170  QStringList NeededHypos;  //!< list of obligatory hypotheses
171  QStringList OptionalHypos;//!< list of optional hypotheses
172  QStringList InputTypes;   //!< list of element types required as a prerequisite
173  QStringList OutputTypes;  //!< list of types of generated elements
174 };
175
176 /*!
177  * \brief Class containing set of hypotheses
178  *
179  * Actually it contains list of hypo types
180  */
181 class HypothesesSet
182 {
183  public:
184   HypothesesSet( const QString& theSetName ) 
185     : HypoSetName( theSetName ) {};
186   HypothesesSet( const QString&     theSetName,
187                  const QStringList& theHypoList,
188                  const QStringList& theAlgoList )
189     : HypoSetName( theSetName ), HypoList(theHypoList), AlgoList(theAlgoList) {};
190   QString     HypoSetName;
191   QStringList HypoList, AlgoList;
192 };
193 #endif