X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESHGUI%2FSMESHGUI_HypothesesUtils.cxx;h=5f3500230d4617ab7c32b62fecc2828bdc845f3c;hb=62c4337c5becb0add8bff676b465f70cc5f4e513;hp=35b8a567d54e9e93932a3b92eb82fbc2a8e6ac14;hpb=b75d24976cdad444043f03d73f056c666055c984;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx index 35b8a567d..5f3500230 100644 --- a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -1,28 +1,29 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 CEA +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_HypothesesUtils.cxx // Author : Julia DOROVSKIKH, Open CASCADE S.A.S. -// - // SMESH includes +// #include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI.h" @@ -77,22 +78,20 @@ static int MYDEBUG = 0; namespace SMESH { - typedef QMap THypothesisDataMap; + typedef QMap THypothesisDataMap; THypothesisDataMap myHypothesesMap; THypothesisDataMap myAlgorithmsMap; - typedef QMap THypCreatorMap; + typedef QMap THypCreatorMap; THypCreatorMap myHypCreatorMap; - std::list myListOfHypothesesSets; - //QList myListOfHypothesesSets; + QList myListOfHypothesesSets; void processHypothesisStatus(const int theHypStatus, SMESH::SMESH_Hypothesis_ptr theHyp, const bool theIsAddition) { if (theHypStatus > SMESH::HYP_OK) { - // get Hyp name QString aHypName ("NULL Hypothesis"); if (!CORBA::is_nil(theHyp)) { @@ -141,13 +140,12 @@ namespace SMESH HypsXml.sprintf("%s", cenv); QStringList HypsXmlList = HypsXml.split(":", QString::SkipEmptyParts); - if (HypsXmlList.count() == 0) - { - SUIT_MessageBox::critical(SMESHGUI::desktop(), - QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("MESHERS_FILE_NO_VARIABLE")); - return; - } + if (HypsXmlList.count() == 0) { + SUIT_MessageBox::critical(SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("MESHERS_FILE_NO_VARIABLE")); + return; + } // loop on files in HypsXml QString aNoAccessFiles; @@ -173,10 +171,14 @@ namespace SMESH bool ok = reader.parse(source); file.close(); if (ok) { - myHypothesesMap.unite( QMap( aXmlHandler->myHypothesesMap ) ); - myAlgorithmsMap.unite( QMap( aXmlHandler->myAlgorithmsMap ) ); - myListOfHypothesesSets.splice( myListOfHypothesesSets.begin(), - aXmlHandler->myListOfHypothesesSets ); + myHypothesesMap.unite( aXmlHandler->myHypothesesMap ); + myAlgorithmsMap.unite( aXmlHandler->myAlgorithmsMap ); + QList::iterator it, pos = myListOfHypothesesSets.begin(); + for ( it = aXmlHandler->myListOfHypothesesSets.begin(); + it != aXmlHandler->myListOfHypothesesSets.end(); + ++it ) { + myListOfHypothesesSets.insert( pos, *it ); + } } else { SUIT_MessageBox::critical(SMESHGUI::desktop(), @@ -215,21 +217,22 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - bool checkGeometry = !isNeedGeometry; + bool checkGeometry = ( !isNeedGeometry && isAlgo ); // fill list of hypotheses/algorithms - THypothesisDataMap* pMap = isAlgo ? &myAlgorithmsMap : &myHypothesesMap; + THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap; THypothesisDataMap::iterator anIter; - for ( anIter = pMap->begin(); anIter != pMap->end(); anIter++ ) - { - HypothesisData* aData = anIter.value(); - if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) - if (checkGeometry){ - if (aData->IsNeedGeometry == isNeedGeometry) - aHypList.append(anIter.key().c_str()); - } - else - aHypList.append(anIter.key().c_str()); + for ( anIter = pMap.begin(); anIter != pMap.end(); anIter++ ) { + HypothesisData* aData = anIter.value(); + if ( ( theDim < 0 || aData->Dim.contains( theDim ) ) && aData->IsAux == isAux) { + if (checkGeometry) { + if (aData->IsNeedGeometry == isNeedGeometry) + aHypList.append(anIter.key()); + } + else { + aHypList.append(anIter.key()); + } } + } return aHypList; } @@ -241,29 +244,29 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - std::list::iterator hypoSet = myListOfHypothesesSets.begin(); - //QList::iterator hypoSet = myListOfHypothesesSets.begin(); - for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) - { - HypothesesSet* aSet = *hypoSet; - if ( aSet && aSet->AlgoList.count() ) { - aSetNameList.append( aSet->HypoSetName ); - } + QList::iterator hypoSet; + for ( hypoSet = myListOfHypothesesSets.begin(); + hypoSet != myListOfHypothesesSets.end(); + ++hypoSet ) { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->AlgoList.count() ) { + aSetNameList.append( aSet->HypoSetName ); } - + } + return aSetNameList; } HypothesesSet* GetHypothesesSet(const QString& theSetName) { - std::list::iterator hypoSet = myListOfHypothesesSets.begin(); - //QList::iterator hypoSet = myListOfHypothesesSets.begin(); - for ( ; hypoSet != myListOfHypothesesSets.end(); ++hypoSet ) - { - HypothesesSet* aSet = *hypoSet; - if ( aSet && aSet->HypoSetName == theSetName ) - return aSet; - } + QList::iterator hypoSet; + for ( hypoSet = myListOfHypothesesSets.begin(); + hypoSet != myListOfHypothesesSets.end(); + ++hypoSet ) { + HypothesesSet* aSet = *hypoSet; + if ( aSet && aSet->HypoSetName == theSetName ) + return aSet; + } return 0; } @@ -274,14 +277,11 @@ namespace SMESH // Init list of available hypotheses, if needed InitAvailableHypotheses(); - THypothesisDataMap::iterator type_data = myHypothesesMap.find(aHypType.toLatin1().data()); - if (type_data != myHypothesesMap.end()) { - aHypData = type_data.value(); + if (myHypothesesMap.find(aHypType) != myHypothesesMap.end()) { + aHypData = myHypothesesMap[aHypType]; } - else { - type_data = myAlgorithmsMap.find(aHypType.toLatin1().data()); - if (type_data != myAlgorithmsMap.end()) - aHypData = type_data.value(); + else if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) { + aHypData = myAlgorithmsMap[aHypType]; } return aHypData; } @@ -326,8 +326,8 @@ namespace SMESH SMESHGUI_GenericHypothesisCreator* aCreator = 0; // check, if creator for this hypothesis type already exists - if (myHypCreatorMap.find(aHypType.toLatin1().data()) != myHypCreatorMap.end()) { - aCreator = myHypCreatorMap[aHypType.toLatin1().data()]; + if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) { + aCreator = myHypCreatorMap[aHypType]; } else { // 1. Init list of available hypotheses, if needed @@ -347,15 +347,14 @@ namespace SMESH LibHandle libHandle = LoadLib( aClientLibName.toLatin1().data() ); if (!libHandle) { // report any error, if occured - if ( MYDEBUG ) - { + if ( MYDEBUG ) { #ifdef WIN32 - const char* anError = "Can't load client meshers plugin library"; + const char* anError = "Can't load client meshers plugin library"; #else - const char* anError = dlerror(); + const char* anError = dlerror(); #endif - MESSAGE(anError); - } + MESSAGE(anError); + } } else { // get method, returning hypothesis creator @@ -377,7 +376,7 @@ namespace SMESH } else { // map hypothesis creator to a hypothesis name - myHypCreatorMap[aHypType.toLatin1().data()] = aCreator; + myHypCreatorMap[aHypType] = aCreator; } } }