Upgraded Qwt to 6.2 (branch: qwt-multiaxes) (#4427)

This commit is based on https://github.com/GoldenCheetah/GoldenCheetah/pull/3956
with the following additions / changes:
* Upgraded to the latest version of the multiaxes-branch, thus eliminating crashes of GoldenCheetah on startup
* Disabled the emitting of Layout Requests on geometry changes of QwtScaleWidget - without this, CPU utilization was up to 100% on one core
* Added the class SplineLookup, reusing small portions of code from Qwt 6.1
* Re-added the splines in WPrime and RideFile (resampling), using the new interface of QwtSpline
* Appveyor: qwt in cache-section now depends on qwt/qwtconfig.prin.in for refresh on version change
This commit is contained in:
Joachim Kohlhammer
2024-01-06 22:59:55 +01:00
committed by GitHub
parent ea044a0c39
commit 49cf6340a4
991 changed files with 63097 additions and 46278 deletions

View File

@@ -0,0 +1,103 @@
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "Plot.h"
#include <QwtPlotGraphicItem>
#include <QwtPlotLayout>
#include <QwtPlotPanner>
#include <QwtPlotMagnifier>
#include <QwtGraphic>
#define DEBUG_SCALE 0
#if DEBUG_SCALE
#include <QwtPlotGrid>
#endif
#include <QSvgRenderer>
#include <QFileDialog>
Plot::Plot( QWidget* parent )
: QwtPlot( parent )
, m_mapItem( NULL )
, m_mapRect( 0.0, 0.0, 100.0, 100.0 ) // something
{
#if DEBUG_SCALE
QwtPlotGrid* grid = new QwtPlotGrid();
grid->attach( this );
#else
/*
m_mapRect is only a reference for zooming, but
the ranges are nothing useful for the user. So we
hide the axes.
*/
plotLayout()->setCanvasMargin( 0 );
for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
setAxisVisible( axisPos, false );
#endif
/*
Navigation:
Left Mouse Button: Panning
Mouse Wheel: Zooming In/Out
Right Mouse Button: Reset to initial
*/
( void )new QwtPlotPanner( canvas() );
( void )new QwtPlotMagnifier( canvas() );
canvas()->setFocusPolicy( Qt::WheelFocus );
setCanvasBackground( Qt::white );
rescale();
}
#ifndef QT_NO_FILEDIALOG
void Plot::loadSVG()
{
QString dir;
const QString fileName = QFileDialog::getOpenFileName( NULL,
"Load a Scaleable Vector Graphic (SVG) Map",
dir, "SVG Files (*.svg)" );
if ( !fileName.isEmpty() )
loadSVG( fileName );
}
#endif
void Plot::loadSVG( const QString& fileName )
{
if ( m_mapItem == NULL )
{
m_mapItem = new QwtPlotGraphicItem();
m_mapItem->attach( this );
}
QwtGraphic graphic;
QSvgRenderer renderer;
if ( renderer.load( fileName ) )
{
QPainter p( &graphic );
renderer.render( &p );
}
m_mapItem->setGraphic( m_mapRect, graphic );
rescale();
replot();
}
void Plot::rescale()
{
setAxisScale( QwtAxis::XBottom, m_mapRect.left(), m_mapRect.right() );
setAxisScale( QwtAxis::YLeft, m_mapRect.top(), m_mapRect.bottom() );
}
#include "moc_Plot.cpp"

View File

@@ -0,0 +1,33 @@
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#pragma once
#include <QwtPlot>
#include <QRect>
class QwtPlotGraphicItem;
class Plot : public QwtPlot
{
Q_OBJECT
public:
Plot( QWidget* = NULL );
public Q_SLOTS:
#ifndef QT_NO_FILEDIALOG
void loadSVG();
#endif
void loadSVG( const QString& );
private:
void rescale();
QwtPlotGraphicItem* m_mapItem;
const QRectF m_mapRect;
};

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 92 KiB

View File

@@ -1,49 +1,65 @@
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include "plot.h"
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
class MainWindow: public QMainWindow
#include "Plot.h"
#include <QApplication>
#include <QMainWindow>
#ifndef QT_NO_FILEDIALOG
#include <QToolBar>
#include <QToolButton>
#endif
namespace
{
public:
MainWindow( const QString &fileName )
class MainWindow : public QMainWindow
{
Plot *plot = new Plot( this );
if ( !fileName.isEmpty() )
plot->loadSVG( fileName );
public:
MainWindow( const QString& fileName )
{
Plot* plot = new Plot( this );
if ( !fileName.isEmpty() )
plot->loadSVG( fileName );
setCentralWidget( plot );
setCentralWidget( plot );
#ifndef QT_NO_FILEDIALOG
QToolBar *toolBar = new QToolBar( this );
QToolButton* btnLoad = new QToolButton();
btnLoad->setText( "Load SVG" );
btnLoad->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
QToolButton *btnLoad = new QToolButton( toolBar );
QToolBar* toolBar = new QToolBar();
toolBar->addWidget( btnLoad );
addToolBar( toolBar );
btnLoad->setText( "Load SVG" );
btnLoad->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
toolBar->addWidget( btnLoad );
addToolBar( toolBar );
connect( btnLoad, SIGNAL( clicked() ), plot, SLOT( loadSVG() ) );
connect( btnLoad, SIGNAL(clicked()), plot, SLOT(loadSVG()) );
#endif
}
};
}
};
}
int main( int argc, char **argv )
int main( int argc, char* argv[] )
{
QApplication a( argc, argv );
QApplication app( argc, argv );
QString fileName;
if ( argc > 1 )
{
fileName = argv[1];
}
else
{
// see: https://commons.wikimedia.org/wiki/File:Schlosspark_Nymphenburg.svg
fileName = ":/svg/Schlosspark_Nymphenburg.svg";
}
MainWindow w( fileName );
w.resize( 600, 400 );
w.show();
MainWindow window( fileName );
window.resize( 600, 600 );
window.show();
int rv = a.exec();
return rv;
return app.exec();
}

