mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
QT5 -- remove old qwt
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
#include <qapplication.h>
|
||||
#include <qmainwindow.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qwindowsstyle.h>
|
||||
#include "plot.h"
|
||||
|
||||
class MainWindow: public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow(QWidget * = NULL);
|
||||
};
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent):
|
||||
QMainWindow(parent)
|
||||
{
|
||||
Plot *plot = new Plot(this);
|
||||
setCentralWidget(plot);
|
||||
|
||||
QToolBar *toolBar = new QToolBar(this);
|
||||
|
||||
QComboBox *rasterBox = new QComboBox(toolBar);
|
||||
rasterBox->setStyle(new QWindowsStyle() );
|
||||
rasterBox->addItem("Wikipedia");
|
||||
|
||||
toolBar->addWidget(new QLabel("Data ", toolBar));
|
||||
toolBar->addWidget(rasterBox);
|
||||
toolBar->addSeparator();
|
||||
|
||||
QComboBox *modeBox = new QComboBox(toolBar);
|
||||
modeBox->setStyle(new QWindowsStyle() );
|
||||
modeBox->addItem("Nearest Neighbour");
|
||||
modeBox->addItem("Bilinear Interpolation");
|
||||
|
||||
toolBar->addWidget(new QLabel("Resampling ", toolBar));
|
||||
toolBar->addWidget(modeBox);
|
||||
|
||||
toolBar->addSeparator();
|
||||
|
||||
QToolButton *btnExport = new QToolButton(toolBar);
|
||||
btnExport->setText("Export");
|
||||
btnExport->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
toolBar->addWidget(btnExport);
|
||||
|
||||
addToolBar(toolBar);
|
||||
|
||||
connect(modeBox, SIGNAL(activated(int)), plot, SLOT(setResampleMode(int)));
|
||||
connect(btnExport, SIGNAL(clicked()), plot, SLOT(exportPlot()) );
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.resize(600,400);
|
||||
mainWindow.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
#include "plot.h"
|
||||
#include <qwt_color_map.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
#include <qwt_plot_layout.h>
|
||||
#include <qwt_matrix_raster_data.h>
|
||||
#include <qwt_scale_widget.h>
|
||||
#include <qwt_plot_magnifier.h>
|
||||
#include <qwt_plot_panner.h>
|
||||
#include <qwt_plot_renderer.h>
|
||||
#include <qwt_plot_grid.h>
|
||||
#include <qwt_plot_canvas.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qimagewriter.h>
|
||||
|
||||
class RasterData: public QwtMatrixRasterData
|
||||
{
|
||||
public:
|
||||
RasterData()
|
||||
{
|
||||
const double matrix[] =
|
||||
{
|
||||
1, 2, 4, 1,
|
||||
6, 3, 5, 2,
|
||||
4, 2, 1, 5,
|
||||
5, 4, 2, 3
|
||||
};
|
||||
|
||||
QVector<double> values;
|
||||
for ( uint i = 0; i < sizeof(matrix) / sizeof(double); i++ )
|
||||
values += matrix[i];
|
||||
|
||||
const int numColumns = 4;
|
||||
setValueMatrix(values, numColumns);
|
||||
|
||||
setInterval( Qt::XAxis,
|
||||
QwtInterval( -0.5, 3.5, QwtInterval::ExcludeMaximum ) );
|
||||
setInterval( Qt::YAxis,
|
||||
QwtInterval( -0.5, 3.5, QwtInterval::ExcludeMaximum ) );
|
||||
setInterval( Qt::ZAxis, QwtInterval(1.0, 6.0) );
|
||||
}
|
||||
};
|
||||
|
||||
class ColorMap: public QwtLinearColorMap
|
||||
{
|
||||
public:
|
||||
ColorMap():
|
||||
QwtLinearColorMap(Qt::darkBlue, Qt::darkRed)
|
||||
{
|
||||
addColorStop(0.2, Qt::blue);
|
||||
addColorStop(0.4, Qt::cyan);
|
||||
addColorStop(0.6, Qt::yellow);
|
||||
addColorStop(0.8, Qt::red);
|
||||
}
|
||||
};
|
||||
|
||||
Plot::Plot(QWidget *parent):
|
||||
QwtPlot(parent)
|
||||
{
|
||||
#if 0
|
||||
QwtPlotGrid *grid = new QwtPlotGrid();
|
||||
grid->setPen(QPen(Qt::DotLine));
|
||||
grid->attach(this);
|
||||
#endif
|
||||
|
||||
d_spectrogram = new QwtPlotSpectrogram();
|
||||
d_spectrogram->setRenderThreadCount(0); // use system specific thread count
|
||||
|
||||
d_spectrogram->setColorMap( new ColorMap() );
|
||||
|
||||
d_spectrogram->setData(new RasterData());
|
||||
d_spectrogram->attach(this);
|
||||
|
||||
const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
|
||||
// A color bar on the right axis
|
||||
QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
|
||||
rightAxis->setColorBarEnabled(true);
|
||||
rightAxis->setColorBarWidth(40);
|
||||
rightAxis->setColorMap(zInterval, new ColorMap() );
|
||||
|
||||
setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
|
||||
enableAxis(QwtPlot::yRight);
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
setAxisScale(QwtPlot::xBottom, 0.0, 3.0);
|
||||
setAxisMaxMinor(QwtPlot::xBottom, 0);
|
||||
setAxisScale(QwtPlot::yLeft, 0.0, 3.0);
|
||||
setAxisMaxMinor(QwtPlot::yLeft, 0);
|
||||
|
||||
QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
|
||||
magnifier->setAxisEnabled( QwtPlot::yRight, false);
|
||||
|
||||
QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
|
||||
panner->setAxisEnabled( QwtPlot::yRight, false);
|
||||
|
||||
canvas()->setBorderRadius( 10 );
|
||||
}
|
||||
|
||||
void Plot::exportPlot()
|
||||
{
|
||||
QString fileName = "rasterview.pdf";
|
||||
|
||||
#ifndef QT_NO_FILEDIALOG
|
||||
const QList<QByteArray> imageFormats =
|
||||
QImageWriter::supportedImageFormats();
|
||||
|
||||
QStringList filter;
|
||||
filter += "PDF Documents (*.pdf)";
|
||||
#ifndef QWT_NO_SVG
|
||||
filter += "SVG Documents (*.svg)";
|
||||
#endif
|
||||
filter += "Postscript Documents (*.ps)";
|
||||
|
||||
if ( imageFormats.size() > 0 )
|
||||
{
|
||||
QString imageFilter("Images (");
|
||||
for ( int i = 0; i < imageFormats.size(); i++ )
|
||||
{
|
||||
if ( i > 0 )
|
||||
imageFilter += " ";
|
||||
imageFilter += "*.";
|
||||
imageFilter += imageFormats[i];
|
||||
}
|
||||
imageFilter += ")";
|
||||
|
||||
filter += imageFilter;
|
||||
}
|
||||
|
||||
fileName = QFileDialog::getSaveFileName(
|
||||
this, "Export File Name", fileName,
|
||||
filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite);
|
||||
#endif
|
||||
if ( !fileName.isEmpty() )
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.renderDocument(this, fileName, QSizeF(300, 200), 85);
|
||||
}
|
||||
}
|
||||
|
||||
void Plot::setResampleMode(int mode)
|
||||
{
|
||||
RasterData *data = (RasterData *)d_spectrogram->data();
|
||||
data->setResampleMode( (QwtMatrixRasterData::ResampleMode) mode);
|
||||
|
||||
replot();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_plot_spectrogram.h>
|
||||
|
||||
class Plot: public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot(QWidget * = NULL);
|
||||
|
||||
public Q_SLOTS:
|
||||
void exportPlot();
|
||||
void setResampleMode(int);
|
||||
|
||||
private:
|
||||
QwtPlotSpectrogram *d_spectrogram;
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
################################################################
|
||||
# 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
|
||||
################################################################
|
||||
|
||||
include( $${PWD}/../examples.pri )
|
||||
|
||||
TARGET = rasterview
|
||||
|
||||
HEADERS = \
|
||||
plot.h
|
||||
|
||||
SOURCES = \
|
||||
plot.cpp \
|
||||
main.cpp
|
||||
Reference in New Issue
Block a user