1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: SalomeApp_NoteBook.cxx
21 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
24 #include "PyConsole_Interp.h" // this include must be first (see PyInterp_base.h)!
25 #include "PyConsole_Console.h"
27 #include "SalomeApp_NoteBook.h"
28 #include "SalomeApp_Application.h"
29 #include "SalomeApp_Study.h"
30 #include "SalomeApp_VisualState.h"
34 #include <CAM_Module.h>
36 #include <SUIT_Desktop.h>
37 #include <SUIT_MessageBox.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_Session.h>
42 #include <QGridLayout>
43 #include <QTableWidget>
44 #include <QTableWidgetItem>
45 #include <QPushButton>
49 #include <QApplication>
55 #define DEFAULT_MARGIN 11
56 #define DEFAULT_SPACING 6
57 #define SPACER_SIZE 100
58 #define COLUMN_SIZE 100
61 #define VALUE_COLUMN 1
64 ///////////////////////////////////////////////////////////////////////////
65 // NoteBook_TableRow class //
66 ///////////////////////////////////////////////////////////////////////////
67 //============================================================================
68 /*! Function : NoteBook_TableRow
69 * Purpose : Constructor
71 //============================================================================
72 NoteBook_TableRow::NoteBook_TableRow(int index, NoteBook_Table* parentTable, QWidget* parent):
74 myParentTable(parentTable),
76 myRowHeader(new QTableWidgetItem()),
77 myVariableName(new QTableWidgetItem()),
78 myVariableValue(new QTableWidgetItem())
82 //============================================================================
83 /*! Function : ~NoteBook_TableRow
84 * Purpose : Destructor
86 //============================================================================
87 NoteBook_TableRow::~NoteBook_TableRow()
91 //============================================================================
92 /*! Function : AddToTable
93 * Purpose : Add this row to the table theTable
95 //============================================================================
96 void NoteBook_TableRow::AddToTable(QTableWidget *theTable)
98 int aPosition = theTable->rowCount();
99 int aRowCount = aPosition+1;
100 theTable->setRowCount(aRowCount);
101 myRowHeader->setText(QString::number(aRowCount));
103 theTable->setVerticalHeaderItem(aPosition,myRowHeader);
104 theTable->setItem(aPosition, NAME_COLUMN, myVariableName);
105 theTable->setItem(aPosition, VALUE_COLUMN, myVariableValue);
108 //============================================================================
109 /*! Function : SetName
112 //============================================================================
113 void NoteBook_TableRow::SetName(const QString theName)
115 myVariableName->setText(theName);
118 //============================================================================
119 /*! Function : SetValue
122 //============================================================================
123 void NoteBook_TableRow::SetValue(const QString theValue)
125 myVariableValue->setText(theValue);
128 //============================================================================
129 /*! Function : GetName
130 * Purpose : Return variable name
132 //============================================================================
133 QString NoteBook_TableRow::GetName() const
135 return myVariableName->text();
138 //============================================================================
139 /*! Function : GetValue
140 * Purpose : Return variable value
142 //============================================================================
143 QString NoteBook_TableRow::GetValue() const
145 return myVariableValue->text();
148 //============================================================================
149 /*! Function : CheckName
150 * Purpose : Return true if variable name correct, otherwise return false
152 //============================================================================
153 bool NoteBook_TableRow::CheckName()
155 QString aName = GetName();
157 QRegExpValidator aValidator( QRegExp("^([a-zA-Z]+)([a-zA-Z0-9_]*)$"), 0 );
158 if( aName.isEmpty() || !aValidator.validate( aName, aPos ) )
163 //============================================================================
164 /*! Function : CheckValue
165 * Purpose : Return true if variable value correct, otherwise return false
167 //============================================================================
168 bool NoteBook_TableRow::CheckValue()
170 bool aResult = false;
171 QString aValue = GetValue();
172 if(!aValue.isEmpty() &&
173 (IsRealValue(aValue) ||
174 IsIntegerValue(aValue) ||
175 IsBooleanValue(aValue) ||
176 IsValidStringValue(aValue)))
182 //============================================================================
183 /*! Function : GetVariableItem
186 //============================================================================
187 QTableWidgetItem* NoteBook_TableRow::GetVariableItem()
189 return myVariableValue;
192 //============================================================================
193 /*! Function : GetNameItem
196 //============================================================================
197 QTableWidgetItem* NoteBook_TableRow::GetNameItem()
199 return myVariableName;
202 //============================================================================
203 /*! Function : GetHeaderItem
206 //============================================================================
207 QTableWidgetItem* NoteBook_TableRow::GetHeaderItem()
212 //============================================================================
213 /*! Function : IsRealValue
214 * Purpose : Return true if theValue string is real value, otherwise return
217 //============================================================================
218 bool NoteBook_TableRow::IsRealValue(const QString theValue, double* theResult)
220 bool aResult = false;
221 double aDResult = theValue.toDouble(&aResult);
222 if(aResult && theResult)
223 *theResult = aDResult;
228 //============================================================================
229 /*! Function : IsBooleanValue
230 * Purpose : Return true if theValue String is boolean value, otherwise return
233 //============================================================================
234 bool NoteBook_TableRow::IsBooleanValue(const QString theValue, bool* theResult){
235 bool aResult = false;
237 if(theValue.compare("True") == 0) {
241 else if(theValue.compare("False") == 0) {
245 if(aResult && theResult)
246 *theResult = aBResult;
251 //============================================================================
252 /*! Function : IsIntegerValue
253 * Purpose : Return true if theValue string is integer value, otherwise return
256 //============================================================================
257 bool NoteBook_TableRow::IsIntegerValue(const QString theValue, int* theResult)
259 bool aResult = false;
261 anIResult = theValue.toInt(&aResult);
263 if(aResult && theResult)
264 *theResult = anIResult;
269 //============================================================================
270 /*! Function : IsValidStringValue
271 * Purpose : Return true if theValue string is valid, otherwise return
273 * The string are always valid for the moment
274 * The whole notebook is verified on apply
276 //============================================================================
277 bool NoteBook_TableRow::IsValidStringValue(const QString theValue)
279 int aNumRows = myParentTable->myRows.count();
283 bool aLastRowIsEmpty = myParentTable->myRows[ aNumRows - 1 ]->GetName().isEmpty() &&
284 myParentTable->myRows[ aNumRows - 1 ]->GetValue().isEmpty();
286 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
287 PyConsole_Console* pyConsole = app->pythonConsole();
288 PyConsole_Interp* pyInterp = app->getPyInterp();
289 PyLockWrapper aLock; // Acquire GIL
290 std::string command = "import salome_notebook ; ";
291 command += "salome_notebook.checkThisNoteBook(";
292 for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ ) {
293 command += myParentTable->myRows[i]->GetName().toStdString();
295 command += myParentTable->myRows[i]->GetValue().toStdString();
300 //rnv: fix for bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook"
301 bool oldSuppressValue = pyConsole->isSuppressOutput();
302 pyConsole->setIsSuppressOutput(true);
303 bool aResult = pyInterp->run(command.c_str());
304 pyConsole->setIsSuppressOutput(oldSuppressValue);
308 ///////////////////////////////////////////////////////////////////////////
309 // NoteBook_Table class //
310 ///////////////////////////////////////////////////////////////////////////
311 //============================================================================
312 /*! Function : NoteBook_Table
313 * Purpose : Constructor
315 //============================================================================
316 NoteBook_Table::NoteBook_Table(QWidget * parent)
317 :QTableWidget(parent),
318 isProcessItemChangedSignal(false),
322 setSelectionMode(QAbstractItemView::SingleSelection);
324 //Add Headers Columns
325 QFont aFont = QFont();
326 aFont.setPointSize(10);
329 QTableWidgetItem * aNameHeader = new QTableWidgetItem();
330 aNameHeader->setText(tr("VARNAME_COLUMN"));
331 aNameHeader->setFont(aFont);
332 setHorizontalHeaderItem(0,aNameHeader);
333 setColumnWidth ( 0, COLUMN_SIZE);
336 QTableWidgetItem * aValueHeader = new QTableWidgetItem();
337 aValueHeader->setText(tr("VARVALUE_COLUMN"));
338 aValueHeader->setFont(aFont);
339 setHorizontalHeaderItem(1,aValueHeader);
340 setColumnWidth ( 1, COLUMN_SIZE);
341 setSortingEnabled(false);
343 connect(this,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(onItemChanged(QTableWidgetItem*)));
346 //============================================================================
347 /*! Function : ~NoteBook_Table
348 * Purpose : Destructor
350 //============================================================================
351 NoteBook_Table::~NoteBook_Table(){}
353 //============================================================================
354 /*! Function : getUniqueIndex
355 * Purpose : Get a unique index for the new row
357 //============================================================================
358 int NoteBook_Table::getUniqueIndex() const
361 if( !myRows.isEmpty() )
362 if( NoteBook_TableRow* aRow = myRows.last() )
363 anIndex = aRow->GetIndex();
365 int aMaxRemovedRow = 0;
366 for( QListIterator<int> anIter( myRemovedRows ); anIter.hasNext(); )
368 int aRemovedRow = anIter.next();
369 aMaxRemovedRow = qMax( aRemovedRow, aMaxRemovedRow );
372 anIndex = qMax( anIndex, aMaxRemovedRow ) + 1;
376 //============================================================================
378 * Purpose : Add variables in the table from theStudy
380 //============================================================================
381 void NoteBook_Table::Init(_PTR(Study) theStudy)
383 isProcessItemChangedSignal = false;
385 int aNumRows = myRows.count();
388 for( int i = 0; i < myRows.size(); i++ )
390 NoteBook_TableRow* aRow = myRows[ i ];
401 myRemovedRows.clear();
402 myVariableMapRef.clear();
403 myVariableMap.clear();
405 //Add all variables into the table
406 std::vector<std::string> aVariables = theStudy->GetVariableNames();
407 for(int iVar = 0; iVar < aVariables.size(); iVar++ ) {
408 AddRow(QString(aVariables[iVar].c_str()),
409 Variable2String(aVariables[iVar],theStudy));
414 isProcessItemChangedSignal = true;
421 //============================================================================
422 /*! Function : Variable2String
423 * Purpose : Convert variable values to QString
425 //============================================================================
426 QString NoteBook_Table::Variable2String(const std::string& theVarName,
427 _PTR(Study) theStudy)
430 if( theStudy->IsReal(theVarName) )
431 aResult = QString::number(theStudy->GetReal(theVarName));
432 else if( theStudy->IsInteger(theVarName) )
433 aResult = QString::number(theStudy->GetInteger(theVarName));
434 else if( theStudy->IsBoolean(theVarName) )
435 aResult = theStudy->GetBoolean(theVarName) ? QString("True") : QString("False");
436 else if( theStudy->IsString(theVarName) )
437 aResult = theStudy->GetString(theVarName).c_str();
442 //============================================================================
443 /*! Function : IsValid
444 * Purpose : Check validity of the table data
446 //============================================================================
447 bool NoteBook_Table::IsValid() const
449 int aNumRows = myRows.count();
453 bool aLastRowIsEmpty = myRows[ aNumRows - 1 ]->GetName().isEmpty() &&
454 myRows[ aNumRows - 1 ]->GetValue().isEmpty();
456 for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
457 if( !myRows[i]->CheckName() || !IsUniqueName( myRows[i] ) || !myRows[i]->CheckValue() )
460 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
461 PyConsole_Console* pyConsole = app->pythonConsole();
462 PyConsole_Interp* pyInterp = app->getPyInterp();
463 PyLockWrapper aLock; // Acquire GIL
464 std::string command = "import salome_notebook ; ";
465 command += "salome_notebook.checkThisNoteBook(";
466 for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
468 command += myRows[i]->GetName().toStdString();
470 command += myRows[i]->GetValue().toStdString();
475 //rnv: fix for bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook"
476 bool oldSuppressValue = pyConsole->isSuppressOutput();
477 pyConsole->setIsSuppressOutput(true);
478 bool aResult = pyInterp->run(command.c_str());
479 pyConsole->setIsSuppressOutput(oldSuppressValue);
484 //============================================================================
485 /*! Function : RenumberRowItems
486 * Purpose : renumber row items
488 //============================================================================
489 void NoteBook_Table::RenumberRowItems() {
490 for(int i=0; i<myRows.size();i++){
491 myRows[i]->GetHeaderItem()->setText(QString::number(i+1));
495 //============================================================================
496 /*! Function : AddRow
497 * Purpose : Add a row into the table
499 //============================================================================
500 void NoteBook_Table::AddRow(const QString& theName, const QString& theValue)
502 int anIndex = getUniqueIndex();
503 NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this, this);
504 aRow->SetName(theName);
505 aRow->SetValue(theValue);
506 aRow->AddToTable(this);
509 myVariableMap.insert( anIndex, NoteBoox_Variable( theName, theValue ) );
512 //============================================================================
513 /*! Function : AddEmptyRow
514 * Purpose : Add an empty row into the end of the table
516 //============================================================================
517 void NoteBook_Table::AddEmptyRow()
519 isProcessItemChangedSignal = false;
521 isProcessItemChangedSignal = true;
524 //============================================================================
525 /*! Function : GetRowByItem
528 //============================================================================
529 NoteBook_TableRow* NoteBook_Table::GetRowByItem(const QTableWidgetItem* theItem) const
531 int aCurrentRow = row(theItem);
533 if( (myRows.size() <= aCurrentRow ) && (aCurrentRow < 0))
536 return myRows.at(aCurrentRow);
539 //============================================================================
540 /*! Function : IsLastRow
541 * Purpose : Return true if theRow is last row in the table
543 //============================================================================
544 bool NoteBook_Table::IsLastRow(const NoteBook_TableRow* theRow) const
546 return (myRows.last() == theRow);
549 //============================================================================
550 /*! Function : onItemChanged
551 * Purpose : [slot] called when table item changed
553 //============================================================================
554 void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem)
556 if(isProcessItemChangedSignal) {
557 bool isModified = true;
558 NoteBook_TableRow* aRow = GetRowByItem(theItem);
560 int aCurrentColumn = column(theItem);
561 bool IsCorrect = true, IsVariableComplited = false;
564 if(aCurrentColumn == NAME_COLUMN) {
565 int anIndex = aRow->GetIndex();
566 if( myVariableMap.contains( anIndex ) )
568 const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
569 if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) )
571 if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
572 tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ),
573 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
575 bool isBlocked = blockSignals( true );
576 aRow->SetName( aVariable.Name );
577 blockSignals( isBlocked );
584 //Case when variable name was changed.
585 if(aCurrentColumn == NAME_COLUMN) {
586 if(!aRow->CheckName()) {
588 aMsg = tr( "VARNAME_INCORRECT" ).arg(aRow->GetName());
590 else if(!IsUniqueName(aRow)) {
592 aMsg = tr( "VARNAME_EXISTS" ).arg(aRow->GetName());
595 IsVariableComplited = aRow->CheckValue();
598 //Case when variable value was changed.
599 else if(aCurrentColumn == VALUE_COLUMN){
600 if(!aRow->CheckValue()) {
602 aMsg = tr( "VARVALUE_INCORRECT" ).arg(aRow->GetName());
605 IsVariableComplited = aRow->CheckName() && IsUniqueName(aRow);
608 if(!IsCorrect && !aMsg.isEmpty())
609 SUIT_MessageBox::warning( parentWidget(), tr( "WARNING" ), aMsg );
611 bool isBlocked = blockSignals( true );
612 theItem->setForeground( QBrush( IsCorrect ? Qt::black : Qt::red ) );
613 blockSignals( isBlocked );
615 int anIndex = aRow->GetIndex();
616 if( myVariableMap.contains( anIndex ) )
618 NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
619 if( aVariable.Name.compare( aRow->GetName() ) != 0 ||
620 aVariable.Value.compare( aRow->GetValue() ) != 0 )
622 aVariable.Name = aRow->GetName();
623 aVariable.Value = aRow->GetValue();
629 if(IsCorrect && IsVariableComplited && IsLastRow(aRow))
632 if( aRow->CheckName() && aRow->CheckValue() )
633 qobject_cast<SalomeApp_NoteBook*>(parentWidget())->onApply();
637 myIsModified = isModified;
641 //============================================================================
642 /*! Function : IsUniqueName
643 * Purpose : Return true if theName is unique name of the Variable
645 //============================================================================
646 bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const
648 for(int i=0; i<myRows.size();i++) {
649 if(myRows[i] == theRow )
651 if(myRows[i]->GetName().compare(theRow->GetName()) == 0)
657 //============================================================================
658 /*! Function : RemoveSelected
659 * Purpose : Remove selected rows in the table
661 //============================================================================
662 void NoteBook_Table::RemoveSelected()
664 isProcessItemChangedSignal = false;
665 QList<QTableWidgetItem*> aSelectedItems = selectedItems();
666 if( !(aSelectedItems.size() > 0)) {
667 isProcessItemChangedSignal = true;
670 bool removedFromStudy = false;
671 for(int i=0; i < aSelectedItems.size(); i++ ) {
672 NoteBook_TableRow* aRow = GetRowByItem(aSelectedItems[i]);
674 if(IsLastRow(aRow)) {
675 aRow->SetName(QString());
676 aRow->SetValue(QString());
679 int nRow = row(aSelectedItems[i]);
681 if( myStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) )
683 if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
684 tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ),
685 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
687 isProcessItemChangedSignal = true;
692 int index = aRow->GetIndex();
693 QString aVarName = aRow->GetName();
694 myRemovedRows.append( index );
695 if( myVariableMap.contains( index ) )
696 myVariableMap.remove( index );
698 myRows.removeAt(nRow);
699 if(myStudy->IsVariable(aVarName.toLatin1().constData()))
700 removedFromStudy = true;
707 isProcessItemChangedSignal = true;
710 //============================================================================
711 /*! Function : SetProcessItemChangedSignalFlag
714 //============================================================================
715 void NoteBook_Table::SetProcessItemChangedSignalFlag(const bool enable)
717 isProcessItemChangedSignal = enable;
720 //============================================================================
721 /*! Function : GetProcessItemChangedSignalFlag
724 //============================================================================
725 bool NoteBook_Table::GetProcessItemChangedSignalFlag() const
727 return isProcessItemChangedSignal;
730 //============================================================================
731 /*! Function : GetRows
734 //============================================================================
735 QList<NoteBook_TableRow*> NoteBook_Table::GetRows() const
740 //============================================================================
741 /*! Function : ResetMaps
742 * Purpose : Reset variable maps
744 //============================================================================
745 void NoteBook_Table::ResetMaps()
747 myIsModified = false;
748 myVariableMapRef = myVariableMap;
749 myRemovedRows.clear();
752 ///////////////////////////////////////////////////////////////////////////
753 // SalomeApp_NoteBook class //
754 ///////////////////////////////////////////////////////////////////////////
755 //============================================================================
756 /*! Function : SalomeApp_NoteBook
757 * Purpose : Constructor
759 //============================================================================
760 SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy):
764 setObjectName("SalomeApp_NoteBook");
765 setWindowTitle(tr("NOTEBOOK_TITLE"));
766 QGridLayout* aLayout = new QGridLayout(this);
769 myTable = new NoteBook_Table(this);
770 aLayout->addWidget(myTable, 0, 0, 1, 3);
773 myRemoveButton = new QPushButton(tr("BUT_REMOVE"));
774 aLayout->addWidget(myRemoveButton, 1, 0);
776 QSpacerItem* spacer =
777 new QSpacerItem(DEFAULT_SPACING, 5 , QSizePolicy::Expanding, QSizePolicy::Minimum);
778 aLayout->addItem(spacer, 1, 1);
780 myUpdateStudyBtn = new QPushButton(tr("BUT_UPDATE_STUDY"));
781 aLayout->addWidget(myUpdateStudyBtn, 1, 2);
783 QWidgetList aWidgetList;
784 aWidgetList.append( myTable );
785 aWidgetList.append( myUpdateStudyBtn );
786 aWidgetList.append( myRemoveButton );
787 Qtx::setTabOrder( aWidgetList );
789 connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) );
790 connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
792 myTable->Init(myStudy);
794 myDumpedStudyScript = "";
795 myIsDumpedStudySaved = false;
798 //============================================================================
799 /*! Function : ~SalomeApp_NoteBook
800 * Purpose : Destructor
802 //============================================================================
803 SalomeApp_NoteBook::~SalomeApp_NoteBook(){}
806 //============================================================================
807 /*! Function : Init()
808 * Purpose : init variable table
810 //============================================================================
811 void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){
812 if(myStudy!= theStudy)
814 myTable->Init(myStudy);
818 //============================================================================
819 /*! Function : onVarUpdate
822 //============================================================================
823 void SalomeApp_NoteBook::onVarUpdate(QString theVarName)
825 myTable->Init(myStudy);
828 //============================================================================
829 /*! Function : onApply
832 //============================================================================
833 void SalomeApp_NoteBook::onApply()
835 if( !myTable->IsValid() )
837 SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) );
845 const QList<int>& aRemovedRows = myTable->GetRemovedRows();
846 const VariableMap& aVariableMap = myTable->GetVariableMap();
847 const VariableMap& aVariableMapRef = myTable->GetVariableMapRef();
849 for( QListIterator<int> anIter( aRemovedRows ); anIter.hasNext(); )
851 int anIndex = anIter.next();
852 if( aVariableMapRef.contains( anIndex ) )
854 QString aRemovedVariable = aVariableMapRef[ anIndex ].Name;
855 myStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) );
859 VariableMap::const_iterator it = aVariableMap.constBegin(), itEnd = aVariableMap.constEnd();
860 for( ; it != itEnd; ++it )
862 int anIndex = it.key();
863 const NoteBoox_Variable& aVariable = it.value();
864 QString aName = aVariable.Name;
865 QString aValue = aVariable.Value;
867 if( !aName.isEmpty() && !aValue.isEmpty() )
869 if( aVariableMapRef.contains( anIndex ) )
871 const NoteBoox_Variable& aVariableRef = aVariableMapRef[ anIndex ];
872 QString aNameRef = aVariableRef.Name;
873 QString aValueRef = aVariableRef.Value;
875 if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName )
877 myStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ),
878 std::string( aName.toLatin1().constData() ) );
882 if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) )
883 myStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal);
885 else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) )
886 myStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal);
888 else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) )
889 myStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal);
892 myStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString());
895 myTable->ResetMaps();
897 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
899 app->updateActions();
904 //============================================================================
905 /*! Function : onRemove
908 //============================================================================
909 void SalomeApp_NoteBook::onRemove()
911 myTable->RemoveSelected();
915 //============================================================================
916 /*! Function : onUpdateStudy
919 //============================================================================
920 void SalomeApp_NoteBook::onUpdateStudy()
923 if( !myTable->IsValid() )
926 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
929 app->onUpdateStudy();