View File

@@ -1,79 +0,0 @@
#include <qfiledialog.h>
#include <qwt_plot_svgitem.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_layout.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_magnifier.h>
#include "plot.h"
Plot::Plot( QWidget *parent ):
QwtPlot( parent ),
d_mapItem( NULL ),
d_mapRect( 0.0, 0.0, 100.0, 100.0 ) // something
{
#if 1
/*
d_mapRect is only a reference for zooming, but
the ranges are nothing useful for the user. So we
hide the axes.
*/
plotLayout()->setCanvasMargin( 0 );
for ( int axis = 0; axis < QwtAxis::PosCount; axis++ )
setAxisVisible( axis, false );
#else
QwtPlotGrid *grid = new QwtPlotGrid();
grid->attach( this );
#endif
/*
Navigation:
Left Mouse Button: Panning
Mouse Wheel: Zooming In/Out
Right Mouse Button: Reset to initial
*/
( void )new QwtPlotPanner( canvas() );
( void )new QwtPlotMagnifier( canvas() );
canvas()->setFocusPolicy( Qt::WheelFocus );
rescale();
}
#ifndef QT_NO_FILEDIALOG
void Plot::loadSVG()
{
QString dir;
const QString fileName = QFileDialog::getOpenFileName( NULL,
"Load a Scaleable Vector Graphic (SVG) Map",
dir, "SVG Files (*.svg)" );
if ( !fileName.isEmpty() )
loadSVG( fileName );
}
#endif
void Plot::loadSVG( const QString &fileName )
{
if ( d_mapItem == NULL )
{
d_mapItem = new QwtPlotSvgItem();
d_mapItem->attach( this );
}
d_mapItem->loadFile( d_mapRect, fileName );
rescale();
replot();
}
void Plot::rescale()
{
setAxisScale( QwtAxis::xBottom,
d_mapRect.left(), d_mapRect.right() );
setAxisScale( QwtAxis::yLeft,
d_mapRect.top(), d_mapRect.bottom() );
}

View File

@@ -1,26 +0,0 @@
#include <qwt_plot.h>
#include <qrect.h>
class QwtPlotSvgItem;
class Plot: public QwtPlot
{
Q_OBJECT
public:
Plot( QWidget * = NULL );
public Q_SLOTS:
#ifndef QT_NO_FILEDIALOG
void loadSVG();
#endif
void loadSVG( const QString & );
private:
void rescale();
QwtPlotSvgItem *d_mapItem;
const QRectF d_mapRect;
};

View File

@@ -1,26 +1,25 @@
################################################################
# Qwt Widget Library
# Copyright (C) 1997 Josef Wilgen
# Copyright (C) 2002 Uwe Rathmann
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the Qwt License, Version 1.0
################################################################
######################################################################
# Qwt Examples - Copyright (C) 2002 Uwe Rathmann
# This file may be used under the terms of the 3-clause BSD License
######################################################################
include( $${PWD}/../playground.pri )
!contains(QWT_CONFIG, QwtSvg) {
message(Are you trying to build Qwt with the Qt Creator as Shadow Build ?)
error(Qwt is configured without SVG support !)
greaterThan(QT_MAJOR_VERSION, 4) {
!qtHaveModule(svg) {
error("Qt has been built without SVG support !")
}
}
TARGET = svgmap
QT += svg
RESOURCES += \
svgmap.qrc
HEADERS = \
plot.h
Plot.h
SOURCES = \
plot.cpp \
Plot.cpp \
main.cpp

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/svg">
<file>Schlosspark_Nymphenburg.svg</file>
</qresource>
</RCC>