1 // Copyright (C) 2007-2021 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
344 SMESH::UpdateActorsAfterUpdateStudy();// remove actors of removed groups (#16522)
345 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
348 emit finished( result );
351 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
356 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
360 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
361 for( ; anIt!=aLast; anIt++ )
363 item.myName = (*anIt)->objectName();
364 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
366 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
367 item.myValue = sb->value();
368 item.myText = sb->text();
369 params.append( item );
371 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
373 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
374 item.myValue = sb->value();
375 item.myText = sb->text();
376 params.append( item );
378 else if( (*anIt)->inherits( "QLineEdit" ) )
380 QLineEdit* line = ( QLineEdit* )( *anIt );
381 item.myValue = item.myText = line->text();
382 params.append( item );
384 else if ( getParamFromCustomWidget( item, *anIt ))
386 params.append( item );
394 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
396 SMESH::SMESH_Hypothesis_var h = hypothesis();
399 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
400 return QString( aVaribaleName.in() );
405 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
408 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
409 for( ; anIt!=aLast; anIt++ ) {
410 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
411 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
412 aResult.append(sb->text());
418 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
420 QString valueStr = "";
421 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
423 for ( ; param != aLast; param++ )
425 if ( valueStr.length() > len0 ) {
427 len0 = valueStr.length();
429 switch( (*param).myValue.type() )
432 valueStr += valueStr.number( (*param).myValue.toInt() );
434 case QVariant::Double:
435 valueStr += valueStr.number( (*param).myValue.toDouble() );
437 case QVariant::String:
438 valueStr += (*param).myValue.toString();
441 QVariant valCopy = (*param).myValue;
442 valueStr += valCopy.toString();
448 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
453 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
455 myShapeEntry = theEntry;
458 //================================================================================
460 * \brief Return hypothesis containing initial parameters
461 * \param strictly - if true, always return myInitParamsHypo,
462 * else, return myInitParamsHypo only in creation mode and if it
465 //================================================================================
467 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
470 return myInitParamsHypo;
471 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
473 return myInitParamsHypo;
476 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
478 return !CORBA::is_nil( myInitParamsHypo );
481 QString SMESHGUI_GenericHypothesisCreator::hypType() const
486 QString SMESHGUI_GenericHypothesisCreator::hypName() const
491 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
493 return myParamWidgets;
496 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
498 return myParamWidgets;
501 //================================================================================
503 * \brief Returns a QLabel of a specified parameter.
504 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
506 //================================================================================
508 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
512 if ( i < myParamLabels.size() )
513 return (QLabel*) myParamLabels.at(i);
517 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
522 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
527 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
531 QString SMESHGUI_GenericHypothesisCreator::caption() const
536 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
541 QString SMESHGUI_GenericHypothesisCreator::type() const
545 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
547 const int /*index*/) const
551 //================================================================================
553 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
555 //================================================================================
557 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
562 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
567 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
570 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
571 for( ; anIt!=aLast; anIt++ )
573 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
575 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
576 ok = sb->isValid( msg, true ) && ok;
578 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
580 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
581 ok = sb->isValid( msg, true ) && ok;
587 void SMESHGUI_GenericHypothesisCreator::onReject()
591 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
593 QString aHypType = hypType();
594 QString aHelpFileName = "";
595 if ( aHypType == "LocalLength" )
596 aHelpFileName = "1d_meshing_hypo.html#average-length-anchor";
597 else if ( aHypType == "MaxLength" )
598 aHelpFileName = "1d_meshing_hypo.html#max-length-anchor";
599 else if ( aHypType == "Arithmetic1D")
600 aHelpFileName = "1d_meshing_hypo.html#arithmetic-1d-anchor";
601 else if ( aHypType == "GeometricProgression")
602 aHelpFileName = "1d_meshing_hypo.html#geometric-1d-anchor";
603 else if ( aHypType == "FixedPoints1D")
604 aHelpFileName = "1d_meshing_hypo.html#fixed-points-1d-anchor";
605 else if ( aHypType == "MaxElementArea")
606 aHelpFileName = "2d_meshing_hypo.html#max-element-area-anchor";
607 else if ( aHypType == "MaxElementVolume")
608 aHelpFileName = "3d_meshing_hypo.html#max-element-volume-hypothesis";
609 else if ( aHypType == "StartEndLength")
610 aHelpFileName = "1d_meshing_hypo.html#start-and-end-length-anchor";
611 else if ( aHypType == "Deflection1D")
612 aHelpFileName = "1d_meshing_hypo.html#deflection-1d-anchor";
613 else if ( aHypType == "Adaptive1D")
614 aHelpFileName = "1d_meshing_hypo.html#adaptive-1d-anchor";
615 else if ( aHypType == "AutomaticLength")
616 aHelpFileName = "1d_meshing_hypo.html#automatic-length-anchor";
617 else if ( aHypType == "NumberOfSegments")
618 aHelpFileName = "1d_meshing_hypo.html#number-of-segments-anchor";
619 else if ( aHypType == "ProjectionSource1D")
620 aHelpFileName = "projection_algos.html";
621 else if ( aHypType == "ProjectionSource2D")
622 aHelpFileName = "projection_algos.html";
623 else if ( aHypType == "ProjectionSource3D")
624 aHelpFileName = "projection_algos.html";
625 else if ( aHypType == "NumberOfLayers")
626 aHelpFileName = "radial_prism_algo.html";
627 else if ( aHypType == "NumberOfLayers2D")
628 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
629 else if ( aHypType == "LayerDistribution")
630 aHelpFileName = "radial_prism_algo.html";
631 else if ( aHypType == "LayerDistribution2D")
632 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
633 else if ( aHypType == "SegmentLengthAroundVertex")
634 aHelpFileName = "segments_around_vertex_algo.html";
635 else if ( aHypType == "QuadrangleParams")
636 aHelpFileName = "2d_meshing_hypo.html#hypo-quad-params-anchor";
637 else if ( aHypType == "ViscousLayers")
638 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
639 else if ( aHypType == "ViscousLayers2D")
640 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
641 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
642 aHelpFileName = "use_existing_algos.html";
643 return aHelpFileName;
646 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
647 : QtxDialog( parent, false, true ),
650 setAttribute(Qt::WA_DeleteOnClose, true);
651 // setMinimumSize( 300, height() );
652 // setFixedSize( 300, height() );
653 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
654 topLayout->setMargin( 0 );
655 topLayout->setSpacing( 0 );
657 QFrame* titFrame = new QFrame( mainFrame() );
658 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
659 titLay->setMargin( 0 );
660 titLay->setSpacing( SPACING );
662 myIconLabel = new QLabel( titFrame );
663 myIconLabel->setScaledContents( false );
664 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
665 myTypeLabel = new QLabel( titFrame );
667 myTypeLabel->setText( creator->hypType() );
669 titLay->addWidget( myIconLabel, 0 );
670 titLay->addWidget( myTypeLabel, 0 );
671 titLay->addStretch( 1 );
673 topLayout->addWidget( titFrame, 0 );
675 myHelpFileName = creator->helpPage();
677 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
680 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
685 void SMESHGUI_HypothesisDlg::showEvent(QShowEvent *event)
687 // resize( minimumSizeHint() );
690 QtxDialog::showEvent( event );
693 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
697 f->setParent( mainFrame() );
698 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
702 void SMESHGUI_HypothesisDlg::accept()
704 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
706 if ( myCreator && !myCreator->checkParams( msg ) )
708 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
709 if ( !msg.isEmpty() )
711 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
717 void SMESHGUI_HypothesisDlg::reject()
719 if ( myCreator ) myCreator->onReject();
723 void SMESHGUI_HypothesisDlg::onHelp()
725 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
727 QString name = "SMESH";
729 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
730 if( pluginName.isValid() ) {
731 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
732 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
733 if(!varValue.isEmpty())
734 name = pluginName.toString() + "PLUGIN";
737 app->onHelpContextModule(name, myHelpFileName);
742 platform = "winapplication";
744 platform = "application";
746 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
747 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
748 arg(app->resourceMgr()->stringValue("ExternalBrowser",
750 arg(myHelpFileName));
754 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
756 myIconLabel->setPixmap( p );
759 void SMESHGUI_HypothesisDlg::setType( const QString& t )
761 myTypeLabel->setText( t );
764 HypothesisData::HypothesisData( const QString& theTypeName,
765 const QString& thePluginName,
766 const QString& theServerLibName,
767 const QString& theClientLibName,
768 const QString& theLabel,
769 const QString& theIconId,
770 const QString& theContext,
771 const int theGroupID,
772 const int thePriority,
773 const QList<int>& theDim,
774 const bool theIsAuxOrNeedHyp,
775 const QStringList& theBasicHypos,
776 const QStringList& theOptionalHypos,
777 const QStringList& theInputTypes,
778 const QStringList& theOutputTypes,
779 const int theIsNeedGeometry,
780 const bool theSupportSub)
781 : TypeName( theTypeName ),
782 PluginName( thePluginName ),
783 ServerLibName( theServerLibName ),
784 ClientLibName( theClientLibName ),
787 Context( theContext ),
788 GroupID( theGroupID ),
789 Priority( thePriority ),
791 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
792 IsNeedGeometry( theIsNeedGeometry ),
793 IsSupportSubmeshes( theSupportSub ),
794 BasicHypos( theBasicHypos ),
795 OptionalHypos( theOptionalHypos ),
796 InputTypes( theInputTypes ),
797 OutputTypes( theOutputTypes )
801 // HypothesesSet::HypothesesSet( const QString& theSetName )
802 // : myHypoSetName( theSetName ),
803 // myIsAlgo( false ),
804 // myIsCustom( false )
808 HypothesesSet::HypothesesSet( const QString& theSetName,
809 bool useCommonSize, bool isQuadDominated,
810 const QStringList& mainHypos, const QStringList& mainAlgos,
811 const QStringList& altHypos, const QStringList& altAlgos,
812 const QStringList& intHypos, const QStringList& intAlgos )
813 : myUseCommonSize( useCommonSize ),
814 myQuadDominated( isQuadDominated ),
815 myHypoSetName( theSetName ),
816 myHypoList { mainHypos, altHypos, intHypos },
817 myAlgoList { mainAlgos, altAlgos, intAlgos },
822 for ( myHypType = MAIN; myHypType < NB_HYP_TYPES; SMESHUtils::Increment( myHypType ))
823 for ( int isAlgo = myIsAlgo = 0; isAlgo < 2; myIsAlgo = ++isAlgo )
825 QStringList& hyps = *list();
826 for ( int i = 0; i < hyps.count(); ++i )
827 hyps[ i ] = hyps[ i ].trimmed();
831 QStringList* HypothesesSet::list( bool is_algo, SetType setType) const
833 return const_cast<QStringList*>( &( is_algo ? myAlgoList[setType] : myHypoList[setType] ));
836 QStringList* HypothesesSet::list() const
838 return list( myIsAlgo, myHypType );
841 QString HypothesesSet::name() const
843 return myHypoSetName;
846 // void HypothesesSet::set( bool isAlgo, const QStringList& lst )
848 // *list(isAlgo) = lst;
851 // int HypothesesSet::count( bool isAlgo, SetType setType ) const
853 // return list(isAlgo,setType)->count();
856 // bool HypothesesSet::isAlgo() const
861 void HypothesesSet::init( bool isAlgo, SetType setType )
868 bool HypothesesSet::more() const
870 return myIndex < list()->count();
873 void HypothesesSet::next()
878 QString HypothesesSet::current() const
880 return list()->at(myIndex);
883 void HypothesesSet::setIsCustom( bool isCustom )
885 myIsCustom = isCustom;
888 bool HypothesesSet::getIsCustom() const
893 void HypothesesSet::setAlgoAvailable( SetType type, bool isAvailable )
895 if ( MAIN <= type && type < NB_HYP_TYPES )
896 myIsAlgoAvailable[ type ] = isAvailable;
899 bool HypothesesSet::getAlgoAvailable( SetType type )
902 if ( MAIN <= type && type < NB_HYP_TYPES )
903 isAva = myIsAlgoAvailable[ type ];
907 HypothesesSet::SetType HypothesesSet::getPreferredHypType()
909 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
910 int useAltHypos = !resMgr->booleanValue( "SMESH", "use-meshgems-hypo-sets", false );
911 return ( HypothesesSet::SetType ) useAltHypos;
914 int HypothesesSet::maxDim() const
916 HypothesesSet * thisSet = (HypothesesSet*) this;
918 for ( int setType = 0; setType < 2; ++setType )
919 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
921 for ( thisSet->init( isAlgo, SetType( setType )); thisSet->more(); thisSet->next() )
922 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
923 for ( int i = 0; i < hypData->Dim.count(); ++i )
924 dim = qMax( dim, hypData->Dim[i] );
929 const char* HypothesesSet::getCommonHypoSetHypoType()
931 return "AverageLengthForHypoSet";