Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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   virtual bool checkParams() const = 0;
55
56   QString                     hypType() const;
57   bool                        isCreation() const;
58
59 protected:
60   typedef struct
61   {
62     QString   myName;
63     QVariant  myValue;
64
65   } StdParam;
66
67   typedef QValueList<StdParam>   ListOfStdParams;
68   typedef QPtrList<QWidget>      ListOfWidgets;
69
70   SMESH::SMESH_Hypothesis_var hypothesis() const;
71   SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
72   const ListOfWidgets&        widgets() const;
73   ListOfWidgets&              changeWidgets();
74
75   virtual QFrame*  buildFrame    () = 0;
76           QFrame*  buildStdFrame ();
77   virtual void     retrieveParams() const = 0;
78   virtual QString  storeParams   () const = 0;
79   virtual bool     stdParams     ( ListOfStdParams& ) const;
80           bool     getStdParamFromDlg( ListOfStdParams& ) const;
81   static  QString  stdParamValues( const ListOfStdParams& );
82   virtual void     attuneStdWidget( QWidget*, const int ) const;
83   virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
84   virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
85   virtual QString  caption() const;
86   virtual QPixmap  icon() const;
87   virtual QString  type() const;
88
89 protected slots:
90   virtual void onValueChanged();
91
92 private:
93           bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
94
95 private:
96   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
97   QString                      myHypType;
98   ListOfWidgets                myParamWidgets;
99   bool                         myIsCreate;
100 };
101
102 class SMESHGUI_HypothesisDlg : public QtxDialog
103 {
104   Q_OBJECT
105
106 public:
107   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
108   virtual ~SMESHGUI_HypothesisDlg();
109
110           void setHIcon( const QPixmap& );
111           void setCustomFrame( QFrame* );
112           void setType( const QString& );
113
114 protected slots:
115   virtual void accept();
116   void onHelp(); 
117
118 private:
119   SMESHGUI_GenericHypothesisCreator*   myCreator;
120   QVBoxLayout*                         myLayout;
121   QLabel                              *myIconLabel, *myTypeLabel;
122   QString                              myHelpFileName;
123 };
124
125 /*!
126  * \brief Class containing information about hypothesis
127 */
128 class HypothesisData
129 {
130  public:
131   HypothesisData( const QString& theTypeName,
132                   const QString& thePluginName,
133                   const QString& theServerLibName,
134                   const QString& theClientLibName,
135                   const QString& theLabel,
136                   const QString& theIconId,
137                   const QValueList<int>& theDim,
138                   const bool theIsAux,
139                   const QStringList& theNeededHypos,
140                   const QStringList& theOptionalHypos,
141                   const QStringList& theInputTypes,
142                   const QStringList& theOutputTypes)
143     : TypeName( theTypeName ),
144     PluginName( thePluginName ),
145     ServerLibName( theServerLibName ),
146     ClientLibName( theClientLibName ),
147     Label( theLabel ),
148     IconId( theIconId ),
149     Dim( theDim ),
150     IsAux( theIsAux ),
151     NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ),
152     InputTypes( theInputTypes ), OutputTypes( theOutputTypes )
153     {};
154
155  QString TypeName;        //!< hypothesis type name
156  QString PluginName;      //!< plugin name
157  QString ServerLibName;   //!< server library name
158  QString ClientLibName;   //!< client library name
159  QString Label;           //!< label
160  QString IconId;          //!< icon identifier
161  QValueList<int> Dim;     //!< list of supported dimensions (see SMESH::Dimension enumeration)
162  bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, 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& theSetName ) 
180     : HypoSetName( theSetName ) {};
181   HypothesesSet( const QString&     theSetName,
182                  const QStringList& theHypoList,
183                  const QStringList& theAlgoList )
184     : HypoSetName( theSetName ), HypoList(theHypoList), AlgoList(theAlgoList) {};
185   QString     HypoSetName;
186   QStringList HypoList, AlgoList;
187 };
188 #endif