From 26c1171c6c905a8eb236a3eb9088eb080f6078a6 Mon Sep 17 00:00:00 2001 From: Charles PIGNEROL <> Date: Wed, 13 Dec 2023 16:42:52 +0100 Subject: [PATCH] Version 5.3.0. Porting Qt 6. --- CMakeLists.txt | 2 +- cmake/version.cmake | 4 +- src/QwtCharts/CMakeLists.txt | 5 +- src/QwtCharts/QwtChartGeneralOptionsPanel.cpp | 79 +++---- src/QwtCharts/QwtChartOptionsDialog.cpp | 24 +- src/QwtCharts/QwtChartPanel.cpp | 113 ++++----- src/QwtCharts/QwtChartsManager.cpp | 66 +++--- src/QwtCharts/QwtCurveChartPanel.cpp | 1 + src/QwtCharts/QwtCurvesOptionsPanel.cpp | 1 + src/QwtCharts/QwtExtendedMultiBarChart.cpp | 74 ++---- src/QwtCharts/QwtExtendedPlotZoomer.cpp | 13 +- src/QwtCharts/QwtExtendedScaleDraw.cpp | 8 +- src/QwtCharts/QwtHistogramChartPanel.cpp | 1 + .../QwtHistogramCoordinatesPicker.cpp | 10 +- .../QwtPlotCurveCoordinatesPicker.cpp | 217 +++++++----------- .../public/QwtCharts/QwtChartPanel.h | 4 +- .../QwtCharts/QwtHistogramCoordinatesPicker.h | 15 +- .../QwtCharts/QwtPlotCoordinatesPicker.h | 2 + .../QwtCharts/QwtPlotCurveCoordinatesPicker.h | 5 +- src/tests/CMakeLists.txt | 3 +- src/tests/QtCurvesMainWindow.cpp | 1 + src/tests/curves_app.cpp | 5 +- versions.txt | 8 + 23 files changed, 277 insertions(+), 384 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9ab5f7..9eade19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.15) project (QwtCharts CXX) diff --git a/cmake/version.cmake b/cmake/version.cmake index 0e24bee..8bc6a75 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -3,8 +3,8 @@ # set (QWT_CHARTS_MAJOR_VERSION "5") -set (QWT_CHARTS_MINOR_VERSION "2") -set (QWT_CHARTS_RELEASE_VERSION "1") +set (QWT_CHARTS_MINOR_VERSION "3") +set (QWT_CHARTS_RELEASE_VERSION "0") set (QWT_CHARTS_VERSION ${QWT_CHARTS_MAJOR_VERSION}.${QWT_CHARTS_MINOR_VERSION}.${QWT_CHARTS_RELEASE_VERSION}) diff --git a/src/QwtCharts/CMakeLists.txt b/src/QwtCharts/CMakeLists.txt index c246c80..2cb2e8d 100644 --- a/src/QwtCharts/CMakeLists.txt +++ b/src/QwtCharts/CMakeLists.txt @@ -10,10 +10,11 @@ find_package (Qwt REQUIRED) # définit ${QWT_TARGET} include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) find_package (QtUtil 6 REQUIRED) -find_package(Qt5Core 5 NO_CMAKE_SYSTEM_PATH) # In order to enable moc ... +find_package(Qt${QT_MAJOR}Core ${QT_MAJOR} NO_CMAKE_SYSTEM_PATH) # In order to enable moc ... file (GLOB HEADERS public/${CURRENT_PACKAGE_NAME}/*.h) file (GLOB CPP_SOURCES *.cpp *.qrc) @@ -26,7 +27,7 @@ set_property (TARGET QwtCharts PROPERTY AUTORCC ON) # => QwtCharts.qrc taken int set (ALL_TARGETS QwtCharts) set_property (TARGET QwtCharts PROPERTY VERSION ${QWT_CHARTS_VERSION}) set_property (TARGET QwtCharts PROPERTY SOVERSION ${QWT_CHARTS_MAJOR_VERSION}) -set (QWT_CHARTS_PUBLIC_FLAGS -DQT_5) +set (QWT_CHARTS_PUBLIC_FLAGS -DQT_${QT_MAJOR}) set (QWT_CHARTS_PRIVATE_FLAGS -DQWT_CHARTS_VERSION="${QWT_CHARTS_VERSION}") target_include_directories (QwtCharts PUBLIC $$) diff --git a/src/QwtCharts/QwtChartGeneralOptionsPanel.cpp b/src/QwtCharts/QwtChartGeneralOptionsPanel.cpp index 73468a8..7a8f701 100644 --- a/src/QwtCharts/QwtChartGeneralOptionsPanel.cpp +++ b/src/QwtCharts/QwtChartGeneralOptionsPanel.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -26,15 +27,10 @@ static const TkUtil::Charset charset ("àéèùô"); USE_ENCODING_AUTODETECTION -QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( - QWidget* parent, QwtChartPanel* chartPanel) +QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (QWidget* parent, QwtChartPanel* chartPanel) : QwtChartPanel::QwtChartEditionPanel (parent, chartPanel), - _chartPanel (chartPanel), - _backgroundColor (Qt::white), - _titleTextField (0), _titleFontPanel (0), - _cartesianButton (0), _polarButton (0), - _marginsTextField (0), - _aspectRatioCheckbox (0), _aspectRatioTextField (0) + _chartPanel (chartPanel), _backgroundColor (Qt::white), _titleTextField (0), _titleFontPanel (0), + _cartesianButton (0), _polarButton (0), _marginsTextField (0), _aspectRatioCheckbox (0), _aspectRatioTextField (0) { if (0 != _chartPanel) _backgroundColor = _chartPanel->getBackgroundColor ( ); @@ -51,19 +47,15 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( vLayout->addLayout (hLayout); QLabel* label = new QLabel ("Titre :", group); hLayout->addWidget (label); - QString title = - 0 == _chartPanel ? "" : _chartPanel->getPlot ( ).title ( ).text ( ); + QString title = 0 == _chartPanel ? "" : _chartPanel->getPlot ( ).title ( ).text ( ); _titleTextField = new QtTextField (title, group); hLayout->addWidget (_titleTextField); QPushButton* button = new QPushButton ("Modifier ...", group); hLayout->addWidget (button); connect (button, SIGNAL (clicked ( )), this, SLOT (editTitleCallback ( ))); - QFont font = 0 == _chartPanel ? - QApplication::font( ) : _chartPanel->getPlot ( ).title ( ).font ( ); - QColor color = 0 == _chartPanel ? - Qt::black : _chartPanel->getPlot ( ).title ( ).color ( ); - _titleFontPanel = - new QtFontPanel (this, font, color, QtFontPanel::HORIZONTAL_PANEL); + QFont font = 0 == _chartPanel ? QApplication::font( ) : _chartPanel->getPlot ( ).title ( ).font ( ); + QColor color = 0 == _chartPanel ? Qt::black : _chartPanel->getPlot ( ).title ( ).color ( ); + _titleFontPanel = new QtFontPanel (this, font, color, QtFontPanel::HORIZONTAL_PANEL); vLayout->addWidget (_titleFontPanel); vLayout->addStretch (2); @@ -74,21 +66,18 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( hLayout = new QHBoxLayout ( ); group->setLayout (hLayout); mainLayout->addWidget (group); - _cartesianButton = - new QRadioButton (QSTR ("Cartésienne"), group); + _cartesianButton = new QRadioButton (QSTR ("Cartésienne"), group); hLayout->addWidget (_cartesianButton); if (QwtChartPanel::CARTESIAN == chartPanel->getDisplayMode ( )) _cartesianButton->setChecked (true); - _cartesianButton->setEnabled ( - chartPanel->isDisplayModeAllowed (QwtChartPanel::CARTESIAN)); + _cartesianButton->setEnabled (chartPanel->isDisplayModeAllowed (QwtChartPanel::CARTESIAN)); buttonGroup->addButton (_cartesianButton); _polarButton = new QRadioButton ("Polaire", group); buttonGroup->addButton (_polarButton); hLayout->addWidget (_polarButton); if (QwtChartPanel::POLAR == chartPanel->getDisplayMode ( )) _polarButton->setChecked (true); - _polarButton->setEnabled ( - chartPanel->isDisplayModeAllowed (QwtChartPanel::POLAR)); + _polarButton->setEnabled (chartPanel->isDisplayModeAllowed (QwtChartPanel::POLAR)); hLayout->addStretch (200); // Fond : @@ -100,8 +89,7 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( hLayout->addWidget (label); button = new QPushButton ("Couleur ...", group); hLayout->addWidget (button); - connect (button, SIGNAL (clicked ( )), this, - SLOT (backgroundColorCallback ( ))); + connect (button, SIGNAL (clicked ( )), this, SLOT (backgroundColorCallback ( ))); hLayout->addStretch (2); // Marges : @@ -113,7 +101,11 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( hLayout->addWidget (label); int margin = 0; if (0 != _chartPanel) +#ifdef QT_5 _chartPanel->getPlot ( ).getContentsMargins (&margin, &margin, &margin, &margin); +#else // QT_5 + margin = _chartPanel->getPlot ( ).contentsMargins ( ).left ( ); +#endif // QT_5 _marginsTextField = new QtIntTextField (margin, group); _marginsTextField->setRange (0, 100); _marginsTextField->setVisibleColumns (3); @@ -124,16 +116,13 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( hLayout = new QHBoxLayout ( ); group->setLayout (hLayout); mainLayout->addWidget (group); - _aspectRatioCheckbox = - new QCheckBox ("Utiliser le rapport d'aspect", group); + _aspectRatioCheckbox = new QCheckBox ("Utiliser le rapport d'aspect", group); if (0 != _chartPanel) _aspectRatioCheckbox->setChecked (_chartPanel->useAspectRatio ( )); hLayout->addWidget (_aspectRatioCheckbox); label = new QLabel ("Rapport d'aspect :", group); hLayout->addWidget (label); - _aspectRatioTextField = - new QtDoubleTextField (0 == _chartPanel ? - 1. : _chartPanel->getAspectRatio ( ), group); + _aspectRatioTextField = new QtDoubleTextField (0 == _chartPanel ? 1. : _chartPanel->getAspectRatio ( ), group); _aspectRatioTextField->setRange (1E-6, 1E6); hLayout->addWidget (_aspectRatioTextField); hLayout->addStretch (2); @@ -143,20 +132,16 @@ QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( } // QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel -QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel ( - const QwtChartGeneralOptionsPanel& view) +QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (const QwtChartGeneralOptionsPanel& view) : QwtChartPanel::QwtChartEditionPanel (0, 0), _chartPanel (0), _backgroundColor (Qt::white), _titleTextField (0), _titleFontPanel (0), - _cartesianButton (0), _polarButton (0), - _marginsTextField (0), - _aspectRatioCheckbox (0), _aspectRatioTextField (0) + _cartesianButton (0), _polarButton (0), _marginsTextField (0), _aspectRatioCheckbox (0), _aspectRatioTextField (0) { assert (0 && "QwtChartGeneralOptionsPanel copy constructor is not allowed."); } // QwtChartGeneralOptionsPanel::QwtChartGeneralOptionsPanel (const QwtChartGeneralOptionsPanel& view) -QwtChartGeneralOptionsPanel& QwtChartGeneralOptionsPanel::operator = ( - const QwtChartGeneralOptionsPanel& view) +QwtChartGeneralOptionsPanel& QwtChartGeneralOptionsPanel::operator = (const QwtChartGeneralOptionsPanel& view) { assert (0 && "QwtChartGeneralOptionsPanel::operator = is not allowed."); return *this; @@ -190,8 +175,7 @@ void QwtChartGeneralOptionsPanel::setTitle (const QwtText& title) } // QwtChartGeneralOptionsPanel::setTitle -QwtChartPanel::DISPLAY_MODE - QwtChartGeneralOptionsPanel::getDisplayMode ( ) const +QwtChartPanel::DISPLAY_MODE QwtChartGeneralOptionsPanel::getDisplayMode ( ) const { assert (0 != _cartesianButton); assert (0 != _polarButton); @@ -205,18 +189,15 @@ QwtChartPanel::DISPLAY_MODE } // QwtChartGeneralOptionsPanel::getDisplayMode -void QwtChartGeneralOptionsPanel::setDisplayMode ( - QwtChartPanel::DISPLAY_MODE mode) +void QwtChartGeneralOptionsPanel::setDisplayMode (QwtChartPanel::DISPLAY_MODE mode) { assert (0 != _cartesianButton); assert (0 != _polarButton); switch (mode) { - case QwtChartPanel::CARTESIAN : - _cartesianButton->setChecked (true); break; - case QwtChartPanel::POLAR : - _polarButton->setChecked (true); break; + case QwtChartPanel::CARTESIAN : _cartesianButton->setChecked (true); break; + case QwtChartPanel::POLAR : _polarButton->setChecked (true); break; default : { INTERNAL_ERROR (exc, "Mode de représentation (cartésienne/polaire) indéfini.", "QwtChartGeneralOptionsPanel::setDisplayMode") @@ -244,8 +225,7 @@ unsigned int QwtChartGeneralOptionsPanel::getMargins ( ) const if (0 > _marginsTextField->getValue ( )) { UTF8String msg (charset); - msg << "La valeur " << (unsigned long)_marginsTextField->getValue ( ) - << " est négative alors qu'elle devrait être positive ou nulle."; + msg << "La valeur " << (unsigned long)_marginsTextField->getValue ( ) << " est négative alors qu'elle devrait être positive ou nulle."; INTERNAL_ERROR (exc, msg, "QwtChartGeneralOptionsPanel::getMargins") throw exc; } // if (0 > _marginsTextField->getValue ( )) @@ -335,14 +315,11 @@ void QwtChartGeneralOptionsPanel::editTitleCallback ( ) try { - UTF8String title ( - QtUnicodeHelper::qstringToUTF8String (_titleTextField->text( ))); + UTF8String title (QtUnicodeHelper::qstringToUTF8String (_titleTextField->text( ))); QFont font = _titleFontPanel->getFont ( ); QColor textColor = _titleFontPanel->getColor ( ); QColor background = getBackgroundColor ( ); - QtScientificTextDialog dialog ( - this, "Titre du graphique", title, true, font, - textColor, background); + QtScientificTextDialog dialog (this, "Titre du graphique", title, true, font, textColor, background); if (QDialog::Accepted != dialog.exec ( )) return; diff --git a/src/QwtCharts/QwtChartOptionsDialog.cpp b/src/QwtCharts/QwtChartOptionsDialog.cpp index 186bd0f..099c2ba 100644 --- a/src/QwtCharts/QwtChartOptionsDialog.cpp +++ b/src/QwtCharts/QwtChartOptionsDialog.cpp @@ -45,11 +45,8 @@ USE_ENCODING_AUTODETECTION } -QwtChartOptionsDialog::QwtChartOptionsDialog ( - QWidget* parent, QwtChartPanel* chartPanel, bool modal, - const string& helpURL, const string& helpTag) - : QDialog (parent), - _chartOptionsPanel (0), _dlgClosurePanel (0) +QwtChartOptionsDialog::QwtChartOptionsDialog (QWidget* parent, QwtChartPanel* chartPanel, bool modal, const string& helpURL, const string& helpTag) + : QDialog (parent), _chartOptionsPanel (0), _dlgClosurePanel (0) { setWindowTitle (QSTR ("Editions des propriétés du graphique")); setModal (modal); @@ -57,22 +54,22 @@ QwtChartOptionsDialog::QwtChartOptionsDialog ( setWindowModality (Qt::WindowModal); QVBoxLayout* layout = new QVBoxLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // QT_5 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); _chartOptionsPanel = new QwtChartOptionsPanel (this, chartPanel); layout->addWidget (_chartOptionsPanel); layout->addWidget (new QLabel (" ", this)); - _dlgClosurePanel = - new QtDlgClosurePanel (this, true, "Appliquer", "Fermer", "", - helpURL, helpTag); + _dlgClosurePanel = new QtDlgClosurePanel (this, true, "Appliquer", "Fermer", "", helpURL, helpTag); layout->addWidget (_dlgClosurePanel); _dlgClosurePanel->setMinimumSize (_dlgClosurePanel->sizeHint ( )); - connect (_dlgClosurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, - SLOT (applyCallback ( ))); - connect (_dlgClosurePanel->getCloseButton ( ), SIGNAL(clicked ( )), this, - SLOT (accept ( ))); + connect (_dlgClosurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT (applyCallback ( ))); + connect (_dlgClosurePanel->getCloseButton ( ), SIGNAL(clicked ( )), this, SLOT (accept ( ))); _dlgClosurePanel->getApplyButton ( )->setAutoDefault (false); _dlgClosurePanel->getApplyButton ( )->setDefault (false); _dlgClosurePanel->getCloseButton ( )->setAutoDefault (false); @@ -94,8 +91,7 @@ QwtChartOptionsDialog::QwtChartOptionsDialog (const QwtChartOptionsDialog& view) } // QwtChartOptionsDialog::QwtChartOptionsDialog (const QwtChartOptionsDialog& view) -QwtChartOptionsDialog& QwtChartOptionsDialog::operator = ( - const QwtChartOptionsDialog& view) +QwtChartOptionsDialog& QwtChartOptionsDialog::operator = (const QwtChartOptionsDialog& view) { assert (0 && "QwtChartOptionsDialog::operator = is not allowed."); return *this; diff --git a/src/QwtCharts/QwtChartPanel.cpp b/src/QwtCharts/QwtChartPanel.cpp index 0e96f42..1fba359 100644 --- a/src/QwtCharts/QwtChartPanel.cpp +++ b/src/QwtCharts/QwtChartPanel.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include "QwtCharts/QwtExtendedPlot.h" @@ -126,24 +128,20 @@ static void ordExtrema ( // LA CLASSE QwtChartPanel::QwtChartEditionPanel // --------------------------------------------------------------------------- -QwtChartPanel::QwtChartEditionPanel::QwtChartEditionPanel ( - QWidget* parent, QwtChartPanel* panel) +QwtChartPanel::QwtChartEditionPanel::QwtChartEditionPanel (QWidget* parent, QwtChartPanel* panel) : QWidget (parent), _chartPanel (panel) { } // QwtChartEditionPanel::QwtChartEditionPanel -QwtChartPanel::QwtChartEditionPanel::QwtChartEditionPanel ( - const QwtChartPanel::QwtChartEditionPanel&) +QwtChartPanel::QwtChartEditionPanel::QwtChartEditionPanel (const QwtChartPanel::QwtChartEditionPanel&) : QWidget (0), _chartPanel (0) { assert (0 && "QwtChartEditionPanel copy constructor is not allowed."); } // QwtChartEditionPanel::QwtChartEditionPanel -QwtChartPanel::QwtChartEditionPanel& - QwtChartPanel::QwtChartEditionPanel::operator = ( - const QwtChartPanel::QwtChartEditionPanel&) +QwtChartPanel::QwtChartEditionPanel& QwtChartPanel::QwtChartEditionPanel::operator = (const QwtChartPanel::QwtChartEditionPanel&) { assert (0 && "QwtChartEditionPanel operator = is not allowed."); return *this; @@ -173,15 +171,13 @@ QwtChartPanel& QwtChartPanel::QwtChartEditionPanel::getChartPanel ( ) // LA CLASSE QwtChartPanel::QwtChartSpecificPanelCreator // --------------------------------------------------------------------------- -QwtChartPanel::QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator ( - QwtChartPanel* panel) +QwtChartPanel::QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator (QwtChartPanel* panel) : _chartPanel (panel) { } // QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator -QwtChartPanel::QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator ( - const QwtChartPanel::QwtChartSpecificPanelCreator&) +QwtChartPanel::QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator (const QwtChartPanel::QwtChartSpecificPanelCreator&) : _chartPanel (0) { assert (0 && "QwtChartSpecificPanelCreator copy constructor is not allowed."); @@ -189,24 +185,21 @@ QwtChartPanel::QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator ( QwtChartPanel::QwtChartSpecificPanelCreator& - QwtChartPanel::QwtChartSpecificPanelCreator::operator = ( - const QwtChartPanel::QwtChartSpecificPanelCreator&) + QwtChartPanel::QwtChartSpecificPanelCreator::operator = (const QwtChartPanel::QwtChartSpecificPanelCreator&) { assert (0 && "QwtChartSpecificPanelCreator operator = is not allowed."); return *this; } // QwtChartSpecificPanelCreator::QwtChartSpecificPanelCreator -vector - QwtChartPanel::QwtChartSpecificPanelCreator::createEditionPanels (QWidget*) +vector QwtChartPanel::QwtChartSpecificPanelCreator::createEditionPanels (QWidget*) { vector list; return list; } // QwtChartPanel::QwtChartSpecificPanelCreator::createEditionPanels -const QwtChartPanel& QwtChartPanel::QwtChartSpecificPanelCreator::getChartPanel( - ) const +const QwtChartPanel& QwtChartPanel::QwtChartSpecificPanelCreator::getChartPanel( ) const { CHECK_NULL_PTR_ERROR (_chartPanel) return *_chartPanel; @@ -225,8 +218,7 @@ QwtChartPanel& QwtChartPanel::QwtChartSpecificPanelCreator::getChartPanel ( ) // LA CLASSE QwtChartPanel::DataPaintAttributes // --------------------------------------------------------------------------- -QwtChartPanel::DataPaintAttributes::DataPaintAttributes ( - QwtPlotItem* plotItem, const PaintAttributes& pen) +QwtChartPanel::DataPaintAttributes::DataPaintAttributes (QwtPlotItem* plotItem, const PaintAttributes& pen) : _plotItem (plotItem), _name ( ), _pen (pen), _fgValid (true), _bgValid (true) { @@ -235,16 +227,14 @@ QwtChartPanel::DataPaintAttributes::DataPaintAttributes ( } // DataPaintAttributes::DataPaintAttributes -QwtChartPanel::DataPaintAttributes::DataPaintAttributes ( - const string& name, const PaintAttributes& pen) +QwtChartPanel::DataPaintAttributes::DataPaintAttributes (const string& name, const PaintAttributes& pen) : _plotItem (0), _name (name), _pen (pen), _fgValid (true), _bgValid (true) { } // DataPaintAttributes::DataPaintAttributes -QwtChartPanel::DataPaintAttributes::DataPaintAttributes ( - const QwtChartPanel::DataPaintAttributes& copied) +QwtChartPanel::DataPaintAttributes::DataPaintAttributes (const QwtChartPanel::DataPaintAttributes& copied) : _plotItem (copied._plotItem), _name (copied._name), _pen (copied._pen), _fgValid (copied._fgValid), _bgValid (copied._bgValid) { @@ -252,8 +242,7 @@ QwtChartPanel::DataPaintAttributes::DataPaintAttributes ( QwtChartPanel::DataPaintAttributes& - QwtChartPanel::DataPaintAttributes::operator = ( - const QwtChartPanel::DataPaintAttributes& copied) + QwtChartPanel::DataPaintAttributes::operator = (const QwtChartPanel::DataPaintAttributes& copied) { if (&copied != this) { @@ -273,23 +262,19 @@ QwtChartPanel::DataPaintAttributes& // LA CLASSE QwtChartPanel::AxisScale // --------------------------------------------------------------------------- -QwtChartPanel::AxisScale::AxisScale ( - double min, double max, bool autoScale, double tickStep, bool updated) - : _min (min), _max (max), _auto (autoScale), _updated (updated), - _tickStep (tickStep) +QwtChartPanel::AxisScale::AxisScale (double min, double max, bool autoScale, double tickStep, bool updated) + : _min (min), _max (max), _auto (autoScale), _updated (updated), _tickStep (tickStep) { } // AxisScale::AxisScale QwtChartPanel::AxisScale::AxisScale (const QwtChartPanel::AxisScale& as) - : _min (as._min), _max (as._max), _auto (as._auto), _updated (as._updated), - _tickStep (as._tickStep) + : _min (as._min), _max (as._max), _auto (as._auto), _updated (as._updated), _tickStep (as._tickStep) { } // AxisScale::AxisScale (const QwtChartPanel::AxisScale&) -QwtChartPanel::AxisScale& QwtChartPanel::AxisScale::operator = ( - const QwtChartPanel::AxisScale& as) +QwtChartPanel::AxisScale& QwtChartPanel::AxisScale::operator = (const QwtChartPanel::AxisScale& as) { if (&as != this) { @@ -313,10 +298,8 @@ bool QwtChartPanel::drawHorMajorLines = true; bool QwtChartPanel::drawHorMinorLines = false; bool QwtChartPanel::drawVerMajorLines = true; bool QwtChartPanel::drawVerMinorLines = false; -QwtPlot::LegendPosition QwtChartPanel::legendPosition = - QwtPlot::RightLegend; -QwtLegendData::Mode QwtChartPanel::legendCheckable = - QwtLegendData::ReadOnly; +QwtPlot::LegendPosition QwtChartPanel::legendPosition = QwtPlot::RightLegend; +QwtLegendData::Mode QwtChartPanel::legendCheckable = QwtLegendData::ReadOnly; int QwtChartPanel::legendCurveWidth = 3; unsigned char QwtChartPanel::scaleLabelPrecision = 10; char QwtChartPanel::scaleLabelFormat = 'g'; @@ -356,15 +339,14 @@ QwtChartPanel::QwtChartPanel (QWidget* parent) _grid->enableY (drawVerMajorLines); // Lignes horizontales majeures _grid->enableYMin (drawVerMinorLines); // Lignes horizontales mineures _grid->attach (_plotWidget); - + setBackgroundColor (Qt::white); showLegend (true); _plotWidget->setMinimumSize (300, 200); _plotWidget->setContentsMargins (15, 15, 15, 15); for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; i++) { - _plotWidget->setAxisScaleDraw ( - i, new QwtExtendedScaleDraw(scaleLabelPrecision, scaleLabelFormat)); + _plotWidget->setAxisScaleDraw (i, new QwtExtendedScaleDraw(scaleLabelPrecision, scaleLabelFormat)); } // for (int i = QwtPlot::yLeft; i < QwtPlot::axisCnt; i++) mainLayout->addWidget (_plotWidget); @@ -372,7 +354,7 @@ QwtChartPanel::QwtChartPanel (QWidget* parent) _panner = new QwtPlotPanner (_plotWidget->canvas ( )); CHECK_NULL_PTR_ERROR (_panner) - _panner->setMouseButton(Qt::MidButton); + _panner->setMouseButton(Qt::MiddleButton); _panner->setCursor (Qt::ClosedHandCursor); _panner->setEnabled (true); @@ -538,10 +520,15 @@ void QwtChartPanel::setBackgroundColor (const QColor& bg) { QPalette p (palette ( )); setAutoFillBackground (true); +#ifdef QT_5 p.setColor (QPalette::Active, QPalette::Background, bg); p.setColor (QPalette::Inactive, QPalette::Background, bg); setPalette (p); getPlot ( ).setCanvasBackground (bg); +#else // QT_5 + QString backgroundLabel ("background-color:"); + getPlot ( ).setStyleSheet (backgroundLabel + bg.name ( )); // => background-color:#RRGGBB +#endif // QT_5 getPlot ( ).replot ( ); } // QwtChartPanel::setBackgroundColor @@ -549,7 +536,11 @@ void QwtChartPanel::setBackgroundColor (const QColor& bg) int QwtChartPanel::getMargin ( ) const { int margin = 0; +#ifdef QT_5 getContentsMargins (&margin, &margin, &margin, &margin); +#else // QT_5 + margin = contentsMargins ( ).left ( ); +#endif // QT_5 return margin; } // QwtChartPanel::getMargin @@ -946,7 +937,14 @@ int QwtChartPanel::getLegendMargin ( ) const int left = 0, top = 0, right = 0, bottom = 0; if (0 != layout) + { +#ifdef QT_5 layout->getContentsMargins (&left, &top, &right, &bottom); +#else // QT_5 + QMargins margins = layout->contentsMargins ( ); + top = margins.top ( ); right = margins.right ( ); bottom = margins.bottom ( ); left = margins.left ( ); +#endif // QT_5 + } // if (0 != layout) return top; } // QwtChartPanel::getLegendMargin @@ -1477,8 +1475,11 @@ void QwtChartPanel::zoom (QWheelEvent& event) const bool enabled = zoomEnabled ( ); enableZoom (true); +#ifdef QT_5 zoom (1. + sign * (double)event.delta ( ) / 8. / 100.); - +#else // QT_5 + zoom (1. + sign * (double)(event.pixelDelta ( ).x ( ) + event.pixelDelta ( ).y ( )) / 8. / 100.); +#endif // QT_5 event.accept ( ); enableZoom (enabled); } // QwtChartPanel::zoom @@ -1497,7 +1498,7 @@ void QwtChartPanel::zoom (double factor) return; // Le rectangle englobant de la future partie visible : - QwtDoubleRect rect = _zoomer->zoomRect ( ); + QRectF rect = _zoomer->zoomRect ( ); const double width = rect.width ( ); const double height = rect.height ( ); const double dx = (factor - 1.) * width; @@ -1519,7 +1520,7 @@ void QwtChartPanel::zoom (double factor) const double yMax = ordScaleDiv.upperBound ( ); const double x = xMin + (xMax - xMin) / 2.; const double y = yMin + (yMax - yMin) / 2.; - rect.moveCenter (QwtDoublePoint (x, y)); + rect.moveCenter (QPointF (x, y)); _zoomer->zoom (rect); } // QwtChartPanel::zoom @@ -1566,8 +1567,8 @@ void QwtChartPanel::adjustScales ( ) if (true == _rescaler->isEnabled ( )) { - QwtDoubleInterval intervalx (minx, maxx); - QwtDoubleInterval intervaly (miny, maxy); + QwtInterval intervalx (minx, maxx); + QwtInterval intervaly (miny, maxy); _rescaler->setIntervalHint (QwtPlot::xBottom, intervalx); _rescaler->setIntervalHint (QwtPlot::xTop, intervalx); _rescaler->setIntervalHint (QwtPlot::yLeft, intervaly); @@ -1578,7 +1579,7 @@ void QwtChartPanel::adjustScales ( ) { const double width = maxx - minx; const double height = maxy - miny; - QwtDoubleRect rect (minx, miny, width, height); + QRectF rect (minx, miny, width, height); _zoomer->zoom (rect); } } // QwtChartPanel::adjustScales @@ -1665,8 +1666,8 @@ void QwtChartPanel::dataModified ( ) // _zoomer->setZoomBase ( ); // Versions 0.23.0 et ultérieures : on recré l'éventuelle pile de zooms. On // donne pour rectangle initial les dimensions max du graphique. - const QStack& stack = _zoomer->zoomStack ( ); - QStack newStack; + const QStack& stack = _zoomer->zoomStack ( ); + QStack newStack; bool as = false; double x1 = 0., x2 = 0., y1 = 0., y2 = 0.; getAbscissaScale (x1, x2, as); @@ -1674,9 +1675,9 @@ void QwtChartPanel::dataModified ( ) // La nouvelle reference (etat non zoome) : if ((0 != isValid (x1)) && (0 != isValid (x2)) && (0 != isValid (y1)) && (0 != isValid (y2))) - newStack.push (QwtDoubleRect (x1, y1, x2 - x1, y2 - y1)); + newStack.push (QRectF (x1, y1, x2 - x1, y2 - y1)); else - newStack.push (QwtDoubleRect (0., 0., 1., 1.)); + newStack.push (QRectF (0., 0., 1., 1.)); // On conserve le reste de l'ancienne pile : for (size_t i = 1; i < stack.size ( ); i++) @@ -1692,11 +1693,11 @@ void QwtChartPanel::adjustChart ( ) double mn = 0., mx = 0.; bool as = false; getAbscissaScale (mn, mx, as); - QwtDoubleInterval interval (mn, mx); + QwtInterval interval (mn, mx); _rescaler->setIntervalHint (QwtPlot::xBottom, interval); _rescaler->setIntervalHint (QwtPlot::xTop, interval); getOrdinateScale (mn, mx, as); - interval = QwtDoubleInterval (mn, mx); + interval = QwtInterval (mn, mx); _rescaler->setIntervalHint (QwtPlot::yLeft, interval); _rescaler->setIntervalHint (QwtPlot::yRight, interval); if (true == _rescaler->isEnabled ( )) @@ -1723,15 +1724,15 @@ void QwtChartPanel::legendCheckedCallback ( } // legendCheckedCallback -void QwtChartPanel::zoomCallback_Qwt5 (const QwtDoubleRect& r) +void QwtChartPanel::zoomCallback_Qwt5 (const QRectF& r) { CHECK_NULL_PTR_ERROR (_zoomer) double xmin = getPlot ( ).axisScaleDiv (QwtPlot::xBottom).lowerBound ( ); double xmax = getPlot ( ).axisScaleDiv (QwtPlot::xBottom).upperBound ( ); double ymin = getPlot ( ).axisScaleDiv (QwtPlot::yLeft).lowerBound ( ); double ymax = getPlot ( ).axisScaleDiv (QwtPlot::yLeft).upperBound ( ); - QStack stack = _zoomer->zoomStack ( ); - QwtDoubleRect& rect = stack [_zoomer->zoomRectIndex ( )]; + QStack stack = _zoomer->zoomStack ( ); + QRectF& rect = stack [_zoomer->zoomRectIndex ( )]; rect.setRect (xmin, ymin, xmax - xmin, ymax - ymin); _zoomer->setZoomStack (stack, _zoomer->zoomRectIndex ( )); if (0 != _coordsPicker) diff --git a/src/QwtCharts/QwtChartsManager.cpp b/src/QwtCharts/QwtChartsManager.cpp index afeb0a1..5dad431 100644 --- a/src/QwtCharts/QwtChartsManager.cpp +++ b/src/QwtCharts/QwtChartsManager.cpp @@ -17,9 +17,12 @@ #include #include - #include "QwtCharts/QwtChartPrintDialog.h" + +#include +#include + #include #include @@ -527,8 +530,13 @@ void QwtChartsManager::printCallback ( ) else if (0 != lastFileName.size ( )) printer.setOutputFileName (lastFileName); - printer.setOrientation (canvas->width ( ) > canvas->height ( ) ? - QPrinter::Landscape : QPrinter::Portrait); +#ifdef QT_5 + printer.setOrientation (canvas->width ( ) > canvas->height ( ) ? QPrinter::Landscape : QPrinter::Portrait); +#else // QT_5 + QPageLayout pageLayout = printer.pageLayout ( ); + pageLayout.setOrientation (canvas->width ( ) > canvas->height ( ) ? QPageLayout::Landscape : QPageLayout::Portrait); + printer.setPageLayout (pageLayout); +#endif // QT_5 unique_ptr printDialog(new QwtChartPrintDialog(&printer, window)); printDialog->setWindowTitle ("Impression"); if (QDialog::Accepted == printDialog->exec ( )) @@ -539,49 +547,37 @@ void QwtChartsManager::printCallback ( ) return; QPrintEngine* engine = printer.printEngine ( ); - QVariant name = 0 == engine ? QVariant ("inconnue") : - engine->property (QPrintEngine::PPK_PrinterName); + QVariant name = 0 == engine ? QVariant ("inconnue") : engine->property (QPrintEngine::PPK_PrinterName); UTF8String msg (charset), dest (charset); if (0 != printer.outputFileName ( ).size ( )) { toPrinter = false; lastFileName = printer.outputFileName ( ); - dest << "dans le fichier " - << printer.outputFileName ( ).toStdString ( ); + dest << "dans le fichier " << printer.outputFileName ( ).toStdString ( ); } else { toPrinter = true; lastPrinterName = printer.printerName ( ); - dest << "vers l'imprimante " - << name.toString ( ).toStdString ( ); + dest << "vers l'imprimante " << name.toString ( ).toStdString ( ); } // else if (0 != printer.outputFileName ( ).size ( )) switch (printer.printerState ( )) { case QPrinter::Error : - msg << "Echec de l'impression du document " - << window->getTitle ( ).text ( ).toStdString ( ) << " " - << dest << "."; + msg << "Echec de l'impression du document " << window->getTitle ( ).text ( ).toStdString ( ) << " " << dest << "."; displayErrorMessage (window, msg); break; case QPrinter::Idle : - msg << "Impression du document " - << window->getTitle ( ).text ( ).toStdString ( ) - << " " << dest << " effectué."; + msg << "Impression du document " << window->getTitle ( ).text ( ).toStdString ( ) << " " << dest << " effectué."; displayInformationMessage (window, msg); break; case QPrinter::Active : - msg << "Impression du document " - << window->getTitle ( ).text ( ).toStdString ( ) - << " " << dest << " en cours."; + msg << "Impression du document " << window->getTitle ( ).text ( ).toStdString ( ) << " " << dest << " en cours."; displayInformationMessage (window, msg); break; default : - msg << "Status inconnu (" - << (unsigned long)printer.printerState ( ) - << ") de l'impression du document " - << window->getTitle ( ).text ( ).toStdString ( ) - << " " << dest << "."; + msg << "Status inconnu (" << (unsigned long)printer.printerState ( ) << ") de l'impression du document " + << window->getTitle ( ).text ( ).toStdString ( ) << " " << dest << "."; displayWarningMessage (window, msg); } // switch (printer.printerState ( )) } // if (QDialog::Accepted == printDialog->exec ( )) @@ -975,14 +971,10 @@ void QwtChartsManager::focusChanged (const QwtChartPanel* panel) _showLegendAction->setChecked (currentPanel->hasLegend ( )); switch (currentPanel->getLegendPosition ( )) { - case QwtPlot::TopLegend : - _topLegendAction->setChecked (true); break; - case QwtPlot::BottomLegend : - _bottomLegendAction->setChecked (true); break; - case QwtPlot::RightLegend : - _rightLegendAction->setChecked (true); break; - case QwtPlot::LeftLegend : - _leftLegendAction->setChecked (true); break; + case QwtPlot::TopLegend : _topLegendAction->setChecked (true); break; + case QwtPlot::BottomLegend : _bottomLegendAction->setChecked (true); break; + case QwtPlot::RightLegend : _rightLegendAction->setChecked (true); break; + case QwtPlot::LeftLegend : _leftLegendAction->setChecked (true); break; } // switch (currentPanel->getLegendPosition ( )) assert (0 != _verMajorLinesAction); @@ -993,14 +985,10 @@ void QwtChartsManager::focusChanged (const QwtChartPanel* panel) QtActionAutoLock horMinorLock (_horMinorLinesAction); QtActionAutoLock verMajorLock (_verMajorLinesAction); QtActionAutoLock verMinorLock (_verMinorLinesAction); - _verMajorLinesAction->setChecked ( - currentPanel->areVerMajorLinesDisplayed ( )); - _verMinorLinesAction->setChecked ( - currentPanel->areVerMinorLinesDisplayed ( )); - _horMajorLinesAction->setChecked ( - currentPanel->areHorMajorLinesDisplayed ( )); - _horMinorLinesAction->setChecked ( - currentPanel->areHorMinorLinesDisplayed ( )); + _verMajorLinesAction->setChecked (currentPanel->areVerMajorLinesDisplayed ( )); + _verMinorLinesAction->setChecked (currentPanel->areVerMinorLinesDisplayed ( )); + _horMajorLinesAction->setChecked (currentPanel->areHorMajorLinesDisplayed ( )); + _horMinorLinesAction->setChecked (currentPanel->areHorMinorLinesDisplayed ( )); } // if (0 != currentPanel) } // QwtChartsManager::focusChanged diff --git a/src/QwtCharts/QwtCurveChartPanel.cpp b/src/QwtCharts/QwtCurveChartPanel.cpp index 6c148f8..0611b6d 100644 --- a/src/QwtCharts/QwtCurveChartPanel.cpp +++ b/src/QwtCharts/QwtCurveChartPanel.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/src/QwtCharts/QwtCurvesOptionsPanel.cpp b/src/QwtCharts/QwtCurvesOptionsPanel.cpp index 0502714..350c148 100644 --- a/src/QwtCharts/QwtCurvesOptionsPanel.cpp +++ b/src/QwtCharts/QwtCurvesOptionsPanel.cpp @@ -13,6 +13,7 @@ #include #include +#include #include diff --git a/src/QwtCharts/QwtExtendedMultiBarChart.cpp b/src/QwtCharts/QwtExtendedMultiBarChart.cpp index b31cbe1..1c9125c 100644 --- a/src/QwtCharts/QwtExtendedMultiBarChart.cpp +++ b/src/QwtCharts/QwtExtendedMultiBarChart.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -51,8 +52,7 @@ QwtExtendedMultiBarChart::QwtExtendedMultiBarChart (const QString& title) } // QwtExtendedMultiBarChart::QwtExtendedMultiBarChart -QwtExtendedMultiBarChart::QwtExtendedMultiBarChart ( - const QwtExtendedMultiBarChart&) +QwtExtendedMultiBarChart::QwtExtendedMultiBarChart (const QwtExtendedMultiBarChart&) : QwtPlotMultiBarChart (""), _rectangles ( ), _selectedClasses ( ), _style (QwtExtendedMultiBarChart::STYLE_GROUPED), @@ -64,8 +64,7 @@ QwtExtendedMultiBarChart::QwtExtendedMultiBarChart ( } // QwtExtendedMultiBarChart::QwtExtendedMultiBarChart -QwtExtendedMultiBarChart& QwtExtendedMultiBarChart::operator = ( - const QwtExtendedMultiBarChart&) +QwtExtendedMultiBarChart& QwtExtendedMultiBarChart::operator = (const QwtExtendedMultiBarChart&) { assert (0 && "QwtExtendedMultiBarChart operator = is not allowed."); return *this; @@ -93,8 +92,7 @@ size_t QwtExtendedMultiBarChart::getClassesNum ( ) const } // QwtExtendedMultiBarChart::getClassesNum -void QwtExtendedMultiBarChart::setHistogramStyle ( - QwtExtendedMultiBarChart::HISTOGRAM_STYLE style) +void QwtExtendedMultiBarChart::setHistogramStyle (QwtExtendedMultiBarChart::HISTOGRAM_STYLE style) { if (style != _style) { @@ -137,15 +135,13 @@ void QwtExtendedMultiBarChart::displayElementsNum (bool display) } // QwtExtendedMultiBarChart::displayElementsNum -QwtExtendedMultiBarChart::POSITION - QwtExtendedMultiBarChart::getElementNumPos ( ) const +QwtExtendedMultiBarChart::POSITION QwtExtendedMultiBarChart::getElementNumPos ( ) const { return _elementsNumPos; } // QwtExtendedMultiBarChart::getElementNumPos -void QwtExtendedMultiBarChart::setElementNumPos ( - QwtExtendedMultiBarChart::POSITION pos) +void QwtExtendedMultiBarChart::setElementNumPos (QwtExtendedMultiBarChart::POSITION pos) { if (pos != _elementsNumPos) { @@ -163,17 +159,13 @@ bool QwtExtendedMultiBarChart::isVisible (size_t index) const if (index > getSeriesNum ( )) { UTF8String message (charset); - message << "QwtExtendedMultiBarChart::isVisible. Index invalide (" - << index << "). Nombre de séries : " << getSeriesNum ( ) - << "."; + message << "QwtExtendedMultiBarChart::isVisible. Index invalide (" << index << "). Nombre de séries : " << getSeriesNum ( ) << "."; throw Exception (message); } // if (index > getSeriesNum ( )) if (index > _visibleSeries.size ( )) { UTF8String message (charset); - message << "Erreur interne. Index invalide (" - << index << "). Nombre de séries : " << getSeriesNum ( ) - << "."; + message << "Erreur interne. Index invalide (" << index << "). Nombre de séries : " << getSeriesNum ( ) << "."; INTERNAL_ERROR (exc, message, "QwtExtendedMultiBarChart::isVisible") throw exc; } // if (index > _visibleSeries.size ( )) @@ -187,17 +179,13 @@ void QwtExtendedMultiBarChart::setVisible (size_t index, bool visible) if (index > getSeriesNum ( )) { UTF8String message (charset); - message << "QwtExtendedMultiBarChart::setVisible. Index invalide (" - << index << "). Nombre de séries : " << getSeriesNum ( ) - << "."; + message << "QwtExtendedMultiBarChart::setVisible. Index invalide (" << index << "). Nombre de séries : " << getSeriesNum ( ) << "."; throw Exception (message); } // if (index > getSeriesNum ( )) if (index > _visibleSeries.size ( )) { UTF8String message (charset); - message << "Erreur interne. Index invalide (" - << index << "). Nombre de séries : " << getSeriesNum ( ) - << "."; + message << "Erreur interne. Index invalide (" << index << "). Nombre de séries : " << getSeriesNum ( ) << "."; INTERNAL_ERROR (exc, message, "QwtExtendedMultiBarChart::setVisible") throw exc; } // if (index > _visibleSeries.size ( )) @@ -212,12 +200,9 @@ bool QwtExtendedMultiBarChart::isSelected (size_t s, size_t c) const if ((s >= getSeriesNum ( )) || (c >= getClassesNum ( ))) { UTF8String message (charset); - message << "Erreur, classe inexistante (Série : " << s - << ", class : " << c - << ") dans QwtExtendedMultiBarChart::isSelected. " - << "Nombre de séries : " << getSeriesNum ( ) - << ", nombre de classes : " << getClassesNum ( ) - << "."; + message << "Erreur, classe inexistante (Série : " << s << ", class : " << c + << ") dans QwtExtendedMultiBarChart::isSelected. Nombre de séries : " << getSeriesNum ( ) + << ", nombre de classes : " << getClassesNum ( ) << "."; throw Exception (message); } // if ((s >= getSeriesNum ( )) || (c >= getClassesNum ( ))) @@ -290,8 +275,7 @@ vector > QwtExtendedMultiBarChart::getSelection ( ) const } // QwtExtendedMultiBarChart::getSelection -vector > QwtExtendedMultiBarChart::intersectedClasses ( - int x, int y) const +vector > QwtExtendedMultiBarChart::intersectedClasses (int x, int y) const { vector > classes; @@ -313,8 +297,7 @@ vector > QwtExtendedMultiBarChart::intersectedClasses ( } // QwtExtendedMultiBarChart::intersectedClasses -bool QwtExtendedMultiBarChart::intersects ( - int x, int y, double& abs, size_t& ord) const +bool QwtExtendedMultiBarChart::intersects (int x, int y, double& abs, size_t& ord) const { const size_t barsNum = getClassesNum ( ); const size_t seriesNum = getSeriesNum ( ); @@ -339,10 +322,7 @@ bool QwtExtendedMultiBarChart::intersects ( void QwtExtendedMultiBarChart::drawSample ( - QPainter* painter, - const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, const QwtInterval& boundingInterval, - int index, const QwtSetSample& sample) const + QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, const QwtInterval& boundingInterval, int index, const QwtSetSample& sample) const { // if ((index < _visibleSeries.size ( )) && (false == _visibleSeries [index])) // return; @@ -377,9 +357,7 @@ mess << "QwtExtendedMultiBarChart::drawSample, style non supporté (" void QwtExtendedMultiBarChart::drawOverlappedBars ( - QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, - const QRectF& canvasRect, int index, double sampleWidth, - const QwtSetSample &sample) const + QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int index, double sampleWidth, const QwtSetSample &sample) const { // CP : Code fortement inspiré de QwtPlotMultiBarChart::drawGroupedBars. const int numBars = sample.set.size ( ); @@ -388,9 +366,7 @@ void QwtExtendedMultiBarChart::drawOverlappedBars ( if (Qt::Horizontal == orientation ( )) { UTF8String mess (charset); - mess << "QwtExtendedMultiBarChart::drawOverlappedBars. Seule " - << "l'orientation verticale est actuellement supportée. Tracé de " - << "l'histogramme selon cette orientation."; + mess << "QwtExtendedMultiBarChart::drawOverlappedBars. Seule l'orientation verticale est actuellement supportée. Tracé de l'histogramme selon cette orientation."; ConsoleOutput::cerr ( ) << mess << co_endl; } @@ -423,12 +399,9 @@ void QwtExtendedMultiBarChart::drawOverlappedBars ( } // QwtExtendedMultiBarChart::drawOverlappedBars -void QwtExtendedMultiBarChart::drawBar ( - QPainter* painter, int sampleIndex, int barIndex, - const QwtColumnRect& rect) const +void QwtExtendedMultiBarChart::drawBar (QPainter* painter, int sampleIndex, int barIndex, const QwtColumnRect& rect) const { - if ((barIndex < _visibleSeries.size ( )) && - (false == _visibleSeries [barIndex])) + if ((barIndex < _visibleSeries.size ( )) && (false == _visibleSeries [barIndex])) return; assert (0 != painter); @@ -491,9 +464,7 @@ void QwtExtendedMultiBarChart::drawBar ( if (true == first) { UTF8String mess (charset); - mess << "Erreur en " __FILE__ << ' ' << (unsigned long)__LINE__ - << " Position non supportée (" - << (unsigned long)getElementNumPos ( ) << ")"; + mess << "Erreur en " __FILE__ << ' ' << (unsigned long)__LINE__ << " Position non supportée (" << (unsigned long)getElementNumPos ( ) << ")"; ConsoleOutput::cerr ( ) << mess << co_endl; } first = false; @@ -546,8 +517,7 @@ void QwtExtendedMultiBarChart::dataChanged ( ) QwtPlotMultiBarChart::dataChanged ( ); QwtPlot* chart = plot ( ); - QwtLegend* legend = 0 == chart ? - 0 : dynamic_cast(chart->legend ( )); + QwtLegend* legend = 0 == chart ? 0 : dynamic_cast(chart->legend ( )); QList widgets; if (0 != legend) widgets = legend->legendWidgets (chart->itemToInfo (this)); diff --git a/src/QwtCharts/QwtExtendedPlotZoomer.cpp b/src/QwtCharts/QwtExtendedPlotZoomer.cpp index 58f5fc8..af1e880 100644 --- a/src/QwtCharts/QwtExtendedPlotZoomer.cpp +++ b/src/QwtCharts/QwtExtendedPlotZoomer.cpp @@ -3,14 +3,15 @@ #include "QwtCharts/QwtChartPanel.h" #include +#include + #include #include using namespace std; -QwtExtendedPlotZoomer::QwtExtendedPlotZoomer ( - QwtPlotCanvas* canvas, bool doReplot) +QwtExtendedPlotZoomer::QwtExtendedPlotZoomer (QwtPlotCanvas* canvas, bool doReplot) : QwtPlotZoomer (canvas, doReplot), _chartPanel (0) { // Qwt 6 : initMousePattern (2) requis pour éviter que le zoomer réagisse à @@ -23,8 +24,7 @@ QwtExtendedPlotZoomer::QwtExtendedPlotZoomer ( } // QwtExtendedPlotZoomer::QwtExtendedPlotZoomer -QwtExtendedPlotZoomer::QwtExtendedPlotZoomer ( - int xAxis, int yAxis, QwtPlotCanvas* canvas, bool doReplot) +QwtExtendedPlotZoomer::QwtExtendedPlotZoomer (int xAxis, int yAxis, QwtPlotCanvas* canvas, bool doReplot) : QwtPlotZoomer (xAxis, yAxis, canvas, doReplot), _chartPanel (0) { // Qwt 6 : initMousePattern (2) requis pour éviter que le zoomer réagisse à @@ -44,8 +44,7 @@ QwtExtendedPlotZoomer::QwtExtendedPlotZoomer (const QwtExtendedPlotZoomer&) } // QwtExtendedPlotZoomer::QwtExtendedPlotZoomer -QwtExtendedPlotZoomer& QwtExtendedPlotZoomer::operator = ( - const QwtExtendedPlotZoomer& pr) +QwtExtendedPlotZoomer& QwtExtendedPlotZoomer::operator = (const QwtExtendedPlotZoomer& pr) { assert (0 && "QwtExtendedPlotZoomer::operator = is not allowed."); @@ -77,7 +76,7 @@ void QwtExtendedPlotZoomer::rescale ( ) if (0 == managedPlot) return; - const QwtDoubleRect& rect = zoomRect ( ); + const QRectF& rect = zoomRect ( ); if (rect == scaleRect ( )) return; diff --git a/src/QwtCharts/QwtExtendedScaleDraw.cpp b/src/QwtCharts/QwtExtendedScaleDraw.cpp index e0f6e20..2963bf8 100644 --- a/src/QwtCharts/QwtExtendedScaleDraw.cpp +++ b/src/QwtCharts/QwtExtendedScaleDraw.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include #include @@ -12,8 +14,7 @@ USING_STD static const Charset charset ("àéèùô"); USE_ENCODING_AUTODETECTION -QwtExtendedScaleDraw::QwtExtendedScaleDraw ( - unsigned char precision, char format) +QwtExtendedScaleDraw::QwtExtendedScaleDraw (unsigned char precision, char format) : QwtScaleDraw ( ), _precision (precision), _format (format), _isNumberOfDecimalsEnabled (false), _numberOfDecimals (3), _autoNumberOfDecimals (3) @@ -30,8 +31,7 @@ QwtExtendedScaleDraw::QwtExtendedScaleDraw (const QwtExtendedScaleDraw& qesd) } // QwtExtendedScaleDraw::QwtExtendedScaleDraw -QwtExtendedScaleDraw& QwtExtendedScaleDraw::operator = ( - const QwtExtendedScaleDraw& qesd) +QwtExtendedScaleDraw& QwtExtendedScaleDraw::operator = (const QwtExtendedScaleDraw& qesd) { cerr << __FILE__ << ' ' << __LINE__ << " QwtExtendedScaleDraw::operator = is not yet implemented for QWT 6.x." << endl; diff --git a/src/QwtCharts/QwtHistogramChartPanel.cpp b/src/QwtCharts/QwtHistogramChartPanel.cpp index 9dfaca4..4ba2a77 100644 --- a/src/QwtCharts/QwtHistogramChartPanel.cpp +++ b/src/QwtCharts/QwtHistogramChartPanel.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include diff --git a/src/QwtCharts/QwtHistogramCoordinatesPicker.cpp b/src/QwtCharts/QwtHistogramCoordinatesPicker.cpp index 390f42f..680de75 100644 --- a/src/QwtCharts/QwtHistogramCoordinatesPicker.cpp +++ b/src/QwtCharts/QwtHistogramCoordinatesPicker.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include // MAXDOUBLE @@ -132,7 +133,7 @@ void QwtHistogramCoordinatesPicker::updateFromPlot ( ) // Mise à jour de l'aire contenant la sélection : if (0 != _selectionRepresentation) { - QwtDoubleRect rect = _selectionRepresentation->boundingRect( ); + QRectF rect = _selectionRepresentation->boundingRect( ); if (true == rect.isValid ( )) { QRect area = transform (rect); @@ -227,7 +228,7 @@ bool QwtHistogramCoordinatesPicker::end (bool ok) } // QwtHistogramCoordinatesPicker::end -QwtText QwtHistogramCoordinatesPicker::trackerTextF (const QwtDoublePoint& p) const +QwtText QwtHistogramCoordinatesPicker::trackerTextF (const QPointF& p) const { QPoint pos = getCursorPos ( ); const QwtExtendedMultiBarChart* histogram = getHistogram ( ); @@ -237,8 +238,11 @@ QwtText QwtHistogramCoordinatesPicker::trackerTextF (const QwtDoublePoint& p) co double c = 0.; size_t num = 0; if (true == histogram->intersects (pos.x ( ), pos.y ( ), c, num)) +#ifdef QT_5 text.sprintf ("%.4f, %lu", c, num); // v 4.2.1 : %u -> %lu - +#else // QT_5 + text.asprintf ("%.4f, %lu", c, num); // v 4.2.1 : %u -> %lu +#endif // QT_5 return text; } // if (0 != histogram) diff --git a/src/QwtCharts/QwtPlotCurveCoordinatesPicker.cpp b/src/QwtCharts/QwtPlotCurveCoordinatesPicker.cpp index ba88a0c..994c15f 100644 --- a/src/QwtCharts/QwtPlotCurveCoordinatesPicker.cpp +++ b/src/QwtCharts/QwtPlotCurveCoordinatesPicker.cpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include #include #include // MAXDOUBLE @@ -25,11 +27,8 @@ double QwtPlotCurveCoordinatesPicker::_selectionDistance = 10; // -------------------------------------------------------------------------- -QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker ( - int xAxis, int yAxis, int selectionFlags, RubberBand rubberBand, - DisplayMode trackerMode, QwtPlot* plot) - : QwtPlotCoordinatesPicker ( - xAxis, yAxis, selectionFlags, rubberBand, trackerMode, plot), +QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker (int xAxis, int yAxis, int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QwtPlot* plot) + : QwtPlotCoordinatesPicker (xAxis, yAxis, selectionFlags, rubberBand, trackerMode, plot), _displayMode (QwtChartPanel::CARTESIAN), _userPointIndexes ( ), _selectionRepresentation (0), _originalCurve (0), _originalData (0) @@ -38,8 +37,7 @@ QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker ( } // QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker -QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker ( - const QwtPlotCurveCoordinatesPicker& picker) +QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker (const QwtPlotCurveCoordinatesPicker& picker) : QwtPlotCoordinatesPicker (0, 0 , 0, QwtPicker::NoRubberBand, QwtPicker::AlwaysOff,0), _displayMode (QwtChartPanel::CARTESIAN), _userPointIndexes ( ), _selectionRepresentation (0), @@ -49,8 +47,7 @@ QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker ( } // QwtPlotCurveCoordinatesPicker::QwtPlotCurveCoordinatesPicker (const QwtPlotCurveCoordinatesPicker& view) -QwtPlotCurveCoordinatesPicker& QwtPlotCurveCoordinatesPicker::operator = ( - const QwtPlotCurveCoordinatesPicker& picker) +QwtPlotCurveCoordinatesPicker& QwtPlotCurveCoordinatesPicker::operator = (const QwtPlotCurveCoordinatesPicker& picker) { assert (0 && "QwtPlotCurveCoordinatesPicker::operator = is not allowed."); return *this; @@ -65,8 +62,7 @@ QwtPlotCurveCoordinatesPicker::~QwtPlotCurveCoordinatesPicker ( ) } // QwtPlotCurveCoordinatesPicker::~QwtPlotCurveCoordinatesPicker -void QwtPlotCurveCoordinatesPicker::setDisplayMode ( - QwtChartPanel::DISPLAY_MODE mode) +void QwtPlotCurveCoordinatesPicker::setDisplayMode (QwtChartPanel::DISPLAY_MODE mode) { _displayMode = mode; } // QwtPlotCurveCoordinatesPicker::setDisplayMode @@ -149,8 +145,7 @@ void QwtPlotCurveCoordinatesPicker::clearSelection ( ) void QwtPlotCurveCoordinatesPicker::undoLastModifiedPoint ( ) { - if ((LINEAR_INTERPOLATION != getSelectionMode ( )) || - (false == allowCurveEdition ( ))) + if ((LINEAR_INTERPOLATION != getSelectionMode ( )) || (false == allowCurveEdition ( ))) return; if (0 != getSelectedCurve ( )) @@ -174,8 +169,8 @@ void QwtPlotCurveCoordinatesPicker::undoLastModifiedPoint ( ) it, getSelection ( ).selectedPointIndexes.end ( )); } - QwtArray xData (_originalData->size ( )); - QwtArray yData (_originalData->size ( )); + QVector xData (_originalData->size ( )); + QVector yData (_originalData->size ( )); // Recopie des points modifiés : size_t i = 0; if (0 != _userPointIndexes.size ( )) @@ -215,7 +210,7 @@ void QwtPlotCurveCoordinatesPicker::updateFromPlot ( ) // Mise à jour de l'aire contenant la sélection : if (0 != _selectionRepresentation) { - QwtDoubleRect rect = _selectionRepresentation->boundingRect( ); + QRectF rect = _selectionRepresentation->boundingRect( ); if (true == rect.isValid ( )) { QRect area = transform (rect); @@ -231,8 +226,7 @@ void QwtPlotCurveCoordinatesPicker::updateFromPlot ( ) } // QwtPlotCurveCoordinatesPicker::updateFromPlot -size_t QwtPlotCurveCoordinatesPicker::pointAtX ( - const QwtPlotCurve& curve, double x) const +size_t QwtPlotCurveCoordinatesPicker::pointAtX (const QwtPlotCurve& curve, double x) const { CHECK_NULL_PTR_ERROR (curve.data ( )) const QwtSeriesData& data = *curve.data ( ); @@ -260,8 +254,7 @@ QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectionRepresentation ( ) } // QwtPlotCurveCoordinatesPicker::getSelectionRepresentation -const QwtPlotCurve* - QwtPlotCurveCoordinatesPicker::getSelectionRepresentation ( ) const +const QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectionRepresentation ( ) const { return _selectionRepresentation; } // QwtPlotCurveCoordinatesPicker::getSelectionRepresentation @@ -284,26 +277,21 @@ void QwtPlotCurveCoordinatesPicker::widgetMousePressEvent (QMouseEvent* event) if (0 == _originalCurve) { UTF8String name (charset); - name << "original_" - << getSelectedCurve ( )->title ( ).text ( ).toStdString ( ); - _originalCurve = - QwtUtilities::cloneCurve (*getSelectedCurve ( ), name); + name << "original_" << getSelectedCurve ( )->title ( ).text ( ).toStdString ( ); + _originalCurve = QwtUtilities::cloneCurve (*getSelectedCurve ( ), name); _originalCurve->setPen (QPen (Qt::black)); _originalCurve->attach (getPlot ( )); } // if (0 == _originalCurve) QPoint previousPos = getCursorPos ( ); getCursorPos ( ) = event->pos ( ); - QwtDoublePoint p = invTransform (getCursorPos ( )); + QPointF p = invTransform (getCursorPos ( )); const size_t index = pointAtX (*getSelectedCurve ( ), p.x ( )); - const size_t lastIndex = - 0 == getSelection ( ).selectedPointIndexes.size ( ) ? - (size_t)-1 : getSelection ( ).selectedPointIndexes.back ( ); - if ((0 != getSelection ( ).selectedPointIndexes.size ( )) && - (index <= lastIndex)) + const size_t lastIndex = 0 == getSelection ( ).selectedPointIndexes.size ( ) ? (size_t)-1 : getSelection ( ).selectedPointIndexes.back ( ); + if ((0 != getSelection ( ).selectedPointIndexes.size ( )) && (index <= lastIndex)) return; - QwtArray xData (getSelectedCurve ( )->dataSize ( )); - QwtArray yData (getSelectedCurve ( )->dataSize ( )); + QVector xData (getSelectedCurve ( )->dataSize ( )); + QVector yData (getSelectedCurve ( )->dataSize ( )); // Recopie : for (size_t i = 0; i < getSelectedCurve ( )->dataSize ( ); i++) { @@ -317,12 +305,8 @@ void QwtPlotCurveCoordinatesPicker::widgetMousePressEvent (QMouseEvent* event) CHECK_NULL_PTR_ERROR (getSelectedCurve ( )->data ( )) QwtSeriesData& data= *(getSelectedCurve ( )->data ( )); const double dx = p.x ( ) - data.sample (lastIndex).x ( ); - const double a = dx < 1E-12 ? - MAXDOUBLE : - (p.y ( ) - data.sample (lastIndex).y ( )) / dx; - const double b = 0.5 * - (p.y ( ) + data.sample (lastIndex).y ( ) - - a * (p.x ( ) + data.sample (lastIndex).x ( ))); + const double a = dx < 1E-12 ? MAXDOUBLE : (p.y ( ) - data.sample (lastIndex).y ( )) / dx; + const double b = 0.5 * (p.y ( ) + data.sample (lastIndex).y ( ) - a * (p.x ( ) + data.sample (lastIndex).x ( ))); for (size_t i = lastIndex + 1; i < index; i++) { yData [i] = a * xData [i] + b; @@ -335,9 +319,7 @@ void QwtPlotCurveCoordinatesPicker::widgetMousePressEvent (QMouseEvent* event) getSelectedCurve ( )->setSamples (xData, yData); delete _selectionRepresentation; _selectionRepresentation = 0; createSelectionRepresentation ( ); - for (vector::const_iterator it = - getSelection ( ).selectedPointIndexes.begin( ); - getSelection ( ).selectedPointIndexes.end ( ) != it; it++) + for (vector::const_iterator it = getSelection ( ).selectedPointIndexes.begin( ); getSelection ( ).selectedPointIndexes.end ( ) != it; it++) emit pointModified (getSelection ( ).selectedCurveIndex, *it); } // if ((true == controlKeyPressed ( )) && (0 != getSelectedCurve ( )) } // QwtPlotCurveCoordinatesPicker::widgetMousePressEvent @@ -383,12 +365,10 @@ void QwtPlotCurveCoordinatesPicker::widgetMouseMoveEvent (QMouseEvent* event) { Qt::MouseButtons buttons = event->buttons ( ); if ((0 != (Qt::LeftButton & buttons)) && - (true == inSelectionArea ( - getCursorPos ( ).x ( ), getCursorPos ( ).y ( )))) + (true == inSelectionArea (getCursorPos ( ).x ( ), getCursorPos ( ).y ( )))) { event->accept ( ); // v 0.11.0 - moveSelection (getCursorPos ( ).x ( ) - previousPos.x ( ), - getCursorPos ( ).y ( ) - previousPos.y ( )); + moveSelection (getCursorPos ( ).x ( ) - previousPos.x ( ), getCursorPos ( ).y ( ) - previousPos.y ( )); } else selectCursor (event->pos ( )); // v 0.11.0 @@ -401,8 +381,7 @@ void QwtPlotCurveCoordinatesPicker::widgetMouseMoveEvent (QMouseEvent* event) void QwtPlotCurveCoordinatesPicker::begin ( ) { getInitialCursorPos ( ) = getCursorPos ( ); - if (false == inSelectionArea ( - getCursorPos ( ).x ( ), getCursorPos ( ).y ( ))) + if (false == inSelectionArea (getCursorPos ( ).x ( ), getCursorPos ( ).y ( ))) if (LINEAR_INTERPOLATION != getSelectionMode ( )) clearSelection ( ); else @@ -425,8 +404,7 @@ bool QwtPlotCurveCoordinatesPicker::end (bool ok) return false; } // if (false == ok) - if (((size_t)-1 != getSelection ( ).selectedCurveIndex) && - (LINEAR_INTERPOLATION != getSelectionMode ( ))) + if (((size_t)-1 != getSelection ( ).selectedCurveIndex) && (LINEAR_INTERPOLATION != getSelectionMode ( ))) return QwtPlotPicker::end (ok); switch (getSelectionMode ( )) @@ -451,8 +429,7 @@ bool QwtPlotCurveCoordinatesPicker::curveEnd (bool ok) const QwtPlotItemList& itemList = plot->itemList ( ); size_t curveIndex = (size_t)-1; double distance = _selectionDistance; - for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); - it++) + for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); it++) { if ((*it)->rtti ( ) == QwtPlotItem::Rtti_PlotCurve) { @@ -498,10 +475,8 @@ bool QwtPlotCurveCoordinatesPicker::curveEnd (bool ok) getSelection ( ).x2 = selectedCurve->maxXValue ( ); getSelection ( ).y2 = selectedCurve->maxYValue ( ); getViewportSelectionArea ( ).setCoords ( - selectedCurve->minXValue ( ) - (int)_selectionDistance, - selectedCurve->minYValue ( ) - (int)_selectionDistance, - selectedCurve->maxXValue ( ) + (int)_selectionDistance, - selectedCurve->maxYValue ( ) + (int)_selectionDistance); + selectedCurve->minXValue ( ) - (int)_selectionDistance, selectedCurve->minYValue ( ) - (int)_selectionDistance, + selectedCurve->maxXValue ( ) + (int)_selectionDistance, selectedCurve->maxYValue ( ) + (int)_selectionDistance); plot->canvas ( )->setCursor (Qt::ClosedHandCursor); createSelectionRepresentation ( ); } @@ -523,8 +498,7 @@ bool QwtPlotCurveCoordinatesPicker::pointEnd (bool ok) size_t curveIndex = (size_t)-1; size_t pointIndex = (size_t)-1; double distance = _selectionDistance; - for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); - it++) + for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); it++) { if ((*it)->rtti ( ) == QwtPlotItem::Rtti_PlotCurve) { @@ -551,14 +525,10 @@ bool QwtPlotCurveCoordinatesPicker::pointEnd (bool ok) if (0 != selectedCurve) { getSelection ( ).selectedPointIndexes.push_back (pointIndex); - QPoint point = transform ( - QwtDoublePoint (selectedCurve->sample (pointIndex).x ( ), - selectedCurve->sample (pointIndex).y ( ))); + QPoint point = transform (QPointF (selectedCurve->sample (pointIndex).x ( ), selectedCurve->sample (pointIndex).y ( ))); getViewportSelectionArea ( ).setCoords ( - point.x ( ) - (int)_selectionDistance, - point.y ( ) - (int)_selectionDistance, - point.x ( ) + (int)_selectionDistance, - point.y ( ) + (int)_selectionDistance); + point.x ( ) - (int)_selectionDistance, point.y ( ) - (int)_selectionDistance, + point.x ( ) + (int)_selectionDistance, point.y ( ) + (int)_selectionDistance); getSelection ( ).x1 = getSelection ( ).x2 = selectedCurve->sample(pointIndex).x(); getSelection ( ).y1 = getSelection ( ).y2 = selectedCurve->sample(pointIndex).y(); plot->canvas ( )->setCursor (Qt::ClosedHandCursor); @@ -608,9 +578,7 @@ bool QwtPlotCurveCoordinatesPicker::rectEnd (bool ok) const int number = c->dataSize ( ); for (int i = 0; i < number; i++) { - QPoint point = transform ( - QwtDoublePoint (c->sample (i).x ( ), - c->sample (i).y ( ))); + QPoint point = transform (QPointF (c->sample (i).x ( ), c->sample (i).y ( ))); if (true == rectangle.contains (point.x ( ), point.y ( ))) { getSelection ( ).selectedPointIndexes.push_back (i); @@ -629,12 +597,10 @@ bool QwtPlotCurveCoordinatesPicker::rectEnd (bool ok) if ((size_t)-1 != getSelection ( ).selectedCurveIndex) { plot->canvas ( )->setCursor (Qt::ClosedHandCursor); - QwtDoublePoint dPoint = - invTransform (QPoint (rectangle.x ( ), rectangle.y( ))); + QPointF dPoint = invTransform (QPoint (rectangle.x ( ), rectangle.y( ))); getSelection ( ).x1 = dPoint.x ( ); getSelection ( ).y1 = dPoint.y ( ); - dPoint = invTransform (QPoint (rectangle.x ( ) + rectangle.width ( ), - rectangle.y ( ) + rectangle.height( ))); + dPoint = invTransform (QPoint (rectangle.x ( ) + rectangle.width ( ), rectangle.y ( ) + rectangle.height( ))); getSelection ( ).x2 = dPoint.x ( ); getSelection ( ).y2 = dPoint.y ( ); getViewportSelectionArea ( ) = rectangle; @@ -671,28 +637,33 @@ bool QwtPlotCurveCoordinatesPicker::linearInterpolationEnd (bool ok) } // QwtPlotCurveCoordinatesPicker::linearInterpolationEnd -QwtText QwtPlotCurveCoordinatesPicker::trackerText ( - const QwtDoublePoint& pos) const +QwtText QwtPlotCurveCoordinatesPicker::trackerText (const QPointF& pos) const { QString label; switch (getDisplayMode ( )) { case QwtChartPanel::CARTESIAN : +#ifdef QT_5 label.sprintf ("%.4g %.4g", pos.x ( ), pos.y ( )); +#else // QT_5 + label.asprintf ("%.4g %.4g", pos.x ( ), pos.y ( )); +#endif // QT_5 break; case QwtChartPanel::POLAR : { - const double radius = - sqrt (pos.x ( ) * pos.x ( ) + pos.y ( ) * pos.y ( )); - double angle = 0. == pos.x ( ) ? - 0 : atan (pos.y ( ) / pos.x ( )) * 180. / M_PI; + const double radius = sqrt (pos.x ( ) * pos.x ( ) + pos.y ( ) * pos.y ( )); + double angle = 0. == pos.x ( ) ? 0 : atan (pos.y ( ) / pos.x ( )) * 180. / M_PI; if (pos.x ( ) < 0.) angle = 180. + angle; else if (pos.y ( ) < 0.) angle = 360. + angle; +#ifdef QT_5 label.sprintf ("%.4g %.4g", angle, radius); +#else // QT_5 + label.asprintf ("%.4g %.4g", angle, radius); +#endif // QT_5 break; } // case POLAR } // switch (getDisplayMode ( )) @@ -722,8 +693,7 @@ void QwtPlotCurveCoordinatesPicker::updateSelection ( ) getSelection ( ).selectedPointIndexes.push_back (i); break; case POINT : - if ((1 != getSelection ( ).selectedPointIndexes.size ( )) || - ((0 != getSelection ( ).selectedPointIndexes.size ( )) && + if ((1 != getSelection ( ).selectedPointIndexes.size ( )) || ((0 != getSelection ( ).selectedPointIndexes.size ( )) && (getSelection ( ).selectedPointIndexes[0] >= curve->dataSize()))) clearSelection ( ); @@ -735,13 +705,10 @@ void QwtPlotCurveCoordinatesPicker::updateSelection ( ) // On refait la sélection complète (y a-t-il eu // addition/suppression et/ou déplacement de points ? getSelection ( ).selectedPointIndexes.clear ( ); - QRectF selectionArea (getSelection ( ).x1, getSelection ( ).y1, - getSelection ( ).x2 - getSelection ( ).x1, - getSelection ( ).y2 - getSelection ( ).y1);; + QRectF selectionArea (getSelection ( ).x1, getSelection ( ).y1, getSelection ( ).x2 - getSelection ( ).x1, getSelection ( ).y2 - getSelection ( ).y1); for (i = 0; i < curve->dataSize ( ); i++) { - if (true == selectionArea.contains ( - curve->sample (i).x ( ), curve->sample (i).y ( ))) + if (true == selectionArea.contains (curve->sample (i).x ( ), curve->sample (i).y ( ))) getSelection ( ).selectedPointIndexes.push_back (i); } } @@ -755,15 +722,11 @@ void QwtPlotCurveCoordinatesPicker::updateSelection ( ) } catch (const Exception& exc) { - cout << "Erreur interne dans QwtPlotCurveCoordinatesPicker::updateSelection " - << "(" << __FILE__ << ' ' << __LINE__ << ") : " - << exc.getFullMessage ( ) << endl; + cout << "Erreur interne dans QwtPlotCurveCoordinatesPicker::updateSelection " << "(" << __FILE__ << ' ' << __LINE__ << ") : " << exc.getFullMessage ( ) << endl; } catch (...) { - cout << "Erreur interne dans QwtPlotCurveCoordinatesPicker::updateSelection " - << "(" << __FILE__ << ' ' << __LINE__ << ") : " - << "Erreur non documentée." << endl; + cout << "Erreur interne dans QwtPlotCurveCoordinatesPicker::updateSelection " << "(" << __FILE__ << ' ' << __LINE__ << ") : " << "Erreur non documentée." << endl; } } // QwtPlotCurveCoordinatesPicker::updateSelection @@ -779,8 +742,7 @@ bool QwtPlotCurveCoordinatesPicker::inSelectionArea (int x, int y) const void QwtPlotCurveCoordinatesPicker::moveSelection (int dx, int dy) { - if (((0 == dx) && (0 == dy)) || - (0 == getSelection ( ).selectedPointIndexes.size ( ))) + if (((0 == dx) && (0 == dy)) || (0 == getSelection ( ).selectedPointIndexes.size ( ))) return; assert (0 != _selectionRepresentation); @@ -789,10 +751,10 @@ void QwtPlotCurveCoordinatesPicker::moveSelection (int dx, int dy) if ((0 == curve) || (0 == plot)) return; - QwtArray xData (curve->dataSize ( )); - QwtArray yData (curve->dataSize ( )); - QwtArray xSelData (_selectionRepresentation->dataSize ( )); - QwtArray ySelData (_selectionRepresentation->dataSize ( )); + QVector xData (curve->dataSize ( )); + QVector yData (curve->dataSize ( )); + QVector xSelData (_selectionRepresentation->dataSize ( )); + QVector ySelData (_selectionRepresentation->dataSize ( )); size_t i = 0, sel = 0; // Recopie : for (i = 0; i < curve->dataSize ( ); i++) @@ -804,16 +766,13 @@ void QwtPlotCurveCoordinatesPicker::moveSelection (int dx, int dy) // Déplacement des points sélectionnés : int xMin = INT_MAX, xMax = INT_MIN; int yMin = INT_MAX, yMax = INT_MIN; - for (vector::const_iterator it = - getSelection ( ).selectedPointIndexes.begin ( ); + for (vector::const_iterator it = getSelection ( ).selectedPointIndexes.begin ( ); getSelection ( ).selectedPointIndexes.end ( ) != it; it++, sel++) { - QPoint point = transform ( - QwtDoublePoint (curve->sample (*it).x ( ), - curve->sample (*it).y ( ))); + QPoint point = transform (QPointF (curve->sample (*it).x ( ), curve->sample (*it).y ( ))); point.setX (point.x ( ) + dx); point.setY (point.y ( ) + dy); - QwtDoublePoint dPoint = invTransform (point); + QPointF dPoint = invTransform (point); if (true == allowAbscissaTranslation ( )) xData [*it] = xSelData [sel] = dPoint.x ( ); else @@ -831,11 +790,8 @@ void QwtPlotCurveCoordinatesPicker::moveSelection (int dx, int dy) _selectionRepresentation->setSamples (xSelData, ySelData); plot->replot ( ); // +- 100 : on s'accorde une marge pour les déplacements rapides de souris. - getViewportSelectionArea ( ).setCoords ( - xMin - 100, yMin - 100, xMax + 100, yMax + 100); - for (vector::const_iterator it = - getSelection ( ).selectedPointIndexes.begin ( ); - getSelection ( ).selectedPointIndexes.end ( ) != it; it++, sel++) + getViewportSelectionArea ( ).setCoords (xMin - 100, yMin - 100, xMax + 100, yMax + 100); + for (vector::const_iterator it = getSelection ( ).selectedPointIndexes.begin ( ); getSelection ( ).selectedPointIndexes.end ( ) != it; it++, sel++) { emit pointModified (getSelection ( ).selectedCurveIndex, *it); } // for (vector::const_iterator it = ... @@ -844,8 +800,7 @@ void QwtPlotCurveCoordinatesPicker::moveSelection (int dx, int dy) QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) { - if (((size_t)-1 == getSelection ( ).selectedCurveIndex) || - (0 == getPlot ( ))) + if (((size_t)-1 == getSelection ( ).selectedCurveIndex) || (0 == getPlot ( ))) return 0; const QwtPlotItemList& itemList = getPlot ( )->itemList ( ); @@ -853,10 +808,8 @@ QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) if (getSelection ( ).selectedCurveIndex >= itemList.size ( )) { UTF8String mess (charset); - mess << "Erreur interne en " << __FILE__ << ' ' << (unsigned long)__LINE__ - << " QwtPlotCurveCoordinatesPicker::getSelectedCurve. " - << "Incohérence entre le numéro de courbe sélectionnée et le " - << "contenu du graphique."; + mess << "Erreur interne en " << __FILE__ << ' ' << (unsigned long)__LINE__ << " QwtPlotCurveCoordinatesPicker::getSelectedCurve. " + << "Incohérence entre le numéro de courbe sélectionnée et le contenu du graphique."; ConsoleOutput::cerr ( ) << mess << co_endl; return 0; } // if (getSelection ( ).selectedCurveIndex >= itemList.size ( )) @@ -881,8 +834,7 @@ QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) const QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) const { - if (((size_t)-1 == getSelection ( ).selectedCurveIndex) || - (0 == getPlot ( ))) + if (((size_t)-1 == getSelection ( ).selectedCurveIndex) || (0 == getPlot ( ))) return 0; const QwtPlotItemList& itemList = getPlot ( )->itemList ( ); @@ -890,15 +842,12 @@ const QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) const if (getSelection ( ).selectedCurveIndex >= itemList.size ( )) { UTF8String mess (charset); - mess << "Erreur interne en " << __FILE__ << ' ' << (unsigned long)__LINE__ - << " QwtPlotCurveCoordinatesPicker::getSelectedCurve. " - << "Incohérence entre le numéro de courbe sélectionnée et le " - << "contenu du graphique."; + mess << "Erreur interne en " << __FILE__ << ' ' << (unsigned long)__LINE__ << " QwtPlotCurveCoordinatesPicker::getSelectedCurve. " + << "Incohérence entre le numéro de courbe sélectionnée et le contenu du graphique."; ConsoleOutput::cerr ( ) << mess << co_endl; return 0; } // if (getSelection ( ).selectedCurveIndex >= itemList.size ( )) - for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); - it++) + for (QwtPlotItemIterator it = itemList.begin ( ); it != itemList.end( ); it++) { if ((*it)->rtti ( ) == QwtPlotItem::Rtti_PlotCurve) { @@ -916,8 +865,7 @@ const QwtPlotCurve* QwtPlotCurveCoordinatesPicker::getSelectedCurve ( ) const } // QwtPlotCurveCoordinatesPicker::getSelectedCurve -void QwtPlotCurveCoordinatesPicker::getSelectionArea ( - double& x1, double& y1, double& x2, double& y2) const +void QwtPlotCurveCoordinatesPicker::getSelectionArea (double& x1, double& y1, double& x2, double& y2) const { if (0 == _selectionRepresentation) throw Exception ("QwtPlotCurveCoordinatesPicker::getSelectionArea : absence de sélection."); @@ -947,9 +895,8 @@ void QwtPlotCurveCoordinatesPicker::getSelectionExtrema ( else { CHECK_NULL_PTR_ERROR (_selectionRepresentation->data ( )) - const QwtSeriesData& data = - *_selectionRepresentation->data ( ); - const QwtDoubleRect rect = data.boundingRect ( ); + const QwtSeriesData& data = *_selectionRepresentation->data ( ); + const QRectF rect = data.boundingRect ( ); xmin = rect.left ( ); ymin = rect.top ( ); xmax = rect.right ( ); @@ -965,21 +912,16 @@ void QwtPlotCurveCoordinatesPicker::createSelectionRepresentation ( ) return; QColor selectionColor (255, 125, 0); _selectionRepresentation = new QwtPlotCurve ("Selection"); - _selectionRepresentation->setItemAttribute ( - QwtPlotItem::Legend, getChartPanel ( )->isSelectionLegendShown ( )); + _selectionRepresentation->setItemAttribute (QwtPlotItem::Legend, getChartPanel ( )->isSelectionLegendShown ( )); _selectionRepresentation->attach (getPlot ( )); _selectionRepresentation->setPen (selectionColor); - AutoArrayPtr xData (getSelection ( ).selectedPointIndexes.size ( )), - yData (getSelection ( ).selectedPointIndexes.size ( )); + AutoArrayPtr xData (getSelection ( ).selectedPointIndexes.size ( )), yData (getSelection ( ).selectedPointIndexes.size ( )); for (size_t i = 0; i < getSelection ( ).selectedPointIndexes.size ( ); i++) { - xData [i] = getSelectedCurve ( )->sample ( - getSelection ( ).selectedPointIndexes [i]).x ( ); - yData [i] = getSelectedCurve ( )->sample ( - getSelection ( ).selectedPointIndexes [i]).y ( ); + xData [i] = getSelectedCurve ( )->sample (getSelection ( ).selectedPointIndexes [i]).x ( ); + yData [i] = getSelectedCurve ( )->sample (getSelection ( ).selectedPointIndexes [i]).y ( ); } // for (size_t i = 0; i < getSelection ( ).selectedPointIndexes.size ( ); i++) - _selectionRepresentation->setSamples (xData.get ( ), yData.get ( ), - getSelection ( ).selectedPointIndexes.size( )); + _selectionRepresentation->setSamples (xData.get ( ), yData.get ( ), getSelection ( ).selectedPointIndexes.size( )); const QwtSymbol* sym = getSelectedCurve ( )->symbol ( ); QwtSymbol* symbol = new QwtSymbol ( ); @@ -988,8 +930,7 @@ void QwtPlotCurveCoordinatesPicker::createSelectionRepresentation ( ) // Ecraser le symbol de la courbe originelle : QSize size = 0 == sym ? QSize (3, 3) : sym->size ( ); size = size + QSize (4, 4); - QwtUtilities::setSymbolAttributes ( - *symbol, QwtSymbol::Triangle, size, selectionColor, selectionColor); + QwtUtilities::setSymbolAttributes (*symbol, QwtSymbol::Triangle, size, selectionColor, selectionColor); _selectionRepresentation->setSymbol (symbol); getPlot ( )->replot (); diff --git a/src/QwtCharts/public/QwtCharts/QwtChartPanel.h b/src/QwtCharts/public/QwtCharts/QwtChartPanel.h index 620b31d..7e42928 100644 --- a/src/QwtCharts/public/QwtCharts/QwtChartPanel.h +++ b/src/QwtCharts/public/QwtCharts/QwtChartPanel.h @@ -936,9 +936,9 @@ class QwtChartPanel : public QWidget */ // Rem CP : le compilo moc ne tient pas compte des -D... // => on a ici 2 fonctions callbacks analogues de même signature car - // QwtDoubleRect est un typedef sur QRectF ... Mais ça ne marche pas au + // QRectF est un typedef sur QRectF ... Mais ça ne marche pas au // niveau de connect qui repose sur des strings. - virtual void zoomCallback_Qwt5 (const QwtDoubleRect&); + virtual void zoomCallback_Qwt5 (const QRectF&); virtual void zoomCallback_Qwt6 (const QRectF&); diff --git a/src/QwtCharts/public/QwtCharts/QwtHistogramCoordinatesPicker.h b/src/QwtCharts/public/QwtCharts/QwtHistogramCoordinatesPicker.h index 215711f..5e1c54c 100644 --- a/src/QwtCharts/public/QwtCharts/QwtHistogramCoordinatesPicker.h +++ b/src/QwtCharts/public/QwtCharts/QwtHistogramCoordinatesPicker.h @@ -5,7 +5,10 @@ #include // => QWT_VERSION +#ifdef QT_5 #include +#endif // QT_5 + #include "QwtCharts/QwtPlotCoordinatesPicker.h" @@ -13,14 +16,11 @@ class QwtHistogramChartPanel; class QwtExtendedMultiBarChart; /** - *

