X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_NoteBook.cxx;h=5467ef600ae5e70bb5d5bf8d48d6feb9bb3a1a47;hb=331294345d3e1716fbf79ae25a2851011729be79;hp=accca55943395331f2c0a8231ebba8e3a901c0c0;hpb=80f32aba5aa2bf61f6278621910d3e81a443d2e8;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_NoteBook.cxx b/src/SalomeApp/SalomeApp_NoteBook.cxx index accca5594..5467ef600 100644 --- a/src/SalomeApp/SalomeApp_NoteBook.cxx +++ b/src/SalomeApp/SalomeApp_NoteBook.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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 @@ -21,8 +21,8 @@ // Author : Roman NIKOLAEV, Open CASCADE S.A.S. // Module : GUI // -#include // this include must be first (see PyInterp_base.h)! -#include +#include "PyConsole_Interp.h" // this include must be first (see PyInterp_base.h)! +#include "PyConsole_Console.h" #include "SalomeApp_NoteBook.h" #include "SalomeApp_Application.h" @@ -285,7 +285,7 @@ bool NoteBook_TableRow::IsValidStringValue(const QString theValue) SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command = "import salome_notebook ; "; command += "salome_notebook.checkThisNoteBook("; @@ -378,7 +378,7 @@ int NoteBook_Table::getUniqueIndex() const * Purpose : Add variables in the table from theStudy */ //============================================================================ -void NoteBook_Table::Init(_PTR(Study) theStudy) +void NoteBook_Table::Init() { isProcessItemChangedSignal = false; @@ -403,10 +403,10 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) myVariableMap.clear(); //Add all variables into the table - std::vector aVariables = theStudy->GetVariableNames(); + std::vector aVariables = SalomeApp_Application::getStudy()->GetVariableNames(); for(int iVar = 0; iVar < aVariables.size(); iVar++ ) { AddRow(QString(aVariables[iVar].c_str()), - Variable2String(aVariables[iVar],theStudy)); + Variable2String(aVariables[iVar])); } //Add empty row @@ -414,8 +414,6 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) isProcessItemChangedSignal = true; ResetMaps(); - - myStudy = theStudy; } //============================================================================ @@ -423,18 +421,18 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) * Purpose : Convert variable values to QString */ //============================================================================ -QString NoteBook_Table::Variable2String(const std::string& theVarName, - _PTR(Study) theStudy) +QString NoteBook_Table::Variable2String(const std::string& theVarName) { + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); QString aResult; - if( theStudy->IsReal(theVarName) ) - aResult = QString::number(theStudy->GetReal(theVarName)); - else if( theStudy->IsInteger(theVarName) ) - aResult = QString::number(theStudy->GetInteger(theVarName)); - else if( theStudy->IsBoolean(theVarName) ) - aResult = theStudy->GetBoolean(theVarName) ? QString("True") : QString("False"); - else if( theStudy->IsString(theVarName) ) - aResult = theStudy->GetString(theVarName).c_str(); + if( aStudy->IsReal(theVarName) ) + aResult = QString::number(aStudy->GetReal(theVarName)); + else if( aStudy->IsInteger(theVarName) ) + aResult = QString::number(aStudy->GetInteger(theVarName)); + else if( aStudy->IsBoolean(theVarName) ) + aResult = aStudy->GetBoolean(theVarName) ? QString("True") : QString("False"); + else if( aStudy->IsString(theVarName) ) + aResult = aStudy->GetString(theVarName).c_str(); return aResult; } @@ -459,7 +457,7 @@ bool NoteBook_Table::IsValid() const SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command = "import salome_notebook ; "; command += "salome_notebook.checkThisNoteBook("; @@ -566,7 +564,7 @@ void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) if( myVariableMap.contains( anIndex ) ) { const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ]; - if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) ) + if( !aVariable.Name.isEmpty() && SalomeApp_Application::getStudy()->IsVariableUsed( std::string( aVariable.Name.toUtf8().constData() ) ) ) { if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ), @@ -661,6 +659,7 @@ bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const //============================================================================ void NoteBook_Table::RemoveSelected() { + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); isProcessItemChangedSignal = false; QList aSelectedItems = selectedItems(); if( !(aSelectedItems.size() > 0)) { @@ -678,7 +677,7 @@ void NoteBook_Table::RemoveSelected() else { int nRow = row(aSelectedItems[i]); - if( myStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) ) + if( aStudy->IsVariableUsed( std::string( aRow->GetName().toUtf8().constData() ) ) ) { if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ), @@ -696,7 +695,7 @@ void NoteBook_Table::RemoveSelected() myVariableMap.remove( index ); removeRow(nRow); myRows.removeAt(nRow); - if(myStudy->IsVariable(aVarName.toLatin1().constData())) + if(aStudy->IsVariable(aVarName.toUtf8().constData())) removedFromStudy = true; } } @@ -757,9 +756,8 @@ void NoteBook_Table::ResetMaps() * Purpose : Constructor */ //============================================================================ -SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy): - QWidget(parent), - myStudy(theStudy) +SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent): + QWidget(parent) { setObjectName("SalomeApp_NoteBook"); setWindowTitle(tr("NOTEBOOK_TITLE")); @@ -789,7 +787,7 @@ SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy): connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) ); connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove())); - myTable->Init(myStudy); + myTable->Init(); myDumpedStudyScript = ""; myIsDumpedStudySaved = false; @@ -808,10 +806,8 @@ SalomeApp_NoteBook::~SalomeApp_NoteBook(){} * Purpose : init variable table */ //============================================================================ -void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){ - if(myStudy!= theStudy) - myStudy = theStudy; - myTable->Init(myStudy); +void SalomeApp_NoteBook::Init(){ + myTable->Init(); } @@ -822,7 +818,7 @@ void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){ //============================================================================ void SalomeApp_NoteBook::onVarUpdate(QString theVarName) { - myTable->Init(myStudy); + myTable->Init(); } //============================================================================ @@ -837,6 +833,7 @@ void SalomeApp_NoteBook::onApply() SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) ); return; } + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); double aDVal; int anIVal; @@ -852,7 +849,7 @@ void SalomeApp_NoteBook::onApply() if( aVariableMapRef.contains( anIndex ) ) { QString aRemovedVariable = aVariableMapRef[ anIndex ].Name; - myStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) ); + aStudy->RemoveVariable( std::string( aRemovedVariable.toUtf8().constData() ) ); } } @@ -874,22 +871,22 @@ void SalomeApp_NoteBook::onApply() if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName ) { - myStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ), - std::string( aName.toLatin1().constData() ) ); + aStudy->RenameVariable( std::string( aNameRef.toUtf8().constData() ), + std::string( aName.toUtf8().constData() ) ); } } if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) ) - myStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal); + aStudy->SetInteger(std::string(aName.toUtf8().constData()),anIVal); else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) ) - myStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal); + aStudy->SetReal(std::string(aName.toUtf8().constData()),aDVal); else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) ) - myStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal); + aStudy->SetBoolean(std::string(aName.toUtf8().constData()),aBVal); else - myStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString()); + aStudy->SetString(std::string(aName.toUtf8().constData()),aValue.toStdString()); } } myTable->ResetMaps(); @@ -898,7 +895,7 @@ void SalomeApp_NoteBook::onApply() if(app) app->updateActions(); - myStudy->Modified(); + aStudy->Modified(); } //============================================================================