Salome HOME
remove images in ascii
[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   virtual bool checkParams() const = 0;
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
77   virtual QFrame*  buildFrame    () = 0;
78           QFrame*  buildStdFrame ();
79   virtual void     retrieveParams() const = 0;
80   virtual QString  storeParams   () const = 0;
81   virtual bool     stdParams     ( ListOfStdParams& ) const;
82           bool     getStdParamFromDlg( ListOfStdParams& ) const;
83   static  QString  stdParamValues( const ListOfStdParams& );
84   virtual void     attuneStdWidget( QWidget*, const int ) const;
85   virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
86   virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
87   virtual QString  caption() const;
88   virtual QPixmap  icon() const;
89   virtual QString  type() const;
90
91 protected slots:
92   virtual void onValueChanged();
93
94 private:
95           bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
96
97 private:
98   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
99   QString                      myHypType;
100   ListOfWidgets                myParamWidgets;
101   bool                         myIsCreate;
102 };
103
104 class SMESHGUI_HypothesisDlg : public QtxDialog
105 {
106   Q_OBJECT
107
108 public:
109   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
110   virtual ~SMESHGUI_HypothesisDlg();
111
112           void setHIcon( const QPixmap& );
113           void setCustomFrame( QFrame* );
114           void setType( const QString& );
115
116 protected slots:
117   virtual void accept();
118   void onHelp(); 
119
120 private:
121   SMESHGUI_GenericHypothesisCreator*   myCreator;
122   QVBoxLayout*                         myLayout;
123   QLabel                              *myIconLabel, *myTypeLabel;
124   QString                              myHelpFileName;
125 };
126
127 /*!
128  * \brief Class containing information about hypothesis
129 */
130 class HypothesisData
131 {
132  public:
133   HypothesisData( const QString& theTypeName,
134                   const QString& thePluginName,
135                   const QString& theServerLibName,
136                   const QString& theClientLibName,
137                   const QString& theLabel,
138                   const QString& theIconId,
139                   const QValueList<int>& theDim,
140                   const bool theIsAux,
141                   const QStringList& theNeededHypos,
142                   const QStringList& theOptionalHypos,
143                   const QStringList& theInputTypes,
144                   const QStringList& theOutputTypes)
145     : TypeName( theTypeName ),
146     PluginName( thePluginName ),
147     ServerLibName( theServerLibName ),
148     ClientLibName( theClientLibName ),
149     Label( theLabel ),
150     IconId( theIconId ),
151     Dim( theDim ),
152     IsAux( theIsAux ),
153     NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ),
154     InputTypes( theInputTypes ), OutputTypes( theOutputTypes )
155     {};
156
157  QString TypeName;        //!< hypothesis type name
158  QString PluginName;      //!< plugin name
159  QString ServerLibName;   //!< server library name
160  QString ClientLibName;   //!< client library name
161  QString Label;           //!< label
162  QString IconId;          //!< icon identifier
163  QValueList<int> Dim;     //!< list of supported dimensions (see SMESH::Dimension enumeration)
164  bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
165
166  // for algorithm only: dependencies algo <-> algo and algo -> hypos
167  QStringList NeededHypos;  //!< list of obligatory hypotheses
168  QStringList OptionalHypos;//!< list of optional hypotheses
169  QStringList InputTypes;   //!< list of element types required as a prerequisite
170  QStringList OutputTypes;  //!< list of types of generated elements
171 };
172
173 /*!
174  * \brief Class containing set of hypotheses
175  *
176  * Actually it contains list of hypo types
177  */
178 class HypothesesSet
179 {
180  public:
181   HypothesesSet( const QString& theSetName ) 
182     : HypoSetName( theSetName ) {};
183   HypothesesSet( const QString&     theSetName,
184                  const QStringList& theHypoList,
185                  const QStringList& theAlgoList )
186     : HypoSetName( theSetName ), HypoList(theHypoList), AlgoList(theAlgoList) {};
187   QString     HypoSetName;
188   QStringList HypoList, AlgoList;
189 };
190 #endif