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