From 46675a6e6fd744c9326300f23be29841f1d025b9 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 25 Mar 2014 11:57:46 +0400 Subject: [PATCH] GUITHARE 0002109: External 20696 2D 3D surfaces. 1) 4.29.2 Remove surfaces 2) 4.29.3 Fit range/zoom (partially) 3) 4.29.6 Legends --- adm_local/win32/SVTK.vcproj | 32 +++ src/SVTK/Plot3d_FitDataDlg.cxx | 286 ++++++++++++++++++++++++++ src/SVTK/Plot3d_FitDataDlg.h | 76 +++++++ src/SVTK/Plot3d_SetupSurfacesDlg.cxx | 2 +- src/SVTK/SVTK_FitDataDlg.cxx | 287 +++++++++++++++++++++++++++ src/SVTK/SVTK_FitDataDlg.h | 75 +++++++ src/SVTK/SVTK_ViewModel.cxx | 7 + src/SVTK/SVTK_ViewWindow.cxx | 27 ++- src/SVTK/SVTK_ViewWindow.h | 5 + src/SVTK/resources/SVTK_msg_en.ts | 43 ++++ 10 files changed, 837 insertions(+), 3 deletions(-) create mode 100644 src/SVTK/Plot3d_FitDataDlg.cxx create mode 100644 src/SVTK/Plot3d_FitDataDlg.h create mode 100644 src/SVTK/SVTK_FitDataDlg.cxx create mode 100644 src/SVTK/SVTK_FitDataDlg.h diff --git a/adm_local/win32/SVTK.vcproj b/adm_local/win32/SVTK.vcproj index 2591e62a2..4f231d289 100644 --- a/adm_local/win32/SVTK.vcproj +++ b/adm_local/win32/SVTK.vcproj @@ -646,6 +646,30 @@ /> + + + + + + + + @@ -1607,6 +1631,10 @@ RelativePath="..\..\src\SVTK\Plot3d_Actor.cxx" > + + @@ -1760,6 +1788,10 @@ Name="Meta Object Files" Filter="moc_*.cxx" > + + diff --git a/src/SVTK/Plot3d_FitDataDlg.cxx b/src/SVTK/Plot3d_FitDataDlg.cxx new file mode 100644 index 000000000..44db9e460 --- /dev/null +++ b/src/SVTK/Plot3d_FitDataDlg.cxx @@ -0,0 +1,286 @@ +// 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 : Plot3d_FitDataDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "Plot3d_FitDataDlg.h" + +#include +#include +#include +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_EDIT_SIZE 100 + +/*! + Constructor +*/ +Plot3d_FitDataDlg::Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY ) + : QDialog( parent ? parent : 0, + Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY ) +{ + setObjectName( "Plot3d_FitDataDlg" ); + setModal( true ); + setWindowTitle( tr( "FIT_DATA_TLT" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + // 'Range' group + myRangeGrp = new QGroupBox( this ); + QGridLayout* aGridLayout = new QGridLayout( myRangeGrp ); + myRangeGrp->setLayout( aGridLayout ); + aGridLayout->setAlignment( Qt::AlignTop ); + aGridLayout->setMargin( MARGIN_SIZE ); + aGridLayout->setSpacing( SPACING_SIZE ); + + myModeAllRB = new QRadioButton( tr( "FIT_ALL" ), myRangeGrp ); + myModeHorRB = new QRadioButton( tr( "FIT_HORIZONTAL" ), myRangeGrp ); + myModeVerRB = new QRadioButton( tr( "FIT_VERTICAL" ), myRangeGrp ); + + QDoubleValidator* aValidator = new QDoubleValidator( this ); + myXMinEdit = new QLineEdit( myRangeGrp ); + myXMinEdit->setValidator( aValidator ); + myXMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMinEdit->setText( "0.0" ); + + myYMinEdit = new QLineEdit( myRangeGrp ); + myYMinEdit->setValidator( aValidator ); + myYMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMinEdit->setText( "0.0" ); + + myXMaxEdit = new QLineEdit( myRangeGrp ); + myXMaxEdit->setValidator( aValidator ); + myXMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMaxEdit->setText( "0.0" ); + + myYMaxEdit = new QLineEdit( myRangeGrp ); + myYMaxEdit->setValidator( aValidator ); + myYMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMaxEdit->setText( "0.0" ); + + if (mySecondAxisY) { + myY2MinEdit = new QLineEdit( myRangeGrp ); + myY2MinEdit->setValidator( aValidator ); + myY2MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MinEdit->setText( "0.0" ); + + myY2MaxEdit = new QLineEdit( myRangeGrp ); + myY2MaxEdit->setValidator( aValidator ); + myY2MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MaxEdit->setText( "0.0" ); + } + + QFrame* aHLine = new QFrame( myRangeGrp ); + aHLine->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + + QHBoxLayout* aModeLayout = new QHBoxLayout; + aModeLayout->setMargin( 0 ); + aModeLayout->setSpacing( SPACING_SIZE ); + aModeLayout->addWidget( myModeAllRB ); + aModeLayout->addWidget( myModeHorRB ); + aModeLayout->addWidget( myModeVerRB ); + + QLabel* horLab = new QLabel( tr( "HORIZONTAL_AXIS" ), myRangeGrp ); + QLabel* verLab = new QLabel( tr( "VERTICAL_AXIS" ), myRangeGrp ); + if (mySecondAxisY) + verLab->setText( tr( "VERTICAL_LEFT_AXIS" ) ); + + QFont font = horLab->font(); font.setBold( true ); + horLab->setFont( font ); verLab->setFont( font ); + + aGridLayout->addLayout( aModeLayout, 0, 0, 1, 5 ); + aGridLayout->addWidget( aHLine, 1, 0, 1, 5 ); + aGridLayout->addWidget( horLab, 2, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 2, 1 ); + aGridLayout->addWidget( myXMinEdit, 2, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 2, 3 ); + aGridLayout->addWidget( myXMaxEdit, 2, 4 ); + aGridLayout->addWidget( verLab, 3, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 3, 1 ); + aGridLayout->addWidget( myYMinEdit, 3, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 3, 3 ); + aGridLayout->addWidget( myYMaxEdit, 3, 4 ); + + if (mySecondAxisY) { + QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp ); + ver2Lab->setFont( font ); + aGridLayout->addWidget( ver2Lab, 4, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 4, 1 ); + aGridLayout->addWidget( myY2MinEdit, 4, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 4, 3 ); + aGridLayout->addWidget( myY2MaxEdit, 4, 4 ); + } + + // OK/Cancel buttons + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myOkBtn->setObjectName( "buttonOk" ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + myCancelBtn->setObjectName( "buttonCancel" ); + myCancelBtn->setAutoDefault( TRUE ); + + topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 ); + topLayout->addWidget( myOkBtn, 1, 0 ); + topLayout->setColumnStretch( 1, 5 ); + topLayout->addWidget( myCancelBtn, 1, 2 ); + + // connect signals + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myRangeGrp, SIGNAL( clicked( int ) ), this, SLOT( onModeChanged( int ) ) ); + + // initial state + myModeAllRB->setChecked( true ); + onModeChanged( 0 ); +} + +/*! + Sets range +*/ +void Plot3d_FitDataDlg::setRange( const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min, + const double y2Max) +{ + myXMinEdit->setText( QString::number( xMin ) ); + myXMaxEdit->setText( QString::number( xMax ) ); + myYMinEdit->setText( QString::number( yMin ) ); + myYMaxEdit->setText( QString::number( yMax ) ); + if (mySecondAxisY) { + myY2MinEdit->setText( QString::number( y2Min ) ); + myY2MaxEdit->setText( QString::number( y2Max ) ); + } +} + +/*! + Gets range, returns mode (see getMode()) +*/ +int Plot3d_FitDataDlg::getRange( double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max) +{ + xMin = myXMinEdit->text().toDouble(); + xMax = myXMaxEdit->text().toDouble(); + yMin = myYMinEdit->text().toDouble(); + yMax = myYMaxEdit->text().toDouble(); + if (mySecondAxisY) { + y2Min = myY2MinEdit->text().toDouble(); + y2Max = myY2MaxEdit->text().toDouble(); + } + else { + y2Min = 0; + y2Max = 0; + } + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical +*/ +int Plot3d_FitDataDlg::getMode() +{ + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Called when range mode changed +*/ +void Plot3d_FitDataDlg::onModeChanged(int mode) +{ + bool badFocus; + switch( mode ) { + case 0: // fit all mode + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + break; + case 1: // fit horizontal mode + badFocus = myYMinEdit->hasFocus() || myYMaxEdit->hasFocus(); + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(false); + myYMaxEdit->setEnabled(false); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(false); + myY2MaxEdit->setEnabled(false); + } + if (badFocus) + myXMinEdit->setFocus(); + break; + case 2: // fit vertical mode + badFocus = myXMinEdit->hasFocus() || myXMaxEdit->hasFocus(); + myXMinEdit->setEnabled(false); + myXMaxEdit->setEnabled(false); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + if (badFocus) + myYMinEdit->setFocus(); + break; + } +} diff --git a/src/SVTK/Plot3d_FitDataDlg.h b/src/SVTK/Plot3d_FitDataDlg.h new file mode 100644 index 000000000..5b5916aa4 --- /dev/null +++ b/src/SVTK/Plot3d_FitDataDlg.h @@ -0,0 +1,76 @@ +// 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 +// +#ifndef PLOT3D_FITDATADLG_H +#define PLOT3D_FITDATADLG_H + +#include "SVTK.h" + +#include + +class QGroupBox; +class QRadioButton; +class QLineEdit; +class QPushButton; + +class SVTK_EXPORT Plot3d_FitDataDlg : public QDialog +{ + Q_OBJECT + +public: +// constuctor + Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY ); + +// sets range + void setRange(const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min = 0, + const double y2Max = 0); +// gets range, returns mode (see getMode()) + int getRange(double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max); +// gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical + int getMode(); + +protected slots: +// called when range mode changed + void onModeChanged(int); + +private: + QGroupBox* myRangeGrp; + QRadioButton* myModeAllRB; + QRadioButton* myModeHorRB; + QRadioButton* myModeVerRB; + QLineEdit* myXMinEdit; + QLineEdit* myYMinEdit; + QLineEdit* myY2MinEdit; + QLineEdit* myXMaxEdit; + QLineEdit* myYMaxEdit; + QLineEdit* myY2MaxEdit; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + bool mySecondAxisY; +}; + +#endif diff --git a/src/SVTK/Plot3d_SetupSurfacesDlg.cxx b/src/SVTK/Plot3d_SetupSurfacesDlg.cxx index a1c1e49af..4fb7d4c62 100644 --- a/src/SVTK/Plot3d_SetupSurfacesDlg.cxx +++ b/src/SVTK/Plot3d_SetupSurfacesDlg.cxx @@ -95,7 +95,7 @@ Plot3d_SetupSurfacesDlg::Plot3d_SetupSurfacesDlg( QWidget* theParent ) connect( myTable, SIGNAL( valueChanged( int, int ) ), SLOT( onValueChanged( int, int ) ) ); setButtonPosition( Right, Cancel ); - setMinimumWidth( 500 ); + setMinimumWidth( 300 ); setMinimumHeight( 250 ); } diff --git a/src/SVTK/SVTK_FitDataDlg.cxx b/src/SVTK/SVTK_FitDataDlg.cxx new file mode 100644 index 000000000..5f5cf1850 --- /dev/null +++ b/src/SVTK/SVTK_FitDataDlg.cxx @@ -0,0 +1,287 @@ +// 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 : Plot2d_FitDataDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "Plot2d_FitDataDlg.h" +#include +#include +#include +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_EDIT_SIZE 100 + +/*! + Constructor +*/ +Plot2d_FitDataDlg::Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY ) + : QDialog( parent ? parent : 0, + Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY ) + +{ + setObjectName( "Plot2d_FitDataDlg" ); + setModal( true ); + setWindowTitle( tr( "FIT_DATA_TLT" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + // 'Range' group + myRangeGrp = new QGroupBox( this ); + QGridLayout* aGridLayout = new QGridLayout( myRangeGrp ); + myRangeGrp->setLayout( aGridLayout ); + aGridLayout->setAlignment( Qt::AlignTop ); + aGridLayout->setMargin( MARGIN_SIZE ); + aGridLayout->setSpacing( SPACING_SIZE ); + + myModeAllRB = new QRadioButton( tr( "FIT_ALL" ), myRangeGrp ); + myModeHorRB = new QRadioButton( tr( "FIT_HORIZONTAL" ), myRangeGrp ); + myModeVerRB = new QRadioButton( tr( "FIT_VERTICAL" ), myRangeGrp ); + + QDoubleValidator* aValidator = new QDoubleValidator( this ); + myXMinEdit = new QLineEdit( myRangeGrp ); + myXMinEdit->setValidator( aValidator ); + myXMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMinEdit->setText( "0.0" ); + + myYMinEdit = new QLineEdit( myRangeGrp ); + myYMinEdit->setValidator( aValidator ); + myYMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMinEdit->setText( "0.0" ); + + myXMaxEdit = new QLineEdit( myRangeGrp ); + myXMaxEdit->setValidator( aValidator ); + myXMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXMaxEdit->setText( "0.0" ); + + myYMaxEdit = new QLineEdit( myRangeGrp ); + myYMaxEdit->setValidator( aValidator ); + myYMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myYMaxEdit->setText( "0.0" ); + + if (mySecondAxisY) { + myY2MinEdit = new QLineEdit( myRangeGrp ); + myY2MinEdit->setValidator( aValidator ); + myY2MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MinEdit->setText( "0.0" ); + + myY2MaxEdit = new QLineEdit( myRangeGrp ); + myY2MaxEdit->setValidator( aValidator ); + myY2MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myY2MaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myY2MaxEdit->setText( "0.0" ); + } + + QFrame* aHLine = new QFrame( myRangeGrp ); + aHLine->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + + QHBoxLayout* aModeLayout = new QHBoxLayout; + aModeLayout->setMargin( 0 ); + aModeLayout->setSpacing( SPACING_SIZE ); + aModeLayout->addWidget( myModeAllRB ); + aModeLayout->addWidget( myModeHorRB ); + aModeLayout->addWidget( myModeVerRB ); + + QLabel* horLab = new QLabel( tr( "HORIZONTAL_AXIS" ), myRangeGrp ); + QLabel* verLab = new QLabel( tr( "VERTICAL_AXIS" ), myRangeGrp ); + if (mySecondAxisY) + verLab->setText( tr( "VERTICAL_LEFT_AXIS" ) ); + + QFont font = horLab->font(); font.setBold( true ); + horLab->setFont( font ); verLab->setFont( font ); + + aGridLayout->addLayout( aModeLayout, 0, 0, 1, 5 ); + aGridLayout->addWidget( aHLine, 1, 0, 1, 5 ); + aGridLayout->addWidget( horLab, 2, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 2, 1 ); + aGridLayout->addWidget( myXMinEdit, 2, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 2, 3 ); + aGridLayout->addWidget( myXMaxEdit, 2, 4 ); + aGridLayout->addWidget( verLab, 3, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 3, 1 ); + aGridLayout->addWidget( myYMinEdit, 3, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 3, 3 ); + aGridLayout->addWidget( myYMaxEdit, 3, 4 ); + + if (mySecondAxisY) { + QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp ); + ver2Lab->setFont( font ); + aGridLayout->addWidget( ver2Lab, 4, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 4, 1 ); + aGridLayout->addWidget( myY2MinEdit, 4, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 4, 3 ); + aGridLayout->addWidget( myY2MaxEdit, 4, 4 ); + } + + // OK/Cancel buttons + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myOkBtn->setObjectName( "buttonOk" ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + myCancelBtn->setObjectName( "buttonCancel" ); + myCancelBtn->setAutoDefault( TRUE ); + + topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 ); + topLayout->addWidget( myOkBtn, 1, 0 ); + topLayout->setColumnStretch( 1, 5 ); + topLayout->addWidget( myCancelBtn, 1, 2 ); + + // connect signals + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myRangeGrp, SIGNAL( clicked( int ) ), this, SLOT( onModeChanged( int ) ) ); + + // initial state + myModeAllRB->setChecked( true ); + onModeChanged( 0 ); +} + +/*! + Sets range +*/ +void Plot2d_FitDataDlg::setRange( const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min, + const double y2Max) +{ + myXMinEdit->setText( QString::number( xMin ) ); + myXMaxEdit->setText( QString::number( xMax ) ); + myYMinEdit->setText( QString::number( yMin ) ); + myYMaxEdit->setText( QString::number( yMax ) ); + if (mySecondAxisY) { + myY2MinEdit->setText( QString::number( y2Min ) ); + myY2MaxEdit->setText( QString::number( y2Max ) ); + } +} + +/*! + Gets range, returns mode (see getMode()) +*/ +int Plot2d_FitDataDlg::getRange( double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max) +{ + xMin = myXMinEdit->text().toDouble(); + xMax = myXMaxEdit->text().toDouble(); + yMin = myYMinEdit->text().toDouble(); + yMax = myYMaxEdit->text().toDouble(); + if (mySecondAxisY) { + y2Min = myY2MinEdit->text().toDouble(); + y2Max = myY2MaxEdit->text().toDouble(); + } + else { + y2Min = 0; + y2Max = 0; + } + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical +*/ +int Plot2d_FitDataDlg::getMode() +{ + int myMode = 0; + if ( myModeAllRB->isChecked() ) + myMode = 0; + if ( myModeHorRB->isChecked() ) + myMode = 1; + if ( myModeVerRB->isChecked() ) + myMode = 2; + return myMode; +} + +/*! + Called when range mode changed +*/ +void Plot2d_FitDataDlg::onModeChanged(int mode) +{ + bool badFocus; + switch( mode ) { + case 0: // fit all mode + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + break; + case 1: // fit horizontal mode + badFocus = myYMinEdit->hasFocus() || myYMaxEdit->hasFocus(); + myXMinEdit->setEnabled(true); + myXMaxEdit->setEnabled(true); + myYMinEdit->setEnabled(false); + myYMaxEdit->setEnabled(false); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(false); + myY2MaxEdit->setEnabled(false); + } + if (badFocus) + myXMinEdit->setFocus(); + break; + case 2: // fit vertical mode + badFocus = myXMinEdit->hasFocus() || myXMaxEdit->hasFocus(); + myXMinEdit->setEnabled(false); + myXMaxEdit->setEnabled(false); + myYMinEdit->setEnabled(true); + myYMaxEdit->setEnabled(true); + if (mySecondAxisY) { + myY2MinEdit->setEnabled(true); + myY2MaxEdit->setEnabled(true); + } + if (badFocus) + myYMinEdit->setFocus(); + break; + } +} + diff --git a/src/SVTK/SVTK_FitDataDlg.h b/src/SVTK/SVTK_FitDataDlg.h new file mode 100644 index 000000000..096a8baa6 --- /dev/null +++ b/src/SVTK/SVTK_FitDataDlg.h @@ -0,0 +1,75 @@ +// 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 +// +#ifndef PLOT2D_FITDATADLG_H +#define PLOT2D_FITDATADLG_H + +#include "Plot2d.h" +#include + +class QGroupBox; +class QRadioButton; +class QLineEdit; +class QPushButton; + +class PLOT2D_EXPORT Plot2d_FitDataDlg : public QDialog +{ + Q_OBJECT + +public: +// constuctor + Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY ); + +// sets range + void setRange(const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double y2Min = 0, + const double y2Max = 0); +// gets range, returns mode (see getMode()) + int getRange(double& xMin, + double& xMax, + double& yMin, + double& yMax, + double& y2Min, + double& y2Max); +// gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical + int getMode(); + +protected slots: +// called when range mode changed + void onModeChanged(int); + +private: + QGroupBox* myRangeGrp; + QRadioButton* myModeAllRB; + QRadioButton* myModeHorRB; + QRadioButton* myModeVerRB; + QLineEdit* myXMinEdit; + QLineEdit* myYMinEdit; + QLineEdit* myY2MinEdit; + QLineEdit* myXMaxEdit; + QLineEdit* myYMaxEdit; + QLineEdit* myY2MaxEdit; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + bool mySecondAxisY; +}; + +#endif diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index bbaf40ded..c84b84bc7 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -324,6 +324,13 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) */ void SVTK_Viewer::contextMenuPopup( QMenu* thePopup ) { + SVTK_ViewWindow* aView = (SVTK_ViewWindow*)myViewManager->getActiveView(); + if( aView ) + aView->contextMenuPopup( thePopup ); + + if( !thePopup->isEmpty() ) + thePopup->addSeparator(); + thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index ad94c7c18..5df7b7edc 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -24,10 +24,12 @@ #include "SVTK_ViewParameterDlg.h" #include "Plot3d_Actor.h" +#include "Plot3d_FitDataDlg.h" #include "Plot3d_SetupSurfacesDlg.h" #include "SALOME_Actor.h" +#include #include #include #include @@ -44,6 +46,7 @@ #include #include #include +#include #include "QtxAction.h" @@ -233,6 +236,15 @@ void SVTK_ViewWindow::Initialize(SVTK_View* theView, SVTK_ViewWindow::~SVTK_ViewWindow() {} +/*! + Fill the context menu + \param thePopup context menu +*/ +void SVTK_ViewWindow::contextMenuPopup( QMenu* thePopup ) +{ + if( myMode2D ) + thePopup->addAction( tr( "TOT_SVTK_FITDATA" ), this, SLOT( onFitData() ) ); +} /*! \return corresponding view @@ -2259,7 +2271,8 @@ void SVTK_ViewWindow::onSurfacesSettings() if( Plot3d_Actor* aSurface = dynamic_cast( anActor ) ) { aSurfaces << aSurface; - aNameList << aSurface->getName(); + if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() ) + aNameList << aScalarBar->GetTitle(); } } @@ -2285,6 +2298,7 @@ void SVTK_ViewWindow::onSurfacesSettings() Plot3d_Actor* aSurface = aSurfaces[ anIndex ]; aSurfaces.removeAt( anIndex ); aSurface->RemoveFromRender( aRenderer ); + aSurface->Delete(); } } @@ -2301,7 +2315,8 @@ void SVTK_ViewWindow::onSurfacesSettings() { Plot3d_Actor* aSurface = anIndexToSurface[ i ]; QString aText = aTexts[ i ]; - aSurface->setName( aText.toLatin1().constData() ); + if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() ) + aScalarBar->SetTitle( aText.toLatin1().constData() ); } vtkFloatingPointType aGlobalBounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN, @@ -2339,3 +2354,11 @@ void SVTK_ViewWindow::onSurfacesSettings() SetScale( aScale ); onFitAll(); } + +/*! + Fit 2D surfaces to the specified data range +*/ +void SVTK_ViewWindow::onFitData() +{ + // to do +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 3df84190c..14b3e6cea 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -97,6 +97,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! To initialize #SVTK_ViewWindow instance virtual void Initialize(SVTK_ViewModelBase* theModel); + //! Fill the context menu + void contextMenuPopup( QMenu* thePopup ); + //! Get #SVTK_View SVTK_View* getView(); @@ -312,6 +315,8 @@ public slots: void onSurfacesSettings(); + void onFitData(); + void onStartRecording(); void onPlayRecording(); void onPauseRecording(); diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index a31323cde..987cb7c0f 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -343,6 +343,10 @@ Tool jpeg2yuv, necessary for AVI recording, is not available. Please, refer to the documentation. + + TOT_SVTK_FITDATA + Fit range + SVTK_NonIsometricDlg @@ -625,6 +629,45 @@ Please, refer to the documentation. Change background... + + Plot3d_FitDataDlg + + FIT_HORIZONTAL + Fit horizontally + + + MIN_VALUE_LAB + Min: + + + VERTICAL_AXIS + Vertical axis + + + MAX_VALUE_LAB + Max: + + + HORIZONTAL_AXIS + Horizontal axis + + + VERTICAL_LEFT_AXIS + Vertical left axis + + + FIT_ALL + Fit both + + + VERTICAL_RIGHT_AXIS + Vertical right axis + + + FIT_VERTICAL + Fit vertically + + Plot3d_SetupSurfacesDlg -- 2.39.2