Plot2d_ViewModel.h \
Plot2d_ViewWindow.h \
Plot2d_SetupCurveDlg.h \
+ Plot2d_SetupCurveScaleDlg.h \
Plot2d_ToolTip.h
dist_libPlot2d_la_SOURCES = \
Plot2d_ViewModel.cxx \
Plot2d_ViewWindow.cxx \
Plot2d_SetupCurveDlg.cxx \
+ Plot2d_SetupCurveScaleDlg.cxx \
Plot2d_ToolTip.cxx
MOC_FILES = \
Plot2d_ViewModel_moc.cxx \
Plot2d_ViewWindow_moc.cxx \
Plot2d_SetupCurveDlg_moc.cxx \
+ Plot2d_SetupCurveScaleDlg_moc.cxx \
Plot2d_ToolTip_moc.cxx
nodist_libPlot2d_la_SOURCES = $(MOC_FILES)
myName( "" ),
myXAxis( QwtPlot::xBottom ),
myYAxis( QwtPlot::yLeft ),
- myIsSelected(false)
+ myIsSelected(false),
+ myScale ( 1.0 )
{
}
myXAxis = object.getXAxis();
myYAxis = object.getYAxis();
myPoints = object.getPointList();
+ myScale = object.getScale();
}
/*!
myXAxis = object.getXAxis();
myYAxis = object.getYAxis();
myPoints = object.getPointList();
+ myScale = object.getScale();
return *this;
}
theItem->attach( aPlot );
}
}
- theItem->setTitle( !getName().isEmpty() ? getName() : getVerTitle() );
+ QString name = !getName().isEmpty() ? getName() : getVerTitle();
+ if( myScale != 1.0 )
+ name = name + QString("( *%1 )").arg(myScale);
+ theItem->setTitle( name );
}
/*!
return myName;
}
+/*!
+ Sets object's scale factor
+ */
+void Plot2d_Object::setScale( double theScale )
+{
+ myScale = theScale;
+}
+/*!
+ Gets object's scale factor
+ */
+double Plot2d_Object::getScale() const
+{
+ return myScale;
+}
+
/*!
Adds one point for object.
*/
int aNPoints = nbPoints();
double* aY = new double[aNPoints];
for (int i = 0; i < aNPoints; i++) {
- aY[i] = myPoints[i].y;
+ aY[i] = myScale * myPoints[i].y;
}
return aY;
}
*theY = new double[aNPoints];
for (int i = 0; i < aNPoints; i++) {
(*theX)[i] = myPoints[i].x;
- (*theY)[i] = myPoints[i].y;
+ (*theY)[i] = myScale * myPoints[i].y;
}
return aNPoints;
}
double aMinY = 1e150;
pointList::const_iterator aIt;
for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt)
- aMinY = qMin( aMinY, (*aIt).y );
+ aMinY = qMin( aMinY, myScale * (*aIt).y );
return aMinY;
}
double aMaxY = -1e150;
pointList::const_iterator aIt;
for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt)
- aMaxY = qMax( aMaxY, (*aIt).y );
+ aMaxY = qMax( aMaxY, myScale * (*aIt).y );
return aMaxY;
}
void setName( const QString& );
QString getName() const;
+ void setScale( double );
+ double getScale() const;
+
void addPoint( double, double, const QString& = QString() );
void addPoint( const Plot2d_Point& );
void insertPoint( int, double, double, const QString& = QString() );
QwtPlot::Axis myXAxis;
QwtPlot::Axis myYAxis;
+ double myScale;
+
pointList myPoints;
bool myIsSelected;
--- /dev/null
+// 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_SetupCurveScaleDlg.cxx
+//
+#include "Plot2d_SetupCurveScaleDlg.h"
+
+#include <SUIT_Tools.h>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+
+#include <QtxDoubleSpinBox.h>
+
+const int MARGIN_SIZE = 11;
+const int SPACING_SIZE = 6;
+const int MIN_COMBO_WIDTH = 100;
+const int MIN_SPIN_WIDTH = 50;
+
+/*!
+ \class Plot2d_SetupCurveScaleDlg
+ \brief Dialog box for modifying 2d curve scale factor.
+*/
+
+/*!
+ \brief Constructor.
+ \param parent parent widget
+*/
+Plot2d_SetupCurveScaleDlg::Plot2d_SetupCurveScaleDlg( /*curveList lst, */QWidget* parent )
+: QDialog( parent )
+{
+ setModal( true );
+ setWindowTitle( tr("TLT_SETUP_CURVE_SCALE") );
+ setSizeGripEnabled( true );
+
+ /************************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox( this );
+ QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 );
+ GroupC1Layout->setSpacing( SPACING_SIZE );
+ GroupC1Layout->setMargin( MARGIN_SIZE );
+
+ QLabel* aScaleLab = new QLabel( tr( "CURVE_SCALE_FACTOR" ), GroupC1 );
+ myValueSpin = new QtxDoubleSpinBox( GroupC1 );
+ myValueSpin->setMinimum( 0.01 );
+ myValueSpin->setSingleStep( 0.1 );
+ myValueSpin->setMinimumWidth( MIN_SPIN_WIDTH );
+
+ GroupC1Layout->addWidget( aScaleLab );
+ GroupC1Layout->addWidget( myValueSpin );
+
+ /************************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox( this );
+ QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
+ GroupButtonsLayout->setSpacing( SPACING_SIZE );
+ GroupButtonsLayout->setMargin( MARGIN_SIZE );
+
+ myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
+ myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
+
+ GroupButtonsLayout->addWidget( myOkBtn );
+ GroupButtonsLayout->addSpacing( 10 );
+ GroupButtonsLayout->addWidget( myCancelBtn );
+
+ /************************************************************************/
+ QVBoxLayout* topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( SPACING_SIZE );
+ topLayout->setMargin( MARGIN_SIZE );
+ topLayout->addWidget( GroupC1 );
+ topLayout->addWidget( GroupButtons );
+
+ // default settings
+ setScale( 1.0 ); // no scale
+
+ // connections
+ connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+ \brief Destructor.
+*/
+Plot2d_SetupCurveScaleDlg::~Plot2d_SetupCurveScaleDlg()
+{
+}
+
+/*!
+ \brief Set scale factor.
+ \param coef scale factor
+ \sa getScale()
+*/
+void Plot2d_SetupCurveScaleDlg::setScale( const double coef )
+{
+ if ( coef > myValueSpin->maximum() ){
+ myValueSpin->setMaximum( coef );
+ }
+ myValueSpin->setValue( coef );
+}
+
+/*!
+ \brief Get scale factor.
+ \return chosen scale factor
+ \sa setScale()
+*/
+double Plot2d_SetupCurveScaleDlg::getScale() const
+{
+ return myValueSpin->value();
+}
+/*!
+ \brief Clear value in the "Scale factor" spinbox.
+*/
+void Plot2d_SetupCurveScaleDlg::setUndefinedValue() {
+ myValueSpin->setCleared(true);
+ myValueSpin->setSpecialValueText("");
+}
\ No newline at end of file
--- /dev/null
+// 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_SetupCurveScaleDlg.h
+//
+#ifndef PLOT2D_SETUPCURVESCALEDLG_H
+#define PLOT2D_SETUPCURVESCALEDLG_H
+
+#include "Plot2d.h"
+
+#include <QDialog>
+
+class QPushButton;
+class QLabel;
+
+class QtxDoubleSpinBox;
+
+class PLOT2D_EXPORT Plot2d_SetupCurveScaleDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ Plot2d_SetupCurveScaleDlg( /*curveList,*/ QWidget* = 0 );
+ ~Plot2d_SetupCurveScaleDlg();
+
+public:
+ void setScale( const double );
+ double getScale() const;
+
+ void setUndefinedValue();
+
+private:
+ QPushButton* myOkBtn;
+ QPushButton* myCancelBtn;
+ QtxDoubleSpinBox* myValueSpin;
+};
+
+#endif // PLOT2D_SETUPCURVESCALEDLG_H
+
<translation>Background color</translation>
</message>
</context>
+<context>
+ <name>Plot2d_SetupCurveScaleDlg</name>
+ <message>
+ <source>TLT_SETUP_CURVE_SCALE</source>
+ <translation>Curve(s) scale</translation>
+ </message>
+ <message>
+ <source>CURVE_SCALE_FACTOR</source>
+ <translation>Scale factor</translation>
+ </message>
+</context>
</TS>