1 // Copyright (C) 2007-2019 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"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESH_Actor.h"
35 // SALOME KERNEL includes
36 #include <SALOMEDSClient_Study.hxx>
37 #include <utilities.h>
39 // SALOME GUI includes
40 #include <LightApp_Application.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_OverrideCursor.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SalomeApp_IntSpinBox.h>
46 #include <SalomeApp_Tools.h>
47 #include <SVTK_ViewWindow.h>
54 #include <QVBoxLayout>
59 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
60 : myToDeleteInitParamsHypo( false ),
61 myHypType( theHypType ),
67 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
69 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
70 myInitParamsHypo->UnRegister();
73 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
75 if ( !CORBA::is_nil( hyp ) ) {
76 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
77 myInitParamsHypo->UnRegister();
78 CORBA::String_var hypName = hyp->GetName();
79 if ( hypType() == hypName.in() )
81 myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
82 myToDeleteInitParamsHypo = !SMESH::FindSObject( myInitParamsHypo );
87 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
88 const QString& theHypName,
89 QWidget* parent, QObject* obj, const QString& slot )
91 setInitParamsHypothesis( initParamsHyp );
92 create( false, theHypName, parent, obj, slot );
95 void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
96 const QString& theHypName,
103 // Create hypothesis/algorithm
105 SMESH::SMESH_Hypothesis_var anAlgo =
106 SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
107 anAlgo.out(); // avoid unused variable warning
110 SMESH::SMESH_Hypothesis_var aHypothesis =
111 SMESH::CreateHypothesis( hypType(), theHypName, false );
112 editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
116 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
117 const QString& theHypName,
118 QWidget* theParent, QObject* obj, const QString& slot )
120 if( CORBA::is_nil( theHypothesis ) )
125 editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
128 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
129 const QString& theHypName,
131 QObject* obj, const QString& slot )
133 myHypName = theHypName;
134 myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
137 SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
138 connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
139 connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
140 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), Dlg, SLOT( reject() ));
143 QFrame* fr = buildFrame();
146 Dlg->setCustomFrame( fr );
147 Dlg->setWindowTitle( caption() );
148 Dlg->setObjectName( theHypName );
149 Dlg->setHIcon( icon() );
150 Dlg->setType( type() );
153 Dlg->resize( Dlg->minimumSizeHint() );
156 emit finished( QDialog::Accepted );
161 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
163 if( CORBA::is_nil( hypothesis() ) )
166 ListOfStdParams params;
167 if( !stdParams( params ) || params.isEmpty() )
170 QFrame* fr = new QFrame( 0 );
171 QVBoxLayout* lay = new QVBoxLayout( fr );
173 lay->setSpacing( 0 );
175 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
176 lay->addWidget( GroupC1 );
178 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
179 GroupC1Layout->setSpacing( SPACING );
180 GroupC1Layout->setMargin( MARGIN );
182 ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
183 for( int i=0; anIt!=aLast; anIt++, i++ )
185 QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
186 GroupC1Layout->addWidget( lab, i, 0 );
187 myParamLabels << lab;
189 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
191 switch( (*anIt).myValue.type() )
195 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
196 sb->setObjectName( (*anIt).myName );
197 attuneStdWidget( sb, i );
198 sb->setValue( (*anIt).myValue.toInt() );
199 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
203 case QVariant::Double:
205 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
206 sb->setObjectName( (*anIt).myName );
207 attuneStdWidget( sb, i );
208 sb->setValue( (*anIt).myValue.toDouble() );
209 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
213 case QVariant::String:
215 if((*anIt).isVariable) {
216 _PTR(Study) aStudy = SMESH::getStudy();
217 QString aVar = (*anIt).myValue.toString();
218 if(aStudy->IsInteger(aVar.toLatin1().constData())){
219 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
220 sb->setObjectName( (*anIt).myName );
221 attuneStdWidget( sb, i );
223 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
226 else if(aStudy->IsReal(aVar.toLatin1().constData())){
227 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
228 sb->setObjectName( (*anIt).myName );
229 attuneStdWidget( sb, i );
231 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
236 QLineEdit* le = new QLineEdit( GroupC1 );
237 le->setObjectName( (*anIt).myName );
238 attuneStdWidget( le, i );
239 le->setText( (*anIt).myValue.toString() );
240 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
247 } // switch( (*anIt).myValue.type() )
251 GroupC1Layout->addWidget( w, i, 1 );
252 changeWidgets().append( w );
255 if ( QWidget* w = getHelperWidget() )
258 w->move( QPoint( 0, 0 ) );
265 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
267 valueChanged( (QWidget*) sender() );
270 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
274 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
276 bool res = result==QDialog::Accepted;
281 SUIT_OverrideCursor wc;
283 // No longer needed since NoteBook appears and "Value" OB field shows names of variable
284 // QString paramValues = storeParams();
285 // if ( !paramValues.isEmpty() ) {
286 // if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
287 // SMESH::SetValue( SHyp, paramValues );
290 catch ( const SALOME::SALOME_Exception& S_ex ) {
291 SalomeApp_Tools::QtCatchCorbaException( S_ex );
295 changeWidgets().clear();
297 if( myIsCreate && !res )
299 //remove just created hypothesis
300 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
301 _PTR(Study) aStudy = SMESH::getStudy();
302 if( aStudy && !aStudy->GetProperties()->IsLocked() )
304 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
305 aBuilder->RemoveObjectWithChildren( aHypSObject );
308 else if( !myIsCreate && res )
310 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
311 if( listSOmesh.size() > 0 )
312 for( size_t i = 0; i < listSOmesh.size(); i++ )
314 _PTR(SObject) submSO = listSOmesh[i];
315 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
316 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
317 if( !aSubMesh->_is_nil() )
318 aMesh = aSubMesh->GetFather();
319 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
320 SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
321 if( actor && actor->GetVisibility() )
325 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
326 myHypo->UnRegister();
327 myHypo = SMESH::SMESH_Hypothesis::_nil();
328 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
330 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
332 //delete myDlg; since WA_DeleteOnClose==true
334 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
337 emit finished( result );
340 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
345 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
349 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
350 for( ; anIt!=aLast; anIt++ )
352 item.myName = (*anIt)->objectName();
353 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
355 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
356 item.myValue = sb->value();
357 item.myText = sb->text();
358 params.append( item );
360 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
362 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
363 item.myValue = sb->value();
364 item.myText = sb->text();
365 params.append( item );
367 else if( (*anIt)->inherits( "QLineEdit" ) )
369 QLineEdit* line = ( QLineEdit* )( *anIt );
370 item.myValue = item.myText = line->text();
371 params.append( item );
373 else if ( getParamFromCustomWidget( item, *anIt ))
375 params.append( item );
383 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
385 SMESH::SMESH_Hypothesis_var h = hypothesis();
388 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
389 return QString( aVaribaleName.in() );
394 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
397 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
398 for( ; anIt!=aLast; anIt++ ) {
399 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
400 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
401 aResult.append(sb->text());
407 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
409 QString valueStr = "";
410 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
412 for ( ; param != aLast; param++ )
414 if ( valueStr.length() > len0 ) {
416 len0 = valueStr.length();
418 switch( (*param).myValue.type() )
421 valueStr += valueStr.number( (*param).myValue.toInt() );
423 case QVariant::Double:
424 valueStr += valueStr.number( (*param).myValue.toDouble() );
426 case QVariant::String:
427 valueStr += (*param).myValue.toString();
430 QVariant valCopy = (*param).myValue;
431 valueStr += valCopy.toString();
437 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
442 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
444 myShapeEntry = theEntry;
447 //================================================================================
449 * \brief Return hypothesis containing initial parameters
450 * \param strictly - if true, always return myInitParamsHypo,
451 * else, return myInitParamsHypo only in creation mode and if it
454 //================================================================================
456 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
459 return myInitParamsHypo;
460 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
462 return myInitParamsHypo;
465 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
467 return !CORBA::is_nil( myInitParamsHypo );
470 QString SMESHGUI_GenericHypothesisCreator::hypType() const
475 QString SMESHGUI_GenericHypothesisCreator::hypName() const
480 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
482 return myParamWidgets;
485 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
487 return myParamWidgets;
490 //================================================================================
492 * \brief Returns a QLabel of a spesified parameter.
493 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
495 //================================================================================
497 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
501 if ( i < myParamLabels.size() )
502 return (QLabel*) myParamLabels.at(i);
506 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
511 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
516 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
520 QString SMESHGUI_GenericHypothesisCreator::caption() const
525 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
530 QString SMESHGUI_GenericHypothesisCreator::type() const
534 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
536 const int /*index*/) const
540 //================================================================================
542 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
544 //================================================================================
546 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
551 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
556 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
559 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
560 for( ; anIt!=aLast; anIt++ )
562 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
564 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
565 ok = sb->isValid( msg, true ) && ok;
567 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
569 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
570 ok = sb->isValid( msg, true ) && ok;
576 void SMESHGUI_GenericHypothesisCreator::onReject()
580 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
582 QString aHypType = hypType();
583 QString aHelpFileName = "";
584 if ( aHypType == "LocalLength" )
585 aHelpFileName = "1d_meshing_hypo.html#average-length-anchor";
586 else if ( aHypType == "MaxLength" )
587 aHelpFileName = "1d_meshing_hypo.html#max-length-anchor";
588 else if ( aHypType == "Arithmetic1D")
589 aHelpFileName = "1d_meshing_hypo.html#arithmetic-1d-anchor";
590 else if ( aHypType == "GeometricProgression")
591 aHelpFileName = "1d_meshing_hypo.html#geometric-1d-anchor";
592 else if ( aHypType == "FixedPoints1D")
593 aHelpFileName = "1d_meshing_hypo.html#fixed-points-1d-anchor";
594 else if ( aHypType == "MaxElementArea")
595 aHelpFileName = "2d_meshing_hypo.html#max-element-area-anchor";
596 else if ( aHypType == "MaxElementVolume")
597 aHelpFileName = "max_element_volume_hypo.html";
598 else if ( aHypType == "StartEndLength")
599 aHelpFileName = "1d_meshing_hypo.html#start-and-end-length-anchor";
600 else if ( aHypType == "Deflection1D")
601 aHelpFileName = "1d_meshing_hypo.html#deflection-1d-anchor";
602 else if ( aHypType == "Adaptive1D")
603 aHelpFileName = "1d_meshing_hypo.html#adaptive-1d-anchor";
604 else if ( aHypType == "AutomaticLength")
605 aHelpFileName = "1d_meshing_hypo.html#automatic-length-anchor";
606 else if ( aHypType == "NumberOfSegments")
607 aHelpFileName = "1d_meshing_hypo.html#number-of-segments-anchor";
608 else if ( aHypType == "ProjectionSource1D")
609 aHelpFileName = "projection_algos.html";
610 else if ( aHypType == "ProjectionSource2D")
611 aHelpFileName = "projection_algos.html";
612 else if ( aHypType == "ProjectionSource3D")
613 aHelpFileName = "projection_algos.html";
614 else if ( aHypType == "NumberOfLayers")
615 aHelpFileName = "radial_prism_algo.html";
616 else if ( aHypType == "NumberOfLayers2D")
617 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
618 else if ( aHypType == "LayerDistribution")
619 aHelpFileName = "radial_prism_algo.html";
620 else if ( aHypType == "LayerDistribution2D")
621 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
622 else if ( aHypType == "SegmentLengthAroundVertex")
623 aHelpFileName = "segments_around_vertex_algo.html";
624 else if ( aHypType == "QuadrangleParams")
625 aHelpFileName = "2d_meshing_hypo.html#hypo-quad-params-anchor";
626 else if ( aHypType == "ViscousLayers")
627 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
628 else if ( aHypType == "ViscousLayers2D")
629 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
630 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
631 aHelpFileName = "use_existing_algos.html";
632 return aHelpFileName;
635 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
636 : QtxDialog( parent, false, true ),
639 setAttribute(Qt::WA_DeleteOnClose, true);
640 // setMinimumSize( 300, height() );
641 // setFixedSize( 300, height() );
642 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
643 topLayout->setMargin( 0 );
644 topLayout->setSpacing( 0 );
646 QFrame* titFrame = new QFrame( mainFrame() );
647 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
648 titLay->setMargin( 0 );
649 titLay->setSpacing( SPACING );
651 myIconLabel = new QLabel( titFrame );
652 myIconLabel->setScaledContents( false );
653 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
654 myTypeLabel = new QLabel( titFrame );
656 myTypeLabel->setText( creator->hypType() );
658 titLay->addWidget( myIconLabel, 0 );
659 titLay->addWidget( myTypeLabel, 0 );
660 titLay->addStretch( 1 );
662 topLayout->addWidget( titFrame, 0 );
664 myHelpFileName = creator->helpPage();
666 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
669 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
674 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
678 f->setParent( mainFrame() );
679 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
683 void SMESHGUI_HypothesisDlg::accept()
685 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
687 if ( myCreator && !myCreator->checkParams( msg ) )
689 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
690 if ( !msg.isEmpty() )
692 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
698 void SMESHGUI_HypothesisDlg::reject()
700 if ( myCreator ) myCreator->onReject();
704 void SMESHGUI_HypothesisDlg::onHelp()
706 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
708 QString name = "SMESH";
710 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
711 if( pluginName.isValid() ) {
712 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
713 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
714 if(!varValue.isEmpty())
715 name = pluginName.toString() + "PLUGIN";
718 app->onHelpContextModule(name, myHelpFileName);
723 platform = "winapplication";
725 platform = "application";
727 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
728 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
729 arg(app->resourceMgr()->stringValue("ExternalBrowser",
731 arg(myHelpFileName));
735 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
737 myIconLabel->setPixmap( p );
740 void SMESHGUI_HypothesisDlg::setType( const QString& t )
742 myTypeLabel->setText( t );
745 HypothesisData::HypothesisData( const QString& theTypeName,
746 const QString& thePluginName,
747 const QString& theServerLibName,
748 const QString& theClientLibName,
749 const QString& theLabel,
750 const QString& theIconId,
751 const QString& theContext,
752 const int theGroupID,
753 const int thePriority,
754 const QList<int>& theDim,
755 const bool theIsAuxOrNeedHyp,
756 const QStringList& theBasicHypos,
757 const QStringList& theOptionalHypos,
758 const QStringList& theInputTypes,
759 const QStringList& theOutputTypes,
760 const int theIsNeedGeometry,
761 const bool theSupportSub)
762 : TypeName( theTypeName ),
763 PluginName( thePluginName ),
764 ServerLibName( theServerLibName ),
765 ClientLibName( theClientLibName ),
768 Context( theContext ),
769 GroupID( theGroupID ),
770 Priority( thePriority ),
772 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
773 IsNeedGeometry( theIsNeedGeometry ),
774 IsSupportSubmeshes( theSupportSub ),
775 BasicHypos( theBasicHypos ),
776 OptionalHypos( theOptionalHypos ),
777 InputTypes( theInputTypes ),
778 OutputTypes( theOutputTypes )
782 HypothesesSet::HypothesesSet( const QString& theSetName )
783 : myHypoSetName( theSetName ),
789 HypothesesSet::HypothesesSet( const QString& theSetName,
790 const QStringList& theHypoList,
791 const QStringList& theAlgoList )
792 : myHypoSetName( theSetName ),
793 myHypoList( theHypoList ),
794 myAlgoList( theAlgoList ),
800 QStringList* HypothesesSet::list(bool is_algo) const
802 return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
805 QStringList* HypothesesSet::list() const
807 return list( myIsAlgo );
810 QString HypothesesSet::name() const
812 return myHypoSetName;
815 void HypothesesSet::set( bool isAlgo, const QStringList& lst )
820 int HypothesesSet::count( bool isAlgo ) const
822 return list(isAlgo)->count();
825 bool HypothesesSet::isAlgo() const
830 void HypothesesSet::init( bool isAlgo )
836 bool HypothesesSet::more() const
838 return myIndex < list()->count();
841 void HypothesesSet::next()
846 QString HypothesesSet::current() const
848 return list()->at(myIndex);
851 void HypothesesSet::setIsCustom( bool isCustom )
853 myIsCustom = isCustom;
856 bool HypothesesSet::getIsCustom() const
861 int HypothesesSet::maxDim() const
863 HypothesesSet * thisSet = (HypothesesSet*) this;
865 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
867 thisSet->init( isAlgo );
868 while ( thisSet->next(), thisSet->more() )
869 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
870 for ( int i = 0; i < hypData->Dim.count(); ++i )
871 dim = qMax( dim, hypData->Dim[i] );