Classe de picker Qwt affichant les coordonnées pointées par la souris - * spécialisé pour des graphiques type Histogrammes.. + *

Classe de picker Qwt affichant les coordonnées pointées par la souris spécialisé pour des graphiques type Histogrammes.. * Permet la sélection d'entités de l'histogramme. *

- * @warning Les instances de cette classe ne sont pas informées des - * éventuels évènements pouvant survenir au niveau du graphique, - * tel qu'un zoom. Il convient d'appeler la méthode updateFromPlot - * dans de telles circonstances. + * @warning Les instances de cette classe ne sont pas informées des éventuels évènements pouvant survenir au niveau du graphique, + * tel qu'un zoom. Il convient d'appeler la méthode updateFromPlot dans de telles circonstances. */ class QwtHistogramCoordinatesPicker : public QwtPlotCoordinatesPicker { @@ -118,7 +118,6 @@ class QwtHistogramCoordinatesPicker : public QwtPlotCoordinatesPicker void pointModified (int curve, int point); - protected : /** @@ -145,7 +144,7 @@ class QwtHistogramCoordinatesPicker : public QwtPlotCoordinatesPicker * graphique. * @see getDisplayMode */ - virtual QwtText trackerTextF (const QwtDoublePoint& pos) const; // v 1.12.0 + virtual QwtText trackerTextF (const QPointF& pos) const; // v 1.12.0 /** * @return true si le point tranmis en argument est dans la zone diff --git a/src/QwtCharts/public/QwtCharts/QwtPlotCoordinatesPicker.h b/src/QwtCharts/public/QwtCharts/QwtPlotCoordinatesPicker.h index 2310a2e..91c217f 100644 --- a/src/QwtCharts/public/QwtCharts/QwtPlotCoordinatesPicker.h +++ b/src/QwtCharts/public/QwtCharts/QwtPlotCoordinatesPicker.h @@ -5,7 +5,9 @@ #include // => QWT_VERSION +#ifdef QT_5 #include +#endif // QT_5 #include #include diff --git a/src/QwtCharts/public/QwtCharts/QwtPlotCurveCoordinatesPicker.h b/src/QwtCharts/public/QwtCharts/QwtPlotCurveCoordinatesPicker.h index e35a78e..e4546a0 100644 --- a/src/QwtCharts/public/QwtCharts/QwtPlotCurveCoordinatesPicker.h +++ b/src/QwtCharts/public/QwtCharts/QwtPlotCurveCoordinatesPicker.h @@ -8,7 +8,10 @@ #include #include #include +#ifdef QT_5 #include +#endif // QT_5 + #include #include @@ -200,7 +203,7 @@ class QwtPlotCurveCoordinatesPicker : public QwtPlotCoordinatesPicker * graphique. * @see getDisplayMode */ - virtual QwtText trackerText (const QwtDoublePoint& pos) const; + virtual QwtText trackerText (const QPointF& pos) const; /** * Met à jour la sélection en fonction de ses paramètres et des courbes diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 00d6454..71dc448 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -2,9 +2,10 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) -find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) add_executable (qwt_test QtCurvesMainWindow.cpp curves_app.cpp public/QtCurvesMainWindow.h) # *.h for automoc ... set_property (TARGET qwt_test PROPERTY AUTOMOC ON) diff --git a/src/tests/QtCurvesMainWindow.cpp b/src/tests/QtCurvesMainWindow.cpp index 72a6d99..b3dd091 100644 --- a/src/tests/QtCurvesMainWindow.cpp +++ b/src/tests/QtCurvesMainWindow.cpp @@ -12,6 +12,7 @@ // Pour tests alphabet grec : #include +#include using namespace std; using namespace TkUtil; diff --git a/src/tests/curves_app.cpp b/src/tests/curves_app.cpp index 7702eca..df9cf17 100644 --- a/src/tests/curves_app.cpp +++ b/src/tests/curves_app.cpp @@ -6,10 +6,9 @@ int main (int argc, char* argv[]) { QApplication application (argc, argv); - QwtChartsManager::editionDialogHelpURL = - "classQwtCurveChartPanel.html"; + QwtChartsManager::editionDialogHelpURL = "classQwtCurveChartPanel.html"; QwtChartsManager::initialize ( ); -QwtChartPanel::legendCheckable = QwtLegendData::Checkable; + QwtChartPanel::legendCheckable = QwtLegendData::Checkable; QtChartsMainWindow* mainWindow = new QtChartsMainWindow (0); mainWindow->show ( ); return application.exec ( ); diff --git a/versions.txt b/versions.txt index c48e073..cb7a1c8 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,14 @@ A FAIRE : Affichage optionnel des symboles => option dans les panneaux. +Version 5.3.0 : 13/12/23 +=============== + +Portage Qt 6/GUIToolkitsVariables v 1.4.0/QtUtil v 6.4.0. +QwtDoublePoint -> QPointF +QwtDoubleRect -> QRectF + + Version 5.2.0 : 23/06/23 ===============