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
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>
44 #include <SalomeApp_Tools.h>
51 #include <QVBoxLayout>
56 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
57 : myToDeleteInitParamsHypo( false ),
58 myHypType( theHypType ),
64 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
66 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
67 myInitParamsHypo->UnRegister();
70 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
72 if ( !CORBA::is_nil( hyp ) ) {
73 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
74 myInitParamsHypo->UnRegister();
75 CORBA::String_var hypName = hyp->GetName();
76 if ( hypType() == hypName.in() )
78 myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
79 myToDeleteInitParamsHypo = !SMESH::FindSObject( myInitParamsHypo );
84 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
85 const QString& theHypName,
86 QWidget* parent, QObject* obj, const QString& slot )
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 )
98 // Create hypothesis/algorithm
100 SMESH::SMESH_Hypothesis_var anAlgo =
101 SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
102 anAlgo.out(); // avoid unused variable warning
105 SMESH::SMESH_Hypothesis_var aHypothesis =
106 SMESH::CreateHypothesis( hypType(), theHypName, false );
107 editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
111 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
112 const QString& theHypName,
113 QWidget* theParent, QObject* obj, const QString& slot )
115 if( CORBA::is_nil( theHypothesis ) )
120 editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
123 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
124 const QString& theHypName,
126 QObject* obj, const QString& slot )
128 myHypName = theHypName;
129 myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
132 SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
133 connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
134 connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
135 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), Dlg, SLOT( reject() ));
138 QFrame* fr = buildFrame();
141 Dlg->setCustomFrame( fr );
142 Dlg->setWindowTitle( caption() );
143 Dlg->setObjectName( theHypName );
144 Dlg->setHIcon( icon() );
145 Dlg->setType( type() );
148 Dlg->resize( Dlg->minimumSizeHint() );
151 emit finished( QDialog::Accepted );
156 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
158 if( CORBA::is_nil( hypothesis() ) )
161 ListOfStdParams params;
162 if( !stdParams( params ) || params.isEmpty() )
165 QFrame* fr = new QFrame( 0 );
166 QVBoxLayout* lay = new QVBoxLayout( fr );
168 lay->setSpacing( 0 );
170 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
171 lay->addWidget( GroupC1 );
173 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
174 GroupC1Layout->setSpacing( SPACING );
175 GroupC1Layout->setMargin( MARGIN );
177 ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
178 for( int i=0; anIt!=aLast; anIt++, i++ )
180 QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
181 GroupC1Layout->addWidget( lab, i, 0 );
182 myParamLabels << lab;
184 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
186 switch( (*anIt).myValue.type() )
190 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
191 sb->setObjectName( (*anIt).myName );
192 attuneStdWidget( sb, i );
193 sb->setValue( (*anIt).myValue.toInt() );
194 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
198 case QVariant::Double:
200 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
201 sb->setObjectName( (*anIt).myName );
202 attuneStdWidget( sb, i );
203 sb->setValue( (*anIt).myValue.toDouble() );
204 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
208 case QVariant::String:
210 if((*anIt).isVariable) {
211 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
212 QString aVar = (*anIt).myValue.toString();
213 if(aStudy->IsInteger(aVar.toLatin1().constData())){
214 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
215 sb->setObjectName( (*anIt).myName );
216 attuneStdWidget( sb, i );
218 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
221 else if(aStudy->IsReal(aVar.toLatin1().constData())){
222 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
223 sb->setObjectName( (*anIt).myName );
224 attuneStdWidget( sb, i );
226 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
231 QLineEdit* le = new QLineEdit( GroupC1 );
232 le->setObjectName( (*anIt).myName );
233 attuneStdWidget( le, i );
234 le->setText( (*anIt).myValue.toString() );
235 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
242 } // switch( (*anIt).myValue.type() )
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;
276 SUIT_OverrideCursor wc;
278 // No longer needed since NoteBook appears and "Value" OB field shows names of variable
279 // QString paramValues = storeParams();
280 // if ( !paramValues.isEmpty() ) {
281 // if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
282 // SMESH::SetValue( SHyp, paramValues );
285 catch ( const SALOME::SALOME_Exception& S_ex ) {
286 SalomeApp_Tools::QtCatchCorbaException( S_ex );
290 changeWidgets().clear();
292 if( myIsCreate && !res )
294 //remove just created hypothesis
295 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
296 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
297 if( aStudy && !aStudy->GetProperties()->IsLocked() )
299 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
300 aBuilder->RemoveObjectWithChildren( aHypSObject );
303 else if( !myIsCreate && res )
305 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
306 if( listSOmesh.size() > 0 )
307 for( size_t i = 0; i < listSOmesh.size(); i++ )
309 _PTR(SObject) submSO = listSOmesh[i];
310 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
311 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
312 if( !aSubMesh->_is_nil() )
313 aMesh = aSubMesh->GetFather();
314 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
315 SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
318 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
319 myHypo->UnRegister();
320 myHypo = SMESH::SMESH_Hypothesis::_nil();
321 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
323 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
325 //delete myDlg; since WA_DeleteOnClose==true
327 emit finished( result );
330 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
335 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
339 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
340 for( ; anIt!=aLast; anIt++ )
342 item.myName = (*anIt)->objectName();
343 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
345 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
346 item.myValue = sb->value();
347 item.myText = sb->text();
348 params.append( item );
350 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
352 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
353 item.myValue = sb->value();
354 item.myText = sb->text();
355 params.append( item );
357 else if( (*anIt)->inherits( "QLineEdit" ) )
359 QLineEdit* line = ( QLineEdit* )( *anIt );
360 item.myValue = item.myText = line->text();
361 params.append( item );
363 else if ( getParamFromCustomWidget( item, *anIt ))
365 params.append( item );
373 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
375 SMESH::SMESH_Hypothesis_var h = hypothesis();
378 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
379 return QString( aVaribaleName.in() );
384 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
387 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
388 for( ; anIt!=aLast; anIt++ ) {
389 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
390 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
391 aResult.append(sb->text());
397 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
399 QString valueStr = "";
400 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
402 for ( ; param != aLast; param++ )
404 if ( valueStr.length() > len0 ) {
406 len0 = valueStr.length();
408 switch( (*param).myValue.type() )
411 valueStr += valueStr.number( (*param).myValue.toInt() );
413 case QVariant::Double:
414 valueStr += valueStr.number( (*param).myValue.toDouble() );
416 case QVariant::String:
417 valueStr += (*param).myValue.toString();
420 QVariant valCopy = (*param).myValue;
421 valueStr += valCopy.toString();
427 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
432 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
434 myShapeEntry = theEntry;
437 //================================================================================
439 * \brief Return hypothesis containing initial parameters
440 * \param strictly - if true, always return myInitParamsHypo,
441 * else, return myInitParamsHypo only in creation mode and if it
444 //================================================================================
446 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
449 return myInitParamsHypo;
450 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
452 return myInitParamsHypo;
455 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
457 return !CORBA::is_nil( myInitParamsHypo );
460 QString SMESHGUI_GenericHypothesisCreator::hypType() const
465 QString SMESHGUI_GenericHypothesisCreator::hypName() const
470 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
472 return myParamWidgets;
475 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
477 return myParamWidgets;
480 //================================================================================
482 * \brief Returns a QLabel of a spesified parameter.
483 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
485 //================================================================================
487 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
491 if ( i < myParamLabels.size() )
492 return (QLabel*) myParamLabels.at(i);
496 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
501 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
506 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
510 QString SMESHGUI_GenericHypothesisCreator::caption() const
515 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
520 QString SMESHGUI_GenericHypothesisCreator::type() const
524 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
526 const int /*index*/) const
530 //================================================================================
532 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
534 //================================================================================
536 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
541 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
546 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
549 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
550 for( ; anIt!=aLast; anIt++ )
552 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
554 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
555 ok = sb->isValid( msg, true ) && ok;
557 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
559 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
560 ok = sb->isValid( msg, true ) && ok;
566 void SMESHGUI_GenericHypothesisCreator::onReject()
570 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
572 QString aHypType = hypType();
573 QString aHelpFileName = "";
574 if ( aHypType == "LocalLength" )
575 aHelpFileName = "a1d_meshing_hypo_page.html#average_length_anchor";
576 else if ( aHypType == "MaxLength" )
577 aHelpFileName = "a1d_meshing_hypo_page.html#max_length_anchor";
578 else if ( aHypType == "Arithmetic1D")
579 aHelpFileName = "a1d_meshing_hypo_page.html#arithmetic_1d_anchor";
580 else if ( aHypType == "GeometricProgression")
581 aHelpFileName = "a1d_meshing_hypo_page.html#geometric_1d_anchor";
582 else if ( aHypType == "FixedPoints1D")
583 aHelpFileName = "a1d_meshing_hypo_page.html#fixed_points_1d_anchor";
584 else if ( aHypType == "MaxElementArea")
585 aHelpFileName = "a2d_meshing_hypo_page.html#max_element_area_anchor";
586 else if ( aHypType == "MaxElementVolume")
587 aHelpFileName = "max_element_volume_hypo_page.html";
588 else if ( aHypType == "StartEndLength")
589 aHelpFileName = "a1d_meshing_hypo_page.html#start_and_end_length_anchor";
590 else if ( aHypType == "Deflection1D")
591 aHelpFileName = "a1d_meshing_hypo_page.html#deflection_1d_anchor";
592 else if ( aHypType == "Adaptive1D")
593 aHelpFileName = "a1d_meshing_hypo_page.html#adaptive_1d_anchor";
594 else if ( aHypType == "AutomaticLength")
595 aHelpFileName = "a1d_meshing_hypo_page.html#automatic_length_anchor";
596 else if ( aHypType == "NumberOfSegments")
597 aHelpFileName = "a1d_meshing_hypo_page.html#number_of_segments_anchor";
598 else if ( aHypType == "ProjectionSource1D")
599 aHelpFileName = "projection_algos_page.html";
600 else if ( aHypType == "ProjectionSource2D")
601 aHelpFileName = "projection_algos_page.html";
602 else if ( aHypType == "ProjectionSource3D")
603 aHelpFileName = "projection_algos_page.html";
604 else if ( aHypType == "NumberOfLayers")
605 aHelpFileName = "radial_prism_algo_page.html";
606 else if ( aHypType == "NumberOfLayers2D")
607 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
608 else if ( aHypType == "LayerDistribution")
609 aHelpFileName = "radial_prism_algo_page.html";
610 else if ( aHypType == "LayerDistribution2D")
611 aHelpFileName = "radial_quadrangle_1D2D_algo_page.html";
612 else if ( aHypType == "SegmentLengthAroundVertex")
613 aHelpFileName = "segments_around_vertex_algo_page.html";
614 else if ( aHypType == "QuadrangleParams")
615 aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
616 else if ( aHypType == "ViscousLayers")
617 aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
618 else if ( aHypType == "ViscousLayers2D")
619 aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
620 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
621 aHelpFileName = "import_algos_page.html";
622 return aHelpFileName;
625 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
626 : QtxDialog( parent, false, true ),
629 setAttribute(Qt::WA_DeleteOnClose, true);
630 // setMinimumSize( 300, height() );
631 // setFixedSize( 300, height() );
632 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
633 topLayout->setMargin( 0 );
634 topLayout->setSpacing( 0 );
636 QFrame* titFrame = new QFrame( mainFrame() );
637 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
638 titLay->setMargin( 0 );
639 titLay->setSpacing( SPACING );
641 myIconLabel = new QLabel( titFrame );
642 myIconLabel->setScaledContents( false );
643 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
644 myTypeLabel = new QLabel( titFrame );
646 myTypeLabel->setText( creator->hypType() );
648 titLay->addWidget( myIconLabel, 0 );
649 titLay->addWidget( myTypeLabel, 0 );
650 titLay->addStretch( 1 );
652 topLayout->addWidget( titFrame, 0 );
654 myHelpFileName = creator->helpPage();
656 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
659 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
664 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
668 f->setParent( mainFrame() );
669 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
673 void SMESHGUI_HypothesisDlg::accept()
675 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
677 if ( myCreator && !myCreator->checkParams( msg ) )
679 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
680 if ( !msg.isEmpty() )
682 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
688 void SMESHGUI_HypothesisDlg::reject()
690 if ( myCreator ) myCreator->onReject();
694 void SMESHGUI_HypothesisDlg::onHelp()
696 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
698 QString name = "SMESH";
700 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
701 if( pluginName.isValid() ) {
702 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
703 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
704 if(!varValue.isEmpty())
705 name = pluginName.toString() + "PLUGIN";
708 app->onHelpContextModule(name, myHelpFileName);
713 platform = "winapplication";
715 platform = "application";
717 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
718 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
719 arg(app->resourceMgr()->stringValue("ExternalBrowser",
721 arg(myHelpFileName));
725 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
727 myIconLabel->setPixmap( p );
730 void SMESHGUI_HypothesisDlg::setType( const QString& t )
732 myTypeLabel->setText( t );
735 HypothesisData::HypothesisData( const QString& theTypeName,
736 const QString& thePluginName,
737 const QString& theServerLibName,
738 const QString& theClientLibName,
739 const QString& theLabel,
740 const QString& theIconId,
741 const QString& theContext,
742 const QList<int>& theDim,
743 const bool theIsAuxOrNeedHyp,
744 const QStringList& theBasicHypos,
745 const QStringList& theOptionalHypos,
746 const QStringList& theInputTypes,
747 const QStringList& theOutputTypes,
748 const bool theIsNeedGeometry,
749 const bool supportSub)
750 : TypeName( theTypeName ),
751 PluginName( thePluginName ),
752 ServerLibName( theServerLibName ),
753 ClientLibName( theClientLibName ),
756 Context( theContext ),
758 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
759 IsNeedGeometry( theIsNeedGeometry ),
760 IsSupportSubmeshes( supportSub ),
761 BasicHypos( theBasicHypos ),
762 OptionalHypos( theOptionalHypos ),
763 InputTypes( theInputTypes ),
764 OutputTypes( theOutputTypes )
768 HypothesesSet::HypothesesSet( const QString& theSetName )
769 : myHypoSetName( theSetName ),
775 HypothesesSet::HypothesesSet( const QString& theSetName,
776 const QStringList& theHypoList,
777 const QStringList& theAlgoList )
778 : myHypoSetName( theSetName ),
779 myHypoList( theHypoList ),
780 myAlgoList( theAlgoList ),
786 QStringList* HypothesesSet::list(bool is_algo) const
788 return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
791 QStringList* HypothesesSet::list() const
793 return list( myIsAlgo );
796 QString HypothesesSet::name() const
798 return myHypoSetName;
801 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
806 int HypothesesSet::count( bool isAlgo ) const
808 return list(isAlgo)->count();
811 bool HypothesesSet::isAlgo() const
816 void HypothesesSet::init( bool isAlgo )
822 bool HypothesesSet::more() const
824 return myIndex < list()->count();
827 void HypothesesSet::next()
832 QString HypothesesSet::current() const
834 return list()->at(myIndex);
837 void HypothesesSet::setIsCustom( bool isCustom )
839 myIsCustom = isCustom;
842 bool HypothesesSet::getIsCustom() const
847 int HypothesesSet::maxDim() const
849 HypothesesSet * thisSet = (HypothesesSet*) this;
851 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
853 thisSet->init( isAlgo );
854 while ( thisSet->next(), thisSet->more() )
855 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
856 for ( int i = 0; i < hypData->Dim.count(); ++i )
857 dim = qMax( dim, hypData->Dim[i] );