X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_NoteBook.cxx;h=3f53f2c28a461126e79a5cecfcaa19db0dbdc00a;hp=a482d86ed2db2260982111d8db8d182b7e34bea8;hb=HEAD;hpb=866063cabbbb91db3bc2635d726b061a759e17a2 diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx index a482d86ed..6576b5d5e 100644 --- a/src/SMESH_I/SMESH_NoteBook.cxx +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,12 +36,6 @@ #include #include -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - using namespace std; @@ -53,7 +47,7 @@ namespace */ void SetVariable(Handle(_pyCommand) theCommand, const SMESH_ObjectStates* theStates, - int position, int theArgNb) + size_t position, int theArgNb) { if(theStates->GetCurrectState().size() > position) if(!theStates->GetCurrectState().at(position).IsEmpty()) @@ -100,7 +94,7 @@ void SMESH_ObjectStates::AddState(const TState &theState) //================================================================================ TState SMESH_ObjectStates::GetCurrectState() const { - if(_states.size() > _dumpstate) + if ( (int) _states.size() > _dumpstate) return _states[_dumpstate]; TState empty; return empty; @@ -231,18 +225,18 @@ SMESH_NoteBook::~SMESH_NoteBook() /*! * \brief Replace parameters of the functions on the Salome NoteBook Variables * \param theString - Input string - * \retval TCollection_AsciiString - Convertion result + * \retval TCollection_AsciiString - Conversion result */ //================================================================================ void SMESH_NoteBook::ReplaceVariables() { - for(int i=0;i<_commands.size();i++) + for ( size_t i = 0 ; i < _commands.size(); i++ ) { Handle(_pyCommand) aCmd = _commands[i]; TCollection_AsciiString aMethod = aCmd->GetMethod(); TCollection_AsciiString aObject = aCmd->GetObject(); TCollection_AsciiString aResultValue = aCmd->GetResultValue(); - if(MYDEBUG) { + if(SALOME::VerbosityActivated()) { cout<<"Command before : "<< aCmd->GetString()<AddDistribution(aCmd->GetArg(1)); - if(MYDEBUG) + if(SALOME::VerbosityActivated()) cout<<"Add Distribution :"<GetArg(1)<GetCurrentStudy(); - SALOMEDS::SObject_wrap sobj = aStudy->FindObjectID( (*it).first.ToCString() ); + SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( (*it).first.ToCString() ); CORBA::Object_var obj = aGen->SObjectToObject( sobj ); if ( SMESH_Hypothesis_i* h = SMESH::DownCast< SMESH_Hypothesis_i*>( obj )) { TState aCurrentState = aStates->GetCurrectState(); int argIndex = h->getParamIndex( aMethod, aCurrentState.size() ); - if ( 0 <= argIndex && argIndex < aCurrentState.size() && + if ( 0 <= argIndex && argIndex < (int)aCurrentState.size() && !aCurrentState[argIndex].IsEmpty() ) aCmd->SetArg( 1, aCurrentState[argIndex] ); @@ -724,10 +717,10 @@ void SMESH_NoteBook::ReplaceVariables() } } else { - if(MYDEBUG) + if(SALOME::VerbosityActivated()) cout << "Object not found" << endl; } - if(MYDEBUG) { + if(SALOME::VerbosityActivated()) { cout<<"Command after: "<< aCmd->GetString()<GetCurrentStudy(); + SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant(); if(aStudy->_is_nil()) return; @@ -767,7 +760,7 @@ void SMESH_NoteBook::InitObjectMap() std::vector< std::string > allVars = aGen->GetAllParameters( anID.in() ); SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters.in()); _entry2VarsMap[ TCollection_AsciiString( anID.in() )] = allVars; - if(MYDEBUG) { + if(SALOME::VerbosityActivated()) { cout<<"Entry : "<< anID<_is_nil() ) { anObjType = "Mesh"; } - if(MYDEBUG) + if(SALOME::VerbosityActivated()) cout<<"The object Type : "<length(); i++) { + for ( size_t i = 0; i < aSections->length(); i++ ) { TState aVars; SALOMEDS::ListOfStrings aListOfVars = aSections[i]; - for ( int j = 0; jIsVariable(aVar.ToCString())) { @@ -801,7 +794,7 @@ void SMESH_NoteBook::InitObjectMap() aVar.InsertAfter(aVar.Length(), SMESH::TVar::Quote() ); } aVars.push_back(aVar); - if(MYDEBUG) { + if(SALOME::VerbosityActivated()) { cout<<"Variable: '"<GetResultValue(); if(_commands[i]->GetMethod() == "CreateHypothesis" && aLDS[j]->HasDistribution(aResultValue)){ @@ -872,8 +865,8 @@ void SMESH_NoteBook::ProcessLayerDistribution() } // 3) ... and replase variables ... - for(int i=0;i<_commands.size();i++){ - for(int j =0;j < aLDS.size();j++){ + for ( size_t i = 0; i < _commands.size(); i++ ) { + for ( size_t j = 0; j < aLDS.size(); j++ ) { TCollection_AsciiString anObject = _commands[i]->GetObject(); if(aLDS[j]->HasDistribution(anObject)) { @@ -929,11 +922,22 @@ void SMESH_NoteBook::ProcessLayerDistribution() TCollection_AsciiString SMESH_NoteBook::GetResultScript() const { TCollection_AsciiString aResult; - for(int i=0;i<_commands.size();i++) - aResult+=_commands[i]->GetString()+"\n"; + for ( size_t i = 0; i < _commands.size(); i++ ) + aResult += _commands[i]->GetString() + "\n"; return aResult; } +//================================================================================ +/*! + * \brief Return lines of the result script + */ +//================================================================================ +void SMESH_NoteBook::GetResultLines(std::list< TCollection_AsciiString >& lines) const +{ + for ( size_t i = 0; i < _commands.size(); i++ ) + lines.push_back( _commands[i]->GetString() ); +} + //================================================================================ /*! * \brief Return value of the variable @@ -943,11 +947,7 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& { bool ok = false; - SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen(); - if(!aGen) - return ok; - - SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy(); + SALOMEDS::Study_ptr aStudy = SMESH_Gen_i::GetSMESHGen()->getStudyServant(); if(aStudy->_is_nil()) return ok; @@ -965,4 +965,3 @@ bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& return ok; } -