diff --git a/bora/src/SlicingPlotWidget.cpp b/bora/src/SlicingPlotWidget.cpp index 8959dc90..77272237 100644 --- a/bora/src/SlicingPlotWidget.cpp +++ b/bora/src/SlicingPlotWidget.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2015-2018, All Rights Reserved +// Copyright (c) Sorbonne Université 2015-2023, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -81,11 +81,20 @@ namespace Bora { : QWidget (parent) , _viewer (NULL) , _plot (new QwtPlot ()) +#if QWT_VERSION < 0x060000 + , _picker (new QwtPlotPicker( QwtPlot::xBottom // X Axis id. + , QwtPlot::yLeft // Y Axis id. + , QwtPicker::PointSelection + , QwtPicker::CrossRubberBand + , QwtPicker::ActiveOnly + , _plot->canvas()) ) +#else , _picker (new QwtPlotPicker( QwtPlot::xBottom // X Axis id. , QwtPlot::yLeft // Y Axis id. , QwtPicker::CrossRubberBand , QwtPicker::ActiveOnly , _plot->canvas()) ) +#endif , _gridDisplay (new QGridLayout()) , _gridLabel () // Label line 2: text , _widths (NULL) // Coordinates X for STreeCurve @@ -97,7 +106,9 @@ namespace Bora { , _paretoCurve (new QwtPlotCurve("Pareto")) // Black curve: pareto curve , _selectedPoint (new QwtPlotCurve("Selected")) // Red dot : selected placement { +#if QWT_VERSION >= 0x060000 _picker->setStateMachine(new QwtPickerClickPointMachine()); +#endif setStyleSheet ( "border: 0px" ); int ptSize = Graphics::isHighDpi() ? 2 : 2; @@ -134,7 +145,11 @@ namespace Bora { symbol->setStyle( QwtSymbol::Triangle ); symbol->setSize ( 6 ); symbol->setPen ( dotPen ); +#if QWT_VERSION < 0x060000 + _STreeCurve->setSymbol( *symbol ); +#else _STreeCurve->setSymbol( symbol ); +#endif QPen selectPen ( Qt::red ); selectPen.setWidth( ptSize+2 ); @@ -142,7 +157,11 @@ namespace Bora { _selectedPoint->setPen ( selectPen ); _selectedPoint->attach ( _plot ); +#if QWT_VERSION < 0x060000 + connect( _picker, SIGNAL(selected(const QwtDoublePoint&)), this, SLOT(onPointSelect(const QwtDoublePoint&)) ); +#else connect( _picker, SIGNAL(selected(const QPointF&)), this, SLOT(onPointSelect(const QPointF&)) ); +#endif QVBoxLayout* vLayout = new QVBoxLayout(); vLayout->addWidget ( _plot ); @@ -270,8 +289,13 @@ namespace Bora { i++; } +#if QWT_VERSION < 0x060000 + _STreeCurve->setData ( _widths , _heights , nodeSets->size() ); + _paretoCurve->setData( _pareto.xs(), _pareto.ys(), _pareto.size() ); +#else _STreeCurve->setSamples ( _widths , _heights , nodeSets->size() ); _paretoCurve->setSamples( _pareto.xs(), _pareto.ys(), _pareto.size() ); +#endif _STreeCurve->show(); _paretoCurve->show(); _plot->replot(); @@ -312,7 +336,11 @@ namespace Bora { } +#if QWT_VERSION < 0x060000 + void SlicingPlotWidget::onPointSelect ( const QwtDoublePoint& point ) +#else void SlicingPlotWidget::onPointSelect ( const QPointF& point ) +#endif { // Clicking on SlicingTree's Pareto Graph: // 1) Update slicing tree @@ -329,8 +357,13 @@ namespace Bora { cdebug.log(539) << " Selection: [" << point.x() << " " << point.y() << "]" << endl; if ( (iclosest >= 0) and (iclosest < dataSize) ) { +#if QWT_VERSION < 0x060000 + double x = _STreeCurve->x( iclosest ); + double y = _STreeCurve->y( iclosest ); +#else double x = _STreeCurve->sample( iclosest ).x(); double y = _STreeCurve->sample( iclosest ).y(); +#endif ostringstream message; message << "(" << DbU::getValueString(x) << "," << DbU::getValueString(y) << ")"; @@ -373,7 +406,11 @@ namespace Bora { _widthSelected [0] = x; _heightSelected[0] = y; +#if QWT_VERSION < 0x060000 + _selectedPoint->setData ( _widthSelected, _heightSelected, 1 ); +#else _selectedPoint->setSamples ( _widthSelected, _heightSelected, 1 ); +#endif _selectedPoint->show(); _plot->replot(); diff --git a/bora/src/bora/SlicingPlotWidget.h b/bora/src/bora/SlicingPlotWidget.h index ac2ad24d..c0ade9d4 100644 --- a/bora/src/bora/SlicingPlotWidget.h +++ b/bora/src/bora/SlicingPlotWidget.h @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2015-2018, All Rights Reserved +// Copyright (c) Sorbonne Université 2015-2023, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -10,13 +10,11 @@ // | Authors : Jean-Paul Chaput, Eric LAO | // | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | -// | C++ Header : "./bora/DSlicingNode.h" | +// | C++ Header : "./bora/SlicingPlotWidget.h" | // +-----------------------------------------------------------------+ -#ifndef BORA_SLICING_PLOT_WIDGET_H -#define BORA_SLICING_PLOT_WIDGET_H - +#pragma once //Work sround for older qwt releases #include #if QT_VERSION >= 0x050400 @@ -55,7 +53,11 @@ namespace Bora { void setViewer ( CellViewer* ); void setDatas (); public slots: +#if QWT_VERSION < 0x060000 + void onPointSelect ( const QwtDoublePoint& ); +#else void onPointSelect ( const QPointF& ); +#endif void updateSelectedPoint ( double x, double y ); signals: void updatePlacement ( BoxSet* ); @@ -78,5 +80,3 @@ namespace Bora { } // Bora namespace. - -#endif // BORA_SLICING_PLOT_WIDGET_H