1 // Copyright (C) 2007-2016 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()
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 = SalomeApp_Application::getStudy()->GetVariableNames();
407 for(int iVar = 0; iVar < aVariables.size(); iVar++ ) {
408 AddRow(QString(aVariables[iVar].c_str()),
409 Variable2String(aVariables[iVar]));
414 isProcessItemChangedSignal = true;
419 //============================================================================
420 /*! Function : Variable2String
421 * Purpose : Convert variable values to QString
423 //============================================================================
424 QString NoteBook_Table::Variable2String(const std::string& theVarName)
426 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
428 if( aStudy->IsReal(theVarName) )
429 aResult = QString::number(aStudy->GetReal(theVarName));
430 else if( aStudy->IsInteger(theVarName) )
431 aResult = QString::number(aStudy->GetInteger(theVarName));
432 else if( aStudy->IsBoolean(theVarName) )
433 aResult = aStudy->GetBoolean(theVarName) ? QString("True") : QString("False");
434 else if( aStudy->IsString(theVarName) )
435 aResult = aStudy->GetString(theVarName).c_str();
440 //============================================================================
441 /*! Function : IsValid
442 * Purpose : Check validity of the table data
444 //============================================================================
445 bool NoteBook_Table::IsValid() const
447 int aNumRows = myRows.count();
451 bool aLastRowIsEmpty = myRows[ aNumRows - 1 ]->GetName().isEmpty() &&
452 myRows[ aNumRows - 1 ]->GetValue().isEmpty();
454 for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
455 if( !myRows[i]->CheckName() || !IsUniqueName( myRows[i] ) || !myRows[i]->CheckValue() )
458 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
459 PyConsole_Console* pyConsole = app->pythonConsole();
460 PyConsole_Interp* pyInterp = app->getPyInterp();
461 PyLockWrapper aLock; // Acquire GIL
462 std::string command = "import salome_notebook ; ";
463 command += "salome_notebook.checkThisNoteBook(";
464 for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
466 command += myRows[i]->GetName().toStdString();
468 command += myRows[i]->GetValue().toStdString();
473 //rnv: fix for bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook"
474 bool oldSuppressValue = pyConsole->isSuppressOutput();
475 pyConsole->setIsSuppressOutput(true);
476 bool aResult = pyInterp->run(command.c_str());
477 pyConsole->setIsSuppressOutput(oldSuppressValue);
482 //============================================================================
483 /*! Function : RenumberRowItems
484 * Purpose : renumber row items
486 //============================================================================
487 void NoteBook_Table::RenumberRowItems() {
488 for(int i=0; i<myRows.size();i++){
489 myRows[i]->GetHeaderItem()->setText(QString::number(i+1));
493 //============================================================================
494 /*! Function : AddRow
495 * Purpose : Add a row into the table
497 //============================================================================
498 void NoteBook_Table::AddRow(const QString& theName, const QString& theValue)
500 int anIndex = getUniqueIndex();
501 NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this, this);
502 aRow->SetName(theName);
503 aRow->SetValue(theValue);
504 aRow->AddToTable(this);
507 myVariableMap.insert( anIndex, NoteBoox_Variable( theName, theValue ) );
510 //============================================================================
511 /*! Function : AddEmptyRow
512 * Purpose : Add an empty row into the end of the table
514 //============================================================================
515 void NoteBook_Table::AddEmptyRow()
517 isProcessItemChangedSignal = false;
519 isProcessItemChangedSignal = true;
522 //============================================================================
523 /*! Function : GetRowByItem
526 //============================================================================
527 NoteBook_TableRow* NoteBook_Table::GetRowByItem(const QTableWidgetItem* theItem) const
529 int aCurrentRow = row(theItem);
531 if( (myRows.size() <= aCurrentRow ) && (aCurrentRow < 0))
534 return myRows.at(aCurrentRow);
537 //============================================================================
538 /*! Function : IsLastRow
539 * Purpose : Return true if theRow is last row in the table
541 //============================================================================
542 bool NoteBook_Table::IsLastRow(const NoteBook_TableRow* theRow) const
544 return (myRows.last() == theRow);
547 //============================================================================
548 /*! Function : onItemChanged
549 * Purpose : [slot] called when table item changed
551 //============================================================================
552 void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem)
554 if(isProcessItemChangedSignal) {
555 bool isModified = true;
556 NoteBook_TableRow* aRow = GetRowByItem(theItem);
558 int aCurrentColumn = column(theItem);
559 bool IsCorrect = true, IsVariableComplited = false;
562 if(aCurrentColumn == NAME_COLUMN) {
563 int anIndex = aRow->GetIndex();
564 if( myVariableMap.contains( anIndex ) )
566 const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
567 if( !aVariable.Name.isEmpty() && SalomeApp_Application::getStudy()->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) )
569 if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
570 tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ),
571 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
573 bool isBlocked = blockSignals( true );
574 aRow->SetName( aVariable.Name );
575 blockSignals( isBlocked );
582 //Case when variable name was changed.
583 if(aCurrentColumn == NAME_COLUMN) {
584 if(!aRow->CheckName()) {
586 aMsg = tr( "VARNAME_INCORRECT" ).arg(aRow->GetName());
588 else if(!IsUniqueName(aRow)) {
590 aMsg = tr( "VARNAME_EXISTS" ).arg(aRow->GetName());
593 IsVariableComplited = aRow->CheckValue();
596 //Case when variable value was changed.
597 else if(aCurrentColumn == VALUE_COLUMN){
598 if(!aRow->CheckValue()) {
600 aMsg = tr( "VARVALUE_INCORRECT" ).arg(aRow->GetName());
603 IsVariableComplited = aRow->CheckName() && IsUniqueName(aRow);
606 if(!IsCorrect && !aMsg.isEmpty())
607 SUIT_MessageBox::warning( parentWidget(), tr( "WARNING" ), aMsg );
609 bool isBlocked = blockSignals( true );
610 theItem->setForeground( QBrush( IsCorrect ? Qt::black : Qt::red ) );
611 blockSignals( isBlocked );
613 int anIndex = aRow->GetIndex();
614 if( myVariableMap.contains( anIndex ) )
616 NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
617 if( aVariable.Name.compare( aRow->GetName() ) != 0 ||
618 aVariable.Value.compare( aRow->GetValue() ) != 0 )
620 aVariable.Name = aRow->GetName();
621 aVariable.Value = aRow->GetValue();
627 if(IsCorrect && IsVariableComplited && IsLastRow(aRow))
630 if( aRow->CheckName() && aRow->CheckValue() )
631 qobject_cast<SalomeApp_NoteBook*>(parentWidget())->onApply();
635 myIsModified = isModified;
639 //============================================================================
640 /*! Function : IsUniqueName
641 * Purpose : Return true if theName is unique name of the Variable
643 //============================================================================
644 bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const
646 for(int i=0; i<myRows.size();i++) {
647 if(myRows[i] == theRow )
649 if(myRows[i]->GetName().compare(theRow->GetName()) == 0)
655 //============================================================================
656 /*! Function : RemoveSelected
657 * Purpose : Remove selected rows in the table
659 //============================================================================
660 void NoteBook_Table::RemoveSelected()
662 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
663 isProcessItemChangedSignal = false;
664 QList<QTableWidgetItem*> aSelectedItems = selectedItems();
665 if( !(aSelectedItems.size() > 0)) {
666 isProcessItemChangedSignal = true;
669 bool removedFromStudy = false;
670 for(int i=0; i < aSelectedItems.size(); i++ ) {
671 NoteBook_TableRow* aRow = GetRowByItem(aSelectedItems[i]);
673 if(IsLastRow(aRow)) {
674 aRow->SetName(QString());
675 aRow->SetValue(QString());
678 int nRow = row(aSelectedItems[i]);
680 if( aStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) )
682 if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
683 tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ),
684 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
686 isProcessItemChangedSignal = true;
691 int index = aRow->GetIndex();
692 QString aVarName = aRow->GetName();
693 myRemovedRows.append( index );
694 if( myVariableMap.contains( index ) )
695 myVariableMap.remove( index );
697 myRows.removeAt(nRow);
698 if(aStudy->IsVariable(aVarName.toLatin1().constData()))
699 removedFromStudy = true;
706 isProcessItemChangedSignal = true;
709 //============================================================================
710 /*! Function : SetProcessItemChangedSignalFlag
713 //============================================================================
714 void NoteBook_Table::SetProcessItemChangedSignalFlag(const bool enable)
716 isProcessItemChangedSignal = enable;
719 //============================================================================
720 /*! Function : GetProcessItemChangedSignalFlag
723 //============================================================================
724 bool NoteBook_Table::GetProcessItemChangedSignalFlag() const
726 return isProcessItemChangedSignal;
729 //============================================================================
730 /*! Function : GetRows
733 //============================================================================
734 QList<NoteBook_TableRow*> NoteBook_Table::GetRows() const
739 //============================================================================
740 /*! Function : ResetMaps
741 * Purpose : Reset variable maps
743 //============================================================================
744 void NoteBook_Table::ResetMaps()
746 myIsModified = false;
747 myVariableMapRef = myVariableMap;
748 myRemovedRows.clear();
751 ///////////////////////////////////////////////////////////////////////////
752 // SalomeApp_NoteBook class //
753 ///////////////////////////////////////////////////////////////////////////
754 //============================================================================
755 /*! Function : SalomeApp_NoteBook
756 * Purpose : Constructor
758 //============================================================================
759 SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent):
762 setObjectName("SalomeApp_NoteBook");
763 setWindowTitle(tr("NOTEBOOK_TITLE"));
764 QGridLayout* aLayout = new QGridLayout(this);
767 myTable = new NoteBook_Table(this);
768 aLayout->addWidget(myTable, 0, 0, 1, 3);
771 myRemoveButton = new QPushButton(tr("BUT_REMOVE"));
772 aLayout->addWidget(myRemoveButton, 1, 0);
774 QSpacerItem* spacer =
775 new QSpacerItem(DEFAULT_SPACING, 5 , QSizePolicy::Expanding, QSizePolicy::Minimum);
776 aLayout->addItem(spacer, 1, 1);
778 myUpdateStudyBtn = new QPushButton(tr("BUT_UPDATE_STUDY"));
779 aLayout->addWidget(myUpdateStudyBtn, 1, 2);
781 QWidgetList aWidgetList;
782 aWidgetList.append( myTable );
783 aWidgetList.append( myUpdateStudyBtn );
784 aWidgetList.append( myRemoveButton );
785 Qtx::setTabOrder( aWidgetList );
787 connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) );
788 connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
792 myDumpedStudyScript = "";
793 myIsDumpedStudySaved = false;
796 //============================================================================
797 /*! Function : ~SalomeApp_NoteBook
798 * Purpose : Destructor
800 //============================================================================
801 SalomeApp_NoteBook::~SalomeApp_NoteBook(){}
804 //============================================================================
805 /*! Function : Init()
806 * Purpose : init variable table
808 //============================================================================
809 void SalomeApp_NoteBook::Init(){
814 //============================================================================
815 /*! Function : onVarUpdate
818 //============================================================================
819 void SalomeApp_NoteBook::onVarUpdate(QString theVarName)
824 //============================================================================
825 /*! Function : onApply
828 //============================================================================
829 void SalomeApp_NoteBook::onApply()
831 if( !myTable->IsValid() )
833 SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) );
836 _PTR(Study) aStudy = SalomeApp_Application::getStudy();
842 const QList<int>& aRemovedRows = myTable->GetRemovedRows();
843 const VariableMap& aVariableMap = myTable->GetVariableMap();
844 const VariableMap& aVariableMapRef = myTable->GetVariableMapRef();
846 for( QListIterator<int> anIter( aRemovedRows ); anIter.hasNext(); )
848 int anIndex = anIter.next();
849 if( aVariableMapRef.contains( anIndex ) )
851 QString aRemovedVariable = aVariableMapRef[ anIndex ].Name;
852 aStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) );
856 VariableMap::const_iterator it = aVariableMap.constBegin(), itEnd = aVariableMap.constEnd();
857 for( ; it != itEnd; ++it )
859 int anIndex = it.key();
860 const NoteBoox_Variable& aVariable = it.value();
861 QString aName = aVariable.Name;
862 QString aValue = aVariable.Value;
864 if( !aName.isEmpty() && !aValue.isEmpty() )
866 if( aVariableMapRef.contains( anIndex ) )
868 const NoteBoox_Variable& aVariableRef = aVariableMapRef[ anIndex ];
869 QString aNameRef = aVariableRef.Name;
870 QString aValueRef = aVariableRef.Value;
872 if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName )
874 aStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ),
875 std::string( aName.toLatin1().constData() ) );
879 if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) )
880 aStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal);
882 else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) )
883 aStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal);
885 else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) )
886 aStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal);
889 aStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString());
892 myTable->ResetMaps();
894 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
896 app->updateActions();
901 //============================================================================
902 /*! Function : onRemove
905 //============================================================================
906 void SalomeApp_NoteBook::onRemove()
908 myTable->RemoveSelected();
912 //============================================================================
913 /*! Function : onUpdateStudy
916 //============================================================================
917 void SalomeApp_NoteBook::onUpdateStudy()
920 if( !myTable->IsValid() )
923 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
926 app->onUpdateStudy();