From: nds Date: Fri, 8 Jun 2007 08:44:07 +0000 (+0000) Subject: Porting on qwt-5.0.1 and qt-4.2.3 products. Temporarily version. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d6fe7a8c0e648dba45c55ece32e03dc6583bd32;p=modules%2Fgui.git Porting on qwt-5.0.1 and qt-4.2.3 products. Temporarily version. --- diff --git a/adm_local/unix/config_files/check_qwt.m4 b/adm_local/unix/config_files/check_qwt.m4 index 151cf5574..443f0bc32 100644 --- a/adm_local/unix/config_files/check_qwt.m4 +++ b/adm_local/unix/config_files/check_qwt.m4 @@ -97,7 +97,7 @@ then else QT_LIB_DIR="-L$QTDIR/lib${LIB_LOCATION_SUFFIX}" fi - LIBS="$LIBS $QT_LIB_DIR -lQtCore" + LIBS="$LIBS $QT_LIB_DIR -lQtCore -lQtGui" if test "x$QWTHOME" = "x/usr" then @@ -111,12 +111,14 @@ then AC_CACHE_VAL(salome_cv_lib_qwt,[ AC_TRY_LINK( -#include +#include #include , int n; char **s; QApplication a(n, s); QwtPlot* p; + p.resize( 600, 400 ); + p.show(); a.exec();, eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no") ]) diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index bec633fdc..41668a1f6 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -17,7 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "Plot2d_Curve.h" -#include +#include /*! Constructor @@ -166,7 +166,7 @@ void Plot2d_Curve::insertPoint(int thePos, double theX, double theY, const QStri aPoint.y = theY; aPoint.text = txt; - QValueList::iterator aIt; + QList::iterator aIt; int aCurrent = 0; for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { if (thePos == aCurrent) { @@ -183,7 +183,10 @@ void Plot2d_Curve::insertPoint(int thePos, double theX, double theY, const QStri */ void Plot2d_Curve::deletePoint(int thePos) { - QValueList::iterator aIt; + if ( thePos >= 0 && thePos < myPoints.count() ) + myPoints.removeAt( thePos ); + /* + QList::iterator aIt; int aCurrent = 0; for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { if (thePos == aCurrent) { @@ -192,6 +195,7 @@ void Plot2d_Curve::deletePoint(int thePos) } aCurrent++; } + */ } /*! @@ -366,7 +370,7 @@ QwtPlot::Axis Plot2d_Curve::getYAxis() const */ double Plot2d_Curve::getMinX() const { - QValueList::const_iterator aIt; + QList::const_iterator aIt; double aMinX = 1e150; //int aCurrent = 0; for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { @@ -381,7 +385,7 @@ double Plot2d_Curve::getMinX() const */ double Plot2d_Curve::getMinY() const { - QValueList::const_iterator aIt; + QList::const_iterator aIt; double aMinY = 1e150; //int aCurrent = 0; for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index bd3be97bd..a5d7cef73 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -20,8 +20,7 @@ #define PLOT2D_CURVE_H #include "Plot2d.h" -#include -#include +#include #include class QColor; @@ -33,7 +32,7 @@ typedef struct QString text; } Plot2d_Point; -typedef QValueList pointList; +typedef QList pointList; class PLOT2D_EXPORT Plot2d_Curve { @@ -107,6 +106,6 @@ protected: pointList myPoints; }; -typedef QPtrList curveList; +typedef QList curveList; #endif diff --git a/src/Plot2d/Plot2d_FitDataDlg.cxx b/src/Plot2d/Plot2d_FitDataDlg.cxx index 9ff544a07..f5141e1a7 100755 --- a/src/Plot2d/Plot2d_FitDataDlg.cxx +++ b/src/Plot2d/Plot2d_FitDataDlg.cxx @@ -22,13 +22,13 @@ // $Header$ #include "Plot2d_FitDataDlg.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #define SPACING_SIZE 6 #define MARGIN_SIZE 11 @@ -39,24 +39,22 @@ */ Plot2d_FitDataDlg::Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY ) : QDialog( parent ? parent : 0, - "Plot2d_FitDataDlg", - true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY ) + Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY ) { - setCaption( tr( "FIT_DATA_TLT" ) ); + setObjectName( "Plot2d_FitDataDlg" ); + setModal( true ); + setWindowTitle( tr( "FIT_DATA_TLT" ) ); setSizeGripEnabled( TRUE ); QGridLayout* topLayout = new QGridLayout( this ); topLayout->setSpacing( SPACING_SIZE ); topLayout->setMargin( MARGIN_SIZE ); // 'Range' group - myRangeGrp = new QButtonGroup( this ); - myRangeGrp->setColumnLayout( 0, Qt::Vertical ); - myRangeGrp->layout()->setSpacing( 0 ); - myRangeGrp->layout()->setMargin( 0 ); - QGridLayout* aGridLayout = new QGridLayout( myRangeGrp->layout() ); + myRangeGrp = new QGroupBox( this ); + QGridLayout* aGridLayout = new QGridLayout( myRangeGrp ); + myRangeGrp->setLayout( aGridLayout ); aGridLayout->setAlignment( Qt::AlignTop ); aGridLayout->setMargin( MARGIN_SIZE ); aGridLayout->setSpacing( SPACING_SIZE ); @@ -122,45 +120,47 @@ Plot2d_FitDataDlg::Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY ) QFont font = horLab->font(); font.setBold( true ); horLab->setFont( font ); verLab->setFont( font ); - aGridLayout->addMultiCellLayout( aModeLayout, 0, 0, 0, 4 ); - aGridLayout->addMultiCellWidget( aHLine, 1, 1, 0, 4 ); - aGridLayout->addWidget ( horLab, 2, 0 ); - aGridLayout->addWidget ( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), - 2, 1 ); - aGridLayout->addWidget ( myXMinEdit, 2, 2 ); - aGridLayout->addWidget ( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), - 2, 3 ); - aGridLayout->addWidget ( myXMaxEdit, 2, 4 ); - aGridLayout->addWidget ( verLab, 3, 0 ); - aGridLayout->addWidget ( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), - 3, 1 ); - aGridLayout->addWidget ( myYMinEdit, 3, 2 ); - aGridLayout->addWidget ( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), - 3, 3 ); - aGridLayout->addWidget ( myYMaxEdit, 3, 4 ); + aGridLayout->addLayout( aModeLayout, 0, 0, 1, 5 ); + aGridLayout->addWidget( aHLine, 1, 0, 1, 5 ); + aGridLayout->addWidget( horLab, 2, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 2, 1 ); + aGridLayout->addWidget( myXMinEdit, 2, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 2, 3 ); + aGridLayout->addWidget( myXMaxEdit, 2, 4 ); + aGridLayout->addWidget( verLab, 3, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 3, 1 ); + aGridLayout->addWidget( myYMinEdit, 3, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 3, 3 ); + aGridLayout->addWidget( myYMaxEdit, 3, 4 ); if (mySecondAxisY) { QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp ); ver2Lab->setFont( font ); - aGridLayout->addWidget ( ver2Lab, 4, 0 ); - aGridLayout->addWidget ( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), - 4, 1 ); - aGridLayout->addWidget ( myY2MinEdit, 4, 2 ); - aGridLayout->addWidget ( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), - 4, 3 ); - aGridLayout->addWidget ( myY2MaxEdit, 4, 4 ); + aGridLayout->addWidget( ver2Lab, 4, 0 ); + aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), + 4, 1 ); + aGridLayout->addWidget( myY2MinEdit, 4, 2 ); + aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), + 4, 3 ); + aGridLayout->addWidget( myY2MaxEdit, 4, 4 ); } // OK/Cancel buttons - myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" ); + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myOkBtn->setObjectName( "buttonOk" ); myOkBtn->setAutoDefault( TRUE ); myOkBtn->setDefault( TRUE ); - myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + myCancelBtn->setObjectName( "buttonCancel" ); myCancelBtn->setAutoDefault( TRUE ); - topLayout->addMultiCellWidget( myRangeGrp, 0, 0, 0, 2 ); + topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 ); topLayout->addWidget( myOkBtn, 1, 0 ); - topLayout->setColStretch( 1, 5 ); + topLayout->setColumnStretch( 1, 5 ); topLayout->addWidget( myCancelBtn, 1, 2 ); // connect signals diff --git a/src/Plot2d/Plot2d_FitDataDlg.h b/src/Plot2d/Plot2d_FitDataDlg.h index ccecaaa32..096a8baa6 100755 --- a/src/Plot2d/Plot2d_FitDataDlg.h +++ b/src/Plot2d/Plot2d_FitDataDlg.h @@ -20,9 +20,9 @@ #define PLOT2D_FITDATADLG_H #include "Plot2d.h" -#include +#include -class QButtonGroup; +class QGroupBox; class QRadioButton; class QLineEdit; class QPushButton; @@ -57,7 +57,7 @@ protected slots: void onModeChanged(int); private: - QButtonGroup* myRangeGrp; + QGroupBox* myRangeGrp; QRadioButton* myModeAllRB; QRadioButton* myModeHorRB; QRadioButton* myModeVerRB; diff --git a/src/Plot2d/Plot2d_Prs.cxx b/src/Plot2d/Plot2d_Prs.cxx index 7c3bd0372..fe91c3da2 100755 --- a/src/Plot2d/Plot2d_Prs.cxx +++ b/src/Plot2d/Plot2d_Prs.cxx @@ -95,5 +95,5 @@ bool Plot2d_Prs::isSecondY() const */ void Plot2d_Prs::setAutoDel(bool theDel) { - myCurves.setAutoDelete(theDel); + //myCurves.setAutoDelete(theDel); } diff --git a/src/Plot2d/Plot2d_SetupCurveDlg.cxx b/src/Plot2d/Plot2d_SetupCurveDlg.cxx index dc2291e24..4bd211758 100644 --- a/src/Plot2d/Plot2d_SetupCurveDlg.cxx +++ b/src/Plot2d/Plot2d_SetupCurveDlg.cxx @@ -48,73 +48,78 @@ using namespace std; Constructor */ Plot2d_SetupCurveDlg::Plot2d_SetupCurveDlg( QWidget* parent ) - : QDialog( parent, "Plot2d_SetupCurveDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) { - setCaption( tr("TLT_SETUP_CURVE") ); + 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 ); - TopGroup->setColumnLayout( 0, Qt::Vertical ); - TopGroup->layout()->setSpacing( 0 ); TopGroup->layout()->setMargin( 0 ); - QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup ); + TopGroup->setLayout( TopGroupLayout ); TopGroupLayout->setAlignment( Qt::AlignTop ); TopGroupLayout->setSpacing( SPACING_SIZE ); TopGroupLayout->setMargin( MARGIN_SIZE ); QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), TopGroup ); - myLineCombo = new QComboBox( false, TopGroup ); + myLineCombo = new QComboBox( TopGroup ); + myLineCombo->setEditable( false ); myLineCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLineCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) ); - myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) ); - myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) ); - myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) ); - myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) ); - myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) ); - myLineCombo->setCurrentItem( 1 ); // SOLID by default + 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( 0, MAX_LINE_WIDTH, 1, TopGroup ); + myLineSpin = new QSpinBox( TopGroup ); + 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( false, TopGroup ); + myMarkerCombo = new QComboBox( TopGroup ); + myMarkerCombo->setEditable( false ); myMarkerCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myMarkerCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) ); - myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) ); - myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default + 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->addMultiCellWidget( myLineCombo, 0, 0, 1, 2 ); + TopGroupLayout->addWidget( myLineCombo, 0, 1, 1, 2 ); TopGroupLayout->addWidget( aLineWidthLab, 1, 0 ); - TopGroupLayout->addMultiCellWidget( myLineSpin, 1, 1, 1, 2 ); + TopGroupLayout->addWidget( myLineSpin, 1, 1, 1, 2 ); TopGroupLayout->addWidget( aMarkerLab, 2, 0 ); - TopGroupLayout->addMultiCellWidget( myMarkerCombo, 2, 2, 1, 2 ); + TopGroupLayout->addWidget( myMarkerCombo, 2, 1, 1, 2 ); TopGroupLayout->addWidget( aColorLab, 3, 0 ); TopGroupLayout->addWidget( myColorBtn, 3, 1 ); - TopGroupLayout->setColStretch( 2, 5 ); + TopGroupLayout->setColumnStretch( 2, 5 ); QGroupBox* GroupButtons = new QGroupBox( this ); - GroupButtons->setColumnLayout( 0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); + GroupButtons->setLayout( GroupButtonsLayout ); GroupButtonsLayout->setAlignment( Qt::AlignTop ); GroupButtonsLayout->setSpacing( SPACING_SIZE ); GroupButtonsLayout->setMargin( MARGIN_SIZE ); @@ -148,7 +153,7 @@ Plot2d_SetupCurveDlg::~Plot2d_SetupCurveDlg() */ void Plot2d_SetupCurveDlg::setLine( const int line, const int width ) { - myLineCombo->setCurrentItem( line ); + myLineCombo->setCurrentIndex( line ); myLineSpin->setValue( width ); } /*! @@ -156,7 +161,7 @@ void Plot2d_SetupCurveDlg::setLine( const int line, const int width ) */ int Plot2d_SetupCurveDlg::getLine() const { - return myLineCombo->currentItem(); + return myLineCombo->currentIndex(); } /*! Gets line width @@ -170,14 +175,14 @@ int Plot2d_SetupCurveDlg::getLineWidth() const */ void Plot2d_SetupCurveDlg::setMarker( const int marker ) { - myMarkerCombo->setCurrentItem( marker ); + myMarkerCombo->setCurrentIndex( marker ); } /*! Gets marker style */ int Plot2d_SetupCurveDlg::getMarker() const { - return myMarkerCombo->currentItem(); + return myMarkerCombo->currentIndex(); } /*! Sets color @@ -185,12 +190,9 @@ int Plot2d_SetupCurveDlg::getMarker() const void Plot2d_SetupCurveDlg::setColor( const QColor& color ) { QPalette pal = myColorBtn->palette(); - QColorGroup ca = pal.active(); - ca.setColor( QColorGroup::Button, color ); - QColorGroup ci = pal.inactive(); - ci.setColor( QColorGroup::Button, color ); - pal.setActive( ca ); - pal.setInactive( ci ); + pal.setColor( QPalette::Active, QPalette::Button, color ); + pal.setColor( QPalette::Inactive, QPalette::Button, color ); + myColorBtn->setPalette( pal ); } /*! @@ -198,7 +200,7 @@ void Plot2d_SetupCurveDlg::setColor( const QColor& color ) */ QColor Plot2d_SetupCurveDlg::getColor() const { - return myColorBtn->palette().active().button(); + return myColorBtn->palette().color( QPalette::Active, QPalette::Button ); } /*! button slot, invokes color selection dialog box diff --git a/src/Plot2d/Plot2d_SetupViewDlg.cxx b/src/Plot2d/Plot2d_SetupViewDlg.cxx index 9f1b2f03a..e89eaffc7 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.cxx +++ b/src/Plot2d/Plot2d_SetupViewDlg.cxx @@ -23,17 +23,17 @@ #include "Plot2d_SetupViewDlg.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define MARGIN_SIZE 11 #define SPACING_SIZE 6 @@ -45,11 +45,12 @@ Constructor */ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bool secondAxisY ) - : QDialog( parent, "Plot2d_SetupViewDlg", true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) { + setObjectName( "Plot2d_SetupViewDlg" ); + setModal( true ); mySecondAxisY = secondAxisY; - setCaption( tr("TLT_SETUP_PLOT2D_VIEW") ); + setWindowTitle( tr("TLT_SETUP_PLOT2D_VIEW") ); setSizeGripEnabled( TRUE ); QGridLayout* topLayout = new QGridLayout( this ); topLayout->setSpacing( SPACING_SIZE ); @@ -62,24 +63,29 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleEdit->setMinimumWidth( MIN_EDIT_WIDTH ); // curve type : points, lines, spline QLabel* aCurveLab = new QLabel( tr( "PLOT2D_CURVE_TYPE_LBL" ), this ); - myCurveCombo = new QComboBox( false, this ); + myCurveCombo = new QComboBox( this ); + myCurveCombo->setEditable( false ); myCurveCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myCurveCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_POINTS" ) ); - myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) ); - myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) ); + 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( false, this ); + myLegendCombo = new QComboBox( this ); + myCurveCombo->setEditable( false ); myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) ); - myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) ); - myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) ); - myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) ); + 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( 0, 100, 1, this ); + myMarkerSpin = new QSpinBox( this ); + myMarkerSpin->setMinimum( 0 ); + myMarkerSpin->setMaximum( 100 ); + myMarkerSpin->setSingleStep( 1 ); myMarkerSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myMarkerSpin->setMinimumWidth( MIN_SPIN_WIDTH ); @@ -90,23 +96,24 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo // scale mode QGroupBox* aScaleGrp = new QGroupBox( tr( "PLOT2D_SCALE_TLT" ), this ); - aScaleGrp->setColumnLayout(0, Qt::Vertical ); - aScaleGrp->layout()->setSpacing( 0 ); aScaleGrp->layout()->setMargin( 0 ); - QGridLayout* aScaleLayout = new QGridLayout( aScaleGrp->layout() ); + QGridLayout* aScaleLayout = new QGridLayout( aScaleGrp ); aScaleLayout->setMargin( MARGIN_SIZE ); aScaleLayout->setSpacing( SPACING_SIZE ); + aScaleGrp->setLayout( aScaleLayout ); QLabel* xScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_HOR" ), aScaleGrp ); - myXModeCombo = new QComboBox( false, aScaleGrp ); + myXModeCombo = new QComboBox( aScaleGrp ); + myCurveCombo->setEditable( false ); myXModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myXModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myXModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); - myXModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); + 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( false, aScaleGrp ); + myYModeCombo = new QComboBox( aScaleGrp ); + myCurveCombo->setEditable( false ); myYModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myYModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); - myYModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); - myYModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); + myYModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); + myYModeCombo->addItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); aScaleLayout->addWidget( xScaleLab, 0, 0 ); aScaleLayout->addWidget( myXModeCombo, 0, 1 ); @@ -114,7 +121,8 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo aScaleLayout->addWidget( myYModeCombo, 0, 3 ); // tab widget for choose properties of axis - QTabWidget* aTabWidget = new QTabWidget( this, "tabWidget" ); + QTabWidget* aTabWidget = new QTabWidget( this ); + aTabWidget->setObjectName( "tabWidget" ); // widget for parameters on Ox QWidget* aXWidget = new QWidget(aTabWidget); @@ -126,22 +134,27 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleXEdit = new QLineEdit( aXWidget ); myTitleXEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTitleXEdit->setMinimumWidth( MIN_EDIT_WIDTH ); - aXLayout->addWidget( myTitleXCheck, 1, 0 ); - aXLayout->addMultiCellWidget( myTitleXEdit, 1, 1, 1, 3 ); + aXLayout->addWidget( myTitleXCheck,1, 0 ); + aXLayout->addWidget( myTitleXEdit, 1, 1, 1, 3 ); // grid QGroupBox* aGridGrpX = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aXWidget ); - aGridGrpX->setColumnLayout(0, Qt::Vertical ); - aGridGrpX->layout()->setSpacing( 0 ); aGridGrpX->layout()->setMargin( 0 ); - QGridLayout* aGridLayoutX = new QGridLayout( aGridGrpX->layout() ); + QGridLayout* aGridLayoutX = new QGridLayout( aGridGrpX ); + aGridGrpX->setLayout( aGridLayoutX ); 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( 1, 100, 1, aGridGrpX ); + myXGridSpin = new QSpinBox( aGridGrpX ); + myXGridSpin->setMinimum( 1 ); + myXGridSpin->setMaximum( 100 ); + 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( 1, 100, 1, aGridGrpX ); + myXMinGridSpin = new QSpinBox( aGridGrpX ); + myXMinGridSpin->setMinimum( 1 ); + myXMinGridSpin->setMaximum( 100 ); + myXMinGridSpin->setSingleStep( 1 ); myXMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myXMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); @@ -151,7 +164,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo aGridLayoutX->addWidget( myXMinGridCheck, 1, 0 ); aGridLayoutX->addWidget( aXMinLbl, 1, 1 ); aGridLayoutX->addWidget( myXMinGridSpin, 1, 2 ); - aXLayout->addMultiCellWidget( aGridGrpX, 3, 3, 0, 3 ); + aXLayout->addWidget( aGridGrpX, 3, 0, 1, 4 ); aTabWidget->addTab( aXWidget, tr( "INF_AXES_X" ) ); @@ -165,22 +178,27 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleYEdit = new QLineEdit( aYWidget ); myTitleYEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTitleYEdit->setMinimumWidth( MIN_EDIT_WIDTH ); - aYLayout->addWidget( myTitleYCheck, 1, 0 ); - aYLayout->addMultiCellWidget( myTitleYEdit, 1, 1, 1, 3 ); + aYLayout->addWidget( myTitleYCheck,1, 0 ); + aYLayout->addWidget( myTitleYEdit, 1, 1, 1, 3 ); // grid QGroupBox* aGridGrpY = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget ); - aGridGrpY->setColumnLayout(0, Qt::Vertical ); - aGridGrpY->layout()->setSpacing( 0 ); aGridGrpY->layout()->setMargin( 0 ); - QGridLayout* aGridLayoutY = new QGridLayout( aGridGrpY->layout() ); + 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( 1, 100, 1, aGridGrpY ); + myYGridSpin = new QSpinBox( aGridGrpY ); + myYGridSpin->setMinimum( 1 ); + myYGridSpin->setMaximum( 100 ); + 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( 1, 100, 1, aGridGrpY ); + myYMinGridSpin = new QSpinBox( aGridGrpY ); + myYMinGridSpin->setMinimum( 1 ); + myYMinGridSpin->setMaximum( 100 ); + myYMinGridSpin->setSingleStep( 1 ); myYMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myYMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); @@ -190,7 +208,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo aGridLayoutY->addWidget( myYMinGridCheck, 1, 0 ); aGridLayoutY->addWidget( aYMinLbl, 1, 1 ); aGridLayoutY->addWidget( myYMinGridSpin, 1, 2 ); - aYLayout->addMultiCellWidget( aGridGrpY, 3, 3, 0, 3 ); + aYLayout->addWidget( aGridGrpY, 3, 0, 1, 4 ); aTabWidget->addTab( aYWidget, tr( "INF_AXES_Y_LEFT" ) ); @@ -206,22 +224,27 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myTitleY2Edit = new QLineEdit( aYWidget2 ); myTitleY2Edit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myTitleY2Edit->setMinimumWidth( MIN_EDIT_WIDTH ); - aYLayout2->addWidget( myTitleY2Check, 1, 0 ); - aYLayout2->addMultiCellWidget( myTitleY2Edit, 1, 1, 1, 3 ); + aYLayout2->addWidget( myTitleY2Check,1, 0 ); + aYLayout2->addWidget( myTitleY2Edit, 1, 1, 1, 3 ); // grid QGroupBox* aGridGrpY2 = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), aYWidget2 ); - aGridGrpY2->setColumnLayout(0, Qt::Vertical ); - aGridGrpY2->layout()->setSpacing( 0 ); aGridGrpY2->layout()->setMargin( 0 ); - QGridLayout* aGridLayoutY2 = new QGridLayout( aGridGrpY2->layout() ); + 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( 1, 100, 1, aGridGrpY2 ); + myY2GridSpin = new QSpinBox( aGridGrpY2 ); + myY2GridSpin->setMinimum( 1 ); + myY2GridSpin->setMaximum( 100 ); + 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( 1, 100, 1, aGridGrpY2 ); + myY2MinGridSpin = new QSpinBox( aGridGrpY2 ); + myY2MinGridSpin->setMinimum( 1 ); + myY2MinGridSpin->setMaximum( 100 ); + myY2MinGridSpin->setSingleStep( 1 ); myY2MinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myY2MinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); @@ -231,7 +254,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo aGridLayoutY2->addWidget( myY2MinGridCheck, 1, 0 ); aGridLayoutY2->addWidget( aY2MinLbl, 1, 1 ); aGridLayoutY2->addWidget( myY2MinGridSpin, 1, 2 ); - aYLayout2->addMultiCellWidget( aGridGrpY2, 3, 3, 0, 3 ); + aYLayout2->addWidget( aGridGrpY2, 3, 0, 1, 4 ); aTabWidget->addTab( aYWidget2, tr( "INF_AXES_Y_RIGHT" ) ); } @@ -244,7 +267,7 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo myY2MinGridSpin = 0; myY2ModeCombo = 0; } - aTabWidget->setCurrentPage( 0 ); + aTabWidget->setCurrentIndex( 0 ); /* "Set as default" check box */ myDefCheck = new QCheckBox( tr( "PLOT2D_SET_AS_DEFAULT_CHECK" ), this ); /* OK/Cancel buttons */ @@ -259,24 +282,24 @@ Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck, bo btnLayout->addWidget( myCancelBtn ); // layout widgets - topLayout->addWidget( myTitleCheck, 0, 0 ); - topLayout->addMultiCellWidget( myTitleEdit, 0, 0, 1, 3 ); - topLayout->addWidget( aCurveLab, 1, 0 ); - topLayout->addWidget( myCurveCombo, 1, 1 ); - topLayout->addWidget( myLegendCheck, 1, 2 ); - topLayout->addWidget( myLegendCombo, 1, 3 ); - topLayout->addWidget( aMarkerLab, 2, 0 ); - topLayout->addWidget( myMarkerSpin, 2, 1 ); + topLayout->addWidget( myTitleCheck, 0, 0 ); + topLayout->addWidget( myTitleEdit, 0, 1, 1, 3 ); + topLayout->addWidget( aCurveLab, 1, 0 ); + topLayout->addWidget( myCurveCombo, 1, 1 ); + topLayout->addWidget( myLegendCheck, 1, 2 ); + topLayout->addWidget( myLegendCombo, 1, 3 ); + topLayout->addWidget( aMarkerLab, 2, 0 ); + topLayout->addWidget( myMarkerSpin, 2, 1 ); QHBoxLayout* bgLayout = new QHBoxLayout; bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch(); - topLayout->addWidget( aBGLab, 2, 2 ); - topLayout->addLayout( bgLayout, 2, 3 ); - topLayout->addMultiCellWidget( aScaleGrp, 3, 3, 0, 3 ); - topLayout->addMultiCellWidget( aTabWidget, 4, 4, 0, 3 ); - topLayout->addMultiCellWidget( myDefCheck, 5, 5, 0, 3 ); + topLayout->addWidget( aBGLab, 2, 2 ); + topLayout->addLayout( bgLayout, 2, 3 ); + topLayout->addWidget( aScaleGrp, 3, 0, 1, 4 ); + topLayout->addWidget( aTabWidget, 4, 0, 1, 4 ); + topLayout->addWidget( myDefCheck, 5, 0, 1, 4 ); topLayout->setRowStretch( 5, 5 ); - topLayout->addMultiCellLayout( btnLayout, 6, 6, 0, 3 ); + topLayout->addLayout( btnLayout, 6, 0, 1, 4 ); if ( !showDefCheck ) myDefCheck->hide(); @@ -423,14 +446,14 @@ QString Plot2d_SetupViewDlg::getY2Title() */ void Plot2d_SetupViewDlg::setCurveType( const int type ) { - myCurveCombo->setCurrentItem( type ); + myCurveCombo->setCurrentIndex( type ); } /*! Gets curve type : 0 - points, 1 - lines, 2 - splines */ int Plot2d_SetupViewDlg::getCurveType() { - return myCurveCombo->currentItem(); + return myCurveCombo->currentIndex(); } /*! Sets legend attributes : pos = 0 - left, 1 - right, 2 - top, 3 - bottom @@ -438,7 +461,7 @@ int Plot2d_SetupViewDlg::getCurveType() void Plot2d_SetupViewDlg::setLegend( bool enable, int pos ) { myLegendCheck->setChecked( enable ); - myLegendCombo->setCurrentItem( pos ); + myLegendCombo->setCurrentIndex( pos ); onLegendChecked(); } /*! @@ -453,7 +476,7 @@ bool Plot2d_SetupViewDlg::isLegendEnabled() */ int Plot2d_SetupViewDlg::getLegendPos() { - return myLegendCombo->currentItem(); + return myLegendCombo->currentIndex(); } /*! Sets marker size @@ -475,12 +498,9 @@ int Plot2d_SetupViewDlg::getMarkerSize() void Plot2d_SetupViewDlg::setBackgroundColor( const QColor& color ) { QPalette pal = myBackgroundBtn->palette(); - QColorGroup ca = pal.active(); - ca.setColor( QColorGroup::Button, color ); - QColorGroup ci = pal.inactive(); - ci.setColor( QColorGroup::Button, color ); - pal.setActive( ca ); - pal.setInactive( ci ); + pal.setColor( QPalette::Active, QPalette::Button, color ); + pal.setColor( QPalette::Inactive, QPalette::Button, color ); + myBackgroundBtn->setPalette( pal ); } /*! @@ -488,7 +508,7 @@ void Plot2d_SetupViewDlg::setBackgroundColor( const QColor& color ) */ QColor Plot2d_SetupViewDlg::getBackgroundColor() { - return myBackgroundBtn->palette().active().button(); + return myBackgroundBtn->palette().color( QPalette::Active, QPalette::Button ); } /*! Sets major grid parameters @@ -573,22 +593,22 @@ void Plot2d_SetupViewDlg::getMinorGrid( bool& enableX, int& divX, */ void Plot2d_SetupViewDlg::setScaleMode( const int xMode, const int yMode ) { - myXModeCombo->setCurrentItem( xMode ); - myYModeCombo->setCurrentItem( yMode ); + myXModeCombo->setCurrentIndex( xMode ); + myYModeCombo->setCurrentIndex( yMode ); } /*! Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic */ int Plot2d_SetupViewDlg::getXScaleMode() { - return myXModeCombo->currentItem(); + return myXModeCombo->currentIndex(); } /*! Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic */ int Plot2d_SetupViewDlg::getYScaleMode() { - return myYModeCombo->currentItem(); + return myYModeCombo->currentIndex(); } /*! Slot, called when user clicks "Show main title" check box diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h index 37db3d641..862e9978a 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.h +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -20,7 +20,7 @@ #define PLOT2D_SETUPVIEWDLG_H #include "Plot2d.h" -#include +#include class QSpinBox; class QCheckBox; diff --git a/src/Plot2d/Plot2d_ToolTip.cxx b/src/Plot2d/Plot2d_ToolTip.cxx index 3cdb1ba8a..12e85eeea 100644 --- a/src/Plot2d/Plot2d_ToolTip.cxx +++ b/src/Plot2d/Plot2d_ToolTip.cxx @@ -23,7 +23,8 @@ #include #include -#include +#include +#include #include #include @@ -46,23 +47,26 @@ Plot2d_ToolTip::~Plot2d_ToolTip() void Plot2d_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect ) { - int curInd, pInd, dist; - double x, y; - curInd = myPlot->closestCurve( p.x(), p.y(), dist, x, y, pInd ); + int pInd;//, dist; + double dist; + //double x, y; + //curInd = myPlot->closestCurve( p.x(), p.y(), dist, x, y, pInd ); - if( dist>maxDist ) - return; + //if( dist>maxDist ) + // return; - Plot2d_Curve* c = myFrame->getCurves().find( curInd ); - if( !c ) + //Plot2d_Curve* c = myFrame->getCurves().find( curInd ); + + Plot2d_Curve* c = myPlot->getClosestCurve( p, dist, pInd ); + if( dist>maxDist || !c ) return; str = c->text( pInd ); - if( !str ) + if( str.isEmpty() ) return; QFontMetrics m( f ); - QStringList lst = QStringList::split( "\n", str ); + QStringList lst = str.split( "\n", QString::SkipEmptyParts ); QStringList::const_iterator anIt = lst.begin(), aLast = lst.end(); int w = 0, h = 0; for( ; anIt!=aLast; anIt++ ) @@ -85,8 +89,8 @@ bool Plot2d_ToolTip::eventFilter( QObject* o, QEvent* e ) bool res = QtxToolTip::eventFilter( o, e ); if( e && e->type() == QEvent::MouseMove ) { - QMouseEvent* me = ( QMouseEvent* )e; - if( me->state()==0 ) + ///QMouseEvent* me = ( QMouseEvent* )e; + ///if( me->state()==0 ) return true; } return res; diff --git a/src/Plot2d/Plot2d_ToolTip.h b/src/Plot2d/Plot2d_ToolTip.h index a26c46a83..c2f2d785f 100644 --- a/src/Plot2d/Plot2d_ToolTip.h +++ b/src/Plot2d/Plot2d_ToolTip.h @@ -36,12 +36,11 @@ public: Plot2d_ToolTip( Plot2d_ViewFrame*, Plot2d_Plot2d* ); virtual ~Plot2d_ToolTip(); + virtual bool eventFilter( QObject*, QEvent* ); + public slots: void onToolTip( QPoint, QString&, QFont&, QRect&, QRect& ); -protected: - virtual bool eventFilter( QObject*, QEvent* ); - private: Plot2d_ViewFrame* myFrame; Plot2d_Plot2d* myPlot; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index b68a44439..fb138e2fc 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -31,20 +31,28 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Application.h" -#include "qapplication.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include + #include #include #include @@ -138,13 +146,13 @@ const char* imageCrossCursor[] = { Constructor */ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) - : QWidget (parent, title, 0), + : QWidget (parent, 0), myOperation( NoOpId ), myCurveType( 1 ), myShowLegend( true ), myLegendPos( 1 ), myMarkerSize( DEFAULT_MARKER_SIZE ), myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ), - myBackground( white ), + myBackground( Qt::white ), myTitleEnabled( true ), myXTitleEnabled( true ), myYTitleEnabled( true ), myY2TitleEnabled (true), myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ), @@ -153,6 +161,7 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ), myXMode( 0 ), myYMode( 0 ), mySecondY( false ) { + setObjectName( title ); /* Plot 2d View */ QVBoxLayout* aLayout = new QVBoxLayout( this ); myPlot = new Plot2d_Plot2d( this ); @@ -168,6 +177,7 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) this, SLOT( plotMousePressed( const QMouseEvent& ) ) ); connect( myPlot, SIGNAL( plotMouseReleased( const QMouseEvent& ) ), this, SLOT( plotMouseReleased( const QMouseEvent& ) ) ); + //connect( myPlot, SIGNAL( legendClicked( long ) ), // this, SLOT( onLegendClicked( long ) ) ); @@ -196,14 +206,14 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) if ( parent ) { resize( (int)(0.8 * parent->width()), (int)(0.8 * parent->height()) ); } - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); - myXDistance = xMap.d2() - xMap.d1(); - myYDistance = yMap.d2() - yMap.d1(); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + myXDistance = xMap.p2() - xMap.p1(); + myYDistance = yMap.p2() - yMap.p1(); myYDistance2 = 0; if (mySecondY) { - QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); - myYDistance2 = yMap2.d2() - yMap2.d1(); + QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + myYDistance2 = yMap2.p2() - yMap2.p1(); } } /*! @@ -224,7 +234,7 @@ QWidget* Plot2d_ViewFrame::getViewWidget() */ void Plot2d_ViewFrame::DisplayAll() { - QList clist; + QList clist; getCurves( clist ); for ( int i = 0; i < (int)clist.count(); i++ ) { updateCurve( clist.at( i ), false ); @@ -237,7 +247,7 @@ void Plot2d_ViewFrame::DisplayAll() void Plot2d_ViewFrame::EraseAll() { myPlot->clear(); - myCurves.clear(); + myPlot->getCurves().clear(); myPlot->replot(); } /*! @@ -332,10 +342,10 @@ void Plot2d_ViewFrame::readPreferences() myY2GridMaxMinor = resMgr->integerValue( "Plot2d", "VerMinorGridMax", myY2GridMaxMinor ); myXMode = resMgr->integerValue( "Plot2d", "HorScaleMode", myXMode ); - myXMode = QMAX( 0, QMIN( 1, myXMode ) ); + myXMode = qMax( 0, qMin( 1, myXMode ) ); myYMode = resMgr->integerValue( "Plot2d", "VerScaleMode", myYMode ); - myYMode = QMAX( 0, QMIN( 1, myYMode ) ); + myYMode = qMax( 0, qMin( 1, myYMode ) ); } /*! @@ -386,11 +396,13 @@ void Plot2d_ViewFrame::writePreferences() QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) { int i; + QwtValueList aTicks; bool xFound = false, yFound = false; double xCoord, yCoord; - const QwtScaleDiv* aXscale = myPlot->axisScale( QwtPlot::xBottom ); - for ( i = 0; i < aXscale->majCnt(); i++ ) { - double majXmark = aXscale->majMark( i ); + const QwtScaleDiv* aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom ); + aTicks = aXscale->ticks( QwtScaleDiv::MajorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double majXmark = aTicks[i]; int xmark = myPlot->transform( QwtPlot::xBottom, majXmark ); if ( xmark-2 == pnt.x() ) { xCoord = majXmark; @@ -399,8 +411,9 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } if ( !xFound ) { - for ( i = 0; i < aXscale->minCnt(); i++ ) { - double minXmark = aXscale->minMark( i ); + aTicks = aXscale->ticks( QwtScaleDiv::MinorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double minXmark = aTicks[i]; int xmark = myPlot->transform( QwtPlot::xBottom, minXmark ); if ( xmark-2 == pnt.x() ) { xCoord = minXmark; @@ -409,9 +422,10 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } } - const QwtScaleDiv* aYscale = myPlot->axisScale( QwtPlot::yLeft ); - for ( i = 0; i < aYscale->majCnt(); i++ ) { - double majYmark = aYscale->majMark( i ); + const QwtScaleDiv* aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft ); + aTicks = aYscale->ticks( QwtScaleDiv::MajorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double majYmark = aTicks[i]; int ymark = myPlot->transform( QwtPlot::yLeft, majYmark ); if ( ymark-2 == pnt.y() ) { yCoord = majYmark; @@ -420,8 +434,9 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } if ( !yFound ) { - for ( i = 0; i < aYscale->minCnt(); i++ ) { - double minYmark = aYscale->minMark( i ); + aTicks = aYscale->ticks( QwtScaleDiv::MinorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double minYmark = aTicks[i]; int ymark = myPlot->transform( QwtPlot::yLeft, minYmark ); if ( ymark-2 == pnt.y() ) { yCoord = minYmark; @@ -431,10 +446,10 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } - QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).stripWhiteSpace(); + QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).trimmed(); if ( strX == "-0" ) strX = "0"; - QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).stripWhiteSpace(); + QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).trimmed(); if ( strY == "-0" ) strY = "0"; QString info = ""; @@ -443,9 +458,10 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) bool yFound2 = false; double yCoord2; - const QwtScaleDiv* aYscale2 = myPlot->axisScale( QwtPlot::yRight ); - for ( i = 0; i < aYscale2->majCnt(); i++ ) { - double majYmark = aYscale2->majMark( i ); + const QwtScaleDiv* aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight ); + aTicks = aYscale2->ticks( QwtScaleDiv::MajorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double majYmark = aTicks[i]; int ymark = myPlot->transform( QwtPlot::yRight, majYmark ); if ( ymark-2 == pnt.y() ) { yCoord2 = majYmark; @@ -454,8 +470,9 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } if ( !yFound2 ) { - for ( i = 0; i < aYscale2->minCnt(); i++ ) { - double minYmark = aYscale2->minMark( i ); + aTicks = aYscale2->ticks( QwtScaleDiv::MinorTick ); + for ( i = 0; i < aTicks.count(); i++ ) { + double minYmark = aTicks[i]; int ymark = myPlot->transform( QwtPlot::yRight, minYmark ); if ( ymark-2 == pnt.y() ) { yCoord2 = minYmark; @@ -465,7 +482,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) } } QString strY2 = QString::number( yFound2 ? yCoord2 : - myPlot->invTransform( QwtPlot::yRight, pnt.y() ) ).stripWhiteSpace(); + myPlot->invTransform( QwtPlot::yRight, pnt.y() ) ).trimmed(); if ( strY2 == "-0" ) strY2 = "0"; info = tr("INF_COORDINATES_SOME_Y").arg( strX ).arg( strY ).arg( strY2 ); @@ -481,7 +498,7 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) */ static QwtSymbol::Style plot2qwtMarker( Plot2d_Curve::MarkerType m ) { - QwtSymbol::Style ms = QwtSymbol::None; + QwtSymbol::Style ms = QwtSymbol::NoSymbol; switch ( m ) { case Plot2d_Curve::Circle: ms = QwtSymbol::Ellipse; break; @@ -503,7 +520,7 @@ static QwtSymbol::Style plot2qwtMarker( Plot2d_Curve::MarkerType m ) ms = QwtSymbol::XCross; break; case Plot2d_Curve::None: default: - ms = QwtSymbol::None; break; + ms = QwtSymbol::NoSymbol; break; } return ms; } @@ -513,7 +530,7 @@ static QwtSymbol::Style plot2qwtMarker( Plot2d_Curve::MarkerType m ) */ static Plot2d_Curve::MarkerType qwt2plotMarker( QwtSymbol::Style m ) { - Plot2d_Curve::MarkerType ms = Plot2d_Curve::None; + Plot2d_Curve::MarkerType ms = Plot2d_Curve::None; switch ( m ) { case QwtSymbol::Ellipse: ms = Plot2d_Curve::Circle; break; @@ -533,9 +550,9 @@ static Plot2d_Curve::MarkerType qwt2plotMarker( QwtSymbol::Style m ) ms = Plot2d_Curve::Cross; break; case QwtSymbol::XCross: ms = Plot2d_Curve::XCross; break; - case QwtSymbol::None: + case QwtSymbol::NoSymbol: default: - ms = Plot2d_Curve::None; break; + ms = Plot2d_Curve::None; break; } return ms; } @@ -604,24 +621,33 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) if ( myYMode && curve->getMinY() <= 0. ) setVerScaleMode( 0, false ); - if ( hasCurve( curve ) ) { + if ( hasPlotCurve( curve ) ) { updateCurve( curve, update ); } else { - long curveKey = myPlot->insertCurve( curve->getVerTitle() ); - myPlot->setCurveYAxis(curveKey, curve->getYAxis()); + QwtPlotCurve* aPCurve = new QwtPlotCurve( curve->getVerTitle() ); + aPCurve->attach( myPlot ); + //long curveKey = myPlot->insertCurve( curve->getVerTitle() ); + //myPlot->setCurveYAxis(curveKey, curve->getYAxis()); - myCurves.insert( curveKey, curve ); + //myCurves.insert( curveKey, curve ); + myPlot->getCurves().insert( aPCurve, curve ); if ( curve->isAutoAssign() ) { QwtSymbol::Style typeMarker; QColor color; Qt::PenStyle typeLine; + myPlot->getNextMarker( typeMarker, color, typeLine ); - myPlot->setCurvePen( curveKey, QPen( color, DEFAULT_LINE_WIDTH, typeLine ) ); - myPlot->setCurveSymbol( curveKey, QwtSymbol( typeMarker, + aPCurve->setPen( QPen( color, DEFAULT_LINE_WIDTH, typeLine ) ); + //myPlot->setCurvePen( curveKey, QPen( color, DEFAULT_LINE_WIDTH, typeLine ) ); + aPCurve->setSymbol( QwtSymbol( typeMarker, QBrush( color ), QPen( color ), QSize( myMarkerSize, myMarkerSize ) ) ); + //myPlot->setCurveSymbol( curveKey, QwtSymbol( typeMarker, + // QBrush( color ), + // QPen( color ), + // QSize( myMarkerSize, myMarkerSize ) ) ); curve->setColor( color ); curve->setLine( qwt2plotLine( typeLine ) ); curve->setMarker( qwt2plotMarker( typeMarker ) ); @@ -629,19 +655,28 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) else { Qt::PenStyle ps = plot2qwtLine( curve->getLine() ); QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() ); - myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); - myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + aPCurve->setPen( QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + //myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + aPCurve->setSymbol( QwtSymbol( ms, QBrush( curve->getColor() ), QPen( curve->getColor() ), QSize( myMarkerSize, myMarkerSize ) ) ); + //myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + // QBrush( curve->getColor() ), + // QPen( curve->getColor() ), + // QSize( myMarkerSize, myMarkerSize ) ) ); } if ( myCurveType == 0 ) - myPlot->setCurveStyle( curveKey, QwtCurve::NoCurve ); + aPCurve->setStyle( QwtPlotCurve::NoCurve ); + //myPlot->setCurveStyle( curveKey, QwtCurve::NoCurve ); else if ( myCurveType == 1 ) - myPlot->setCurveStyle( curveKey, QwtCurve::Lines ); + aPCurve->setStyle( QwtPlotCurve::Lines ); + //myPlot->setCurveStyle( curveKey, QwtCurve::Lines ); else if ( myCurveType == 2 ) - myPlot->setCurveStyle( curveKey, QwtCurve::Spline ); - myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() ); + aPCurve->setStyle( QwtPlotCurve::Dots ); + //myPlot->setCurveStyle( curveKey, QwtCurve::Spline ); + aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() ); + //myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() ); } updateTitles(); if ( update ) @@ -654,11 +689,11 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) void Plot2d_ViewFrame::displayCurves( const curveList& curves, bool update ) { myPlot->setUpdatesEnabled( false ); - QPtrListIterator it(curves); + QList::const_iterator it = curves.begin(); Plot2d_Curve* aCurve; - while( (aCurve = it.current()) ) { + for (; it != curves.end(); ++it ) { + aCurve = *it; displayCurve( aCurve, false ); - ++it; } fitAll(); @@ -674,10 +709,15 @@ void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update ) { if ( !curve ) return; - int curveKey = hasCurve( curve ); - if ( curveKey ) { - myPlot->removeCurve( curveKey ); - myCurves.remove( curveKey ); + if ( hasPlotCurve( curve ) ) { + QwtPlotCurve* aPCurve = getPlotCurve( curve ); + aPCurve->hide(); + aPCurve->detach(); + //int curveKey = hasCurve( curve ); + //if ( curveKey ) { + //myPlot->removeCurve( curveKey ); + //myCurves.remove( curveKey ); + myPlot->getCurves().remove( aPCurve ); updateTitles(); if ( update ) myPlot->replot(); @@ -689,11 +729,11 @@ void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update ) */ void Plot2d_ViewFrame::eraseCurves( const curveList& curves, bool update ) { - QPtrListIterator it(curves); + QList::const_iterator it = curves.begin(); Plot2d_Curve* aCurve; - while( (aCurve = it.current()) ) { + for (; it != curves.end(); ++it ) { + aCurve = *it; eraseCurve( aCurve, false ); - ++it; } // fitAll(); if ( update ) @@ -707,20 +747,30 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) { if ( !curve ) return; - int curveKey = hasCurve( curve ); - if ( curveKey ) { + //int curveKey = hasCurve( curve ); + //if ( curveKey ) { + if ( hasPlotCurve( curve ) ) { + QwtPlotCurve* aPCurve = getPlotCurve( curve ); if ( !curve->isAutoAssign() ) { Qt::PenStyle ps = plot2qwtLine( curve->getLine() ); QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() ); - myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); - myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + aPCurve->setPen ( QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + //myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + aPCurve->setSymbol( QwtSymbol( ms, QBrush( curve->getColor() ), QPen( curve->getColor() ), QSize( myMarkerSize, myMarkerSize ) ) ); - myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() ); + //myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + // QBrush( curve->getColor() ), + // QPen( curve->getColor() ), + // QSize( myMarkerSize, myMarkerSize ) ) ); + aPCurve->setData( curve->horData(), curve->verData(), curve->nbPoints() ); + //myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() ); } - myPlot->setCurveTitle( curveKey, curve->getVerTitle() ); - myPlot->curve( curveKey )->setEnabled( true ); + aPCurve->setTitle( curve->getVerTitle() ); + //myPlot->setCurveTitle( curveKey, curve->getVerTitle() ); + aPCurve->setVisible( true ); + //myPlot->curve( curveKey )->setEnabled( true ); if ( update ) myPlot->replot(); } @@ -729,7 +779,7 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) /*! Returns curve key if is is displayed in the viewer and 0 otherwise */ -int Plot2d_ViewFrame::hasCurve( Plot2d_Curve* curve ) +/*int Plot2d_ViewFrame::hasCurve( Plot2d_Curve* curve ) { QIntDictIterator it( myCurves ); for ( ; it.current(); ++it ) { @@ -738,30 +788,42 @@ int Plot2d_ViewFrame::hasCurve( Plot2d_Curve* curve ) } return 0; } - +*/ /*! Gets lsit of displayed curves */ -int Plot2d_ViewFrame::getCurves( QList& clist ) +int Plot2d_ViewFrame::getCurves( curveList& clist ) { clist.clear(); - clist.setAutoDelete( false ); - QIntDictIterator it( myCurves ); - for ( ; it.current(); ++it ) { - clist.append( it.current() ); - } + //clist.setAutoDelete( false ); + + CurveDict::iterator it = myPlot->getCurves().begin(); + for ( ; it != myPlot->getCurves().end(); it++ ) + clist.append( it.value() ); + //QIntDictIterator it( myCurves ); + //for ( ; it.current(); ++it ) { + // clist.append( it.current() ); + //} return clist.count(); } +const CurveDict& Plot2d_ViewFrame::getCurves() +{ + return myPlot->getCurves(); +} + /*! Returns true if the curve is visible */ bool Plot2d_ViewFrame::isVisible( Plot2d_Curve* curve ) { if(curve) { - int key = hasCurve( curve ); - if ( key ) - return myPlot->curve( key )->enabled(); + if ( hasPlotCurve( curve ) ) { + return getPlotCurve( curve )->isVisible(); + } + //int key = hasCurve( curve ); + //if ( key ) + // return myPlot->curve( key )->enabled(); } return false; } @@ -775,13 +837,15 @@ void Plot2d_ViewFrame::updateLegend( const Plot2d_Prs* prs ) return; curveList aCurves = prs->getCurves(); - QPtrListIterator it(aCurves); + QList::iterator it = aCurves.begin(); Plot2d_Curve* aCurve; - while( (aCurve = it.current()) ) { - int curveKey = hasCurve( aCurve ); - if ( curveKey ) - myPlot->setCurveTitle( curveKey, aCurve->getVerTitle() ); - ++it; + for (; it != aCurves.end(); ++it ) { + aCurve = *it; + if ( hasPlotCurve( aCurve ) ) + getPlotCurve( aCurve )->setTitle( aCurve->getVerTitle() ); + //int curveKey = hasCurve( aCurve ); + //if ( curveKey ) + // myPlot->setCurveTitle( curveKey, aCurve->getVerTitle() ); } } @@ -793,34 +857,32 @@ void Plot2d_ViewFrame::fitAll() // Postpone fitAll operation until QwtPlot geometry // has been fully defined if ( !myPlot->polished() ){ - QApplication::postEvent( this, new QCustomEvent( FITALL_EVENT ) ); + QApplication::postEvent( this, new QEvent( (QEvent::Type)FITALL_EVENT ) ); return; } - QwtDiMap xMap1 = myPlot->canvasMap( QwtPlot::xBottom ); - myPlot->setAxisAutoScale( QwtPlot::yLeft ); myPlot->setAxisAutoScale( QwtPlot::xBottom ); myPlot->replot(); // for existing grid - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2() ) ); + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p1() ) ), + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p2() ) ) ); myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2() ) ); + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p1() ) ), + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p2() ) ) ); if (mySecondY) { myPlot->setAxisAutoScale( QwtPlot::yRight ); myPlot->replot(); - QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, yMap2.i1() ), - myPlot->invTransform( QwtPlot::yRight, yMap2.i2() ) ); + myPlot->invTransform( QwtPlot::yRight, yMap2.transform( yMap2.p1() ) ), + myPlot->invTransform( QwtPlot::yRight, yMap2.transform( yMap2.p2() ) ) ); } myPlot->replot(); } @@ -830,7 +892,7 @@ void Plot2d_ViewFrame::fitAll() */ void Plot2d_ViewFrame::fitArea( const QRect& area ) { - QRect rect = area.normalize(); + QRect rect = area.normalized(); if ( rect.width() < MIN_RECT_SIZE ) { rect.setWidth( MIN_RECT_SIZE ); rect.setLeft( rect.left() - MIN_RECT_SIZE/2 ); @@ -877,10 +939,15 @@ void Plot2d_ViewFrame::getFitRanges(double& xMin,double& xMax, double& yMin, double& yMax, double& y2Min, double& y2Max) { - int ixMin = myPlot->canvasMap( QwtPlot::xBottom ).i1(); - int ixMax = myPlot->canvasMap( QwtPlot::xBottom ).i2(); - int iyMin = myPlot->canvasMap( QwtPlot::yLeft ).i1(); - int iyMax = myPlot->canvasMap( QwtPlot::yLeft ).i2(); + double aP1 = myPlot->canvasMap( QwtPlot::xBottom ).p1(); + double aP2 = myPlot->canvasMap( QwtPlot::xBottom ).p2(); + double aS1 = myPlot->canvasMap( QwtPlot::xBottom ).s1(); + double aS2 = myPlot->canvasMap( QwtPlot::xBottom ).s2(); + + int ixMin = myPlot->canvasMap( QwtPlot::xBottom ).transform( myPlot->canvasMap( QwtPlot::xBottom ).p1() ); + int ixMax = myPlot->canvasMap( QwtPlot::xBottom ).transform( myPlot->canvasMap( QwtPlot::xBottom ).p2() ); + int iyMin = myPlot->canvasMap( QwtPlot::yLeft ).transform( myPlot->canvasMap( QwtPlot::yLeft ).p1() ); + int iyMax = myPlot->canvasMap( QwtPlot::yLeft ).transform( myPlot->canvasMap( QwtPlot::yLeft ).p2() ); xMin = myPlot->invTransform(QwtPlot::xBottom, ixMin); xMax = myPlot->invTransform(QwtPlot::xBottom, ixMax); yMin = myPlot->invTransform(QwtPlot::yLeft, iyMin); @@ -888,8 +955,8 @@ void Plot2d_ViewFrame::getFitRanges(double& xMin,double& xMax, y2Min = 0; y2Max = 0; if (mySecondY) { - int iyMin = myPlot->canvasMap( QwtPlot::yRight ).i1(); - int iyMax = myPlot->canvasMap( QwtPlot::yRight ).i2(); + int iyMin = myPlot->canvasMap( QwtPlot::yRight ).transform( myPlot->canvasMap( QwtPlot::yRight ).p1() ); + int iyMax = myPlot->canvasMap( QwtPlot::yRight ).transform( myPlot->canvasMap( QwtPlot::yRight ).p2() ); y2Min = myPlot->invTransform(QwtPlot::yRight, iyMin); y2Max = myPlot->invTransform(QwtPlot::yRight, iyMax); } @@ -900,10 +967,10 @@ void Plot2d_ViewFrame::getFitRanges(double& xMin,double& xMax, */ int Plot2d_ViewFrame::testOperation( const QMouseEvent& me ) { - int btn = me.button() | me.state(); - const int zoomBtn = ControlButton | LeftButton; - const int panBtn = ControlButton | MidButton; - const int fitBtn = ControlButton | RightButton; + int btn = me.buttons(); // | me.state(); + const int zoomBtn = Qt::ControlModifier | Qt::LeftButton; + const int panBtn = Qt::ControlModifier | Qt::MidButton; + const int fitBtn = Qt::ControlModifier | Qt::RightButton; switch (btn) { @@ -1077,7 +1144,20 @@ void Plot2d_ViewFrame::onChangeBackground() void Plot2d_ViewFrame::setCurveType( int curveType, bool update ) { myCurveType = curveType; - QArray keys = myPlot->curveKeys(); + CurveDict::iterator it = myPlot->getCurves().begin(); + for ( ; it != myPlot->getCurves().end(); it++ ) { + QwtPlotCurve* crv = it.key(); + if ( crv ) { + if ( myCurveType == 0 ) + crv->setStyle( QwtPlotCurve::Dots );//QwtCurve::NoCurve + else if ( myCurveType == 1 ) + crv->setStyle( QwtPlotCurve::Lines ); + else if ( myCurveType == 2 ) + crv->setStyle( QwtPlotCurve::Dots );//Spline ); + } + } + /* + //QArray keys = myPlot->curveKeys(); for ( int i = 0; i < (int)keys.count(); i++ ) { if ( myCurveType == 0 ) myPlot->setCurveStyle( keys[i], QwtCurve::Dots );//QwtCurve::NoCurve @@ -1086,6 +1166,7 @@ void Plot2d_ViewFrame::setCurveType( int curveType, bool update ) else if ( myCurveType == 2 ) myPlot->setCurveStyle( keys[i], QwtCurve::Spline ); } + */ if ( update ) myPlot->replot(); emit vpCurveChanged(); @@ -1096,9 +1177,11 @@ void Plot2d_ViewFrame::setCurveType( int curveType, bool update ) \param curveKey - curve id \param title - new title */ -void Plot2d_ViewFrame::setCurveTitle( int curveKey, const QString& title ) +void Plot2d_ViewFrame::setCurveTitle( Plot2d_Curve* curve, const QString& title ) { - if(myPlot) myPlot->setCurveTitle(curveKey, title); + if ( curve && hasPlotCurve( curve ) ) + getPlotCurve( curve )->setTitle( title ); + //if(myPlot) myPlot->setCurveTitle(curveKey, title); } /*! @@ -1107,8 +1190,17 @@ void Plot2d_ViewFrame::setCurveTitle( int curveKey, const QString& title ) void Plot2d_ViewFrame::showLegend( bool show, bool update ) { myShowLegend = show; - myPlot->setAutoLegend( myShowLegend ); - myPlot->enableLegend( myShowLegend ); + if ( myShowLegend ) { + QwtLegend* legend = myPlot->legend(); + if ( !legend ) + legend = new QwtLegend(); + myPlot->insertLegend( legend ); + setLegendPos( myLegendPos ); + } + else + myPlot->insertLegend( 0 ); + //myPlot->setAutoLegend( myShowLegend ); + //myPlot->enableLegend( myShowLegend ); if ( update ) myPlot->replot(); } @@ -1119,18 +1211,19 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update ) void Plot2d_ViewFrame::setLegendPos( int pos ) { myLegendPos = pos; + QwtLegend* legend = myPlot->legend(); switch( pos ) { case 0: - myPlot->setLegendPos( Qwt::Left ); + myPlot->insertLegend( legend, QwtPlot::LeftLegend ); break; case 1: - myPlot->setLegendPos( Qwt::Right ); + myPlot->insertLegend( legend, QwtPlot::RightLegend ); break; case 2: - myPlot->setLegendPos( Qwt::Top ); + myPlot->insertLegend( legend, QwtPlot::TopLegend ); break; case 3: - myPlot->setLegendPos( Qwt::Bottom ); + myPlot->insertLegend( legend, QwtPlot::BottomLegend ); break; } } @@ -1143,6 +1236,17 @@ void Plot2d_ViewFrame::setMarkerSize( const int size, bool update ) if ( myMarkerSize != size ) { myMarkerSize = size; + CurveDict::iterator it = myPlot->getCurves().begin(); + for ( ; it != myPlot->getCurves().end(); it++ ) { + QwtPlotCurve* crv = it.key(); + if ( crv ) + { + QwtSymbol aSymbol = crv->symbol(); + aSymbol.setSize( myMarkerSize, myMarkerSize ); + crv->setSymbol( aSymbol ); + } + } + /* QArray keys = myPlot->curveKeys(); for ( int i = 0; i < (int)keys.count(); i++ ) { @@ -1154,6 +1258,7 @@ void Plot2d_ViewFrame::setMarkerSize( const int size, bool update ) myPlot->setCurveSymbol( keys[i], aSymbol ); } } + */ if ( update ) myPlot->replot(); } @@ -1168,13 +1273,14 @@ void Plot2d_ViewFrame::setBackgroundColor( const QColor& color ) //myPlot->setCanvasBackground( myBackground ); myPlot->canvas()->setPalette( myBackground ); myPlot->setPalette( myBackground ); - QPalette aPal = myPlot->getLegend()->palette(); - for ( int i = 0; i < QPalette::NColorGroups; i++ ) { - QPalette::ColorGroup cg = (QPalette::ColorGroup)i; - aPal.setColor( cg, QColorGroup::Base, myBackground ); - aPal.setColor( cg, QColorGroup::Background, myBackground ); + if ( myPlot->getLegend() ) { + QPalette aPal = myPlot->getLegend()->palette(); + for ( int i = 0; i < QPalette::NColorGroups; i++ ) { + aPal.setColor( QPalette::Base, myBackground ); + aPal.setColor( QPalette::Background, myBackground ); + } + myPlot->getLegend()->setPalette( aPal ); } - myPlot->getLegend()->setPalette( aPal ); Repaint(); } /*! @@ -1195,11 +1301,16 @@ void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax, myXGridMinorEnabled = xMinorEnabled; myXGridMaxMajor = xMajorMax; myXGridMaxMinor = xMinorMax; + myPlot->setAxisMaxMajor( QwtPlot::xBottom, myXGridMaxMajor ); myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor ); - myPlot->setGridXAxis(QwtPlot::xBottom); - myPlot->enableGridX( myXGridMajorEnabled ); - myPlot->enableGridXMin( myXGridMinorEnabled ); + + QwtPlotGrid* grid = myPlot->grid(); + if ( myPlot->axisScaleDiv( QwtPlot::xBottom ) ) + grid->setXDiv( *myPlot->axisScaleDiv( QwtPlot::xBottom ) ); + grid->enableX( myXGridMajorEnabled ); + grid->enableXMin( myXGridMinorEnabled ); + if ( update ) myPlot->replot(); } @@ -1231,26 +1342,30 @@ void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax, myPlot->setAxisMaxMinor( QwtPlot::yRight, myY2GridMaxMinor ); } - myPlot->setGridYAxis(QwtPlot::yLeft); + QwtPlotGrid* grid = myPlot->grid(); + if ( myPlot->axisScaleDiv( QwtPlot::yLeft ) ) + grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yLeft ) ); + ///myPlot->setGridYAxis(QwtPlot::yLeft); if (mySecondY) { if (myYGridMajorEnabled) { - myPlot->enableGridYMin(myYGridMinorEnabled); - myPlot->enableGridY( myYGridMajorEnabled); + grid->enableY( myYGridMajorEnabled ); + grid->enableYMin( myYGridMinorEnabled ); } else if (myY2GridMajorEnabled) { - myPlot->setGridYAxis(QwtPlot::yRight); - myPlot->enableGridYMin(myY2GridMinorEnabled); - myPlot->enableGridY(myY2GridMajorEnabled); + if ( myPlot->axisScaleDiv( QwtPlot::yRight ) ) + grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yRight ) ); + grid->enableY( myY2GridMajorEnabled ); + grid->enableYMin( myY2GridMinorEnabled ); } else { - myPlot->enableGridYMin(false); - myPlot->enableGridY(false); + grid->enableY( false ); + grid->enableYMin( false ); } } else { - myPlot->enableGridY( myYGridMajorEnabled ); - myPlot->enableGridYMin( myYGridMinorEnabled ); + grid->enableY( myYGridMajorEnabled ); + grid->enableYMin( myYGridMinorEnabled ); } if ( update ) myPlot->replot(); @@ -1312,20 +1427,24 @@ void Plot2d_ViewFrame::setFont( const QFont& font, ObjectType type, bool update) { switch (type) { case MainTitle: - myPlot->setTitleFont(font); + myPlot->title().setFont(font); + //myPlot->setTitleFont(font); break; case XTitle: - myPlot->setAxisTitleFont(QwtPlot::xBottom, font); break; + myPlot->axisTitle(QwtPlot::xBottom).setFont(font); break; + //myPlot->setAxisTitleFont(QwtPlot::xBottom, font); break; case YTitle: - myPlot->setAxisTitleFont(QwtPlot::yLeft, font); break; + myPlot->axisTitle(QwtPlot::yLeft).setFont(font); break; + //myPlot->setAxisTitleFont(QwtPlot::yLeft, font); break; case Y2Title: - myPlot->setAxisTitleFont(QwtPlot::yRight, font); break; + myPlot->axisTitle(QwtPlot::yRight).setFont(font); break; + //myPlot->setAxisTitleFont(QwtPlot::yRight, font); break; case XAxis: - myPlot->setAxisFont(QwtPlot::xBottom, font); break; + myPlot->setAxisFont(QwtPlot::xBottom, font); break; case YAxis: - myPlot->setAxisFont(QwtPlot::yLeft, font); break; + myPlot->setAxisFont(QwtPlot::yLeft, font); break; case Y2Axis: - myPlot->setAxisFont(QwtPlot::yRight, font); break; + myPlot->setAxisFont(QwtPlot::yRight, font); break; } if ( update ) myPlot->replot(); @@ -1345,7 +1464,8 @@ void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update ) myXMode = mode; - myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, myXMode != 0 ); + myPlot->setLogScale(QwtPlot::xBottom, myXMode != 0); + //myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, myXMode != 0 ); if ( update ) fitAll(); @@ -1365,9 +1485,11 @@ void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update ) } myYMode = mode; - myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, myYMode != 0 ); + myPlot->setLogScale(QwtPlot::yLeft, myXMode != 0); + //myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, myYMode != 0 ); if (mySecondY) - myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, myYMode != 0 ); + myPlot->setLogScale( QwtPlot::yRight, myXMode != 0 ); + //myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, myYMode != 0 ); if ( update ) fitAll(); @@ -1392,7 +1514,7 @@ bool Plot2d_ViewFrame::isModeVerLinear() /*! Slot, called when user presses mouse button */ -void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me ) +void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me ) { Plot2d_ViewWindow* aParent = dynamic_cast(parent()); if (aParent) @@ -1402,7 +1524,7 @@ void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me ) if ( myOperation != NoOpId ) { myPnt = me.pos(); if ( myOperation == FitAreaId ) { - myPlot->setOutlineStyle( Qwt::Rect ); + ///myPlot->setOutlineStyle( Qwt::Rect ); } else if ( myOperation == GlPanId ) { myPlot->setAxisScale( QwtPlot::yLeft, @@ -1419,10 +1541,10 @@ void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me ) } } else { - int btn = me.button() | me.state(); - if (btn == RightButton) { + int btn = me.buttons();// | me.state(); + if (btn == Qt::RightButton) { QMouseEvent* aEvent = new QMouseEvent(QEvent::MouseButtonPress, - me.pos(), btn, me.state()); + me.pos(), me.button(), me.buttons(), Qt::KeypadModifier );//state()); // QMouseEvent 'me' has the 'MouseButtonDblClick' type. In this case we create new event 'aEvent'. parent()->eventFilter(this, aEvent); } @@ -1432,6 +1554,7 @@ void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me ) /*! Slot, called when user moves mouse */ + void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me ) { int dx = me.pos().x() - myPnt.x(); @@ -1458,11 +1581,11 @@ void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me ) */ void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me ) { - if ( myOperation == NoOpId && me.button() == RightButton ) + if ( myOperation == NoOpId && me.button() == Qt::RightButton ) { QContextMenuEvent aEvent( QContextMenuEvent::Mouse, - me.pos(), me.globalPos(), - me.state() ); + me.pos(), me.globalPos() );//, + //me.buttons());//state() ); emit contextMenuRequested( &aEvent ); } if ( myOperation == FitAreaId ) { @@ -1470,7 +1593,7 @@ void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me ) fitArea( rect ); } myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) ); - myPlot->setOutlineStyle( Qwt::Triangle ); + ///myPlot->setOutlineStyle( Qwt::Triangle ); Plot2d_ViewWindow* aParent = dynamic_cast(parent()); if (aParent) @@ -1485,24 +1608,50 @@ void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event) double aDelta = event->delta(); double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.; - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2() )*aScale ); + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( xMap.p1() ) ), + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( xMap.p2() ) )*aScale ); myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2() )*aScale ); + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p1() ) ), + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p2() ) )*aScale ); if (mySecondY) { - QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); + QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), - myPlot->invTransform( QwtPlot::yRight, y2Map.i2() )*aScale ); + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p1() ) ), + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p2() ) )*aScale ); } myPlot->replot(); myPnt = event->pos(); } + +/*! + Returns qwt plot curve if it is existed in map of curves and 0 otherwise +*/ +QwtPlotCurve* Plot2d_ViewFrame::getPlotCurve( Plot2d_Curve* curve ) +{ + CurveDict::iterator it = myPlot->getCurves().begin(); + for ( ; it != myPlot->getCurves().end(); it++ ) { + if ( it.value() == curve ) + return it.key(); + } + return 0; +} +/*! + Returns true if qwt plot curve is existed in map of curves and false otherwise +*/ +bool Plot2d_ViewFrame::hasPlotCurve( Plot2d_Curve* curve ) +{ + CurveDict::iterator it = myPlot->getCurves().begin(); + for ( ; it != myPlot->getCurves().end(); it++ ) { + if ( it.value() == curve ) + return true; + } + return false; +} + /*! View operations : Pan view */ @@ -1548,20 +1697,23 @@ void Plot2d_ViewFrame::onViewGlobalPan() QPixmap globalPanPixmap (imageCrossCursor); QCursor glPanCursor (globalPanPixmap); myPlot->canvas()->setCursor( glPanCursor ); - myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false ); - myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false ); + myPlot->setLogScale(QwtPlot::xBottom, false); + myPlot->setLogScale(QwtPlot::yLeft, false); + //myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false ); + //myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false ); if (mySecondY) - myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, false ); + myPlot->setLogScale(QwtPlot::yRight, false); + //myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, false ); myPlot->replot(); - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); - myXDistance = xMap.d2() - xMap.d1(); - myYDistance = yMap.d2() - yMap.d1(); + myXDistance = xMap.p2() - xMap.p1(); + myYDistance = yMap.p2() - yMap.p1(); if (mySecondY) { - QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); - myYDistance2 = yMap2.d2() - yMap2.d1(); + QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + myYDistance2 = yMap2.p2() - yMap2.p1(); } fitAll(); myOperation = GlPanId; @@ -1574,10 +1726,13 @@ void Plot2d_ViewFrame::onViewGlobalPan() bool Plot2d_ViewFrame::isXLogEnabled() const { bool allPositive = true; - QIntDictIterator it( myCurves ); - for ( ; allPositive && it.current(); ++it ) { - allPositive = ( it.current()->getMinX() > 0. ); - } + CurveDict::const_iterator it = myPlot->getCurves().begin(); + for ( ; allPositive && it != myPlot->getCurves().end(); it++ ) + allPositive = ( it.value()->getMinX() > 0. ); + //QIntDictIterator it( myCurves ); + //for ( ; allPositive && it.current(); ++it ) { + // allPositive = ( it.current()->getMinX() > 0. ); + //} return allPositive; } @@ -1587,10 +1742,13 @@ bool Plot2d_ViewFrame::isXLogEnabled() const bool Plot2d_ViewFrame::isYLogEnabled() const { bool allPositive = true; - QIntDictIterator it( myCurves ); - for ( ; allPositive && it.current(); ++it ) { - allPositive = ( it.current()->getMinY() > 0. ); - } + CurveDict::const_iterator it = myPlot->getCurves().begin(); + for ( ; allPositive && it != myPlot->getCurves().end(); it++ ) + allPositive = ( it.value()->getMinY() > 0. ); + //QIntDictIterator it( myCurves ); + //for ( ; allPositive && it.current(); ++it ) { + // allPositive = ( it.current()->getMinY() > 0. ); + //} return allPositive; } @@ -1602,23 +1760,43 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent ) myIsPolished( false ) { // outline - enableOutline( true ); - setOutlineStyle( Qwt::Triangle ); - setOutlinePen( green ); + ///enableOutline( true ); + ///setOutlineStyle( Qwt::Triangle ); + ///setOutlinePen( green ); // legend - setAutoLegend( false ); - setLegendFrameStyle( QFrame::Box | QFrame::Sunken ); - enableLegend( false ); - // grid - enableGridX( false ); - enableGridXMin( false ); - enableGridY( false ); - enableGridYMin( false ); + ///setAutoLegend( false ); + ///setLegendFrameStyle( QFrame::Box | QFrame::Sunken ); + ///enableLegend( false ); + // auto scaling by default setAxisAutoScale( QwtPlot::yLeft ); setAxisAutoScale( QwtPlot::yRight ); setAxisAutoScale( QwtPlot::xBottom ); + // grid + myGrid = new QwtPlotGrid(); + QPen aMajPen = myGrid->majPen(); + aMajPen.setStyle( Qt::DashLine ); + myGrid->setPen( aMajPen ); + + myGrid->enableX( false ); + myGrid->enableXMin( false ); + myGrid->enableY( false ); + myGrid->enableYMin( false ); + + myGrid->attach( this ); } + +/*! + \set axis scale engine - linear or log10 +*/ +void Plot2d_Plot2d::setLogScale( int axisId, bool log10 ) +{ + if ( log10 ) + setAxisScaleEngine( axisId, new QwtLog10ScaleEngine() ); + else + setAxisScaleEngine( axisId, new QwtLinearScaleEngine() ); +} + /*! Recalculates and redraws Plot 2d view */ @@ -1728,6 +1906,27 @@ void Plot2d_Plot2d::getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, */ } +void Plot2d_Plot2d::mousePressEvent ( QMouseEvent * me ) +{ + QMouseEvent m( QEvent::MouseButtonPress, me->pos(), me->button(), me->buttons(), Qt::KeypadModifier );//state()); + emit plotMousePressed( m ); + QWidget::mousePressEvent( me ); +} + +void Plot2d_Plot2d::mouseMoveEvent( QMouseEvent* me ) +{ + QMouseEvent m( QEvent::MouseButtonPress, me->pos(), me->button(), me->buttons(), Qt::KeypadModifier );//state()); + emit plotMouseMoved( m ); + QWidget::mousePressEvent( me ); +} + +void Plot2d_Plot2d::mouseReleaseEvent( QMouseEvent* me ) +{ + QMouseEvent m( QEvent::MouseButtonPress, me->pos(), me->button(), me->buttons(), Qt::KeypadModifier );//state()); + emit plotMouseReleased( m ); + QWidget::mousePressEvent( me ); +} + /*! \return the default layout behavior of the widget */ @@ -1753,18 +1952,50 @@ QSize Plot2d_Plot2d::minimumSizeHint() const // QSize aSize = QwtPlot::minimumSizeHint(); // return QSize(aSize.width()*3/4, aSize.height()); } + +/*! + return closest curve if it exist, else 0 +*/ +Plot2d_Curve* Plot2d_Plot2d::getClosestCurve( QPoint p, double& distance, int& index ) +{ + CurveDict::iterator it = getCurves().begin(); + QwtPlotCurve* aCurve; + for ( ; it != getCurves().end(); it++ ) { + aCurve = it.key(); + if ( !aCurve ) + continue; + index = aCurve->closestPoint( p, &distance ); + if ( index > -1 ) + return it.value(); + } + return 0; +} + /*! Checks if marker belongs to any enitity */ bool Plot2d_Plot2d::existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ) { // getting all curves - QArray keys = curveKeys(); + ///QArray keys = curveKeys(); //QColor aRgbColor; - - if ( closeColors( color, backgroundColor() ) ) + QColor aColor = palette().color( QPalette::Background ); + if ( closeColors( color, aColor ) ) return true; - for ( int i = 0; i < (int)keys.count(); i++ ) + + CurveDict::iterator it = myCurves.begin(); + for ( ; it != myCurves.end(); it++ ) { + QwtPlotCurve* crv = it.key(); + if ( crv ) { + QwtSymbol::Style aStyle = crv->symbol().style(); + QColor aColor = crv->pen().color(); + Qt::PenStyle aLine = crv->pen().style(); +// if ( aStyle == typeMarker && aColor == color && aLine == typeLine ) + if ( aStyle == typeMarker && closeColors( aColor,color ) && aLine == typeLine ) + return true; + } + } + /*for ( int i = 0; i < (int)keys.count(); i++ ) { QwtPlotCurve* crv = curve( keys[i] ); if ( crv ) { @@ -1775,7 +2006,7 @@ bool Plot2d_Plot2d::existMarker( const QwtSymbol::Style typeMarker, const QColor if ( aStyle == typeMarker && closeColors( aColor,color ) && aLine == typeLine ) return true; } - } + }*/ return false; } @@ -1843,33 +2074,36 @@ void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf ) #define BRACKETIZE(x) QString( "[ " ) + x + QString( " ]" ) void Plot2d_ViewFrame::updateTitles() { - QIntDictIterator it( myCurves ); + CurveDict::iterator it = myPlot->getCurves().begin(); + //QIntDictIterator it( myCurves ); QStringList aXTitles; QStringList aYTitles; QStringList aXUnits; QStringList aYUnits; QStringList aTables; int i = 0; - while ( it.current() ) { + + Plot2d_Curve* aCurve; + for ( ; it != myPlot->getCurves().end(); it++ ) { + //while ( it.current() ) { // collect titles and units from all curves... - QString xTitle = it.current()->getHorTitle().stripWhiteSpace(); - QString yTitle = it.current()->getVerTitle().stripWhiteSpace(); - QString xUnits = it.current()->getHorUnits().stripWhiteSpace(); - QString yUnits = it.current()->getVerUnits().stripWhiteSpace(); + aCurve = it.value(); + QString xTitle = aCurve->getHorTitle().trimmed(); + QString yTitle = aCurve->getVerTitle().trimmed(); + QString xUnits = aCurve->getHorUnits().trimmed(); + QString yUnits = aCurve->getVerUnits().trimmed(); aYTitles.append( yTitle ); - if ( aXTitles.find( xTitle ) == aXTitles.end() ) + if ( !aXTitles.contains( xTitle ) )//aXTitles.find( xTitle ) == aXTitles.end() ) aXTitles.append( xTitle ); - if ( aXUnits.find( xUnits ) == aXUnits.end() ) + if ( !aXUnits.contains( xUnits ) )//aXUnits.find( xUnits ) == aXUnits.end() ) aXUnits.append( xUnits ); - if ( aYUnits.find( yUnits ) == aYUnits.end() ) + if ( !aYUnits.contains( yUnits ) )//aYUnits.find( yUnits ) == aYUnits.end() ) aYUnits.append( yUnits ); - QString aName = it.current()->getTableTitle(); - if( !aName.isEmpty() && aTables.find( aName ) == aTables.end() ) + QString aName = aCurve->getTableTitle(); + if( !aName.isEmpty() && !aTables.contains( aName ) )//aTables.find( aName ) == aTables.end() ) aTables.append( aName ); - - ++it; ++i; } // ... and update plot 2d view @@ -1913,7 +2147,7 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const { QPrinter* pr = new QPrinter( QPrinter::HighResolution ); pr->setPageSize( QPrinter::A4 ); - pr->setOutputToFile( true ); + ///pr->setOutputToFile( true ); pr->setOutputFileName( file ); pr->setPrintProgram( "" ); pd = pr; @@ -1948,7 +2182,8 @@ QString Plot2d_ViewFrame::getVisualParameters() */ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) { - QStringList paramsLst = QStringList::split( '*', parameters, true ); + QStringList paramsLst = parameters.split( '*' ); + //QStringList::split( '*', parameters, true ); if ( paramsLst.size() == 9 ) { double xmin, xmax, ymin, ymax, y2min, y2max; myXMode = paramsLst[0].toInt(); @@ -1967,8 +2202,8 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) setVerScaleMode( myYMode, /*update=*/false ); if (mySecondY) { - QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); - myYDistance2 = yMap2.d2() - yMap2.d1(); + QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight ); + myYDistance2 = yMap2.p2() - yMap2.p1(); } fitData( 0, xmin, xmax, ymin, ymax, y2min, y2max ); @@ -1980,20 +2215,20 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters ) Incremental zooming operation */ void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) { - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-incrY ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-incrY ) ); + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p1() )-incrY ), + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p2() )-incrY ) ); myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-incrX ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-incrX ) ); + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p1() )-incrX ), + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p2() )-incrX ) ); if (mySecondY) { - QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); + QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, y2Map.i1()-incrY ), - myPlot->invTransform( QwtPlot::yRight, y2Map.i2()-incrY ) ); + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p1() )-incrY ), + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p2() )-incrY ) ); } myPlot->replot(); } @@ -2002,20 +2237,20 @@ void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) { Incremental panning operation */ void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) { - QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); - QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), - myPlot->invTransform( QwtPlot::yLeft, yMap.i2() + incrY ) ); + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p1() ) ), + myPlot->invTransform( QwtPlot::yLeft, yMap.transform( yMap.p2() ) + incrY ) ); myPlot->setAxisScale( QwtPlot::xBottom, - myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), - myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - incrX ) ); + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p1() ) ), + myPlot->invTransform( QwtPlot::xBottom, xMap.transform( xMap.p2() ) - incrX ) ); if (mySecondY) { - QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); + QwtScaleMap y2Map = myPlot->canvasMap( QwtPlot::yRight ); myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), - myPlot->invTransform( QwtPlot::yRight, y2Map.i2() + incrY ) ); + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p1() ) ), + myPlot->invTransform( QwtPlot::yRight, y2Map.transform( y2Map.p2() ) + incrY ) ); } myPlot->replot(); } @@ -2075,7 +2310,7 @@ void Plot2d_ViewFrame::onZoomOut() event queue. This ensures that other important events (show, resize, etc.) are processed first. */ -void Plot2d_ViewFrame::customEvent( QCustomEvent* ce ) +void Plot2d_ViewFrame::customEvent( QEvent* ce ) { if ( ce->type() == FITALL_EVENT ) fitAll(); diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 108cbd957..f98cce1c8 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -20,14 +20,18 @@ #define PLOT2D_VIEWFRAME_H #include "Plot2d_Curve.h" -#include -#include +#include +#include +#include +#include class Plot2d_Plot2d; class Plot2d_Prs; class QCustomEvent; +class QwtPlotCurve; +class QwtPlotGrid; -typedef QIntDict CurveDict; +typedef QMultiHash CurveDict; class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget { @@ -64,8 +68,8 @@ public: void eraseCurve( Plot2d_Curve* curve, bool update = false ); void eraseCurves( const curveList& curves, bool update = false ); int getCurves( curveList& clist ); - const CurveDict& getCurves() { return myCurves; } - int hasCurve( Plot2d_Curve* curve ); + const CurveDict& getCurves();/// { return myPlot->getCurves(); } + //int hasCurve( Plot2d_Curve* curve ); bool isVisible( Plot2d_Curve* curve ); void updateCurve( Plot2d_Curve* curve, bool update = false ); void updateLegend( const Plot2d_Prs* prs ); @@ -84,7 +88,7 @@ public: void copyPreferences( Plot2d_ViewFrame* ); void setCurveType( int curveType, bool update = true ); int getCurveType() const { return myCurveType; } - void setCurveTitle( int curveKey, const QString& title ); + void setCurveTitle( Plot2d_Curve* curve, const QString& title ); void showLegend( bool show, bool update = true ); void setLegendPos( int pos ); int getLegendPos() const { return myLegendPos; } @@ -131,6 +135,8 @@ protected: void writePreferences(); QString getInfo( const QPoint& pnt ); virtual void wheelEvent( QWheelEvent* ); + QwtPlotCurve* getPlotCurve( Plot2d_Curve* curve ); + bool hasPlotCurve( Plot2d_Curve* curve ); public slots: void onViewPan(); @@ -150,7 +156,7 @@ public slots: void onZoomOut(); protected: - virtual void customEvent( QCustomEvent* ); + virtual void customEvent( QEvent* ); protected slots: void plotMousePressed( const QMouseEvent& ); @@ -167,7 +173,7 @@ protected: Plot2d_Plot2d* myPlot; int myOperation; QPoint myPnt; - CurveDict myCurves; + //CurveDict myCurves; int myCurveType; bool myShowLegend; @@ -191,6 +197,8 @@ class Plot2d_Plot2d : public QwtPlot public: Plot2d_Plot2d( QWidget* parent ); + void setLogScale( int axisId, bool log10 ); + void replot(); void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine ); QwtLegend* getLegend() { @@ -205,15 +213,28 @@ public: virtual QSize minimumSizeHint() const; bool polished() const { return myIsPolished; } + QwtPlotGrid* grid() { return myGrid; }; + CurveDict& getCurves() { return myCurves; } + Plot2d_Curve* getClosestCurve( QPoint p, double& distance, int& index ); + +signals: + void plotMouseMoved( const QMouseEvent& ); + void plotMousePressed( const QMouseEvent& ); + void plotMouseReleased( const QMouseEvent& ); public slots: virtual void polish(); protected: bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ); + virtual void mousePressEvent( QMouseEvent* event ); + virtual void mouseMoveEvent( QMouseEvent* event ); + virtual void mouseReleaseEvent( QMouseEvent* event ); protected: - QValueList myColors; + CurveDict myCurves; + QwtPlotGrid* myGrid; + QList myColors; bool myIsPolished; }; diff --git a/src/Plot2d/Plot2d_ViewModel.cxx b/src/Plot2d/Plot2d_ViewModel.cxx index e689f6ef5..ecef0231d 100755 --- a/src/Plot2d/Plot2d_ViewModel.cxx +++ b/src/Plot2d/Plot2d_ViewModel.cxx @@ -24,7 +24,9 @@ #include "Plot2d_ViewFrame.h" #include "Plot2d_Prs.h" -#include +#include +#include +#include /*! Constructor @@ -61,20 +63,22 @@ SUIT_ViewWindow* Plot2d_Viewer::createView(SUIT_Desktop* theDesktop) Adds custom items to popup menu \param thePopup - popup menu */ -void Plot2d_Viewer::contextMenuPopup(QPopupMenu* thePopup) +void Plot2d_Viewer::contextMenuPopup(QMenu* thePopup) { Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView()); if ( aView ) aView->contextMenuPopup(thePopup); - if (thePopup->count() > 0) thePopup->insertSeparator(); - thePopup->insertItem( tr( "MNU_DUMP_VIEW" ), this, SLOT(onDumpView())); - thePopup->insertItem( tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), this, SLOT(onChangeBgColor())); + if (!thePopup->isEmpty()) + thePopup->addSeparator(); + thePopup->addAction( tr( "MNU_DUMP_VIEW" ), this, SLOT(onDumpView())); + thePopup->addAction( tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), this, SLOT(onChangeBgColor())); if ( aView ) { if ( !aView->getToolBar()->isVisible() ) { - if (thePopup->count() > 0) thePopup->insertSeparator(); - thePopup->insertItem("Show toolbar", this, SLOT(onShowToolbar())); + if (!thePopup->isEmpty()) + thePopup->addSeparator(); + thePopup->addAction("Show toolbar", this, SLOT(onShowToolbar())); } aView->RefreshDumpImage(); } @@ -98,7 +102,7 @@ void Plot2d_Viewer::setPrs(Plot2d_Prs* thePrs) void Plot2d_Viewer::update() { SUIT_ViewManager* aMgr = getViewManager(); - QPtrVector aViews = aMgr->getViews(); + QVector aViews = aMgr->getViews(); unsigned int aSize = aViews.size(); for (uint i = 0; i < aSize; i++) { Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i]; @@ -113,7 +117,7 @@ void Plot2d_Viewer::update() void Plot2d_Viewer::clearPrs() { SUIT_ViewManager* aMgr = getViewManager(); - QPtrVector aViews = aMgr->getViews(); + QVector aViews = aMgr->getViews(); unsigned int aSize = aViews.size(); for (uint i = 0; i < aSize; i++) { Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i]; diff --git a/src/Plot2d/Plot2d_ViewModel.h b/src/Plot2d/Plot2d_ViewModel.h index 75445ff9b..db0c471d2 100755 --- a/src/Plot2d/Plot2d_ViewModel.h +++ b/src/Plot2d/Plot2d_ViewModel.h @@ -27,7 +27,7 @@ class SUIT_Desktop; class Plot2d_ViewFrame; class Plot2d_Prs; class QString; -class QPopupMenu; +class QMenu; class PLOT2D_EXPORT Plot2d_Viewer: public SUIT_ViewModel { @@ -42,7 +42,7 @@ public: virtual void setViewManager( SUIT_ViewManager* ); virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); virtual QString getType() const { return Type(); } - virtual void contextMenuPopup(QPopupMenu*); + virtual void contextMenuPopup(QMenu*); Plot2d_Prs* getPrs() const { return myPrs; }; void setPrs(Plot2d_Prs* thePrs); void update(); diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 1fdf78431..44e1dfa2a 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -29,10 +29,13 @@ #include "QtxAction.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /*! Constructor @@ -41,15 +44,13 @@ Plot2d_ViewWindow::Plot2d_ViewWindow(SUIT_Desktop* theDesktop, Plot2d_Viewer* th : SUIT_ViewWindow(theDesktop) { myModel = theModel; - myDumpImage = QImage(); myViewFrame = new Plot2d_ViewFrame(this, "plotView"); setCentralWidget(myViewFrame); - myToolBar = new QToolBar(this); - myToolBar->setCloseMode(QDockWindow::Undocked); - myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL")); + myToolBar = addToolBar( tr("LBL_TOOLBAR_LABEL") ); + //myToolBar->setCloseMode(QDockWindow::Undocked); // toolbar has "Close" (X) button only if it's undocked, but there is no such functionality in Qt4 createActions(); createToolBar(); @@ -59,6 +60,7 @@ Plot2d_ViewWindow::Plot2d_ViewWindow(SUIT_Desktop* theDesktop, Plot2d_Viewer* th connect(myViewFrame, SIGNAL(contextMenuRequested( QContextMenuEvent * )), this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) ); + myViewFrame->installEventFilter( this ); } /*! @@ -75,33 +77,36 @@ Plot2d_ViewWindow::~Plot2d_ViewWindow() void Plot2d_ViewWindow::putInfo(QString theMsg) { QStatusBar* aStatusBar = myDesktop->statusBar(); - aStatusBar->message(theMsg/*, 3000*/); + aStatusBar->showMessage(theMsg/*, 3000*/); } /*! Fills popup menu with custom actions \param popup - popup menu to be filled with */ -void Plot2d_ViewWindow::contextMenuPopup( QPopupMenu* thePopup ) +void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup ) { // scaling - QPopupMenu* scalingPopup = new QPopupMenu( thePopup ); + QMenu* scalingPopup = new QMenu( thePopup ); + scalingPopup->addAction( myActionsMap[ PModeXLinearId ] ); myActionsMap[ PModeXLinearId ]->addTo( scalingPopup ); myActionsMap[ PModeXLogarithmicId ]->addTo( scalingPopup ); onChangeHorMode(); - scalingPopup->insertSeparator(); + scalingPopup->addSeparator(); myActionsMap[ PModeYLinearId ]->addTo( scalingPopup ); myActionsMap[ PModeYLogarithmicId ]->addTo( scalingPopup ); - thePopup->insertItem( tr( "SCALING_POPUP" ), scalingPopup ); + scalingPopup->setTitle( tr( "SCALING_POPUP" ) ); + thePopup->addMenu( scalingPopup ); onChangeVerMode(); - thePopup->insertItem(tr("TOT_PLOT2D_FITDATA"), myViewFrame, SLOT(onFitData())); + thePopup->addAction(tr("TOT_PLOT2D_FITDATA"), myViewFrame, SLOT(onFitData())); // curve type - QPopupMenu* curTypePopup = new QPopupMenu( thePopup ); + QMenu* curTypePopup = new QMenu( thePopup ); myActionsMap[ CurvPointsId ]->addTo( curTypePopup ); myActionsMap[ CurvLinesId ]->addTo( curTypePopup ); myActionsMap[ CurvSplinesId ]->addTo( curTypePopup ); - thePopup->insertItem( tr( "CURVE_TYPE_POPUP" ), curTypePopup ); + curTypePopup->setTitle( tr( "CURVE_TYPE_POPUP" ) ); + thePopup->addMenu( curTypePopup ); // legend myActionsMap[ LegendId ]->addTo(thePopup); @@ -195,7 +200,7 @@ void Plot2d_ViewWindow::createActions() tr("MEN_PLOT2D_CURVES_POINTS"), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_CURVES_POINTS")); connect(aAction, SIGNAL(activated()), this, SLOT(onCurves())); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[ CurvPointsId ] = aAction; // Curve type - lines @@ -204,7 +209,7 @@ void Plot2d_ViewWindow::createActions() tr("MEN_PLOT2D_CURVES_LINES"), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_CURVES_LINES")); connect(aAction, SIGNAL(activated()), this, SLOT(onCurves())); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[ CurvLinesId ] = aAction; // Curve type - splines @@ -213,7 +218,7 @@ void Plot2d_ViewWindow::createActions() tr("MEN_PLOT2D_CURVES_SPLINES"), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_CURVES_SPLINES")); connect(aAction, SIGNAL(activated()), this, SLOT(onCurves())); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[ CurvSplinesId ] = aAction; // Mode for X (linear or logarithmic) @@ -238,7 +243,7 @@ void Plot2d_ViewWindow::createActions() tr("MEN_PLOT2D_SHOW_LEGEND"), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_SHOW_LEGEND")); connect(aAction, SIGNAL(activated()), this, SLOT(onLegend())); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[ LegendId ] = aAction; // Settings @@ -263,7 +268,7 @@ void Plot2d_ViewWindow::createActions() aResMgr->loadPixmap("Plot2d", tr("ICON_PLOT2D_MODE_LINEAR_HOR")), tr("MEN_PLOT2D_MODE_LINEAR_HOR"), 0, this); aAction->setStatusTip (tr("PRP_PLOT2D_MODE_LINEAR_HOR")); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[PModeXLinearId] = aAction; connect(aAction, SIGNAL(activated()), this, SLOT(onViewHorMode())); @@ -271,7 +276,7 @@ void Plot2d_ViewWindow::createActions() aResMgr->loadPixmap("Plot2d", tr("ICON_PLOT2D_MODE_LOGARITHMIC_HOR")), tr("MEN_PLOT2D_MODE_LOGARITHMIC_HOR"), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_MODE_LOGARITHMIC_HOR")); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[PModeXLogarithmicId] = aAction; connect(aAction, SIGNAL(activated()), this, SLOT(onViewHorMode())); @@ -280,7 +285,7 @@ void Plot2d_ViewWindow::createActions() aResMgr->loadPixmap("Plot2d", tr("ICON_PLOT2D_MODE_LINEAR_VER")), tr("MEN_PLOT2D_MODE_LINEAR_VER" ), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_MODE_LINEAR_VER")); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[PModeYLinearId] = aAction; connect(aAction, SIGNAL(activated()), this, SLOT(onViewVerMode())); @@ -288,10 +293,9 @@ void Plot2d_ViewWindow::createActions() aResMgr->loadPixmap("Plot2d", tr("ICON_PLOT2D_MODE_LOGARITHMIC_VER")), tr("MEN_PLOT2D_MODE_LOGARITHMIC_VER" ), 0, this); aAction->setStatusTip(tr("PRP_PLOT2D_MODE_LOGARITHMIC_VER")); - aAction->setToggleAction(true); + aAction->setCheckable(true); myActionsMap[PModeYLogarithmicId] = aAction; connect(aAction, SIGNAL(activated()), this, SLOT(onViewVerMode())); - } /*! @@ -305,16 +309,19 @@ void Plot2d_ViewWindow::createToolBar() aScaleBtn->AddAction(myActionsMap[FitAllId]); aScaleBtn->AddAction(myActionsMap[FitRectId]); aScaleBtn->AddAction(myActionsMap[ZoomId]); + myToolBar->addWidget( aScaleBtn ); SUIT_ToolButton* aPanBtn = new SUIT_ToolButton(myToolBar); aPanBtn->AddAction(myActionsMap[PanId]); aPanBtn->AddAction(myActionsMap[GlobalPanId]); + myToolBar->addWidget( aPanBtn ); myCurveBtn = new SUIT_ToolButton(myToolBar); myCurveBtn->AddAction(myActionsMap[CurvPointsId]); myCurveBtn->AddAction(myActionsMap[CurvLinesId]); myCurveBtn->AddAction(myActionsMap[CurvSplinesId]); - myActionsMap[CurvLinesId]->setOn(true); + myToolBar->addWidget( myCurveBtn ); + myActionsMap[CurvLinesId]->setChecked(true); onChangeCurveMode(); myActionsMap[HorId]->addTo(myToolBar); @@ -336,12 +343,12 @@ void Plot2d_ViewWindow::onChangeHorMode() bool aLinear = myViewFrame->isModeHorLinear(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - myActionsMap[PModeXLinearId]->setOn( aLinear ); - myActionsMap[PModeXLogarithmicId]->setOn( !aLinear ); + myActionsMap[PModeXLinearId]->setChecked( aLinear ); + myActionsMap[PModeXLogarithmicId]->setChecked( !aLinear ); QPixmap pix = aResMgr->loadPixmap( "Plot2d", tr( aLinear ? "ICON_PLOT2D_MODE_LOGARITHMIC_HOR" : "ICON_PLOT2D_MODE_LINEAR_HOR" ) ); - myActionsMap[HorId]->setIconSet( pix ); + myActionsMap[HorId]->setIcon( pix ); myActionsMap[HorId]->setToolTip( tr( aLinear ? "TOT_PLOT2D_MODE_LOGARITHMIC_HOR" : "TOT_PLOT2D_MODE_LINEAR_HOR" ) ); myActionsMap[HorId]->setStatusTip( tr( aLinear ? "PRP_PLOT2D_MODE_LOGARITHMIC_HOR" : @@ -358,12 +365,12 @@ void Plot2d_ViewWindow::onChangeVerMode() bool aLinear = myViewFrame->isModeVerLinear(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - myActionsMap[PModeYLinearId]->setOn( aLinear ); - myActionsMap[PModeYLogarithmicId]->setOn( !aLinear ); + myActionsMap[PModeYLinearId]->setChecked( aLinear ); + myActionsMap[PModeYLogarithmicId]->setChecked( !aLinear ); QPixmap pix = aResMgr->loadPixmap( "Plot2d", tr( aLinear ? "ICON_PLOT2D_MODE_LOGARITHMIC_VER" : "ICON_PLOT2D_MODE_LINEAR_VER" ) ); - myActionsMap[VerId]->setIconSet( pix ); + myActionsMap[VerId]->setIcon( pix ); myActionsMap[VerId]->setToolTip( tr( aLinear ? "TOT_PLOT2D_MODE_LOGARITHMIC_VER" : "TOT_PLOT2D_MODE_LINEAR_VER" ) ); myActionsMap[VerId]->setStatusTip( tr( aLinear ? "PRP_PLOT2D_MODE_LOGARITHMIC_VER" : @@ -380,9 +387,9 @@ void Plot2d_ViewWindow::onChangeCurveMode() int aCurveType = myViewFrame->getCurveType(); myCurveBtn->SetItem(aCurveType); - myActionsMap[CurvPointsId]->setOn(aCurveType == 0); - myActionsMap[CurvLinesId]->setOn(aCurveType == 1); - myActionsMap[CurvSplinesId]->setOn(aCurveType == 2); + myActionsMap[CurvPointsId]->setChecked(aCurveType == 0); + myActionsMap[CurvLinesId]->setChecked(aCurveType == 1); + myActionsMap[CurvSplinesId]->setChecked(aCurveType == 2); } /*! @@ -390,7 +397,7 @@ void Plot2d_ViewWindow::onChangeCurveMode() */ void Plot2d_ViewWindow::onChangeLegendMode() { - myActionsMap[ LegendId ]->setOn(myViewFrame->isLegendShow()); + myActionsMap[ LegendId ]->setChecked(myViewFrame->isLegendShow()); } /*! @@ -483,7 +490,7 @@ void Plot2d_ViewWindow::onCurves() */ void Plot2d_ViewWindow::onDumpView() { - qApp->postEvent( myViewFrame, new QPaintEvent( QRect( 0, 0, myViewFrame->width(), myViewFrame->height() ), TRUE ) ); + qApp->postEvent( myViewFrame, new QPaintEvent( QRect( 0, 0, myViewFrame->width(), myViewFrame->height() ) ) ); SUIT_ViewWindow::onDumpView(); } @@ -492,10 +499,10 @@ void Plot2d_ViewWindow::onDumpView() */ QImage Plot2d_ViewWindow::dumpView() { - if ( getToolBar()->hasMouse() || myDumpImage.isNull() ) + if ( getToolBar()->underMouse() || myDumpImage.isNull() ) { QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); - return px.convertToImage(); + return px.toImage(); } return myDumpImage; @@ -545,5 +552,5 @@ void Plot2d_ViewWindow::setVisualParameters( const QString& parameters ) void Plot2d_ViewWindow::RefreshDumpImage() { QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); - myDumpImage = px.convertToImage(); + myDumpImage = px.toImage(); } diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index aa1d4dd62..3f1a9df68 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -21,8 +21,8 @@ #include "Plot2d.h" #include +#include -#include #ifdef WIN32 #pragma warning( disable:4251 ) @@ -33,6 +33,9 @@ class Plot2d_Viewer; class Plot2d_ViewFrame; class QtxAction; class SUIT_ToolButton; +class QImage; +class QMenu; +class QToolBar; class PLOT2D_EXPORT Plot2d_ViewWindow : public SUIT_ViewWindow { @@ -46,21 +49,19 @@ public: void putInfo(QString theMsg); Plot2d_ViewFrame* getViewFrame() { return myViewFrame; }; QToolBar* getToolBar() { return myToolBar; }; - void contextMenuPopup( QPopupMenu* thePopup ); + void contextMenuPopup( QMenu* thePopup ); virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& parameters ); virtual void RefreshDumpImage(); + virtual bool eventFilter(QObject* watched, QEvent* e); protected: virtual QImage dumpView(); virtual QString filter() const; virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); -private: - bool eventFilter(QObject* watched, QEvent* e); - void createActions(); void createToolBar();