Salome HOME
IPAL21120 SIGSEGV on Meshing attached Compound with Automatic Hexadralization
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH SMESHGUI : GUI for SMESH component
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   virtual QString helpPage() const;
60
61   QString hypType() const;
62   QString hypName() const;
63   bool    isCreation() const;
64
65 protected:
66   typedef struct
67   {
68     QString   myName;
69     QVariant  myValue;
70
71   } StdParam;
72
73   typedef QValueList<StdParam>   ListOfStdParams;
74   typedef QPtrList<QWidget>      ListOfWidgets;
75
76   SMESH::SMESH_Hypothesis_var hypothesis() const;
77   SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
78   const ListOfWidgets&        widgets() const;
79   ListOfWidgets&              changeWidgets();
80   QtxDialog*                  dlg() const { return myDlg; }
81
82   virtual QFrame*  buildFrame    () = 0;
83           QFrame*  buildStdFrame ();
84   virtual void     retrieveParams() const = 0;
85   virtual QString  storeParams   () const = 0;
86   virtual bool     stdParams     ( ListOfStdParams& ) const;
87           bool     getStdParamFromDlg( ListOfStdParams& ) const;
88   static  QString  stdParamValues( const ListOfStdParams& );
89   virtual void     attuneStdWidget( QWidget*, const int ) const;
90   virtual QWidget* getCustomWidget( const StdParam &, QWidget*, const int ) const;
91   virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
92   virtual QString  caption() const;
93   virtual QPixmap  icon() const;
94   virtual QString  type() const;
95
96 protected slots:
97   virtual void onValueChanged();
98
99 private:
100   bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget* );
101
102 private:
103   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
104   QString                      myHypName;
105   QString                      myHypType;
106   ListOfWidgets                myParamWidgets;
107   bool                         myIsCreate;
108   QtxDialog*                   myDlg;
109 };
110
111 class SMESHGUI_HypothesisDlg : public QtxDialog
112 {
113   Q_OBJECT
114
115 public:
116   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
117   virtual ~SMESHGUI_HypothesisDlg();
118
119   void setHIcon( const QPixmap& );
120   void setCustomFrame( QFrame* );
121   void setType( const QString& );
122
123 protected slots:
124   virtual void accept();
125   virtual void reject();
126   void onHelp(); 
127
128 private:
129   SMESHGUI_GenericHypothesisCreator*   myCreator;
130   QVBoxLayout*                         myLayout;
131   QLabel*                              myIconLabel;
132   QLabel*                              myTypeLabel;
133   QString                              myHelpFileName;
134 };
135
136 /*!
137  * \brief Class containing information about hypothesis
138 */
139 class HypothesisData
140 {
141  public:
142   HypothesisData( const QString& theTypeName,
143                   const QString& thePluginName,
144                   const QString& theServerLibName,
145                   const QString& theClientLibName,
146                   const QString& theLabel,
147                   const QString& theIconId,
148                   const QValueList<int>& theDim,
149                   const bool theIsAux,
150                   const QStringList& theNeededHypos,
151                   const QStringList& theOptionalHypos,
152                   const QStringList& theInputTypes,
153                   const QStringList& theOutputTypes,
154                   const bool theIsNeedGeometry = true,
155                   const bool theSupportSub = false)
156     : TypeName( theTypeName ),
157     PluginName( thePluginName ),
158     ServerLibName( theServerLibName ),
159     ClientLibName( theClientLibName ),
160     Label( theLabel ),
161     IconId( theIconId ),
162     Dim( theDim ),
163     IsAux( theIsAux ),
164     NeededHypos( theNeededHypos ), OptionalHypos( theOptionalHypos ),
165     InputTypes( theInputTypes ), OutputTypes( theOutputTypes ),
166     IsNeedGeometry( theIsNeedGeometry ),
167     IsSupportSubmeshes( theSupportSub )
168     {};
169
170  QString TypeName;        //!< hypothesis type name
171  QString PluginName;      //!< plugin name
172  QString ServerLibName;   //!< server library name
173  QString ClientLibName;   //!< client library name
174  QString Label;           //!< label
175  QString IconId;          //!< icon identifier
176  QValueList<int> Dim;     //!< list of supported dimensions (see SMESH::Dimension enumeration)
177  bool IsAux;              //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
178  bool IsNeedGeometry;     //!< TRUE if the algorithm works with shapes only, FALSE otherwise
179  bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
180
181  // for algorithm only: dependencies algo <-> algo and algo -> hypos
182  QStringList NeededHypos;  //!< list of obligatory hypotheses
183  QStringList OptionalHypos;//!< list of optional hypotheses
184  QStringList InputTypes;   //!< list of element types required as a prerequisite
185  QStringList OutputTypes;  //!< list of types of generated elements
186 };
187
188 /*!
189  * \brief Class containing set of hypotheses
190  *
191  * Actually it contains list of hypo types
192  */
193 class HypothesesSet
194 {
195  public:
196   HypothesesSet( const QString& theSetName ) 
197     : HypoSetName( theSetName ) {};
198   HypothesesSet( const QString&     theSetName,
199                  const QStringList& theHypoList,
200                  const QStringList& theAlgoList )
201     : HypoSetName( theSetName ), HypoList(theHypoList), AlgoList(theAlgoList) {};
202   QString     HypoSetName;
203   QStringList HypoList, AlgoList;
204 };
205 #endif