SalomeApp_CheckFileDlg.h \
SalomeApp_VisualState.h \
SalomeApp_ExitDlg.h \
- SalomeApp_NoteBookDlg.h
+ SalomeApp_NoteBookDlg.h \
+ SalomeApp_DoubleSpinBox.h \
+ SalomeApp_IntSpinBox.h
dist_libSalomeApp_la_SOURCES = \
SalomeApp_Module.cxx \
SalomeApp_CheckFileDlg.cxx \
SalomeApp_VisualState.cxx \
SalomeApp_ExitDlg.cxx \
- SalomeApp_NoteBookDlg.cxx
+ SalomeApp_NoteBookDlg.cxx \
+ SalomeApp_DoubleSpinBox.cxx \
+ SalomeApp_IntSpinBox.cxx
MOC_FILES = \
SalomeApp_Application_moc.cxx \
SalomeApp_ListView_moc.cxx \
SalomeApp_CheckFileDlg_moc.cxx \
SalomeApp_ExitDlg_moc.cxx \
- SalomeApp_NoteBookDlg_moc.cxx
+ SalomeApp_NoteBookDlg_moc.cxx \
+ SalomeApp_DoubleSpinBox_moc.cxx \
+ SalomeApp_IntSpinBox_moc.cxx
nodist_libSalomeApp_la_SOURCES = $(MOC_FILES)
QString val;
_PTR(GenericAttribute) attr;
- if ( obj->FindAttribute( attr, "AttributeInteger" ) )
+ if ( obj->FindAttribute( attr, "AttributeString" ) )
+ {
+ _PTR(AttributeString) strAttr = attr;
+ std::string str = strAttr->Value();
+ val = QString( str.c_str() );
+ }
+ 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)
+
+/*!
+ \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 )
+{
+}
+
+/*!
+ \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 )
+{
+}
+
+/*!
+ \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 )
+{
+}
+
+/*!
+ \brief Destructor.
+*/
+SalomeApp_DoubleSpinBox::~SalomeApp_DoubleSpinBox()
+{
+}
+
+/*!
+ \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
+{
+ QString str = text;
+
+ double value = 0;
+ if( findVariable( str, value ) )
+ str = QString::number( value );
+
+ int pos = 0;
+ if( QtxDoubleSpinBox::validate( str, pos ) == QValidator::Acceptable )
+ value = QtxDoubleSpinBox::valueFromText( str );
+ else
+ value = defaultValue();
+
+ return value;
+}
+
+/*!
+ \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() const
+{
+ QString str = text();
+
+ double value = 0;
+ if( findVariable( str, value ) )
+ str = QString::number( value );
+
+ int pos = 0;
+ return QtxDoubleSpinBox::validate( str, pos ) == QValidator::Acceptable;
+}
+
+/*!
+ \brief This function return a default acceptable value (commonly, 0.0).
+ \return default acceptable value
+*/
+double SalomeApp_DoubleSpinBox::defaultValue() const
+{
+ if( minimum() > 0 || maximum() < 0 )
+ return minimum();
+
+ return 0.0;
+}
+
+/*!
+ \brief This function is used to determine whether input is a variable name and to get its value.
+ \return true if the input is a variable name
+*/
+bool SalomeApp_DoubleSpinBox::findVariable( const QString& name, double& value ) const
+{
+ 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::vector<std::string> aVariableNames = studyDS->GetVariableNames();
+ for( unsigned int i = 0, n = aVariableNames.size(); i < n; i++ )
+ {
+ std::string aName = aVariableNames[ i ];
+ if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) )
+ {
+ double aValue = studyDS->GetReal( aName );
+ if( aName == name.toStdString() )
+ {
+ value = aValue;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
--- /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
+
+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;
+
+ bool isValid() const;
+
+protected:
+ double defaultValue() const;
+ bool findVariable( const QString&, double& ) const;
+
+private slots:
+
+private:
+};
+
+#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)
+
+/*!
+ \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 )
+{
+}
+
+/*!
+ \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 )
+{
+}
+
+/*!
+ \brief Destructor.
+*/
+SalomeApp_IntSpinBox::~SalomeApp_IntSpinBox()
+{
+}
+
+/*!
+ \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
+{
+ QString str = text;
+
+ int value = 0;
+ if( findVariable( str, value ) )
+ str = QString::number( value );
+
+ int pos = 0;
+ if( QtxIntSpinBox::validate( str, pos ) == QValidator::Acceptable )
+ value = QtxIntSpinBox::valueFromText( str );
+ else
+ value = defaultValue();
+
+ return value;
+}
+
+/*!
+ \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() const
+{
+ QString str = text();
+
+ int value = 0;
+ if( findVariable( str, value ) )
+ str = QString::number( value );
+
+ int pos = 0;
+ return QtxIntSpinBox::validate( str, pos ) == QValidator::Acceptable;
+}
+
+/*!
+ \brief This function return a default acceptable value (commonly, 0).
+ \return default acceptable value
+*/
+int SalomeApp_IntSpinBox::defaultValue() const
+{
+ if( minimum() > 0 || maximum() < 0 )
+ return minimum();
+
+ return 0;
+}
+
+/*!
+ \brief This function is used to determine whether input is a variable name and to get its value.
+ \return true if the input is a variable name
+*/
+bool SalomeApp_IntSpinBox::findVariable( const QString& name, int& value ) const
+{
+ 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::vector<std::string> aVariableNames = studyDS->GetVariableNames();
+ for( unsigned int i = 0, n = aVariableNames.size(); i < n; i++ )
+ {
+ std::string aName = aVariableNames[ i ];
+ if( studyDS->IsInteger( aName ) )
+ {
+ int aValue = studyDS->GetInteger( aName );
+
+ if( aName == name.toStdString() )
+ {
+ value = aValue;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
--- /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
+
+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;
+
+ bool isValid() const;
+
+protected:
+ int defaultValue() const;
+ bool findVariable( const QString&, int& ) const;
+
+private slots:
+
+private:
+};
+
+#endif