1 // Copyright (C) 2007-2015 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
22 // File : SMESHGUI_Hypotheses.cxx
23 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
26 #include "SMESHGUI_Hypotheses.h"
29 #include "SMESHGUI_HypothesesUtils.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_SpinBox.h"
33 // SALOME KERNEL includes
34 #include <SALOMEDSClient_Study.hxx>
35 #include <utilities.h>
37 // SALOME GUI includes
38 #include <LightApp_Application.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_OverrideCursor.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Session.h>
43 #include <SalomeApp_IntSpinBox.h>
50 #include <QVBoxLayout>
55 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
56 : myToDeleteInitParamsHypo( false ),
57 myHypType( theHypType ),
63 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
65 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
66 myInitParamsHypo->UnRegister();
69 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
71 if ( !CORBA::is_nil( hyp ) ) {
72 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
73 myInitParamsHypo->UnRegister();
74 CORBA::String_var hypName = hyp->GetName();
75 if ( hypType() == hypName.in() )
77 myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
78 myToDeleteInitParamsHypo = !SMESH::FindSObject( myInitParamsHypo );
83 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
84 const QString& theHypName,
85 QWidget* parent, QObject* obj, const QString& slot )
87 MESSAGE( "Creation of hypothesis with initial params" );
88 setInitParamsHypothesis( initParamsHyp );
89 create( false, theHypName, parent, obj, slot );
92 void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
93 const QString& theHypName,
94 QWidget* theParent, QObject* obj, const QString& slot )
96 MESSAGE( "Creation of hypothesis" );
100 // Create hypothesis/algorithm
102 SMESH::SMESH_Hypothesis_var anAlgo =
103 SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
104 anAlgo.out(); // avoid unused variable warning
107 SMESH::SMESH_Hypothesis_var aHypothesis =
108 SMESH::CreateHypothesis( hypType(), theHypName, false );
109 editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
113 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
114 const QString& theHypName,
115 QWidget* theParent, QObject* obj, const QString& slot )
117 if( CORBA::is_nil( theHypothesis ) )
122 editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
125 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
126 const QString& theHypName,
128 QObject* obj, const QString& slot )
130 myHypName = theHypName;
131 myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
134 SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
135 connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
136 connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
137 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), Dlg, SLOT( reject() ));
140 QFrame* fr = buildFrame();
143 Dlg->setCustomFrame( fr );
144 Dlg->setWindowTitle( caption() );
145 Dlg->setObjectName( theHypName );
146 Dlg->setHIcon( icon() );
147 Dlg->setType( type() );
150 Dlg->resize( Dlg->minimumSizeHint() );
153 emit finished( QDialog::Accepted );
158 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
160 if( CORBA::is_nil( hypothesis() ) )
163 ListOfStdParams params;
164 if( !stdParams( params ) || params.isEmpty() )
167 QFrame* fr = new QFrame( 0 );
168 QVBoxLayout* lay = new QVBoxLayout( fr );
170 lay->setSpacing( 0 );
172 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
173 lay->addWidget( GroupC1 );
175 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
176 GroupC1Layout->setSpacing( SPACING );
177 GroupC1Layout->setMargin( MARGIN );
179 ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
180 for( int i=0; anIt!=aLast; anIt++, i++ )
182 QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
183 GroupC1Layout->addWidget( lab, i, 0 );
184 myParamLabels << lab;
186 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
188 switch( (*anIt).myValue.type() )
192 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
193 sb->setObjectName( (*anIt).myName );
194 attuneStdWidget( sb, i );
195 sb->setValue( (*anIt).myValue.toInt() );
196 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
200 case QVariant::Double:
202 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
203 sb->setObjectName( (*anIt).myName );
204 attuneStdWidget( sb, i );
205 sb->setValue( (*anIt).myValue.toDouble() );
206 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
210 case QVariant::String:
212 if((*anIt).isVariable) {
213 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
214 QString aVar = (*anIt).myValue.toString();
215 if(aStudy->IsInteger(aVar.toLatin1().constData())){
216 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
217 sb->setObjectName( (*anIt).myName );
218 attuneStdWidget( sb, i );
220 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
223 else if(aStudy->IsReal(aVar.toLatin1().constData())){
224 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
225 sb->setObjectName( (*anIt).myName );
226 attuneStdWidget( sb, i );
228 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
233 QLineEdit* le = new QLineEdit( GroupC1 );
234 le->setObjectName( (*anIt).myName );
235 attuneStdWidget( le, i );
236 le->setText( (*anIt).myValue.toString() );
237 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
246 GroupC1Layout->addWidget( w, i, 1 );
247 changeWidgets().append( w );
250 if ( QWidget* w = getHelperWidget() )
253 w->move( QPoint( 0, 0 ) );
260 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
262 valueChanged( (QWidget*) sender() );
265 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
269 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
271 bool res = result==QDialog::Accepted;
274 SUIT_OverrideCursor wc;
275 /*QString paramValues = */storeParams();
276 // No longer needed since NoteBook appears and "Value" OB field shows names of variable
277 // if ( !paramValues.isEmpty() ) {
278 // if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
279 // SMESH::SetValue( SHyp, paramValues );
283 changeWidgets().clear();
285 if( myIsCreate && !res )
287 //remove just created hypothesis
288 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
289 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
290 if( aStudy && !aStudy->GetProperties()->IsLocked() )
292 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
293 aBuilder->RemoveObjectWithChildren( aHypSObject );
296 else if( !myIsCreate && res )
298 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
299 if( listSOmesh.size() > 0 )
300 for( int i = 0; i < listSOmesh.size(); i++ )
302 _PTR(SObject) submSO = listSOmesh[i];
303 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
304 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
305 if( !aSubMesh->_is_nil() )
306 aMesh = aSubMesh->GetFather();
307 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
308 SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
311 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
312 myHypo->UnRegister();
313 myHypo = SMESH::SMESH_Hypothesis::_nil();
314 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
316 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
318 //delete myDlg; since WA_DeleteOnClose==true
320 emit finished( result );
323 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
328 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
332 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
333 for( ; anIt!=aLast; anIt++ )
335 item.myName = (*anIt)->objectName();
336 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
338 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
339 item.myValue = sb->value();
340 item.myText = sb->text();
341 params.append( item );
343 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
345 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
346 item.myValue = sb->value();
347 item.myText = sb->text();
348 params.append( item );
350 else if( (*anIt)->inherits( "QLineEdit" ) )
352 QLineEdit* line = ( QLineEdit* )( *anIt );
353 item.myValue = item.myText = line->text();
354 params.append( item );
356 else if ( getParamFromCustomWidget( item, *anIt ))
358 params.append( item );
366 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
368 SMESH::SMESH_Hypothesis_var h = hypothesis();
371 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
372 return QString( aVaribaleName.in() );
377 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
380 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
381 for( ; anIt!=aLast; anIt++ ) {
382 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
383 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
384 aResult.append(sb->text());
390 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
392 QString valueStr = "";
393 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
395 for( int i=0; param!=aLast; param++, i++ )
397 if ( valueStr.length() > len0 ) {
399 len0 = valueStr.length();
401 switch( (*param).myValue.type() )
404 valueStr += valueStr.number( (*param).myValue.toInt() );
406 case QVariant::Double:
407 valueStr += valueStr.number( (*param).myValue.toDouble() );
409 case QVariant::String:
410 valueStr += (*param).myValue.toString();
413 QVariant valCopy = (*param).myValue;
414 valueStr += valCopy.toString();
420 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
425 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
427 myShapeEntry = theEntry;
430 //================================================================================
432 * \brief Return hypothesis containing initial parameters
433 * \param strictly - if true, always return myInitParamsHypo,
434 * else, return myInitParamsHypo only in creation mode and if it
437 //================================================================================
439 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
442 return myInitParamsHypo;
443 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
445 return myInitParamsHypo;
448 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
450 return !CORBA::is_nil( myInitParamsHypo );
453 QString SMESHGUI_GenericHypothesisCreator::hypType() const
458 QString SMESHGUI_GenericHypothesisCreator::hypName() const
463 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
465 return myParamWidgets;
468 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
470 return myParamWidgets;
473 //================================================================================
475 * \brief Returns a QLabel of a spesified parameter.
476 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
478 //================================================================================
480 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
484 if ( i < myParamLabels.size() )
485 return (QLabel*) myParamLabels.at(i);
489 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
494 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
499 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
503 QString SMESHGUI_GenericHypothesisCreator::caption() const
508 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
513 QString SMESHGUI_GenericHypothesisCreator::type() const
517 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
519 const int /*index*/) const
523 //================================================================================
525 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
527 //================================================================================
529 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
534 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
539 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
542 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
543 for( ; anIt!=aLast; anIt++ )
545 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
547 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
548 ok = sb->isValid( msg, true ) && ok;
550 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
552 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
553 ok = sb->isValid( msg, true ) && ok;
559 void SMESHGUI_GenericHypothesisCreator::onReject()
563 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
565 QString aHypType = hypType();
566 QString aHelpFileName = "";
567 if ( aHypType == "LocalLength" )
568 aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
569 else if ( aHypType == "MaxLength" )
570 aHelpFileName = "a1d_meshing_hypo_page.html#max_length_anchor";
571 else if ( aHypType == "Arithmetic1D")
572 aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
573 else if ( aHypType == "GeometricProgression")
574 aHelpFileName = "a1d_meshing_hypo_page.html#geometric_1d_anchor";
575 else if ( aHypType == "FixedPoints1D")
576 aHelpFileName = "a1d_meshing_hypo_page.html#fixed_points_1d_anchor";
577 else if ( aHypType == "MaxElementArea")
578 aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
579 else if ( aHypType == "MaxElementVolume")
580 aHelpFileName = "max_element_volume_hypo_page.html";
581 else if ( aHypType == "StartEndLength")
582 aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
583 else if ( aHypType == "Deflection1D")
584 aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
585 else if ( aHypType == "Adaptive1D")
586 aHelpFileName = "a1d_meshing_hypo_page.html#adaptive_1d_anchor";
587 else if ( aHypType == "AutomaticLength")
588 aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
589 else if ( aHypType == "NumberOfSegments")
590 aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
591 else if ( aHypType == "ProjectionSource1D")
592 aHelpFileName = "projection_algos_page.html";
593 else if ( aHypType == "ProjectionSource2D")
594 aHelpFileName = "projection_algos_page.html";
595 else if ( aHypType == "ProjectionSource3D")
596 aHelpFileName = "projection_algos_page.html";
597 else if ( aHypType == "NumberOfLayers")
598 aHelpFileName = "radial_prism_algo_page.html";
599 else if ( aHypType == "NumberOfLayers2D")
600 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
601 else if ( aHypType == "LayerDistribution")
602 aHelpFileName = "radial_prism_algo_page.html";
603 else if ( aHypType == "LayerDistribution2D")
604 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
605 else if ( aHypType == "SegmentLengthAroundVertex")
606 aHelpFileName = "segments_around_vertex_algo_page.html";
607 else if ( aHypType == "QuadrangleParams")
608 aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
609 else if ( aHypType == "ViscousLayers")
610 aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
611 else if ( aHypType == "ViscousLayers2D")
612 aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
613 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
614 aHelpFileName = "import_algos_page.html";
615 return aHelpFileName;
618 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
619 : QtxDialog( parent, false, true ),
622 setAttribute(Qt::WA_DeleteOnClose, true);
623 // setMinimumSize( 300, height() );
624 // setFixedSize( 300, height() );
625 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
626 topLayout->setMargin( 0 );
627 topLayout->setSpacing( 0 );
629 QFrame* titFrame = new QFrame( mainFrame() );
630 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
631 titLay->setMargin( 0 );
632 titLay->setSpacing( SPACING );
634 myIconLabel = new QLabel( titFrame );
635 myIconLabel->setScaledContents( false );
636 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
637 myTypeLabel = new QLabel( titFrame );
639 myTypeLabel->setText( creator->hypType() );
641 titLay->addWidget( myIconLabel, 0 );
642 titLay->addWidget( myTypeLabel, 0 );
643 titLay->addStretch( 1 );
645 topLayout->addWidget( titFrame, 0 );
647 myHelpFileName = creator->helpPage();
649 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
652 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
657 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
661 f->setParent( mainFrame() );
662 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
666 void SMESHGUI_HypothesisDlg::accept()
668 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
670 if ( myCreator && !myCreator->checkParams( msg ) )
672 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
673 if ( !msg.isEmpty() )
675 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
681 void SMESHGUI_HypothesisDlg::reject()
683 if ( myCreator ) myCreator->onReject();
687 void SMESHGUI_HypothesisDlg::onHelp()
689 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
691 QString name = "SMESH";
693 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
694 if( pluginName.isValid() ) {
695 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
696 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
697 if(!varValue.isEmpty())
698 name = pluginName.toString() + "PLUGIN";
701 app->onHelpContextModule(name, myHelpFileName);
706 platform = "winapplication";
708 platform = "application";
710 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
711 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
712 arg(app->resourceMgr()->stringValue("ExternalBrowser",
714 arg(myHelpFileName));
718 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
720 myIconLabel->setPixmap( p );
723 void SMESHGUI_HypothesisDlg::setType( const QString& t )
725 myTypeLabel->setText( t );
728 HypothesisData::HypothesisData( const QString& theTypeName,
729 const QString& thePluginName,
730 const QString& theServerLibName,
731 const QString& theClientLibName,
732 const QString& theLabel,
733 const QString& theIconId,
734 const QString& theContext,
735 const QList<int>& theDim,
736 const bool theIsAuxOrNeedHyp,
737 const QStringList& theBasicHypos,
738 const QStringList& theOptionalHypos,
739 const QStringList& theInputTypes,
740 const QStringList& theOutputTypes,
741 const bool theIsNeedGeometry,
742 const bool supportSub)
743 : TypeName( theTypeName ),
744 PluginName( thePluginName ),
745 ServerLibName( theServerLibName ),
746 ClientLibName( theClientLibName ),
749 Context( theContext ),
751 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
752 BasicHypos( theBasicHypos ),
753 OptionalHypos( theOptionalHypos ),
754 InputTypes( theInputTypes ),
755 OutputTypes( theOutputTypes ),
756 IsNeedGeometry( theIsNeedGeometry ),
757 IsSupportSubmeshes( supportSub )
761 HypothesesSet::HypothesesSet( const QString& theSetName )
762 : myHypoSetName( theSetName ),
768 HypothesesSet::HypothesesSet( const QString& theSetName,
769 const QStringList& theHypoList,
770 const QStringList& theAlgoList )
771 : myHypoSetName( theSetName ),
772 myHypoList( theHypoList ),
773 myAlgoList( theAlgoList ),
779 QStringList* HypothesesSet::list(bool is_algo) const
781 return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
784 QStringList* HypothesesSet::list() const
786 return list( myIsAlgo );
789 QString HypothesesSet::name() const
791 return myHypoSetName;
794 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
799 int HypothesesSet::count( bool isAlgo ) const
801 return list(isAlgo)->count();
804 bool HypothesesSet::isAlgo() const
809 void HypothesesSet::init( bool isAlgo )
815 bool HypothesesSet::more() const
817 return myIndex < list()->count();
820 void HypothesesSet::next()
825 QString HypothesesSet::current() const
827 return list()->at(myIndex);
830 void HypothesesSet::setIsCustom( bool isCustom )
832 myIsCustom = isCustom;
835 bool HypothesesSet::getIsCustom() const
840 int HypothesesSet::maxDim() const
842 HypothesesSet * thisSet = (HypothesesSet*) this;
844 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
846 thisSet->init( isAlgo );
847 while ( thisSet->next(), thisSet->more() )
848 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
849 for ( int i = 0; i < hypData->Dim.count(); ++i )
850 dim = qMax( dim, hypData->Dim[i] );