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 = new QLabel( (*anIt).myName, GroupC1 );
191 GroupC1Layout->addWidget( lab, i, 0 );
192 myParamLabels << lab;
194 QWidget* w = getCustomWidget( *anIt, GroupC1, i );
196 switch( (*anIt).myValue.type() )
200 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
201 sb->setObjectName( (*anIt).myName );
202 attuneStdWidget( sb, i );
203 sb->setValue( (*anIt).myValue.toInt() );
204 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
208 case QVariant::Double:
210 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
211 sb->setObjectName( (*anIt).myName );
212 attuneStdWidget( sb, i );
213 sb->setValue( (*anIt).myValue.toDouble() );
214 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
218 case QVariant::String:
220 if((*anIt).isVariable) {
221 _PTR(Study) aStudy = SMESH::getStudy();
222 QString aVar = (*anIt).myValue.toString();
223 if(aStudy->IsInteger(aVar.toLatin1().constData())){
224 SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
225 sb->setObjectName( (*anIt).myName );
226 attuneStdWidget( sb, i );
228 connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
231 else if(aStudy->IsReal(aVar.toLatin1().constData())){
232 SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
233 sb->setObjectName( (*anIt).myName );
234 attuneStdWidget( sb, i );
236 connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
241 QLineEdit* le = new QLineEdit( GroupC1 );
242 le->setObjectName( (*anIt).myName );
243 attuneStdWidget( le, i );
244 le->setText( (*anIt).myValue.toString() );
245 connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
252 } // switch( (*anIt).myValue.type() )
256 GroupC1Layout->addWidget( w, i, 1 );
257 changeWidgets().append( w );
260 if ( QWidget* w = getHelperWidget() )
263 w->move( QPoint( 0, 0 ) );
270 void SMESHGUI_GenericHypothesisCreator::onValueChanged()
272 valueChanged( (QWidget*) sender() );
275 void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
279 void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
281 bool res = result==QDialog::Accepted;
286 SUIT_OverrideCursor wc;
288 // No longer needed since NoteBook appears and "Value" OB field shows names of variable
289 // QString paramValues = storeParams();
290 // if ( !paramValues.isEmpty() ) {
291 // if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
292 // SMESH::SetValue( SHyp, paramValues );
295 catch ( const SALOME::SALOME_Exception& S_ex ) {
296 SalomeApp_Tools::QtCatchCorbaException( S_ex );
300 changeWidgets().clear();
302 if( myIsCreate && !res )
304 //remove just created hypothesis
305 _PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
306 _PTR(Study) aStudy = SMESH::getStudy();
307 if( aStudy && !aStudy->GetProperties()->IsLocked() )
309 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
310 aBuilder->RemoveObjectWithChildren( aHypSObject );
313 else if( !myIsCreate && res )
315 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
316 if( listSOmesh.size() > 0 )
317 for( size_t i = 0; i < listSOmesh.size(); i++ )
319 _PTR(SObject) submSO = listSOmesh[i];
320 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
321 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
322 if( !aSubMesh->_is_nil() )
323 aMesh = aSubMesh->GetFather();
324 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
325 SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
326 if( actor && actor->GetVisibility() )
330 SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
331 myHypo->UnRegister();
332 myHypo = SMESH::SMESH_Hypothesis::_nil();
333 myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
335 disconnect( myDlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
337 //delete myDlg; since WA_DeleteOnClose==true
339 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
342 emit finished( result );
345 bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
350 bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
354 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
355 for( ; anIt!=aLast; anIt++ )
357 item.myName = (*anIt)->objectName();
358 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
360 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
361 item.myValue = sb->value();
362 item.myText = sb->text();
363 params.append( item );
365 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
367 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
368 item.myValue = sb->value();
369 item.myText = sb->text();
370 params.append( item );
372 else if( (*anIt)->inherits( "QLineEdit" ) )
374 QLineEdit* line = ( QLineEdit* )( *anIt );
375 item.myValue = item.myText = line->text();
376 params.append( item );
378 else if ( getParamFromCustomWidget( item, *anIt ))
380 params.append( item );
388 QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
390 SMESH::SMESH_Hypothesis_var h = hypothesis();
393 CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
394 return QString( aVaribaleName.in() );
399 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
402 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
403 for( ; anIt!=aLast; anIt++ ) {
404 if( (*anIt)->inherits( "QAbstractSpinBox" ) ) {
405 QAbstractSpinBox* sb = ( QAbstractSpinBox* )( *anIt );
406 aResult.append(sb->text());
412 QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
414 QString valueStr = "";
415 ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
417 for ( ; param != aLast; param++ )
419 if ( valueStr.length() > len0 ) {
421 len0 = valueStr.length();
423 switch( (*param).myValue.type() )
426 valueStr += valueStr.number( (*param).myValue.toInt() );
428 case QVariant::Double:
429 valueStr += valueStr.number( (*param).myValue.toDouble() );
431 case QVariant::String:
432 valueStr += (*param).myValue.toString();
435 QVariant valCopy = (*param).myValue;
436 valueStr += valCopy.toString();
442 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
447 void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry )
449 myShapeEntry = theEntry;
452 //================================================================================
454 * \brief Return hypothesis containing initial parameters
455 * \param strictly - if true, always return myInitParamsHypo,
456 * else, return myInitParamsHypo only in creation mode and if it
459 //================================================================================
461 SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
464 return myInitParamsHypo;
465 if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
467 return myInitParamsHypo;
470 bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
472 return !CORBA::is_nil( myInitParamsHypo );
475 QString SMESHGUI_GenericHypothesisCreator::hypType() const
480 QString SMESHGUI_GenericHypothesisCreator::hypName() const
485 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
487 return myParamWidgets;
490 SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
492 return myParamWidgets;
495 //================================================================================
497 * \brief Returns a QLabel of a specified parameter.
498 * If isCreation(), the 1st label (supposed to be "Name") is not countered.
500 //================================================================================
502 QLabel* SMESHGUI_GenericHypothesisCreator::getLabel(int i) const
506 if ( i < myParamLabels.size() )
507 return (QLabel*) myParamLabels.at(i);
511 QtxDialog* SMESHGUI_GenericHypothesisCreator:: dlg() const
516 bool SMESHGUI_GenericHypothesisCreator::isCreation() const
521 void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
525 QString SMESHGUI_GenericHypothesisCreator::caption() const
530 QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
535 QString SMESHGUI_GenericHypothesisCreator::type() const
539 QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
541 const int /*index*/) const
545 //================================================================================
547 * \brief Returns a widget representing not a hypothesis parameter but some helper widget
549 //================================================================================
551 QWidget* SMESHGUI_GenericHypothesisCreator::getHelperWidget() const
556 bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWidget* ) const
561 bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const
564 ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
565 for( ; anIt!=aLast; anIt++ )
567 if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
569 SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
570 ok = sb->isValid( msg, true ) && ok;
572 else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
574 SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
575 ok = sb->isValid( msg, true ) && ok;
581 void SMESHGUI_GenericHypothesisCreator::onReject()
585 QString SMESHGUI_GenericHypothesisCreator::helpPage() const
587 QString aHypType = hypType();
588 QString aHelpFileName = "";
589 if ( aHypType == "LocalLength" )
590 aHelpFileName = "1d_meshing_hypo.html#average-length-anchor";
591 else if ( aHypType == "MaxLength" )
592 aHelpFileName = "1d_meshing_hypo.html#max-length-anchor";
593 else if ( aHypType == "Arithmetic1D")
594 aHelpFileName = "1d_meshing_hypo.html#arithmetic-1d-anchor";
595 else if ( aHypType == "GeometricProgression")
596 aHelpFileName = "1d_meshing_hypo.html#geometric-1d-anchor";
597 else if ( aHypType == "FixedPoints1D")
598 aHelpFileName = "1d_meshing_hypo.html#fixed-points-1d-anchor";
599 else if ( aHypType == "MaxElementArea")
600 aHelpFileName = "2d_meshing_hypo.html#max-element-area-anchor";
601 else if ( aHypType == "MaxElementVolume")
602 aHelpFileName = "max_element_volume_hypo.html";
603 else if ( aHypType == "StartEndLength")
604 aHelpFileName = "1d_meshing_hypo.html#start-and-end-length-anchor";
605 else if ( aHypType == "Deflection1D")
606 aHelpFileName = "1d_meshing_hypo.html#deflection-1d-anchor";
607 else if ( aHypType == "Adaptive1D")
608 aHelpFileName = "1d_meshing_hypo.html#adaptive-1d-anchor";
609 else if ( aHypType == "AutomaticLength")
610 aHelpFileName = "1d_meshing_hypo.html#automatic-length-anchor";
611 else if ( aHypType == "NumberOfSegments")
612 aHelpFileName = "1d_meshing_hypo.html#number-of-segments-anchor";
613 else if ( aHypType == "ProjectionSource1D")
614 aHelpFileName = "projection_algos.html";
615 else if ( aHypType == "ProjectionSource2D")
616 aHelpFileName = "projection_algos.html";
617 else if ( aHypType == "ProjectionSource3D")
618 aHelpFileName = "projection_algos.html";
619 else if ( aHypType == "NumberOfLayers")
620 aHelpFileName = "radial_prism_algo.html";
621 else if ( aHypType == "NumberOfLayers2D")
622 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
623 else if ( aHypType == "LayerDistribution")
624 aHelpFileName = "radial_prism_algo.html";
625 else if ( aHypType == "LayerDistribution2D")
626 aHelpFileName = "radial_quadrangle_1D2D_algo.html";
627 else if ( aHypType == "SegmentLengthAroundVertex")
628 aHelpFileName = "segments_around_vertex_algo.html";
629 else if ( aHypType == "QuadrangleParams")
630 aHelpFileName = "2d_meshing_hypo.html#hypo-quad-params-anchor";
631 else if ( aHypType == "ViscousLayers")
632 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
633 else if ( aHypType == "ViscousLayers2D")
634 aHelpFileName = "additional_hypo.html#viscous-layers-anchor";
635 else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
636 aHelpFileName = "use_existing_algos.html";
637 return aHelpFileName;
640 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
641 : QtxDialog( parent, false, true ),
644 setAttribute(Qt::WA_DeleteOnClose, true);
645 // setMinimumSize( 300, height() );
646 // setFixedSize( 300, height() );
647 QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
648 topLayout->setMargin( 0 );
649 topLayout->setSpacing( 0 );
651 QFrame* titFrame = new QFrame( mainFrame() );
652 QHBoxLayout* titLay = new QHBoxLayout( titFrame );
653 titLay->setMargin( 0 );
654 titLay->setSpacing( SPACING );
656 myIconLabel = new QLabel( titFrame );
657 myIconLabel->setScaledContents( false );
658 myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
659 myTypeLabel = new QLabel( titFrame );
661 myTypeLabel->setText( creator->hypType() );
663 titLay->addWidget( myIconLabel, 0 );
664 titLay->addWidget( myTypeLabel, 0 );
665 titLay->addStretch( 1 );
667 topLayout->addWidget( titFrame, 0 );
669 myHelpFileName = creator->helpPage();
671 connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
674 SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
679 void SMESHGUI_HypothesisDlg::showEvent(QShowEvent *event)
681 // resize( minimumSizeHint() );
684 QtxDialog::showEvent( event );
687 void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
691 f->setParent( mainFrame() );
692 qobject_cast<QVBoxLayout*>( mainFrame()->layout() )->insertWidget( 1, f, 1 );
696 void SMESHGUI_HypothesisDlg::accept()
698 SUIT_OverrideCursor wc; // some creators temporary set params to a hyp which can be long
700 if ( myCreator && !myCreator->checkParams( msg ) )
702 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
703 if ( !msg.isEmpty() )
705 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
711 void SMESHGUI_HypothesisDlg::reject()
713 if ( myCreator ) myCreator->onReject();
717 void SMESHGUI_HypothesisDlg::onHelp()
719 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
721 QString name = "SMESH";
723 QVariant pluginName = myCreator->property( SMESH::Plugin_Name() );
724 if( pluginName.isValid() ) {
725 QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
726 QString varValue = QString( getenv(rootDir.toLatin1().constData()));
727 if(!varValue.isEmpty())
728 name = pluginName.toString() + "PLUGIN";
731 app->onHelpContextModule(name, myHelpFileName);
736 platform = "winapplication";
738 platform = "application";
740 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
741 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
742 arg(app->resourceMgr()->stringValue("ExternalBrowser",
744 arg(myHelpFileName));
748 void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
750 myIconLabel->setPixmap( p );
753 void SMESHGUI_HypothesisDlg::setType( const QString& t )
755 myTypeLabel->setText( t );
758 HypothesisData::HypothesisData( const QString& theTypeName,
759 const QString& thePluginName,
760 const QString& theServerLibName,
761 const QString& theClientLibName,
762 const QString& theLabel,
763 const QString& theIconId,
764 const QString& theContext,
765 const int theGroupID,
766 const int thePriority,
767 const QList<int>& theDim,
768 const bool theIsAuxOrNeedHyp,
769 const QStringList& theBasicHypos,
770 const QStringList& theOptionalHypos,
771 const QStringList& theInputTypes,
772 const QStringList& theOutputTypes,
773 const int theIsNeedGeometry,
774 const bool theSupportSub)
775 : TypeName( theTypeName ),
776 PluginName( thePluginName ),
777 ServerLibName( theServerLibName ),
778 ClientLibName( theClientLibName ),
781 Context( theContext ),
782 GroupID( theGroupID ),
783 Priority( thePriority ),
785 IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
786 IsNeedGeometry( theIsNeedGeometry ),
787 IsSupportSubmeshes( theSupportSub ),
788 BasicHypos( theBasicHypos ),
789 OptionalHypos( theOptionalHypos ),
790 InputTypes( theInputTypes ),
791 OutputTypes( theOutputTypes )
795 // HypothesesSet::HypothesesSet( const QString& theSetName )
796 // : myHypoSetName( theSetName ),
797 // myIsAlgo( false ),
798 // myIsCustom( false )
802 HypothesesSet::HypothesesSet( const QString& theSetName,
803 bool useCommonSize, bool isQuadDominated,
804 const QStringList& mainHypos, const QStringList& mainAlgos,
805 const QStringList& altHypos, const QStringList& altAlgos,
806 const QStringList& intHypos, const QStringList& intAlgos )
807 : myUseCommonSize( useCommonSize ),
808 myQuadDominated( isQuadDominated ),
809 myHypoSetName( theSetName ),
810 myHypoList({ mainHypos, altHypos, intHypos }),
811 myAlgoList({ mainAlgos, altAlgos, intAlgos }),
816 for ( myHypType = MAIN; myHypType < NB_HYP_TYPES; SMESHUtils::Increment( myHypType ))
817 for ( int isAlgo = myIsAlgo = 0; isAlgo < 2; myIsAlgo = ++isAlgo )
819 QStringList& hyps = *list();
820 for ( int i = 0; i < hyps.count(); ++i )
821 hyps[ i ] = hyps[ i ].trimmed();
825 QStringList* HypothesesSet::list( bool is_algo, SetType setType) const
827 return const_cast<QStringList*>( &( is_algo ? myAlgoList[setType] : myHypoList[setType] ));
830 QStringList* HypothesesSet::list() const
832 return list( myIsAlgo, myHypType );
835 QString HypothesesSet::name() const
837 return myHypoSetName;
840 // void HypothesesSet::set( bool isAlgo, const QStringList& lst )
842 // *list(isAlgo) = lst;
845 // int HypothesesSet::count( bool isAlgo, SetType setType ) const
847 // return list(isAlgo,setType)->count();
850 // bool HypothesesSet::isAlgo() const
855 void HypothesesSet::init( bool isAlgo, SetType setType )
862 bool HypothesesSet::more() const
864 return myIndex < list()->count();
867 void HypothesesSet::next()
872 QString HypothesesSet::current() const
874 return list()->at(myIndex);
877 void HypothesesSet::setIsCustom( bool isCustom )
879 myIsCustom = isCustom;
882 bool HypothesesSet::getIsCustom() const
887 void HypothesesSet::setAlgoAvailable( SetType type, bool isAvailable )
889 if ( MAIN <= type && type < NB_HYP_TYPES )
890 myIsAlgoAvailable[ type ] = isAvailable;
893 bool HypothesesSet::getAlgoAvailable( SetType type )
896 if ( MAIN <= type && type < NB_HYP_TYPES )
897 isAva = myIsAlgoAvailable[ type ];
901 HypothesesSet::SetType HypothesesSet::getPreferredHypType()
903 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
904 int useAltHypos = !resMgr->booleanValue( "SMESH", "use-meshgems-hypo-sets", false );
905 return ( HypothesesSet::SetType ) useAltHypos;
908 int HypothesesSet::maxDim() const
910 HypothesesSet * thisSet = (HypothesesSet*) this;
912 for ( int setType = 0; setType < 2; ++setType )
913 for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
915 for ( thisSet->init( isAlgo, SetType( setType )); thisSet->more(); thisSet->next() )
916 if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
917 for ( int i = 0; i < hypData->Dim.count(); ++i )
918 dim = qMax( dim, hypData->Dim[i] );
923 const char* HypothesesSet::getCommonHypoSetHypoType()
925 return "AverageLengthForHypoSet";