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