1 // Copyright (C) 2007-2015 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_HypothesesUtils.cxx
25 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
28 #include "SMESHGUI_HypothesesUtils.h"
31 #include "SMESHGUI_Hypotheses.h"
32 #include "SMESHGUI_XmlHandler.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_GEOMGenUtils.h"
36 // SALOME GUI includes
37 #include <SUIT_Desktop.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_OverrideCursor.h>
40 #include <SUIT_ResourceMgr.h>
42 #include <SalomeApp_Study.h>
43 #include <SalomeApp_Tools.h>
45 // SALOME KERNEL includes
46 #include <utilities.h>
65 #define LibHandle HMODULE
66 #define LoadLib( name ) LoadLibrary( name )
67 #define GetProc GetProcAddress
68 #define UnLoadLib( handle ) FreeLibrary( handle );
70 #define LibHandle void*
71 #define LoadLib( name ) dlopen( name, RTLD_LAZY )
73 #define UnLoadLib( handle ) dlclose( handle );
77 static int MYDEBUG = 1;
79 static int MYDEBUG = 0;
84 typedef IMap<QString,HypothesisData*> THypothesisDataMap;
85 THypothesisDataMap myHypothesesMap;
86 THypothesisDataMap myAlgorithmsMap;
89 //typedef QMap<QString,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
90 //THypCreatorMap myHypCreatorMap;
92 QList<HypothesesSet*> myListOfHypothesesSets;
94 void processHypothesisStatus(const int theHypStatus,
95 SMESH::SMESH_Hypothesis_ptr theHyp,
96 const bool theIsAddition,
97 const char* theError = 0)
99 if (theHypStatus > SMESH::HYP_OK) {
101 QString aHypName ("NULL Hypothesis");
102 if (!CORBA::is_nil(theHyp)) {
103 _PTR(SObject) Shyp = SMESH::FindSObject(theHyp);
106 aHypName = Shyp->GetName().c_str();
110 CORBA::String_var hypType = theHyp->GetName();
111 aHypName = GetHypothesisData( hypType.in() )->Label;
116 bool isFatal = (theHypStatus >= SMESH::HYP_UNKNOWN_FATAL);
119 aMsg = (isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN");
121 aMsg = (isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN");
123 aMsg = QObject::tr(aMsg.toLatin1().data()).arg(aHypName);
125 if ( theError && theError[0] )
131 aMsg += QObject::tr(QString("SMESH_HYP_%1").arg(theHypStatus).toLatin1().data());
133 if ( theHypStatus == SMESH::HYP_HIDDEN_ALGO ) { // PAL18501
134 CORBA::String_var hypType = theHyp->GetName();
135 if ( HypothesisData* hd = GetHypothesisData( hypType.in() ))
136 aMsg = aMsg.arg( hd->Dim[0] );
139 SUIT_MessageBox::warning(SMESHGUI::desktop(),
140 QObject::tr("SMESH_WRN_WARNING"),
145 //================================================================================
147 * \brief Prepends dimension and appends '[custom]' to the name of hypothesis set
149 //================================================================================
151 static QString mangledHypoSetName(HypothesesSet* hypSet)
153 QString name = hypSet->name();
156 int dim = hypSet->maxDim();
158 name = QString("%1D: %2").arg(dim).arg(name);
161 if ( hypSet->getIsCustom() )
162 name = QString("%1 [custom]").arg(name);
167 //================================================================================
169 * \brief Removes dimension and '[custom]' from the name of hypothesis set
171 //================================================================================
173 static QString demangledHypoSetName(QString name)
175 name.remove(QRegExp("[0-3]D: "));
176 name.remove(" [custom]");
180 void InitAvailableHypotheses()
182 SUIT_OverrideCursor wc;
183 if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) {
185 SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr();
188 // Find name of a resource XML file ("SMESH_Meshers.xml");
190 char* cenv = getenv("SMESH_MeshersList");
192 HypsXml.sprintf("%s", cenv);
194 QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts);
195 if (HypsXmlList.count() == 0) {
196 SUIT_MessageBox::critical(SMESHGUI::desktop(),
197 QObject::tr("SMESH_WRN_WARNING"),
198 QObject::tr("MESHERS_FILE_NO_VARIABLE"));
201 // get full names of xml files from HypsXmlList
202 QStringList xmlFiles;
203 xmlFiles.append( QDir::home().filePath("CustomMeshers.xml")); // may be inexistent
204 for (int i = 0; i < HypsXmlList.count(); i++) {
205 QString HypsXml = HypsXmlList[ i ];
207 // Find full path to the resource XML file
208 QString xmlFile = resMgr->path("resources", "SMESH", HypsXml + ".xml");
209 if ( xmlFile.isEmpty() ) // try PLUGIN resources
210 xmlFile = resMgr->path("resources", HypsXml, HypsXml + ".xml");
211 if ( !xmlFile.isEmpty() )
212 xmlFiles.append( xmlFile );
216 QString aNoAccessFiles;
217 for (int i = 0; i < xmlFiles.count(); i++)
219 QString xmlFile = xmlFiles[ i ];
220 QFile file (xmlFile);
221 if (file.exists() && file.open(QIODevice::ReadOnly))
225 SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler();
228 QXmlInputSource source (&file);
229 QXmlSimpleReader reader;
230 reader.setContentHandler(aXmlHandler);
231 reader.setErrorHandler(aXmlHandler);
232 bool ok = reader.parse(source);
236 THypothesisDataMap::ConstIterator it1 = aXmlHandler->myHypothesesMap.begin();
238 for( ;it1 != aXmlHandler->myHypothesesMap.end(); it1++)
239 myHypothesesMap.insert( it1.key(), it1.value() );
241 it1 = aXmlHandler->myAlgorithmsMap.begin();
242 for( ;it1 != aXmlHandler->myAlgorithmsMap.end(); it1++)
243 myAlgorithmsMap.insert( it1.key(), it1.value() );
245 QList<HypothesesSet*>::iterator it;
246 for ( it = aXmlHandler->myListOfHypothesesSets.begin();
247 it != aXmlHandler->myListOfHypothesesSets.end();
250 (*it)->setIsCustom( i == 0 );
251 myListOfHypothesesSets.append( *it );
255 SUIT_MessageBox::critical(SMESHGUI::desktop(),
256 QObject::tr("INF_PARSE_ERROR"),
257 QObject::tr(aXmlHandler->errorProtocol().toLatin1().data()));
261 else if ( i > 0 ) { // 1st is ~/CustomMeshers.xml
262 if (aNoAccessFiles.isEmpty())
263 aNoAccessFiles = xmlFile;
265 aNoAccessFiles += ", " + xmlFile;
267 } // end loop on xmlFiles
270 if (!aNoAccessFiles.isEmpty()) {
271 QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
272 aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE");
274 SUIT_MessageBox::warning(SMESHGUI::desktop(),
275 QObject::tr("SMESH_WRN_WARNING"),
283 QStringList GetAvailableHypotheses( const bool isAlgo,
286 const bool isNeedGeometry,
287 const bool isSubMesh)
289 QStringList aHypList;
291 // Init list of available hypotheses, if needed
292 InitAvailableHypotheses();
293 bool checkGeometry = ( !isNeedGeometry && isAlgo );
294 const char* context = isSubMesh ? "LOCAL" : "GLOBAL";
295 // fill list of hypotheses/algorithms
296 THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap;
297 THypothesisDataMap::ConstIterator anIter;
298 for ( anIter = pMap.begin(); anIter != pMap.end(); anIter++ )
300 HypothesisData* aData = anIter.value();
301 if (( aData && !aData->Label.isEmpty() ) &&
302 ( theDim < 0 || aData->Dim.contains( theDim )) &&
303 ( isAlgo || aData->IsAuxOrNeedHyp == isAux ) &&
304 ( aData->Context == "ANY" || aData->Context == context ) &&
305 ( !checkGeometry || aData->IsNeedGeometry == isNeedGeometry ))
307 aHypList.append(anIter.key());
314 QStringList GetHypothesesSets(int maxDim)
316 QStringList aSetNameList;
318 // Init list of available hypotheses, if needed
319 InitAvailableHypotheses();
320 QList<HypothesesSet*>::iterator hypoSet;
321 for ( hypoSet = myListOfHypothesesSets.begin();
322 hypoSet != myListOfHypothesesSets.end();
324 HypothesesSet* aSet = *hypoSet;
325 if ( aSet && ( aSet->count( true ) || aSet->count( false )) &&
326 aSet->maxDim() <= maxDim)
328 aSetNameList.append( mangledHypoSetName( aSet ));
331 aSetNameList.removeDuplicates();
334 // reverse order of aSetNameList
335 QStringList reversedNames;
336 for ( int i = 0; i < aSetNameList.count(); ++i )
337 reversedNames.prepend( aSetNameList[i] );
339 return reversedNames;
342 HypothesesSet* GetHypothesesSet(const QString& theSetName)
344 QString name = demangledHypoSetName( theSetName );
345 QList<HypothesesSet*>::iterator hypoSet;
346 for ( hypoSet = myListOfHypothesesSets.begin();
347 hypoSet != myListOfHypothesesSets.end();
349 HypothesesSet* aSet = *hypoSet;
350 if ( aSet && aSet->name() == name )
356 HypothesisData* GetHypothesisData (const QString& aHypType)
358 HypothesisData* aHypData = 0;
360 // Init list of available hypotheses, if needed
361 InitAvailableHypotheses();
363 if (myHypothesesMap.contains(aHypType)) {
364 aHypData = myHypothesesMap[aHypType];
366 else if (myAlgorithmsMap.contains(aHypType)) {
367 aHypData = myAlgorithmsMap[aHypType];
372 bool IsAvailableHypothesis(const HypothesisData* algoData,
373 const QString& hypType,
379 if ( algoData->BasicHypos.contains( hypType ))
381 if ( algoData->OptionalHypos.contains( hypType)) {
388 bool IsCompatibleAlgorithm(const HypothesisData* algo1Data,
389 const HypothesisData* algo2Data)
391 if ( !algo1Data || !algo2Data )
393 const HypothesisData* algoIn = algo1Data, *algoMain = algo2Data;
394 if ( algoIn->Dim.first() > algoMain->Dim.first() ) {
395 algoIn = algo2Data; algoMain = algo1Data;
397 // look for any output type of algoIn between input types of algoMain
398 QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
399 for ( ; inElemType != algoIn->OutputTypes.end(); ++inElemType )
400 if ( algoMain->InputTypes.contains( *inElemType ))
405 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator(const QString& aHypType)
407 if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType.toLatin1().data());
409 SMESHGUI_GenericHypothesisCreator* aCreator = 0;
411 // check, if creator for this hypothesis type already exists
413 //if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) {
414 // aCreator = myHypCreatorMap[aHypType];
418 // 1. Init list of available hypotheses, if needed
419 InitAvailableHypotheses();
421 // 2. Get names of plugin libraries
422 HypothesisData* aHypData = GetHypothesisData(aHypType);
426 QString aClientLibName = aHypData->ClientLibName;
427 QString aServerLibName = aHypData->ServerLibName;
429 // 3. Load Client Plugin Library
431 // load plugin library
432 if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
433 LibHandle libHandle = LoadLib( aClientLibName.toLatin1().data() );
435 // report any error, if occured
438 const char* anError = "Can't load client meshers plugin library";
440 const char* anError = dlerror();
442 INFOS(anError); // always display this kind of error !
446 // get method, returning hypothesis creator
447 if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ...");
448 typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
450 GetHypothesisCreator procHandle =
451 (GetHypothesisCreator)GetProc(libHandle, "GetHypothesisCreator");
453 if(MYDEBUG) MESSAGE("bad hypothesis client plugin library");
454 UnLoadLib(libHandle);
457 // get hypothesis creator
458 if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << aHypType.toLatin1().data());
459 aCreator = procHandle( aHypType );
461 if(MYDEBUG) MESSAGE("no such a hypothesis in this plugin");
464 // map hypothesis creator to a hypothesis name
466 //myHypCreatorMap[aHypType] = aCreator;
468 //rnv : This dynamic property of the QObject stores the name of the plugin.
469 // It is used to obtain plugin root dir environment variable
470 // in the SMESHGUI_HypothesisDlg class. Plugin root dir environment
471 // variable is used to display documentation.
472 aCreator->setProperty(SMESH::Plugin_Name(),aHypData->PluginName);
477 catch (const SALOME::SALOME_Exception& S_ex) {
478 SalomeApp_Tools::QtCatchCorbaException(S_ex);
486 SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const QString& aHypType,
487 const QString& aHypName,
490 if(MYDEBUG) MESSAGE("Create " << aHypType.toLatin1().data() <<
491 " with name " << aHypName.toLatin1().data());
492 HypothesisData* aHypData = GetHypothesisData(aHypType);
493 QString aServLib = aHypData->ServerLibName;
495 SMESH::SMESH_Hypothesis_var aHypothesis;
496 aHypothesis = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType.toLatin1().data(),
497 aServLib.toLatin1().data());
498 if (!aHypothesis->_is_nil()) {
499 _PTR(SObject) aHypSObject = SMESH::FindSObject(aHypothesis.in());
501 if (!aHypName.isEmpty())
502 SMESH::SetName(aHypSObject, aHypName);
503 SMESHGUI::Modified();
504 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
505 return aHypothesis._retn();
508 } catch (const SALOME::SALOME_Exception & S_ex) {
509 SalomeApp_Tools::QtCatchCorbaException(S_ex);
512 return SMESH::SMESH_Hypothesis::_nil();
515 bool IsApplicable(const QString& aHypType,
516 GEOM::GEOM_Object_ptr theGeomObject,
517 const bool toCheckAll)
519 if ( getenv("NO_LIMIT_ALGO_BY_SHAPE")) // allow a workaround for a case if
520 return true; // IsApplicable() returns false due to a bug
522 HypothesisData* aHypData = GetHypothesisData(aHypType);
523 QString aServLib = aHypData->ServerLibName;
524 return SMESHGUI::GetSMESHGen()->IsApplicable( aHypType.toLatin1().data(),
525 aServLib.toLatin1().data(),
531 bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
533 if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh");
534 int res = SMESH::HYP_UNKNOWN_FATAL;
535 SUIT_OverrideCursor wc;
537 if (!aMesh->_is_nil()) {
538 _PTR(SObject) SM = SMESH::FindSObject(aMesh);
539 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM);
541 CORBA::String_var error;
542 res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out());
543 if (res < SMESH::HYP_UNKNOWN_FATAL) {
544 _PTR(SObject) aSH = SMESH::FindSObject(aHyp);
546 SMESH::ModifiedMesh(SM, false, aMesh->NbNodes()==0);
549 if (res > SMESH::HYP_OK) {
551 processHypothesisStatus(res, aHyp, true, error.in() );
555 catch(const SALOME::SALOME_Exception& S_ex) {
557 SalomeApp_Tools::QtCatchCorbaException(S_ex);
558 res = SMESH::HYP_UNKNOWN_FATAL;
561 return res < SMESH::HYP_UNKNOWN_FATAL;
565 bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
567 if(MYDEBUG) MESSAGE("SMESHGUI::AddHypothesisOnSubMesh() ");
568 int res = SMESH::HYP_UNKNOWN_FATAL;
569 SUIT_OverrideCursor wc;
571 if (!aSubMesh->_is_nil() && ! aHyp->_is_nil()) {
573 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
574 _PTR(SObject) SsubM = SMESH::FindSObject(aSubMesh);
575 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SsubM);
576 if (!aMesh->_is_nil() && SsubM && !aShapeObject->_is_nil())
578 CORBA::String_var error;
579 res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() );
580 if (res < SMESH::HYP_UNKNOWN_FATAL) {
581 _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
583 SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
585 if (res > SMESH::HYP_OK) {
587 processHypothesisStatus( res, aHyp, true, error.in() );
592 SCRUTE(aHyp->_is_nil());
593 SCRUTE(aMesh->_is_nil());
595 SCRUTE(aShapeObject->_is_nil());
598 catch(const SALOME::SALOME_Exception& S_ex) {
600 SalomeApp_Tools::QtCatchCorbaException(S_ex);
601 res = SMESH::HYP_UNKNOWN_FATAL;
605 SCRUTE(aSubMesh->_is_nil());
606 SCRUTE(aHyp->_is_nil());
608 return res < SMESH::HYP_UNKNOWN_FATAL;
611 bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject)
613 int res = SMESH::HYP_UNKNOWN_FATAL;
614 SUIT_OverrideCursor wc;
617 _PTR(Study) aStudy = GetActiveStudyDocument();
618 _PTR(SObject) aHypObj = aStudy->FindObjectID( IObject->getEntry() );
621 _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh( aHypObj );
622 _PTR(SObject) aRealHypo;
623 if( aHypObj->ReferencedObject( aRealHypo ) )
625 SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aRealHypo ) );
626 RemoveHypothesisOrAlgorithmOnMesh( MorSM, hypo );
630 SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aHypObj ) );
631 SObjectList meshList = GetMeshesUsingAlgoOrHypothesis( hypo );
632 for( size_t i = 0; i < meshList.size(); i++ )
633 RemoveHypothesisOrAlgorithmOnMesh( meshList[ i ], hypo );
637 catch(const SALOME::SALOME_Exception& S_ex)
640 SalomeApp_Tools::QtCatchCorbaException(S_ex);
641 res = SMESH::HYP_UNKNOWN_FATAL;
643 return res < SMESH::HYP_UNKNOWN_FATAL;
646 bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM,
647 SMESH::SMESH_Hypothesis_ptr anHyp)
649 int res = SMESH::HYP_UNKNOWN_FATAL;
650 SUIT_OverrideCursor wc;
654 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
655 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
656 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
658 if (!aSubMesh->_is_nil())
659 aMesh = aSubMesh->GetFather();
661 if (!aMesh->_is_nil()) {
662 if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) {
663 res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
664 if (res < SMESH::HYP_UNKNOWN_FATAL) {
665 _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
667 SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
671 else if(!aMesh->HasShapeToMesh()){
672 res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
673 if (res < SMESH::HYP_UNKNOWN_FATAL) {
674 _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
676 SMESH::ModifiedMesh(meshSO, false, aMesh->NbNodes()==0);
679 if (res > SMESH::HYP_OK) {
681 processHypothesisStatus(res, anHyp, false);
685 } catch(const SALOME::SALOME_Exception& S_ex) {
687 SalomeApp_Tools::QtCatchCorbaException(S_ex);
688 res = SMESH::HYP_UNKNOWN_FATAL;
691 return res < SMESH::HYP_UNKNOWN_FATAL;
694 SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp)
696 SObjectList listSOmesh;
697 listSOmesh.resize(0);
699 unsigned int index = 0;
700 if (!AlgoOrHyp->_is_nil()) {
701 _PTR(SObject) SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp);
704 SMESHGUI::activeStudy()->studyDS()->FindDependances(SO_Hypothesis);
706 if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO.size());
707 for (unsigned int i = 0; i < listSO.size(); i++) {
708 _PTR(SObject) SO = listSO[i];
710 _PTR(SObject) aFather = SO->GetFather();
712 _PTR(SObject) SOfatherFather = aFather->GetFather();
713 if (SOfatherFather) {
714 if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
716 listSOmesh.resize(index);
717 listSOmesh[index - 1] = SOfatherFather;
724 if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
728 #define CASE2MESSAGE(enum) case SMESH::enum: msg = QObject::tr( "STATE_" #enum ); break;
729 QString GetMessageOnAlgoStateErrors(const algo_error_array& errors)
731 QString resMsg; // PAL14861 = QObject::tr("SMESH_WRN_MISSING_PARAMETERS") + ":\n";
732 for ( size_t i = 0; i < errors.length(); ++i ) {
733 const SMESH::AlgoStateError & error = errors[ i ];
734 const bool hasAlgo = ( strlen( error.algoName ) != 0 );
737 msg = QObject::tr( "STATE_ALGO_MISSING" );
739 switch( error.state ) {
740 CASE2MESSAGE( HYP_MISSING );
741 CASE2MESSAGE( HYP_NOTCONFORM );
742 CASE2MESSAGE( HYP_BAD_PARAMETER );
743 CASE2MESSAGE( HYP_BAD_GEOMETRY );
746 // apply args to message:
749 msg = msg.arg( error.algoName.in() );
751 msg = msg.arg( error.algoDim );
753 msg = msg.arg( QObject::tr( error.isGlobalAlgo ? "GLOBAL_ALGO" : "LOCAL_ALGO" ));
754 // %4 - hypothesis dim == algoDim
755 msg = msg.arg( error.algoDim );
757 if ( i ) resMsg += ";\n";
762 } // end of namespace SMESH