1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_Hypotheses.h
25 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
27 #ifndef SMESHGUI_HYPOTHESES_H
28 #define SMESHGUI_HYPOTHESES_H
31 #include "SMESH_SMESHGUI.hxx"
32 #include "SMESHGUI_HypothesesUtils.h"
35 #include <QtxDialog.h>
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
45 * \brief Auxiliary class for creation of hypotheses
47 class SMESHGUI_EXPORT SMESHGUI_GenericHypothesisCreator : public QObject
52 SMESHGUI_GenericHypothesisCreator( const QString& );
53 virtual ~SMESHGUI_GenericHypothesisCreator();
55 void create( SMESH::SMESH_Hypothesis_ptr,
56 const QString&, QWidget*, QObject*, const QString& );
57 void create( bool, const QString&, QWidget*, QObject*, const QString& );
58 void edit( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject*, const QString& );
59 void setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
61 virtual bool checkParams( QString& ) const;
62 virtual void onReject();
63 virtual QString helpPage() const;
65 QString hypType() const;
66 QString hypName() const;
67 bool isCreation() const;
69 QString getShapeEntry() const { return myShapeEntry; }
70 void setShapeEntry( const QString& theEntry );
72 QString getMainShapeEntry() const { return myMainShapeEntry; }
73 void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; }
85 QByteArray myTextAsBytes;
89 const char* text() const {
90 ((QByteArray&) myTextAsBytes) = myText.toLatin1(); return myTextAsBytes.constData();
94 typedef QList<StdParam> ListOfStdParams;
95 typedef QList<QWidget*> ListOfWidgets;
97 SMESH::SMESH_Hypothesis_var hypothesis() const;
98 SMESH::SMESH_Hypothesis_var initParamsHypothesis(const bool strict=false) const;
99 bool hasInitParamsHypothesis() const;
100 const ListOfWidgets& widgets() const;
101 ListOfWidgets& changeWidgets();
102 QLabel* getLabel(int i) const;
103 QtxDialog* dlg() const;
104 QString getVariableName(const char* methodName) const;
106 virtual QFrame* buildFrame() = 0;
107 QFrame* buildStdFrame();
108 virtual void retrieveParams() const = 0;
109 virtual QString storeParams() const = 0;
110 virtual bool stdParams( ListOfStdParams& ) const;
111 bool getStdParamFromDlg( ListOfStdParams& ) const;
112 virtual QStringList getVariablesFromDlg() const;
113 static QString stdParamValues( const ListOfStdParams& );
114 virtual void attuneStdWidget( QWidget*, const int ) const;
115 virtual QWidget* getCustomWidget( const StdParam&,
116 QWidget*, const int ) const;
117 virtual QWidget* getHelperWidget() const;
118 virtual bool getParamFromCustomWidget( StdParam&, QWidget* ) const;
119 virtual void valueChanged( QWidget* );
120 virtual QString caption() const;
121 virtual QPixmap icon() const;
122 virtual QString type() const;
125 virtual void onValueChanged();
128 virtual void onDialogFinished( int );
131 void editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject* obj, const QString& );
134 SMESH::SMESH_Hypothesis_var myHypo, myInitParamsHypo;
135 bool myToDeleteInitParamsHypo;
138 ListOfWidgets myParamWidgets;
139 ListOfWidgets myParamLabels;
142 QString myShapeEntry;
143 QString myMainShapeEntry;
146 class SMESHGUI_HypothesisDlg : public QtxDialog
151 SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
152 virtual ~SMESHGUI_HypothesisDlg();
154 void setHIcon( const QPixmap& );
155 void setCustomFrame( QFrame* );
156 void setType( const QString& );
159 virtual void accept();
160 virtual void reject();
164 SMESHGUI_GenericHypothesisCreator* myCreator;
165 QLabel *myIconLabel, *myTypeLabel;
166 QString myHelpFileName;
170 * \brief Information about a hypothesis
172 struct HypothesisData
174 HypothesisData( const QString&, const QString&, const QString&,
175 const QString&, const QString&, const QString&,
176 const QString&, const QList<int>&, const bool,
177 const QStringList&, const QStringList&,
178 const QStringList&, const QStringList&,
179 const bool=true, const bool supportSub=false );
181 QString TypeName; //!< hypothesis type name
182 QString PluginName; //!< plugin name
183 QString ServerLibName; //!< server library name
184 QString ClientLibName; //!< client library name
185 QString Label; //!< label
186 QString IconId; //!< icon identifier
187 QString Context; //!< ["GLOBAL","LOCAL","ANY"(default)]
188 QList<int> Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration)
189 bool IsAuxOrNeedHyp; //!< TRUE if given hypothesis is auxiliary one, FALSE otherwise
190 //!< TRUE if given algorithm can't work w/o hypotheses
191 bool IsNeedGeometry; //!< TRUE if the algorithm works with shapes only, FALSE otherwise
192 bool IsSupportSubmeshes; //!< TRUE if the algo building all-dim elems supports submeshes
194 // for algorithm only: dependencies algo <-> algo and algo -> hypos
195 QStringList BasicHypos; //!< list of basic hypotheses
196 QStringList OptionalHypos;//!< list of optional hypotheses
197 QStringList InputTypes; //!< list of element types required as a prerequisite
198 QStringList OutputTypes; //!< list of types of generated elements
202 * \brief Class containing set of hypotheses
204 * Actually it contains list of hypo types
209 HypothesesSet( const QString& );
210 HypothesesSet( const QString&, const QStringList&, const QStringList& );
212 QString name() const;
213 void set( bool, const QStringList& );
214 int count( bool ) const;
216 void setIsCustom( bool );
217 bool getIsCustom() const;
222 //this method sets internal index to -1, thus before any data access it is necessary to call next()
227 QString current() const;
230 QStringList* list(bool) const;
231 QStringList* list() const;
234 QString myHypoSetName;
235 QStringList myHypoList, myAlgoList;
236 bool myIsAlgo, myIsCustom;
240 #endif // SMESHGUI_HYPOTHESES_H