</ul>
To confirm your choice click \b Save.
+<b>Notebook</b> - allows to manage study variables using \subpage using_notebook "NoteBook".
+
<b>Load Script</b> - allows to load a saved Python Script.
\image html loadscript.png
--- /dev/null
+/*!
+
+\page using_notebook Using NoteBook
+
+SALOME <b>NoteBook</b> is destined for managing numerical and boolean
+parameters (variables) which are used to create and modify objects in
+different components.
+
+To open the <b>NoteBook</b> choose <b>File > Notebook</b>, the following
+dialog box will appear:
+
+\image html notebook1.png
+
+Here you can add new variables, remove and rename existing variables and
+change their values.
+
+If you have modified some variables, which are already used in the current
+study, you should click <b>Update Study</b> button to apply your changes
+to the study.
+
+\note The dialog will not be validated until at least one of variables in
+the table has invalid name or value (marked by red color). Names of
+variables should be unique and their values should be numerical (integer or
+double) or boolean ("True" / "False").
+
+*/
\ No newline at end of file
SalomeApp_StudyPropertiesDlg.h \
SalomeApp_CheckFileDlg.h \
SalomeApp_VisualState.h \
- SalomeApp_ExitDlg.h
+ SalomeApp_ExitDlg.h \
+ SalomeApp_NoteBookDlg.h \
+ SalomeApp_DoubleSpinBox.h \
+ SalomeApp_IntSpinBox.h
dist_libSalomeApp_la_SOURCES = \
SalomeApp_Module.cxx \
SalomeApp_ListView.cxx \
SalomeApp_CheckFileDlg.cxx \
SalomeApp_VisualState.cxx \
- SalomeApp_ExitDlg.cxx
+ SalomeApp_ExitDlg.cxx \
+ SalomeApp_NoteBookDlg.cxx \
+ SalomeApp_DoubleSpinBox.cxx \
+ SalomeApp_IntSpinBox.cxx
MOC_FILES = \
SalomeApp_Application_moc.cxx \
SalomeApp_StudyPropertiesDlg_moc.cxx \
SalomeApp_ListView_moc.cxx \
SalomeApp_CheckFileDlg_moc.cxx \
- SalomeApp_ExitDlg_moc.cxx
+ SalomeApp_ExitDlg_moc.cxx \
+ SalomeApp_NoteBookDlg_moc.cxx \
+ SalomeApp_DoubleSpinBox_moc.cxx \
+ SalomeApp_IntSpinBox_moc.cxx
nodist_libSalomeApp_la_SOURCES = $(MOC_FILES)
#include "SalomeApp_VisualState.h"
#include "SalomeApp_StudyPropertiesDlg.h"
#include "SalomeApp_LoadStudiesDlg.h"
+#include "SalomeApp_NoteBookDlg.h"
+
#include "SalomeApp_ExitDlg.h"
#include <LightApp_Application.h>
/*!Constructor.*/
SalomeApp_Application::SalomeApp_Application()
-: LightApp_Application()
+ : LightApp_Application()
{
connect( desktop(), SIGNAL( message( const QString& ) ),
this, SLOT( onDesktopMessage( const QString& ) ) );
+ setNoteBook(0);
}
/*!Destructor.
tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) );
+ //! NoteBook
+ createAction(NoteBookId, tr( "TOT_DESK_FILE_NOTEBOOK" ), QIcon(),
+ tr( "MEN_DESK_FILE_NOTEBOOK" ), tr( "PRP_DESK_FILE_NOTEBOOK" ),
+ Qt::CTRL+Qt::Key_K, desk, false, this, SLOT(onNoteBook()));
+
//! Load script
createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(),
tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
createMenu( DumpStudyId, fileMenu, 10, -1 );
+ createMenu( NoteBookId, fileMenu, 10, -1 );
createMenu( separator(), fileMenu, -1, 10, -1 );
createMenu( LoadScriptId, fileMenu, 10, -1 );
createMenu( separator(), fileMenu, -1, 10, -1 );
}
LightApp_Application::onCloseDoc( ask );
+ if(myNoteBook && myNoteBook->isVisible())
+ myNoteBook->hide();
}
/*!Sets enable or disable some actions on selection changed.*/
if ( a )
a->setEnabled( activeStudy() );
+ // Note Book
+ a = action(NoteBookId);
+ if( a )
+ a->setEnabled( activeStudy() );
+
// Load script menu
a = action( LoadScriptId );
if ( a )
}
}
+/*!Private SLOT. On NoteBook*/
+void SalomeApp_Application::onNoteBook()
+{
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( appStudy ) {
+ _PTR(Study) aStudy = appStudy->studyDS();
+ if(!myNoteBook) {
+ myNoteBook = new SalomeApp_NoteBookDlg(desktop(),aStudy);
+ }
+ else if(!myNoteBook->isVisible()){
+ myNoteBook->Init(aStudy);
+ myNoteBook->adjustSize();
+ myNoteBook->move((int)(desktop()->x() + desktop()->width()/2 - myNoteBook->frameGeometry().width()/2),
+ (int)(desktop()->y() + desktop()->height()/2 - myNoteBook->frameGeometry().height()/2));
+ }
+ myNoteBook->show();
+ }
+}
+
/*!Private SLOT. On load script.*/
void SalomeApp_Application::onLoadScript( )
{
objectBrowser()->treeView()->setColumnHidden( i, !shown );
}
}
+
+/*! Set SalomeApp_NoteBookDlg pointer */
+void SalomeApp_Application::setNoteBook(SalomeApp_NoteBookDlg* theNoteBook){
+ myNoteBook = theNoteBook;
+}
+
+/*! Return SalomeApp_NoteBookDlg pointer */
+SalomeApp_NoteBookDlg* SalomeApp_Application::getNoteBook() const
+{
+ return myNoteBook;
+}
+
class LightApp_Preferences;
class SalomeApp_Study;
+class SalomeApp_NoteBookDlg;
class SUIT_DataObject;
class SALOME_LifeCycleCORBA;
public:
enum { MenuToolsId = 5 };
enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
- CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID };
+ CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, NoteBookId, UserID };
protected:
enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
virtual bool useStudy( const QString& );
virtual void updateDesktopTitle();
+
+ virtual void setNoteBook(SalomeApp_NoteBookDlg* theNoteBook);
+ virtual SalomeApp_NoteBookDlg* getNoteBook() const;
public slots:
virtual void onLoadDoc();
void onDblClick( SUIT_DataObject* );
void onProperties();
void onDumpStudy();
+ void onNoteBook();
void onLoadScript();
void onDeleteGUIState();
void onCatalogGen();
void onRegDisplay();
void onOpenWith();
+
+ private:
+ SalomeApp_NoteBookDlg* myNoteBook;
};
#ifdef WIN32
QString val;
_PTR(GenericAttribute) attr;
- if ( obj->FindAttribute( attr, "AttributeInteger" ) )
+ if ( obj->FindAttribute( attr, "AttributeString" ) )
+ {
+ _PTR(AttributeString) strAttr = attr;
+ std::string str = strAttr->Value();
+ QString aStrings = QString( str.c_str() );
+
+ //Special case to show NoteBook variables in the "Value" column of the OB
+ if ( LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() ) )
+ {
+ if ( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( aRoot->study() ) )
+ {
+ _PTR(Study) studyDS( aStudy->studyDS() );
+
+ bool ok = false;
+ QStringList aSectionList = aStrings.split( "|" );
+ if ( !aSectionList.isEmpty() )
+ {
+ QString aLastSection = aSectionList.last();
+ QStringList aStringList = aLastSection.split( ":" );
+ if ( !aStringList.isEmpty() )
+ {
+ ok = true;
+ for ( int i = 0, n = aStringList.size(); i < n; i++ )
+ {
+ QString aStr = aStringList[i];
+ if ( studyDS->IsVariable( aStr.toStdString() ) )
+ val.append( aStr + ", " );
+ }
+
+ if ( !val.isEmpty() )
+ val.remove( val.length() - 2, 2 );
+ }
+ }
+ if( !ok )
+ val = aStrings;
+ }
+ }
+ }
+ else if ( obj->FindAttribute( attr, "AttributeInteger" ) )
{
_PTR(AttributeInteger) intAttr = attr;
if ( intAttr )
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_DoubleSpinBox.cxx
+// Author: Oleg UVAROV
+
+#include "SalomeApp_DoubleSpinBox.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+
+#include <SUIT_Session.h>
+
+#include "SALOMEDSClient_ClientFactory.hxx"
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+#include <QKeyEvent>
+#include <QLineEdit>
+
+/*!
+ \class SalomeApp_DoubleSpinBox
+*/
+
+/*!
+ \brief Constructor.
+
+ Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value,
+ a step value of 1.0 and a precision of 2 decimal places.
+ The value is initially set to 0.00.
+
+ \param parent parent object
+*/
+SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( QWidget* parent )
+: QtxDoubleSpinBox( parent ),
+ myDefaultValue( 0.0 ),
+ myIsRangeSet( false ),
+ myMinimum( 0.0 ),
+ myMaximum( 99.99 )
+{
+ connectSignalsAndSlots();
+}
+
+/*!
+ \brief Constructor.
+
+ Constructs a spin box with specified minimum, maximum and step value.
+ The precision is set to 2 decimal places.
+ The value is initially set to the minimum value.
+
+ \param min spin box minimum possible value
+ \param max spin box maximum possible value
+ \param step spin box increment/decrement value
+ \param parent parent object
+*/
+SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( double min, double max, double step, QWidget* parent )
+: QtxDoubleSpinBox( min, max, step, parent ),
+ myDefaultValue( 0.0 ),
+ myIsRangeSet( false ),
+ myMinimum( min ),
+ myMaximum( max )
+{
+ connectSignalsAndSlots();
+}
+
+/*!
+ \brief Constructor.
+
+ Constructs a spin box with specified minimum, maximum and step value.
+ The precision is set to 2 decimal places.
+ The value is initially set to the minimum value.
+
+ \param min spin box minimum possible value
+ \param max spin box maximum possible value
+ \param step spin box increment/decrement value
+ \param parent parent object
+*/
+SalomeApp_DoubleSpinBox::SalomeApp_DoubleSpinBox( double min, double max, double step, int prec, int dec, QWidget* parent )
+: QtxDoubleSpinBox( min, max, step, prec, dec, parent ),
+ myDefaultValue( 0.0 ),
+ myIsRangeSet( false ),
+ myMinimum( min ),
+ myMaximum( max )
+{
+ connectSignalsAndSlots();
+}
+
+/*!
+ \brief Destructor.
+*/
+SalomeApp_DoubleSpinBox::~SalomeApp_DoubleSpinBox()
+{
+}
+
+/*!
+ \brief Connect signals and slots.
+*/
+void SalomeApp_DoubleSpinBox::connectSignalsAndSlots()
+{
+ connect( this, SIGNAL( editingFinished() ),
+ this, SLOT( onEditingFinished() ) );
+
+ connect( this, SIGNAL( valueChanged( const QString& ) ),
+ this, SLOT( onTextChanged( const QString& ) ) );
+
+ connect( lineEdit(), SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( onTextChanged( const QString& ) ) );
+
+ connect( lineEdit(), SIGNAL( textChanged( const QString& )),
+ this, SIGNAL( textChanged( const QString& ) ) );
+}
+
+/*!
+ \brief This function is called when editing is finished.
+*/
+void SalomeApp_DoubleSpinBox::onEditingFinished()
+{
+ if( myTextValue.isNull() )
+ myTextValue = text();
+
+ setText( myTextValue );
+}
+
+/*!
+ \brief This function is called when value is changed.
+*/
+void SalomeApp_DoubleSpinBox::onTextChanged( const QString& text )
+{
+ myTextValue = text;
+
+ double value = 0;
+ if( isValid( text, value ) == Acceptable )
+ myCorrectValue = text;
+}
+
+/*!
+ \brief Interpret text entered by the user as a value.
+ \param text text entered by the user
+ \return mapped value
+ \sa textFromValue()
+*/
+double SalomeApp_DoubleSpinBox::valueFromText( const QString& text ) const
+{
+ double value = 0;
+ if( isValid( text, value ) == Acceptable )
+ return value;
+
+ return defaultValue();
+}
+
+/*!
+ \brief This function is used by the spin box whenever it needs to display
+ the given value.
+
+ \param val spin box value
+ \return text representation of the value
+ \sa valueFromText()
+*/
+QString SalomeApp_DoubleSpinBox::textFromValue( double val ) const
+{
+ return QtxDoubleSpinBox::textFromValue( val );
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \param str currently entered value
+ \param pos cursor position in the string
+ \return validating operation result
+*/
+QValidator::State SalomeApp_DoubleSpinBox::validate( QString& str, int& pos ) const
+{
+ return QValidator::Acceptable;
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \return validating operation result
+*/
+bool SalomeApp_DoubleSpinBox::isValid( QString& msg, bool toCorrect )
+{
+ double value;
+ State aState = isValid( text(), value );
+
+ if( aState != Acceptable )
+ {
+ if( toCorrect )
+ {
+ if( aState == Incompatible )
+ msg += tr( "ERR_INCOMPATIBLE_TYPE" ).arg( text() ) + "\n";
+ else if( aState == NoVariable )
+ msg += tr( "ERR_NO_VARIABLE" ).arg( text() ) + "\n";
+ else if( aState == Invalid )
+ msg += tr( "ERR_INVALID_VALUE" ) + "\n";
+
+ setText( myCorrectValue );
+ }
+ return false;
+ }
+
+ return true;
+}
+
+/*!
+ \brief This function is used to set a default value for this spinbox.
+ \param value default value
+*/
+void SalomeApp_DoubleSpinBox::setDefaultValue( const double value )
+{
+ myDefaultValue = value;
+}
+
+/*!
+ \brief This function is used to set minimum and maximum values for this spinbox.
+ \param min minimum value
+ \param max maximum value
+*/
+void SalomeApp_DoubleSpinBox::setRange( const double min, const double max )
+{
+ QtxDoubleSpinBox::setRange( min, max );
+
+ myIsRangeSet = true;
+ myMinimum = min;
+ myMaximum = max;
+}
+
+/*!
+ \brief This function is used to set a current value for this spinbox.
+ \param value current value
+*/
+void SalomeApp_DoubleSpinBox::setValue( const double value )
+{
+ QtxDoubleSpinBox::setValue( value );
+
+ myCorrectValue = QString::number( value );
+ myTextValue = myCorrectValue;
+}
+
+/*!
+ \brief This function is used to set a text for this spinbox.
+ \param value current value
+*/
+void SalomeApp_DoubleSpinBox::setText( const QString& value )
+{
+ lineEdit()->setText(value);
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \return validating operation result
+*/
+SalomeApp_DoubleSpinBox::State SalomeApp_DoubleSpinBox::isValid( const QString& text, double& value ) const
+{
+ SearchState aSearchState = findVariable( text, value );
+ if( aSearchState == NotFound )
+ {
+ bool ok = false;
+ value = text.toDouble( &ok );
+ if( !ok )
+ return NoVariable;
+ }
+ else if( aSearchState == IncorrectType )
+ return Incompatible;
+
+ if( !checkRange( value ) )
+ return Invalid;
+
+ return Acceptable;
+}
+
+/*!
+ \brief This function return a default acceptable value (commonly, 0.0).
+ \return default acceptable value
+*/
+double SalomeApp_DoubleSpinBox::defaultValue() const
+{
+ if( myMinimum > myDefaultValue || myMaximum < myDefaultValue )
+ return myMinimum;
+
+ return myDefaultValue;
+}
+
+/*!
+ \brief This function is used to check that string value lies within predefined range.
+ \return check status
+*/
+bool SalomeApp_DoubleSpinBox::checkRange( const double value ) const
+{
+ if( !myIsRangeSet )
+ return true;
+
+ return value >= myMinimum && value <= myMaximum;
+}
+
+/*!
+ \brief This function is used to determine whether input is a variable name and to get its value.
+ \return status of search operation
+*/
+SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( const QString& name, double& value ) const
+{
+ value = 0;
+ if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ {
+ if( SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
+ {
+ _PTR(Study) studyDS = study->studyDS();
+
+ std::string aName = name.toStdString();
+ if( studyDS->IsVariable( aName ) )
+ {
+ if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) )
+ {
+ value = studyDS->GetReal( aName );
+ return Found;
+ }
+ return IncorrectType;
+ }
+ }
+ }
+ return NotFound;
+}
+
+/*!
+ \brief This function is called when the spinbox recieves key press event.
+*/
+void SalomeApp_DoubleSpinBox::keyPressEvent( QKeyEvent* e )
+{
+ if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
+ QWidget::keyPressEvent( e );
+ else
+ QtxDoubleSpinBox::keyPressEvent( e );
+}
+
+/*!
+ \brief This function is called when the spinbox recieves show event.
+*/
+void SalomeApp_DoubleSpinBox::showEvent( QShowEvent* )
+{
+ setText( myTextValue );
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_DoubleSpinBox.h
+// Author: Oleg UVAROV
+
+#ifndef SALOMEAPP_DOUBLESPINBOX_H
+#define SALOMEAPP_DOUBLESPINBOX_H
+
+#include "SalomeApp.h"
+
+#include <QtxDoubleSpinBox.h>
+
+#include <QValidator>
+
+class SALOMEAPP_EXPORT SalomeApp_DoubleSpinBox : public QtxDoubleSpinBox
+{
+ Q_OBJECT
+
+ enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
+ enum SearchState { NotFound = 0, IncorrectType, Found };
+
+public:
+ SalomeApp_DoubleSpinBox( QWidget* = 0 );
+ SalomeApp_DoubleSpinBox( double, double, double = 1, QWidget* = 0 );
+ SalomeApp_DoubleSpinBox( double, double, double, int, int, QWidget* = 0 );
+ virtual ~SalomeApp_DoubleSpinBox();
+
+ virtual double valueFromText( const QString& ) const;
+ virtual QString textFromValue( double ) const;
+
+ virtual QValidator::State validate( QString&, int& ) const;
+
+ virtual bool isValid( QString& msg, bool = false );
+
+ virtual void setDefaultValue( const double );
+
+ virtual void setRange( double, double );
+ virtual void setValue( double );
+
+ virtual void setText(const QString& );
+
+signals:
+ void textChanged( const QString& );
+
+protected:
+ State isValid( const QString&, double& ) const;
+
+ double defaultValue() const;
+ bool checkRange( const double ) const;
+
+ SearchState findVariable( const QString&, double& ) const;
+
+protected:
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void showEvent( QShowEvent* );
+
+protected slots:
+ void onEditingFinished();
+ void onTextChanged( const QString& );
+
+private:
+ void connectSignalsAndSlots();
+
+private:
+ double myDefaultValue;
+
+ bool myIsRangeSet;
+ double myMinimum;
+ double myMaximum;
+
+ QString myCorrectValue;
+ QString myTextValue;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_IntSpinBox.cxx
+// Author: Oleg UVAROV
+
+#include "SalomeApp_IntSpinBox.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+
+#include <SUIT_Session.h>
+
+#include "SALOMEDSClient_ClientFactory.hxx"
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+#include <QKeyEvent>
+#include <QLineEdit>
+
+/*!
+ \class SalomeApp_IntSpinBox
+*/
+
+/*!
+ \brief Constructor.
+
+ Constructs a spin box with 0 as minimum value and 99 as maximum value,
+ a step value of 1. The value is initially set to 0.
+
+ \param parent parent object
+*/
+SalomeApp_IntSpinBox::SalomeApp_IntSpinBox( QWidget* parent )
+: QtxIntSpinBox( parent ),
+ myDefaultValue( 0 )
+{
+ connectSignalsAndSlots();
+}
+
+/*!
+ \brief Constructor.
+
+ Constructs a spin box with specified minimum, maximum and step value.
+ The value is initially set to the minimum value.
+
+ \param min spin box minimum possible value
+ \param max spin box maximum possible value
+ \param step spin box increment/decrement value
+ \param parent parent object
+*/
+SalomeApp_IntSpinBox::SalomeApp_IntSpinBox( int min, int max, int step, QWidget* parent )
+: QtxIntSpinBox( min, max, step, parent ),
+ myDefaultValue( 0 )
+{
+ connectSignalsAndSlots();
+}
+
+/*!
+ \brief Destructor.
+*/
+SalomeApp_IntSpinBox::~SalomeApp_IntSpinBox()
+{
+}
+
+/*!
+ \brief Connect signals and slots.
+*/
+void SalomeApp_IntSpinBox::connectSignalsAndSlots()
+{
+ connect( this, SIGNAL( editingFinished() ),
+ this, SLOT( onEditingFinished() ) );
+
+ connect( this, SIGNAL( valueChanged( const QString& ) ),
+ this, SLOT( onTextChanged( const QString& ) ) );
+
+ connect( lineEdit(), SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( onTextChanged( const QString& ) ) );
+
+ connect( lineEdit(), SIGNAL( textChanged( const QString& )),
+ this, SIGNAL( textChanged( const QString& ) ) );
+}
+
+/*!
+ \brief This function is called when editing is finished.
+*/
+void SalomeApp_IntSpinBox::onEditingFinished()
+{
+ if( myTextValue.isNull() )
+ myTextValue = text();
+
+ setText( myTextValue );
+}
+
+/*!
+ \brief This function is called when value is changed.
+*/
+void SalomeApp_IntSpinBox::onTextChanged( const QString& text )
+{
+ myTextValue = text;
+
+ int value = 0;
+ if( isValid( text, value ) == Acceptable )
+ myCorrectValue = text;
+}
+
+/*!
+ \brief Interpret text entered by the user as a value.
+ \param text text entered by the user
+ \return mapped value
+ \sa textFromValue()
+*/
+int SalomeApp_IntSpinBox::valueFromText( const QString& text ) const
+{
+ int value = 0;
+ if( isValid( text, value ) == Acceptable )
+ return value;
+
+ return defaultValue();
+}
+
+/*!
+ \brief This function is used by the spin box whenever it needs to display
+ the given value.
+
+ \param val spin box value
+ \return text representation of the value
+ \sa valueFromText()
+*/
+QString SalomeApp_IntSpinBox::textFromValue( int val ) const
+{
+ return QtxIntSpinBox::textFromValue( val );
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \param str currently entered value
+ \param pos cursor position in the string
+ \return validating operation result
+*/
+QValidator::State SalomeApp_IntSpinBox::validate( QString& str, int& pos ) const
+{
+ return QValidator::Acceptable;
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \return validating operation result
+*/
+bool SalomeApp_IntSpinBox::isValid( QString& msg, bool toCorrect )
+{
+ int value;
+ State aState = isValid( text(), value );
+
+ if( aState != Acceptable )
+ {
+ if( toCorrect )
+ {
+ if( aState == Incompatible )
+ msg += tr( "ERR_INCOMPATIBLE_TYPE" ).arg( text() ) + "\n";
+ else if( aState == NoVariable )
+ msg += tr( "ERR_NO_VARIABLE" ).arg( text() ) + "\n";
+ else if( aState == Invalid )
+ msg += tr( "ERR_INVALID_VALUE" ) + "\n";
+
+ setText( myCorrectValue );
+ }
+ return false;
+ }
+
+ return true;
+}
+
+/*!
+ \brief This function is used to set a default value for this spinbox.
+ \param value default value
+*/
+void SalomeApp_IntSpinBox::setDefaultValue( const int value )
+{
+ myDefaultValue = value;
+}
+
+/*!
+ \brief This function is used to set a current value for this spinbox.
+ \param value current value
+*/
+void SalomeApp_IntSpinBox::setValue( const int value )
+{
+ QtxIntSpinBox::setValue( value );
+
+ myCorrectValue = QString::number( value );
+ myTextValue = myCorrectValue;
+}
+
+/*!
+ \brief This function is used to set a text for this spinbox.
+ \param value current value
+*/
+void SalomeApp_IntSpinBox::setText( const QString& value )
+{
+ lineEdit()->setText(value);
+}
+
+/*!
+ \brief This function is used to determine whether input is valid.
+ \return validating operation result
+*/
+SalomeApp_IntSpinBox::State SalomeApp_IntSpinBox::isValid( const QString& text, int& value ) const
+{
+ SearchState aSearchState = findVariable( text, value );
+ if( aSearchState == NotFound )
+ {
+ bool ok = false;
+ value = text.toInt( &ok );
+ if( !ok )
+ {
+ text.toDouble( &ok );
+ if( ok )
+ return Invalid;
+ return NoVariable;
+ }
+ }
+ else if( aSearchState == IncorrectType )
+ return Incompatible;
+
+ if( !checkRange( value ) )
+ return Invalid;
+
+ return Acceptable;
+}
+
+/*!
+ \brief This function return a default acceptable value (commonly, 0).
+ \return default acceptable value
+*/
+int SalomeApp_IntSpinBox::defaultValue() const
+{
+ if( minimum() > myDefaultValue || maximum() < myDefaultValue )
+ return minimum();
+
+ return myDefaultValue;
+}
+
+/*!
+ \brief This function is used to check that string value lies within predefined range.
+ \return check status
+*/
+bool SalomeApp_IntSpinBox::checkRange( const int value ) const
+{
+ return value >= minimum() && value <= maximum();
+}
+
+/*!
+ \brief This function is used to determine whether input is a variable name and to get its value.
+ \return status of search operation
+*/
+SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QString& name, int& value ) const
+{
+ value = 0;
+ if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) )
+ {
+ if( SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
+ {
+ _PTR(Study) studyDS = study->studyDS();
+
+ std::string aName = name.toStdString();
+ if( studyDS->IsVariable( aName ) )
+ {
+ if( studyDS->IsInteger( aName ) )
+ {
+ value = studyDS->GetInteger( aName );
+ return Found;
+ }
+ return IncorrectType;
+ }
+ }
+ }
+ return NotFound;
+}
+
+/*!
+ \brief This function is called when the spinbox recieves key press event.
+*/
+void SalomeApp_IntSpinBox::keyPressEvent( QKeyEvent* e )
+{
+ if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
+ QWidget::keyPressEvent( e );
+ else
+ QtxIntSpinBox::keyPressEvent( e );
+}
+
+/*!
+ \brief This function is called when the spinbox recieves show event.
+*/
+void SalomeApp_IntSpinBox::showEvent( QShowEvent* )
+{
+ setText( myTextValue );
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_IntSpinBox.h
+// Author: Oleg UVAROV
+
+#ifndef SALOMEAPP_INTSPINBOX_H
+#define SALOMEAPP_INTSPINBOX_H
+
+#include "SalomeApp.h"
+
+#include <QtxIntSpinBox.h>
+
+#include <QValidator>
+
+class SALOMEAPP_EXPORT SalomeApp_IntSpinBox : public QtxIntSpinBox
+{
+ Q_OBJECT
+
+ enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
+ enum SearchState { NotFound = 0, IncorrectType, Found };
+
+public:
+ SalomeApp_IntSpinBox( QWidget* = 0 );
+ SalomeApp_IntSpinBox( int, int, int = 1, QWidget* = 0 );
+ virtual ~SalomeApp_IntSpinBox();
+
+ virtual int valueFromText( const QString& ) const;
+ virtual QString textFromValue( int ) const;
+
+ virtual QValidator::State validate( QString&, int& ) const;
+
+ virtual bool isValid( QString& msg, bool = false );
+
+ virtual void setDefaultValue( const int );
+
+ virtual void setValue( int );
+
+ virtual void setText(const QString& );
+
+signals:
+ void textChanged( const QString& );
+
+protected:
+ State isValid( const QString&, int& ) const;
+
+ int defaultValue() const;
+ bool checkRange( const int ) const;
+
+ SearchState findVariable( const QString&, int& ) const;
+
+protected:
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void showEvent( QShowEvent* );
+
+protected slots:
+ void onEditingFinished();
+ void onTextChanged( const QString& );
+
+private:
+ void connectSignalsAndSlots();
+
+private:
+ int myDefaultValue;
+
+ QString myCorrectValue;
+ QString myTextValue;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2008 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_NoteBookDlg.cxx
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S.
+// Module : GUI
+
+#include "SalomeApp_NoteBookDlg.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_VisualState.h"
+
+#include <Qtx.h>
+
+#include <CAM_Module.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <PyConsole_Console.h>
+
+#include <SALOMEDS_Tool.hxx>
+
+#include <QWidget>
+#include <QDialog>
+#include <QGridLayout>
+#include <QTableWidget>
+#include <QTableWidgetItem>
+#include <QPushButton>
+#include <QFont>
+#include <QGroupBox>
+#include <QList>
+#include <QApplication>
+#include <QDir>
+
+#include <string>
+#include <vector>
+
+using namespace std;
+
+#define DEFAULT_MARGIN 11
+#define DEFAULT_SPACING 6
+#define SPACER_SIZE 120
+#define COLUMN_SIZE 180
+
+#define NAME_COLUMN 0
+#define VALUE_COLUMN 1
+
+
+///////////////////////////////////////////////////////////////////////////
+// NoteBook_TableRow class //
+///////////////////////////////////////////////////////////////////////////
+//============================================================================
+/*! Function : NoteBook_TableRow
+ * Purpose : Constructor
+ */
+//============================================================================
+NoteBook_TableRow::NoteBook_TableRow(int index, QWidget* parent):
+ QWidget(parent),
+ myIndex(index),
+ myRowHeader(new QTableWidgetItem()),
+ myVariableName(new QTableWidgetItem()),
+ myVariableValue(new QTableWidgetItem())
+{
+}
+
+//============================================================================
+/*! Function : ~NoteBook_TableRow
+ * Purpose : Destructor
+ */
+//============================================================================
+NoteBook_TableRow::~NoteBook_TableRow()
+{
+}
+
+//============================================================================
+/*! Function : AddToTable
+ * Purpose : Add this row to the table theTable
+ */
+//============================================================================
+void NoteBook_TableRow::AddToTable(QTableWidget *theTable)
+{
+ int aPosition = theTable->rowCount();
+ int aRowCount = aPosition+1;
+ theTable->setRowCount(aRowCount);
+ myRowHeader->setText(QString::number(aRowCount));
+
+ theTable->setVerticalHeaderItem(aPosition,myRowHeader);
+ theTable->setItem(aPosition, NAME_COLUMN, myVariableName);
+ theTable->setItem(aPosition, VALUE_COLUMN, myVariableValue);
+}
+
+//============================================================================
+/*! Function : SetName
+ * Purpose :
+ */
+//============================================================================
+void NoteBook_TableRow::SetName(const QString theName)
+{
+ myVariableName->setText(theName);
+}
+
+//============================================================================
+/*! Function : SetValue
+ * Purpose :
+ */
+//============================================================================
+void NoteBook_TableRow::SetValue(const QString theValue)
+{
+ myVariableValue->setText(theValue);
+}
+
+//============================================================================
+/*! Function : GetName
+ * Purpose : Return variable name
+ */
+//============================================================================
+QString NoteBook_TableRow::GetName() const
+{
+ return myVariableName->text();
+}
+
+//============================================================================
+/*! Function : GetValue
+ * Purpose : Return variable value
+ */
+//============================================================================
+QString NoteBook_TableRow::GetValue() const
+{
+ return myVariableValue->text();
+}
+
+//============================================================================
+/*! Function : CheckName
+ * Purpose : Return true if variable name correct, otherwise return false
+ */
+//============================================================================
+bool NoteBook_TableRow::CheckName()
+{
+ QString aName = GetName();
+ int aPos = 0;
+ QRegExpValidator aValidator( QRegExp("^([a-zA-Z]+)([a-zA-Z0-9_]*)$"), 0 );
+ if( aName.isEmpty() || !aValidator.validate( aName, aPos ) )
+ return false;
+ return true;
+}
+
+//============================================================================
+/*! Function : CheckValue
+ * Purpose : Return true if variable value correct, otherwise return false
+ */
+//============================================================================
+bool NoteBook_TableRow::CheckValue()
+{
+ bool aResult = false;
+ QString aValue = GetValue();
+ if( (!aValue.isEmpty()) &&
+ (IsRealValue(aValue)) ||
+ IsIntegerValue(aValue)||
+ IsBooleanValue(aValue))
+ aResult = true;
+
+ return aResult;
+}
+
+//============================================================================
+/*! Function : GetVariableItem
+ * Purpose :
+ */
+//============================================================================
+QTableWidgetItem* NoteBook_TableRow::GetVariableItem()
+{
+ return myVariableValue;
+}
+
+//============================================================================
+/*! Function : GetNameItem
+ * Purpose :
+ */
+//============================================================================
+QTableWidgetItem* NoteBook_TableRow::GetNameItem()
+{
+ return myVariableName;
+}
+
+//============================================================================
+/*! Function : GetHeaderItem
+ * Purpose :
+ */
+//============================================================================
+QTableWidgetItem* NoteBook_TableRow::GetHeaderItem()
+{
+ return myRowHeader;
+}
+
+//============================================================================
+/*! Function : IsRealValue
+ * Purpose : Return true if theValue string is real value, otherwise return
+ * false
+ */
+//============================================================================
+bool NoteBook_TableRow::IsRealValue(const QString theValue, double* theResult)
+{
+ bool aResult = false;
+ double aDResult = theValue.toDouble(&aResult);
+ if(theResult)
+ *theResult = aDResult;
+
+ return aResult;
+}
+
+//============================================================================
+/*! Function : IsBooleanValue
+ * Purpose : Return true if theValue String is boolean value, otherwise return
+ * false
+ */
+//============================================================================
+bool NoteBook_TableRow::IsBooleanValue(const QString theValue, bool* theResult){
+ bool aResult = false;
+ bool aBResult;
+ if(theValue.compare("True") == 0) {
+ aBResult = true;
+ aResult = true;
+ }
+ else if(theValue.compare("False") == 0) {
+ aBResult = false;
+ aResult = true;
+ }
+ if(theResult)
+ *theResult = aBResult;
+
+ return aResult;
+}
+
+//============================================================================
+/*! Function : IsIntegerValue
+ * Purpose : Return true if theValue string is integer value, otherwise return
+ * false
+ */
+//============================================================================
+bool NoteBook_TableRow::IsIntegerValue(const QString theValue, int* theResult)
+{
+ bool aResult = false;
+ int anIResult;
+ anIResult = theValue.toInt(&aResult);
+
+ if(theResult)
+ *theResult = anIResult;
+
+ return aResult;
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+// NoteBook_Table class //
+///////////////////////////////////////////////////////////////////////////
+//============================================================================
+/*! Function : NoteBook_Table
+ * Purpose : Constructor
+ */
+//============================================================================
+NoteBook_Table::NoteBook_Table(QWidget * parent)
+ :QTableWidget(parent),
+ isProcessItemChangedSignal(false),
+ myIsModified(false)
+{
+ setColumnCount(2);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+
+ //Add Headers Columns
+ QFont aFont = QFont();
+ aFont.setBold(true);
+ aFont.setPointSize(10);
+
+ //"Name" column
+ QTableWidgetItem * aNameHeader = new QTableWidgetItem();
+ aNameHeader->setText(tr("VARNAME_COLUMN"));
+ aNameHeader->setFont(aFont);
+ setHorizontalHeaderItem(0,aNameHeader);
+ setColumnWidth ( 0, COLUMN_SIZE);
+
+ //"Value" Column
+ QTableWidgetItem * aValueHeader = new QTableWidgetItem();
+ aValueHeader->setText(tr("VARVALUE_COLUMN"));
+ aValueHeader->setFont(aFont);
+ setHorizontalHeaderItem(1,aValueHeader);
+ setColumnWidth ( 1, COLUMN_SIZE);
+ setSortingEnabled(false);
+
+ connect(this,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(onItemChanged(QTableWidgetItem*)));
+}
+
+//============================================================================
+/*! Function : ~NoteBook_Table
+ * Purpose : Destructor
+ */
+//============================================================================
+NoteBook_Table::~NoteBook_Table(){}
+
+//============================================================================
+/*! Function : getUniqueIndex
+ * Purpose : Get a unique index for the new row
+ */
+//============================================================================
+int NoteBook_Table::getUniqueIndex() const
+{
+ int anIndex = 0;
+ if( !myRows.isEmpty() )
+ if( NoteBook_TableRow* aRow = myRows.last() )
+ anIndex = aRow->GetIndex();
+
+ int aMaxRemovedRow = 0;
+ for( QListIterator<int> anIter( myRemovedRows ); anIter.hasNext(); )
+ {
+ int aRemovedRow = anIter.next();
+ aMaxRemovedRow = qMax( aRemovedRow, aMaxRemovedRow );
+ }
+
+ anIndex = qMax( anIndex, aMaxRemovedRow ) + 1;
+ return anIndex;
+}
+
+//============================================================================
+/*! Function : Init
+ * Purpose : Add variables in the table from theStudy
+ */
+//============================================================================
+void NoteBook_Table::Init(_PTR(Study) theStudy)
+{
+ isProcessItemChangedSignal = false;
+
+ int aNumRows = myRows.count();
+ if( aNumRows > 0 )
+ {
+ for( int i = 0; i < myRows.size(); i++ )
+ {
+ NoteBook_TableRow* aRow = myRows[ i ];
+ if( aRow )
+ {
+ delete aRow;
+ aRow = 0;
+ }
+ }
+ myRows.clear();
+ }
+ setRowCount( 0 );
+
+ myRemovedRows.clear();
+ myVariableMapRef.clear();
+ myVariableMap.clear();
+
+ //Add all variables into the table
+ vector<string> aVariables = theStudy->GetVariableNames();
+ for(int iVar = 0; iVar < aVariables.size(); iVar++ ) {
+ AddRow(QString(aVariables[iVar].c_str()),
+ Variable2String(aVariables[iVar],theStudy));
+ }
+
+ //Add empty row
+ AddEmptyRow();
+ isProcessItemChangedSignal = true;
+
+ ResetMaps();
+
+ myStudy = theStudy;
+}
+
+//============================================================================
+/*! Function : Variable2String
+ * Purpose : Convert variable values to QString
+ */
+//============================================================================
+QString NoteBook_Table::Variable2String(const string& theVarName,
+ _PTR(Study) theStudy)
+{
+ 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");
+
+ return aResult;
+}
+
+//============================================================================
+/*! Function : IsValid
+ * Purpose : Check validity of the table data
+ */
+//============================================================================
+bool NoteBook_Table::IsValid() const
+{
+ int aNumRows = myRows.count();
+ if( aNumRows == 0 )
+ return true;
+
+ bool aLastRowIsEmpty = myRows[ aNumRows - 1 ]->GetName().isEmpty() &&
+ myRows[ aNumRows - 1 ]->GetValue().isEmpty();
+
+ for( int i = 0, n = aLastRowIsEmpty ? aNumRows - 1 : aNumRows; i < n; i++ )
+ if( !myRows[i]->CheckName() || !IsUniqueName( myRows[i] ) || !myRows[i]->CheckValue() )
+ return false;
+
+ return true;
+}
+
+//============================================================================
+/*! Function : RenamberRowItems
+ * Purpose : renumber row items
+ */
+//============================================================================
+void NoteBook_Table::RenamberRowItems(){
+ for(int i=0; i<myRows.size();i++){
+ myRows[i]->GetHeaderItem()->setText(QString::number(i+1));
+ }
+}
+
+//============================================================================
+/*! Function : AddRow
+ * Purpose : Add a row into the table
+ */
+//============================================================================
+void NoteBook_Table::AddRow(const QString& theName, const QString& theValue)
+{
+ int anIndex = getUniqueIndex();
+ NoteBook_TableRow* aRow = new NoteBook_TableRow(anIndex, this);
+ aRow->SetName(theName);
+ aRow->SetValue(theValue);
+ aRow->AddToTable(this);
+ myRows.append(aRow);
+
+ myVariableMap.insert( anIndex, NoteBoox_Variable( theName, theValue ) );
+}
+
+//============================================================================
+/*! Function : AddEmptyRow
+ * Purpose : Add an empty row into the end of the table
+ */
+//============================================================================
+void NoteBook_Table::AddEmptyRow()
+{
+ isProcessItemChangedSignal = false;
+ AddRow();
+ isProcessItemChangedSignal = true;
+}
+
+//============================================================================
+/*! Function : GetRowByItem
+ * Purpose :
+ */
+//============================================================================
+NoteBook_TableRow* NoteBook_Table::GetRowByItem(const QTableWidgetItem* theItem) const
+{
+ int aCurrentRow = row(theItem);
+
+ if( (myRows.size() <= aCurrentRow ) && (aCurrentRow < 0))
+ return NULL;
+ else
+ return myRows.at(aCurrentRow);
+}
+
+//============================================================================
+/*! Function : IsLastRow
+ * Purpose : Return true if theRow is last row in the table
+ */
+//============================================================================
+bool NoteBook_Table::IsLastRow(const NoteBook_TableRow* theRow) const
+{
+ return (myRows.last() == theRow);
+}
+
+//============================================================================
+/*! Function : onItemChanged
+ * Purpose : [slot] called then table item changed
+ */
+//============================================================================
+void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem)
+{
+ if(isProcessItemChangedSignal) {
+ bool isModified = true;
+ NoteBook_TableRow* aRow = GetRowByItem(theItem);
+ if(aRow) {
+ int aCurrentColumn = column(theItem);
+ bool IsCorrect = true, IsVariableComplited = false;
+ QString aMsg;
+
+ if(aCurrentColumn == NAME_COLUMN) {
+ int anIndex = aRow->GetIndex();
+ if( myVariableMap.contains( anIndex ) )
+ {
+ const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
+ if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( string( aVariable.Name.toLatin1().constData() ) ) )
+ {
+ if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
+ tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ),
+ QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
+ {
+ bool isBlocked = blockSignals( true );
+ aRow->SetName( aVariable.Name );
+ blockSignals( isBlocked );
+ return;
+ }
+ }
+ }
+ }
+
+ //Case then varible name changed.
+ if(aCurrentColumn == NAME_COLUMN) {
+ if(!aRow->CheckName()) {
+ IsCorrect = false;
+ aMsg = tr( "VARNAME_INCORRECT" ).arg(aRow->GetName());
+ }
+ else if(!IsUniqueName(aRow)) {
+ IsCorrect = false;
+ aMsg = tr( "VARNAME_EXISTS" ).arg(aRow->GetName());
+ }
+ else
+ IsVariableComplited = aRow->CheckValue();
+ }
+
+ //Case then varible value changed.
+ else if(aCurrentColumn == VALUE_COLUMN){
+ if(!aRow->CheckValue()) {
+ IsCorrect = false;
+ aMsg = tr( "VARVALUE_INCORRECT" ).arg(aRow->GetName());
+ }
+ else
+ IsVariableComplited = aRow->CheckName() && IsUniqueName(aRow);
+ }
+
+ if(!IsCorrect && !aMsg.isEmpty())
+ SUIT_MessageBox::warning( parentWidget(), tr( "WARNING" ), aMsg );
+
+ bool isBlocked = blockSignals( true );
+ theItem->setForeground( QBrush( IsCorrect ? Qt::black : Qt::red ) );
+ blockSignals( isBlocked );
+
+ int anIndex = aRow->GetIndex();
+ if( myVariableMap.contains( anIndex ) )
+ {
+ NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
+ if( aVariable.Name.compare( aRow->GetName() ) != 0 ||
+ aVariable.Value.compare( aRow->GetValue() ) != 0 )
+ {
+ aVariable.Name = aRow->GetName();
+ aVariable.Value = aRow->GetValue();
+ }
+ else
+ isModified = false;
+ }
+
+ if(IsCorrect && IsVariableComplited && IsLastRow(aRow))
+ AddEmptyRow();
+ }
+
+ if( !myIsModified )
+ myIsModified = isModified;
+ }
+}
+
+//============================================================================
+/*! Function : IsUniqueName
+ * Purpose : Return true if theName is unique name of the Variable
+ */
+//============================================================================
+bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const
+{
+ for(int i=0; i<myRows.size();i++) {
+ if(myRows[i] == theRow )
+ continue;
+ if(myRows[i]->GetName().compare(theRow->GetName()) == 0)
+ return false;
+ }
+ return true;
+}
+
+//============================================================================
+/*! Function : RemoveSelected
+ * Purpose : Remove selected rows in the table
+ */
+//============================================================================
+void NoteBook_Table::RemoveSelected()
+{
+ isProcessItemChangedSignal = false;
+ QList<QTableWidgetItem*> aSelectedItems = selectedItems();
+ if( !(aSelectedItems.size() > 0)) {
+ isProcessItemChangedSignal = true;
+ return;
+ }
+ bool removedFromStudy = false;
+ for(int i=0; i < aSelectedItems.size(); i++ ) {
+ NoteBook_TableRow* aRow = GetRowByItem(aSelectedItems[i]);
+ if(aRow) {
+ if(IsLastRow(aRow)) {
+ aRow->SetName(QString());
+ aRow->SetValue(QString());
+ }
+ else {
+ int nRow = row(aSelectedItems[i]);
+
+ if( myStudy->IsVariableUsed( string( aRow->GetName().toLatin1().constData() ) ) )
+ {
+ if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
+ tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ),
+ QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
+ {
+ isProcessItemChangedSignal = true;
+ return;
+ }
+ }
+
+ int index = aRow->GetIndex();
+ QString aVarName = aRow->GetName();
+ myRemovedRows.append( index );
+ if( myVariableMap.contains( index ) )
+ myVariableMap.remove( index );
+ removeRow(nRow);
+ myRows.removeAt(nRow);
+ if(myStudy->IsVariable(aVarName.toLatin1().constData()))
+ removedFromStudy = true;
+ }
+ }
+ }
+ if(removedFromStudy)
+ myIsModified = true;
+ RenamberRowItems();
+ isProcessItemChangedSignal = true;
+}
+
+//============================================================================
+/*! Function : SetProcessItemChangedSignalFlag
+ * Purpose :
+ */
+//============================================================================
+void NoteBook_Table::SetProcessItemChangedSignalFlag(const bool enable)
+{
+ isProcessItemChangedSignal = enable;
+}
+
+//============================================================================
+/*! Function : GetProcessItemChangedSignalFlag
+ * Purpose :
+ */
+//============================================================================
+bool NoteBook_Table::GetProcessItemChangedSignalFlag() const
+{
+ return isProcessItemChangedSignal;
+}
+
+//============================================================================
+/*! Function : GetRows
+ * Purpose :
+ */
+//============================================================================
+QList<NoteBook_TableRow*> NoteBook_Table::GetRows() const
+{
+ return myRows;
+}
+
+//============================================================================
+/*! Function : ResetMaps
+ * Purpose : Reset variable maps
+ */
+//============================================================================
+void NoteBook_Table::ResetMaps()
+{
+ myIsModified = false;
+ myVariableMapRef = myVariableMap;
+ myRemovedRows.clear();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// SalomeApp_NoteBookDlg class //
+///////////////////////////////////////////////////////////////////////////
+//============================================================================
+/*! Function : SalomeApp_NoteBookDlg
+ * Purpose : Constructor
+ */
+//============================================================================
+SalomeApp_NoteBookDlg::SalomeApp_NoteBookDlg(QWidget * parent, _PTR(Study) theStudy):
+ QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
+ myStudy(theStudy)
+{
+ setModal(false);
+ setObjectName("SalomeApp_NoteBookDlg");
+ setWindowTitle(tr("NOTEBOOK_TITLE"));
+ QGridLayout* aLayout = new QGridLayout(this);
+ aLayout->setMargin(DEFAULT_MARGIN);
+ aLayout->setSpacing(DEFAULT_SPACING);
+
+ //Table
+ myTable = new NoteBook_Table(this);
+ aLayout->addWidget(myTable, 0, 0, 1, 3);
+
+ //Buttons
+ myRemoveButton = new QPushButton(tr("BUT_REMOVE"));
+ aLayout->addWidget(myRemoveButton, 1, 0, 1, 1);
+
+ QSpacerItem* spacer =
+ new QSpacerItem(DEFAULT_SPACING, 5 , QSizePolicy::Expanding, QSizePolicy::Minimum);
+ aLayout->addItem(spacer, 1, 1, 2, 1);
+
+ myUpdateStudyBtn = new QPushButton(tr("BUT_UPDATE_STUDY"));
+ aLayout->addWidget(myUpdateStudyBtn, 1, 2, 1, 1);
+
+ QGroupBox* groupBox = new QGroupBox(this);
+
+ QGridLayout* aLayout1 = new QGridLayout(groupBox);
+
+ aLayout1->setMargin(DEFAULT_MARGIN);
+ aLayout1->setSpacing(DEFAULT_SPACING);
+
+ myOkBtn = new QPushButton(tr("BUT_APPLY_AND_CLOSE"));
+ aLayout1->addWidget(myOkBtn, 0, 0, 1, 1);
+
+ myApplyBtn = new QPushButton(tr("BUT_APPLY"));
+ aLayout1->addWidget(myApplyBtn, 0, 1, 1, 1);
+
+ QSpacerItem* spacer1 =
+ new QSpacerItem(DEFAULT_SPACING, 5, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ aLayout1->addItem(spacer1, 0, 2, 1, 1);
+
+ myCancelBtn = new QPushButton(tr("BUT_CLOSE"));
+ aLayout1->addWidget(myCancelBtn, 0, 3, 1, 1);
+
+ myHelpBtn = new QPushButton(tr("BUT_HELP"));
+ aLayout1->addWidget(myHelpBtn, 0, 4, 1, 1);
+
+ aLayout->addWidget(groupBox, 2, 0, 1, 3);
+
+ QWidgetList aWidgetList;
+ aWidgetList.append( myTable );
+ aWidgetList.append( myOkBtn );
+ aWidgetList.append( myApplyBtn );
+ aWidgetList.append( myCancelBtn );
+ aWidgetList.append( myHelpBtn );
+ aWidgetList.append( myUpdateStudyBtn );
+ aWidgetList.append( myRemoveButton );
+ Qtx::setTabOrder( aWidgetList );
+
+ connect( myOkBtn, SIGNAL(clicked()), this, SLOT(onOK()) );
+ connect( myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()) );
+ connect( myCancelBtn, SIGNAL(clicked()), this, SLOT(onCancel()) );
+ connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) );
+ connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
+ connect( myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
+
+ myTable->Init(myStudy);
+}
+
+//============================================================================
+/*! Function : ~SalomeApp_NoteBookDlg
+ * Purpose : Destructor
+ */
+//============================================================================
+SalomeApp_NoteBookDlg::~SalomeApp_NoteBookDlg(){}
+
+
+//============================================================================
+/*! Function : Init()
+ * Purpose : init variable table
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::Init(_PTR(Study) theStudy){
+ if(myStudy!= theStudy)
+ myStudy = theStudy;
+ myTable->Init(myStudy);
+}
+
+
+//============================================================================
+/*! Function : onOK
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onOK()
+{
+ onApply();
+ if( myTable->IsValid() )
+ accept();
+}
+
+//============================================================================
+/*! Function : onHelp
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onHelp()
+{
+ QString aHelpFileName("using_notebook.html");
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule("GUI",aHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(aHelpFileName));
+ }
+
+}
+//============================================================================
+/*! Function : onApply
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onApply()
+{
+ if( !myTable->IsValid() )
+ {
+ SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) );
+ return;
+ }
+
+ double aDVal;
+ int anIVal;
+ bool aBVal;
+
+ const QList<int>& aRemovedRows = myTable->GetRemovedRows();
+ const VariableMap& aVariableMap = myTable->GetVariableMap();
+ const VariableMap& aVariableMapRef = myTable->GetVariableMapRef();
+
+ for( QListIterator<int> anIter( aRemovedRows ); anIter.hasNext(); )
+ {
+ int anIndex = anIter.next();
+ if( aVariableMapRef.contains( anIndex ) )
+ {
+ QString aRemovedVariable = aVariableMapRef[ anIndex ].Name;
+ myStudy->RemoveVariable( string( aRemovedVariable.toLatin1().constData() ) );
+ }
+ }
+
+ VariableMap::const_iterator it = aVariableMap.constBegin(), itEnd = aVariableMap.constEnd();
+ for( ; it != itEnd; ++it )
+ {
+ int anIndex = it.key();
+ const NoteBoox_Variable& aVariable = it.value();
+ QString aName = aVariable.Name;
+ QString aValue = aVariable.Value;
+
+ if( !aName.isEmpty() && !aValue.isEmpty() )
+ {
+ if( aVariableMapRef.contains( anIndex ) )
+ {
+ const NoteBoox_Variable& aVariableRef = aVariableMapRef[ anIndex ];
+ QString aNameRef = aVariableRef.Name;
+ QString aValueRef = aVariableRef.Value;
+
+ if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName )
+ {
+ myStudy->RenameVariable( string( aNameRef.toLatin1().constData() ),
+ string( aName.toLatin1().constData() ) );
+ }
+ }
+
+ if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) )
+ myStudy->SetInteger(string(aName.toLatin1().constData()),anIVal);
+
+ else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) )
+ myStudy->SetReal(string(aName.toLatin1().constData()),aDVal);
+
+ else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) )
+ myStudy->SetBoolean(string(aName.toLatin1().constData()),aBVal);
+ }
+ }
+ myTable->ResetMaps();
+
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if(app)
+ app->updateActions();
+
+}
+
+//============================================================================
+/*! Function : onCancel
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onCancel()
+{
+ if( myTable->IsModified() )
+ {
+ int answer = QMessageBox::question( this, tr( "CLOSE_CAPTION" ), tr( "CLOSE_DESCRIPTION" ),
+ QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel );
+ switch( answer )
+ {
+ case QMessageBox::Yes : onOK(); return;
+ case QMessageBox::No : break;
+ case QMessageBox::Cancel : return;
+ default : break;
+ }
+ }
+ reject();
+}
+
+//============================================================================
+/*! Function : onRemove
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onRemove()
+{
+ myTable->RemoveSelected();
+}
+
+//============================================================================
+/*! Function : onUpdateStudy
+ * Purpose : [slot]
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::onUpdateStudy()
+{
+ onApply();
+ if( !myTable->IsValid() )
+ return;
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ if( !updateStudy() )
+ SUIT_MessageBox::warning( this, tr( "ERROR" ), tr( "ERR_UPDATE_STUDY_FAILED" ) );
+
+ QApplication::restoreOverrideCursor();
+}
+
+//============================================================================
+/*! Function : updateStudy
+ * Purpose :
+ */
+//============================================================================
+bool SalomeApp_NoteBookDlg::updateStudy()
+{
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return false;
+
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if( !study )
+ return false;
+
+ bool isStudySaved = study->isSaved();
+ QString aStudyName = study->studyName();
+
+ _PTR(Study) studyDS = study->studyDS();
+
+ // get unique temporary directory name
+ QString aTmpDir = QString::fromStdString( SALOMEDS_Tool::GetTmpDir() );
+ if( aTmpDir.isEmpty() )
+ return false;
+
+ if( aTmpDir.right( 1 ).compare( QDir::separator() ) == 0 )
+ aTmpDir.remove( aTmpDir.length() - 1, 1 );
+
+ // dump study to the temporary directory
+ QString aFileName( "notebook" );
+ bool toPublish = true;
+ bool toSaveGUI = true;
+
+ int savePoint;
+ _PTR(AttributeParameter) ap;
+ _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+ if(ip->isDumpPython(studyDS)) ip->setDumpPython(studyDS); //Unset DumpPython flag.
+ if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
+ ip->setDumpPython(studyDS);
+ savePoint = SalomeApp_VisualState( app ).storeState(); //SRN: create a temporary save point
+ }
+ bool ok = studyDS->DumpStudy( aTmpDir.toStdString(), aFileName.toStdString(), toPublish );
+ if ( toSaveGUI )
+ study->removeSavePoint(savePoint); //SRN: remove the created temporary save point.
+
+ if( !ok )
+ return false;
+
+ // clear a study (delete all objects)
+ clearStudy();
+
+ // get active application
+ app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+
+ // load study from the temporary directory
+ QString command = QString( "execfile(\"%1\")" ).arg( aTmpDir + QDir::separator() + aFileName + ".py" );
+
+ PyConsole_Console* pyConsole = app->pythonConsole();
+ if ( pyConsole )
+ pyConsole->execAndWait( command );
+
+ // remove temporary directory
+ QDir aDir( aTmpDir );
+ QStringList aFiles = aDir.entryList( QStringList( "*.py*" ) );
+ for( QStringList::iterator it = aFiles.begin(), itEnd = aFiles.end(); it != itEnd; ++it )
+ ok = aDir.remove( *it ) && ok;
+ if( ok )
+ ok = aDir.rmdir( aTmpDir );
+
+ if( SalomeApp_Study* newStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
+ {
+ myStudy = newStudy->studyDS();
+ myTable->Init(myStudy);
+ if(isStudySaved) {
+ newStudy->markAsSavedIn(aStudyName);
+ }
+ }
+ else
+ ok = false;
+
+ return ok;
+}
+
+//============================================================================
+/*! Function : clearStudy
+ * Purpose :
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::clearStudy()
+{
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ QList<SUIT_Application*> aList = SUIT_Session::session()->applications();
+ int anIndex = aList.indexOf( app );
+
+ //Store position and size of the this dialog
+ int aW = width();
+ int aH = height();
+ int aX = x();
+ int aY = y();
+
+ // Disconnect dialog from application desktop in case if:
+ // 1) Application is not the first application in the session
+ // 2) Application is the first application in session but not the only.
+ bool changeDesktop = ((anIndex > 0) || (anIndex == 0 && aList.count() > 1));
+
+ if( changeDesktop )
+ setParent( 0 );
+
+ app->onCloseDoc( false );
+
+ if( anIndex > 0 && anIndex < aList.count() )
+ app = dynamic_cast<SalomeApp_Application*>( aList[ anIndex - 1 ] );
+ else if(anIndex == 0 && aList.count() > 1)
+ app = dynamic_cast<SalomeApp_Application*>( aList[ 1 ] );
+
+ if( !app )
+ return;
+
+ app->onNewDoc();
+
+ app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if( changeDesktop && app ) {
+ setParent( app->desktop(), Qt::Dialog );
+ app->setNoteBook(this);
+ }
+ //Set position and size of the this dialog
+ resize( aW, aH );
+ move( aX, aY );
+ show();
+}
--- /dev/null
+// Copyright (C) 2008 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: SalomeApp_NoteBookDlg.h
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S.
+// Module : GUI
+
+#ifndef SALOMEAPP_NOTEBOOKDLG_H
+#define SALOMEAPP_NOTEBOOKDLG_H
+
+#include "SalomeApp.h"
+
+#include "SALOMEDSClient_ClientFactory.hxx"
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+#include <QDialog>
+#include <QTableWidget>
+#include <QList>
+
+class QWidget;
+class QPushButton;
+class QTableWidgetItem;
+
+struct NoteBoox_Variable
+{
+ NoteBoox_Variable() {}
+ NoteBoox_Variable( const QString& theName, const QString& theValue )
+ {
+ Name = theName;
+ Value = theValue;
+ }
+ QString Name;
+ QString Value;
+};
+
+typedef QMap< int, NoteBoox_Variable > VariableMap;
+
+class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget
+{
+ public:
+ NoteBook_TableRow(int, QWidget* parent=0);
+ virtual ~NoteBook_TableRow();
+
+ int GetIndex() const { return myIndex; }
+
+ void AddToTable(QTableWidget *theTable);
+
+ void SetName(const QString theName);
+ void SetValue(const QString theValue);
+
+ QString GetValue() const;
+ QString GetName() const;
+
+ bool CheckName();
+ bool CheckValue();
+
+ QTableWidgetItem* GetVariableItem();
+ QTableWidgetItem* GetNameItem();
+ QTableWidgetItem* GetHeaderItem();
+
+ static bool IsRealValue(const QString theValue, double* theResult = 0);
+ static bool IsIntegerValue(const QString theValue, int* theResult = 0);
+ static bool IsBooleanValue(const QString theValue, bool* theResult = 0);
+
+ private:
+ int myIndex;
+ QTableWidgetItem* myRowHeader;
+ QTableWidgetItem* myVariableName;
+ QTableWidgetItem* myVariableValue;
+};
+
+class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget
+{
+ Q_OBJECT
+ public:
+ NoteBook_Table(QWidget * parent = 0);
+ virtual ~NoteBook_Table();
+
+ void Init(_PTR(Study) theStudy);
+ static QString Variable2String(const std::string& theVarName,
+ _PTR(Study) theStudy);
+
+ bool IsValid() const;
+
+ void AddRow( const QString& theName = QString::null, const QString& theValue = QString::null );
+ void AddEmptyRow();
+ NoteBook_TableRow* GetRowByItem(const QTableWidgetItem* theItem) const;
+ bool IsLastRow(const NoteBook_TableRow* aRow) const;
+
+ void RemoveSelected();
+
+ void SetProcessItemChangedSignalFlag(const bool enable);
+ bool GetProcessItemChangedSignalFlag()const;
+
+ bool IsUniqueName(const NoteBook_TableRow* theRow) const;
+ QList<NoteBook_TableRow*> GetRows() const;
+
+ const bool IsModified() const { return myIsModified; }
+ const QList<int>& GetRemovedRows() const { return myRemovedRows; }
+ const VariableMap& GetVariableMap() const { return myVariableMap; }
+ const VariableMap& GetVariableMapRef() const { return myVariableMapRef; }
+ void RenamberRowItems();
+
+ void ResetMaps();
+
+ public slots:
+ void onItemChanged(QTableWidgetItem* theItem);
+
+ private:
+ int getUniqueIndex() const;
+
+ private:
+ bool isProcessItemChangedSignal;
+ QList<NoteBook_TableRow*> myRows;
+
+ bool myIsModified;
+ QList<int> myRemovedRows;
+ VariableMap myVariableMapRef;
+ VariableMap myVariableMap;
+
+ _PTR(Study) myStudy;
+};
+
+class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog
+{
+ Q_OBJECT
+ public:
+ SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy);
+ virtual ~SalomeApp_NoteBookDlg();
+
+ void Init(_PTR(Study) theStudy);
+
+ public slots:
+ void onOK();
+ void onApply();
+ void onCancel();
+ void onRemove();
+ void onUpdateStudy();
+ void onHelp();
+
+ protected:
+ bool updateStudy();
+ void clearStudy();
+
+ private:
+ NoteBook_Table* myTable;
+ QPushButton* myRemoveButton;
+ QPushButton* myUpdateStudyBtn;
+ QPushButton* myOkBtn;
+ QPushButton* myApplyBtn;
+ QPushButton* myCancelBtn;
+ QPushButton* myHelpBtn;
+
+ _PTR(Study) myStudy;
+};
+
+#endif //SALOMEAPP_NOTEBOOKDLG_H
}
}
+/*!
+ Mark the study as saved in the file
+ \param theFileName - the name of file
+*/
+void SalomeApp_Study::markAsSavedIn(QString theFileName)
+{
+ setStudyName(theFileName);
+ setIsSaved(true);
+}
+
/*!
Deletes all references to object
\param obj - object
virtual std::string getVisualComponentName();
virtual void restoreState(int savePoint);
+ void markAsSavedIn(QString theFileName);
protected:
virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );
<source>REFENTRY_COLUMN</source>
<translation>Ref.Entry</translation>
</message>
+ <message>
+ <source>ERR_INCOMPATIBLE_TYPE</source>
+ <translation>Variable with name "%1" has incompatible numeric type</translation>
+ </message>
+ <message>
+ <source>ERR_INVALID_VALUE</source>
+ <translation>Value hasn't been validated</translation>
+ </message>
+ <message>
+ <source>ERR_NO_VARIABLE</source>
+ <translation>Variable with name "%1" doesn't exist</translation>
+ </message>
</context>
<context>
<name>SalomeApp_Application</name>
<source>PRP_DESK_FILE_DUMP_STUDY</source>
<translation>Dumps study to the python script</translation>
</message>
+ <message>
+ <source>TOT_DESK_FILE_NOTEBOOK</source>
+ <translation>Open Notebook</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_FILE_NOTEBOOK</source>
+ <translation>Noteboo&k...</translation>
+ </message>
+ <message>
+ <source>PRP_DESK_FILE_NOTEBOOK</source>
+ <translation>Open Notebook</translation>
+ </message>
<message>
<source>TOT_DESK_PROPERTIES</source>
<translation>Study properties</translation>
<translation>Shutdown standalone servers</translation>
</message>
</context>
+<context>
+ <name>NoteBook_Table</name>
+ <message>
+ <source>REMOVE_VARIABLE_IS_USED</source>
+ <translation>Variable with name "%1" is used in the study.
+Do you really want to remove it?</translation>
+ </message>
+ <message>
+ <source>RENAME_VARIABLE_IS_USED</source>
+ <translation>Variable with name "%1" is used in the study.
+Do you really want to rename it?</translation>
+ </message>
+ <message>
+ <source>VARNAME_COLUMN</source>
+ <translation>Variable Name</translation>
+ </message>
+ <message>
+ <source>VARVALUE_COLUMN</source>
+ <translation>Variable Value</translation>
+ </message>
+ <message>
+ <source>VARVALUE_INCORRECT</source>
+ <translation>Variable Value Incorrect: %1</translation>
+ </message>
+ <message>
+ <source>VARNAME_INCORRECT</source>
+ <translation>Valiable Name Incorrect :%1</translation>
+ </message>
+ <message>
+ <source>VARNAME_EXISTS</source>
+ <translation>Valiable with name "%1" exists</translation>
+ </message>
+</context>
+<context>
+ <name>SalomeApp_NoteBookDlg</name>
+ <message>
+ <source>NOTEBOOK_TITLE</source>
+ <translation>Salome NoteBook</translation>
+ </message>
+ <message>
+ <source>BUT_UPDATE_STUDY</source>
+ <translation>&Update Study</translation>
+ </message>
+ <message>
+ <source>BUT_REMOVE</source>
+ <translation>&Remove</translation>
+ </message>
+ <message>
+ <source>BUT_APPLY_AND_CLOSE</source>
+ <translation>A&pply and Close</translation>
+ </message>
+ <message>
+ <source>BUT_HELP</source>
+ <translation>&Help</translation>
+ </message>
+ <message>
+ <source>CLOSE_CAPTION</source>
+ <translation>Close NoteBook</translation>
+ </message>
+ <message>
+ <source>CLOSE_DESCRIPTION</source>
+ <translation>Do you want to save changes you made to NoteBook?</translation>
+ </message>
+ <message>
+ <source>INCORRECT_DATA</source>
+ <translation>At least one variable has been defined incorrectly.
+Please edit its parameters or remove it from table.</translation>
+ </message>
+ <message>
+ <source>ERR_UPDATE_STUDY_FAILED</source>
+ <translation>Failed to update study!</translation>
+ </message>
+</context>
</TS>