Add files from zip

This commit is contained in:
2023-10-31 09:22:42 +01:00
parent 6bacdc5f6d
commit 4dae68036f
2788 changed files with 492537 additions and 0 deletions

View File

@@ -0,0 +1,124 @@
/*****************************************************************************
* 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 <QwtColorMap>
#include <QwtPlotSpectrogram>
#include <QwtPlotLayout>
#include <QwtMatrixRasterData>
#include <QwtScaleWidget>
#include <QwtPlotMagnifier>
#include <QwtPlotPanner>
#include <QwtPlotRenderer>
#include <QwtPlotGrid>
#include <QwtPlotCanvas>
#include <QwtInterval>
namespace
{
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 )
{
QwtPlotCanvas* canvas = new QwtPlotCanvas();
canvas->setBorderRadius( 10 );
setCanvas( canvas );
#if 0
QwtPlotGrid* grid = new QwtPlotGrid();
grid->setPen( Qt::DotLine );
grid->attach( this );
#endif
m_spectrogram = new QwtPlotSpectrogram();
m_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count
m_spectrogram->setColorMap( new ColorMap() );
m_spectrogram->setData( new RasterData() );
m_spectrogram->attach( this );
const QwtInterval zInterval = m_spectrogram->data()->interval( Qt::ZAxis );
// A color bar on the right axis
QwtScaleWidget* rightAxis = axisWidget( QwtAxis::YRight );
rightAxis->setColorBarEnabled( true );
rightAxis->setColorBarWidth( 40 );
rightAxis->setColorMap( zInterval, new ColorMap() );
setAxisScale( QwtAxis::YRight, zInterval.minValue(), zInterval.maxValue() );
setAxisVisible( QwtAxis::YRight );
plotLayout()->setAlignCanvasToScales( true );
setAxisScale( QwtAxis::XBottom, 0.0, 3.0 );
setAxisMaxMinor( QwtAxis::XBottom, 0 );
setAxisScale( QwtAxis::YLeft, 0.0, 3.0 );
setAxisMaxMinor( QwtAxis::YLeft, 0 );
QwtPlotMagnifier* magnifier = new QwtPlotMagnifier( canvas );
magnifier->setAxisEnabled( QwtAxis::YRight, false );
QwtPlotPanner* panner = new QwtPlotPanner( canvas );
panner->setAxisEnabled( QwtAxis::YRight, false );
}
void Plot::exportPlot()
{
QwtPlotRenderer renderer;
renderer.exportTo( this, "rasterview.pdf" );
}
void Plot::setResampleMode( int mode )
{
RasterData* rasterData = static_cast< RasterData* >( m_spectrogram->data() );
rasterData->setResampleMode(
static_cast< QwtMatrixRasterData::ResampleMode >( mode ) );
replot();
}
#include "moc_Plot.cpp"

View File

@@ -0,0 +1,25 @@
/*****************************************************************************
* 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>
class QwtPlotSpectrogram;
class Plot : public QwtPlot
{
Q_OBJECT
public:
Plot( QWidget* = NULL );
public Q_SLOTS:
void exportPlot();
void setResampleMode( int );
private:
QwtPlotSpectrogram* m_spectrogram;
};

View File

@@ -0,0 +1,67 @@
/*****************************************************************************
* 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 <QApplication>
#include <QMainWindow>
#include <QToolBar>
#include <QToolButton>
#include <QComboBox>
#include <QLabel>
namespace
{
class MainWindow : public QMainWindow
{
public:
MainWindow( QWidget* parent = NULL )
: QMainWindow( parent )
{
Plot* plot = new Plot( this );
setCentralWidget( plot );
QToolBar* toolBar = new QToolBar( this );
QComboBox* rasterBox = new QComboBox( toolBar );
rasterBox->addItem( "Wikipedia" );
toolBar->addWidget( new QLabel( "Data ", toolBar ) );
toolBar->addWidget( rasterBox );
toolBar->addSeparator();
QComboBox* modeBox = new QComboBox( toolBar );
modeBox->addItem( "Nearest Neighbour" );
modeBox->addItem( "Bilinear Interpolation" );
modeBox->addItem( "Bicubic 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 app( argc, argv );
MainWindow window;
window.resize( 600, 400 );
window.show();
return app.exec();
}

View File

@@ -0,0 +1,15 @@
######################################################################
# Qwt Examples - Copyright (C) 2002 Uwe Rathmann
# This file may be used under the terms of the 3-clause BSD License
######################################################################
include( $${PWD}/../examples.pri )
TARGET = rasterview
HEADERS = \
Plot.h
SOURCES = \
Plot.cpp \
main.cpp