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