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_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESH_Actor.h"
34 #include "SMESH_TypeDefs.hxx"
36 // SALOME KERNEL includes
37 #include <SALOMEDSClient_Study.hxx>
38 #include <utilities.h>
40 // SALOME GUI includes
41 #include <LightApp_Application.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_OverrideCursor.h>
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_Session.h>
46 #include <SalomeApp_IntSpinBox.h>
47 #include <SalomeApp_Tools.h>
48 #include <SVTK_ViewWindow.h>
55 #include <QVBoxLayout>
60 SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
61 : myToDeleteInitParamsHypo( false ),
62 myHypType( theHypType ),
68 SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
70 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
71 myInitParamsHypo->UnRegister();
74 void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
76 if ( !CORBA::is_nil( hyp ) ) {
77 if ( myToDeleteInitParamsHypo && !myInitParamsHypo->_is_nil() )
78 myInitParamsHypo->UnRegister();
79 CORBA::String_var hypName = hyp->GetName();
80 if ( hypType() == hypName.in() )
82 myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
83 myToDeleteInitParamsHypo = !SMESH::FindSObject( myInitParamsHypo );
88 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
89 const QString& theHypName,
90 QWidget* parent, QObject* obj, const QString& slot )
92 setInitParamsHypothesis( initParamsHyp );
93 create( false, theHypName, parent, obj, slot );
96 void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
97 const QString& theHypName,
100 const QString& slot )
104 // Create hypothesis/algorithm
106 SMESH::SMESH_Hypothesis_var anAlgo =
107 SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
108 anAlgo.out(); // avoid unused variable warning
111 SMESH::SMESH_Hypothesis_var aHypothesis =
112 SMESH::CreateHypothesis( hypType(), theHypName, false );
113 editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
117 void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
118 const QString& theHypName,
119 QWidget* theParent, QObject* obj, const QString& slot )
121 if( CORBA::is_nil( theHypothesis ) )
126 editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
129 void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
130 const QString& theHypName,
132 QObject* obj, const QString& slot )
134 myHypName = theHypName;
135 myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
138 SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
139 connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
140 connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
141 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), Dlg, SLOT( reject() ));
144 QFrame* fr = buildFrame();
147 Dlg->setCustomFrame( fr );
148 Dlg->setWindowTitle( caption() );
149 Dlg->setObjectName( theHypName );
150 Dlg->setHIcon( icon() );
151 if ( theHypName == HypothesesSet::getCommonHypoSetHypoType() )
152 Dlg->setType( tr( HypothesesSet::getCommonHypoSetHypoType()) );
154 Dlg->setType( type() );
156 Dlg->show(); // w/o this Dlg blocks selection
157 Dlg->resize( Dlg->minimumSizeHint() );
158 Dlg->exec(); // w/o this we cant wait until edition ends when applying a hypo-set
161 emit finished( QDialog::Accepted );
166 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
168 if( CORBA::is_nil( hypothesis() ) )
171 ListOfStdParams params;
172 if( !stdParams( params ) || params.isEmpty() )
175 QFrame* fr = new QFrame( 0 );
176 QVBoxLayout* lay = new QVBoxLayout( fr );
178 lay->setSpacing( 0 );
180 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
181 lay->addWidget( GroupC1 );
183 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
184 GroupC1Layout->setSpacing( SPACING );
185 GroupC1Layout->setMargin( MARGIN );
187 ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
188 for( int i = 0; anIt != aLast; anIt++, i++ )
190 QLabel* lab = anIt->hasName() ? new QLabel( anIt->myName, GroupC1 ) : NULL;
192 GroupC1Layout->addWidget( lab, i, 0 );
193 myParamLabels << lab;
195 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
197 switch( (*anIt).myValue.type() )
201 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
202 sb->setObjectName( (*anIt).myName );
203 attuneStdWidget( sb, i );
204 sb->setValue( (*anIt).myValue.toInt() );
205 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
209 case QVariant::Double:
211 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
212 sb->setObjectName( (*anIt).myName );
213 attuneStdWidget( sb, i );
214 sb->setValue( (*anIt).myValue.toDouble() );
215 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
219 case QVariant::String:
221 if((*anIt).isVariable) {
222 _PTR(Study) aStudy = SMESH::getStudy();
223 QString aVar = (*anIt).myValue.toString();
224 if(aStudy->IsInteger(aVar.toLatin1().constData())){
225 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
226 sb->setObjectName( (*anIt).myName );
227 attuneStdWidget( sb, i );
229 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
232 else if(aStudy->IsReal(aVar.toLatin1().constData())){
233 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
234 sb->setObjectName( (*anIt).myName );
235 attuneStdWidget( sb, i );
237 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
242 QLineEdit* le = new QLineEdit( GroupC1 );
243 le->setObjectName( (*anIt).myName );
244 attuneStdWidget( le, i );
245 le->setText( (*anIt).myValue.toString() );
246 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
253 } // switch( (*anIt).myValue.type() )
258 GroupC1Layout->addWidget( w, i, 1 );
260 GroupC1Layout->addWidget( w, i, 0, 1, 2 );
261 changeWidgets().append( w );
264 if ( QWidget* w = getHelperWidget() )
267 w->move( QPoint( 0, 0 ) );
274 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
276 valueChanged( (QWidget*) sender() );
279 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
283 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
285 bool res = result==QDialog::Accepted;
290 SUIT_OverrideCursor wc;
292 // No longer needed since NoteBook appears and "Value" OB field shows names of variable
293 // QString paramValues = storeParams();
294 // if ( !paramValues.isEmpty() ) {
295 // if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
296 // SMESH::SetValue( SHyp, paramValues );
299 catch ( const SALOME::SALOME_Exception& S_ex ) {
300 SalomeApp_Tools::QtCatchCorbaException( S_ex );
304 changeWidgets().clear();
306 if( myIsCreate && !res )
308 //remove just created hypothesis
309 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
310 _PTR(Study) aStudy = SMESH::getStudy();
311 if( aStudy && !aStudy->GetProperties()->IsLocked() )
313 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
314 aBuilder->RemoveObjectWithChildren( aHypSObject );
317 else if( !myIsCreate && res )
319 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
320 if( listSOmesh.size() > 0 )
321 for( size_t i = 0; i < listSOmesh.size(); i++ )
323 _PTR(SObject) submSO = listSOmesh[i];
324 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
325 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
326 if( !aSubMesh->_is_nil() )
327 aMesh = aSubMesh->GetFather();
328 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
329 SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
330 if( actor && actor->GetVisibility() )
334 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
335 myHypo->UnRegister();
336 myHypo = SMESH::SMESH_Hypothesis::_nil();
337 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
339 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
341 //delete myDlg; since WA_DeleteOnClose==true
343 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
346 emit finished( result );
349 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
354 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
358 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
359 for( ; anIt!=aLast; anIt++ )
361 item.myName = (*anIt)->objectName();
362 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
364 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
365 item.myValue = sb->value();
366 item.myText = sb->text();
367 params.append( item );
369 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
371 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
372 item.myValue = sb->value();
373 item.myText = sb->text();
374 params.append( item );
376 else if( (*anIt)->inherits( "QLineEdit" ) )
378 QLineEdit* line = ( QLineEdit* )( *anIt );
379 item.myValue = item.myText = line->text();
380 params.append( item );
382 else if ( getParamFromCustomWidget( item, *anIt ))
384 params.append( item );
392 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
394 SMESH::SMESH_Hypothesis_var h = hypothesis();
397 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
398 return QString( aVaribaleName.in() );
403 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
406 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
407 for( ; anIt!=aLast; anIt++ ) {
408 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
409 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
410 aResult.append(sb->text());
416 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
418 QString valueStr = "";
419 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
421 for ( ; param != aLast; param++ )
423 if ( valueStr.length() > len0 ) {
425 len0 = valueStr.length();
427 switch( (*param).myValue.type() )
430 valueStr += valueStr.number( (*param).myValue.toInt() );
432 case QVariant::Double:
433 valueStr += valueStr.number( (*param).myValue.toDouble() );
435 case QVariant::String:
436 valueStr += (*param).myValue.toString();
439 QVariant valCopy = (*param).myValue;
440 valueStr += valCopy.toString();
446 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
451 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
453 myShapeEntry = theEntry;
456 //================================================================================
458 * \brief Return hypothesis containing initial parameters
459 * \param strictly - if true, always return myInitParamsHypo,
460 * else, return myInitParamsHypo only in creation mode and if it
463 //================================================================================
465 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
468 return myInitParamsHypo;
469 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
471 return myInitParamsHypo;
474 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
476 return !CORBA::is_nil( myInitParamsHypo );
479 QString SMESHGUI_GenericHypothesisCreator::hypType() const
484 QString SMESHGUI_GenericHypothesisCreator::hypName() const
489 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
491 return myParamWidgets;
494 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
496 return myParamWidgets;
499 //================================================================================
501 * \brief Returns a QLabel of a specified parameter.
502 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
504 //================================================================================
506 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
510 if ( i < myParamLabels.size() )
511 return (QLabel*) myParamLabels.at(i);
515 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
520 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
525 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
529 QString SMESHGUI_GenericHypothesisCreator::caption() const
534 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
539 QString SMESHGUI_GenericHypothesisCreator::type() const
543 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
545 const int /*index*/) const
549 //================================================================================
551 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
553 //================================================================================
555 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
560 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
565 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
568 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
569 for( ; anIt!=aLast; anIt++ )
571 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
573 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
574 ok = sb->isValid( msg, true ) && ok;
576 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
578 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
579 ok = sb->isValid( msg, true ) && ok;
585 void SMESHGUI_GenericHypothesisCreator::onReject()
589 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
591 QString aHypType = hypType();
592 QString aHelpFileName = "";
593 if ( aHypType == "LocalLength" )
594 aHelpFileName = "1d_meshing_hypo.html#average-length-anchor";
595 else if ( aHypType == "MaxLength" )
596 aHelpFileName = "1d_meshing_hypo.html#max-length-anchor";
597 else if ( aHypType == "Arithmetic1D")
598 aHelpFileName = "1d_meshing_hypo.html#arithmetic-1d-anchor";
599 else if ( aHypType == "GeometricProgression")
600 aHelpFileName = "1d_meshing_hypo.html#geometric-1d-anchor";
601 else if ( aHypType == "FixedPoints1D")
602 aHelpFileName = "1d_meshing_hypo.html#fixed-points-1d-anchor";
603 else if ( aHypType == "MaxElementArea")
604 aHelpFileName = "2d_meshing_hypo.html#max-element-area-anchor";
605 else if ( aHypType == "MaxElementVolume")
606 aHelpFileName = "max_element_volume_hypo.html";
607 else if ( aHypType == "StartEndLength")
608 aHelpFileName = "1d_meshing_hypo.html#start-and-end-length-anchor";
609 else if ( aHypType == "Deflection1D")
610 aHelpFileName = "1d_meshing_hypo.html#deflection-1d-anchor";
611 else if ( aHypType == "Adaptive1D")
612 aHelpFileName = "1d_meshing_hypo.html#adaptive-1d-anchor";
613 else if ( aHypType == "AutomaticLength")
614 aHelpFileName = "1d_meshing_hypo.html#automatic-length-anchor";
615 else if ( aHypType == "NumberOfSegments")
616 aHelpFileName = "1d_meshing_hypo.html#number-of-segments-anchor";
617 else if ( aHypType == "ProjectionSource1D")
618 aHelpFileName = "projection_algos.html";
619 else if ( aHypType == "ProjectionSource2D")
620 aHelpFileName = "projection_algos.html";
621 else if ( aHypType == "ProjectionSource3D")
622 aHelpFileName = "projection_algos.html";
623 else if ( aHypType == "NumberOfLayers")
624 aHelpFileName = "radial_prism_algo.html";
625 else if ( aHypType == "NumberOfLayers2D")
626 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
627 else if ( aHypType == "LayerDistribution")
628 aHelpFileName = "radial_prism_algo.html";
629 else if ( aHypType == "LayerDistribution2D")
630 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
631 else if ( aHypType == "SegmentLengthAroundVertex")
632 aHelpFileName = "segments_around_vertex_algo.html";
633 else if ( aHypType == "QuadrangleParams")
634 aHelpFileName = "2d_meshing_hypo.html#hypo-quad-params-anchor";
635 else if ( aHypType == "ViscousLayers")
636 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
637 else if ( aHypType == "ViscousLayers2D")
638 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
639 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
640 aHelpFileName = "use_existing_algos.html";
641 return aHelpFileName;
644 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
645 : QtxDialog( parent, false, true ),
648 setAttribute(Qt::WA_DeleteOnClose, true);
649 // setMinimumSize( 300, height() );
650 // setFixedSize( 300, height() );
651 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
652 topLayout->setMargin( 0 );
653 topLayout->setSpacing( 0 );
655 QFrame* titFrame = new QFrame( mainFrame() );
656 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
657 titLay->setMargin( 0 );
658 titLay->setSpacing( SPACING );
660 myIconLabel = new QLabel( titFrame );
661 myIconLabel->setScaledContents( false );
662 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
663 myTypeLabel = new QLabel( titFrame );
665 myTypeLabel->setText( creator->hypType() );
667 titLay->addWidget( myIconLabel, 0 );
668 titLay->addWidget( myTypeLabel, 0 );
669 titLay->addStretch( 1 );
671 topLayout->addWidget( titFrame, 0 );
673 myHelpFileName = creator->helpPage();
675 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
678 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
683 void SMESHGUI_HypothesisDlg::showEvent(QShowEvent *event)
685 // resize( minimumSizeHint() );
688 QtxDialog::showEvent( event );
691 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
695 f->setParent( mainFrame() );
696 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
700 void SMESHGUI_HypothesisDlg::accept()
702 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
704 if ( myCreator && !myCreator->checkParams( msg ) )
706 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
707 if ( !msg.isEmpty() )
709 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
715 void SMESHGUI_HypothesisDlg::reject()
717 if ( myCreator ) myCreator->onReject();
721 void SMESHGUI_HypothesisDlg::onHelp()
723 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
725 QString name = "SMESH";
727 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
728 if( pluginName.isValid() ) {
729 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
730 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
731 if(!varValue.isEmpty())
732 name = pluginName.toString() + "PLUGIN";
735 app->onHelpContextModule(name, myHelpFileName);
740 platform = "winapplication";
742 platform = "application";
744 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
745 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
746 arg(app->resourceMgr()->stringValue("ExternalBrowser",
748 arg(myHelpFileName));
752 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
754 myIconLabel->setPixmap( p );
757 void SMESHGUI_HypothesisDlg::setType( const QString& t )
759 myTypeLabel->setText( t );
762 HypothesisData::HypothesisData( const QString& theTypeName,
763 const QString& thePluginName,
764 const QString& theServerLibName,
765 const QString& theClientLibName,
766 const QString& theLabel,
767 const QString& theIconId,
768 const QString& theContext,
769 const int theGroupID,
770 const int thePriority,
771 const QList<int>& theDim,
772 const bool theIsAuxOrNeedHyp,
773 const QStringList& theBasicHypos,
774 const QStringList& theOptionalHypos,
775 const QStringList& theInputTypes,
776 const QStringList& theOutputTypes,
777 const int theIsNeedGeometry,
778 const bool theSupportSub)
779 : TypeName( theTypeName ),
780 PluginName( thePluginName ),
781 ServerLibName( theServerLibName ),
782 ClientLibName( theClientLibName ),
785 Context( theContext ),
786 GroupID( theGroupID ),
787 Priority( thePriority ),
789 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
790 IsNeedGeometry( theIsNeedGeometry ),
791 IsSupportSubmeshes( theSupportSub ),
792 BasicHypos( theBasicHypos ),
793 OptionalHypos( theOptionalHypos ),
794 InputTypes( theInputTypes ),
795 OutputTypes( theOutputTypes )
799 // HypothesesSet::HypothesesSet( const QString& theSetName )
800 // : myHypoSetName( theSetName ),
801 // myIsAlgo( false ),
802 // myIsCustom( false )
806 HypothesesSet::HypothesesSet( const QString& theSetName,
807 bool useCommonSize, bool isQuadDominated,
808 const QStringList& mainHypos, const QStringList& mainAlgos,
809 const QStringList& altHypos, const QStringList& altAlgos,
810 const QStringList& intHypos, const QStringList& intAlgos )
811 : myUseCommonSize( useCommonSize ),
812 myQuadDominated( isQuadDominated ),
813 myHypoSetName( theSetName ),
814 myHypoList { mainHypos, altHypos, intHypos },
815 myAlgoList { mainAlgos, altAlgos, intAlgos },
820 for ( myHypType = MAIN; myHypType < NB_HYP_TYPES; SMESHUtils::Increment( myHypType ))
821 for ( int isAlgo = myIsAlgo = 0; isAlgo < 2; myIsAlgo = ++isAlgo )
823 QStringList& hyps = *list();
824 for ( int i = 0; i < hyps.count(); ++i )
825 hyps[ i ] = hyps[ i ].trimmed();
829 QStringList* HypothesesSet::list( bool is_algo, SetType setType) const
831 return const_cast<QStringList*>( &( is_algo ? myAlgoList[setType] : myHypoList[setType] ));
834 QStringList* HypothesesSet::list() const
836 return list( myIsAlgo, myHypType );
839 QString HypothesesSet::name() const
841 return myHypoSetName;
844 // void HypothesesSet::set( bool isAlgo, const QStringList& lst )
846 // *list(isAlgo) = lst;
849 // int HypothesesSet::count( bool isAlgo, SetType setType ) const
851 // return list(isAlgo,setType)->count();
854 // bool HypothesesSet::isAlgo() const
859 void HypothesesSet::init( bool isAlgo, SetType setType )
866 bool HypothesesSet::more() const
868 return myIndex < list()->count();
871 void HypothesesSet::next()
876 QString HypothesesSet::current() const
878 return list()->at(myIndex);
881 void HypothesesSet::setIsCustom( bool isCustom )
883 myIsCustom = isCustom;
886 bool HypothesesSet::getIsCustom() const
891 void HypothesesSet::setAlgoAvailable( SetType type, bool isAvailable )
893 if ( MAIN <= type && type < NB_HYP_TYPES )
894 myIsAlgoAvailable[ type ] = isAvailable;
897 bool HypothesesSet::getAlgoAvailable( SetType type )
900 if ( MAIN <= type && type < NB_HYP_TYPES )
901 isAva = myIsAlgoAvailable[ type ];
905 HypothesesSet::SetType HypothesesSet::getPreferredHypType()
907 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
908 int useAltHypos = !resMgr->booleanValue( "SMESH", "use-meshgems-hypo-sets", false );
909 return ( HypothesesSet::SetType ) useAltHypos;
912 int HypothesesSet::maxDim() const
914 HypothesesSet * thisSet = (HypothesesSet*) this;
916 for ( int setType = 0; setType < 2; ++setType )
917 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
919 for ( thisSet->init( isAlgo, SetType( setType )); thisSet->more(); thisSet->next() )
920 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
921 for ( int i = 0; i < hypData->Dim.count(); ++i )
922 dim = qMax( dim, hypData->Dim[i] );
927 const char* HypothesesSet::getCommonHypoSetHypoType()
929 return "AverageLengthForHypoSet";