-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 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
// Author : Roman NIKOLAEV, Open CASCADE S.A.S.
// Module : GUI
//
-#include <PyConsole_Interp.h> // this include must be first (see PyInterp_base.h)!
-#include <PyConsole_Console.h>
+#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"
//============================================================================
NoteBook_TableRow::NoteBook_TableRow(int index, NoteBook_Table* parentTable, QWidget* parent):
QWidget(parent),
- myParentTable(parentTable),
myIndex(index),
+ myParentTable(parentTable),
myRowHeader(new QTableWidgetItem()),
myVariableName(new QTableWidgetItem()),
myVariableValue(new QTableWidgetItem())
* The whole notebook is verified on apply
*/
//============================================================================
-bool NoteBook_TableRow::IsValidStringValue(const QString theValue)
+bool NoteBook_TableRow::IsValidStringValue(const QString /*theValue*/)
{
int aNumRows = myParentTable->myRows.count();
if( aNumRows == 0 )
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
- PyLockWrapper aLock = pyInterp->GetLockWrapper();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
+ PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ ) {
* Purpose : Add variables in the table from theStudy
*/
//============================================================================
-void NoteBook_Table::Init(_PTR(Study) theStudy)
+void NoteBook_Table::Init()
{
isProcessItemChangedSignal = false;
myVariableMap.clear();
//Add all variables into the table
- std::vector<std::string> aVariables = theStudy->GetVariableNames();
- for(int iVar = 0; iVar < aVariables.size(); iVar++ ) {
+ std::vector<std::string> aVariables = SalomeApp_Application::getStudy()->GetVariableNames();
+ for(int iVar = 0; iVar < (int)aVariables.size(); iVar++ ) {
AddRow(QString(aVariables[iVar].c_str()),
- Variable2String(aVariables[iVar],theStudy));
+ Variable2String(aVariables[iVar]));
}
//Add empty row
isProcessItemChangedSignal = true;
ResetMaps();
-
- myStudy = 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;
}
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
- PyLockWrapper aLock = pyInterp->GetLockWrapper();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
+ PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
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 ),
//============================================================================
void NoteBook_Table::RemoveSelected()
{
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
isProcessItemChangedSignal = false;
QList<QTableWidgetItem*> aSelectedItems = selectedItems();
if( !(aSelectedItems.size() > 0)) {
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() ),
myVariableMap.remove( index );
removeRow(nRow);
myRows.removeAt(nRow);
- if(myStudy->IsVariable(aVarName.toLatin1().constData()))
+ if(aStudy->IsVariable(aVarName.toUtf8().constData()))
removedFromStudy = true;
}
}
* 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"));
connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) );
connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
- myTable->Init(myStudy);
+ myTable->Init();
myDumpedStudyScript = "";
myIsDumpedStudySaved = false;
* 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();
}
* Purpose : [slot]
*/
//============================================================================
-void SalomeApp_NoteBook::onVarUpdate(QString theVarName)
+void SalomeApp_NoteBook::onVarUpdate(QString /*theVarName*/)
{
- myTable->Init(myStudy);
+ myTable->Init();
}
//============================================================================
SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) );
return;
}
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
double aDVal;
int anIVal;
if( aVariableMapRef.contains( anIndex ) )
{
QString aRemovedVariable = aVariableMapRef[ anIndex ].Name;
- myStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) );
+ aStudy->RemoveVariable( std::string( aRemovedVariable.toUtf8().constData() ) );
}
}
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();
if(app)
app->updateActions();
- myStudy->Modified();
+ aStudy->Modified();
}
//============================================================================