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