From: ana Date: Wed, 28 Dec 2011 13:22:13 +0000 (+0000) Subject: Implementation of the "0021387: [CEA 511] Plot2d Normalize Plot2d view" issue. X-Git-Tag: pxsxl1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7d4fdb91b3d8f524c99fcfdfdddf5e3b8b4d9ac9;p=modules%2Fgui.git Implementation of the "0021387: [CEA 511] Plot2d Normalize Plot2d view" issue. --- diff --git a/src/Plot2d/Makefile.am b/src/Plot2d/Makefile.am index 02922e499..0aa21990a 100755 --- a/src/Plot2d/Makefile.am +++ b/src/Plot2d/Makefile.am @@ -43,6 +43,8 @@ salomeinclude_HEADERS = \ Plot2d_ViewManager.h \ Plot2d_ViewModel.h \ Plot2d_ViewWindow.h \ + Plot2d_Algorithm.h \ + Plot2d_NormalizeAlgorithm.h \ Plot2d_SetupCurveDlg.h \ Plot2d_ToolTip.h \ Plot2d_SetupCurveScaleDlg.h @@ -68,6 +70,8 @@ dist_libPlot2d_la_SOURCES = \ Plot2d_ViewManager.cxx \ Plot2d_ViewModel.cxx \ Plot2d_ViewWindow.cxx \ + Plot2d_Algorithm.cxx \ + Plot2d_NormalizeAlgorithm.cxx \ Plot2d_SetupCurveDlg.cxx \ Plot2d_SetupCurveScaleDlg.cxx \ Plot2d_ToolTip.cxx @@ -87,6 +91,8 @@ MOC_FILES = \ Plot2d_ViewModel_moc.cxx \ Plot2d_ViewWindow_moc.cxx \ Plot2d_SetupCurveDlg_moc.cxx \ + Plot2d_Algorithm_moc.cxx \ + Plot2d_NormalizeAlgorithm_moc.cxx \ Plot2d_SetupCurveScaleDlg_moc.cxx \ Plot2d_ToolTip_moc.cxx @@ -114,6 +120,10 @@ dist_salomeres_DATA = \ resources/plot2d_settings.png \ resources/plot2d_splines.png \ resources/plot2d_analitic_curve.png \ + resources/plot2d_lmax_normalization.png \ + resources/plot2d_lmin_normalization.png \ + resources/plot2d_rmax_normalization.png \ + resources/plot2d_rmin_normalization.png \ resources/plot2d_zoom.png nodist_salomeres_DATA = \ diff --git a/src/Plot2d/Plot2d_Algorithm.cxx b/src/Plot2d/Plot2d_Algorithm.cxx new file mode 100755 index 000000000..4e1a1c62a --- /dev/null +++ b/src/Plot2d/Plot2d_Algorithm.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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_Algorithm.cxx + +#include "Plot2d_Algorithm.h" + +/*! + Constructor +*/ +Plot2d_Algorithm::Plot2d_Algorithm(QObject *parent) : + QObject(parent), + myDataChanged(false) +{ +} + +/*! + Destructor +*/ +Plot2d_Algorithm::~Plot2d_Algorithm() +{ +} + +/*! + Sets input data values +*/ +void Plot2d_Algorithm::setInput(AlgoPlot2dInputData theInuptData) +{ + clear(); + myInuptData = theInuptData; + myDataChanged = true; +} + +/*! + Gets result data values +*/ +AlgoPlot2dOutputData Plot2d_Algorithm::getOutput() +{ + return myResultData; +} + +/*! + Check the data values changed +*/ +bool Plot2d_Algorithm::isDataChanged() +{ + return myDataChanged; +} + + +void Plot2d_Algorithm::clear() { + myDataChanged=false; + myInuptData.clear(); + myResultData.clear(); +} \ No newline at end of file diff --git a/src/Plot2d/Plot2d_Algorithm.h b/src/Plot2d/Plot2d_Algorithm.h new file mode 100755 index 000000000..43595ab9a --- /dev/null +++ b/src/Plot2d/Plot2d_Algorithm.h @@ -0,0 +1,58 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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_Algorithm.h + +#ifndef PLOT2D_ALGORITHM_H +#define PLOT2D_ALGORITHM_H + +#include "Plot2d.h" + +#include +#include +#include + +class Plot2d_Object; + +typedef QList< QPair > AlgoPlot2dItem; +typedef QList AlgoPlot2dInputData; +typedef QMap AlgoPlot2dOutputData; + +class PLOT2D_EXPORT Plot2d_Algorithm : public QObject { + Q_OBJECT +public: + Plot2d_Algorithm(QObject *parent = 0); + ~Plot2d_Algorithm(); + + void setInput(AlgoPlot2dInputData); + AlgoPlot2dOutputData getOutput(); + virtual void execute() = 0; + virtual void clear(); + + bool isDataChanged(); + +protected: + AlgoPlot2dInputData myInuptData; + AlgoPlot2dOutputData myResultData; + bool myDataChanged; +}; + +#endif //PLOT2D_ALGORITHM_H diff --git a/src/Plot2d/Plot2d_NormalizeAlgorithm.cxx b/src/Plot2d/Plot2d_NormalizeAlgorithm.cxx new file mode 100755 index 000000000..f30b618b8 --- /dev/null +++ b/src/Plot2d/Plot2d_NormalizeAlgorithm.cxx @@ -0,0 +1,183 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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_NormalizeAlgorithm.cxx + +#include "Plot2d_NormalizeAlgorithm.h" +#include +#include +#include "Plot2d_Object.h" + +/*! + Constructor +*/ +Plot2d_NormalizeAlgorithm::Plot2d_NormalizeAlgorithm(QObject *parent) : + Plot2d_Algorithm(parent), + myNormalizationMode(NormalizeNone) +{ +} + +/*! + Destructor +*/ +Plot2d_NormalizeAlgorithm::~Plot2d_NormalizeAlgorithm() +{ +} + +/*! + Sets normalozation mode +*/ +void Plot2d_NormalizeAlgorithm::setNormalizationMode(NormalizationMode theMode) { + if(myNormalizationMode != theMode) { + myNormalizationMode = theMode; + myDataChanged = true; + } +} + +/*! + Gets normalozation mode +*/ +Plot2d_NormalizeAlgorithm::NormalizationMode Plot2d_NormalizeAlgorithm::getNormalizationMode()const { + return myNormalizationMode; +} + +/*! + Gets k normalization coefficient +*/ +double Plot2d_NormalizeAlgorithm::getKkoef(Plot2d_Object* theObj) +{ + QMap::iterator it = myKkoefs.find(theObj); + if(it != myKkoefs.end()) + return it.value(); + return 0; +} + +/*! + Gets b normalization coefficient +*/ +double Plot2d_NormalizeAlgorithm::getBkoef(Plot2d_Object* theObj) +{ + QMap::iterator it = myBkoefs.find(theObj); + if(it != myBkoefs.end()) + return it.value(); + return 0; + +} + +void Plot2d_NormalizeAlgorithm::execute() { + if (!isDataChanged() || myInuptData.isEmpty()) + return; + + if (myNormalizationMode != NormalizeNone) { + QList yMinLst, yMaxLst; + QList aKkoefs,aBkoefs; + double _pMin, _pMax; + for (int i = 0; i < myInuptData.size(); ++i) { + QList aTmpItemValues; + Plot2d_Object* object = myInuptData.at(i); + double *x, *y; + long nb = object->getData( &x, &y ); + for (int j = 0; j < nb; ++j) { + aTmpItemValues<getPoint(j).y; + } + delete x; + delete y; + yMaxLst<<*(std::max_element(aTmpItemValues.begin(), aTmpItemValues.end())); + yMinLst<<*(std::min_element(aTmpItemValues.begin(), aTmpItemValues.end())); + } + _pMin = *(std::min_element(yMinLst.begin(), yMinLst.end())); + _pMax = *(std::max_element(yMaxLst.begin(), yMaxLst.end())); + + double pMin, pMax, kKoef, bKoef, yMin, yMax; + switch( getNormalizationMode() ) { + case NormalizeToMin: + pMin = _pMin; + for (int i = 0; i < yMaxLst.size(); ++i) { + yMin = yMinLst.at(i); + yMax = yMaxLst.at(i); + pMax = yMax; + kKoef = (pMax - pMin)/(yMax - yMin); + bKoef = pMin - kKoef * yMin; + aBkoefs<nbPoints(); ++j) { + yOld = myInuptData.at(i)->getPoint(j).y; + xOld = myInuptData.at(i)->getPoint(j).x; + yNew = aKkoefs.at(i) * yOld + aBkoefs.at(i); + tmpItem.append( qMakePair(xOld, yNew) ); + } + myResultData.insert(myInuptData.at(i),tmpItem); + myKkoefs.insert(myInuptData.at(i),aKkoefs.at(i)); + myBkoefs.insert(myInuptData.at(i),aBkoefs.at(i)); + } + } else { + for (int i = 0; i < myInuptData.size(); ++i) { + double yOld,xOld; + AlgoPlot2dItem tmpItem; + for (int j = 0; j < myInuptData.at(i)->nbPoints(); ++j) { + yOld = myInuptData.at(i)->getPoint(j).y; + xOld = myInuptData.at(i)->getPoint(j).x; + tmpItem.append( qMakePair(xOld, yOld) ); + } + myResultData.insert(myInuptData.at(i),tmpItem); + } + + } + myDataChanged = false; +} + + +void Plot2d_NormalizeAlgorithm::clear() { + Plot2d_Algorithm::clear(); + myBkoefs.clear(); + myKkoefs.clear(); +} \ No newline at end of file diff --git a/src/Plot2d/Plot2d_NormalizeAlgorithm.h b/src/Plot2d/Plot2d_NormalizeAlgorithm.h new file mode 100755 index 000000000..5156a218b --- /dev/null +++ b/src/Plot2d/Plot2d_NormalizeAlgorithm.h @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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_NormalizeAlgorithm.h + +#ifndef PLOT2D_NORMALIZEALGORITHM_H +#define PLOT2D_NORMALIZEALGORITHM_H + +#include "Plot2d.h" +#include "Plot2d_Algorithm.h" +#include + +class Plot2d_Object; + +class PLOT2D_EXPORT Plot2d_NormalizeAlgorithm : public Plot2d_Algorithm { + Q_OBJECT +public: + Plot2d_NormalizeAlgorithm(QObject *parent); + ~Plot2d_NormalizeAlgorithm(); + + enum NormalizationMode { NormalizeToMin, NormalizeToMax, NormalizeToMinMax, NormalizeNone }; + + void setNormalizationMode(NormalizationMode); + NormalizationMode getNormalizationMode() const; + double getKkoef(Plot2d_Object*); + double getBkoef(Plot2d_Object*); + virtual void execute(); + virtual void clear(); + +private: + NormalizationMode myNormalizationMode; + QMap myBkoefs; + QMap myKkoefs; +}; + +#endif //PLOT2D_NORMALIZEALGORITHM_H diff --git a/src/Plot2d/Plot2d_Object.cxx b/src/Plot2d/Plot2d_Object.cxx index 3498791bd..cc525e017 100755 --- a/src/Plot2d/Plot2d_Object.cxx +++ b/src/Plot2d/Plot2d_Object.cxx @@ -298,6 +298,14 @@ pointList Plot2d_Object::getPointList() const return myPoints; } +/*! + Gets points by index. +*/ + +Plot2d_Point& Plot2d_Object::getPoint(int index) { + return myPoints[index]; +} + /*! Gets object's data : abscissas of points */ diff --git a/src/Plot2d/Plot2d_Object.h b/src/Plot2d/Plot2d_Object.h index 3b7c048f8..60b8cd010 100755 --- a/src/Plot2d/Plot2d_Object.h +++ b/src/Plot2d/Plot2d_Object.h @@ -72,6 +72,7 @@ public: void clearAllPoints(); pointList getPointList() const; void setPointList( const pointList& points ); + Plot2d_Point& getPoint(int index); void setData( const double*, const double*, long, const QStringList& = QStringList() ); diff --git a/src/Plot2d/Plot2d_SetupViewDlg.cxx b/src/Plot2d/Plot2d_SetupViewDlg.cxx index b5770fa90..07e143455 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.cxx +++ b/src/Plot2d/Plot2d_SetupViewDlg.cxx @@ -113,6 +113,25 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, QLabel* aBGLab = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this ); myBackgroundBtn = new QtxColorButton( this ); + // normalize mode + QGroupBox* aNormalizeGrp = new QGroupBox( tr( "PLOT2D_NORMALIZE_TLT" ), this ); + QGridLayout* aNormalizeLayout = new QGridLayout( aNormalizeGrp ); + aNormalizeLayout->setMargin( MARGIN_SIZE ); aNormalizeLayout->setSpacing( SPACING_SIZE ); + aNormalizeGrp->setLayout( aNormalizeLayout ); + QLabel* aYLeftLab = new QLabel( tr( "PLOT2D_NORMALIZE_LEFT_AXIS" ), aNormalizeGrp ); + myNormLMinCheck = new QCheckBox( tr( "PLOT2D_NORMALIZE_MODE_MIN" ), aNormalizeGrp ); + myNormLMaxCheck = new QCheckBox( tr( "PLOT2D_NORMALIZE_MODE_MAX" ), aNormalizeGrp ); + QLabel* aYRightLab = new QLabel( tr( "PLOT2D_NORMALIZE_RIGHT_AXIS" ), aNormalizeGrp ); + myNormRMinCheck = new QCheckBox( tr( "PLOT2D_NORMALIZE_MODE_MIN" ), aNormalizeGrp ); + myNormRMaxCheck = new QCheckBox( tr( "PLOT2D_NORMALIZE_MODE_MAX" ), aNormalizeGrp ); + + aNormalizeLayout->addWidget( aYLeftLab, 0, 0 ); + aNormalizeLayout->addWidget( myNormLMaxCheck, 0, 1 ); + aNormalizeLayout->addWidget( myNormLMinCheck, 0, 2 ); + aNormalizeLayout->addWidget( aYRightLab, 1, 0 ); + aNormalizeLayout->addWidget( myNormRMaxCheck, 1, 1 ); + aNormalizeLayout->addWidget( myNormRMinCheck, 1, 2 ); + // scale mode QGroupBox* aScaleGrp = new QGroupBox( tr( "PLOT2D_SCALE_TLT" ), this ); QGridLayout* aScaleLayout = new QGridLayout( aScaleGrp ); @@ -232,7 +251,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, myYMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); aGridLayoutY->addWidget( myYGridCheck, 0, 0 ); - aGridLayoutY->addWidget( aYMajLbl, 0, 1 ); + aGridLayoutY->addWidget( aYMajLbl, 0, 1 ); aGridLayoutY->addWidget( myYGridSpin, 0, 2 ); aGridLayoutY->addWidget( myYMinGridCheck, 1, 0 ); aGridLayoutY->addWidget( aYMinLbl, 1, 1 ); @@ -339,12 +358,13 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch(); topLayout->addWidget( aBGLab, 3, 2 ); topLayout->addLayout( bgLayout, 3, 3 ); - topLayout->addWidget( aScaleGrp, 4, 0, 1, 4 ); - topLayout->addWidget( aTabWidget, 5, 0, 1, 4 ); - topLayout->addWidget( myDefCheck, 6, 0, 1, 4 ); - topLayout->setRowStretch( 6, 5 ); + topLayout->addWidget( aNormalizeGrp, 4, 0, 1, 4 ); + topLayout->addWidget( aScaleGrp, 5, 0, 1, 4 ); + topLayout->addWidget( aTabWidget, 6, 0, 1, 4 ); + topLayout->addWidget( myDefCheck, 7, 0, 1, 4 ); + topLayout->setRowStretch( 7, 5 ); - topLayout->addLayout( btnLayout, 7, 0, 1, 4 ); + topLayout->addLayout( btnLayout, 8, 0, 1, 4 ); if ( !showDefCheck ) myDefCheck->hide(); @@ -357,6 +377,11 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, connect( myYGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMajorChecked() ) ); connect( myXMinGridCheck, SIGNAL( clicked() ), this, SLOT( onXGridMinorChecked() ) ); connect( myYMinGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMinorChecked() ) ); + connect( myNormLMaxCheck, SIGNAL( clicked() ), this, SLOT( onNormLMaxChecked() ) ); + connect( myNormLMinCheck, SIGNAL( clicked() ), this, SLOT( onNormLMinChecked() ) ); + connect( myNormRMaxCheck, SIGNAL( clicked() ), this, SLOT( onNormRMaxChecked() ) ); + connect( myNormRMinCheck, SIGNAL( clicked() ), this, SLOT( onNormRMinChecked() ) ); + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); @@ -377,6 +402,10 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, onXGridMajorChecked(); onYGridMajorChecked(); onXGridMinorChecked(); + onNormLMaxChecked(); + onNormLMinChecked(); + onNormRMaxChecked(); + onNormRMinChecked(); if ( mySecondAxisY ) { onY2TitleChecked(); onY2GridMajorChecked(); @@ -547,6 +576,86 @@ int Plot2d_SetupViewDlg::getCurveType() return myCurveCombo->currentIndex(); } +/*! + \brief Set normalization to maximum by left Y axis. + \param type normalizatoin type: true,false + \sa getMaxNormMode() +*/ +void Plot2d_SetupViewDlg::setLMaxNormMode( const bool type ) +{ + myNormLMaxCheck->setChecked( type ); +} + +/*! + \brief Check if normalization to maximum by left Y axis sets. + \return curve normalizatoin type: true,false + \sa setMaxNormMode() +*/ +bool Plot2d_SetupViewDlg::getLMaxNormMode() +{ + return myNormLMaxCheck->isChecked(); +} + +/*! + \brief Set normalization to minimum by left Y axis. + \param type normalizatoin type: true,false + \sa getMinNormMode() +*/ +void Plot2d_SetupViewDlg::setLMinNormMode( const bool type ) +{ + myNormLMinCheck->setChecked( type ); +} + +/*! + \brief Check if normalization to minimum by left Y axis sets. + \return curve normalizatoin type: true,false + \sa setMinNormMode() +*/ +bool Plot2d_SetupViewDlg::getLMinNormMode() +{ + return myNormLMinCheck->isChecked(); +} + +/*! + \brief Set normalization to maximum by right Y axis. + \param type normalizatoin type: true,false + \sa getMaxNormMode() +*/ +void Plot2d_SetupViewDlg::setRMaxNormMode( const bool type ) +{ + myNormRMaxCheck->setChecked( type ); +} + +/*! + \brief Check if normalization to maximum by right Y axis sets. + \return curve normalizatoin type: true,false + \sa setMaxNormMode() +*/ +bool Plot2d_SetupViewDlg::getRMaxNormMode() +{ + return myNormRMaxCheck->isChecked(); +} + +/*! + \brief Set normalization to minimum by right Y axis. + \param type normalizatoin type: true,false + \sa getMinNormMode() +*/ +void Plot2d_SetupViewDlg::setRMinNormMode( const bool type ) +{ + myNormRMinCheck->setChecked( type ); +} + +/*! + \brief Check if normalization to minimum by right Y axis sets. + \return curve normalizatoin type: true,false + \sa setMinNormMode() +*/ +bool Plot2d_SetupViewDlg::getRMinNormMode() +{ + return myNormRMinCheck->isChecked(); +} + /*! \brief Set legend attribute. \param if \c true legend is shown @@ -871,6 +980,34 @@ void Plot2d_SetupViewDlg::onY2GridMinorChecked() { } +/*! + \brief Called when user clicks "Left Y Axis: Normalize to maximum" check box. +*/ +void Plot2d_SetupViewDlg::onNormLMaxChecked() +{ +} + +/*! + \brief Called when user clicks "Left Y Axis: Normalize to minimum" check box. +*/ +void Plot2d_SetupViewDlg::onNormLMinChecked() +{ +} + +/*! + \brief Called when user clicks "Right Y Axis: Normalize to maximum" check box. +*/ +void Plot2d_SetupViewDlg::onNormRMaxChecked() +{ +} + +/*! + \brief Called when user clicks "Right Y Axis: Normalize to minimum" check box. +*/ +void Plot2d_SetupViewDlg::onNormRMinChecked() +{ +} + /*! \brief Get "Set settings as default" check box value. \return \c true if "Set settings as default" check box is on diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h index 50c7e8c37..f109d1ba9 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.h +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -64,6 +64,15 @@ public: void setCurveType( const int ); int getCurveType(); + bool getLMaxNormMode(); + void setLMaxNormMode(const bool); + bool getLMinNormMode(); + void setLMinNormMode(const bool); + bool getRMaxNormMode(); + void setRMaxNormMode(const bool); + bool getRMinNormMode(); + void setRMinNormMode(const bool); + void setLegend( bool, int, const QFont&, const QColor& ); bool isLegendEnabled(); int getLegendPos(); @@ -99,6 +108,10 @@ protected slots: void onXGridMinorChecked(); void onYGridMinorChecked(); void onY2GridMinorChecked(); + void onNormLMaxChecked(); + void onNormLMinChecked(); + void onNormRMaxChecked(); + void onNormRMinChecked(); void onHelp(); private: @@ -131,6 +144,10 @@ private: QSpinBox* myMarkerSpin; QComboBox* myXModeCombo; QComboBox* myYModeCombo; + QCheckBox* myNormLMaxCheck; + QCheckBox* myNormLMinCheck; + QCheckBox* myNormRMaxCheck; + QCheckBox* myNormRMinCheck; QComboBox* myY2ModeCombo; QCheckBox* myDefCheck; QPushButton* myOkBtn; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index ea4972f95..9de2a5cea 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -172,9 +172,12 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ), myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ), myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ), - myXMode( 0 ), myYMode( 0 ), mySecondY( false ), myIsDefTitle( true ) + myXMode( 0 ), myYMode( 0 ),myNormLMin(false), myNormLMax(false), myNormRMin(false), myNormRMax(false), + mySecondY( false ), myIsDefTitle( true ) { setObjectName( title ); + myRNormAlgo = new Plot2d_NormalizeAlgorithm(this); + myLNormAlgo = new Plot2d_NormalizeAlgorithm(this); /* Plot 2d View */ QVBoxLayout* aLayout = new QVBoxLayout( this ); myPlot = new Plot2d_Plot2d( this ); @@ -411,6 +414,10 @@ void Plot2d_ViewFrame::readPreferences() setHorScaleMode( qMax( 0, qMin( 1, resMgr->integerValue( "Plot2d", "HorScaleMode", myXMode ) ) ), false ); setVerScaleMode( qMax( 0, qMin( 1, resMgr->integerValue( "Plot2d", "VerScaleMode", myYMode ) ) ), false ); + setNormLMinMode( resMgr->booleanValue( "Plot2d", "VerNormLMinMode", myNormLMin ) ); + setNormLMaxMode( resMgr->booleanValue( "Plot2d", "VerNormLMaxMode", myNormLMax ) ); + setNormRMinMode( resMgr->booleanValue( "Plot2d", "VerNormRMinMode", myNormRMin ) ); + setNormRMaxMode( resMgr->booleanValue( "Plot2d", "VerNormRMaxMode", myNormRMax ) ); } /*! @@ -455,6 +462,10 @@ void Plot2d_ViewFrame::writePreferences() } resMgr->setValue( "Plot2d", "VerScaleMode", myYMode ); + resMgr->setValue( "Plot2d", "VerNormLMinMode", myNormLMin ); + resMgr->setValue( "Plot2d", "VerNormLMaxMode", myNormLMax ); + resMgr->setValue( "Plot2d", "VerNormRMinMode", myNormRMin ); + resMgr->setValue( "Plot2d", "VerNormRMaxMode", myNormRMax ); } /*! @@ -606,6 +617,54 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) updateObject( curve, update ); } +void Plot2d_ViewFrame::processFiltering(bool update) +{ + CurveDict aCurves = getCurves(); + AlgoPlot2dInputData aLData, aRData; + CurveDict::iterator it; + for ( it = aCurves.begin(); it != aCurves.end(); it++ ) { + Plot2d_Object* objItem = it.value(); + if (objItem->getYAxis() == QwtPlot::yRight) + aRData.append(objItem); + else + aLData.append(objItem); + } + +// Normalization by left Y axis + if (!myNormLMin && !myNormLMax) + myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone); + if(myNormLMin && myNormLMax) + myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax); + else if(myNormLMin) + myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin); + else if(myNormLMax) + myLNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMax); + + myLNormAlgo->setInput(aLData); + myLNormAlgo->execute(); + +// Normalization by right Y axis + if (!myNormRMin && !myNormRMax) + myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeNone); + if(myNormRMin && myNormRMax) + myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMinMax); + else if(myNormRMin) + myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMin); + else if(myNormRMax) + myRNormAlgo->setNormalizationMode(Plot2d_NormalizeAlgorithm::NormalizeToMax); + + myRNormAlgo->setInput(aRData); + myRNormAlgo->execute(); + + for ( it = aCurves.begin(); it != aCurves.end(); it++) { + QwtPlotCurve* item = it.key(); + Plot2d_Object* objItem = it.value(); + updatePlotItem(objItem, item); + } + if(update) + myPlot->replot(); +} + /*! Gets lsit of displayed curves */ @@ -659,6 +718,7 @@ void Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update ) object->autoFill( myPlot ); if ( hasPlotObject( object ) ) { + processFiltering(update); updateObject( object, update ); } else { @@ -671,7 +731,8 @@ void Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update ) Plot2d_Curve* aCurve = dynamic_cast( object ); if ( aCurve ) { aCurve->setMarkerSize( myMarkerSize ); - aCurve->updatePlotItem( anItem ); + processFiltering(update); + updatePlotItem( aCurve, anItem ); setCurveType( getPlotCurve( aCurve ), myCurveType ); } } @@ -744,7 +805,7 @@ void Plot2d_ViewFrame::updateObject( Plot2d_Object* object, bool update ) QwtPlotItem* anItem = getPlotObject( object ); if ( !anItem ) return; - object->updatePlotItem( anItem ); + updatePlotItem(object, anItem ); anItem->setVisible( true ); if ( update ) myPlot->replot(); @@ -1055,6 +1116,10 @@ void Plot2d_ViewFrame::onSettings() dlg->setMarkerSize( myMarkerSize ); dlg->setBackgroundColor( myBackground ); dlg->setScaleMode(myXMode, myYMode); + dlg->setLMinNormMode(myNormLMin); + dlg->setLMaxNormMode(myNormLMax); + dlg->setRMinNormMode(myNormRMin); + dlg->setRMaxNormMode(myNormRMax); // dlg->setMajorGrid( myXGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::xBottom ), myYGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::yLeft ), @@ -1118,6 +1183,19 @@ void Plot2d_ViewFrame::onSettings() if ( myYMode != dlg->getYScaleMode() ) { setVerScaleMode( dlg->getYScaleMode() ); } + if ( myNormLMin != dlg->getLMinNormMode() ) { + setNormLMinMode( dlg->getLMinNormMode() ); + } + if ( myNormLMax != dlg->getLMaxNormMode() ) { + setNormLMaxMode( dlg->getLMaxNormMode() ); + } + if ( myNormRMin != dlg->getRMinNormMode() ) { + setNormRMinMode( dlg->getRMinNormMode() ); + } + if ( myNormRMax != dlg->getRMaxNormMode() ) { + setNormRMaxMode( dlg->getRMaxNormMode() ); + } + // update view myPlot->replot(); // update preferences @@ -1663,6 +1741,98 @@ int Plot2d_ViewFrame::getVerScaleMode() const return myYMode; } +/*! + Sets normalization mode to the global maximum by left Y axis +*/ +void Plot2d_ViewFrame::setNormLMaxMode( bool mode, bool update ) +{ + if ( myNormLMax == mode ) + return; + + myNormLMax = mode; + processFiltering(true); + if ( update ) + fitAll(); + emit vpNormLModeChanged(); +} + +/*! + Gets normalization mode to the global maximum by left Y axis +*/ +bool Plot2d_ViewFrame::getNormLMaxMode() const +{ + return myNormLMax; +} + +/*! + Sets normalization mode to the global minimum by left Y axis +*/ +void Plot2d_ViewFrame::setNormLMinMode( bool mode, bool update ) +{ + if ( myNormLMin == mode ) + return; + + myNormLMin = mode; + processFiltering(true); + if ( update ) + fitAll(); + emit vpNormLModeChanged(); +} + +/*! + Gets normalization mode to the global minimum by left Y axis +*/ +bool Plot2d_ViewFrame::getNormLMinMode() const +{ + return myNormLMax; +} + +/*! + Sets normalization mode to the global maximum by right Y axis +*/ +void Plot2d_ViewFrame::setNormRMaxMode( bool mode, bool update ) +{ + if ( myNormRMax == mode ) + return; + + myNormRMax = mode; + processFiltering(true); + if ( update ) + fitAll(); + emit vpNormRModeChanged(); +} + +/*! + Gets normalization mode to the global maximum by right Y axis +*/ +bool Plot2d_ViewFrame::getNormRMaxMode() const +{ + return myNormRMax; +} + +/*! + Sets normalization mode to the global minimum by right Y axis +*/ +void Plot2d_ViewFrame::setNormRMinMode( bool mode, bool update ) +{ + if ( myNormRMin == mode ) + return; + + myNormRMin = mode; + processFiltering(true); + if ( update ) + fitAll(); + emit vpNormRModeChanged(); +} + +/*! + Gets normalization mode to the global minimum by right Y axis +*/ +bool Plot2d_ViewFrame::getNormRMinMode() const +{ + return myNormRMax; +} + /*! Return, scale mode for horizontal axis */ @@ -1679,6 +1849,38 @@ bool Plot2d_ViewFrame::isModeVerLinear() return (myYMode == 0 ? true : false); } +/*! + Return \c True if curves are normalize to the global maximum by left Y axis +*/ +bool Plot2d_ViewFrame::isNormLMaxMode() +{ + return (myNormLMax ? true : false); +} + +/*! + Return \c True if curves are normalize to the global minimum by left Y axis +*/ +bool Plot2d_ViewFrame::isNormLMinMode() +{ + return (myNormLMin ? true : false); +} + +/*! + Return \c True if curves are normalize to the global maximum by right Y axis +*/ +bool Plot2d_ViewFrame::isNormRMaxMode() +{ + return (myNormRMax ? true : false); +} + +/*! + Return \c True if curves are normalize to the global minimum by right Y axis +*/ +bool Plot2d_ViewFrame::isNormRMinMode() +{ + return (myNormRMin ? true : false); +} + /*! Return \c True if legend is shown */ @@ -2558,6 +2760,44 @@ void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) { myPlot->replot(); } +/* + Update plot item +*/ +void Plot2d_ViewFrame::updatePlotItem(Plot2d_Object* theObject, QwtPlotItem* theItem) { + theObject->updatePlotItem( theItem ); + Plot2d_Curve* c = dynamic_cast(theObject); + QwtPlotCurve* cu = dynamic_cast(theItem); + Plot2d_NormalizeAlgorithm* aNormAlgo; + if(c && cu) { + if(c->getYAxis() == QwtPlot::yRight) + aNormAlgo = myRNormAlgo; + else + aNormAlgo = myLNormAlgo; + if(aNormAlgo->getNormalizationMode() != Plot2d_NormalizeAlgorithm::NormalizeNone) { + AlgoPlot2dOutputData aResultData = aNormAlgo->getOutput(); + AlgoPlot2dOutputData::iterator itTmp = aResultData.find(theObject); + double *xNew,*yNew; + int size = itTmp.value().size(); + xNew = new double[size]; + yNew = new double[size]; + int j = 0; + for (; j < size; ++j) { + xNew[j] = itTmp.value().at(j).first; + yNew[j] = itTmp.value().at(j).second; + } + cu->setData(xNew, yNew,j); + delete xNew; + delete yNew; + if(aNormAlgo->getNormalizationMode() != Plot2d_NormalizeAlgorithm::NormalizeNone) { + QString name = c->getName().isEmpty() ? c->getVerTitle() : c->getName(); + name = name + QString("(B=%1, K=%2)"); + name = name.arg(aNormAlgo->getBkoef(c)).arg(aNormAlgo->getKkoef(c)); + cu->setTitle(name); + } + } + } +} + /** * */ diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 71985514a..fdbe1f365 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -28,6 +28,7 @@ #ifndef DISABLE_PYCONSOLE #include "Plot2d_AnaliticCurve.h" #endif +#include "Plot2d_NormalizeAlgorithm.h" #include #include @@ -88,6 +89,7 @@ public: int getCurves( curveList& ) const; CurveDict getCurves() const; void updateCurve( Plot2d_Curve*, bool = false ); + void processFiltering(bool = false); /* objects operations */ void displayObject( Plot2d_Object*, bool = false ); @@ -144,9 +146,23 @@ public: int getHorScaleMode() const; void setVerScaleMode( const int, bool = true ); int getVerScaleMode() const; + void setNormLMaxMode( bool, bool = true); + bool getNormLMaxMode()const; + void setNormLMinMode( bool, bool = true); + bool getNormLMinMode()const; + void setNormRMaxMode( bool, bool = true); + bool getNormRMaxMode()const; + void setNormRMinMode( bool, bool = true); + bool getNormRMinMode()const; + bool isModeHorLinear(); bool isModeVerLinear(); + bool isNormLMaxMode(); + bool isNormLMinMode(); + bool isNormRMaxMode(); + bool isNormRMinMode(); + bool isLegendShow() const; // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: @@ -173,6 +189,8 @@ public: QwtPlotItem* getPlotObject( Plot2d_Object* ) const; QwtPlotCurve* getPlotCurve( Plot2d_Curve* ) const; Plot2d_Plot2d* getPlot() const { return myPlot; } + + void updatePlotItem(Plot2d_Object*, QwtPlotItem*); protected: int testOperation( const QMouseEvent& ); void readPreferences(); @@ -211,6 +229,8 @@ protected: signals: void vpModeHorChanged(); void vpModeVerChanged(); + void vpNormLModeChanged(); + void vpNormRModeChanged(); void vpCurveChanged(); void contextMenuRequested( QContextMenuEvent* ); void legendClicked( QwtPlotItem* ); @@ -234,12 +254,15 @@ protected: int myXGridMaxMajor, myYGridMaxMajor, myY2GridMaxMajor; int myXGridMaxMinor, myYGridMaxMinor, myY2GridMaxMinor; int myXMode, myYMode; + bool myNormLMin, myNormLMax, myNormRMin, myNormRMax; double myXDistance, myYDistance, myYDistance2; bool mySecondY; ObjectDict myObjects; #ifndef DISABLE_PYCONSOLE AnaliticCurveList myAnaliticCurves; #endif + Plot2d_NormalizeAlgorithm* myLNormAlgo; + Plot2d_NormalizeAlgorithm* myRNormAlgo; bool myIsDefTitle; }; diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index d4bcf6c94..a9cfe63b7 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -88,6 +88,8 @@ void Plot2d_ViewWindow::initLayout() connect( myViewFrame, SIGNAL( vpModeHorChanged() ), this, SLOT( onChangeHorMode() ) ); connect( myViewFrame, SIGNAL( vpModeVerChanged() ), this, SLOT( onChangeVerMode() ) ); + connect( myViewFrame, SIGNAL( vpNormLModeChanged() ), this, SLOT( onChangeNormLMode() ) ); + connect( myViewFrame, SIGNAL( vpNormRModeChanged() ), this, SLOT( onChangeNormRMode() ) ); connect( myViewFrame, SIGNAL( vpCurveChanged() ), this, SLOT( onChangeCurveMode() ) ); connect( myViewFrame, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ), this, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) ); @@ -156,6 +158,15 @@ void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup ) curTypePopup->addAction( mgr->action( CurvLinesId ) ); curTypePopup->addAction( mgr->action( CurvSplinesId ) ); + //Normalization type + QMenu* normTypePopup = thePopup->addMenu( tr( "NORMALIZATION_TYPE_POPUP" ) ); + normTypePopup->addAction( mgr->action( PModeNormLMinId ) ); + normTypePopup->addAction( mgr->action( PModeNormLMaxId ) ); + normTypePopup->addSeparator(); + normTypePopup->addAction( mgr->action( PModeNormRMinId ) ); + normTypePopup->addAction( mgr->action( PModeNormRMaxId ) ); + + // legend thePopup->addAction( mgr->action( LegendId ) ); @@ -359,7 +370,49 @@ void Plot2d_ViewWindow::createActions() aVerGroup->addAction( mgr->action( PModeYLinearId ) ); aVerGroup->addAction( mgr->action( PModeYLogarithmicId ) ); - // 7. Legend + // 7. Normalization mode operations + + // 7.1. Normalize to the global minimum by left Y axis + aAction = new QtxAction( tr( "TOT_PLOT2D_NORMALIZE_MODE_LMIN" ), + aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_NORMALIZE_MODE_LMIN" ) ), + tr( "MEN_PLOT2D_NORMALIZE_MODE_LMIN" ), + 0, this ); + aAction->setStatusTip( tr( "PRP_PLOT2D_NORMALIZE_MODE_LMIN" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewNormLMode() ) ); + aAction->setCheckable( true ); + mgr->registerAction( aAction, PModeNormLMinId ); + + // 7.2. Normalize to the global maximum by right Y axis + aAction = new QtxAction( tr( "TOT_PLOT2D_NORMALIZE_MODE_LMAX" ), + aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_NORMALIZE_MODE_LMAX" ) ), + tr( "MEN_PLOT2D_NORMALIZE_MODE_LMAX" ), + 0, this ); + aAction->setStatusTip( tr( "PRP_PLOT2D_NORMALIZE_MODE_LMAX" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewNormLMode() ) ); + aAction->setCheckable( true ); + mgr->registerAction( aAction, PModeNormLMaxId ); + + // 7.3. Normalize to the global minimum by right Y axis + aAction = new QtxAction( tr( "TOT_PLOT2D_NORMALIZE_MODE_RMIN" ), + aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_NORMALIZE_MODE_RMIN" ) ), + tr( "MEN_PLOT2D_NORMALIZE_MODE_RMIN" ), + 0, this ); + aAction->setStatusTip( tr( "PRP_PLOT2D_NORMALIZE_MODE_RMIN" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewNormRMode() ) ); + aAction->setCheckable( true ); + mgr->registerAction( aAction, PModeNormRMinId ); + + // 7.4. Normalize to the global maximum by left Y axis + aAction = new QtxAction( tr( "TOT_PLOT2D_NORMALIZE_MODE_RMAX" ), + aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_NORMALIZE_MODE_RMAX" ) ), + tr( "MEN_PLOT2D_NORMALIZE_MODE_RMAX" ), + 0, this ); + aAction->setStatusTip( tr( "PRP_PLOT2D_NORMALIZE_MODE_RMAX" ) ); + connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewNormRMode() ) ); + aAction->setCheckable( true ); + mgr->registerAction( aAction, PModeNormRMaxId ); + + // 8. Legend aAction = new QtxAction( tr( "TOT_PLOT2D_SHOW_LEGEND" ), aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_SHOW_LEGEND" ) ), tr( "MEN_PLOT2D_SHOW_LEGEND" ), @@ -369,7 +422,7 @@ void Plot2d_ViewWindow::createActions() aAction->setCheckable( true ); mgr->registerAction( aAction, LegendId ); - // 8. Settings + // 9. Settings aAction = new QtxAction( tr( "TOT_PLOT2D_SETTINGS" ), aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_SETTINGS" ) ), tr( "MEN_PLOT2D_SETTINGS" ), @@ -412,6 +465,8 @@ void Plot2d_ViewWindow::createActions() onChangeCurveMode(); onChangeHorMode(); onChangeVerMode(); + onChangeNormLMode(); + onChangeNormRMode(); onChangeLegendMode(); } @@ -430,6 +485,12 @@ void Plot2d_ViewWindow::createToolBar() mgr->append( CurvLinesId, myToolBar ); mgr->append( CurvSplinesId, myToolBar ); mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( PModeNormLMaxId, myToolBar ); + mgr->append( PModeNormLMinId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); + mgr->append( PModeNormRMaxId, myToolBar ); + mgr->append( PModeNormRMinId, myToolBar ); + mgr->append( toolMgr()->separator(), myToolBar ); mgr->append( PModeXLinearId, myToolBar ); mgr->append( PModeXLogarithmicId, myToolBar ); mgr->append( toolMgr()->separator(), myToolBar ); @@ -502,6 +563,42 @@ void Plot2d_ViewWindow::onChangeVerMode() toolMgr()->action( GlobalPanId )->setEnabled( aHorLinear && aVerLinear ); } +/*! + \brief Called when the normalization mode (by left Y axis) for curves is changed. +*/ +void Plot2d_ViewWindow::onChangeNormLMode() +{ + bool aNormMax = myViewFrame->isNormLMaxMode(); + bool aNormMin = myViewFrame->isNormLMinMode(); + + if ( aNormMax ) + toolMgr()->action( PModeNormLMaxId )->setChecked( true ); + else + toolMgr()->action( PModeNormLMaxId )->setChecked( false ); + if ( aNormMin ) + toolMgr()->action( PModeNormLMinId )->setChecked( true ); + else + toolMgr()->action( PModeNormLMinId )->setChecked( false ); +} + +/*! + \brief Called when the normalization mode (by left Y axis) for curves is changed. +*/ +void Plot2d_ViewWindow::onChangeNormRMode() +{ + bool aNormMax = myViewFrame->isNormRMaxMode(); + bool aNormMin = myViewFrame->isNormRMinMode(); + + if ( aNormMax ) + toolMgr()->action( PModeNormRMaxId )->setChecked( true ); + else + toolMgr()->action( PModeNormRMaxId )->setChecked( false ); + if ( aNormMin ) + toolMgr()->action( PModeNormRMinId )->setChecked( true ); + else + toolMgr()->action( PModeNormRMinId )->setChecked( false ); +} + /*! \brief Called when the curve type is changed. */ @@ -586,6 +683,26 @@ void Plot2d_ViewWindow::onViewVerMode() myViewFrame->setVerScaleMode( toolMgr()->action( PModeYLinearId )->isChecked() ? 0 : 1 ); } +/*! + \brief Called when normalization mode action (by left Y axis) is activated. +*/ + +void Plot2d_ViewWindow::onViewNormLMode() +{ + myViewFrame->setNormLMaxMode( toolMgr()->action( PModeNormLMaxId )->isChecked() ? true : false ); + myViewFrame->setNormLMinMode( toolMgr()->action( PModeNormLMinId )->isChecked() ? true : false ); +} + +/*! + \brief Called when normalization mode action (by right Y axis) is activated. +*/ + +void Plot2d_ViewWindow::onViewNormRMode() +{ + myViewFrame->setNormRMaxMode( toolMgr()->action( PModeNormRMaxId )->isChecked() ? true : false ); + myViewFrame->setNormRMinMode( toolMgr()->action( PModeNormRMinId )->isChecked() ? true : false ); +} + /*! \brief Called when the "Show legend" action is activated. */ diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index 86e52053c..66975732d 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -53,6 +53,8 @@ public: MoveOpId, PanId, GlobalPanId, PModeXLinearId, PModeXLogarithmicId, PModeYLinearId, PModeYLogarithmicId, + PModeNormLMaxId, PModeNormLMinId, + PModeNormRMaxId, PModeNormRMinId, CurvPointsId, CurvLinesId, CurvSplinesId, LegendId, CurvSettingsId, @@ -85,6 +87,9 @@ public slots: void onChangeVerMode(); void onChangeCurveMode(); void onChangeLegendMode(); + void onChangeNormLMode(); + void onChangeNormRMode(); + void onFitAll(); void onFitRect(); @@ -93,6 +98,8 @@ public slots: void onGlobalPanning(); void onViewHorMode(); void onViewVerMode(); + void onViewNormLMode(); + void onViewNormRMode(); void onLegend(); void onCurves();