From 38acd11e070c25f7fd58e552ede75965364b88fc Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 13 Jul 2007 13:54:03 +0000 Subject: [PATCH] *** empty log message *** --- src/Plot2d/Makefile.am | 1 + src/Plot2d/Plot2d.cxx | 350 ++++++++++++++++++++++++++++ src/Plot2d/Plot2d.h | 84 ++++++- src/Plot2d/Plot2d_Curve.cxx | 22 +- src/Plot2d/Plot2d_Curve.h | 121 +++++----- src/Plot2d/Plot2d_SetupCurveDlg.cxx | 347 ++++++++++++++++----------- src/Plot2d/Plot2d_SetupCurveDlg.h | 57 ++--- src/Plot2d/Plot2d_SetupViewDlg.cxx | 318 ++++++++++++++++++------- src/Plot2d/Plot2d_SetupViewDlg.h | 170 +++++++------- src/Plot2d/Plot2d_ViewFrame.cxx | 124 +--------- 10 files changed, 1073 insertions(+), 521 deletions(-) create mode 100755 src/Plot2d/Plot2d.cxx diff --git a/src/Plot2d/Makefile.am b/src/Plot2d/Makefile.am index b2fd5cfbf..b8e08f99e 100755 --- a/src/Plot2d/Makefile.am +++ b/src/Plot2d/Makefile.am @@ -40,6 +40,7 @@ salomeinclude_HEADERS= \ Plot2d_ToolTip.h dist_libPlot2d_la_SOURCES= \ + Plot2d.cxx \ Plot2d_Curve.cxx \ Plot2d_FitDataDlg.cxx \ Plot2d_Prs.cxx \ diff --git a/src/Plot2d/Plot2d.cxx b/src/Plot2d/Plot2d.cxx new file mode 100755 index 000000000..610dbc362 --- /dev/null +++ b/src/Plot2d/Plot2d.cxx @@ -0,0 +1,350 @@ +// 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.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "Plot2d.h" + +#include + +/*! + \brief Convert Plot2d marker type to Qwt marker type. + \param m Plot2d marker type + \return Qwt marker type +*/ +QwtSymbol::Style Plot2d::plot2qwtMarker( Plot2d::MarkerType m ) +{ + QwtSymbol::Style ms = QwtSymbol::NoSymbol; + switch ( m ) { + case Plot2d::Circle: + ms = QwtSymbol::Ellipse; break; + case Plot2d::Rectangle: + ms = QwtSymbol::Rect; break; + case Plot2d::Diamond: + ms = QwtSymbol::Diamond; break; + case Plot2d::DTriangle: + ms = QwtSymbol::DTriangle; break; + case Plot2d::UTriangle: + ms = QwtSymbol::UTriangle; break; + case Plot2d::LTriangle: + ms = QwtSymbol::LTriangle; break; + case Plot2d::RTriangle: + ms = QwtSymbol::RTriangle; break; + case Plot2d::Cross: + ms = QwtSymbol::Cross; break; + case Plot2d::XCross: + ms = QwtSymbol::XCross; break; + case Plot2d::None: + default: + ms = QwtSymbol::NoSymbol; break; + } + return ms; +} + +/*! + \brief Convert Qwt marker type to Plot2d marker type. + \param m Qwt marker type + \return Plot2d marker type +*/ +Plot2d::MarkerType Plot2d::qwt2plotMarker( QwtSymbol::Style m ) +{ + Plot2d::MarkerType ms = Plot2d::None; + switch ( m ) { + case QwtSymbol::Ellipse: + ms = Plot2d::Circle; break; + case QwtSymbol::Rect: + ms = Plot2d::Rectangle; break; + case QwtSymbol::Diamond: + ms = Plot2d::Diamond; break; + case QwtSymbol::DTriangle: + ms = Plot2d::DTriangle; break; + case QwtSymbol::UTriangle: + ms = Plot2d::UTriangle; break; + case QwtSymbol::RTriangle: + ms = Plot2d::RTriangle; break; + case QwtSymbol::LTriangle: + ms = Plot2d::LTriangle; break; + case QwtSymbol::Cross: + ms = Plot2d::Cross; break; + case QwtSymbol::XCross: + ms = Plot2d::XCross; break; + case QwtSymbol::NoSymbol: + default: + ms = Plot2d::None; break; + } + return ms; +} + +/*! + \brief Convert Plot2d line type to Qt/Qwt line type. + \param p Plot2d line type + \return Qt/Qwt line type +*/ +Qt::PenStyle Plot2d::plot2qwtLine( Plot2d::LineType p ) +{ + Qt::PenStyle ps = Qt::NoPen; + switch ( p ) { + case Plot2d::Solid: + ps = Qt::SolidLine; break; + case Plot2d::Dash: + ps = Qt::DashLine; break; + case Plot2d::Dot: + ps = Qt::DotLine; break; + case Plot2d::DashDot: + ps = Qt::DashDotLine; break; + case Plot2d::DashDotDot: + ps = Qt::DashDotDotLine; break; + case Plot2d::NoPen: + default: + ps = Qt::NoPen; break; + } + return ps; +} + +/*! + \brief Convert Qt/Qwt line type to Plot2d line type. + \param p Qt/Qwt line type + \return Plot2d line type +*/ +Plot2d::LineType Plot2d::qwt2plotLine( Qt::PenStyle p ) +{ + Plot2d::LineType ps = Plot2d::NoPen; + switch ( p ) { + case Qt::SolidLine: + ps = Plot2d::Solid; break; + case Qt::DashLine: + ps = Plot2d::Dash; break; + case Qt::DotLine: + ps = Plot2d::Dot; break; + case Qt::DashDotLine: + ps = Plot2d::DashDot; break; + case Qt::DashDotDotLine: + ps = Plot2d::DashDotDot; break; + case Qt::NoPen: + default: + ps = Plot2d::NoPen; break; + } + return ps; +} + +/*! + \brief Draw line. + \param painter painter + \param p1 starting point + \param p2 ending point + \param type line type + \param color line color + \param width line width +*/ +void Plot2d::drawLine( QPainter* painter, const QPoint& p1, const QPoint& p2, + Qt::PenStyle type, const QColor& color, int width ) +{ + painter->save(); + QPen pen( type ); + pen.setColor( color ); + pen.setWidth( width ); + painter->setPen( pen ); + painter->drawLine( p1, p2 ); + painter->restore(); +} + +/*! + \brief Draw line. + \param painter painter + \param p1 starting point + \param p2 ending point + \param type line type + \param color line color + \param width line width +*/ +void Plot2d::drawLine( QPainter* painter, const QPoint& p1, const QPoint& p2, + Plot2d::LineType type, const QColor& color, int width ) +{ + drawLine( painter, p1, p2, plot2qwtLine( type ), color, width ); +} + +/*! + \brief Draw line. + \param painter painter + \param x1 X coordinate of the starting point + \param y1 Y coordinate of the starting point + \param x2 X coordinate of the ending point + \param y2 Y coordinate of the ending point + \param type line type + \param color line color + \param width line width +*/ +void Plot2d::drawLine( QPainter* painter, int x1, int y1, int x2, int y2, + Qt::PenStyle type, const QColor& color, int width ) +{ + drawLine( painter, QPoint( x1, y1 ), QPoint( x2, y2 ), type, color, width ); +} + +/*! + \brief Draw line. + \param painter painter + \param x1 X coordinate of the starting point + \param y1 Y coordinate of the starting point + \param x2 X coordinate of the ending point + \param y2 Y coordinate of the ending point + \param type line type + \param color line color + \param width line width +*/ +void Plot2d::drawLine( QPainter* painter, int x1, int y1, int x2, int y2, + Plot2d::LineType type, const QColor& color, int width ) +{ + drawLine( painter, QPoint( x1, y1 ), QPoint( x2, y2 ), + plot2qwtLine( type), color, width ); +} + +/*! + \brief Draw marker. + \param painter painter + \param p central point + \param r marker rectangle + \param type marker type + \param color marker color +*/ +void Plot2d::drawMarker( QPainter* painter, const QPoint& p, const QRect& r, + QwtSymbol::Style type, const QColor& color ) +{ + painter->save(); + painter->setPen( color ); + painter->setBrush( color ); + + QRect ar = r; + ar.moveCenter( p ); + const int w2 = ar.width() / 2; + const int h2 = ar.height() / 2; + + switch( type ) { + case QwtSymbol::Ellipse: + painter->drawEllipse( ar ); + break; + case QwtSymbol::Rect: + painter->drawRect( ar ); + painter->fillRect( ar, QBrush( color ) ); + break; + case QwtSymbol::Diamond: + { + QPolygon polygon; + polygon << QPoint( ar.x() + w2, ar.y() ); + polygon << QPoint( ar.right(), ar.y() + h2 ); + polygon << QPoint( ar.x() + w2, ar.bottom() ); + polygon << QPoint( ar.x(), ar.y() + h2 ); + painter->drawPolygon( polygon ); + break; + } + case QwtSymbol::Cross: + painter->drawLine( ar.left() + w2, ar.top(), ar.left() + w2, ar.bottom() ); + painter->drawLine( ar.left(), ar.top() + h2, ar.right(), ar.top() + h2 ); + break; + case QwtSymbol::XCross: + painter->drawLine( ar.left(), ar.top(), ar.right(), ar.bottom() ); + painter->drawLine( ar.left(), ar.bottom(), ar.right(), ar.top() ); + break; + case QwtSymbol::UTriangle: + { + QPolygon polygon; + polygon << QPoint( ar.left() + w2, ar.top() ); + polygon << QPoint( ar.right(), ar.bottom() ); + polygon << QPoint( ar.left(), ar.bottom() ); + painter->drawPolygon( polygon ); + break; + } + case QwtSymbol::DTriangle: + { + QPolygon polygon; + polygon << QPoint( ar.left() + w2, ar.bottom() ); + polygon << QPoint( ar.right(), ar.top() ); + polygon << QPoint( ar.left(), ar.top() ); + painter->drawPolygon( polygon ); + break; + } + case QwtSymbol::RTriangle: + { + QPolygon polygon; + polygon << QPoint( ar.left(), ar.top() ); + polygon << QPoint( ar.right(), ar.top() + h2 ); + polygon << QPoint( ar.left(), ar.bottom() ); + painter->drawPolygon( polygon ); + break; + } + case QwtSymbol::LTriangle: + { + QPolygon polygon; + polygon << QPoint( ar.left(), ar.top() + h2 ); + polygon << QPoint( ar.right(), ar.top() ); + polygon << QPoint( ar.right(), ar.bottom() ); + painter->drawPolygon( polygon ); + break; + } + default: + break; + } + painter->restore(); +} + +/*! + \brief Draw marker. + \param painter painter + \param p central point + \param r marker rectangle + \param type marker type + \param color marker color +*/ +void Plot2d::drawMarker( QPainter* painter, const QPoint& p, const QRect& r, + Plot2d::MarkerType type, const QColor& color ) +{ + drawMarker( painter, p, r, plot2qwtMarker( type ), color ); +} + +/*! + \brief Draw marker. + \param painter painter + \param x X coordinate of the central point + \param y Y coordinate of the central point + \param w marker rectangle width + \param h marker rectangle height + \param type marker type + \param color marker color +*/ +void Plot2d::drawMarker( QPainter* painter, int x, int y, int w, int h, + QwtSymbol::Style type, const QColor& color ) +{ + drawMarker( painter, QPoint( x, y ), QRect( 0, 0, w, h ), type, color ); +} + +/*! + \brief Draw marker. + \param painter painter + \param x X coordinate of the central point + \param y Y coordinate of the central point + \param w marker rectangle width + \param h marker rectangle height + \param type marker type + \param color marker color +*/ +void Plot2d::drawMarker( QPainter* painter, int x, int y, int w, int h, + Plot2d::MarkerType type, const QColor& color ) +{ + drawMarker( painter, QPoint( x, y ), QRect( 0, 0, w, h ), plot2qwtMarker( type ), color ); +} diff --git a/src/Plot2d/Plot2d.h b/src/Plot2d/Plot2d.h index 72e7b7017..965f67eb2 100755 --- a/src/Plot2d/Plot2d.h +++ b/src/Plot2d/Plot2d.h @@ -16,16 +16,86 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : Plot2d.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#ifndef PLOT2D_H +#define PLOT2D_H + #ifdef WIN32 -#ifdef PLOT2D_EXPORTS -#define PLOT2D_EXPORT __declspec(dllexport) +# ifdef PLOT2D_EXPORTS +# define PLOT2D_EXPORT __declspec(dllexport) +# else +# define PLOT2D_EXPORT __declspec(dllimport) +# endif #else -#define PLOT2D_EXPORT __declspec(dllimport) -#endif -#else -#define PLOT2D_EXPORT +# define PLOT2D_EXPORT #endif +#include +#include + +class QPainter; + +namespace Plot2d +{ + typedef enum { None, + Circle, + Rectangle, + Diamond, + DTriangle, + UTriangle, + LTriangle, + RTriangle, + Cross, + XCross + } MarkerType; + + typedef enum { + NoPen, + Solid, + Dash, + Dot, + DashDot, + DashDotDot + } LineType; + + QwtSymbol::Style plot2qwtMarker( MarkerType ); + MarkerType qwt2plotMarker( QwtSymbol::Style ); + + Qt::PenStyle plot2qwtLine( LineType ); + LineType qwt2plotLine( Qt::PenStyle ); + + void drawLine( QPainter*, const QPoint&, const QPoint&, + Qt::PenStyle = Qt::SolidLine, + const QColor& = Qt::black, int = 0 ); + void drawLine( QPainter*, const QPoint&, const QPoint&, + LineType = Solid, + const QColor& = Qt::black, int = 0 ); + void drawLine( QPainter*, int, int, int, int, + Qt::PenStyle = Qt::SolidLine, + const QColor& = Qt::black, int = 0 ); + void drawLine( QPainter*, int, int, int, int, + LineType = Solid, + const QColor& = Qt::black, int = 0 ); + + void drawMarker( QPainter*, const QPoint&, const QRect&, + QwtSymbol::Style = QwtSymbol::Ellipse, + const QColor& = Qt::black ); + void drawMarker( QPainter*, const QPoint&, const QRect&, + MarkerType = Circle, + const QColor& = Qt::black ); + void drawMarker( QPainter*, int, int, int, int, + QwtSymbol::Style = QwtSymbol::Ellipse, + const QColor& = Qt::black ); + void drawMarker( QPainter*, int, int, int, int, + MarkerType = Circle, + const QColor& = Qt::black ); +} + #if defined WIN32 -#pragma warning ( disable: 4251 ) +# pragma warning ( disable: 4251 ) #endif + +#endif // PLOT2D_H diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 95bee5dc3..abbc13bd3 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -16,6 +16,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : Plot2d_Curve.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #include "Plot2d_Curve.h" #include @@ -24,9 +28,13 @@ */ Plot2d_Curve::Plot2d_Curve() : myHorTitle( "" ), myVerTitle( "" ), -myHorUnits( "" ), myVerUnits( "" ), -myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 ), -myYAxis( QwtPlot::yLeft ) + myHorUnits( "" ), myVerUnits( "" ), + myAutoAssign( true ), + myColor( 0,0,0 ), + myMarker( Plot2d::Circle ), + myLine( Plot2d::Solid ), + myLineWidth( 0 ), + myYAxis( QwtPlot::yLeft ) { } @@ -292,7 +300,7 @@ QColor Plot2d_Curve::getColor() const /*! Sets curve's marker ( and resets AutoAssign flag ) */ -void Plot2d_Curve::setMarker( MarkerType marker ) +void Plot2d_Curve::setMarker( Plot2d::MarkerType marker ) { myMarker = marker; myAutoAssign = false; @@ -301,7 +309,7 @@ void Plot2d_Curve::setMarker( MarkerType marker ) /*! Gets curve's marker */ -Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const +Plot2d::MarkerType Plot2d_Curve::getMarker() const { return myMarker; } @@ -313,7 +321,7 @@ Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const algorithm for diagonals. For horizontal and vertical lines a line width of 0 is the same as a line width of 1. */ -void Plot2d_Curve::setLine( LineType line, const int lineWidth ) +void Plot2d_Curve::setLine( Plot2d::LineType line, const int lineWidth ) { myLine = line; myLineWidth = lineWidth; @@ -324,7 +332,7 @@ void Plot2d_Curve::setLine( LineType line, const int lineWidth ) /*! Gets curve's line type */ -Plot2d_Curve::LineType Plot2d_Curve::getLine() const +Plot2d::LineType Plot2d_Curve::getLine() const { return myLine; } diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index a5d7cef73..3474a56b7 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -16,10 +16,15 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : Plot2d_Curve.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #ifndef PLOT2D_CURVE_H #define PLOT2D_CURVE_H #include "Plot2d.h" + #include #include @@ -37,73 +42,75 @@ typedef QList pointList; class PLOT2D_EXPORT Plot2d_Curve { public: - enum MarkerType { None, Circle, Rectangle, Diamond, - DTriangle, UTriangle, LTriangle, RTriangle, - Cross, XCross }; - enum LineType { NoPen, Solid, Dash, Dot, DashDot, DashDotDot }; - Plot2d_Curve(); virtual ~Plot2d_Curve(); - Plot2d_Curve( const Plot2d_Curve& curve ); - Plot2d_Curve& operator= ( const Plot2d_Curve& curve ); + Plot2d_Curve( const Plot2d_Curve& ); + Plot2d_Curve& operator= ( const Plot2d_Curve& ); - virtual QString getTableTitle() const; + virtual QString getTableTitle() const; - void setHorTitle( const QString& title ); - QString getHorTitle() const; - void setVerTitle( const QString& title ); - QString getVerTitle() const; - void setHorUnits( const QString& units ); - QString getHorUnits() const; - void setVerUnits( const QString& units ); - QString getVerUnits() const; - void addPoint(double theX, double theY, const QString& = QString::null ); - void insertPoint(int thePos, double theX, double theY, const QString& = QString::null ); - void deletePoint(int thePos); - void clearAllPoints(); - pointList getPointList() const; - - void setData( const double* hData, const double* vData, long size, const QStringList& = QStringList() ); - double* horData() const; - double* verData() const; - - void setText( const int, const QString& ); - QString text( const int ) const; - - int nbPoints() const; - bool isEmpty() const; - - void setAutoAssign( bool on ); - bool isAutoAssign() const; - void setColor( const QColor& color ); - QColor getColor() const; - void setMarker( MarkerType marker ); - MarkerType getMarker() const; - void setLine( LineType line, const int lineWidth = 0 ); - LineType getLine() const; - int getLineWidth() const; - void setYAxis(QwtPlot::Axis theYAxis); - QwtPlot::Axis getYAxis() const; + void setHorTitle( const QString& ); + QString getHorTitle() const; + void setVerTitle( const QString& ); + QString getVerTitle() const; + + void setHorUnits( const QString& ); + QString getHorUnits() const; + void setVerUnits( const QString& ); + QString getVerUnits() const; + + void addPoint( double, double, const QString& = QString() ); + void insertPoint( int, double, double, const QString& = QString() ); + void deletePoint( int ); + void clearAllPoints(); + pointList getPointList() const; + + void setData( const double*, const double*, + long, const QStringList& = QStringList() ); + double* horData() const; + double* verData() const; + + void setText( const int, const QString& ); + QString text( const int ) const; + + int nbPoints() const; + bool isEmpty() const; + + void setAutoAssign( bool ); + bool isAutoAssign() const; + + void setColor( const QColor& ); + QColor getColor() const; + + void setMarker( Plot2d::MarkerType ); + Plot2d::MarkerType getMarker() const; + + void setLine( Plot2d::LineType, const int = 0 ); + Plot2d::LineType getLine() const; + int getLineWidth() const; + + void setYAxis( QwtPlot::Axis ); + QwtPlot::Axis getYAxis() const; // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: // it crashes if switched to X/Y logarithmic mode, when one or more points have // non-positive X/Y coordinate - double getMinX() const; - double getMinY() const; + double getMinX() const; + double getMinY() const; protected: - bool myAutoAssign; - QString myHorTitle; - QString myVerTitle; - QString myHorUnits; - QString myVerUnits; - QColor myColor; - MarkerType myMarker; - LineType myLine; - int myLineWidth; - QwtPlot::Axis myYAxis; - - pointList myPoints; + bool myAutoAssign; + QString myHorTitle; + QString myVerTitle; + QString myHorUnits; + QString myVerUnits; + QColor myColor; + Plot2d::MarkerType myMarker; + Plot2d::LineType myLine; + int myLineWidth; + QwtPlot::Axis myYAxis; + + pointList myPoints; }; typedef QList curveList; diff --git a/src/Plot2d/Plot2d_SetupCurveDlg.cxx b/src/Plot2d/Plot2d_SetupCurveDlg.cxx index a94e6429f..b848d83cd 100644 --- a/src/Plot2d/Plot2d_SetupCurveDlg.cxx +++ b/src/Plot2d/Plot2d_SetupCurveDlg.cxx @@ -1,17 +1,17 @@ // 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 +// 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 +// +// 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 +// 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 @@ -21,196 +21,275 @@ // #include "Plot2d_SetupCurveDlg.h" -#include "SUIT_Tools.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef WIN32 -using namespace std; -#endif - -#define MARGIN_SIZE 11 -#define SPACING_SIZE 6 -#define MIN_COMBO_WIDTH 100 -#define MIN_SPIN_WIDTH 50 -#define MAX_LINE_WIDTH 100 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +const int MARGIN_SIZE = 11; +const int SPACING_SIZE = 6; +const int MIN_COMBO_WIDTH = 100; +const int MIN_SPIN_WIDTH = 50; +const int MAX_LINE_WIDTH = 10; +const int MSIZE = 9; /*! - Constructor + \class Plot2d_SetupCurveDlg + \brief Dialog box for modifying 2d curve settings. +*/ + +/*! + \brief Constructor. + \param parent parent widget */ Plot2d_SetupCurveDlg::Plot2d_SetupCurveDlg( QWidget* parent ) - : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) +: QDialog( parent ) { - setObjectName( "Plot2d_SetupCurveDlg" ); setModal( true ); setWindowTitle( tr("TLT_SETUP_CURVE") ); - setSizeGripEnabled( TRUE ); - QGridLayout* topLayout = new QGridLayout( this ); - topLayout->setSpacing( SPACING_SIZE ); - topLayout->setMargin( MARGIN_SIZE ); - - QGroupBox* TopGroup = new QGroupBox( this ); - QGridLayout* TopGroupLayout = new QGridLayout( TopGroup ); - TopGroup->setLayout( TopGroupLayout ); - TopGroupLayout->setAlignment( Qt::AlignTop ); - TopGroupLayout->setSpacing( SPACING_SIZE ); TopGroupLayout->setMargin( MARGIN_SIZE ); + setSizeGripEnabled( true ); - QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), TopGroup ); - myLineCombo = new QComboBox( TopGroup ); - myLineCombo->setEditable( false ); + // curve type + QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), this ); + myLineCombo = new QComboBox( this ); myLineCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLineCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myLineCombo->addItem( tr( "NONE_LINE_LBL" ) ); - myLineCombo->addItem( tr( "SOLID_LINE_LBL" ) ); - myLineCombo->addItem( tr( "DASH_LINE_LBL" ) ); - myLineCombo->addItem( tr( "DOT_LINE_LBL" ) ); - myLineCombo->addItem( tr( "DASHDOT_LINE_LBL" ) ); - myLineCombo->addItem( tr( "DAHSDOTDOT_LINE_LBL" ) ); - myLineCombo->setCurrentIndex( 1 ); // SOLID by default - - QLabel* aLineWidthLab = new QLabel( tr( "CURVE_LINE_WIDTH_LAB" ), TopGroup ); - myLineSpin = new QSpinBox( TopGroup ); + myLineCombo->setIconSize( QSize( 40, 16 ) ); + + // curve width + QLabel* aLineWidthLab = new QLabel( tr( "CURVE_LINE_WIDTH_LAB" ), this ); + myLineSpin = new QSpinBox( this ); myLineSpin->setMinimum( 0 ); myLineSpin->setMaximum( MAX_LINE_WIDTH ); myLineSpin->setSingleStep( 1 ); myLineSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLineSpin->setMinimumWidth( MIN_SPIN_WIDTH ); - myLineSpin->setValue( 0 ); // default width is 0 - QLabel* aMarkerLab = new QLabel( tr( "CURVE_MARKER_TYPE_LAB" ), TopGroup ); - myMarkerCombo = new QComboBox( TopGroup ); - myMarkerCombo->setEditable( false ); + // marker type + QLabel* aMarkerLab = new QLabel( tr( "CURVE_MARKER_TYPE_LAB" ), this ); + myMarkerCombo = new QComboBox( this ); myMarkerCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myMarkerCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myMarkerCombo->addItem( tr( "NONE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "CIRCLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "RECTANGLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "DIAMOND_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "DTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "UTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "LTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "RTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "CROSS_MARKER_LBL" ) ); - myMarkerCombo->addItem( tr( "XCROSS_MARKER_LBL" ) ); - myMarkerCombo->setCurrentIndex( 1 ); // CIRCLE by default - - QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), TopGroup ); - myColorBtn = new QToolButton( TopGroup ); - myColorBtn->setMinimumSize(25, 25); - - TopGroupLayout->addWidget( aLineTypeLab, 0, 0 ); - TopGroupLayout->addWidget( myLineCombo, 0, 1, 1, 2 ); - TopGroupLayout->addWidget( aLineWidthLab, 1, 0 ); - TopGroupLayout->addWidget( myLineSpin, 1, 1, 1, 2 ); - TopGroupLayout->addWidget( aMarkerLab, 2, 0 ); - TopGroupLayout->addWidget( myMarkerCombo, 2, 1, 1, 2 ); - TopGroupLayout->addWidget( aColorLab, 3, 0 ); - TopGroupLayout->addWidget( myColorBtn, 3, 1 ); - TopGroupLayout->setColumnStretch( 2, 5 ); - - QGroupBox* GroupButtons = new QGroupBox( this ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); - GroupButtons->setLayout( GroupButtonsLayout ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( SPACING_SIZE ); GroupButtonsLayout->setMargin( MARGIN_SIZE ); - - myOkBtn = new QPushButton( tr( "BUT_OK" ), GroupButtons ); - myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true ); - myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ) , GroupButtons ); - myCancelBtn->setAutoDefault( true ); - - GroupButtonsLayout->addWidget( myOkBtn ); - GroupButtonsLayout->addStretch(); - GroupButtonsLayout->addWidget( myCancelBtn ); - - connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) ); - connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - setColor( QColor( 0, 0, 0 ) ); - - topLayout->addWidget( TopGroup, 0, 0 ); - topLayout->addWidget( GroupButtons, 1, 0 ); + myMarkerCombo->setIconSize( QSize( 16, 16 ) ); + + // curve color + QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), this ); + myColorBtn = new QtxColorButton( this ); + + // preview + QLabel* aPreviewLab = new QLabel( tr( "CURVE_PREVIEW_LAB" ), this ); + myPreview = new QLabel( this ); + myPreview->setFrameStyle( QLabel::Box | QLabel::Sunken ); + myPreview->setAlignment( Qt::AlignCenter ); + myPreview->setScaledContents( false ); + + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + + // layouting widgets + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + topLayout->addWidget( aLineTypeLab, 0, 0 ); + topLayout->addWidget( myLineCombo, 0, 1, 1, 2 ); + topLayout->addWidget( aLineWidthLab, 1, 0 ); + topLayout->addWidget( myLineSpin, 1, 1, 1, 2 ); + topLayout->addWidget( aMarkerLab, 2, 0 ); + topLayout->addWidget( myMarkerCombo, 2, 1, 1, 2 ); + topLayout->addWidget( aColorLab, 3, 0 ); + topLayout->addWidget( myColorBtn, 3, 1 ); + topLayout->addWidget( aPreviewLab, 4, 0 ); + topLayout->addWidget( myPreview, 4, 1, 1, 2 ); + topLayout->setColumnStretch( 2, 5 ); + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setSpacing( SPACING_SIZE ); + btnLayout->setMargin( 0 ); + + btnLayout->addWidget( myOkBtn ); + btnLayout->addSpacing( 20 ); + btnLayout->addStretch(); + btnLayout->addWidget( myCancelBtn ); + + topLayout->addLayout( btnLayout, 5, 0, 1, 3 ); + + // fill then combo boxes + myLineCombo->addItem( lineIcon( Plot2d::NoPen ), tr( "NONE_LINE_LBL" ) ); + myLineCombo->addItem( lineIcon( Plot2d::Solid ), tr( "SOLID_LINE_LBL" ) ); + myLineCombo->addItem( lineIcon( Plot2d::Dash ), tr( "DASH_LINE_LBL" ) ); + myLineCombo->addItem( lineIcon( Plot2d::Dot ), tr( "DOT_LINE_LBL" ) ); + myLineCombo->addItem( lineIcon( Plot2d::DashDot ), tr( "DASHDOT_LINE_LBL" ) ); + myLineCombo->addItem( lineIcon( Plot2d::DashDotDot ), tr( "DAHSDOTDOT_LINE_LBL" ) ); + + myMarkerCombo->addItem( markerIcon( Plot2d::None ), tr( "NONE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::Circle ), tr( "CIRCLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::Rectangle ), tr( "RECTANGLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::Diamond ), tr( "DIAMOND_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::DTriangle ), tr( "DTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::UTriangle ), tr( "UTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::LTriangle ), tr( "LTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::RTriangle ), tr( "RTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::Cross ), tr( "CROSS_MARKER_LBL" ) ); + myMarkerCombo->addItem( markerIcon( Plot2d::XCross ), tr( "XCROSS_MARKER_LBL" ) ); + + // default settings + setLine( Plot2d::Solid, 0 ); // solid line, width = 0 + setMarker( Plot2d::Circle ); // circle + setColor( QColor( 0, 0, 0 ) ); // black + + // connections + connect( myLineCombo, SIGNAL( activated( int ) ), this, SLOT( updatePreview() ) ); + connect( myLineSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ) ); + connect( myMarkerCombo, SIGNAL( activated( int ) ), this, SLOT( updatePreview() ) ); + connect( myColorBtn, SIGNAL( changed( QColor ) ), this, SLOT( updatePreview() ) ); + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); SUIT_Tools::centerWidget( this, parent ); + updatePreview(); } + /*! - Destructor + \brief Destructor. */ Plot2d_SetupCurveDlg::~Plot2d_SetupCurveDlg() { } + /*! - Sets line style and width + \brief Set curve line type and width. + \param type curve line type + \param width curve line width + \sa getLine(), getLineWidth() */ -void Plot2d_SetupCurveDlg::setLine( const int line, const int width ) +void Plot2d_SetupCurveDlg::setLine( Plot2d::LineType type, const int width ) { - myLineCombo->setCurrentIndex( line ); + myLineCombo->setCurrentIndex( (int)type ); + if ( width > myLineSpin->maximum() ) + myLineSpin->setMaximum( width ); myLineSpin->setValue( width ); + updatePreview(); } + /*! - Gets line style + \brief Get curve line type. + \return chosen curve line type + \sa setLine(), getLineWidth() */ -int Plot2d_SetupCurveDlg::getLine() const +Plot2d::LineType Plot2d_SetupCurveDlg::getLine() const { - return myLineCombo->currentIndex(); + return (Plot2d::LineType)myLineCombo->currentIndex(); } + /*! - Gets line width + \brief Get curve line width. + \return chosen curve line width + \sa setLine(), getLine() */ int Plot2d_SetupCurveDlg::getLineWidth() const { return myLineSpin->value(); } + /*! - Sets marker style + \brief Set curve marker type. + \param type curve marker type + \sa getMarker() */ -void Plot2d_SetupCurveDlg::setMarker( const int marker ) +void Plot2d_SetupCurveDlg::setMarker( Plot2d::MarkerType type ) { - myMarkerCombo->setCurrentIndex( marker ); + myMarkerCombo->setCurrentIndex( (int)type ); + updatePreview(); } + /*! - Gets marker style + \brief Get curve marker type. + \return chosen curve marker type + \sa setMarker() */ -int Plot2d_SetupCurveDlg::getMarker() const +Plot2d::MarkerType Plot2d_SetupCurveDlg::getMarker() const { - return myMarkerCombo->currentIndex(); + return (Plot2d::MarkerType)myMarkerCombo->currentIndex(); } + /*! - Sets color + \brief Set curve color. + \param color curve color + \sa getColor() */ void Plot2d_SetupCurveDlg::setColor( const QColor& color ) { - QPalette pal = myColorBtn->palette(); - pal.setColor( QPalette::Active, QPalette::Button, color ); - pal.setColor( QPalette::Inactive, QPalette::Button, color ); - - myColorBtn->setPalette( pal ); + myColorBtn->setColor( color ); + updatePreview(); } + /*! - Gets color + \brief Get curve color. + \return curve color + \sa setColor() */ -QColor Plot2d_SetupCurveDlg::getColor() const +QColor Plot2d_SetupCurveDlg::getColor() const { - return myColorBtn->palette().color( QPalette::Active, QPalette::Button ); + return myColorBtn->color(); } + /*! - button slot, invokes color selection dialog box + \brief Create icon pixmap according to the line type. + \param type line type + \return icon */ -void Plot2d_SetupCurveDlg::onColorChanged() +QPixmap Plot2d_SetupCurveDlg::lineIcon( Plot2d::LineType type ) const { - QColor color = QColorDialog::getColor( getColor() ); - if ( color.isValid() ) { - setColor( color ); - } + QSize sz = myLineCombo->iconSize(); + QPixmap px( sz ); + px.fill( QColor( 255, 255, 255, 0 ) ); + QPainter p( &px ); + Plot2d::drawLine( &p, 5, sz.height()/2, sz.width()-5, sz.height()/2, type, + myLineCombo->palette().color( QPalette::Text ), 1 ); + return px; } +/*! + \brief Create icon pixmap according to the marker type. + \param type marker type + \return icon +*/ +QPixmap Plot2d_SetupCurveDlg::markerIcon( Plot2d::MarkerType type ) const +{ + QSize sz = myMarkerCombo->iconSize(); + QPixmap px( sz ); + px.fill( QColor( 255, 255, 255, 0 ) ); + QPainter p( &px ); + Plot2d::drawMarker( &p, sz.width()/2, sz.height()/2, MSIZE, MSIZE, type, + myMarkerCombo->palette().color( QPalette::Text ) ); + return px; +} +/* + \brief Update preview widget. +*/ +void Plot2d_SetupCurveDlg::updatePreview() +{ + QSize sz( 150, 20 ); + QPixmap px( sz ); + px.fill( palette().color( QPalette::Background ) ); + QPainter p( &px ); + Plot2d::drawLine( &p, 5+MSIZE/2, sz.height()/2, sz.width()-5-MSIZE/2, sz.height()/2, + getLine(), getColor(), getLineWidth() ); + Plot2d::drawMarker( &p, 5+MSIZE/2, sz.height()/2, MSIZE, MSIZE, + getMarker(), getColor() ); + Plot2d::drawMarker( &p, sz.width()-5-MSIZE/2, sz.height()/2, MSIZE, MSIZE, + getMarker(), getColor() ); + myPreview->setPixmap( px ); +} diff --git a/src/Plot2d/Plot2d_SetupCurveDlg.h b/src/Plot2d/Plot2d_SetupCurveDlg.h index 982a7aff8..43f0c5034 100644 --- a/src/Plot2d/Plot2d_SetupCurveDlg.h +++ b/src/Plot2d/Plot2d_SetupCurveDlg.h @@ -20,51 +20,54 @@ // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -#ifndef Plot2d_SetupCurveDlg_H -#define Plot2d_SetupCurveDlg_H +#ifndef PLOT2D_SETUPCURVEDLG_H +#define PLOT2D_SETUPCURVEDLG_H #include "Plot2d.h" -#include - -/*! - \class Plot2d_SetupCurveDlg - Dialog box for setup Plot2d curve -*/ +#include class QPushButton; class QComboBox; class QSpinBox; -class QToolButton; +class QLabel; +class QtxColorButton; class PLOT2D_EXPORT Plot2d_SetupCurveDlg : public QDialog { Q_OBJECT public: - Plot2d_SetupCurveDlg( QWidget* parent = 0 ); + Plot2d_SetupCurveDlg( QWidget* = 0 ); ~Plot2d_SetupCurveDlg(); public: - void setLine( const int line, const int width ); - int getLine() const; - int getLineWidth() const; - void setMarker( const int marker ); - int getMarker() const ; - void setColor( const QColor& color ); - QColor getColor() const; - -protected slots: - void onColorChanged(); + void setLine( Plot2d::LineType, const int ); + Plot2d::LineType getLine() const; + int getLineWidth() const; + + void setMarker( Plot2d::MarkerType ); + Plot2d::MarkerType getMarker() const ; + + void setColor( const QColor& ); + QColor getColor() const; + +private: + QPixmap lineIcon( Plot2d::LineType ) const; + QPixmap markerIcon( Plot2d::MarkerType ) const; + +private slots: + void updatePreview(); private: - QPushButton* myOkBtn; - QPushButton* myCancelBtn; - QComboBox* myLineCombo; - QSpinBox* myLineSpin; - QComboBox* myMarkerCombo; - QToolButton* myColorBtn; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + QComboBox* myLineCombo; + QSpinBox* myLineSpin; + QComboBox* myMarkerCombo; + QtxColorButton* myColorBtn; + QLabel* myPreview; }; -#endif // Plot2d_SetupCurveDlg_H +#endif // PLOT2D_SETUPCURVEDLG_H diff --git a/src/Plot2d/Plot2d_SetupViewDlg.cxx b/src/Plot2d/Plot2d_SetupViewDlg.cxx index d72f75b44..add4a56d0 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.cxx +++ b/src/Plot2d/Plot2d_SetupViewDlg.cxx @@ -22,35 +22,46 @@ #include "Plot2d_SetupViewDlg.h" +#include + #include #include #include #include -#include -#include +#include +#include #include #include #include -#include #include -#define MARGIN_SIZE 11 -#define SPACING_SIZE 6 -#define MIN_EDIT_WIDTH 200 -#define MIN_COMBO_WIDTH 100 -#define MIN_SPIN_WIDTH 70 +const int MARGIN_SIZE = 11; +const int SPACING_SIZE = 6; +const int MIN_EDIT_WIDTH = 200; +const int MIN_COMBO_WIDTH = 100; +const int MIN_SPIN_WIDTH = 70; /*! - Constructor + \class Plot2d_SetupViewDlg + \brief Dialog box to setup Plot2d view window. */ -Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bool secondAxisY ) - : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) + +/*! + \brief Constructor. + \param parent parent widget + \param showDefCheck if \c true, show "Set settings as default" check box + \param secondAxisY if \c true, show widgets for the second (right) vertical axis +*/ +Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, + bool showDefCheck, + bool secondAxisY ) +: QDialog( parent ), + mySecondAxisY( secondAxisY ) { - setObjectName( "Plot2d_SetupViewDlg" ); setModal( true ); - mySecondAxisY = secondAxisY; setWindowTitle( tr("TLT_SETUP_PLOT2D_VIEW") ); setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); topLayout->setSpacing( SPACING_SIZE ); topLayout->setMargin( MARGIN_SIZE ); @@ -60,25 +71,26 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleEdit = new QLineEdit( this ); myTitleEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTitleEdit->setMinimumWidth( MIN_EDIT_WIDTH ); + // curve type : points, lines, spline QLabel* aCurveLab = new QLabel( tr( "PLOT2D_CURVE_TYPE_LBL" ), this ); myCurveCombo = new QComboBox( this ); - myCurveCombo->setEditable( false ); myCurveCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myCurveCombo->setMinimumWidth( MIN_COMBO_WIDTH ); myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_POINTS" ) ); myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) ); myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) ); + // legend myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this ); myLegendCombo = new QComboBox( this ); - myCurveCombo->setEditable( false ); myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH ); myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) ); myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) ); myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) ); myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) ); + // marker size QLabel* aMarkerLab = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this ); myMarkerSpin = new QSpinBox( this ); @@ -90,8 +102,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo // background color QLabel* aBGLab = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this ); - myBackgroundBtn = new QToolButton( this ); - myBackgroundBtn->setMinimumWidth(20); + myBackgroundBtn = new QtxColorButton( this ); // scale mode QGroupBox* aScaleGrp = new QGroupBox( tr( "PLOT2D_SCALE_TLT" ), this ); @@ -101,14 +112,13 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo QLabel* xScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_HOR" ), aScaleGrp ); myXModeCombo = new QComboBox( aScaleGrp ); - myCurveCombo->setEditable( false ); myXModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myXModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); myXModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); myXModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); + QLabel* yScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_VER" ), aScaleGrp ); myYModeCombo = new QComboBox( aScaleGrp ); - myCurveCombo->setEditable( false ); myYModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myYModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); myYModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); @@ -121,13 +131,13 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo // tab widget for choose properties of axis QTabWidget* aTabWidget = new QTabWidget( this ); - aTabWidget->setObjectName( "tabWidget" ); // widget for parameters on Ox QWidget* aXWidget = new QWidget(aTabWidget); QGridLayout* aXLayout = new QGridLayout( aXWidget ); aXLayout->setSpacing( SPACING_SIZE ); aXLayout->setMargin( MARGIN_SIZE ); + // axis title myTitleXCheck = new QCheckBox( tr( "PLOT2D_ENABLE_HOR_TITLE" ), aXWidget ); myTitleXEdit = new QLineEdit( aXWidget ); @@ -135,12 +145,15 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleXEdit->setMinimumWidth( MIN_EDIT_WIDTH ); aXLayout->addWidget( myTitleXCheck,1, 0 ); aXLayout->addWidget( myTitleXEdit, 1, 1, 1, 3 ); + // grid QGroupBox* aGridGrpX = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aXWidget ); QGridLayout* aGridLayoutX = new QGridLayout( aGridGrpX ); - aGridGrpX->setLayout( aGridLayoutX ); - aGridLayoutX->setMargin( MARGIN_SIZE ); aGridLayoutX->setSpacing( SPACING_SIZE ); + aGridLayoutX->setMargin( MARGIN_SIZE ); + aGridLayoutX->setSpacing( SPACING_SIZE ); + myXGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MAJOR" ), aGridGrpX ); + QLabel* aXMajLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpX); myXGridSpin = new QSpinBox( aGridGrpX ); myXGridSpin->setMinimum( 1 ); @@ -148,7 +161,9 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myXGridSpin->setSingleStep( 1 ); myXGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myXGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myXMinGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MINOR" ), aGridGrpX ); + QLabel* aXMinLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpX); myXMinGridSpin = new QSpinBox( aGridGrpX ); myXMinGridSpin->setMinimum( 1 ); @@ -172,6 +187,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo QGridLayout* aYLayout = new QGridLayout( aYWidget ); aYLayout->setSpacing( SPACING_SIZE ); aYLayout->setMargin( MARGIN_SIZE ); + // axis title myTitleYCheck = new QCheckBox( tr( "PLOT2D_ENABLE_VER_TITLE" ), aYWidget ); myTitleYEdit = new QLineEdit( aYWidget ); @@ -179,12 +195,15 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleYEdit->setMinimumWidth( MIN_EDIT_WIDTH ); aYLayout->addWidget( myTitleYCheck,1, 0 ); aYLayout->addWidget( myTitleYEdit, 1, 1, 1, 3 ); + // grid QGroupBox* aGridGrpY = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget ); QGridLayout* aGridLayoutY = new QGridLayout( aGridGrpY ); aGridGrpY->setLayout( aGridLayoutY ); aGridLayoutY->setMargin( MARGIN_SIZE ); aGridLayoutY->setSpacing( SPACING_SIZE ); + myYGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MAJOR" ), aGridGrpY ); + QLabel* aYMajLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY); myYGridSpin = new QSpinBox( aGridGrpY ); myYGridSpin->setMinimum( 1 ); @@ -192,7 +211,9 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myYGridSpin->setSingleStep( 1 ); myYGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myYGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myYMinGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MINOR" ), aGridGrpY ); + QLabel* aYMinLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY); myYMinGridSpin = new QSpinBox( aGridGrpY ); myYMinGridSpin->setMinimum( 1 ); @@ -212,12 +233,13 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo aTabWidget->addTab( aYWidget, tr( "INF_AXES_Y_LEFT" ) ); // if exist second axis Oy, addition new tab widget for right axis - if (mySecondAxisY) { + if ( mySecondAxisY ) { // widget for parameters on Oy - QWidget* aYWidget2 = new QWidget(aTabWidget); + QWidget* aYWidget2 = new QWidget( aTabWidget ); QGridLayout* aYLayout2 = new QGridLayout( aYWidget2 ); aYLayout2->setSpacing( SPACING_SIZE ); aYLayout2->setMargin( MARGIN_SIZE ); + // axis title myTitleY2Check = new QCheckBox( tr( "PLOT2D_ENABLE_VER_TITLE" ), aYWidget2 ); myTitleY2Edit = new QLineEdit( aYWidget2 ); @@ -225,12 +247,15 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleY2Edit->setMinimumWidth( MIN_EDIT_WIDTH ); aYLayout2->addWidget( myTitleY2Check,1, 0 ); aYLayout2->addWidget( myTitleY2Edit, 1, 1, 1, 3 ); + // grid QGroupBox* aGridGrpY2 = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget2 ); QGridLayout* aGridLayoutY2 = new QGridLayout( aGridGrpY2 ); aGridGrpY2->setLayout( aGridLayoutY2 ); aGridLayoutY2->setMargin( MARGIN_SIZE ); aGridLayoutY2->setSpacing( SPACING_SIZE ); + myY2GridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MAJOR" ), aGridGrpY2 ); + QLabel* aY2MajLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY2); myY2GridSpin = new QSpinBox( aGridGrpY2 ); myY2GridSpin->setMinimum( 1 ); @@ -238,7 +263,9 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myY2GridSpin->setSingleStep( 1 ); myY2GridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myY2GridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myY2MinGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MINOR" ), aGridGrpY2 ); + QLabel* aY2MinLbl = new QLabel( tr( "PLOT2D_MAX_INTERVALS" ), aGridGrpY2); myY2MinGridSpin = new QSpinBox( aGridGrpY2 ); myY2MinGridSpin->setMinimum( 1 ); @@ -266,9 +293,12 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myY2MinGridSpin = 0; myY2ModeCombo = 0; } + aTabWidget->setCurrentIndex( 0 ); /* "Set as default" check box */ + myDefCheck = new QCheckBox( tr( "PLOT2D_SET_AS_DEFAULT_CHECK" ), this ); + /* OK/Cancel buttons */ myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); myOkBtn->setAutoDefault( TRUE ); @@ -306,7 +336,6 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo connect( myTitleCheck, SIGNAL( clicked() ), this, SLOT( onMainTitleChecked() ) ); connect( myTitleXCheck, SIGNAL( clicked() ), this, SLOT( onXTitleChecked() ) ); connect( myTitleYCheck, SIGNAL( clicked() ), this, SLOT( onYTitleChecked() ) ); - connect( myBackgroundBtn, SIGNAL( clicked() ), this, SLOT( onBackgroundClicked() ) ); connect( myLegendCheck, SIGNAL( clicked() ), this, SLOT( onLegendChecked() ) ); connect( myXGridCheck, SIGNAL( clicked() ), this, SLOT( onXGridMajorChecked() ) ); connect( myYGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMajorChecked() ) ); @@ -316,7 +345,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - if (mySecondAxisY) { + if ( mySecondAxisY ) { connect( myTitleY2Check, SIGNAL( clicked() ), this, SLOT( onY2TitleChecked() ) ); connect( myY2GridCheck, SIGNAL( clicked() ), this, SLOT( onY2GridMajorChecked() ) ); connect( myY2MinGridCheck, SIGNAL( clicked() ), this, SLOT( onY2GridMinorChecked() ) ); @@ -331,7 +360,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo onXGridMajorChecked(); onYGridMajorChecked(); onXGridMinorChecked(); - if (mySecondAxisY) { + if ( mySecondAxisY ) { onY2TitleChecked(); onY2GridMajorChecked(); onY2GridMinorChecked(); @@ -339,13 +368,17 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo } /*! - Destructor + \brief Destructor. */ Plot2d_SetupViewDlg::~Plot2d_SetupViewDlg() { } + /*! - Sets main title attributes + \brief Set main title attributes. + \param enable if \c true main title is enabled + \param title main title + \sa isMainTitleEnabled(), getMainTitle() */ void Plot2d_SetupViewDlg::setMainTitle( bool enable, const QString& title ) { @@ -354,22 +387,32 @@ void Plot2d_SetupViewDlg::setMainTitle( bool enable, const QString& title ) myTitleEdit->setText( title ); onMainTitleChecked(); } + /*! - Returns TRUE if main title is enabled + \brief Check if main title is enabled. + \return \c true if main title is enabled + \sa setMainTitle() */ bool Plot2d_SetupViewDlg::isMainTitleEnabled() { return myTitleCheck->isChecked(); } + /*! - Gets main title + \brief Get main title. + \return main title + \sa setMainTitle() */ QString Plot2d_SetupViewDlg::getMainTitle() { return myTitleEdit->text(); } + /*! - Sets horizontal axis title attributes + \brief Set horizontal axis title attributes. + \param enable if \c true horizontal axis title is enabled + \param title horizontal axis title + \sa isXTitleEnabled(), getXTitle() */ void Plot2d_SetupViewDlg::setXTitle( bool enable, const QString& title ) { @@ -378,22 +421,32 @@ void Plot2d_SetupViewDlg::setXTitle( bool enable, const QString& title ) myTitleXEdit->setText( title ); onXTitleChecked(); } + /*! - Returns TRUE if horizontal axis title is enabled + \brief Check if main title is enabled. + \return \c true if horizontal axis title is enabled + \sa setXTitle() */ bool Plot2d_SetupViewDlg::isXTitleEnabled() { return myTitleXCheck->isChecked(); } + /*! - Gets horizontal axis title + \brief Get horizontal axis title. + \return horizontal axis title + \sa setXTitle() */ QString Plot2d_SetupViewDlg::getXTitle() { return myTitleXEdit->text(); } + /*! - Sets vertical left axis title attributes + \brief Set left vertical axis title attributes. + \param enable if \c true left vertical axis title is enabled + \param title left vertical axis title + \sa setY2Title(), isYTitleEnabled(), getYTitle() */ void Plot2d_SetupViewDlg::setYTitle( bool enable, const QString& title ) { @@ -402,8 +455,12 @@ void Plot2d_SetupViewDlg::setYTitle( bool enable, const QString& title ) myTitleYEdit->setText( title ); onYTitleChecked(); } + /*! - Sets vertical right axis title attributes + \brief Set right vertical axis title attributes. + \param enable if \c true right vertical axis title is enabled + \param title right vertical axis title + \sa setYTitle(), isY2TitleEnabled(), getY2Title() */ void Plot2d_SetupViewDlg::setY2Title( bool enable, const QString& title ) { @@ -412,50 +469,72 @@ void Plot2d_SetupViewDlg::setY2Title( bool enable, const QString& title ) myTitleY2Edit->setText( title ); onY2TitleChecked(); } + /*! - Returns TRUE if vertical left axis title is enabled + \brief Check if left vertical axis title is enabled. + \return \c true if right vertical axis title is enabled + \sa setYTitle() */ bool Plot2d_SetupViewDlg::isYTitleEnabled() { return myTitleYCheck->isChecked(); } + /*! - Returns TRUE if vertical right axis title is enabled + \brief Check if right vertical axis title is enabled. + \return \c true if right vertical axis title is enabled + \sa setY2Title() */ bool Plot2d_SetupViewDlg::isY2TitleEnabled() { return myTitleY2Check->isChecked(); } + /*! - Gets vertical left axis title + \brief Get left vertical axis title. + \return left vertical axis title + \sa setYTitle() */ QString Plot2d_SetupViewDlg::getYTitle() { return myTitleYEdit->text(); } + /*! - Gets vertical right axis title + \brief Get right vertical axis title. + \return right vertical axis title + \sa setY2Title() */ QString Plot2d_SetupViewDlg::getY2Title() { return myTitleY2Edit->text(); } + /*! - Sets curve type : 0 - points, 1 - lines, 2 - splines + \brief Set curve type. + \param type curve type: 0 (points), 1 (lines) or 2 (splines) + \sa getCurveType() */ void Plot2d_SetupViewDlg::setCurveType( const int type ) { myCurveCombo->setCurrentIndex( type ); } + /*! - Gets curve type : 0 - points, 1 - lines, 2 - splines + \brief Get curve type. + \return curve type: 0 (points), 1 (lines) or 2 (splines) + \sa setCurveType() */ int Plot2d_SetupViewDlg::getCurveType() { return myCurveCombo->currentIndex(); } + /*! - Sets legend attributes : pos = 0 - left, 1 - right, 2 - top, 3 - bottom + \brief Set legend attribute. + \param if \c true legend is shown + \param pos legend position: 0 (left), 1 (right), 2 (top), 3 (bottom) + \sa isLegendEnabled(), getLegendPos() */ void Plot2d_SetupViewDlg::setLegend( bool enable, int pos ) { @@ -463,58 +542,80 @@ void Plot2d_SetupViewDlg::setLegend( bool enable, int pos ) myLegendCombo->setCurrentIndex( pos ); onLegendChecked(); } + /*! - Returns TRUE if legend is enabled + \brief Check if legend is enabled. + \return \c true if legend is enabled + \sa setLegend() */ bool Plot2d_SetupViewDlg::isLegendEnabled() { return myLegendCheck->isChecked(); } + /*! - Returns legend position + \brief Get legend position. + \return legend position: 0 (left), 1 (right), 2 (top), 3 (bottom) + \sa setLegend() */ int Plot2d_SetupViewDlg::getLegendPos() { return myLegendCombo->currentIndex(); } + /*! - Sets marker size + \brief Set marker size. + \param size marker size + \sa getMarkerSize() */ void Plot2d_SetupViewDlg::setMarkerSize( const int size ) { myMarkerSpin->setValue( size ); } + /*! - Gets marker size + \brief Get marker size. + \return marker size + \sa setMarkerSize() */ int Plot2d_SetupViewDlg::getMarkerSize() { return myMarkerSpin->value(); } + /*! - Sets background color + \brief Set background color. + \param color background color + \sa getBackgroundColor() */ void Plot2d_SetupViewDlg::setBackgroundColor( const QColor& color ) { - QPalette pal = myBackgroundBtn->palette(); - pal.setColor( QPalette::Active, QPalette::Button, color ); - pal.setColor( QPalette::Inactive, QPalette::Button, color ); - - myBackgroundBtn->setPalette( pal ); + myBackgroundBtn->setColor( color ); } + /*! - Gets background color + \brief Get background color. + \return background color + \sa setBackgroundColor() */ QColor Plot2d_SetupViewDlg::getBackgroundColor() { - return myBackgroundBtn->palette().color( QPalette::Active, QPalette::Button ); + return myBackgroundBtn->color(); } + /*! - Sets major grid parameters + \brief Set major grid parameters. + \param enableX if \c true, horizontal major grid is enabled + \param divX maximum number of ticks for horizontal major grid + \param enableY if \c true, left vertical major grid is enabled + \param divY maximum number of ticks for left vertical major grid + \param enableY2 if \c true, right vertical major grid is enabled + \param divY2 maximum number of ticks for right vertical major grid + \sa getMajorGrid() */ void Plot2d_SetupViewDlg::setMajorGrid( bool enableX, const int divX, bool enableY, const int divY, - bool enableY2, const int divY2 ) + bool enableY2, const int divY2 ) { myXGridCheck->setChecked( enableX ); myXGridSpin->setValue( divX ); @@ -528,12 +629,20 @@ void Plot2d_SetupViewDlg::setMajorGrid( bool enableX, const int divX, onY2GridMajorChecked(); } } + /*! - Gets major grid parameters + \brief Get major grid parameters. + \param enableX \c true if horizontal major grid is enabled + \param divX maximum number of ticks for horizontal major grid + \param enableY \c true if left vertical major grid is enabled + \param divY maximum number of ticks for left vertical major grid + \param enableY2 \c true if right vertical major grid is enabled + \param divY2 maximum number of ticks for right vertical major grid + \sa setMajorGrid() */ void Plot2d_SetupViewDlg::getMajorGrid( bool& enableX, int& divX, bool& enableY, int& divY, - bool& enableY2, int& divY2) + bool& enableY2, int& divY2 ) { enableX = myXGridCheck->isChecked(); divX = myXGridSpin->value(); @@ -548,12 +657,20 @@ void Plot2d_SetupViewDlg::getMajorGrid( bool& enableX, int& divX, divY2 = 1; } } + /*! - Sets minor grid parameters + \brief Set minor grid parameters. + \param enableX if \c true, horizontal minor grid is enabled + \param divX maximum number of ticks for horizontal minor grid + \param enableY if \c true, left vertical minor grid is enabled + \param divY maximum number of ticks for left vertical minor grid + \param enableY2 if \c true, right vertical minor grid is enabled + \param divY2 maximum number of ticks for right vertical minor grid + \sa getMinorGrid() */ void Plot2d_SetupViewDlg::setMinorGrid( bool enableX, const int divX, bool enableY, const int divY, - bool enableY2, const int divY2) + bool enableY2, const int divY2 ) { myXMinGridCheck->setChecked( enableX ); myXMinGridSpin->setValue( divX ); @@ -567,18 +684,26 @@ void Plot2d_SetupViewDlg::setMinorGrid( bool enableX, const int divX, onY2GridMinorChecked(); } } + /*! - Gets minor grid parameters + \brief Get minor grid parameters. + \param enableX \c true if horizontal minor grid is enabled + \param divX maximum number of ticks for horizontal minor grid + \param enableY \c true if left vertical minor grid is enabled + \param divY maximum number of ticks for left vertical minor grid + \param enableY2 \c true if right vertical minor grid is enabled + \param divY2 maximum number of ticks for right vertical minor grid + \sa setMinorGrid() */ void Plot2d_SetupViewDlg::getMinorGrid( bool& enableX, int& divX, bool& enableY, int& divY, - bool& enableY2, int& divY2) + bool& enableY2, int& divY2 ) { enableX = myXMinGridCheck->isChecked(); divX = myXMinGridSpin->value(); enableY = myYMinGridCheck->isChecked(); divY = myYMinGridSpin->value(); - if (mySecondAxisY) { + if ( mySecondAxisY ) { enableY2 = myY2MinGridCheck->isChecked(); divY2 = myY2MinGridSpin->value(); } @@ -587,114 +712,127 @@ void Plot2d_SetupViewDlg::getMinorGrid( bool& enableX, int& divX, divY2 = 1; } } + /*! - Sets scale mode for hor. and ver. axes : 0 - linear, 1 - logarithmic + \brief Set scale mode for horizontal and vertical axes. + \param xMode horizontal axis scale mode: 0 (linear), 1 (logarithmic) + \param yMode vertical axis scale mode: 0 (linear), 1 (logarithmic) + \sa getXScaleMode(), getYScaleMode() */ void Plot2d_SetupViewDlg::setScaleMode( const int xMode, const int yMode ) { myXModeCombo->setCurrentIndex( xMode ); myYModeCombo->setCurrentIndex( yMode ); } + /*! - Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic + \brief Get scale mode for horizontal axis. + \return horizontal axis scale mode: 0 (linear), 1 (logarithmic) + \sa setScaleMode() */ -int Plot2d_SetupViewDlg::getXScaleMode() +int Plot2d_SetupViewDlg::getXScaleMode() { return myXModeCombo->currentIndex(); } + /*! - Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic + \brief Get scale mode for vertical axis. + \return vertical axis scale mode: 0 (linear), 1 (logarithmic) + \sa setScaleMode() */ int Plot2d_SetupViewDlg::getYScaleMode() { return myYModeCombo->currentIndex(); } + /*! - Slot, called when user clicks "Show main title" check box + \brief Called when user clicks "Show main title" check box. */ void Plot2d_SetupViewDlg::onMainTitleChecked() { myTitleEdit->setEnabled( myTitleCheck->isChecked() ); } + /*! - Slot, called when user clicks "Show horizontal axis title" check box + \brief Called when user clicks "Show horizontal axis title" check box. */ void Plot2d_SetupViewDlg::onXTitleChecked() { myTitleXEdit->setEnabled( myTitleXCheck->isChecked() ); } + /*! - Slot, called when user clicks "Show vertical left axis title" check box + \brief Called when user clicks "Show vertical left axis title" check box. */ void Plot2d_SetupViewDlg::onYTitleChecked() { myTitleYEdit->setEnabled( myTitleYCheck->isChecked() ); } + /*! - Slot, called when user clicks "Show vertical right axis title" check box + \brief Called when user clicks "Show vertical right axis title" check box. */ void Plot2d_SetupViewDlg::onY2TitleChecked() { myTitleY2Edit->setEnabled( myTitleY2Check->isChecked() ); } + /*! - Slot, called when user clicks "Change bacground color" button -*/ -void Plot2d_SetupViewDlg::onBackgroundClicked() -{ - QColor color = QColorDialog::getColor( getBackgroundColor() ); - if ( color.isValid() ) { - setBackgroundColor( color ); - } -} -/*! - Slot, called when user clicks "Show Legend" check box + \brief Called when user clicks "Show Legend" check box. */ void Plot2d_SetupViewDlg::onLegendChecked() { myLegendCombo->setEnabled( myLegendCheck->isChecked() ); } + /*! - Slot, called when user clicks "Enable hor. major grid" check box + \brief Called when user clicks "Enable horizontal major grid" check box. */ void Plot2d_SetupViewDlg::onXGridMajorChecked() { myXMinGridCheck->setEnabled( myXGridCheck->isChecked() ); } + /*! - Slot, called when user clicks "Enable ver. major grid" check box + \brief Called when user clicks "Enable left vertical major grid" check box. */ void Plot2d_SetupViewDlg::onYGridMajorChecked() { myYMinGridCheck->setEnabled( myYGridCheck->isChecked() ); } + /*! - Slot, called when user clicks "Enable ver. major grid" check box + \brief Called when user clicks "Enable right vertical major grid" check box. */ void Plot2d_SetupViewDlg::onY2GridMajorChecked() { myY2MinGridCheck->setEnabled( myY2GridCheck->isChecked() ); } + /*! - Slot, called when user clicks "Enable hor. minor grid" check box + \brief Called when user clicks "Enable horizontal minor grid" check box. */ void Plot2d_SetupViewDlg::onXGridMinorChecked() { } + /*! - Slot, called when user clicks "Enable ver. minor grid" check box + \brief Called when user clicks "Enable left vertical minor grid" check box. */ void Plot2d_SetupViewDlg::onYGridMinorChecked() { } + /*! - Slot, called when user clicks "Enable ver. minor grid" check box + \brief Called when user clicks "Enable right vertical minor grid" check box. */ void Plot2d_SetupViewDlg::onY2GridMinorChecked() { } + /*! - Retursns true if "Set as default" check box is on + \brief Get "Set settings as default" check box value. + \return \c true if "Set settings as default" check box is on */ bool Plot2d_SetupViewDlg::isSetAsDefault() { diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h index 862e9978a..dc75f4daa 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.h +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -16,109 +16,117 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : Plot2d_SetupViewDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #ifndef PLOT2D_SETUPVIEWDLG_H #define PLOT2D_SETUPVIEWDLG_H #include "Plot2d.h" + #include class QSpinBox; class QCheckBox; class QLineEdit; class QComboBox; -class QToolButton; class QPushButton; +class QtxColorButton; class PLOT2D_EXPORT Plot2d_SetupViewDlg : public QDialog { Q_OBJECT public: - Plot2d_SetupViewDlg( QWidget* parent = 0, bool showDefCheck = false, bool secondAxisY = false ); + Plot2d_SetupViewDlg( QWidget* = 0, bool = false, bool = false ); ~Plot2d_SetupViewDlg(); - void setMainTitle( bool enable, const QString& title = QString::null ); - bool isMainTitleEnabled(); - QString getMainTitle(); - void setXTitle( bool enable, const QString& title = QString::null ); - bool isXTitleEnabled(); - QString getXTitle(); - void setYTitle( bool enable, const QString& title = QString::null ); - void setY2Title( bool enable, const QString& title = QString::null ); - bool isYTitleEnabled(); - bool isY2TitleEnabled(); - QString getYTitle(); - QString getY2Title(); - void setCurveType( const int type ); - int getCurveType(); - void setLegend( bool enable, int pos ); - bool isLegendEnabled(); - int getLegendPos(); - void setMarkerSize( const int size ); - int getMarkerSize(); - void setBackgroundColor( const QColor& color ); - QColor getBackgroundColor(); - void setMajorGrid( bool enableX, const int xdiv, bool enableY, const int divY, - bool enableY2, const int divY2 ); - void getMajorGrid( bool& enableX, int& xdiv, bool& enableY, int& divY, - bool& enableY2, int& divY2); - void setMinorGrid( bool enableX, const int xdiv, bool enableY, const int divY, - bool enableY2, const int divY2); - void getMinorGrid( bool& enableX, int& xdiv, bool& enableY, int& divY, - bool& enableY2, int& divY2); - void setScaleMode( const int xMode, const int yMode ); - int getXScaleMode(); - int getYScaleMode(); - bool isSetAsDefault(); + void setMainTitle( bool, const QString& = QString() ); + bool isMainTitleEnabled(); + QString getMainTitle(); + + void setXTitle( bool, const QString& = QString() ); + bool isXTitleEnabled(); + QString getXTitle(); + + void setYTitle( bool, const QString& = QString() ); + void setY2Title( bool, const QString& = QString() ); + bool isYTitleEnabled(); + bool isY2TitleEnabled(); + QString getYTitle(); + QString getY2Title(); + + void setCurveType( const int ); + int getCurveType(); + + void setLegend( bool, int ); + bool isLegendEnabled(); + int getLegendPos(); + + void setMarkerSize( const int ); + int getMarkerSize(); + + void setBackgroundColor( const QColor& ); + QColor getBackgroundColor(); + + void setMajorGrid( bool, const int, bool, const int, bool, const int ); + void getMajorGrid( bool&, int&, bool&, int&, bool&, int& ); + void setMinorGrid( bool, const int, bool, const int, bool, const int ); + void getMinorGrid( bool&, int&, bool&, int&, bool&, int& ); + + void setScaleMode( const int, const int ); + int getXScaleMode(); + int getYScaleMode(); + + bool isSetAsDefault(); protected slots: - void onMainTitleChecked(); - void onXTitleChecked(); - void onYTitleChecked(); - void onY2TitleChecked(); - void onBackgroundClicked(); - void onLegendChecked(); - void onXGridMajorChecked(); - void onYGridMajorChecked(); - void onY2GridMajorChecked(); - void onXGridMinorChecked(); - void onYGridMinorChecked(); - void onY2GridMinorChecked(); + void onMainTitleChecked(); + void onXTitleChecked(); + void onYTitleChecked(); + void onY2TitleChecked(); + void onLegendChecked(); + void onXGridMajorChecked(); + void onYGridMajorChecked(); + void onY2GridMajorChecked(); + void onXGridMinorChecked(); + void onYGridMinorChecked(); + void onY2GridMinorChecked(); private: - QCheckBox* myTitleCheck; - QLineEdit* myTitleEdit; - QCheckBox* myTitleXCheck; - QLineEdit* myTitleXEdit; - QCheckBox* myTitleYCheck; - QCheckBox* myTitleY2Check; - QLineEdit* myTitleYEdit; - QLineEdit* myTitleY2Edit; - QToolButton* myBackgroundBtn; - QCheckBox* myXGridCheck; - QSpinBox* myXGridSpin; - QCheckBox* myYGridCheck; - QCheckBox* myY2GridCheck; - QSpinBox* myYGridSpin; - QSpinBox* myY2GridSpin; - QCheckBox* myXMinGridCheck; - QSpinBox* myXMinGridSpin; - QCheckBox* myYMinGridCheck; - QCheckBox* myY2MinGridCheck; - QSpinBox* myYMinGridSpin; - QSpinBox* myY2MinGridSpin; - QComboBox* myCurveCombo; - QCheckBox* myLegendCheck; - QComboBox* myLegendCombo; - QSpinBox* myMarkerSpin; - QComboBox* myXModeCombo; - QComboBox* myYModeCombo; - QComboBox* myY2ModeCombo; - QCheckBox* myDefCheck; - - QPushButton* myOkBtn; - QPushButton* myCancelBtn; - bool mySecondAxisY; + QCheckBox* myTitleCheck; + QLineEdit* myTitleEdit; + QCheckBox* myTitleXCheck; + QLineEdit* myTitleXEdit; + QCheckBox* myTitleYCheck; + QCheckBox* myTitleY2Check; + QLineEdit* myTitleYEdit; + QLineEdit* myTitleY2Edit; + QtxColorButton* myBackgroundBtn; + QCheckBox* myXGridCheck; + QSpinBox* myXGridSpin; + QCheckBox* myYGridCheck; + QCheckBox* myY2GridCheck; + QSpinBox* myYGridSpin; + QSpinBox* myY2GridSpin; + QCheckBox* myXMinGridCheck; + QSpinBox* myXMinGridSpin; + QCheckBox* myYMinGridCheck; + QCheckBox* myY2MinGridCheck; + QSpinBox* myYMinGridSpin; + QSpinBox* myY2MinGridSpin; + QComboBox* myCurveCombo; + QCheckBox* myLegendCheck; + QComboBox* myLegendCombo; + QSpinBox* myMarkerSpin; + QComboBox* myXModeCombo; + QComboBox* myYModeCombo; + QComboBox* myY2ModeCombo; + QCheckBox* myDefCheck; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + bool mySecondAxisY; }; -#endif +#endif // PLOT2D_SETUPVIEWDLG_H diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index d944a6011..390659ac1 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -526,118 +526,6 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) return info; } -/*! - Converts Plot2d_Curve's marker style to Qwt marker style [ static ] -*/ -static QwtSymbol::Style plot2qwtMarker( Plot2d_Curve::MarkerType m ) -{ - QwtSymbol::Style ms = QwtSymbol::NoSymbol; - switch ( m ) { - case Plot2d_Curve::Circle: - ms = QwtSymbol::Ellipse; break; - case Plot2d_Curve::Rectangle: - ms = QwtSymbol::Rect; break; - case Plot2d_Curve::Diamond: - ms = QwtSymbol::Diamond; break; - case Plot2d_Curve::DTriangle: - ms = QwtSymbol::DTriangle; break; - case Plot2d_Curve::UTriangle: - ms = QwtSymbol::UTriangle; break; - case Plot2d_Curve::LTriangle: // Qwt confuses LTriangle and RTriangle :((( - ms = QwtSymbol::RTriangle; break; - case Plot2d_Curve::RTriangle: // Qwt confuses LTriangle and RTriangle :((( - ms = QwtSymbol::LTriangle; break; - case Plot2d_Curve::Cross: - ms = QwtSymbol::Cross; break; - case Plot2d_Curve::XCross: - ms = QwtSymbol::XCross; break; - case Plot2d_Curve::None: - default: - ms = QwtSymbol::NoSymbol; break; - } - return ms; -} - -/*! - Converts Qwt marker style to Plot2d_Curve's marker style [ static ] -*/ -static Plot2d_Curve::MarkerType qwt2plotMarker( QwtSymbol::Style m ) -{ - Plot2d_Curve::MarkerType ms = Plot2d_Curve::None; - switch ( m ) { - case QwtSymbol::Ellipse: - ms = Plot2d_Curve::Circle; break; - case QwtSymbol::Rect: - ms = Plot2d_Curve::Rectangle; break; - case QwtSymbol::Diamond: - ms = Plot2d_Curve::Diamond; break; - case QwtSymbol::DTriangle: - ms = Plot2d_Curve::DTriangle; break; - case QwtSymbol::UTriangle: - ms = Plot2d_Curve::UTriangle; break; - case QwtSymbol::RTriangle: // Qwt confuses LTriangle and RTriangle :((( - ms = Plot2d_Curve::LTriangle; break; - case QwtSymbol::LTriangle: // Qwt confuses LTriangle and RTriangle :((( - ms = Plot2d_Curve::RTriangle; break; - case QwtSymbol::Cross: - ms = Plot2d_Curve::Cross; break; - case QwtSymbol::XCross: - ms = Plot2d_Curve::XCross; break; - case QwtSymbol::NoSymbol: - default: - ms = Plot2d_Curve::None; break; - } - return ms; -} - -/*! - Converts Plot2d_Curve's line style to Qwt line style [ static ] -*/ -static Qt::PenStyle plot2qwtLine( Plot2d_Curve::LineType p ) -{ - Qt::PenStyle ps = Qt::NoPen; - switch ( p ) { - case Plot2d_Curve::Solid: - ps = Qt::SolidLine; break; - case Plot2d_Curve::Dash: - ps = Qt::DashLine; break; - case Plot2d_Curve::Dot: - ps = Qt::DotLine; break; - case Plot2d_Curve::DashDot: - ps = Qt::DashDotLine; break; - case Plot2d_Curve::DashDotDot: - ps = Qt::DashDotDotLine; break; - case Plot2d_Curve::NoPen: - default: - ps = Qt::NoPen; break; - } - return ps; -} - -/*! - Converts Qwt line style to Plot2d_Curve's line style [ static ] -*/ -static Plot2d_Curve::LineType qwt2plotLine( Qt::PenStyle p ) -{ - Plot2d_Curve::LineType ps = Plot2d_Curve::NoPen; - switch ( p ) { - case Qt::SolidLine: - ps = Plot2d_Curve::Solid; break; - case Qt::DashLine: - ps = Plot2d_Curve::Dash; break; - case Qt::DotLine: - ps = Plot2d_Curve::Dot; break; - case Qt::DashDotLine: - ps = Plot2d_Curve::DashDot; break; - case Qt::DashDotDotLine: - ps = Plot2d_Curve::DashDotDot; break; - case Qt::NoPen: - default: - ps = Plot2d_Curve::NoPen; break; - } - return ps; -} - /*! Adds curve into view */ @@ -675,12 +563,12 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) QPen( color ), QSize( myMarkerSize, myMarkerSize ) ) ); curve->setColor( color ); - curve->setLine( qwt2plotLine( typeLine ) ); - curve->setMarker( qwt2plotMarker( typeMarker ) ); + curve->setLine( Plot2d::qwt2plotLine( typeLine ) ); + curve->setMarker( Plot2d::qwt2plotMarker( typeMarker ) ); } else { - Qt::PenStyle ps = plot2qwtLine( curve->getLine() ); - QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() ); + Qt::PenStyle ps = Plot2d::plot2qwtLine( curve->getLine() ); + QwtSymbol::Style ms = Plot2d::plot2qwtMarker( curve->getMarker() ); aPCurve->setPen( QPen( curve->getColor(), curve->getLineWidth(), ps ) ); aPCurve->setSymbol( QwtSymbol( ms, QBrush( curve->getColor() ), @@ -758,8 +646,8 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) if ( hasPlotCurve( curve ) ) { QwtPlotCurve* aPCurve = getPlotCurve( curve ); if ( !curve->isAutoAssign() ) { - Qt::PenStyle ps = plot2qwtLine( curve->getLine() ); - QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() ); + Qt::PenStyle ps = Plot2d::plot2qwtLine( curve->getLine() ); + QwtSymbol::Style ms = Plot2d::plot2qwtMarker( curve->getMarker() ); aPCurve->setPen ( QPen( curve->getColor(), curve->getLineWidth(), ps ) ); aPCurve->setSymbol( QwtSymbol( ms, QBrush( curve->getColor() ), -- 2.39.2