Add files from zip
This commit is contained in:
252
examples/animation/Plot.cpp
Normal file
252
examples/animation/Plot.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "Plot.h"
|
||||
|
||||
#include <QwtMath>
|
||||
#include <QwtSymbol>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtPlotLayout>
|
||||
|
||||
class Curve : public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
void setTransformation( const QTransform& transform )
|
||||
{
|
||||
m_transform = transform;
|
||||
}
|
||||
|
||||
virtual void updateSamples( double phase )
|
||||
{
|
||||
setSamples( m_transform.map( points( phase ) ) );
|
||||
}
|
||||
|
||||
private:
|
||||
virtual QPolygonF points( double phase ) const = 0;
|
||||
|
||||
private:
|
||||
QTransform m_transform;
|
||||
};
|
||||
|
||||
class Curve1 : public Curve
|
||||
{
|
||||
public:
|
||||
Curve1()
|
||||
{
|
||||
setPen( QColor( 150, 150, 200 ), 2 );
|
||||
setStyle( QwtPlotCurve::Lines );
|
||||
|
||||
setCurveAttribute( QwtPlotCurve::Fitted, true );
|
||||
|
||||
QwtSymbol* symbol = new QwtSymbol( QwtSymbol::XCross );
|
||||
symbol->setPen( Qt::yellow );
|
||||
symbol->setSize( 7 );
|
||||
|
||||
setSymbol( symbol );
|
||||
|
||||
// somewhere to the left
|
||||
QTransform transform;
|
||||
transform.scale( 1.5, 1.0 );
|
||||
transform.translate( 1.5, 3.0 );
|
||||
|
||||
setTransformation( transform );
|
||||
}
|
||||
|
||||
virtual QPolygonF points( double phase ) const QWT_OVERRIDE
|
||||
{
|
||||
QPolygonF points;
|
||||
|
||||
const int numSamples = 15;
|
||||
for ( int i = 0; i < numSamples; i++ )
|
||||
{
|
||||
const double v = 6.28 * double( i ) / double( numSamples - 1 );
|
||||
points += QPointF( std::sin( v - phase ), v );
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
};
|
||||
|
||||
class Curve2 : public Curve
|
||||
{
|
||||
public:
|
||||
Curve2()
|
||||
{
|
||||
setStyle( QwtPlotCurve::Sticks );
|
||||
setPen( QColor( 200, 150, 50 ) );
|
||||
|
||||
setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
|
||||
QColor( Qt::gray ), QColor( Qt::yellow ), QSize( 5, 5 ) ) );
|
||||
}
|
||||
|
||||
private:
|
||||
virtual QPolygonF points( double phase ) const QWT_OVERRIDE
|
||||
{
|
||||
QPolygonF points;
|
||||
|
||||
const int numSamples = 50;
|
||||
for ( int i = 0; i < numSamples; i++ )
|
||||
{
|
||||
const double v = 10.0 * i / double( numSamples - 1 );
|
||||
points += QPointF( v, std::cos( 3.0 * ( v + phase ) ) );
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
};
|
||||
|
||||
class Curve3 : public Curve
|
||||
{
|
||||
public:
|
||||
Curve3()
|
||||
{
|
||||
setStyle( QwtPlotCurve::Lines );
|
||||
setPen( QColor( 100, 200, 150 ), 2 );
|
||||
|
||||
setCurveAttribute( QwtPlotCurve::Fitted, true );
|
||||
|
||||
// somewhere in the top right corner
|
||||
QTransform transform;
|
||||
transform.translate( 7.0, 7.5 );
|
||||
transform.scale( 2.0, 2.0 );
|
||||
|
||||
setTransformation( transform );
|
||||
}
|
||||
|
||||
private:
|
||||
virtual QPolygonF points( double phase ) const QWT_OVERRIDE
|
||||
{
|
||||
QPolygonF points;
|
||||
|
||||
const int numSamples = 9;
|
||||
for ( int i = 0; i < numSamples; i++ )
|
||||
{
|
||||
const double v = i * 2.0 * M_PI / ( numSamples - 1 );
|
||||
points += QPointF( std::sin( v - phase ), std::cos( 3.0 * ( v + phase ) ) );
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
};
|
||||
|
||||
class Curve4 : public Curve
|
||||
{
|
||||
public:
|
||||
Curve4()
|
||||
{
|
||||
setStyle( QwtPlotCurve::Lines );
|
||||
setPen( Qt::red, 2 );
|
||||
|
||||
initSamples();
|
||||
|
||||
// somewhere in the center
|
||||
QTransform transform;
|
||||
transform.translate( 7.0, 3.0 );
|
||||
transform.scale( 1.5, 1.5 );
|
||||
|
||||
setTransformation( transform );
|
||||
}
|
||||
|
||||
private:
|
||||
virtual QPolygonF points( double phase ) const QWT_OVERRIDE
|
||||
{
|
||||
const double speed = 0.05;
|
||||
|
||||
const double s = speed * std::sin( phase );
|
||||
const double c = std::sqrt( 1.0 - s * s );
|
||||
|
||||
for ( int i = 0; i < m_points.size(); i++ )
|
||||
{
|
||||
const QPointF p = m_points[i];
|
||||
|
||||
const double u = p.x();
|
||||
const double v = p.y();
|
||||
|
||||
m_points[i].setX( u * c - v * s );
|
||||
m_points[i].setY( v * c + u * s );
|
||||
}
|
||||
|
||||
return m_points;
|
||||
}
|
||||
|
||||
void initSamples()
|
||||
{
|
||||
const int numSamples = 15;
|
||||
|
||||
for ( int i = 0; i < numSamples; i++ )
|
||||
{
|
||||
const double angle = i * ( 2.0 * M_PI / ( numSamples - 1 ) );
|
||||
|
||||
QPointF p( std::cos( angle ), std::sin( angle ) );
|
||||
if ( i % 2 )
|
||||
p *= 0.4;
|
||||
|
||||
m_points += p;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable QPolygonF m_points;
|
||||
};
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent)
|
||||
{
|
||||
setAutoReplot( false );
|
||||
|
||||
setTitle( "Animated Curves" );
|
||||
|
||||
// hide all axes
|
||||
for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
|
||||
setAxisVisible( axisPos, false );
|
||||
|
||||
plotLayout()->setCanvasMargin( 10 );
|
||||
|
||||
Curve* curve1 = new Curve1();
|
||||
curve1->attach( this );
|
||||
|
||||
Curve* curve2 = new Curve2();
|
||||
curve2->attach( this );
|
||||
|
||||
Curve* curve3 = new Curve3();
|
||||
curve3->attach( this );
|
||||
|
||||
Curve* curve4 = new Curve4();
|
||||
curve4->attach( this );
|
||||
|
||||
updateCurves();
|
||||
|
||||
m_timer.start();
|
||||
( void )startTimer( 40 );
|
||||
}
|
||||
|
||||
void Plot::timerEvent( QTimerEvent* )
|
||||
{
|
||||
updateCurves();
|
||||
replot();
|
||||
}
|
||||
|
||||
void Plot::updateCurves()
|
||||
{
|
||||
const double speed = 2 * M_PI / 25000.0; // a cycle every 25 seconds
|
||||
const double phase = m_timer.elapsed() * speed;
|
||||
|
||||
const QwtPlotItemList& items = itemList();
|
||||
for ( QwtPlotItemIterator it = items.constBegin();
|
||||
it != items.constEnd(); ++it )
|
||||
{
|
||||
QwtPlotItem* item = *it;
|
||||
|
||||
if ( item->rtti() == QwtPlotItem::Rtti_PlotCurve )
|
||||
{
|
||||
Curve* curve = dynamic_cast< Curve* >( item );
|
||||
curve->updateSamples( phase );
|
||||
}
|
||||
}
|
||||
}
|
||||
27
examples/animation/Plot.h
Normal file
27
examples/animation/Plot.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtPlot>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
public:
|
||||
Plot( QWidget* = NULL);
|
||||
|
||||
protected:
|
||||
virtual void timerEvent( QTimerEvent* ) QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateCurves();
|
||||
|
||||
QElapsedTimer m_timer;
|
||||
};
|
||||
19
examples/animation/animation.pro
Normal file
19
examples/animation/animation.pro
Normal file
@@ -0,0 +1,19 @@
|
||||
################################################################
|
||||
# Qwt Examples
|
||||
# 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 = animation
|
||||
|
||||
HEADERS = \
|
||||
Plot.h
|
||||
|
||||
SOURCES = \
|
||||
Plot.cpp \
|
||||
main.cpp
|
||||
56
examples/animation/main.cpp
Normal file
56
examples/animation/main.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "Plot.h"
|
||||
#include <QApplication>
|
||||
|
||||
#ifndef QWT_NO_OPENGL
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <qgl.h>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x050400
|
||||
#include <QwtPlotOpenGLCanvas>
|
||||
typedef QwtPlotOpenGLCanvas Canvas;
|
||||
#else
|
||||
#include <QwtPlotGLCanvas>
|
||||
typedef QwtPlotGLCanvas Canvas;
|
||||
#endif
|
||||
#else
|
||||
#include <QwtPlotCanvas>
|
||||
typedef QwtPlotCanvas Canvas;
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
class AminatedPlot : public Plot
|
||||
{
|
||||
public:
|
||||
AminatedPlot()
|
||||
{
|
||||
Canvas* canvas = new Canvas();
|
||||
canvas->setPaintAttribute( Canvas::BackingStore, false );
|
||||
canvas->setFrameStyle( QFrame::NoFrame );
|
||||
|
||||
setCanvas( canvas );
|
||||
setCanvasBackground( QColor( 30, 30, 50 ) );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
AminatedPlot plot;
|
||||
plot.resize( 400, 400 );
|
||||
plot.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
141
examples/barchart/BarChart.cpp
Normal file
141
examples/barchart/BarChart.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "BarChart.h"
|
||||
|
||||
#include <QwtPlotRenderer>
|
||||
#include <QwtPlotMultiBarChart>
|
||||
#include <QwtColumnSymbol>
|
||||
#include <QwtPlotLayout>
|
||||
#include <QwtLegend>
|
||||
#include <QwtScaleDraw>
|
||||
#include <QwtText>
|
||||
#include <QwtMath>
|
||||
|
||||
BarChart::BarChart( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
{
|
||||
setAutoFillBackground( true );
|
||||
|
||||
setPalette( Qt::white );
|
||||
canvas()->setPalette( QColor( "LemonChiffon" ) );
|
||||
|
||||
setTitle( "Bar Chart" );
|
||||
|
||||
setAxisTitle( QwtAxis::YLeft, "Whatever" );
|
||||
setAxisTitle( QwtAxis::XBottom, "Whatever" );
|
||||
|
||||
m_barChartItem = new QwtPlotMultiBarChart( "Bar Chart " );
|
||||
m_barChartItem->setLayoutPolicy( QwtPlotMultiBarChart::AutoAdjustSamples );
|
||||
m_barChartItem->setSpacing( 20 );
|
||||
m_barChartItem->setMargin( 3 );
|
||||
|
||||
m_barChartItem->attach( this );
|
||||
|
||||
insertLegend( new QwtLegend() );
|
||||
|
||||
populate();
|
||||
setOrientation( 0 );
|
||||
|
||||
setAutoReplot( true );
|
||||
}
|
||||
|
||||
void BarChart::populate()
|
||||
{
|
||||
static const char* colors[] = { "DarkOrchid", "SteelBlue", "Gold" };
|
||||
|
||||
const int numSamples = 5;
|
||||
const int numBars = sizeof( colors ) / sizeof( colors[0] );
|
||||
|
||||
QList< QwtText > titles;
|
||||
for ( int i = 0; i < numBars; i++ )
|
||||
{
|
||||
QString title("Bar %1");
|
||||
titles += title.arg( i );
|
||||
}
|
||||
m_barChartItem->setBarTitles( titles );
|
||||
m_barChartItem->setLegendIconSize( QSize( 10, 14 ) );
|
||||
|
||||
for ( int i = 0; i < numBars; i++ )
|
||||
{
|
||||
QwtColumnSymbol* symbol = new QwtColumnSymbol( QwtColumnSymbol::Box );
|
||||
symbol->setLineWidth( 2 );
|
||||
symbol->setFrameStyle( QwtColumnSymbol::Raised );
|
||||
symbol->setPalette( QPalette( colors[i] ) );
|
||||
|
||||
m_barChartItem->setSymbol( i, symbol );
|
||||
}
|
||||
|
||||
QVector< QVector< double > > series;
|
||||
for ( int i = 0; i < numSamples; i++ )
|
||||
{
|
||||
QVector< double > values;
|
||||
for ( int j = 0; j < numBars; j++ )
|
||||
values += ( 2 + qwtRand() % 8 );
|
||||
|
||||
series += values;
|
||||
}
|
||||
|
||||
m_barChartItem->setSamples( series );
|
||||
}
|
||||
|
||||
void BarChart::setMode( int mode )
|
||||
{
|
||||
if ( mode == 0 )
|
||||
{
|
||||
m_barChartItem->setStyle( QwtPlotMultiBarChart::Grouped );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_barChartItem->setStyle( QwtPlotMultiBarChart::Stacked );
|
||||
}
|
||||
}
|
||||
|
||||
void BarChart::setOrientation( int orientation )
|
||||
{
|
||||
int axis1, axis2;
|
||||
|
||||
if ( orientation == 0 )
|
||||
{
|
||||
axis1 = QwtAxis::XBottom;
|
||||
axis2 = QwtAxis::YLeft;
|
||||
|
||||
m_barChartItem->setOrientation( Qt::Vertical );
|
||||
}
|
||||
else
|
||||
{
|
||||
axis1 = QwtAxis::YLeft;
|
||||
axis2 = QwtAxis::XBottom;
|
||||
|
||||
m_barChartItem->setOrientation( Qt::Horizontal );
|
||||
}
|
||||
|
||||
setAxisScale( axis1, 0, m_barChartItem->dataSize() - 1, 1.0 );
|
||||
setAxisAutoScale( axis2 );
|
||||
|
||||
QwtScaleDraw* scaleDraw1 = axisScaleDraw( axis1 );
|
||||
scaleDraw1->enableComponent( QwtScaleDraw::Backbone, false );
|
||||
scaleDraw1->enableComponent( QwtScaleDraw::Ticks, false );
|
||||
|
||||
QwtScaleDraw* scaleDraw2 = axisScaleDraw( axis2 );
|
||||
scaleDraw2->enableComponent( QwtScaleDraw::Backbone, true );
|
||||
scaleDraw2->enableComponent( QwtScaleDraw::Ticks, true );
|
||||
|
||||
plotLayout()->setAlignCanvasToScale( axis1, true );
|
||||
plotLayout()->setAlignCanvasToScale( axis2, false );
|
||||
|
||||
plotLayout()->setCanvasMargin( 0 );
|
||||
updateCanvasMargins();
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
void BarChart::exportChart()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( this, "barchart.pdf" );
|
||||
}
|
||||
|
||||
#include "moc_BarChart.cpp"
|
||||
28
examples/barchart/BarChart.h
Normal file
28
examples/barchart/BarChart.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*****************************************************************************
|
||||
* 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 QwtPlotMultiBarChart;
|
||||
|
||||
class BarChart : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BarChart( QWidget* = NULL );
|
||||
|
||||
public Q_SLOTS:
|
||||
void setMode( int );
|
||||
void setOrientation( int );
|
||||
void exportChart();
|
||||
|
||||
private:
|
||||
void populate();
|
||||
|
||||
QwtPlotMultiBarChart* m_barChartItem;
|
||||
};
|
||||
15
examples/barchart/barchart.pro
Normal file
15
examples/barchart/barchart.pro
Normal 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 = barchart
|
||||
|
||||
SOURCES = \
|
||||
BarChart.cpp \
|
||||
main.cpp
|
||||
|
||||
HEADERS = \
|
||||
BarChart.h
|
||||
70
examples/barchart/main.cpp
Normal file
70
examples/barchart/main.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "BarChart.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
|
||||
namespace
|
||||
{
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow( QWidget* = NULL );
|
||||
};
|
||||
}
|
||||
|
||||
MainWindow::MainWindow( QWidget* parent )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
BarChart* chart = new BarChart();
|
||||
setCentralWidget( chart );
|
||||
|
||||
QToolBar* toolBar = new QToolBar();
|
||||
|
||||
QComboBox* typeBox = new QComboBox( toolBar );
|
||||
typeBox->addItem( "Grouped" );
|
||||
typeBox->addItem( "Stacked" );
|
||||
typeBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
QComboBox* orientationBox = new QComboBox( toolBar );
|
||||
orientationBox->addItem( "Vertical" );
|
||||
orientationBox->addItem( "Horizontal" );
|
||||
orientationBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
QToolButton* btnExport = new QToolButton( toolBar );
|
||||
btnExport->setText( "Export" );
|
||||
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
connect( btnExport, SIGNAL(clicked()), chart, SLOT(exportChart()) );
|
||||
|
||||
toolBar->addWidget( typeBox );
|
||||
toolBar->addWidget( orientationBox );
|
||||
toolBar->addWidget( btnExport );
|
||||
addToolBar( toolBar );
|
||||
|
||||
chart->setMode( typeBox->currentIndex() );
|
||||
connect( typeBox, SIGNAL(currentIndexChanged(int)),
|
||||
chart, SLOT(setMode(int)) );
|
||||
|
||||
chart->setOrientation( orientationBox->currentIndex() );
|
||||
connect( orientationBox, SIGNAL(currentIndexChanged(int)),
|
||||
chart, SLOT(setOrientation(int)) );
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
MainWindow window;
|
||||
|
||||
window.resize( 600, 400 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
87
examples/bode/ComplexNumber.h
Normal file
87
examples/bode/ComplexNumber.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
class ComplexNumber
|
||||
{
|
||||
public:
|
||||
ComplexNumber();
|
||||
ComplexNumber( double r, double i = 0.0 );
|
||||
|
||||
double real() const;
|
||||
double imag() const;
|
||||
|
||||
friend ComplexNumber operator*(
|
||||
const ComplexNumber&, const ComplexNumber& );
|
||||
|
||||
friend ComplexNumber operator+(
|
||||
const ComplexNumber&, const ComplexNumber& );
|
||||
|
||||
friend ComplexNumber operator-(
|
||||
const ComplexNumber&, const ComplexNumber& );
|
||||
friend ComplexNumber operator/(
|
||||
const ComplexNumber&, const ComplexNumber& );
|
||||
|
||||
private:
|
||||
double m_real;
|
||||
double m_imag;
|
||||
};
|
||||
|
||||
inline ComplexNumber::ComplexNumber()
|
||||
: m_real( 0.0 )
|
||||
, m_imag( -0.0 )
|
||||
{
|
||||
}
|
||||
|
||||
inline ComplexNumber::ComplexNumber( double re, double im )
|
||||
: m_real( re )
|
||||
, m_imag( im )
|
||||
{
|
||||
}
|
||||
|
||||
inline double ComplexNumber::real() const
|
||||
{
|
||||
return m_real;
|
||||
}
|
||||
|
||||
inline double ComplexNumber::imag() const
|
||||
{
|
||||
return m_imag;
|
||||
}
|
||||
|
||||
inline ComplexNumber operator+(
|
||||
const ComplexNumber& x1, const ComplexNumber& x2 )
|
||||
{
|
||||
return ComplexNumber( x1.m_real + x2.m_real, x1.m_imag + x2.m_imag );
|
||||
}
|
||||
|
||||
inline ComplexNumber operator-(
|
||||
const ComplexNumber& x1, const ComplexNumber& x2 )
|
||||
{
|
||||
return ComplexNumber( x1.m_real - x2.m_real, x1.m_imag - x2.m_imag );
|
||||
}
|
||||
|
||||
inline ComplexNumber operator*(
|
||||
const ComplexNumber& x1, const ComplexNumber& x2 )
|
||||
{
|
||||
return ComplexNumber( x1.m_real * x2.m_real - x1.m_imag * x2.m_imag,
|
||||
x1.m_real * x2.m_imag + x2.m_real * x1.m_imag );
|
||||
}
|
||||
|
||||
inline ComplexNumber operator/(
|
||||
const ComplexNumber& x1, const ComplexNumber& x2 )
|
||||
{
|
||||
double denom = x2.m_real * x2.m_real + x2.m_imag * x2.m_imag;
|
||||
|
||||
return ComplexNumber(
|
||||
( x1.m_real * x2.m_real + x1.m_imag * x2.m_imag ) / denom,
|
||||
( x1.m_imag * x2.m_real - x2.m_imag * x1.m_real ) / denom
|
||||
);
|
||||
}
|
||||
239
examples/bode/MainWindow.cpp
Normal file
239
examples/bode/MainWindow.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "MainWindow.h"
|
||||
#include "Plot.h"
|
||||
#include "Pixmaps.h"
|
||||
|
||||
#include <QwtCounter>
|
||||
#include <QwtPickerMachine>
|
||||
#include <QwtPlotZoomer>
|
||||
#include <QwtPlotPanner>
|
||||
#include <QwtPlotRenderer>
|
||||
#include <QwtText>
|
||||
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPen>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Zoomer : public QwtPlotZoomer
|
||||
{
|
||||
public:
|
||||
Zoomer( int xAxis, int yAxis, QWidget* canvas )
|
||||
: QwtPlotZoomer( xAxis, yAxis, canvas )
|
||||
{
|
||||
setTrackerMode( QwtPicker::AlwaysOff );
|
||||
setRubberBand( QwtPicker::NoRubberBand );
|
||||
|
||||
// RightButton: zoom out by 1
|
||||
// Ctrl+RightButton: zoom out to full size
|
||||
|
||||
setMousePattern( QwtEventPattern::MouseSelect2,
|
||||
Qt::RightButton, Qt::ControlModifier );
|
||||
setMousePattern( QwtEventPattern::MouseSelect3,
|
||||
Qt::RightButton );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
MainWindow::MainWindow( QWidget* parent )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
m_plot = new Plot( this );
|
||||
|
||||
const int margin = 5;
|
||||
m_plot->setContentsMargins( margin, margin, margin, 0 );
|
||||
|
||||
setContextMenuPolicy( Qt::NoContextMenu );
|
||||
|
||||
m_zoomer[0] = new Zoomer( QwtAxis::XBottom, QwtAxis::YLeft,
|
||||
m_plot->canvas() );
|
||||
m_zoomer[0]->setRubberBand( QwtPicker::RectRubberBand );
|
||||
m_zoomer[0]->setRubberBandPen( QColor( Qt::green ) );
|
||||
m_zoomer[0]->setTrackerMode( QwtPicker::ActiveOnly );
|
||||
m_zoomer[0]->setTrackerPen( QColor( Qt::white ) );
|
||||
|
||||
m_zoomer[1] = new Zoomer(
|
||||
QwtAxis::XTop, QwtAxis::YRight, m_plot->canvas() );
|
||||
|
||||
m_panner = new QwtPlotPanner( m_plot->canvas() );
|
||||
m_panner->setMouseButton( Qt::MiddleButton );
|
||||
|
||||
m_picker = new QwtPlotPicker( QwtAxis::XBottom, QwtAxis::YLeft,
|
||||
QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
|
||||
m_plot->canvas() );
|
||||
m_picker->setStateMachine( new QwtPickerDragPointMachine() );
|
||||
m_picker->setRubberBandPen( QColor( Qt::green ) );
|
||||
m_picker->setRubberBand( QwtPicker::CrossRubberBand );
|
||||
m_picker->setTrackerPen( QColor( Qt::white ) );
|
||||
|
||||
setCentralWidget( m_plot );
|
||||
|
||||
QToolBar* toolBar = new QToolBar( this );
|
||||
|
||||
QToolButton* btnZoom = new QToolButton( toolBar );
|
||||
btnZoom->setText( "Zoom" );
|
||||
btnZoom->setIcon( QPixmap( zoom_xpm ) );
|
||||
btnZoom->setCheckable( true );
|
||||
btnZoom->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
toolBar->addWidget( btnZoom );
|
||||
connect( btnZoom, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool)) );
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
QToolButton* btnPrint = new QToolButton( toolBar );
|
||||
btnPrint->setText( "Print" );
|
||||
btnPrint->setIcon( QPixmap( print_xpm ) );
|
||||
btnPrint->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
toolBar->addWidget( btnPrint );
|
||||
connect( btnPrint, SIGNAL(clicked()), SLOT(print()) );
|
||||
#endif
|
||||
|
||||
QToolButton* btnExport = new QToolButton( toolBar );
|
||||
btnExport->setText( "Export" );
|
||||
btnExport->setIcon( QPixmap( print_xpm ) );
|
||||
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
toolBar->addWidget( btnExport );
|
||||
connect( btnExport, SIGNAL(clicked()), SLOT(exportDocument()) );
|
||||
|
||||
toolBar->addSeparator();
|
||||
|
||||
QWidget* hBox = new QWidget( toolBar );
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout( hBox );
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( new QWidget( hBox ), 10 ); // spacer
|
||||
layout->addWidget( new QLabel( "Damping Factor", hBox ), 0 );
|
||||
layout->addSpacing( 10 );
|
||||
|
||||
QwtCounter* cntDamp = new QwtCounter( hBox );
|
||||
cntDamp->setRange( 0.0, 5.0 );
|
||||
cntDamp->setSingleStep( 0.01 );
|
||||
cntDamp->setValue( 0.0 );
|
||||
|
||||
layout->addWidget( cntDamp, 0 );
|
||||
|
||||
( void )toolBar->addWidget( hBox );
|
||||
|
||||
addToolBar( toolBar );
|
||||
#ifndef QT_NO_STATUSBAR
|
||||
( void )statusBar();
|
||||
#endif
|
||||
|
||||
enableZoomMode( false );
|
||||
showInfo();
|
||||
|
||||
connect( cntDamp, SIGNAL(valueChanged(double)),
|
||||
m_plot, SLOT(setDamp(double)) );
|
||||
|
||||
connect( m_picker, SIGNAL(moved(const QPoint&)),
|
||||
SLOT(moved(const QPoint&)) );
|
||||
connect( m_picker, SIGNAL(selected(const QPolygon&)),
|
||||
SLOT(selected(const QPolygon&)) );
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
void MainWindow::print()
|
||||
{
|
||||
QPrinter printer( QPrinter::HighResolution );
|
||||
|
||||
QString docName = m_plot->title().text();
|
||||
if ( !docName.isEmpty() )
|
||||
{
|
||||
docName.replace ( "\n", " -- " );
|
||||
printer.setDocName ( docName );
|
||||
}
|
||||
|
||||
printer.setCreator( "Bode example" );
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation( QPageLayout::Landscape );
|
||||
#else
|
||||
printer.setOrientation( QPrinter::Landscape );
|
||||
#endif
|
||||
|
||||
QPrintDialog dialog( &printer );
|
||||
if ( dialog.exec() )
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
|
||||
if ( printer.colorMode() == QPrinter::GrayScale )
|
||||
{
|
||||
renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground );
|
||||
renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasBackground );
|
||||
renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasFrame );
|
||||
renderer.setLayoutFlag( QwtPlotRenderer::FrameWithScales );
|
||||
}
|
||||
|
||||
renderer.renderTo( m_plot, printer );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void MainWindow::exportDocument()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( m_plot, "bode.pdf" );
|
||||
}
|
||||
|
||||
void MainWindow::enableZoomMode( bool on )
|
||||
{
|
||||
m_panner->setEnabled( on );
|
||||
|
||||
m_zoomer[0]->setEnabled( on );
|
||||
m_zoomer[0]->zoom( 0 );
|
||||
|
||||
m_zoomer[1]->setEnabled( on );
|
||||
m_zoomer[1]->zoom( 0 );
|
||||
|
||||
m_picker->setEnabled( !on );
|
||||
|
||||
showInfo();
|
||||
}
|
||||
|
||||
void MainWindow::showInfo( QString text )
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
{
|
||||
if ( m_picker->rubberBand() )
|
||||
text = "Cursor Pos: Press left mouse button in plot region";
|
||||
else
|
||||
text = "Zoom: Press mouse button and drag";
|
||||
}
|
||||
|
||||
#ifndef QT_NO_STATUSBAR
|
||||
statusBar()->showMessage( text );
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::moved( const QPoint& pos )
|
||||
{
|
||||
using namespace QwtAxis;
|
||||
|
||||
QString info( "Freq=%1, Ampl=%2, Phase=%3" );
|
||||
info = info.arg( m_plot->invTransform( XBottom, pos.x() ) );
|
||||
info = info.arg( m_plot->invTransform( YLeft, pos.y() ) );
|
||||
info = info.arg( m_plot->invTransform( YRight, pos.y() ) );
|
||||
|
||||
showInfo( info );
|
||||
}
|
||||
|
||||
void MainWindow::selected( const QPolygon& )
|
||||
{
|
||||
showInfo();
|
||||
}
|
||||
|
||||
#include "moc_MainWindow.cpp"
|
||||
46
examples/bode/MainWindow.h
Normal file
46
examples/bode/MainWindow.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QwtPlotZoomer;
|
||||
class QwtPlotPicker;
|
||||
class QwtPlotPanner;
|
||||
class Plot;
|
||||
class QPolygon;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow( QWidget* parent = 0 );
|
||||
|
||||
private Q_SLOTS:
|
||||
void moved( const QPoint& );
|
||||
void selected( const QPolygon& );
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void print();
|
||||
#endif
|
||||
|
||||
void exportDocument();
|
||||
void enableZoomMode( bool );
|
||||
|
||||
private:
|
||||
void showInfo( QString text = QString() );
|
||||
|
||||
Plot* m_plot;
|
||||
|
||||
QwtPlotZoomer* m_zoomer[2];
|
||||
QwtPlotPicker* m_picker;
|
||||
QwtPlotPanner* m_panner;
|
||||
};
|
||||
96
examples/bode/Pixmaps.h
Normal file
96
examples/bode/Pixmaps.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
static const char* print_xpm[] =
|
||||
{
|
||||
"32 32 12 1",
|
||||
"a c #ffffff",
|
||||
"h c #ffff00",
|
||||
"c c #ffffff",
|
||||
"f c #dcdcdc",
|
||||
"b c #c0c0c0",
|
||||
"j c #a0a0a4",
|
||||
"e c #808080",
|
||||
"g c #808000",
|
||||
"d c #585858",
|
||||
"i c #00ff00",
|
||||
"# c #000000",
|
||||
". c None",
|
||||
"................................",
|
||||
"................................",
|
||||
"...........###..................",
|
||||
"..........#abb###...............",
|
||||
".........#aabbbbb###............",
|
||||
".........#ddaaabbbbb###.........",
|
||||
"........#ddddddaaabbbbb###......",
|
||||
".......#deffddddddaaabbbbb###...",
|
||||
"......#deaaabbbddddddaaabbbbb###",
|
||||
".....#deaaaaaaabbbddddddaaabbbb#",
|
||||
"....#deaaabbbaaaa#ddedddfggaaad#",
|
||||
"...#deaaaaaaaaaa#ddeeeeafgggfdd#",
|
||||
"..#deaaabbbaaaa#ddeeeeabbbbgfdd#",
|
||||
".#deeefaaaaaaa#ddeeeeabbhhbbadd#",
|
||||
"#aabbbeeefaaa#ddeeeeabbbbbbaddd#",
|
||||
"#bbaaabbbeee#ddeeeeabbiibbadddd#",
|
||||
"#bbbbbaaabbbeeeeeeabbbbbbaddddd#",
|
||||
"#bjbbbbbbaaabbbbeabbbbbbadddddd#",
|
||||
"#bjjjjbbbbbbaaaeabbbbbbaddddddd#",
|
||||
"#bjaaajjjbbbbbbaaabbbbadddddddd#",
|
||||
"#bbbbbaaajjjbbbbbbaaaaddddddddd#",
|
||||
"#bjbbbbbbaaajjjbbbbbbddddddddd#.",
|
||||
"#bjjjjbbbbbbaaajjjbbbdddddddd#..",
|
||||
"#bjaaajjjbbbbbbjaajjbddddddd#...",
|
||||
"#bbbbbaaajjjbbbjbbaabdddddd#....",
|
||||
"###bbbbbbaaajjjjbbbbbddddd#.....",
|
||||
"...###bbbbbbaaajbbbbbdddd#......",
|
||||
"......###bbbbbbjbbbbbddd#.......",
|
||||
".........###bbbbbbbbbdd#........",
|
||||
"............###bbbbbbd#.........",
|
||||
"...............###bbb#..........",
|
||||
"..................###..........."
|
||||
};
|
||||
|
||||
|
||||
static const char* zoom_xpm[] =
|
||||
{
|
||||
"32 32 8 1",
|
||||
"# c #000000",
|
||||
"b c #c0c0c0",
|
||||
"a c #ffffff",
|
||||
"e c #585858",
|
||||
"d c #a0a0a4",
|
||||
"c c #0000ff",
|
||||
"f c #00ffff",
|
||||
". c None",
|
||||
"..######################........",
|
||||
".#a#baaaaaaaaaaaaaaaaaa#........",
|
||||
"#aa#baaaaaaaaaaaaaccaca#........",
|
||||
"####baaaaaaaaaaaaaaaaca####.....",
|
||||
"#bbbbaaaaaaaaaaaacccaaa#da#.....",
|
||||
"#aaaaaaaaaaaaaaaacccaca#da#.....",
|
||||
"#aaaaaaaaaaaaaaaaaccaca#da#.....",
|
||||
"#aaaaaaaaaabe###ebaaaaa#da#.....",
|
||||
"#aaaaaaaaa#########aaaa#da#.....",
|
||||
"#aaaaaaaa###dbbbb###aaa#da#.....",
|
||||
"#aaaaaaa###aaaaffb###aa#da#.....",
|
||||
"#aaaaaab##aaccaaafb##ba#da#.....",
|
||||
"#aaaaaae#daaccaccaad#ea#da#.....",
|
||||
"#aaaaaa##aaaaaaccaab##a#da#.....",
|
||||
"#aaaaaa##aacccaaaaab##a#da#.....",
|
||||
"#aaaaaa##aaccccaccab##a#da#.....",
|
||||
"#aaaaaae#daccccaccad#ea#da#.....",
|
||||
"#aaaaaab##aacccaaaa##da#da#.....",
|
||||
"#aaccacd###aaaaaaa###da#da#.....",
|
||||
"#aaaaacad###daaad#####a#da#.....",
|
||||
"#acccaaaad##########da##da#.....",
|
||||
"#acccacaaadde###edd#eda#da#.....",
|
||||
"#aaccacaaaabdddddbdd#eda#a#.....",
|
||||
"#aaaaaaaaaaaaaaaaaadd#eda##.....",
|
||||
"#aaaaaaaaaaaaaaaaaaadd#eda#.....",
|
||||
"#aaaaaaaccacaaaaaaaaadd#eda#....",
|
||||
"#aaaaaaaaaacaaaaaaaaaad##eda#...",
|
||||
"#aaaaaacccaaaaaaaaaaaaa#d#eda#..",
|
||||
"########################dd#eda#.",
|
||||
"...#dddddddddddddddddddddd##eda#",
|
||||
"...#aaaaaaaaaaaaaaaaaaaaaa#.####",
|
||||
"...########################..##."
|
||||
};
|
||||
197
examples/bode/Plot.cpp
Normal file
197
examples/bode/Plot.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "Plot.h"
|
||||
#include "ComplexNumber.h"
|
||||
|
||||
#include <QwtMath>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtSymbol>
|
||||
#include <QwtPlotGrid>
|
||||
#include <QwtPlotMarker>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtLegend>
|
||||
#include <QwtText>
|
||||
#include <QwtPlotCanvas>
|
||||
|
||||
static void logSpace( double* array, int size, double xmin, double xmax )
|
||||
{
|
||||
if ( ( xmin <= 0.0 ) || ( xmax <= 0.0 ) || ( size <= 0 ) )
|
||||
return;
|
||||
|
||||
const int imax = size - 1;
|
||||
|
||||
array[0] = xmin;
|
||||
array[imax] = xmax;
|
||||
|
||||
const double lxmin = log( xmin );
|
||||
const double lxmax = log( xmax );
|
||||
const double lstep = ( lxmax - lxmin ) / double( imax );
|
||||
|
||||
for ( int i = 1; i < imax; i++ )
|
||||
array[i] = std::exp( lxmin + double( i ) * lstep );
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
{
|
||||
setAutoReplot( false );
|
||||
|
||||
setTitle( "Frequency Response of a Second-Order System" );
|
||||
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
canvas->setBorderRadius( 10 );
|
||||
|
||||
setCanvas( canvas );
|
||||
setCanvasBackground( QColor( "MidnightBlue" ) );
|
||||
|
||||
// legend
|
||||
QwtLegend* legend = new QwtLegend;
|
||||
insertLegend( legend, QwtPlot::BottomLegend );
|
||||
|
||||
// grid
|
||||
QwtPlotGrid* grid = new QwtPlotGrid;
|
||||
grid->enableXMin( true );
|
||||
grid->setMajorPen( Qt::white, 0, Qt::DotLine );
|
||||
grid->setMinorPen( Qt::gray, 0, Qt::DotLine );
|
||||
grid->attach( this );
|
||||
|
||||
// axes
|
||||
setAxisVisible( QwtAxis::YRight );
|
||||
setAxisTitle( QwtAxis::XBottom, "Normalized Frequency" );
|
||||
setAxisTitle( QwtAxis::YLeft, "Amplitude [dB]" );
|
||||
setAxisTitle( QwtAxis::YRight, "Phase [deg]" );
|
||||
|
||||
setAxisMaxMajor( QwtAxis::XBottom, 6 );
|
||||
setAxisMaxMinor( QwtAxis::XBottom, 9 );
|
||||
setAxisScaleEngine( QwtAxis::XBottom, new QwtLogScaleEngine );
|
||||
|
||||
// curves
|
||||
m_curve1 = new QwtPlotCurve( "Amplitude" );
|
||||
m_curve1->setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
m_curve1->setPen( Qt::yellow );
|
||||
m_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine );
|
||||
m_curve1->setYAxis( QwtAxis::YLeft );
|
||||
m_curve1->attach( this );
|
||||
|
||||
m_curve2 = new QwtPlotCurve( "Phase" );
|
||||
m_curve2->setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
m_curve2->setPen( Qt::cyan );
|
||||
m_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine );
|
||||
m_curve2->setYAxis( QwtAxis::YRight );
|
||||
m_curve2->attach( this );
|
||||
|
||||
// marker
|
||||
m_marker1 = new QwtPlotMarker();
|
||||
m_marker1->setValue( 0.0, 0.0 );
|
||||
m_marker1->setLineStyle( QwtPlotMarker::VLine );
|
||||
m_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
|
||||
m_marker1->setLinePen( Qt::green, 0, Qt::DashDotLine );
|
||||
m_marker1->attach( this );
|
||||
|
||||
m_marker2 = new QwtPlotMarker();
|
||||
m_marker2->setLineStyle( QwtPlotMarker::HLine );
|
||||
m_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
|
||||
m_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine );
|
||||
m_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond,
|
||||
QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) );
|
||||
m_marker2->attach( this );
|
||||
|
||||
setDamp( 0.0 );
|
||||
|
||||
setAutoReplot( true );
|
||||
}
|
||||
|
||||
void Plot::showData( const double* frequency, const double* amplitude,
|
||||
const double* phase, int count )
|
||||
{
|
||||
m_curve1->setSamples( frequency, amplitude, count );
|
||||
m_curve2->setSamples( frequency, phase, count );
|
||||
}
|
||||
|
||||
void Plot::showPeak( double freq, double amplitude )
|
||||
{
|
||||
QString label( "Peak: " );
|
||||
label += QString::number( amplitude, 'g', 3 );
|
||||
label += " dB";
|
||||
|
||||
QwtText text( label );
|
||||
text.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
|
||||
text.setColor( QColor( 200, 150, 0 ) );
|
||||
|
||||
m_marker2->setValue( freq, amplitude );
|
||||
m_marker2->setLabel( text );
|
||||
}
|
||||
|
||||
void Plot::show3dB( double freq )
|
||||
{
|
||||
QString label( "-3 dB at f = " );
|
||||
label += QString::number( freq, 'g', 3 );
|
||||
|
||||
QwtText text( label );
|
||||
text.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
|
||||
text.setColor( Qt::green );
|
||||
|
||||
m_marker1->setValue( freq, 0.0 );
|
||||
m_marker1->setLabel( text );
|
||||
}
|
||||
|
||||
//
|
||||
// re-calculate frequency response
|
||||
//
|
||||
void Plot::setDamp( double damping )
|
||||
{
|
||||
const bool doReplot = autoReplot();
|
||||
setAutoReplot( false );
|
||||
|
||||
const int ArraySize = 200;
|
||||
|
||||
double frequency[ArraySize];
|
||||
double amplitude[ArraySize];
|
||||
double phase[ArraySize];
|
||||
|
||||
// build frequency vector with logarithmic division
|
||||
logSpace( frequency, ArraySize, 0.01, 100 );
|
||||
|
||||
int i3 = 1;
|
||||
double fmax = 1;
|
||||
double amax = -1000.0;
|
||||
|
||||
for ( int i = 0; i < ArraySize; i++ )
|
||||
{
|
||||
double f = frequency[i];
|
||||
const ComplexNumber g =
|
||||
ComplexNumber( 1.0 ) / ComplexNumber( 1.0 - f * f, 2.0 * damping * f );
|
||||
|
||||
amplitude[i] = 20.0 * log10( std::sqrt( g.real() * g.real() + g.imag() * g.imag() ) );
|
||||
phase[i] = std::atan2( g.imag(), g.real() ) * ( 180.0 / M_PI );
|
||||
|
||||
if ( ( i3 <= 1 ) && ( amplitude[i] < -3.0 ) )
|
||||
i3 = i;
|
||||
if ( amplitude[i] > amax )
|
||||
{
|
||||
amax = amplitude[i];
|
||||
fmax = frequency[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double f3 = frequency[i3] - ( frequency[i3] - frequency[i3 - 1] )
|
||||
/ ( amplitude[i3] - amplitude[i3 - 1] ) * ( amplitude[i3] + 3 );
|
||||
|
||||
showPeak( fmax, amax );
|
||||
show3dB( f3 );
|
||||
showData( frequency, amplitude, phase, ArraySize );
|
||||
|
||||
setAutoReplot( doReplot );
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
37
examples/bode/Plot.h
Normal file
37
examples/bode/Plot.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtPlot>
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotMarker;
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot( QWidget* parent );
|
||||
|
||||
public Q_SLOTS:
|
||||
void setDamp( double damping );
|
||||
|
||||
private:
|
||||
void showData( const double* frequency, const double* amplitude,
|
||||
const double* phase, int count );
|
||||
void showPeak( double freq, double amplitude );
|
||||
void show3dB( double freq );
|
||||
|
||||
QwtPlotCurve* m_curve1;
|
||||
QwtPlotCurve* m_curve2;
|
||||
QwtPlotMarker* m_marker1;
|
||||
QwtPlotMarker* m_marker2;
|
||||
};
|
||||
23
examples/bode/bode.pro
Normal file
23
examples/bode/bode.pro
Normal file
@@ -0,0 +1,23 @@
|
||||
################################################################
|
||||
# Qwt Examples
|
||||
# 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 = bode
|
||||
|
||||
HEADERS = \
|
||||
MainWindow.h \
|
||||
Plot.h \
|
||||
ComplexNumber.h \
|
||||
Pixmaps.h
|
||||
|
||||
SOURCES = \
|
||||
Plot.cpp \
|
||||
MainWindow.cpp \
|
||||
main.cpp
|
||||
22
examples/bode/main.cpp
Normal file
22
examples/bode/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "MainWindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
MainWindow window;
|
||||
window.resize( 540, 400 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
176
examples/controls/DialBox.cpp
Normal file
176
examples/controls/DialBox.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "DialBox.h"
|
||||
|
||||
#include <QwtDial>
|
||||
#include <QwtDialNeedle>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtRoundScaleDraw>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
DialBox::DialBox( QWidget* parent, int type )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_dial = createDial( type );
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignCenter );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );;
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( m_dial, 10 );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
connect( m_dial, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
|
||||
setNum( m_dial->value() );
|
||||
}
|
||||
|
||||
QwtDial* DialBox::createDial( int type ) const
|
||||
{
|
||||
QwtDial* dial = new QwtDial();
|
||||
dial->setTracking( true );
|
||||
dial->setFocusPolicy( Qt::StrongFocus );
|
||||
dial->setObjectName( QString( "Dial %1" ).arg( type + 1 ) );
|
||||
|
||||
QColor needleColor( Qt::red );
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 4 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( -100.0, 100.0 );
|
||||
|
||||
needleColor = QColor( "Goldenrod" );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 10 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( 10.0, 0.0 );
|
||||
|
||||
QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw();
|
||||
scaleDraw->setSpacing( 8 );
|
||||
scaleDraw->enableComponent(
|
||||
QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 2 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 8 );
|
||||
dial->setScaleDraw( scaleDraw );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
dial->setOrigin( 150.0 );
|
||||
dial->setScaleArc( 0.0, 240.0 );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
dial->setScaleEngine( scaleEngine );
|
||||
|
||||
QList< double > ticks[ QwtScaleDiv::NTickTypes ];
|
||||
ticks[ QwtScaleDiv::MajorTick ] << 0 << 4
|
||||
<< 16 << 32 << 64 << 96 << 128;
|
||||
ticks[ QwtScaleDiv::MediumTick ] << 24 << 48 << 80 << 112;
|
||||
ticks[ QwtScaleDiv::MinorTick ]
|
||||
<< 0.5 << 1 << 2
|
||||
<< 7 << 10 << 13
|
||||
<< 20 << 28
|
||||
<< 40 << 56
|
||||
<< 72 << 88
|
||||
<< 104 << 120;
|
||||
|
||||
dial->setScale( QwtScaleDiv( 0, 128, ticks ) );
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 9 );
|
||||
dial->setScaleEngine( new QwtLogScaleEngine );
|
||||
dial->setScale( 1.0e-2, 1.0e2 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
dial->setOrigin( 225.0 );
|
||||
dial->setScaleArc( 0.0, 360.0 );
|
||||
dial->setScaleMaxMinor( 5 );
|
||||
dial->setScaleStepSize( 20 );
|
||||
dial->setScale( 100.0, -100.0 );
|
||||
dial->setWrapping( true );
|
||||
dial->setTotalSteps( 40 );
|
||||
dial->setMode( QwtDial::RotateScale );
|
||||
dial->setValue( 70.0 );
|
||||
|
||||
needleColor = QColor( "DarkSlateBlue" );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
dial->setOrigin( 45.0 );
|
||||
dial->setScaleArc( 0.0, 225.0 );
|
||||
dial->setScaleMaxMinor( 5 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( 0.0, 10.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QwtDialSimpleNeedle* needle = new QwtDialSimpleNeedle(
|
||||
QwtDialSimpleNeedle::Arrow, true, needleColor,
|
||||
QColor( Qt::gray ).lighter( 130 ) );
|
||||
dial->setNeedle( needle );
|
||||
|
||||
//const QColor base( QColor( "DimGray" ) );
|
||||
const QColor base( QColor( Qt::darkGray ).darker( 150 ) );
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor( QPalette::Base, base );
|
||||
palette.setColor( QPalette::Window, base.darker( 150 ) );
|
||||
palette.setColor( QPalette::Mid, base.darker( 110 ) );
|
||||
palette.setColor( QPalette::Light, base.lighter( 170 ) );
|
||||
palette.setColor( QPalette::Dark, base.darker( 170 ) );
|
||||
palette.setColor( QPalette::Text, base.darker( 200 ).lighter( 800 ) );
|
||||
palette.setColor( QPalette::WindowText, base.darker( 200 ) );
|
||||
|
||||
dial->setPalette( palette );
|
||||
dial->setLineWidth( 4 );
|
||||
dial->setFrameShadow( QwtDial::Sunken );
|
||||
|
||||
return dial;
|
||||
}
|
||||
|
||||
void DialBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_DialBox.cpp"
|
||||
31
examples/controls/DialBox.h
Normal file
31
examples/controls/DialBox.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtDial;
|
||||
|
||||
class DialBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialBox( QWidget* parent, int type );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtDial* createDial( int type ) const;
|
||||
|
||||
QwtDial* m_dial;
|
||||
QLabel* m_label;
|
||||
};
|
||||
27
examples/controls/DialTab.cpp
Normal file
27
examples/controls/DialTab.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "DialTab.h"
|
||||
#include "DialBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
DialTab::DialTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
|
||||
const int numRows = 3;
|
||||
for ( int i = 0; i < 2 * numRows; i++ )
|
||||
{
|
||||
DialBox* dialBox = new DialBox( this, i );
|
||||
layout->addWidget( dialBox, i / numRows, i % numRows );
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/controls/DialTab.h
Normal file
18
examples/controls/DialTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class DialTab : public QWidget
|
||||
{
|
||||
public:
|
||||
DialTab( QWidget* parent = NULL );
|
||||
};
|
||||
132
examples/controls/KnobBox.cpp
Normal file
132
examples/controls/KnobBox.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "KnobBox.h"
|
||||
|
||||
#include <QwtKnob>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
KnobBox::KnobBox( QWidget* parent, int knobType )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_knob = createKnob( knobType );
|
||||
m_knob->setKnobWidth( 100 );
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignCenter );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );;
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( m_knob, 10 );
|
||||
layout->addWidget( m_label );
|
||||
layout->addStretch( 10 );
|
||||
|
||||
connect( m_knob, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
|
||||
setNum( m_knob->value() );
|
||||
}
|
||||
|
||||
QwtKnob* KnobBox::createKnob( int knobType ) const
|
||||
{
|
||||
QwtKnob* knob = new QwtKnob();
|
||||
knob->setTracking( true );
|
||||
|
||||
switch( knobType )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Nub );
|
||||
knob->setWrapping( true );
|
||||
knob->setNumTurns( 4 );
|
||||
knob->setScaleStepSize( 10.0 );
|
||||
knob->setScale( 0, 400 );
|
||||
knob->setTotalSteps( 400 );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Dot );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Tick );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
knob->setScaleEngine( scaleEngine );
|
||||
|
||||
QList< double > ticks[ QwtScaleDiv::NTickTypes ];
|
||||
ticks[ QwtScaleDiv::MajorTick ] << 0 << 4
|
||||
<< 16 << 32 << 64 << 96 << 128;
|
||||
ticks[ QwtScaleDiv::MediumTick ] << 24 << 48 << 80 << 112;
|
||||
ticks[ QwtScaleDiv::MinorTick ]
|
||||
<< 0.5 << 1 << 2
|
||||
<< 7 << 10 << 13
|
||||
<< 20 << 28
|
||||
<< 40 << 56
|
||||
<< 72 << 88
|
||||
<< 104 << 120;
|
||||
|
||||
knob->setScale( QwtScaleDiv( 0, 128, ticks ) );
|
||||
|
||||
knob->setTotalSteps( 100 );
|
||||
knob->setStepAlignment( false );
|
||||
knob->setSingleSteps( 1 );
|
||||
knob->setPageSteps( 5 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Flat );
|
||||
knob->setMarkerStyle( QwtKnob::Notch );
|
||||
knob->setScaleEngine( new QwtLogScaleEngine() );
|
||||
knob->setScaleStepSize( 1.0 );
|
||||
knob->setScale( 0.1, 1000.0 );
|
||||
knob->setScaleMaxMinor( 10 );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Raised );
|
||||
knob->setMarkerStyle( QwtKnob::Dot );
|
||||
knob->setWrapping( true );
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Styled );
|
||||
knob->setMarkerStyle( QwtKnob::Triangle );
|
||||
knob->setTotalAngle( 180.0 );
|
||||
knob->setScale( 100, -100 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return knob;
|
||||
}
|
||||
|
||||
void KnobBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_KnobBox.cpp"
|
||||
32
examples/controls/KnobBox.h
Normal file
32
examples/controls/KnobBox.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtKnob;
|
||||
|
||||
class KnobBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KnobBox( QWidget* parent, int knobType );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtKnob* createKnob( int knobType ) const;
|
||||
|
||||
QwtKnob* m_knob;
|
||||
QLabel* m_label;
|
||||
};
|
||||
27
examples/controls/KnobTab.cpp
Normal file
27
examples/controls/KnobTab.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "KnobTab.h"
|
||||
#include "KnobBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
KnobTab::KnobTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
|
||||
const int numRows = 3;
|
||||
for ( int i = 0; i < 2 * numRows; i++ )
|
||||
{
|
||||
KnobBox* knobBox = new KnobBox( this, i );
|
||||
layout->addWidget( knobBox, i / numRows, i % numRows );
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/controls/KnobTab.h
Normal file
18
examples/controls/KnobTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class KnobTab : public QWidget
|
||||
{
|
||||
public:
|
||||
KnobTab( QWidget* parent = NULL );
|
||||
};
|
||||
189
examples/controls/SliderBox.cpp
Normal file
189
examples/controls/SliderBox.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "SliderBox.h"
|
||||
|
||||
#include <QwtSlider>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtPainter>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
SliderBox::SliderBox( int sliderType, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_slider = createSlider( sliderType );
|
||||
|
||||
QFlags< Qt::AlignmentFlag > alignment;
|
||||
|
||||
if ( m_slider->orientation() == Qt::Horizontal )
|
||||
{
|
||||
if ( m_slider->scalePosition() == QwtSlider::TrailingScale )
|
||||
alignment = Qt::AlignBottom;
|
||||
else
|
||||
alignment = Qt::AlignTop;
|
||||
|
||||
alignment |= Qt::AlignHCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_slider->scalePosition() == QwtSlider::TrailingScale )
|
||||
alignment = Qt::AlignRight;
|
||||
else
|
||||
alignment = Qt::AlignLeft;
|
||||
|
||||
alignment |= Qt::AlignVCenter;
|
||||
}
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( alignment );
|
||||
|
||||
const int labelWidth = QwtPainter::horizontalAdvance(
|
||||
m_label->fontMetrics(), "10000.9" );
|
||||
m_label->setFixedWidth( labelWidth );
|
||||
|
||||
connect( m_slider, SIGNAL(valueChanged(double)), SLOT(setNum(double)) );
|
||||
|
||||
QBoxLayout* layout;
|
||||
if ( m_slider->orientation() == Qt::Horizontal )
|
||||
layout = new QHBoxLayout( this );
|
||||
else
|
||||
layout = new QVBoxLayout( this );
|
||||
|
||||
layout->addWidget( m_slider );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
setNum( m_slider->value() );
|
||||
}
|
||||
|
||||
QwtSlider* SliderBox::createSlider( int sliderType ) const
|
||||
{
|
||||
QwtSlider* slider = new QwtSlider();
|
||||
|
||||
switch( sliderType )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( false );
|
||||
slider->setSpacing( 0 );
|
||||
slider->setHandleSize( QSize( 30, 16 ) );
|
||||
slider->setScale( 10.0, -10.0 );
|
||||
slider->setTotalSteps( 8 );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 1 );
|
||||
slider->setWrapping( true );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::NoScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
slider->setScale( 0.0, 1.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 5 );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::LeadingScale );
|
||||
slider->setTrough( false );
|
||||
slider->setGroove( true );
|
||||
slider->setHandleSize( QSize( 12, 25 ) );
|
||||
slider->setScale( 1000.0, 3000.0 );
|
||||
slider->setTotalSteps( 200.0 );
|
||||
slider->setSingleSteps( 2 );
|
||||
slider->setPageSteps( 10 );
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
slider->setScaleEngine( scaleEngine );
|
||||
slider->setScale( 0.0, 128.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setStepAlignment( false );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 5 );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( false );
|
||||
slider->setGroove( true );
|
||||
slider->setScale( 100.0, 0.0 );
|
||||
slider->setInvertedControls( true );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 5 );
|
||||
slider->setScaleMaxMinor( 5 );
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::NoScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( false );
|
||||
slider->setScale( 0.0, 100.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 10 );
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::LeadingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
slider->setScaleEngine( new QwtLogScaleEngine );
|
||||
slider->setStepAlignment( false );
|
||||
slider->setHandleSize( QSize( 20, 32 ) );
|
||||
slider->setBorderWidth( 1 );
|
||||
slider->setScale( 1.0, 1.0e4 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 10 );
|
||||
slider->setScaleMaxMinor( 9 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( slider )
|
||||
{
|
||||
QString name( "Slider %1" );
|
||||
slider->setObjectName( name.arg( sliderType ) );
|
||||
}
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
||||
void SliderBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_SliderBox.cpp"
|
||||
31
examples/controls/SliderBox.h
Normal file
31
examples/controls/SliderBox.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtSlider;
|
||||
|
||||
class SliderBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SliderBox( int sliderType, QWidget* parent = NULL );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtSlider* createSlider( int sliderType ) const;
|
||||
|
||||
QwtSlider* m_slider;
|
||||
QLabel* m_label;
|
||||
};
|
||||
47
examples/controls/SliderTab.cpp
Normal file
47
examples/controls/SliderTab.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "SliderTab.h"
|
||||
#include "SliderBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
SliderTab::SliderTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
int i;
|
||||
|
||||
QBoxLayout* hLayout = createLayout( Qt::Vertical );
|
||||
for ( i = 0; i < 4; i++ )
|
||||
hLayout->addWidget( new SliderBox( i ) );
|
||||
hLayout->addStretch();
|
||||
|
||||
QBoxLayout* vLayout = createLayout( Qt::Horizontal );
|
||||
for ( ; i < 7; i++ )
|
||||
vLayout->addWidget( new SliderBox( i ) );
|
||||
|
||||
QBoxLayout* mainLayout = createLayout( Qt::Horizontal, this );
|
||||
mainLayout->addLayout( vLayout );
|
||||
mainLayout->addLayout( hLayout, 10 );
|
||||
}
|
||||
|
||||
QBoxLayout* SliderTab::createLayout(
|
||||
Qt::Orientation orientation, QWidget* widget )
|
||||
{
|
||||
QBoxLayout* layout =
|
||||
new QBoxLayout( QBoxLayout::LeftToRight, widget );
|
||||
|
||||
if ( orientation == Qt::Vertical )
|
||||
layout->setDirection( QBoxLayout::TopToBottom );
|
||||
|
||||
layout->setSpacing( 20 );
|
||||
layout->setContentsMargins( QMargins() );
|
||||
|
||||
return layout;
|
||||
}
|
||||
24
examples/controls/SliderTab.h
Normal file
24
examples/controls/SliderTab.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QBoxLayout;
|
||||
|
||||
class SliderTab : public QWidget
|
||||
{
|
||||
public:
|
||||
SliderTab( QWidget* parent = NULL );
|
||||
|
||||
private:
|
||||
QBoxLayout* createLayout( Qt::Orientation,
|
||||
QWidget* widget = NULL );
|
||||
};
|
||||
199
examples/controls/WheelBox.cpp
Normal file
199
examples/controls/WheelBox.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "WheelBox.h"
|
||||
|
||||
#include <QwtWheel>
|
||||
#include <QwtThermo>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtColorMap>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
WheelBox::WheelBox( Qt::Orientation orientation, int type, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QWidget* box = createBox( orientation, type );
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
|
||||
QBoxLayout* layout = new QVBoxLayout( this );
|
||||
layout->addWidget( box );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
setNum( m_wheel->value() );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
}
|
||||
|
||||
QWidget* WheelBox::createBox( Qt::Orientation orientation, int type )
|
||||
{
|
||||
m_wheel = new QwtWheel();
|
||||
m_wheel->setValue( 80 );
|
||||
m_wheel->setWheelWidth( 20 );
|
||||
m_wheel->setMass( 1.0 );
|
||||
|
||||
m_thermo = new QwtThermo();
|
||||
m_thermo->setOrientation( orientation );
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
{
|
||||
m_thermo->setScalePosition( QwtThermo::LeadingScale );
|
||||
m_wheel->setOrientation( Qt::Vertical );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_thermo->setScalePosition( QwtThermo::TrailingScale );
|
||||
m_wheel->setOrientation( Qt::Horizontal );
|
||||
}
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setColorInterval( Qt::blue, Qt::red );
|
||||
m_thermo->setColorMap( colorMap );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setMode( QwtLinearColorMap::FixedColors );
|
||||
|
||||
int idx = 4;
|
||||
|
||||
colorMap->setColorInterval( Qt::GlobalColor( idx ),
|
||||
Qt::GlobalColor( idx + 10 ) );
|
||||
for ( int i = 1; i < 10; i++ )
|
||||
{
|
||||
colorMap->addColorStop( i / 10.0,
|
||||
Qt::GlobalColor( idx + i ) );
|
||||
}
|
||||
|
||||
m_thermo->setColorMap( colorMap );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_wheel->setRange( 10, 1000 );
|
||||
m_wheel->setSingleStep( 1.0 );
|
||||
|
||||
m_thermo->setScaleEngine( new QwtLogScaleEngine );
|
||||
m_thermo->setScaleMaxMinor( 10 );
|
||||
|
||||
m_thermo->setFillBrush( Qt::darkCyan );
|
||||
m_thermo->setAlarmBrush( Qt::magenta );
|
||||
m_thermo->setAlarmLevel( 500.0 );
|
||||
|
||||
m_wheel->setValue( 800 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
m_wheel->setRange( -1000, 1000 );
|
||||
m_wheel->setSingleStep( 1.0 );
|
||||
m_wheel->setPalette( QColor( "Tan" ) );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine();
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
|
||||
m_thermo->setScaleMaxMinor( 5 );
|
||||
m_thermo->setScaleEngine( scaleEngine );
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor( QPalette::Base, Qt::darkGray );
|
||||
pal.setColor( QPalette::ButtonText, QColor( "darkKhaki" ) );
|
||||
|
||||
m_thermo->setPalette( pal );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
m_wheel->setRange( -100, 300 );
|
||||
m_wheel->setInverted( true );
|
||||
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setColorInterval( Qt::darkCyan, Qt::yellow );
|
||||
m_thermo->setColorMap( colorMap );
|
||||
|
||||
m_wheel->setValue( 243 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
m_thermo->setFillBrush( Qt::darkCyan );
|
||||
m_thermo->setAlarmBrush( Qt::magenta );
|
||||
m_thermo->setAlarmLevel( 60.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
m_thermo->setOriginMode( QwtThermo::OriginMinimum );
|
||||
m_thermo->setFillBrush( QBrush( "DarkSlateBlue" ) );
|
||||
m_thermo->setAlarmBrush( QBrush( "DarkOrange" ) );
|
||||
m_thermo->setAlarmLevel( 60.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
m_wheel->setRange( -100, 100 );
|
||||
|
||||
m_thermo->setOriginMode( QwtThermo::OriginCustom );
|
||||
m_thermo->setOrigin( 0.0 );
|
||||
m_thermo->setFillBrush( Qt::darkBlue );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double min = m_wheel->minimum();
|
||||
double max = m_wheel->maximum();
|
||||
|
||||
if ( m_wheel->isInverted() )
|
||||
qSwap( min, max );
|
||||
|
||||
m_thermo->setScale( min, max );
|
||||
m_thermo->setValue( m_wheel->value() );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
m_thermo, SLOT(setValue(double)) );
|
||||
|
||||
QWidget* box = new QWidget();
|
||||
|
||||
QBoxLayout* layout;
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
layout = new QHBoxLayout( box );
|
||||
else
|
||||
layout = new QVBoxLayout( box );
|
||||
|
||||
layout->addWidget( m_thermo, Qt::AlignCenter );
|
||||
layout->addWidget( m_wheel );
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
void WheelBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_WheelBox.cpp"
|
||||
35
examples/controls/WheelBox.h
Normal file
35
examples/controls/WheelBox.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtThermo;
|
||||
class QwtWheel;
|
||||
|
||||
class WheelBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WheelBox( Qt::Orientation,
|
||||
int type, QWidget* parent = NULL );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QWidget* createBox( Qt::Orientation, int type );
|
||||
|
||||
private:
|
||||
QwtWheel* m_wheel;
|
||||
QwtThermo* m_thermo;
|
||||
QLabel* m_label;
|
||||
};
|
||||
38
examples/controls/WheelTab.cpp
Normal file
38
examples/controls/WheelTab.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "WheelTab.h"
|
||||
#include "WheelBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
WheelTab::WheelTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
const int numBoxes = 4;
|
||||
|
||||
QGridLayout* layout1 = new QGridLayout();
|
||||
for ( int i = 0; i < numBoxes; i++ )
|
||||
{
|
||||
WheelBox* box = new WheelBox( Qt::Vertical, i );
|
||||
layout1->addWidget( box, i / 2, i % 2 );
|
||||
}
|
||||
|
||||
QGridLayout* layout2 = new QGridLayout();
|
||||
for ( int i = 0; i < numBoxes; i++ )
|
||||
{
|
||||
WheelBox* box = new WheelBox( Qt::Horizontal, i + numBoxes );
|
||||
layout2->addWidget( box, i / 2, i % 2 );
|
||||
}
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout( this );
|
||||
layout->addLayout( layout1, 2 );
|
||||
layout->addLayout( layout2, 5 );
|
||||
}
|
||||
|
||||
18
examples/controls/WheelTab.h
Normal file
18
examples/controls/WheelTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class WheelTab : public QWidget
|
||||
{
|
||||
public:
|
||||
WheelTab( QWidget* parent = NULL );
|
||||
};
|
||||
34
examples/controls/controls.pro
Normal file
34
examples/controls/controls.pro
Normal file
@@ -0,0 +1,34 @@
|
||||
################################################################
|
||||
# Qwt Examples
|
||||
# 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 = controls
|
||||
|
||||
HEADERS = \
|
||||
SliderBox.h \
|
||||
SliderTab.h \
|
||||
WheelBox.h \
|
||||
WheelTab.h \
|
||||
KnobBox.h \
|
||||
KnobTab.h \
|
||||
DialBox.h \
|
||||
DialTab.h
|
||||
|
||||
SOURCES = \
|
||||
SliderBox.cpp \
|
||||
SliderTab.cpp \
|
||||
WheelBox.cpp \
|
||||
WheelTab.cpp \
|
||||
KnobBox.cpp \
|
||||
KnobTab.cpp \
|
||||
DialBox.cpp \
|
||||
DialTab.cpp \
|
||||
main.cpp
|
||||
|
||||
60
examples/controls/main.cpp
Normal file
60
examples/controls/main.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 "SliderTab.h"
|
||||
#include "WheelTab.h"
|
||||
#include "KnobTab.h"
|
||||
#include "DialTab.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTabWidget>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TabWidget : public QTabWidget
|
||||
{
|
||||
public:
|
||||
TabWidget()
|
||||
{
|
||||
SliderTab* sliderTab = new SliderTab();
|
||||
sliderTab->setAutoFillBackground( true );
|
||||
sliderTab->setPalette( QColor( "DimGray" ) );
|
||||
|
||||
WheelTab* wheelTab = new WheelTab();
|
||||
wheelTab->setAutoFillBackground( true );
|
||||
wheelTab->setPalette( QColor( "Silver" ) );
|
||||
|
||||
KnobTab* knobTab = new KnobTab();
|
||||
knobTab->setAutoFillBackground( true );
|
||||
knobTab->setPalette( Qt::darkGray );
|
||||
|
||||
DialTab* dialTab = new DialTab();
|
||||
dialTab->setAutoFillBackground( true );
|
||||
dialTab->setPalette( Qt::darkGray );
|
||||
|
||||
addTab( sliderTab, "Slider" );
|
||||
addTab( wheelTab, "Wheel/Thermo" );
|
||||
addTab( knobTab, "Knob" );
|
||||
addTab( dialTab, "Dial" );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
TabWidget tabWidget;
|
||||
|
||||
tabWidget.resize( 800, 600 );
|
||||
tabWidget.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
61
examples/cpuplot/CpuPieMarker.cpp
Normal file
61
examples/cpuplot/CpuPieMarker.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CpuPlot.h"
|
||||
#include "CpuPieMarker.h"
|
||||
|
||||
#include <QwtScaleMap>
|
||||
#include <QwtPlotCurve>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
CpuPieMarker::CpuPieMarker()
|
||||
{
|
||||
setZ( 1000 );
|
||||
setRenderHint( QwtPlotItem::RenderAntialiased, true );
|
||||
}
|
||||
|
||||
int CpuPieMarker::rtti() const
|
||||
{
|
||||
return QwtPlotItem::Rtti_PlotUserItem;
|
||||
}
|
||||
|
||||
void CpuPieMarker::draw( QPainter* painter,
|
||||
const QwtScaleMap&, const QwtScaleMap&,
|
||||
const QRectF& rect ) const
|
||||
{
|
||||
const CpuPlot* cpuPlot = static_cast< CpuPlot* > ( plot() );
|
||||
|
||||
const QwtScaleMap yMap = cpuPlot->canvasMap( QwtAxis::YLeft );
|
||||
|
||||
const int margin = 5;
|
||||
|
||||
QRectF pieRect;
|
||||
pieRect.setX( rect.x() + margin );
|
||||
pieRect.setY( rect.y() + margin );
|
||||
pieRect.setHeight( yMap.transform( 80.0 ) );
|
||||
pieRect.setWidth( pieRect.height() );
|
||||
|
||||
const int dataType[] = { CpuPlot::User, CpuPlot::System, CpuPlot::Idle };
|
||||
|
||||
int angle = static_cast< int >( 5760 * 0.75 );
|
||||
for ( unsigned int i = 0;
|
||||
i < sizeof( dataType ) / sizeof( dataType[0] ); i++ )
|
||||
{
|
||||
const QwtPlotCurve* curve = cpuPlot->cpuCurve( dataType[i] );
|
||||
if ( curve->dataSize() > 0 )
|
||||
{
|
||||
const int value = static_cast< int >( 5760 * curve->sample( 0 ).y() / 100.0 );
|
||||
|
||||
painter->save();
|
||||
painter->setBrush( QBrush( curve->brush().color(), Qt::SolidPattern ) );
|
||||
if ( value != 0 )
|
||||
painter->drawPie( pieRect, -angle, -value );
|
||||
painter->restore();
|
||||
|
||||
angle += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
examples/cpuplot/CpuPieMarker.h
Normal file
20
examples/cpuplot/CpuPieMarker.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtPlotItem>
|
||||
|
||||
class CpuPieMarker : public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
CpuPieMarker();
|
||||
|
||||
virtual int rtti() const QWT_OVERRIDE;
|
||||
|
||||
virtual void draw( QPainter*,
|
||||
const QwtScaleMap&, const QwtScaleMap&,
|
||||
const QRectF& ) const QWT_OVERRIDE;
|
||||
};
|
||||
237
examples/cpuplot/CpuPlot.cpp
Normal file
237
examples/cpuplot/CpuPlot.cpp
Normal file
@@ -0,0 +1,237 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CpuPieMarker.h"
|
||||
#include "CpuPlot.h"
|
||||
|
||||
#include <QwtPlotLayout>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtScaleDraw>
|
||||
#include <QwtScaleMap>
|
||||
#include <QwtScaleWidget>
|
||||
#include <QwtLegend>
|
||||
#include <QwtLegendLabel>
|
||||
#include <QwtPlotCanvas>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TimeScaleDraw : public QwtScaleDraw
|
||||
{
|
||||
public:
|
||||
TimeScaleDraw( const QTime& base )
|
||||
: baseTime( base )
|
||||
{
|
||||
}
|
||||
virtual QwtText label( double v ) const QWT_OVERRIDE
|
||||
{
|
||||
QTime upTime = baseTime.addSecs( static_cast< int >( v ) );
|
||||
return upTime.toString();
|
||||
}
|
||||
private:
|
||||
QTime baseTime;
|
||||
};
|
||||
|
||||
class Background : public QwtPlotItem
|
||||
{
|
||||
public:
|
||||
Background()
|
||||
{
|
||||
setZ( 0.0 );
|
||||
}
|
||||
|
||||
virtual int rtti() const QWT_OVERRIDE
|
||||
{
|
||||
return QwtPlotItem::Rtti_PlotUserItem;
|
||||
}
|
||||
|
||||
virtual void draw( QPainter* painter,
|
||||
const QwtScaleMap&, const QwtScaleMap& yMap,
|
||||
const QRectF& canvasRect ) const QWT_OVERRIDE
|
||||
{
|
||||
QColor c( Qt::white );
|
||||
QRectF r = canvasRect;
|
||||
|
||||
for ( int i = 100; i > 0; i -= 10 )
|
||||
{
|
||||
r.setBottom( yMap.transform( i - 10 ) );
|
||||
r.setTop( yMap.transform( i ) );
|
||||
painter->fillRect( r, c );
|
||||
|
||||
c = c.darker( 110 );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CpuCurve : public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
CpuCurve( const QString& title )
|
||||
: QwtPlotCurve( title )
|
||||
{
|
||||
setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
}
|
||||
|
||||
void setColor( const QColor& color )
|
||||
{
|
||||
QColor c = color;
|
||||
c.setAlpha( 150 );
|
||||
|
||||
setPen( QPen( Qt::NoPen ) );
|
||||
setBrush( c );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CpuPlot::CpuPlot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
, m_dataCount( 0 )
|
||||
{
|
||||
using namespace QwtAxis;
|
||||
|
||||
setAutoReplot( false );
|
||||
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
canvas->setBorderRadius( 10 );
|
||||
|
||||
setCanvas( canvas );
|
||||
|
||||
plotLayout()->setAlignCanvasToScales( true );
|
||||
|
||||
QwtLegend* legend = new QwtLegend;
|
||||
legend->setDefaultItemMode( QwtLegendData::Checkable );
|
||||
insertLegend( legend, QwtPlot::RightLegend );
|
||||
|
||||
setAxisTitle( XBottom, " System Uptime [h:m:s]" );
|
||||
setAxisScaleDraw( XBottom, new TimeScaleDraw( m_cpuStat.upTime() ) );
|
||||
setAxisScale( XBottom, 0, HISTORY );
|
||||
setAxisLabelRotation( XBottom, -50.0 );
|
||||
setAxisLabelAlignment( XBottom, Qt::AlignLeft | Qt::AlignBottom );
|
||||
|
||||
/*
|
||||
In situations, when there is a label at the most right position of the
|
||||
scale, additional space is needed to display the overlapping part
|
||||
of the label would be taken by reducing the width of scale and canvas.
|
||||
To avoid this "jumping canvas" effect, we add a permanent margin.
|
||||
We don't need to do the same for the left border, because there
|
||||
is enough space for the overlapping label below the left scale.
|
||||
*/
|
||||
|
||||
QwtScaleWidget* scaleWidget = axisWidget( XBottom );
|
||||
const int fmh = QFontMetrics( scaleWidget->font() ).height();
|
||||
scaleWidget->setMinBorderDist( 0, fmh / 2 );
|
||||
|
||||
setAxisTitle( YLeft, "Cpu Usage [%]" );
|
||||
setAxisScale( YLeft, 0, 100 );
|
||||
|
||||
Background* bg = new Background();
|
||||
bg->attach( this );
|
||||
|
||||
CpuPieMarker* pie = new CpuPieMarker();
|
||||
pie->attach( this );
|
||||
|
||||
CpuCurve* curve;
|
||||
|
||||
curve = new CpuCurve( "System" );
|
||||
curve->setColor( Qt::red );
|
||||
curve->attach( this );
|
||||
m_data[System].curve = curve;
|
||||
|
||||
curve = new CpuCurve( "User" );
|
||||
curve->setColor( Qt::blue );
|
||||
curve->setZ( curve->z() - 1 );
|
||||
curve->attach( this );
|
||||
m_data[User].curve = curve;
|
||||
|
||||
curve = new CpuCurve( "Total" );
|
||||
curve->setColor( Qt::black );
|
||||
curve->setZ( curve->z() - 2 );
|
||||
curve->attach( this );
|
||||
m_data[Total].curve = curve;
|
||||
|
||||
curve = new CpuCurve( "Idle" );
|
||||
curve->setColor( Qt::darkCyan );
|
||||
curve->setZ( curve->z() - 3 );
|
||||
curve->attach( this );
|
||||
m_data[Idle].curve = curve;
|
||||
|
||||
showCurve( m_data[System].curve, true );
|
||||
showCurve( m_data[User].curve, true );
|
||||
showCurve( m_data[Total].curve, false );
|
||||
showCurve( m_data[Idle].curve, false );
|
||||
|
||||
for ( int i = 0; i < HISTORY; i++ )
|
||||
m_timeData[HISTORY - 1 - i] = i;
|
||||
|
||||
( void )startTimer( 1000 ); // 1 second
|
||||
|
||||
connect( legend, SIGNAL(checked(const QVariant&,bool,int)),
|
||||
SLOT(legendChecked(const QVariant&,bool)) );
|
||||
}
|
||||
|
||||
void CpuPlot::timerEvent( QTimerEvent* )
|
||||
{
|
||||
for ( int i = m_dataCount; i > 0; i-- )
|
||||
{
|
||||
for ( int c = 0; c < NCpuData; c++ )
|
||||
{
|
||||
if ( i < HISTORY )
|
||||
m_data[c].data[i] = m_data[c].data[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
m_cpuStat.statistic( m_data[User].data[0], m_data[System].data[0] );
|
||||
|
||||
m_data[Total].data[0] = m_data[User].data[0] + m_data[System].data[0];
|
||||
m_data[Idle].data[0] = 100.0 - m_data[Total].data[0];
|
||||
|
||||
if ( m_dataCount < HISTORY )
|
||||
m_dataCount++;
|
||||
|
||||
for ( int j = 0; j < HISTORY; j++ )
|
||||
m_timeData[j]++;
|
||||
|
||||
setAxisScale( QwtAxis::XBottom,
|
||||
m_timeData[HISTORY - 1], m_timeData[0] );
|
||||
|
||||
for ( int c = 0; c < NCpuData; c++ )
|
||||
{
|
||||
m_data[c].curve->setRawSamples(
|
||||
m_timeData, m_data[c].data, m_dataCount );
|
||||
}
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
void CpuPlot::legendChecked( const QVariant& itemInfo, bool on )
|
||||
{
|
||||
QwtPlotItem* plotItem = infoToItem( itemInfo );
|
||||
if ( plotItem )
|
||||
showCurve( plotItem, on );
|
||||
}
|
||||
|
||||
void CpuPlot::showCurve( QwtPlotItem* item, bool on )
|
||||
{
|
||||
item->setVisible( on );
|
||||
|
||||
QwtLegend* lgd = qobject_cast< QwtLegend* >( legend() );
|
||||
|
||||
QList< QWidget* > legendWidgets =
|
||||
lgd->legendWidgets( itemToInfo( item ) );
|
||||
|
||||
if ( legendWidgets.size() == 1 )
|
||||
{
|
||||
QwtLegendLabel* legendLabel =
|
||||
qobject_cast< QwtLegendLabel* >( legendWidgets[0] );
|
||||
|
||||
if ( legendLabel )
|
||||
legendLabel->setChecked( on );
|
||||
}
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
#include "moc_CpuPlot.cpp"
|
||||
54
examples/cpuplot/CpuPlot.h
Normal file
54
examples/cpuplot/CpuPlot.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CpuStat.h"
|
||||
#include <QwtPlot>
|
||||
|
||||
#define HISTORY 60 // seconds
|
||||
|
||||
class QwtPlotCurve;
|
||||
|
||||
class CpuPlot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CpuData
|
||||
{
|
||||
User,
|
||||
System,
|
||||
Total,
|
||||
Idle,
|
||||
|
||||
NCpuData
|
||||
};
|
||||
|
||||
CpuPlot( QWidget* = 0 );
|
||||
const QwtPlotCurve* cpuCurve( int id ) const
|
||||
{
|
||||
return m_data[id].curve;
|
||||
}
|
||||
|
||||
protected:
|
||||
void timerEvent( QTimerEvent* ) QWT_OVERRIDE;
|
||||
|
||||
private Q_SLOTS:
|
||||
void legendChecked( const QVariant&, bool on );
|
||||
|
||||
private:
|
||||
void showCurve( QwtPlotItem*, bool on );
|
||||
|
||||
struct
|
||||
{
|
||||
QwtPlotCurve* curve;
|
||||
double data[HISTORY];
|
||||
} m_data[NCpuData];
|
||||
|
||||
double m_timeData[HISTORY];
|
||||
|
||||
int m_dataCount;
|
||||
CpuStat m_cpuStat;
|
||||
};
|
||||
234
examples/cpuplot/CpuStat.cpp
Normal file
234
examples/cpuplot/CpuStat.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CpuStat.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
CpuStat::CpuStat()
|
||||
{
|
||||
lookUp( m_procValues );
|
||||
}
|
||||
|
||||
QTime CpuStat::upTime() const
|
||||
{
|
||||
QTime t( 0, 0, 0 );
|
||||
for ( int i = 0; i < NValues; i++ )
|
||||
t = t.addSecs( int( m_procValues[i] / 100 ) );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void CpuStat::statistic( double& user, double& system )
|
||||
{
|
||||
double values[NValues];
|
||||
|
||||
lookUp( values );
|
||||
|
||||
double userDelta = values[User] + values[Nice]
|
||||
- m_procValues[User] - m_procValues[Nice];
|
||||
double systemDelta = values[System] - m_procValues[System];
|
||||
|
||||
double totalDelta = 0;
|
||||
for ( int i = 0; i < NValues; i++ )
|
||||
totalDelta += values[i] - m_procValues[i];
|
||||
|
||||
user = userDelta / totalDelta * 100.0;
|
||||
system = systemDelta / totalDelta * 100.0;
|
||||
|
||||
for ( int j = 0; j < NValues; j++ )
|
||||
m_procValues[j] = values[j];
|
||||
}
|
||||
|
||||
void CpuStat::lookUp( double values[NValues] ) const
|
||||
{
|
||||
QFile file( "/proc/stat" );
|
||||
#if 1
|
||||
if ( !file.open( QIODevice::ReadOnly ) )
|
||||
#else
|
||||
if ( true )
|
||||
#endif
|
||||
{
|
||||
static double dummyValues[][NValues] =
|
||||
{
|
||||
{ 103726, 0, 23484, 819556 },
|
||||
{ 103783, 0, 23489, 819604 },
|
||||
{ 103798, 0, 23490, 819688 },
|
||||
{ 103820, 0, 23490, 819766 },
|
||||
{ 103840, 0, 23493, 819843 },
|
||||
{ 103875, 0, 23499, 819902 },
|
||||
{ 103917, 0, 23504, 819955 },
|
||||
{ 103950, 0, 23508, 820018 },
|
||||
{ 103987, 0, 23510, 820079 },
|
||||
{ 104020, 0, 23513, 820143 },
|
||||
{ 104058, 0, 23514, 820204 },
|
||||
{ 104099, 0, 23520, 820257 },
|
||||
{ 104121, 0, 23525, 820330 },
|
||||
{ 104159, 0, 23530, 820387 },
|
||||
{ 104176, 0, 23534, 820466 },
|
||||
{ 104215, 0, 23538, 820523 },
|
||||
{ 104245, 0, 23541, 820590 },
|
||||
{ 104267, 0, 23545, 820664 },
|
||||
{ 104311, 0, 23555, 820710 },
|
||||
{ 104355, 0, 23565, 820756 },
|
||||
{ 104367, 0, 23567, 820842 },
|
||||
{ 104383, 0, 23572, 820921 },
|
||||
{ 104396, 0, 23577, 821003 },
|
||||
{ 104413, 0, 23579, 821084 },
|
||||
{ 104446, 0, 23588, 821142 },
|
||||
{ 104521, 0, 23594, 821161 },
|
||||
{ 104611, 0, 23604, 821161 },
|
||||
{ 104708, 0, 23607, 821161 },
|
||||
{ 104804, 0, 23611, 821161 },
|
||||
{ 104895, 0, 23620, 821161 },
|
||||
{ 104993, 0, 23622, 821161 },
|
||||
{ 105089, 0, 23626, 821161 },
|
||||
{ 105185, 0, 23630, 821161 },
|
||||
{ 105281, 0, 23634, 821161 },
|
||||
{ 105379, 0, 23636, 821161 },
|
||||
{ 105472, 0, 23643, 821161 },
|
||||
{ 105569, 0, 23646, 821161 },
|
||||
{ 105666, 0, 23649, 821161 },
|
||||
{ 105763, 0, 23652, 821161 },
|
||||
{ 105828, 0, 23661, 821187 },
|
||||
{ 105904, 0, 23666, 821206 },
|
||||
{ 105999, 0, 23671, 821206 },
|
||||
{ 106094, 0, 23676, 821206 },
|
||||
{ 106184, 0, 23686, 821206 },
|
||||
{ 106273, 0, 23692, 821211 },
|
||||
{ 106306, 0, 23700, 821270 },
|
||||
{ 106341, 0, 23703, 821332 },
|
||||
{ 106392, 0, 23709, 821375 },
|
||||
{ 106423, 0, 23715, 821438 },
|
||||
{ 106472, 0, 23721, 821483 },
|
||||
{ 106531, 0, 23727, 821517 },
|
||||
{ 106562, 0, 23732, 821582 },
|
||||
{ 106597, 0, 23736, 821643 },
|
||||
{ 106633, 0, 23737, 821706 },
|
||||
{ 106666, 0, 23742, 821768 },
|
||||
{ 106697, 0, 23744, 821835 },
|
||||
{ 106730, 0, 23748, 821898 },
|
||||
{ 106765, 0, 23751, 821960 },
|
||||
{ 106799, 0, 23754, 822023 },
|
||||
{ 106831, 0, 23758, 822087 },
|
||||
{ 106862, 0, 23761, 822153 },
|
||||
{ 106899, 0, 23763, 822214 },
|
||||
{ 106932, 0, 23766, 822278 },
|
||||
{ 106965, 0, 23768, 822343 },
|
||||
{ 107009, 0, 23771, 822396 },
|
||||
{ 107040, 0, 23775, 822461 },
|
||||
{ 107092, 0, 23780, 822504 },
|
||||
{ 107143, 0, 23787, 822546 },
|
||||
{ 107200, 0, 23795, 822581 },
|
||||
{ 107250, 0, 23803, 822623 },
|
||||
{ 107277, 0, 23810, 822689 },
|
||||
{ 107286, 0, 23810, 822780 },
|
||||
{ 107313, 0, 23817, 822846 },
|
||||
{ 107325, 0, 23818, 822933 },
|
||||
{ 107332, 0, 23818, 823026 },
|
||||
{ 107344, 0, 23821, 823111 },
|
||||
{ 107357, 0, 23821, 823198 },
|
||||
{ 107368, 0, 23823, 823284 },
|
||||
{ 107375, 0, 23824, 823377 },
|
||||
{ 107386, 0, 23825, 823465 },
|
||||
{ 107396, 0, 23826, 823554 },
|
||||
{ 107422, 0, 23830, 823624 },
|
||||
{ 107434, 0, 23831, 823711 },
|
||||
{ 107456, 0, 23835, 823785 },
|
||||
{ 107468, 0, 23838, 823870 },
|
||||
{ 107487, 0, 23840, 823949 },
|
||||
{ 107515, 0, 23843, 824018 },
|
||||
{ 107528, 0, 23846, 824102 },
|
||||
{ 107535, 0, 23851, 824190 },
|
||||
{ 107548, 0, 23853, 824275 },
|
||||
{ 107562, 0, 23857, 824357 },
|
||||
{ 107656, 0, 23863, 824357 },
|
||||
{ 107751, 0, 23868, 824357 },
|
||||
{ 107849, 0, 23870, 824357 },
|
||||
{ 107944, 0, 23875, 824357 },
|
||||
{ 108043, 0, 23876, 824357 },
|
||||
{ 108137, 0, 23882, 824357 },
|
||||
{ 108230, 0, 23889, 824357 },
|
||||
{ 108317, 0, 23902, 824357 },
|
||||
{ 108412, 0, 23907, 824357 },
|
||||
{ 108511, 0, 23908, 824357 },
|
||||
{ 108608, 0, 23911, 824357 },
|
||||
{ 108704, 0, 23915, 824357 },
|
||||
{ 108801, 0, 23918, 824357 },
|
||||
{ 108891, 0, 23928, 824357 },
|
||||
{ 108987, 0, 23932, 824357 },
|
||||
{ 109072, 0, 23943, 824361 },
|
||||
{ 109079, 0, 23943, 824454 },
|
||||
{ 109086, 0, 23944, 824546 },
|
||||
{ 109098, 0, 23950, 824628 },
|
||||
{ 109108, 0, 23955, 824713 },
|
||||
{ 109115, 0, 23957, 824804 },
|
||||
{ 109122, 0, 23958, 824896 },
|
||||
{ 109132, 0, 23959, 824985 },
|
||||
{ 109142, 0, 23961, 825073 },
|
||||
{ 109146, 0, 23962, 825168 },
|
||||
{ 109153, 0, 23964, 825259 },
|
||||
{ 109162, 0, 23966, 825348 },
|
||||
{ 109168, 0, 23969, 825439 },
|
||||
{ 109176, 0, 23971, 825529 },
|
||||
{ 109185, 0, 23974, 825617 },
|
||||
{ 109193, 0, 23977, 825706 },
|
||||
{ 109198, 0, 23978, 825800 },
|
||||
{ 109206, 0, 23978, 825892 },
|
||||
{ 109212, 0, 23981, 825983 },
|
||||
{ 109219, 0, 23981, 826076 },
|
||||
{ 109225, 0, 23981, 826170 },
|
||||
{ 109232, 0, 23984, 826260 },
|
||||
{ 109242, 0, 23984, 826350 },
|
||||
{ 109255, 0, 23986, 826435 },
|
||||
{ 109268, 0, 23987, 826521 },
|
||||
{ 109283, 0, 23990, 826603 },
|
||||
{ 109288, 0, 23991, 826697 },
|
||||
{ 109295, 0, 23993, 826788 },
|
||||
{ 109308, 0, 23994, 826874 },
|
||||
{ 109322, 0, 24009, 826945 },
|
||||
{ 109328, 0, 24011, 827037 },
|
||||
{ 109338, 0, 24012, 827126 },
|
||||
{ 109347, 0, 24012, 827217 },
|
||||
{ 109354, 0, 24017, 827305 },
|
||||
{ 109367, 0, 24017, 827392 },
|
||||
{ 109371, 0, 24019, 827486 },
|
||||
};
|
||||
static int counter = 0;
|
||||
|
||||
for ( int i = 0; i < NValues; i++ )
|
||||
values[i] = dummyValues[counter][i];
|
||||
|
||||
counter = ( counter + 1 )
|
||||
% ( sizeof( dummyValues ) / sizeof( dummyValues[0] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream textStream( &file );
|
||||
do
|
||||
{
|
||||
QString line = textStream.readLine();
|
||||
line = line.trimmed();
|
||||
if ( line.startsWith( "cpu " ) )
|
||||
{
|
||||
const QStringList valueList =
|
||||
#if QT_VERSION >= 0x050f00
|
||||
line.split( " ", Qt::SkipEmptyParts );
|
||||
#else
|
||||
line.split( " ", QString::SkipEmptyParts );
|
||||
#endif
|
||||
if ( valueList.count() >= 5 )
|
||||
{
|
||||
for ( int i = 0; i < NValues; i++ )
|
||||
values[i] = valueList[i + 1].toDouble();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while( !textStream.atEnd() );
|
||||
}
|
||||
}
|
||||
33
examples/cpuplot/CpuStat.h
Normal file
33
examples/cpuplot/CpuStat.h
Normal 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 <QTime>
|
||||
|
||||
class CpuStat
|
||||
{
|
||||
public:
|
||||
CpuStat();
|
||||
|
||||
void statistic( double& user, double& system );
|
||||
QTime upTime() const;
|
||||
|
||||
private:
|
||||
|
||||
enum Value
|
||||
{
|
||||
User,
|
||||
Nice,
|
||||
System,
|
||||
Idle,
|
||||
|
||||
NValues
|
||||
};
|
||||
|
||||
void lookUp( double[NValues] ) const;
|
||||
|
||||
double m_procValues[NValues];
|
||||
};
|
||||
19
examples/cpuplot/cpuplot.pro
Normal file
19
examples/cpuplot/cpuplot.pro
Normal file
@@ -0,0 +1,19 @@
|
||||
######################################################################
|
||||
# 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 = cpuplot
|
||||
|
||||
HEADERS = \
|
||||
CpuStat.h \
|
||||
CpuPlot.h \
|
||||
CpuPieMarker.h
|
||||
|
||||
SOURCES = \
|
||||
CpuPlot.cpp \
|
||||
CpuStat.cpp \
|
||||
CpuPieMarker.cpp \
|
||||
main.cpp
|
||||
37
examples/cpuplot/main.cpp
Normal file
37
examples/cpuplot/main.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CpuPlot.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLayout>
|
||||
#include <QLabel>
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
QWidget vBox;
|
||||
vBox.setWindowTitle( "Cpu Plot" );
|
||||
|
||||
CpuPlot* plot = new CpuPlot( &vBox );
|
||||
plot->setTitle( "History" );
|
||||
|
||||
const int margin = 5;
|
||||
plot->setContentsMargins( margin, margin, margin, margin );
|
||||
|
||||
QString info( "Press the legend to en/disable a curve" );
|
||||
|
||||
QLabel* label = new QLabel( info, &vBox );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( &vBox );
|
||||
layout->addWidget( plot );
|
||||
layout->addWidget( label );
|
||||
|
||||
vBox.resize( 600, 400 );
|
||||
vBox.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
15
examples/curvedemo/curvedemo.pro
Normal file
15
examples/curvedemo/curvedemo.pro
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################
|
||||
# Qwt Examples
|
||||
# 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 = curvedemo
|
||||
|
||||
SOURCES = \
|
||||
main.cpp
|
||||
184
examples/curvedemo/main.cpp
Normal file
184
examples/curvedemo/main.cpp
Normal file
@@ -0,0 +1,184 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* 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 <QwtScaleMap>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtSymbol>
|
||||
#include <QwtMath>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QFrame>
|
||||
|
||||
const int Size = 27;
|
||||
const int CurvCnt = 6;
|
||||
|
||||
namespace
|
||||
{
|
||||
class CurveBox : public QFrame
|
||||
{
|
||||
public:
|
||||
CurveBox();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent* ) QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
void drawCurves( QPainter* );
|
||||
void populate();
|
||||
void shiftDown( QRect& rect, int offset ) const;
|
||||
|
||||
QwtPlotCurve m_curves[CurvCnt];
|
||||
|
||||
QwtScaleMap xMap;
|
||||
QwtScaleMap yMap;
|
||||
|
||||
double xval[Size];
|
||||
double yval[Size];
|
||||
};
|
||||
}
|
||||
|
||||
CurveBox::CurveBox()
|
||||
{
|
||||
xMap.setScaleInterval( -0.5, 10.5 );
|
||||
yMap.setScaleInterval( -1.1, 1.1 );
|
||||
|
||||
setFrameStyle( QFrame::Box | QFrame::Raised );
|
||||
setLineWidth( 2 );
|
||||
setMidLineWidth( 3 );
|
||||
|
||||
for( int i = 0; i < Size; i++ )
|
||||
{
|
||||
xval[i] = double( i ) * 10.0 / double( Size - 1 );
|
||||
yval[i] = std::sin( xval[i] ) * std::cos( 2.0 * xval[i] );
|
||||
}
|
||||
|
||||
populate();
|
||||
}
|
||||
|
||||
void CurveBox::populate()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
m_curves[i].setSymbol( new QwtSymbol( QwtSymbol::Cross, Qt::NoBrush,
|
||||
QPen( Qt::black ), QSize( 5, 5 ) ) );
|
||||
m_curves[i].setPen( Qt::darkGreen );
|
||||
m_curves[i].setStyle( QwtPlotCurve::Lines );
|
||||
m_curves[i].setCurveAttribute( QwtPlotCurve::Fitted );
|
||||
i++;
|
||||
|
||||
m_curves[i].setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::yellow,
|
||||
QPen( Qt::blue ), QSize( 5, 5 ) ) );
|
||||
m_curves[i].setPen( Qt::red );
|
||||
m_curves[i].setStyle( QwtPlotCurve::Sticks );
|
||||
i++;
|
||||
|
||||
m_curves[i].setPen( Qt::darkBlue );
|
||||
m_curves[i].setStyle( QwtPlotCurve::Lines );
|
||||
i++;
|
||||
|
||||
m_curves[i].setPen( Qt::darkBlue );
|
||||
m_curves[i].setStyle( QwtPlotCurve::Lines );
|
||||
m_curves[i].setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
i++;
|
||||
|
||||
m_curves[i].setPen( Qt::darkCyan );
|
||||
m_curves[i].setStyle( QwtPlotCurve::Steps );
|
||||
i++;
|
||||
|
||||
m_curves[i].setSymbol( new QwtSymbol( QwtSymbol::XCross, Qt::NoBrush,
|
||||
QPen( Qt::darkMagenta ), QSize( 5, 5 ) ) );
|
||||
m_curves[i].setStyle( QwtPlotCurve::NoCurve );
|
||||
i++;
|
||||
|
||||
for( i = 0; i < CurvCnt; i++ )
|
||||
m_curves[i].setRawSamples( xval, yval, Size );
|
||||
}
|
||||
|
||||
void CurveBox::shiftDown( QRect& rect, int offset ) const
|
||||
{
|
||||
rect.translate( 0, offset );
|
||||
}
|
||||
|
||||
void CurveBox::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
QFrame::paintEvent( event );
|
||||
|
||||
QPainter painter( this );
|
||||
painter.setClipRect( contentsRect() );
|
||||
|
||||
drawCurves( &painter );
|
||||
}
|
||||
|
||||
void CurveBox::drawCurves( QPainter* painter )
|
||||
{
|
||||
int deltay, i;
|
||||
|
||||
QRect r = contentsRect();
|
||||
|
||||
deltay = r.height() / CurvCnt - 1;
|
||||
|
||||
r.setHeight( deltay );
|
||||
|
||||
// draw curves
|
||||
for ( i = 0; i < CurvCnt; i++ )
|
||||
{
|
||||
xMap.setPaintInterval( r.left(), r.right() );
|
||||
yMap.setPaintInterval( r.top(), r.bottom() );
|
||||
|
||||
painter->setRenderHint( QPainter::Antialiasing,
|
||||
m_curves[i].testRenderHint( QwtPlotItem::RenderAntialiased ) );
|
||||
m_curves[i].draw( painter, xMap, yMap, r );
|
||||
|
||||
shiftDown( r, deltay );
|
||||
}
|
||||
|
||||
// draw titles
|
||||
r = contentsRect();
|
||||
painter->setFont( QFont( "Helvetica", 8 ) );
|
||||
|
||||
const int alignment = Qt::AlignTop | Qt::AlignHCenter;
|
||||
|
||||
painter->setPen( Qt::black );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: Line/Fitted, Symbol: Cross" );
|
||||
shiftDown( r, deltay );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: Sticks, Symbol: Ellipse" );
|
||||
shiftDown( r, deltay );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: Lines, Symbol: None" );
|
||||
shiftDown( r, deltay );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: Lines, Symbol: None, Antialiased" );
|
||||
shiftDown( r, deltay );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: Steps, Symbol: None" );
|
||||
shiftDown( r, deltay );
|
||||
|
||||
painter->drawText( 0, r.top(), r.width(), painter->fontMetrics().height(),
|
||||
alignment, "Style: NoCurve, Symbol: XCross" );
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
CurveBox curveBox;
|
||||
|
||||
curveBox.resize( 300, 600 );
|
||||
curveBox.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
146
examples/dials/AttitudeIndicator.cpp
Normal file
146
examples/dials/AttitudeIndicator.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "AttitudeIndicator.h"
|
||||
|
||||
#include <QwtPointPolar>
|
||||
#include <QwtRoundScaleDraw>
|
||||
#include <QwtDialNeedle>
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Needle : public QwtDialNeedle
|
||||
{
|
||||
public:
|
||||
|
||||
Needle( const QColor& color )
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor( QPalette::Text, color );
|
||||
setPalette( palette );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void drawNeedle( QPainter* painter,
|
||||
double length, QPalette::ColorGroup colorGroup ) const QWT_OVERRIDE
|
||||
{
|
||||
double triangleSize = length * 0.1;
|
||||
double pos = length - 2.0;
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo( pos, 0 );
|
||||
path.lineTo( pos - 2 * triangleSize, triangleSize );
|
||||
path.lineTo( pos - 2 * triangleSize, -triangleSize );
|
||||
path.closeSubpath();
|
||||
|
||||
painter->setBrush( palette().brush( colorGroup, QPalette::Text ) );
|
||||
painter->drawPath( path );
|
||||
|
||||
double l = length - 2;
|
||||
painter->setPen( QPen( palette().color( colorGroup, QPalette::Text ), 3 ) );
|
||||
painter->drawLine( QPointF( 0.0, -l ), QPointF( 0.0, l ) );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AttitudeIndicator::AttitudeIndicator( QWidget* parent )
|
||||
: QwtDial( parent )
|
||||
, m_gradient( 0.0 )
|
||||
{
|
||||
QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw();
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Labels, false );
|
||||
setScaleDraw( scaleDraw );
|
||||
|
||||
setMode( RotateScale );
|
||||
setWrapping( true );
|
||||
|
||||
setOrigin( 270.0 );
|
||||
|
||||
setScaleMaxMinor( 0 );
|
||||
setScaleStepSize( 30.0 );
|
||||
setScale( 0.0, 360.0 );
|
||||
|
||||
const QColor color = palette().color( QPalette::Text );
|
||||
setNeedle( new Needle( color ) );
|
||||
}
|
||||
|
||||
void AttitudeIndicator::setGradient( double gradient )
|
||||
{
|
||||
if ( gradient < -1.0 )
|
||||
gradient = -1.0;
|
||||
else if ( gradient > 1.0 )
|
||||
gradient = 1.0;
|
||||
|
||||
if ( m_gradient != gradient )
|
||||
{
|
||||
m_gradient = gradient;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void AttitudeIndicator::drawScale( QPainter* painter,
|
||||
const QPointF& center, double radius ) const
|
||||
{
|
||||
const double offset = 4.0;
|
||||
|
||||
const QPointF p0 = qwtPolar2Pos( center, offset, 1.5 * M_PI );
|
||||
|
||||
const double w = innerRect().width();
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo( qwtPolar2Pos( p0, w, 0.0 ) );
|
||||
path.lineTo( qwtPolar2Pos( path.currentPosition(), 2 * w, M_PI ) );
|
||||
path.lineTo( qwtPolar2Pos( path.currentPosition(), w, 0.5 * M_PI ) );
|
||||
path.lineTo( qwtPolar2Pos( path.currentPosition(), w, 0.0 ) );
|
||||
|
||||
painter->save();
|
||||
painter->setClipPath( path ); // swallow 180 - 360 degrees
|
||||
|
||||
QwtDial::drawScale( painter, center, radius );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void AttitudeIndicator::drawScaleContents(
|
||||
QPainter* painter, const QPointF&, double ) const
|
||||
{
|
||||
int dir = 360 - qRound( origin() - value() ); // counter clockwise
|
||||
int arc = 90 + qRound( gradient() * 90 );
|
||||
|
||||
const QColor skyColor( 38, 151, 221 );
|
||||
|
||||
painter->save();
|
||||
painter->setBrush( skyColor );
|
||||
painter->drawChord( scaleInnerRect(),
|
||||
( dir - arc ) * 16, 2 * arc * 16 );
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void AttitudeIndicator::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
switch( event->key() )
|
||||
{
|
||||
case Qt::Key_Plus:
|
||||
{
|
||||
setGradient( gradient() + 0.05 );
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Minus:
|
||||
{
|
||||
setGradient( gradient() - 0.05 );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
QwtDial::keyPressEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_AttitudeIndicator.cpp"
|
||||
35
examples/dials/AttitudeIndicator.h
Normal file
35
examples/dials/AttitudeIndicator.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtDial>
|
||||
|
||||
class AttitudeIndicator : public QwtDial
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AttitudeIndicator( QWidget* parent = NULL );
|
||||
|
||||
double angle() const { return value(); }
|
||||
double gradient() const { return m_gradient; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void setGradient( double );
|
||||
void setAngle( double angle ) { setValue( angle ); }
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent( QKeyEvent* ) QWT_OVERRIDE;
|
||||
|
||||
virtual void drawScale( QPainter*,
|
||||
const QPointF& center, double radius ) const QWT_OVERRIDE;
|
||||
|
||||
virtual void drawScaleContents( QPainter* painter,
|
||||
const QPointF& center, double radius ) const QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
double m_gradient;
|
||||
};
|
||||
239
examples/dials/CockpitGrid.cpp
Normal file
239
examples/dials/CockpitGrid.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CockpitGrid.h"
|
||||
#include "AttitudeIndicator.h"
|
||||
#include "SpeedoMeter.h"
|
||||
|
||||
#include <QwtAnalogClock>
|
||||
#include <QwtRoundScaleDraw>
|
||||
#include <QwtDialNeedle>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QTimer>
|
||||
#include <QTimerEvent>
|
||||
|
||||
static QPalette colorTheme( const QColor& base )
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor( QPalette::Base, base );
|
||||
palette.setColor( QPalette::Window, base.darker( 150 ) );
|
||||
palette.setColor( QPalette::Mid, base.darker( 110 ) );
|
||||
palette.setColor( QPalette::Light, base.lighter( 170 ) );
|
||||
palette.setColor( QPalette::Dark, base.darker( 170 ) );
|
||||
palette.setColor( QPalette::Text, base.darker( 200 ).lighter( 800 ) );
|
||||
palette.setColor( QPalette::WindowText, base.darker( 200 ) );
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class Clock : public QwtAnalogClock
|
||||
{
|
||||
public:
|
||||
Clock( QWidget* parent = NULL )
|
||||
: QwtAnalogClock( parent )
|
||||
{
|
||||
#if 0
|
||||
// disable minor ticks
|
||||
scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
#endif
|
||||
|
||||
const QColor knobColor = QColor( Qt::gray ).lighter( 130 );
|
||||
|
||||
for ( int i = 0; i < QwtAnalogClock::NHands; i++ )
|
||||
{
|
||||
QColor handColor = QColor( Qt::gray ).lighter( 150 );
|
||||
int width = 8;
|
||||
|
||||
if ( i == QwtAnalogClock::SecondHand )
|
||||
{
|
||||
handColor = Qt::gray;
|
||||
width = 5;
|
||||
}
|
||||
|
||||
QwtDialSimpleNeedle* hand = new QwtDialSimpleNeedle(
|
||||
QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
|
||||
hand->setWidth( width );
|
||||
|
||||
setHand( static_cast< QwtAnalogClock::Hand >( i ), hand );
|
||||
}
|
||||
|
||||
QTimer* timer = new QTimer( this );
|
||||
timer->connect( timer, SIGNAL(timeout()), this, SLOT(setCurrentTime()) );
|
||||
timer->start( 1000 );
|
||||
}
|
||||
};
|
||||
|
||||
class Speedo : public SpeedoMeter
|
||||
{
|
||||
public:
|
||||
Speedo( QWidget* parent = NULL )
|
||||
: SpeedoMeter( parent )
|
||||
{
|
||||
setScaleStepSize( 20.0 );
|
||||
setScale( 0.0, 240.0 );
|
||||
scaleDraw()->setPenWidthF( 2 );
|
||||
|
||||
m_timerId = startTimer( 50 );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void timerEvent( QTimerEvent* event ) QWT_OVERRIDE
|
||||
{
|
||||
if ( event->timerId() == m_timerId )
|
||||
{
|
||||
changeSpeed();
|
||||
return;
|
||||
}
|
||||
|
||||
SpeedoMeter::timerEvent( event );
|
||||
}
|
||||
|
||||
private:
|
||||
void changeSpeed()
|
||||
{
|
||||
static double offset = 0.8;
|
||||
|
||||
double speed = value();
|
||||
|
||||
if ( ( speed < 7.0 && offset < 0.0 ) ||
|
||||
( speed > 203.0 && offset > 0.0 ) )
|
||||
{
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
static int counter = 0;
|
||||
|
||||
switch( counter++ % 12 )
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
case 7:
|
||||
case 8:
|
||||
break;
|
||||
default:
|
||||
setValue( speed + offset );
|
||||
}
|
||||
}
|
||||
|
||||
int m_timerId;
|
||||
};
|
||||
|
||||
class AttitudeInstrument : public AttitudeIndicator
|
||||
{
|
||||
public:
|
||||
AttitudeInstrument( QWidget* parent = NULL )
|
||||
: AttitudeIndicator( parent )
|
||||
{
|
||||
scaleDraw()->setPenWidthF( 3 );
|
||||
m_timerId = startTimer( 100 );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void timerEvent( QTimerEvent* event ) QWT_OVERRIDE
|
||||
{
|
||||
if ( event->timerId() == m_timerId )
|
||||
{
|
||||
changeAngle();
|
||||
changeGradient();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AttitudeIndicator::timerEvent( event );
|
||||
}
|
||||
|
||||
private:
|
||||
void changeAngle()
|
||||
{
|
||||
static double offset = 0.05;
|
||||
|
||||
double angle = this->angle();
|
||||
if ( angle > 180.0 )
|
||||
angle -= 360.0;
|
||||
|
||||
if ( ( angle < -5.0 && offset < 0.0 ) ||
|
||||
( angle > 5.0 && offset > 0.0 ) )
|
||||
{
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
setAngle( angle + offset );
|
||||
}
|
||||
|
||||
void changeGradient()
|
||||
{
|
||||
static double offset = 0.005;
|
||||
|
||||
double gradient = this->gradient();
|
||||
|
||||
if ( ( gradient < -0.05 && offset < 0.0 ) ||
|
||||
( gradient > 0.05 && offset > 0.0 ) )
|
||||
{
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
setGradient( gradient + offset );
|
||||
}
|
||||
|
||||
int m_timerId;
|
||||
};
|
||||
}
|
||||
|
||||
CockpitGrid::CockpitGrid( QWidget* parent )
|
||||
: QFrame( parent )
|
||||
{
|
||||
setAutoFillBackground( true );
|
||||
|
||||
setPalette( colorTheme( QColor( Qt::darkGray ).darker( 150 ) ) );
|
||||
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
layout->setSpacing( 5 );
|
||||
layout->setContentsMargins( QMargins() );
|
||||
|
||||
for ( int i = 0; i < 3; i++ )
|
||||
{
|
||||
QwtDial* dial = createDial( i );
|
||||
layout->addWidget( dial, 0, i );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < layout->columnCount(); i++ )
|
||||
layout->setColumnStretch( i, 1 );
|
||||
}
|
||||
|
||||
QwtDial* CockpitGrid::createDial( int pos )
|
||||
{
|
||||
QwtDial* dial = NULL;
|
||||
|
||||
switch( pos )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
dial = new Clock( this );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
dial = new Speedo( this );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
dial = new AttitudeInstrument( this );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( dial )
|
||||
{
|
||||
dial->setReadOnly( true );
|
||||
dial->setLineWidth( 4 );
|
||||
dial->setFrameShadow( QwtDial::Sunken );
|
||||
}
|
||||
|
||||
return dial;
|
||||
}
|
||||
19
examples/dials/CockpitGrid.h
Normal file
19
examples/dials/CockpitGrid.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QwtDial;
|
||||
|
||||
class CockpitGrid : public QFrame
|
||||
{
|
||||
public:
|
||||
CockpitGrid( QWidget* parent = NULL );
|
||||
|
||||
private:
|
||||
QwtDial* createDial( int pos );
|
||||
};
|
||||
228
examples/dials/CompassGrid.cpp
Normal file
228
examples/dials/CompassGrid.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CompassGrid.h"
|
||||
|
||||
#include <QwtCompass>
|
||||
#include <QwtCompassRose>
|
||||
#include <QwtDialNeedle>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QMap>
|
||||
|
||||
CompassGrid::CompassGrid( QWidget* parent )
|
||||
: QFrame( parent )
|
||||
{
|
||||
QPalette p = palette();
|
||||
p.setColor( backgroundRole(), Qt::gray );
|
||||
setPalette( p );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
layout->setSpacing( 5 );
|
||||
layout->setContentsMargins( QMargins() );
|
||||
|
||||
for ( int i = 0; i < 6; i++ )
|
||||
{
|
||||
QwtCompass* compass = createCompass( i );
|
||||
layout->addWidget( compass, i / 3, i % 3 );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < layout->columnCount(); i++ )
|
||||
layout->setColumnStretch( i, 1 );
|
||||
}
|
||||
|
||||
QwtCompass* CompassGrid::createCompass( int pos )
|
||||
{
|
||||
QPalette palette0;
|
||||
for ( int c = 0; c < QPalette::NColorRoles; c++ )
|
||||
{
|
||||
const QPalette::ColorRole colorRole =
|
||||
static_cast< QPalette::ColorRole >( c );
|
||||
|
||||
palette0.setColor( colorRole, QColor() );
|
||||
}
|
||||
|
||||
palette0.setColor( QPalette::Base,
|
||||
palette().color( backgroundRole() ).lighter( 120 ) );
|
||||
|
||||
palette0.setColor( QPalette::WindowText,
|
||||
palette0.color( QPalette::Base ) );
|
||||
|
||||
QwtCompass* compass = new QwtCompass( this );
|
||||
compass->setLineWidth( 4 );
|
||||
compass->setFrameShadow(
|
||||
pos <= 2 ? QwtCompass::Sunken : QwtCompass::Raised );
|
||||
|
||||
switch( pos )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
/*
|
||||
A compass with a rose and no needle. Scale and rose are
|
||||
rotating.
|
||||
*/
|
||||
compass->setMode( QwtCompass::RotateScale );
|
||||
|
||||
QwtSimpleCompassRose* rose = new QwtSimpleCompassRose( 16, 2 );
|
||||
rose->setWidth( 0.15 );
|
||||
|
||||
compass->setRose( rose );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
/*
|
||||
A windrose, with a scale indicating the main directions only
|
||||
*/
|
||||
QMap< double, QString > map;
|
||||
map.insert( 0.0, "N" );
|
||||
map.insert( 90.0, "E" );
|
||||
map.insert( 180.0, "S" );
|
||||
map.insert( 270.0, "W" );
|
||||
|
||||
compass->setScaleDraw( new QwtCompassScaleDraw( map ) );
|
||||
|
||||
QwtSimpleCompassRose* rose = new QwtSimpleCompassRose( 4, 1 );
|
||||
compass->setRose( rose );
|
||||
|
||||
compass->setNeedle(
|
||||
new QwtCompassWindArrow( QwtCompassWindArrow::Style2 ) );
|
||||
compass->setValue( 60.0 );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
/*
|
||||
A compass with a rotating needle in darkBlue. Shows
|
||||
a ticks for each degree.
|
||||
*/
|
||||
|
||||
palette0.setColor( QPalette::Base, Qt::darkBlue );
|
||||
palette0.setColor( QPalette::WindowText,
|
||||
QColor( Qt::darkBlue ).darker( 120 ) );
|
||||
palette0.setColor( QPalette::Text, Qt::white );
|
||||
|
||||
QwtCompassScaleDraw* scaleDraw = new QwtCompassScaleDraw();
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Ticks, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Labels, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 1 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 1 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 3 );
|
||||
|
||||
compass->setScaleDraw( scaleDraw );
|
||||
|
||||
compass->setScaleMaxMajor( 36 );
|
||||
compass->setScaleMaxMinor( 5 );
|
||||
|
||||
compass->setNeedle(
|
||||
new QwtCompassMagnetNeedle( QwtCompassMagnetNeedle::ThinStyle ) );
|
||||
compass->setValue( 220.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
/*
|
||||
A compass without a frame, showing numbers as tick labels.
|
||||
The origin is at 220.0
|
||||
*/
|
||||
palette0.setColor( QPalette::Base,
|
||||
palette().color( backgroundRole() ) );
|
||||
palette0.setColor( QPalette::WindowText, Qt::blue );
|
||||
|
||||
compass->setLineWidth( 0 );
|
||||
|
||||
QMap< double, QString > map;
|
||||
for ( int d = 0; d < 360; d += 60 )
|
||||
map.insert( d, QString::number( d ) );
|
||||
|
||||
QwtCompassScaleDraw* scaleDraw =
|
||||
new QwtCompassScaleDraw( map );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Ticks, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Labels, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, true );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 0 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 3 );
|
||||
|
||||
compass->setScaleDraw( scaleDraw );
|
||||
|
||||
compass->setScaleMaxMajor( 36 );
|
||||
compass->setScaleMaxMinor( 5 );
|
||||
|
||||
compass->setNeedle( new QwtDialSimpleNeedle( QwtDialSimpleNeedle::Ray,
|
||||
true, Qt::white ) );
|
||||
compass->setOrigin( 220.0 );
|
||||
compass->setValue( 20.0 );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
/*
|
||||
A compass showing another needle
|
||||
*/
|
||||
QwtCompassScaleDraw* scaleDraw = new QwtCompassScaleDraw();
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Ticks, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Labels, true );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 0 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 3 );
|
||||
|
||||
compass->setScaleDraw( scaleDraw );
|
||||
|
||||
compass->setNeedle( new QwtCompassMagnetNeedle(
|
||||
QwtCompassMagnetNeedle::TriangleStyle, Qt::white, Qt::red ) );
|
||||
compass->setValue( 220.0 );
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
/*
|
||||
A compass with a yellow on black ray
|
||||
*/
|
||||
palette0.setColor( QPalette::WindowText, Qt::black );
|
||||
|
||||
compass->setNeedle( new QwtDialSimpleNeedle( QwtDialSimpleNeedle::Ray,
|
||||
false, Qt::yellow ) );
|
||||
compass->setValue( 315.0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QPalette newPalette = compass->palette();
|
||||
for ( int c = 0; c < QPalette::NColorRoles; c++ )
|
||||
{
|
||||
const QPalette::ColorRole colorRole =
|
||||
static_cast< QPalette::ColorRole >( c );
|
||||
|
||||
if ( palette0.color( colorRole ).isValid() )
|
||||
newPalette.setColor( colorRole, palette0.color( colorRole ) );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < QPalette::NColorGroups; i++ )
|
||||
{
|
||||
const QPalette::ColorGroup colorGroup =
|
||||
static_cast< QPalette::ColorGroup >( i );
|
||||
|
||||
const QColor light =
|
||||
newPalette.color( colorGroup, QPalette::Base ).lighter( 170 );
|
||||
const QColor dark = newPalette.color( colorGroup, QPalette::Base ).darker( 170 );
|
||||
const QColor mid = compass->frameShadow() == QwtDial::Raised
|
||||
? newPalette.color( colorGroup, QPalette::Base ).darker( 110 )
|
||||
: newPalette.color( colorGroup, QPalette::Base ).lighter( 110 );
|
||||
|
||||
newPalette.setColor( colorGroup, QPalette::Dark, dark );
|
||||
newPalette.setColor( colorGroup, QPalette::Mid, mid );
|
||||
newPalette.setColor( colorGroup, QPalette::Light, light );
|
||||
}
|
||||
|
||||
compass->setPalette( newPalette );
|
||||
|
||||
return compass;
|
||||
}
|
||||
19
examples/dials/CompassGrid.h
Normal file
19
examples/dials/CompassGrid.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class QwtCompass;
|
||||
|
||||
class CompassGrid : public QFrame
|
||||
{
|
||||
public:
|
||||
CompassGrid( QWidget* parent = NULL );
|
||||
|
||||
private:
|
||||
QwtCompass* createCompass( int pos );
|
||||
};
|
||||
59
examples/dials/SpeedoMeter.cpp
Normal file
59
examples/dials/SpeedoMeter.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpeedoMeter.h"
|
||||
|
||||
#include <QwtDialNeedle>
|
||||
#include <QwtRoundScaleDraw>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
SpeedoMeter::SpeedoMeter( QWidget* parent )
|
||||
: QwtDial( parent )
|
||||
, m_label( "km/h" )
|
||||
{
|
||||
QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw();
|
||||
scaleDraw->setSpacing( 8 );
|
||||
scaleDraw->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 8 );
|
||||
setScaleDraw( scaleDraw );
|
||||
|
||||
setWrapping( false );
|
||||
setReadOnly( true );
|
||||
|
||||
setOrigin( 135.0 );
|
||||
setScaleArc( 0.0, 270.0 );
|
||||
|
||||
QwtDialSimpleNeedle* needle = new QwtDialSimpleNeedle(
|
||||
QwtDialSimpleNeedle::Arrow, true, Qt::red,
|
||||
QColor( Qt::gray ).lighter( 130 ) );
|
||||
setNeedle( needle );
|
||||
}
|
||||
|
||||
void SpeedoMeter::setLabel( const QString& label )
|
||||
{
|
||||
m_label = label;
|
||||
update();
|
||||
}
|
||||
|
||||
QString SpeedoMeter::label() const
|
||||
{
|
||||
return m_label;
|
||||
}
|
||||
|
||||
void SpeedoMeter::drawScaleContents( QPainter* painter,
|
||||
const QPointF& center, double radius ) const
|
||||
{
|
||||
QRectF rect( 0.0, 0.0, 2.0 * radius, 2.0 * radius - 10.0 );
|
||||
rect.moveCenter( center );
|
||||
|
||||
const QColor color = palette().color( QPalette::Text );
|
||||
painter->setPen( color );
|
||||
|
||||
const int flags = Qt::AlignBottom | Qt::AlignHCenter;
|
||||
painter->drawText( rect, flags, m_label );
|
||||
}
|
||||
25
examples/dials/SpeedoMeter.h
Normal file
25
examples/dials/SpeedoMeter.h
Normal 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 <QString>
|
||||
#include <QwtDial>
|
||||
|
||||
class SpeedoMeter : public QwtDial
|
||||
{
|
||||
public:
|
||||
SpeedoMeter( QWidget* parent = NULL );
|
||||
|
||||
void setLabel( const QString& );
|
||||
QString label() const;
|
||||
|
||||
protected:
|
||||
virtual void drawScaleContents( QPainter* painter,
|
||||
const QPointF& center, double radius ) const QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
QString m_label;
|
||||
};
|
||||
22
examples/dials/dials.pro
Normal file
22
examples/dials/dials.pro
Normal file
@@ -0,0 +1,22 @@
|
||||
######################################################################
|
||||
# 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 = dials
|
||||
|
||||
HEADERS = \
|
||||
AttitudeIndicator.h \
|
||||
SpeedoMeter.h \
|
||||
CockpitGrid.h \
|
||||
CompassGrid.h
|
||||
|
||||
SOURCES = \
|
||||
AttitudeIndicator.cpp \
|
||||
SpeedoMeter.cpp \
|
||||
CockpitGrid.cpp \
|
||||
CompassGrid.cpp \
|
||||
main.cpp
|
||||
|
||||
24
examples/dials/main.cpp
Normal file
24
examples/dials/main.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "CompassGrid.h"
|
||||
#include "CockpitGrid.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTabWidget>
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
QTabWidget tabWidget;
|
||||
tabWidget.addTab( new CompassGrid, "Compass" );
|
||||
tabWidget.addTab( new CockpitGrid, "Cockpit" );
|
||||
|
||||
tabWidget.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
261
examples/distrowatch/BarChart.cpp
Normal file
261
examples/distrowatch/BarChart.cpp
Normal file
@@ -0,0 +1,261 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "BarChart.h"
|
||||
|
||||
#include <QwtPlotRenderer>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtPlotBarChart>
|
||||
#include <QwtColumnSymbol>
|
||||
#include <QwtPlotLayout>
|
||||
#include <QwtLegend>
|
||||
#include <QwtScaleDraw>
|
||||
#include <QwtText>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
namespace
|
||||
{
|
||||
class ScaleDraw : public QwtScaleDraw
|
||||
{
|
||||
public:
|
||||
ScaleDraw( Qt::Orientation orientation, const QStringList& labels )
|
||||
: m_labels( labels )
|
||||
{
|
||||
setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
setTickLength( QwtScaleDiv::MediumTick, 0 );
|
||||
setTickLength( QwtScaleDiv::MajorTick, 2 );
|
||||
|
||||
enableComponent( QwtScaleDraw::Backbone, false );
|
||||
|
||||
if ( orientation == Qt::Vertical )
|
||||
{
|
||||
setLabelRotation( -60.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
setLabelRotation( -20.0 );
|
||||
}
|
||||
|
||||
setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
}
|
||||
|
||||
virtual QwtText label( double value ) const QWT_OVERRIDE
|
||||
{
|
||||
QwtText lbl;
|
||||
|
||||
const int index = qRound( value );
|
||||
if ( index >= 0 && index < m_labels.size() )
|
||||
{
|
||||
lbl = m_labels[ index ];
|
||||
}
|
||||
|
||||
return lbl;
|
||||
}
|
||||
|
||||
private:
|
||||
const QStringList m_labels;
|
||||
};
|
||||
|
||||
class ChartItem : public QwtPlotBarChart
|
||||
{
|
||||
public:
|
||||
ChartItem()
|
||||
: QwtPlotBarChart( "Page Hits" )
|
||||
{
|
||||
setLegendMode( QwtPlotBarChart::LegendBarTitles );
|
||||
setLegendIconSize( QSize( 10, 14 ) );
|
||||
setLayoutPolicy( AutoAdjustSamples );
|
||||
setLayoutHint( 4.0 ); // minimum width for a single bar
|
||||
|
||||
setSpacing( 10 ); // spacing between bars
|
||||
}
|
||||
|
||||
void addDistro( const QString& distro, const QColor& color )
|
||||
{
|
||||
m_colors += color;
|
||||
m_distros += distro;
|
||||
itemChanged();
|
||||
}
|
||||
|
||||
virtual QwtColumnSymbol* specialSymbol(
|
||||
int index, const QPointF& ) const QWT_OVERRIDE
|
||||
{
|
||||
// we want to have individual colors for each bar
|
||||
|
||||
QwtColumnSymbol* symbol = new QwtColumnSymbol( QwtColumnSymbol::Box );
|
||||
symbol->setLineWidth( 2 );
|
||||
symbol->setFrameStyle( QwtColumnSymbol::Raised );
|
||||
|
||||
QColor c( Qt::white );
|
||||
if ( index >= 0 && index < m_colors.size() )
|
||||
c = m_colors[ index ];
|
||||
|
||||
symbol->setPalette( c );
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
virtual QwtText barTitle( int sampleIndex ) const QWT_OVERRIDE
|
||||
{
|
||||
QwtText title;
|
||||
if ( sampleIndex >= 0 && sampleIndex < m_distros.size() )
|
||||
title = m_distros[ sampleIndex ];
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
private:
|
||||
QList< QColor > m_colors;
|
||||
QList< QString > m_distros;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
BarChart::BarChart( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
{
|
||||
const struct
|
||||
{
|
||||
const char* distro;
|
||||
const int hits;
|
||||
QColor color;
|
||||
|
||||
} pageHits[] =
|
||||
{
|
||||
{ "Arch", 1114, QColor( "DodgerBlue" ) },
|
||||
{ "Debian", 1373, QColor( "#d70751" ) },
|
||||
{ "Fedora", 1638, QColor( "SteelBlue" ) },
|
||||
{ "Mageia", 1395, QColor( "Indigo" ) },
|
||||
{ "Mint", 3874, QColor( 183, 255, 183 ) },
|
||||
{ "openSuSE", 1532, QColor( 115, 186, 37 ) },
|
||||
{ "Puppy", 1059, QColor( "LightSkyBlue" ) },
|
||||
{ "Ubuntu", 2391, QColor( "FireBrick" ) }
|
||||
};
|
||||
|
||||
setAutoFillBackground( true );
|
||||
setPalette( QColor( "Linen" ) );
|
||||
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
canvas->setLineWidth( 2 );
|
||||
canvas->setFrameStyle( QFrame::Box | QFrame::Sunken );
|
||||
canvas->setBorderRadius( 10 );
|
||||
|
||||
QPalette canvasPalette( QColor( "Plum" ) );
|
||||
canvasPalette.setColor( QPalette::WindowText, QColor( "Indigo" ) );
|
||||
canvas->setPalette( canvasPalette );
|
||||
|
||||
setCanvas( canvas );
|
||||
|
||||
setTitle( "DistroWatch Page Hit Ranking, April 2012" );
|
||||
|
||||
ChartItem* chartItem = new ChartItem();
|
||||
|
||||
QVector< double > samples;
|
||||
|
||||
for ( uint i = 0; i < sizeof( pageHits ) / sizeof( pageHits[ 0 ] ); i++ )
|
||||
{
|
||||
m_distros += pageHits[ i ].distro;
|
||||
samples += pageHits[ i ].hits;
|
||||
|
||||
chartItem->addDistro( pageHits[ i ].distro, pageHits[ i ].color );
|
||||
}
|
||||
|
||||
chartItem->setSamples( samples );
|
||||
chartItem->attach( this );
|
||||
|
||||
m_chartItem = chartItem;
|
||||
|
||||
insertLegend( new QwtLegend() );
|
||||
|
||||
setOrientation( 0 );
|
||||
setAutoReplot( false );
|
||||
}
|
||||
|
||||
void BarChart::setOrientation( int o )
|
||||
{
|
||||
const Qt::Orientation orientation =
|
||||
( o == 0 ) ? Qt::Vertical : Qt::Horizontal;
|
||||
|
||||
int axis1 = QwtAxis::XBottom;
|
||||
int axis2 = QwtAxis::YLeft;
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
qSwap( axis1, axis2 );
|
||||
|
||||
m_chartItem->setOrientation( orientation );
|
||||
|
||||
setAxisTitle( axis1, "Distros" );
|
||||
setAxisMaxMinor( axis1, 3 );
|
||||
setAxisScaleDraw( axis1, new ScaleDraw( orientation, m_distros ) );
|
||||
|
||||
setAxisTitle( axis2, "Hits per day ( HPD )" );
|
||||
setAxisMaxMinor( axis2, 3 );
|
||||
|
||||
QwtScaleDraw* scaleDraw = new QwtScaleDraw();
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 );
|
||||
setAxisScaleDraw( axis2, scaleDraw );
|
||||
|
||||
plotLayout()->setCanvasMargin( 0 );
|
||||
replot();
|
||||
}
|
||||
|
||||
void BarChart::exportChart()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( this, "distrowatch.pdf" );
|
||||
}
|
||||
|
||||
void BarChart::doScreenShot()
|
||||
{
|
||||
exportPNG( 800, 600 );
|
||||
}
|
||||
|
||||
void BarChart::exportPNG( int width, int height )
|
||||
{
|
||||
const QString fileBase = QString("distrowatch-%2x%3" ).arg( width ).arg( height);
|
||||
|
||||
const int resolution = qRound( 85.0 * width / 800.0 );
|
||||
|
||||
const double mmToInch = 1.0 / 25.4;
|
||||
const int dotsPerMeter = qRound( resolution * mmToInch * 1000.0 );
|
||||
|
||||
QImage image( width, height, QImage::Format_ARGB32 );
|
||||
image.setDotsPerMeterX( dotsPerMeter );
|
||||
image.setDotsPerMeterY( dotsPerMeter );
|
||||
|
||||
image.fill( Qt::transparent );
|
||||
|
||||
QPainter painter( &image );
|
||||
render( &painter, QRectF( 0, 0, width, height ) );
|
||||
painter.end();
|
||||
|
||||
image.save( fileBase + ".png" );
|
||||
}
|
||||
|
||||
void BarChart::render( QPainter* painter, const QRectF& targetRect )
|
||||
{
|
||||
const int r = 20;
|
||||
const QRectF plotRect = targetRect.adjusted( 0.5 * r, 0.5 * r, -0.5 * r, -0.5 * r );
|
||||
|
||||
QwtPlotRenderer renderer;
|
||||
|
||||
if ( qApp->styleSheet().isEmpty() )
|
||||
{
|
||||
renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, true );
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
painter->setPen( QPen( Qt::darkGray, 1 ) );
|
||||
painter->setBrush( QColor( "WhiteSmoke" ) );
|
||||
painter->drawRoundedRect( targetRect, r, r );
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
renderer.render( this, painter, plotRect );
|
||||
}
|
||||
|
||||
#include "moc_BarChart.cpp"
|
||||
32
examples/distrowatch/BarChart.h
Normal file
32
examples/distrowatch/BarChart.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*****************************************************************************
|
||||
* 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 <QStringList>
|
||||
|
||||
class QwtPlotBarChart;
|
||||
|
||||
class BarChart : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BarChart( QWidget* = NULL );
|
||||
|
||||
public Q_SLOTS:
|
||||
void setOrientation( int );
|
||||
void exportChart();
|
||||
void doScreenShot();
|
||||
|
||||
private:
|
||||
void populate();
|
||||
void exportPNG( int width, int height );
|
||||
void render( QPainter* painter, const QRectF& targetRect );
|
||||
|
||||
QwtPlotBarChart* m_chartItem;
|
||||
QStringList m_distros;
|
||||
};
|
||||
15
examples/distrowatch/distrowatch.pro
Normal file
15
examples/distrowatch/distrowatch.pro
Normal 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 = distrowatch
|
||||
|
||||
HEADERS = \
|
||||
BarChart.h
|
||||
|
||||
SOURCES = \
|
||||
BarChart.cpp \
|
||||
main.cpp
|
||||
67
examples/distrowatch/main.cpp
Normal file
67
examples/distrowatch/main.cpp
Normal 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 "BarChart.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
|
||||
namespace
|
||||
{
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow( QWidget* = NULL );
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
MainWindow::MainWindow( QWidget* parent )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
BarChart* chart = new BarChart( this );
|
||||
setCentralWidget( chart );
|
||||
|
||||
QToolBar* toolBar = new QToolBar( this );
|
||||
|
||||
QComboBox* orientationBox = new QComboBox( toolBar );
|
||||
orientationBox->addItem( "Vertical" );
|
||||
orientationBox->addItem( "Horizontal" );
|
||||
orientationBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
QToolButton* btnExport = new QToolButton( toolBar );
|
||||
btnExport->setText( "Export" );
|
||||
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
connect( btnExport, SIGNAL(clicked()), chart, SLOT(exportChart()) );
|
||||
|
||||
QToolButton* btnScreenshot = new QToolButton( toolBar );
|
||||
btnScreenshot->setText( "Screenshot" );
|
||||
btnScreenshot->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
connect( btnScreenshot, SIGNAL(clicked()), chart, SLOT(doScreenShot()) );
|
||||
|
||||
toolBar->addWidget( orientationBox );
|
||||
toolBar->addWidget( btnExport );
|
||||
toolBar->addWidget( btnScreenshot );
|
||||
addToolBar( toolBar );
|
||||
|
||||
chart->setOrientation( orientationBox->currentIndex() );
|
||||
connect( orientationBox, SIGNAL(currentIndexChanged(int)),
|
||||
chart, SLOT(setOrientation(int)) );
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
MainWindow window;
|
||||
|
||||
window.resize( 600, 400 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
70
examples/examples.pri
Normal file
70
examples/examples.pri
Normal file
@@ -0,0 +1,70 @@
|
||||
######################################################################
|
||||
# Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
# This file may be used under the terms of the 3-clause BSD License
|
||||
######################################################################
|
||||
|
||||
QWT_ROOT = $${PWD}/..
|
||||
include( $${QWT_ROOT}/qwtconfig.pri )
|
||||
include( $${QWT_ROOT}/qwtbuild.pri )
|
||||
include( $${QWT_ROOT}/qwtfunctions.pri )
|
||||
|
||||
QWT_OUT_ROOT = $${OUT_PWD}/../..
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += $${QWT_ROOT}/src
|
||||
DEPENDPATH += $${QWT_ROOT}/src
|
||||
|
||||
INCLUDEPATH += $${QWT_ROOT}/classincludes
|
||||
DEPENDPATH += $${QWT_ROOT}/classincludes
|
||||
|
||||
!debug_and_release {
|
||||
|
||||
DESTDIR = $${QWT_OUT_ROOT}/examples/bin
|
||||
}
|
||||
else {
|
||||
CONFIG(debug, debug|release) {
|
||||
|
||||
DESTDIR = $${QWT_OUT_ROOT}/examples/bin_debug
|
||||
}
|
||||
else {
|
||||
|
||||
DESTDIR = $${QWT_OUT_ROOT}/examples/bin
|
||||
}
|
||||
}
|
||||
|
||||
QMAKE_RPATHDIR *= $${QWT_OUT_ROOT}/lib
|
||||
qwtAddLibrary($${QWT_OUT_ROOT}/lib, qwt)
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
|
||||
QT += printsupport
|
||||
QT += concurrent
|
||||
}
|
||||
|
||||
contains(QWT_CONFIG, QwtOpenGL ) {
|
||||
|
||||
QT += opengl
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
QT += openglwidgets
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
DEFINES += QWT_NO_OPENGL
|
||||
}
|
||||
|
||||
contains(QWT_CONFIG, QwtSvg) {
|
||||
|
||||
QT += svg
|
||||
}
|
||||
else {
|
||||
|
||||
DEFINES += QWT_NO_SVG
|
||||
}
|
||||
|
||||
|
||||
contains(QWT_CONFIG, QwtDll) {
|
||||
DEFINES += QT_DLL QWT_DLL
|
||||
}
|
||||
54
examples/examples.pro
Normal file
54
examples/examples.pro
Normal file
@@ -0,0 +1,54 @@
|
||||
######################################################################
|
||||
# Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
# This file may be used under the terms of the 3-clause BSD License
|
||||
######################################################################
|
||||
|
||||
include( $${PWD}/../qwtconfig.pri )
|
||||
|
||||
TEMPLATE = subdirs
|
||||
|
||||
contains(QWT_CONFIG, QwtPlot) {
|
||||
|
||||
SUBDIRS += \
|
||||
animation \
|
||||
barchart \
|
||||
cpuplot \
|
||||
curvedemo \
|
||||
distrowatch \
|
||||
friedberg \
|
||||
itemeditor \
|
||||
legends \
|
||||
stockchart \
|
||||
simpleplot \
|
||||
sinusplot \
|
||||
realtime \
|
||||
refreshtest \
|
||||
scatterplot \
|
||||
spectrogram \
|
||||
rasterview \
|
||||
tvplot
|
||||
|
||||
contains(QWT_CONFIG, QwtWidgets) {
|
||||
|
||||
SUBDIRS += \
|
||||
bode \
|
||||
splineeditor \
|
||||
oscilloscope
|
||||
}
|
||||
|
||||
contains(QWT_CONFIG, QwtPolar) {
|
||||
|
||||
SUBDIRS += \
|
||||
polardemo \
|
||||
polarspectrogram \
|
||||
}
|
||||
}
|
||||
|
||||
contains(QWT_CONFIG, QwtWidgets) {
|
||||
|
||||
SUBDIRS += \
|
||||
sysinfo \
|
||||
radio \
|
||||
dials \
|
||||
controls
|
||||
}
|
||||
389
examples/friedberg/Friedberg2007.cpp
Normal file
389
examples/friedberg/Friedberg2007.cpp
Normal file
@@ -0,0 +1,389 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Friedberg2007.h"
|
||||
|
||||
// Temperature 2007 from Friedberg somewhere in Germany
|
||||
// See: http://wetter61169.de
|
||||
|
||||
Temperature friedberg2007[] =
|
||||
{
|
||||
/* 01.01 */ Temperature( 2.6, 9.8, 7.07862 ),
|
||||
/* 02.01 */ Temperature( 0.8, 5.8, 3.6993 ),
|
||||
/* 03.01 */ Temperature( 2, 7, 5.02388 ),
|
||||
/* 04.01 */ Temperature( 5.3, 7.8, 6.37778 ),
|
||||
/* 05.01 */ Temperature( 5.6, 7.7, 6.83149 ),
|
||||
/* 06.01 */ Temperature( 7.2, 8.9, 8.0816 ),
|
||||
/* 07.01 */ Temperature( 4.2, 9.9, 7.54704 ),
|
||||
/* 08.01 */ Temperature( 3.5, 8.9, 6.71951 ),
|
||||
/* 09.01 */ Temperature( 8.2, 12.9, 10.8594 ),
|
||||
/* 10.01 */ Temperature( 6.3, 11.9, 9.76424 ),
|
||||
/* 11.01 */ Temperature( 3.9, 9.2, 6.18223 ),
|
||||
/* 12.01 */ Temperature( 6.9, 9.7, 8.44236 ),
|
||||
/* 13.01 */ Temperature( 9, 12.3, 10.6649 ),
|
||||
/* 14.01 */ Temperature( 1.8, 10.8, 7.23438 ),
|
||||
/* 15.01 */ Temperature( -2.8, 1.8, -0.518403 ),
|
||||
/* 16.01 */ Temperature( -0.6, 4.5, 2.39479 ),
|
||||
/* 17.01 */ Temperature( 4.3, 10.2, 7.23472 ),
|
||||
/* 18.01 */ Temperature( 9.1, 13.6, 10.9316 ),
|
||||
/* 19.01 */ Temperature( 6.9, 12.4, 9.4128 ),
|
||||
/* 20.01 */ Temperature( 7.1, 13.3, 10.5083 ),
|
||||
/* 21.01 */ Temperature( 3.5, 9.6, 6.10871 ),
|
||||
/* 22.01 */ Temperature( -1.8, 6, 2.89028 ),
|
||||
/* 23.01 */ Temperature( -5.4, 1.7, -2.46678 ),
|
||||
/* 24.01 */ Temperature( -5.3, -1.3, -3.71483 ),
|
||||
/* 25.01 */ Temperature( -7.5, 3.3, -3.36736 ),
|
||||
/* 26.01 */ Temperature( -11.1, 0.3, -5.50662 ),
|
||||
/* 27.01 */ Temperature( 0.2, 3.2, 1.95345 ),
|
||||
/* 28.01 */ Temperature( 1.9, 5.2, 3.43633 ),
|
||||
/* 29.01 */ Temperature( 4.4, 9.1, 6.24236 ),
|
||||
/* 30.01 */ Temperature( 2.3, 11.5, 6.03114 ),
|
||||
/* 31.01 */ Temperature( 4.6, 10.2, 6.04192 ),
|
||||
|
||||
/* 01.02 */ Temperature( 4.8, 13.8, 7.87674 ),
|
||||
/* 02.02 */ Temperature( 5.7, 10, 7.28646 ),
|
||||
/* 03.02 */ Temperature( 2.9, 8.2, 5.71771 ),
|
||||
/* 04.02 */ Temperature( -1.5, 7.2, 4.71319 ),
|
||||
/* 05.02 */ Temperature( -2.6, 4.4, 1.23542 ),
|
||||
/* 06.02 */ Temperature( 0.3, 9.2, 2.59965 ),
|
||||
/* 07.02 */ Temperature( -0.4, 2.4, 0.641667 ),
|
||||
/* 08.02 */ Temperature( -1.7, 3.8, 0.811458 ),
|
||||
/* 09.02 */ Temperature( 0.7, 7, 3.58328 ),
|
||||
/* 10.02 */ Temperature( 1, 6, 3.51181 ),
|
||||
/* 11.02 */ Temperature( 4.7, 9.6, 6.14913 ),
|
||||
/* 12.02 */ Temperature( 5.3, 8.7, 6.80552 ),
|
||||
/* 13.02 */ Temperature( 4.4, 10.3, 6.84552 ),
|
||||
/* 14.02 */ Temperature( 2.6, 6.5, 4.58681 ),
|
||||
/* 15.02 */ Temperature( -0.8, 13.4, 6.38542 ),
|
||||
/* 16.02 */ Temperature( -3, 14.4, 4.11336 ),
|
||||
/* 17.02 */ Temperature( 0.5, 13, 5.87457 ),
|
||||
/* 18.02 */ Temperature( -2.2, 14.1, 4.36528 ),
|
||||
/* 19.02 */ Temperature( 3.9, 5.6, 4.63737 ),
|
||||
/* 20.02 */ Temperature( -0.4, 9.2, 4.37014 ),
|
||||
/* 21.02 */ Temperature( -1.9, 5.5, 1.85675 ),
|
||||
/* 22.02 */ Temperature( 1, 13.1, 5.41176 ),
|
||||
/* 23.02 */ Temperature( 1.9, 13.9, 7.74251 ),
|
||||
/* 24.02 */ Temperature( 3.8, 9.6, 7.19306 ),
|
||||
/* 25.02 */ Temperature( 5.8, 10.8, 7.80312 ),
|
||||
/* 26.02 */ Temperature( 5.2, 10.4, 6.79481 ),
|
||||
/* 27.02 */ Temperature( 3.2, 7.4, 5.22986 ),
|
||||
/* 28.02 */ Temperature( 6.4, 13.4, 9.13356 ),
|
||||
|
||||
/* 01.03 */ Temperature( 4.6, 11.4, 7.70554 ),
|
||||
/* 02.03 */ Temperature( 3.4, 10.9, 5.98408 ),
|
||||
/* 03.03 */ Temperature( 2.9, 10.5, 5.45675 ),
|
||||
/* 04.03 */ Temperature( -0.7, 16.8, 7.29585 ),
|
||||
/* 05.03 */ Temperature( 4.2, 13.4, 8.35862 ),
|
||||
/* 06.03 */ Temperature( 3, 13, 7.76644 ),
|
||||
/* 07.03 */ Temperature( 2, 13.3, 8.24618 ),
|
||||
/* 08.03 */ Temperature( -0.8, 15, 6.11765 ),
|
||||
/* 09.03 */ Temperature( -0.7, 11, 5.7568 ),
|
||||
/* 10.03 */ Temperature( 1.2, 14.4, 6.61389 ),
|
||||
/* 11.03 */ Temperature( -1.7, 18, 6.66146 ),
|
||||
/* 12.03 */ Temperature( -0.6, 21.9, 8.9816 ),
|
||||
/* 13.03 */ Temperature( -0.9, 19.6, 9.08299 ),
|
||||
/* 14.03 */ Temperature( 5.3, 18.9, 10.5562 ),
|
||||
/* 15.03 */ Temperature( 2, 20.5, 9.65156 ),
|
||||
/* 16.03 */ Temperature( 0.2, 16.7, 7.8699 ),
|
||||
/* 17.03 */ Temperature( 4.5, 10.6, 7.87535 ),
|
||||
/* 18.03 */ Temperature( 2.7, 9.7, 6.71806 ),
|
||||
/* 19.03 */ Temperature( 0.4, 10.9, 3.92404 ),
|
||||
/* 20.03 */ Temperature( -2, 12.7, 4.01359 ),
|
||||
/* 21.03 */ Temperature( 0.3, 6.8, 3.00382 ),
|
||||
/* 22.03 */ Temperature( 0.9, 4.2, 2.2816 ),
|
||||
/* 23.03 */ Temperature( 2, 5.7, 3.39233 ),
|
||||
/* 24.03 */ Temperature( 3.9, 9.3, 6.41076 ),
|
||||
/* 25.03 */ Temperature( 4.2, 19.1, 9.92182 ),
|
||||
/* 26.03 */ Temperature( 2.3, 22, 12.5716 ),
|
||||
/* 27.03 */ Temperature( 4.9, 20.6, 13.4568 ),
|
||||
/* 28.03 */ Temperature( 0.3, 22.8, 10.755 ),
|
||||
/* 29.03 */ Temperature( 1.8, 17.2, 9.43924 ),
|
||||
/* 30.03 */ Temperature( 1.9, 19.8, 10.25 ),
|
||||
/* 31.03 */ Temperature( 6.7, 17, 11.1324 ),
|
||||
|
||||
/* 01.04 */ Temperature( 5.7, 22, 12.8457 ),
|
||||
/* 02.04 */ Temperature( 6.4, 22.1, 13.3847 ),
|
||||
/* 03.04 */ Temperature( 5.8, 17.5, 10.5614 ),
|
||||
/* 04.04 */ Temperature( 2.8, 16.2, 8.06574 ),
|
||||
/* 05.04 */ Temperature( -0.6, 20.8, 9.18062 ),
|
||||
/* 06.04 */ Temperature( 2.1, 24, 13.0069 ),
|
||||
/* 07.04 */ Temperature( 5.3, 16.2, 10.2771 ),
|
||||
/* 08.04 */ Temperature( 0.1, 20.7, 9.79861 ),
|
||||
/* 09.04 */ Temperature( 0.3, 18.9, 10.0087 ),
|
||||
/* 10.04 */ Temperature( 4, 16.4, 11.4208 ),
|
||||
/* 11.04 */ Temperature( 2.3, 23.4, 13.083 ),
|
||||
/* 12.04 */ Temperature( 7, 29.4, 16.5826 ),
|
||||
/* 13.04 */ Temperature( 10.6, 31.5, 19.2249 ),
|
||||
/* 14.04 */ Temperature( 11.8, 34, 21.441 ),
|
||||
/* 15.04 */ Temperature( 11.6, 33.8, 21.0201 ),
|
||||
/* 16.04 */ Temperature( 8.7, 31.1, 18.7885 ),
|
||||
/* 17.04 */ Temperature( 5.5, 27.2, 16.1432 ),
|
||||
/* 18.04 */ Temperature( 6.1, 17.2, 10.6688 ),
|
||||
/* 19.04 */ Temperature( -0.6, 21.3, 10.4806 ),
|
||||
/* 20.04 */ Temperature( 5.9, 21.6, 12.6257 ),
|
||||
/* 21.04 */ Temperature( 2.1, 21.6, 11.0858 ),
|
||||
/* 22.04 */ Temperature( 3.9, 25.9, 14.2108 ),
|
||||
/* 23.04 */ Temperature( 3.1, 27.8, 15.7111 ),
|
||||
/* 24.04 */ Temperature( 13.7, 29, 19.6397 ),
|
||||
/* 25.04 */ Temperature( 9.8, 31.6, 19.601 ),
|
||||
/* 26.04 */ Temperature( 8.2, 32.4, 20.0389 ),
|
||||
/* 27.04 */ Temperature( 11.8, 32.1, 21.0726 ),
|
||||
/* 28.04 */ Temperature( 12.6, 33.3, 21.6993 ),
|
||||
/* 29.04 */ Temperature( 10.5, 27.4, 19.1206 ),
|
||||
/* 30.04 */ Temperature( 5.3, 26.4, 15.0972 ),
|
||||
|
||||
/* 01.05 */ Temperature( 6.9, 25.3, 15.2802 ),
|
||||
/* 02.05 */ Temperature( 4.3, 26.2, 14.8401 ),
|
||||
/* 03.05 */ Temperature( 7.1, 28.5, 17.2145 ),
|
||||
/* 04.05 */ Temperature( 11, 28.5, 18.537 ),
|
||||
/* 05.05 */ Temperature( 12, 28, 18.1672 ),
|
||||
/* 06.05 */ Temperature( 10.4, 29, 18.3844 ),
|
||||
/* 07.05 */ Temperature( 13, 18.1, 15.0028 ),
|
||||
/* 08.05 */ Temperature( 10.7, 18.3, 13.2014 ),
|
||||
/* 09.05 */ Temperature( 10.8, 14.4, 12.5208 ),
|
||||
/* 10.05 */ Temperature( 11.9, 23.5, 16.9632 ),
|
||||
/* 11.05 */ Temperature( 9.8, 16.9, 15.0795 ),
|
||||
/* 12.05 */ Temperature( 9.2, 19.6, 13.8521 ),
|
||||
/* 13.05 */ Temperature( 8.9, 26.3, 16.2028 ),
|
||||
/* 14.05 */ Temperature( 11.1, 17.5, 13.2934 ),
|
||||
/* 15.05 */ Temperature( 6.5, 17, 11.7743 ),
|
||||
/* 16.05 */ Temperature( 4.9, 13.6, 9.75625 ),
|
||||
/* 17.05 */ Temperature( 6.8, 16.6, 9.96701 ),
|
||||
/* 18.05 */ Temperature( 2.4, 21.2, 11.4311 ),
|
||||
/* 19.05 */ Temperature( 8.2, 24.4, 15.4188 ),
|
||||
/* 20.05 */ Temperature( 14.1, 31.7, 21.3303 ),
|
||||
/* 21.05 */ Temperature( 11, 30.9, 21.5359 ),
|
||||
/* 22.05 */ Temperature( 13.8, 31, 21.5177 ),
|
||||
/* 23.05 */ Temperature( 16, 27.8, 21.0271 ),
|
||||
/* 24.05 */ Temperature( 15, 34, 23.4142 ),
|
||||
/* 25.05 */ Temperature( 14.3, 31.8, 22.8903 ),
|
||||
/* 26.05 */ Temperature( 13.6, 33.1, 22.6156 ),
|
||||
/* 27.05 */ Temperature( 11.2, 23.4, 16.6192 ),
|
||||
/* 28.05 */ Temperature( 9.6, 13.1, 11.3222 ),
|
||||
/* 29.05 */ Temperature( 8.3, 11.2, 10.3529 ),
|
||||
/* 30.05 */ Temperature( 4.2, 20.8, 12.6218 ),
|
||||
/* 31.05 */ Temperature( 9.2, 23.6, 15.1073 ),
|
||||
|
||||
/* 01.06 */ Temperature( 10.8, 24.4, 16.3205 ),
|
||||
/* 02.06 */ Temperature( 13, 26.5, 18.9649 ),
|
||||
/* 03.06 */ Temperature( 14, 25.1, 18.5398 ),
|
||||
/* 04.06 */ Temperature( 13, 28, 20.2139 ),
|
||||
/* 05.06 */ Temperature( 14, 28.8, 20.438 ),
|
||||
/* 06.06 */ Temperature( 14, 30.4, 21.7821 ),
|
||||
/* 07.06 */ Temperature( 17, 34.8, 25.3087 ),
|
||||
/* 08.06 */ Temperature( 17.9, 35.7, 25.7872 ),
|
||||
/* 09.06 */ Temperature( 17.8, 31.6, 22.0788 ),
|
||||
/* 10.06 */ Temperature( 15.5, 33.4, 22.4458 ),
|
||||
/* 11.06 */ Temperature( 16.6, 28.3, 19.8797 ),
|
||||
/* 12.06 */ Temperature( 14, 27.3, 20.2566 ),
|
||||
/* 13.06 */ Temperature( 13.2, 28.2, 19.4233 ),
|
||||
/* 14.06 */ Temperature( 12.7, 30, 20.1427 ),
|
||||
/* 15.06 */ Temperature( 15.2, 22.6, 18.5917 ),
|
||||
/* 16.06 */ Temperature( 13.2, 24, 17.7014 ),
|
||||
/* 17.06 */ Temperature( 11.7, 27.9, 19.8229 ),
|
||||
/* 18.06 */ Temperature( 15.9, 27.2, 20.3358 ),
|
||||
/* 19.06 */ Temperature( 12.6, 33.7, 22.2427 ),
|
||||
/* 20.06 */ Temperature( 15.7, 30.8, 23.7507 ),
|
||||
/* 21.06 */ Temperature( 14.8, 22.6, 18.2538 ),
|
||||
/* 22.06 */ Temperature( 12.4, 21.3, 15.9969 ),
|
||||
/* 23.06 */ Temperature( 12.6, 21.6, 15.8149 ),
|
||||
/* 24.06 */ Temperature( 13, 26, 18.4176 ),
|
||||
/* 25.06 */ Temperature( 12.9, 24.4, 17.1299 ),
|
||||
/* 26.06 */ Temperature( 10.8, 18.8, 13.2913 ),
|
||||
/* 27.06 */ Temperature( 9.9, 18.8, 13.5465 ),
|
||||
/* 28.06 */ Temperature( 12, 19.8, 14.8434 ),
|
||||
/* 29.06 */ Temperature( 12, 19, 15.155 ),
|
||||
/* 30.06 */ Temperature( 12.4, 22.4, 17.1354 ),
|
||||
|
||||
/* 01.07 */ Temperature( 12.1, 24.9, 19.1639 ),
|
||||
/* 02.07 */ Temperature( 15.7, 24.3, 18.4554 ),
|
||||
/* 03.07 */ Temperature( 12.7, 17.2, 14.6564 ),
|
||||
/* 04.07 */ Temperature( 11.2, 19, 13.9529 ),
|
||||
/* 05.07 */ Temperature( 11.5, 19, 14.6422 ),
|
||||
/* 06.07 */ Temperature( 12.4, 22, 16.6146 ),
|
||||
/* 07.07 */ Temperature( 11.6, 24, 17.666 ),
|
||||
/* 08.07 */ Temperature( 9, 28, 19.1351 ),
|
||||
/* 09.07 */ Temperature( 11.3, 21.5, 16.5271 ),
|
||||
/* 10.07 */ Temperature( 11.3, 20.2, 14.2326 ),
|
||||
/* 11.07 */ Temperature( 10.2, 19.2, 14.0649 ),
|
||||
/* 12.07 */ Temperature( 13.2, 23.1, 16.6346 ),
|
||||
/* 13.07 */ Temperature( 15, 27, 19.6844 ),
|
||||
/* 14.07 */ Temperature( 13.4, 32.4, 23.845 ),
|
||||
/* 15.07 */ Temperature( 15, 38.2, 26.8559 ),
|
||||
/* 16.07 */ Temperature( 16.1, 36.5, 26.4483 ),
|
||||
/* 17.07 */ Temperature( 19.7, 30.5, 24.189 ),
|
||||
/* 18.07 */ Temperature( 14.2, 29.3, 22.1363 ),
|
||||
/* 19.07 */ Temperature( 16.4, 25.9, 19.0819 ),
|
||||
/* 20.07 */ Temperature( 16.2, 30.8, 22.151 ),
|
||||
/* 21.07 */ Temperature( 14, 24.3, 18.6573 ),
|
||||
/* 22.07 */ Temperature( 13.2, 24.5, 18.3301 ),
|
||||
/* 23.07 */ Temperature( 10.6, 23.4, 16.6903 ),
|
||||
/* 24.07 */ Temperature( 13.2, 20.8, 16.2743 ),
|
||||
/* 25.07 */ Temperature( 12.2, 25.8, 18.8267 ),
|
||||
/* 26.07 */ Temperature( 11.9, 28.9, 20.5522 ),
|
||||
/* 27.07 */ Temperature( 17.6, 25.8, 21.5691 ),
|
||||
/* 28.07 */ Temperature( 16.6, 24.6, 19.2295 ),
|
||||
/* 29.07 */ Temperature( 13, 19, 15.9021 ),
|
||||
/* 30.07 */ Temperature( 9.6, 19.7, 13.875 ),
|
||||
/* 31.07 */ Temperature( 8, 22, 14.5284 ),
|
||||
|
||||
/* 01.08 */ Temperature( 7.6, 27.5, 17.5684 ),
|
||||
/* 02.08 */ Temperature( 9.2, 22.2, 16.1035 ),
|
||||
/* 03.08 */ Temperature( 12.7, 25.3, 18.2958 ),
|
||||
/* 04.08 */ Temperature( 8.6, 31.3, 19.7941 ),
|
||||
/* 05.08 */ Temperature( 10.3, 32.7, 21.492 ),
|
||||
/* 06.08 */ Temperature( 10, 33.4, 22.4431 ),
|
||||
/* 07.08 */ Temperature( 16.8, 22.6, 19.5583 ),
|
||||
/* 08.08 */ Temperature( 13.5, 16.7, 15.0264 ),
|
||||
/* 09.08 */ Temperature( 13.2, 18.8, 15.6003 ),
|
||||
/* 10.08 */ Temperature( 14.6, 27.9, 18.8292 ),
|
||||
/* 11.08 */ Temperature( 16.3, 26.4, 20.3837 ),
|
||||
/* 12.08 */ Temperature( 12.1, 28.7, 19.9892 ),
|
||||
/* 13.08 */ Temperature( 15, 27.4, 19.7542 ),
|
||||
/* 14.08 */ Temperature( 11.3, 28.3, 20.5656 ),
|
||||
/* 15.08 */ Temperature( 18.6, 28.4, 23.1215 ),
|
||||
/* 16.08 */ Temperature( 16, 23.6, 19.491 ),
|
||||
/* 17.08 */ Temperature( 12.6, 22, 17.0437 ),
|
||||
/* 18.08 */ Temperature( 8.5, 25.7, 16.5589 ),
|
||||
/* 19.08 */ Temperature( 13.4, 25.8, 18.0543 ),
|
||||
/* 20.08 */ Temperature( 10.9, 21.5, 16.1306 ),
|
||||
/* 21.08 */ Temperature( 10.6, 19.2, 14.6177 ),
|
||||
/* 22.08 */ Temperature( 14, 24.6, 17.3841 ),
|
||||
/* 23.08 */ Temperature( 13.8, 30.4, 20.6125 ),
|
||||
/* 24.08 */ Temperature( 12.3, 30.3, 20.7622 ),
|
||||
/* 25.08 */ Temperature( 12.8, 30.2, 21.6736 ),
|
||||
/* 26.08 */ Temperature( 15, 29.3, 21.266 ),
|
||||
/* 27.08 */ Temperature( 12.9, 25.9, 18.791 ),
|
||||
/* 28.08 */ Temperature( 9.3, 24.6, 16.2833 ),
|
||||
/* 29.08 */ Temperature( 10.8, 25, 16.8459 ),
|
||||
/* 30.08 */ Temperature( 8.2, 24.4, 15.9267 ),
|
||||
/* 31.08 */ Temperature( 14.1, 20.5, 16.6128 ),
|
||||
|
||||
/* 01.09 */ Temperature( 13.4, 21.9, 16.2205 ),
|
||||
/* 02.09 */ Temperature( 12, 20.7, 16.0882 ),
|
||||
/* 03.09 */ Temperature( 10.8, 21.3, 14.7913 ),
|
||||
/* 04.09 */ Temperature( 7.8, 18.2, 12.2747 ),
|
||||
/* 05.09 */ Temperature( 8.1, 22.2, 12.9406 ),
|
||||
/* 06.09 */ Temperature( 10, 23.8, 13.8785 ),
|
||||
/* 07.09 */ Temperature( 10.7, 21.2, 15.4823 ),
|
||||
/* 08.09 */ Temperature( 12.4, 21, 15.8194 ),
|
||||
/* 09.09 */ Temperature( 12.7, 16.9, 14.7212 ),
|
||||
/* 10.09 */ Temperature( 10.3, 17.7, 12.9271 ),
|
||||
/* 11.09 */ Temperature( 10.6, 20.8, 14.4788 ),
|
||||
/* 12.09 */ Temperature( 10.8, 21.9, 15.0184 ),
|
||||
/* 13.09 */ Temperature( 6.9, 24.6, 14.5222 ),
|
||||
/* 14.09 */ Temperature( 8.1, 24, 15.6583 ),
|
||||
/* 15.09 */ Temperature( 8.8, 22.8, 15.941 ),
|
||||
/* 16.09 */ Temperature( 3.1, 24.5, 14.1486 ),
|
||||
/* 17.09 */ Temperature( 12.4, 21.2, 16.0497 ),
|
||||
/* 18.09 */ Temperature( 7.8, 16.1, 12.024 ),
|
||||
/* 19.09 */ Temperature( 5.3, 18.1, 10.3003 ),
|
||||
/* 20.09 */ Temperature( 6.4, 20.3, 12.3177 ),
|
||||
/* 21.09 */ Temperature( 6, 23.8, 13.6247 ),
|
||||
/* 22.09 */ Temperature( 5.7, 27, 14.6847 ),
|
||||
/* 23.09 */ Temperature( 7.8, 28, 16.6238 ),
|
||||
/* 24.09 */ Temperature( 9.6, 24.9, 16.7191 ),
|
||||
/* 25.09 */ Temperature( 8.4, 17.6, 12.636 ),
|
||||
/* 26.09 */ Temperature( 4.3, 18.9, 10.0809 ),
|
||||
/* 27.09 */ Temperature( 9.4, 11.2, 10.3344 ),
|
||||
/* 28.09 */ Temperature( 7.7, 12.6, 10.5337 ),
|
||||
/* 29.09 */ Temperature( 9.8, 15.3, 11.9306 ),
|
||||
/* 30.09 */ Temperature( 9.6, 21.1, 13.6635 ),
|
||||
|
||||
/* 01.10 */ Temperature( 8.9, 24.5, 14.8163 ),
|
||||
/* 02.10 */ Temperature( 13.5, 20.2, 16.1628 ),
|
||||
/* 03.10 */ Temperature( 12.5, 18, 15.4691 ),
|
||||
/* 04.10 */ Temperature( 13.8, 25, 17.2073 ),
|
||||
/* 05.10 */ Temperature( 9.1, 23.2, 14.6181 ),
|
||||
/* 06.10 */ Temperature( 6.4, 23.4, 12.8625 ),
|
||||
/* 07.10 */ Temperature( 4.6, 22.1, 11.0052 ),
|
||||
/* 08.10 */ Temperature( 2, 22.2, 10.1677 ),
|
||||
/* 09.10 */ Temperature( 7.8, 21.6, 12.2139 ),
|
||||
/* 10.10 */ Temperature( 7.1, 22.7, 13.0115 ),
|
||||
/* 11.10 */ Temperature( 6.1, 21.2, 11.4333 ),
|
||||
/* 12.10 */ Temperature( 4.3, 15.2, 10.6104 ),
|
||||
/* 13.10 */ Temperature( 5.8, 23, 12.8875 ),
|
||||
/* 14.10 */ Temperature( 1, 23, 9.72986 ),
|
||||
/* 15.10 */ Temperature( 1, 19.3, 9.33021 ),
|
||||
/* 16.10 */ Temperature( 8.5, 20.4, 13.2639 ),
|
||||
/* 17.10 */ Temperature( 6.8, 17.3, 11.8174 ),
|
||||
/* 18.10 */ Temperature( 5.2, 15.6, 9.06076 ),
|
||||
/* 19.10 */ Temperature( 2.7, 13.5, 7.1309 ),
|
||||
/* 20.10 */ Temperature( -0.2, 15.8, 6.01667 ),
|
||||
/* 21.10 */ Temperature( 2.6, 6.1, 4.9441 ),
|
||||
/* 22.10 */ Temperature( -0.8, 13.2, 4.50694 ),
|
||||
/* 23.10 */ Temperature( -0.4, 13.3, 4.71007 ),
|
||||
/* 24.10 */ Temperature( 2.9, 8.1, 5.96979 ),
|
||||
/* 25.10 */ Temperature( 6.3, 10.5, 8.01206 ),
|
||||
/* 26.10 */ Temperature( 7, 10.8, 8.14965 ),
|
||||
/* 27.10 */ Temperature( 6.6, 9.7, 7.7809 ),
|
||||
/* 28.10 */ Temperature( 1.7, 10.8, 6.95728 ),
|
||||
/* 29.10 */ Temperature( 2.2, 9.9, 6.62917 ),
|
||||
/* 30.10 */ Temperature( 5.8, 15, 8.76181 ),
|
||||
/* 31.10 */ Temperature( 0.7, 15, 6.01528 ),
|
||||
|
||||
/* 01.11 */ Temperature( -0.2, 9.7, 3.75842 ),
|
||||
/* 02.11 */ Temperature( 6.4, 9.6, 8.00138 ),
|
||||
/* 03.11 */ Temperature( 8.7, 13.1, 10.5676 ),
|
||||
/* 04.11 */ Temperature( 8, 11.8, 9.54306 ),
|
||||
/* 05.11 */ Temperature( 5.8, 15.9, 8.52345 ),
|
||||
/* 06.11 */ Temperature( 5.5, 10.8, 7.16493 ),
|
||||
/* 07.11 */ Temperature( 5.5, 8.9, 7.30172 ),
|
||||
/* 08.11 */ Temperature( 7, 11.7, 8.96701 ),
|
||||
/* 09.11 */ Temperature( 2.5, 8.4, 4.86528 ),
|
||||
/* 10.11 */ Temperature( 3.7, 9, 5.20828 ),
|
||||
/* 11.11 */ Temperature( 2.8, 10.6, 6.80756 ),
|
||||
/* 12.11 */ Temperature( 2.7, 9.5, 5.07647 ),
|
||||
/* 13.11 */ Temperature( 0.1, 5.4, 3.3945 ),
|
||||
/* 14.11 */ Temperature( -0.7, 7.9, 2.02234 ),
|
||||
/* 15.11 */ Temperature( -1.8, 6.5, 1.07778 ),
|
||||
/* 16.11 */ Temperature( -4.4, 5.1, -0.693772 ),
|
||||
/* 17.11 */ Temperature( -0.3, 3.4, 1.33229 ),
|
||||
/* 18.11 */ Temperature( -0.4, 4.3, 2.4622 ),
|
||||
/* 19.11 */ Temperature( 1.8, 3.6, 2.78282 ),
|
||||
/* 20.11 */ Temperature( 1.3, 5.6, 2.95979 ),
|
||||
/* 21.11 */ Temperature( 1.6, 5.7, 3.62284 ),
|
||||
/* 22.11 */ Temperature( 3.1, 7.3, 5.60277 ),
|
||||
/* 23.11 */ Temperature( 4.2, 7.7, 6.28166 ),
|
||||
/* 24.11 */ Temperature( -0.5, 11.5, 3.25931 ),
|
||||
/* 25.11 */ Temperature( -1, 8.8, 2.86505 ),
|
||||
/* 26.11 */ Temperature( 1.2, 6.8, 3.09414 ),
|
||||
/* 27.11 */ Temperature( -0.8, 7.5, 3.17805 ),
|
||||
/* 28.11 */ Temperature( -2.8, 3.1, -0.920139 ),
|
||||
/* 29.11 */ Temperature( -2.6, 1.7, -0.491696 ),
|
||||
/* 30.11 */ Temperature( 1.3, 6.5, 3.85 ),
|
||||
|
||||
/* 01.12 */ Temperature( 4.1, 8.7, 5.88924 ),
|
||||
/* 02.12 */ Temperature( 4.8, 9, 6.81667 ),
|
||||
/* 03.12 */ Temperature( 3.5, 8.5, 6.23633 ),
|
||||
/* 04.12 */ Temperature( 2.7, 6.6, 4.63045 ),
|
||||
/* 05.12 */ Temperature( 4.3, 8.6, 6.85993 ),
|
||||
/* 06.12 */ Temperature( 5.5, 9.3, 7.79201 ),
|
||||
/* 07.12 */ Temperature( 3.1, 13.4, 8.79444 ),
|
||||
/* 08.12 */ Temperature( 2.6, 6.3, 4.67093 ),
|
||||
/* 09.12 */ Temperature( 3, 10.4, 5.75724 ),
|
||||
/* 10.12 */ Temperature( 4.1, 6.8, 5.31834 ),
|
||||
/* 11.12 */ Temperature( 4.1, 7.4, 5.28993 ),
|
||||
/* 12.12 */ Temperature( 3.9, 6.4, 4.64479 ),
|
||||
/* 13.12 */ Temperature( 1.7, 9.1, 4.15363 ),
|
||||
/* 14.12 */ Temperature( 0.4, 1.8, 0.934602 ),
|
||||
/* 15.12 */ Temperature( -4.5, 2.1, -1.17292 ),
|
||||
/* 16.12 */ Temperature( -5, 4.8, -2.17431 ),
|
||||
/* 17.12 */ Temperature( -5.6, 6.1, -1.35448 ),
|
||||
/* 18.12 */ Temperature( -4.9, 6.4, -1.25502 ),
|
||||
/* 19.12 */ Temperature( -4.4, 6.6, -1.02396 ),
|
||||
/* 20.12 */ Temperature( -7.3, 5.2, -2.63854 ),
|
||||
/* 21.12 */ Temperature( -8.5, 5.7, -3.58333 ),
|
||||
/* 22.12 */ Temperature( -7.9, -5.3, -6.13438 ),
|
||||
/* 23.12 */ Temperature( -6.1, -4.4, -5.23472 ),
|
||||
/* 24.12 */ Temperature( -4.6, -3.3, -3.84291 ),
|
||||
/* 25.12 */ Temperature( -4.9, -2.8, -3.9066 ),
|
||||
/* 26.12 */ Temperature( -4.7, -1.9, -3.10379 ),
|
||||
/* 27.12 */ Temperature( -1.9, -0.2, -0.679791 ),
|
||||
/* 28.12 */ Temperature( -1.8, 0.5, -0.521875 ),
|
||||
/* 29.12 */ Temperature( -2.2, 2.3, -0.430796 ),
|
||||
/* 30.12 */ Temperature( 0.9, 5.2, 2.83437 ),
|
||||
/* 31.12 */ Temperature( -1, 8.3, 2.27093 )
|
||||
};
|
||||
30
examples/friedberg/Friedberg2007.h
Normal file
30
examples/friedberg/Friedberg2007.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
class Temperature
|
||||
{
|
||||
public:
|
||||
Temperature():
|
||||
minValue( 0.0 ),
|
||||
maxValue( 0.0 ),
|
||||
averageValue( 0.0 )
|
||||
{
|
||||
}
|
||||
|
||||
Temperature( double min, double max, double average ):
|
||||
minValue( min ),
|
||||
maxValue( max ),
|
||||
averageValue( average )
|
||||
{
|
||||
}
|
||||
|
||||
double minValue;
|
||||
double maxValue;
|
||||
double averageValue;
|
||||
};
|
||||
|
||||
extern Temperature friedberg2007[];
|
||||
223
examples/friedberg/Plot.cpp
Normal file
223
examples/friedberg/Plot.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
/*****************************************************************************
|
||||
* 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 "Friedberg2007.h"
|
||||
|
||||
#include <QwtPlotZoomer>
|
||||
#include <QwtPlotPanner>
|
||||
#include <QwtPlotGrid>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtPlotIntervalCurve>
|
||||
#include <QwtLegend>
|
||||
#include <QwtIntervalSymbol>
|
||||
#include <QwtSymbol>
|
||||
#include <QwtText>
|
||||
#include <QwtScaleDraw>
|
||||
#include <QwtPlotRenderer>
|
||||
|
||||
#include <QLocale>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Grid : public QwtPlotGrid
|
||||
{
|
||||
public:
|
||||
Grid()
|
||||
{
|
||||
enableXMin( true );
|
||||
setMajorPen( Qt::white, 0, Qt::DotLine );
|
||||
setMinorPen( Qt::gray, 0, Qt::DotLine );
|
||||
}
|
||||
|
||||
virtual void updateScaleDiv( const QwtScaleDiv& xScaleDiv,
|
||||
const QwtScaleDiv& yScaleDiv ) QWT_OVERRIDE
|
||||
{
|
||||
QwtScaleDiv scaleDiv( xScaleDiv.lowerBound(),
|
||||
xScaleDiv.upperBound() );
|
||||
|
||||
scaleDiv.setTicks( QwtScaleDiv::MinorTick,
|
||||
xScaleDiv.ticks( QwtScaleDiv::MinorTick ) );
|
||||
|
||||
scaleDiv.setTicks( QwtScaleDiv::MajorTick,
|
||||
xScaleDiv.ticks( QwtScaleDiv::MediumTick ) );
|
||||
|
||||
QwtPlotGrid::updateScaleDiv( scaleDiv, yScaleDiv );
|
||||
}
|
||||
};
|
||||
|
||||
class YearScaleDraw : public QwtScaleDraw
|
||||
{
|
||||
public:
|
||||
YearScaleDraw()
|
||||
{
|
||||
setTickLength( QwtScaleDiv::MajorTick, 0 );
|
||||
setTickLength( QwtScaleDiv::MinorTick, 0 );
|
||||
setTickLength( QwtScaleDiv::MediumTick, 6 );
|
||||
|
||||
setLabelRotation( -60.0 );
|
||||
setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
|
||||
setSpacing( 15 );
|
||||
}
|
||||
|
||||
virtual QwtText label( double value ) const QWT_OVERRIDE
|
||||
{
|
||||
const int month = int( value / 30 ) + 1;
|
||||
return QLocale::system().monthName( month, QLocale::LongFormat );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
{
|
||||
setObjectName( "FriedbergPlot" );
|
||||
setTitle( "Temperature of Friedberg/Germany" );
|
||||
|
||||
setAxisTitle( QwtAxis::XBottom, "2007" );
|
||||
setAxisScaleDiv( QwtAxis::XBottom, yearScaleDiv() );
|
||||
setAxisScaleDraw( QwtAxis::XBottom, new YearScaleDraw() );
|
||||
|
||||
setAxisTitle( QwtAxis::YLeft,
|
||||
QString( "Temperature [%1C]" ).arg( QChar( 0x00B0 ) ) );
|
||||
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
canvas->setPalette( Qt::darkGray );
|
||||
canvas->setBorderRadius( 10 );
|
||||
|
||||
setCanvas( canvas );
|
||||
|
||||
// grid
|
||||
QwtPlotGrid* grid = new Grid;
|
||||
grid->attach( this );
|
||||
|
||||
insertLegend( new QwtLegend(), QwtPlot::RightLegend );
|
||||
|
||||
const int numDays = 365;
|
||||
QVector< QPointF > averageData( numDays );
|
||||
QVector< QwtIntervalSample > rangeData( numDays );
|
||||
|
||||
for ( int i = 0; i < numDays; i++ )
|
||||
{
|
||||
const Temperature& t = friedberg2007[i];
|
||||
averageData[i] = QPointF( double( i ), t.averageValue );
|
||||
rangeData[i] = QwtIntervalSample( double( i ),
|
||||
QwtInterval( t.minValue, t.maxValue ) );
|
||||
}
|
||||
|
||||
insertCurve( "Average", averageData, Qt::black );
|
||||
insertErrorBars( "Range", rangeData, Qt::blue );
|
||||
|
||||
/*
|
||||
LeftButton for the zooming
|
||||
MidButton for the panning
|
||||
RightButton: zoom out by 1
|
||||
Ctrl+RighButton: zoom out to full size
|
||||
*/
|
||||
|
||||
QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas );
|
||||
zoomer->setRubberBandPen( QColor( Qt::black ) );
|
||||
zoomer->setTrackerPen( QColor( Qt::black ) );
|
||||
zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
|
||||
Qt::RightButton, Qt::ControlModifier );
|
||||
zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
|
||||
Qt::RightButton );
|
||||
|
||||
QwtPlotPanner* panner = new QwtPlotPanner( canvas );
|
||||
panner->setMouseButton( Qt::MiddleButton );
|
||||
}
|
||||
|
||||
QwtScaleDiv Plot::yearScaleDiv() const
|
||||
{
|
||||
const int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
QList< double > mediumTicks;
|
||||
mediumTicks += 0.0;
|
||||
for ( uint i = 0; i < sizeof( days ) / sizeof( days[0] ); i++ )
|
||||
mediumTicks += mediumTicks.last() + days[i];
|
||||
|
||||
QList< double > minorTicks;
|
||||
for ( int i = 1; i <= 365; i += 7 )
|
||||
minorTicks += i;
|
||||
|
||||
QList< double > majorTicks;
|
||||
for ( int i = 0; i < 12; i++ )
|
||||
majorTicks += i * 30 + 15;
|
||||
|
||||
QwtScaleDiv scaleDiv( mediumTicks.first(), mediumTicks.last() + 1,
|
||||
minorTicks, mediumTicks, majorTicks );
|
||||
return scaleDiv;
|
||||
}
|
||||
|
||||
void Plot::insertCurve( const QString& title,
|
||||
const QVector< QPointF >& samples, const QColor& color )
|
||||
{
|
||||
m_curve = new QwtPlotCurve( title );
|
||||
m_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
m_curve->setStyle( QwtPlotCurve::NoCurve );
|
||||
m_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol );
|
||||
|
||||
QwtSymbol* symbol = new QwtSymbol( QwtSymbol::XCross );
|
||||
symbol->setSize( 4 );
|
||||
symbol->setPen( color );
|
||||
m_curve->setSymbol( symbol );
|
||||
|
||||
m_curve->setSamples( samples );
|
||||
m_curve->attach( this );
|
||||
}
|
||||
|
||||
void Plot::insertErrorBars(
|
||||
const QString& title,
|
||||
const QVector< QwtIntervalSample >& samples,
|
||||
const QColor& color )
|
||||
{
|
||||
m_intervalCurve = new QwtPlotIntervalCurve( title );
|
||||
m_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
m_intervalCurve->setPen( Qt::white );
|
||||
|
||||
QColor bg( color );
|
||||
bg.setAlpha( 150 );
|
||||
m_intervalCurve->setBrush( QBrush( bg ) );
|
||||
m_intervalCurve->setStyle( QwtPlotIntervalCurve::Tube );
|
||||
|
||||
m_intervalCurve->setSamples( samples );
|
||||
m_intervalCurve->attach( this );
|
||||
}
|
||||
|
||||
void Plot::setMode( int style )
|
||||
{
|
||||
if ( style == Tube )
|
||||
{
|
||||
m_intervalCurve->setStyle( QwtPlotIntervalCurve::Tube );
|
||||
m_intervalCurve->setSymbol( NULL );
|
||||
m_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_intervalCurve->setStyle( QwtPlotIntervalCurve::NoCurve );
|
||||
|
||||
QColor c( m_intervalCurve->brush().color().rgb() ); // skip alpha
|
||||
|
||||
QwtIntervalSymbol* errorBar =
|
||||
new QwtIntervalSymbol( QwtIntervalSymbol::Bar );
|
||||
errorBar->setWidth( 8 ); // should be something even
|
||||
errorBar->setPen( c );
|
||||
|
||||
m_intervalCurve->setSymbol( errorBar );
|
||||
m_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, false );
|
||||
}
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
void Plot::exportPlot()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( this, "friedberg.pdf" );
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
49
examples/friedberg/Plot.h
Normal file
49
examples/friedberg/Plot.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*****************************************************************************
|
||||
* 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 <QwtScaleDiv>
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotIntervalCurve;
|
||||
class QwtIntervalSample;
|
||||
|
||||
#if QT_VERSION < 0x060000
|
||||
template< typename T > class QVector;
|
||||
#endif
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
Bars,
|
||||
Tube
|
||||
};
|
||||
|
||||
Plot( QWidget* = NULL );
|
||||
|
||||
public Q_SLOTS:
|
||||
void setMode( int );
|
||||
void exportPlot();
|
||||
|
||||
private:
|
||||
void insertCurve( const QString& title,
|
||||
const QVector< QPointF >&, const QColor& );
|
||||
|
||||
void insertErrorBars( const QString& title,
|
||||
const QVector< QwtIntervalSample >&,
|
||||
const QColor& color );
|
||||
|
||||
|
||||
QwtScaleDiv yearScaleDiv() const;
|
||||
|
||||
QwtPlotIntervalCurve* m_intervalCurve;
|
||||
QwtPlotCurve* m_curve;
|
||||
};
|
||||
17
examples/friedberg/friedberg.pro
Normal file
17
examples/friedberg/friedberg.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
######################################################################
|
||||
# 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 = friedberg
|
||||
|
||||
HEADERS = \
|
||||
Plot.h \
|
||||
Friedberg2007.h
|
||||
|
||||
SOURCES = \
|
||||
Friedberg2007.cpp \
|
||||
Plot.cpp \
|
||||
main.cpp
|
||||
59
examples/friedberg/main.cpp
Normal file
59
examples/friedberg/main.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* 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 <QComboBox>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
namespace
|
||||
{
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow( QWidget* parent = NULL )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
Plot* plot = new Plot();
|
||||
setCentralWidget( plot );
|
||||
|
||||
QComboBox* typeBox = new QComboBox();
|
||||
typeBox->addItem( "Bars" );
|
||||
typeBox->addItem( "Tube" );
|
||||
typeBox->setCurrentIndex( 1 );
|
||||
typeBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
QToolButton* btnExport = new QToolButton();
|
||||
btnExport->setText( "Export" );
|
||||
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
connect( btnExport, SIGNAL(clicked()), plot, SLOT(exportPlot()) );
|
||||
|
||||
QToolBar* toolBar = new QToolBar();
|
||||
toolBar->addWidget( typeBox );
|
||||
toolBar->addWidget( btnExport );
|
||||
addToolBar( toolBar );
|
||||
|
||||
plot->setMode( typeBox->currentIndex() );
|
||||
|
||||
connect( typeBox, SIGNAL(currentIndexChanged(int)),
|
||||
plot, SLOT(setMode(int)) );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
MainWindow window;
|
||||
window.setObjectName( "MainWindow" );
|
||||
window.resize( 600, 400 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
377
examples/itemeditor/Editor.cpp
Normal file
377
examples/itemeditor/Editor.cpp
Normal file
@@ -0,0 +1,377 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Editor.h"
|
||||
|
||||
#include <QwtPlot>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtScaleMap>
|
||||
#include <QwtPlotShapeItem>
|
||||
#include <QwtWidgetOverlay>
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Overlay : public QwtWidgetOverlay
|
||||
{
|
||||
public:
|
||||
Overlay( QWidget* parent, Editor* editor )
|
||||
: QwtWidgetOverlay( parent )
|
||||
, m_editor( editor )
|
||||
{
|
||||
switch( editor->mode() )
|
||||
{
|
||||
case Editor::NoMask:
|
||||
{
|
||||
setMaskMode( QwtWidgetOverlay::NoMask );
|
||||
setRenderMode( QwtWidgetOverlay::AutoRenderMode );
|
||||
break;
|
||||
}
|
||||
case Editor::Mask:
|
||||
{
|
||||
setMaskMode( QwtWidgetOverlay::MaskHint );
|
||||
setRenderMode( QwtWidgetOverlay::AutoRenderMode );
|
||||
break;
|
||||
}
|
||||
case Editor::AlphaMask:
|
||||
{
|
||||
setMaskMode( QwtWidgetOverlay::AlphaMask );
|
||||
setRenderMode( QwtWidgetOverlay::AutoRenderMode );
|
||||
break;
|
||||
}
|
||||
case Editor::AlphaMaskRedraw:
|
||||
{
|
||||
setMaskMode( QwtWidgetOverlay::AlphaMask );
|
||||
setRenderMode( QwtWidgetOverlay::DrawOverlay );
|
||||
break;
|
||||
}
|
||||
case Editor::AlphaMaskCopyMask:
|
||||
{
|
||||
setMaskMode( QwtWidgetOverlay::AlphaMask );
|
||||
setRenderMode( QwtWidgetOverlay::CopyAlphaMask );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void drawOverlay( QPainter* painter ) const QWT_OVERRIDE
|
||||
{
|
||||
m_editor->drawOverlay( painter );
|
||||
}
|
||||
|
||||
virtual QRegion maskHint() const QWT_OVERRIDE
|
||||
{
|
||||
return m_editor->maskHint();
|
||||
}
|
||||
|
||||
private:
|
||||
Editor* m_editor;
|
||||
};
|
||||
}
|
||||
|
||||
Editor::Editor( QwtPlot* plot ):
|
||||
QObject( plot ),
|
||||
m_isEnabled( false ),
|
||||
m_overlay( NULL ),
|
||||
m_mode( Mask )
|
||||
{
|
||||
setEnabled( true );
|
||||
}
|
||||
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
delete m_overlay;
|
||||
}
|
||||
|
||||
QwtPlot* Editor::plot()
|
||||
{
|
||||
return qobject_cast< QwtPlot* >( parent() );
|
||||
}
|
||||
|
||||
const QwtPlot* Editor::plot() const
|
||||
{
|
||||
return qobject_cast< const QwtPlot* >( parent() );
|
||||
}
|
||||
|
||||
void Editor::setMode( Mode mode )
|
||||
{
|
||||
m_mode = mode;
|
||||
}
|
||||
|
||||
Editor::Mode Editor::mode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
void Editor::setEnabled( bool on )
|
||||
{
|
||||
if ( on == m_isEnabled )
|
||||
return;
|
||||
|
||||
QwtPlot* plot = qobject_cast< QwtPlot* >( parent() );
|
||||
if ( plot )
|
||||
{
|
||||
m_isEnabled = on;
|
||||
|
||||
if ( on )
|
||||
{
|
||||
plot->canvas()->installEventFilter( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
plot->canvas()->removeEventFilter( this );
|
||||
|
||||
delete m_overlay;
|
||||
m_overlay = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Editor::isEnabled() const
|
||||
{
|
||||
return m_isEnabled;
|
||||
}
|
||||
|
||||
bool Editor::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
QwtPlot* plot = qobject_cast< QwtPlot* >( parent() );
|
||||
if ( plot && object == plot->canvas() )
|
||||
{
|
||||
switch( event->type() )
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
const QMouseEvent* mouseEvent =
|
||||
dynamic_cast< QMouseEvent* >( event );
|
||||
|
||||
if ( m_overlay == NULL &&
|
||||
mouseEvent->button() == Qt::LeftButton )
|
||||
{
|
||||
const bool accepted = pressed( mouseEvent->pos() );
|
||||
if ( accepted )
|
||||
{
|
||||
m_overlay = new Overlay( plot->canvas(), this );
|
||||
|
||||
m_overlay->updateOverlay();
|
||||
m_overlay->show();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseMove:
|
||||
{
|
||||
if ( m_overlay )
|
||||
{
|
||||
const QMouseEvent* mouseEvent =
|
||||
dynamic_cast< QMouseEvent* >( event );
|
||||
|
||||
const bool accepted = moved( mouseEvent->pos() );
|
||||
if ( accepted )
|
||||
m_overlay->updateOverlay();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
const QMouseEvent* mouseEvent =
|
||||
static_cast< QMouseEvent* >( event );
|
||||
|
||||
if ( m_overlay && mouseEvent->button() == Qt::LeftButton )
|
||||
{
|
||||
released( mouseEvent->pos() );
|
||||
|
||||
delete m_overlay;
|
||||
m_overlay = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return QObject::eventFilter( object, event );
|
||||
}
|
||||
|
||||
bool Editor::pressed( const QPoint& pos )
|
||||
{
|
||||
m_editedItem = itemAt( pos );
|
||||
if ( m_editedItem )
|
||||
{
|
||||
m_currentPos = pos;
|
||||
setItemVisible( m_editedItem, false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false; // don't accept the position
|
||||
}
|
||||
|
||||
bool Editor::moved( const QPoint& pos )
|
||||
{
|
||||
if ( plot() == NULL )
|
||||
return false;
|
||||
|
||||
const QwtScaleMap xMap = plot()->canvasMap( m_editedItem->xAxis() );
|
||||
const QwtScaleMap yMap = plot()->canvasMap( m_editedItem->yAxis() );
|
||||
|
||||
const QPointF p1 = QwtScaleMap::invTransform( xMap, yMap, m_currentPos );
|
||||
const QPointF p2 = QwtScaleMap::invTransform( xMap, yMap, pos );
|
||||
|
||||
const QPainterPath shape = m_editedItem->shape().translated( p2 - p1 );
|
||||
|
||||
m_editedItem->setShape( shape );
|
||||
m_currentPos = pos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Editor::released( const QPoint& pos )
|
||||
{
|
||||
Q_UNUSED( pos );
|
||||
|
||||
if ( m_editedItem )
|
||||
{
|
||||
raiseItem( m_editedItem );
|
||||
setItemVisible( m_editedItem, true );
|
||||
}
|
||||
}
|
||||
|
||||
QwtPlotShapeItem* Editor::itemAt( const QPoint& pos ) const
|
||||
{
|
||||
const QwtPlot* plot = this->plot();
|
||||
if ( plot == NULL )
|
||||
return NULL;
|
||||
|
||||
// translate pos into the plot coordinates
|
||||
|
||||
using namespace QwtAxis;
|
||||
|
||||
double coords[ AxisPositions ];
|
||||
|
||||
coords[ XBottom ] = plot->canvasMap( XBottom ).invTransform( pos.x() );
|
||||
coords[ XTop ] = plot->canvasMap( XTop ).invTransform( pos.x() );
|
||||
coords[ YLeft ] = plot->canvasMap( YLeft ).invTransform( pos.y() );
|
||||
coords[ YRight ] = plot->canvasMap( YRight ).invTransform( pos.y() );
|
||||
|
||||
QwtPlotItemList items = plot->itemList();
|
||||
for ( int i = items.size() - 1; i >= 0; i-- )
|
||||
{
|
||||
QwtPlotItem* item = items[ i ];
|
||||
if ( item->isVisible() &&
|
||||
item->rtti() == QwtPlotItem::Rtti_PlotShape )
|
||||
{
|
||||
QwtPlotShapeItem* shapeItem = static_cast< QwtPlotShapeItem* >( item );
|
||||
const QPointF p( coords[ item->xAxis() ], coords[ item->yAxis() ] );
|
||||
|
||||
if ( shapeItem->boundingRect().contains( p )
|
||||
&& shapeItem->shape().contains( p ) )
|
||||
{
|
||||
return shapeItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QRegion Editor::maskHint() const
|
||||
{
|
||||
return maskHint( m_editedItem );
|
||||
}
|
||||
|
||||
QRegion Editor::maskHint( QwtPlotShapeItem* shapeItem ) const
|
||||
{
|
||||
const QwtPlot* plot = this->plot();
|
||||
if ( plot == NULL || shapeItem == NULL )
|
||||
return QRegion();
|
||||
|
||||
const QwtScaleMap xMap = plot->canvasMap( shapeItem->xAxis() );
|
||||
const QwtScaleMap yMap = plot->canvasMap( shapeItem->yAxis() );
|
||||
|
||||
QRect rect = QwtScaleMap::transform( xMap, yMap,
|
||||
shapeItem->shape().boundingRect() ).toRect();
|
||||
|
||||
const int m = 5; // some margin for the pen
|
||||
return rect.adjusted( -m, -m, m, m );
|
||||
}
|
||||
|
||||
void Editor::drawOverlay( QPainter* painter ) const
|
||||
{
|
||||
const QwtPlot* plot = this->plot();
|
||||
if ( plot == NULL || m_editedItem == NULL )
|
||||
return;
|
||||
|
||||
const QwtScaleMap xMap = plot->canvasMap( m_editedItem->xAxis() );
|
||||
const QwtScaleMap yMap = plot->canvasMap( m_editedItem->yAxis() );
|
||||
|
||||
painter->setRenderHint( QPainter::Antialiasing,
|
||||
m_editedItem->testRenderHint( QwtPlotItem::RenderAntialiased ) );
|
||||
|
||||
m_editedItem->draw( painter, xMap, yMap,
|
||||
plot->canvas()->contentsRect() );
|
||||
}
|
||||
|
||||
void Editor::raiseItem( QwtPlotShapeItem* shapeItem )
|
||||
{
|
||||
const QwtPlot* plot = this->plot();
|
||||
if ( plot == NULL || shapeItem == NULL )
|
||||
return;
|
||||
|
||||
const QwtPlotItemList items = plot->itemList();
|
||||
for ( int i = items.size() - 1; i >= 0; i-- )
|
||||
{
|
||||
QwtPlotItem* item = items[ i ];
|
||||
if ( shapeItem == item )
|
||||
return;
|
||||
|
||||
if ( item->isVisible() &&
|
||||
item->rtti() == QwtPlotItem::Rtti_PlotShape )
|
||||
{
|
||||
shapeItem->setZ( item->z() + 1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::setItemVisible( QwtPlotShapeItem* item, bool on )
|
||||
{
|
||||
if ( plot() == NULL || item == NULL || item->isVisible() == on )
|
||||
return;
|
||||
|
||||
const bool doAutoReplot = plot()->autoReplot();
|
||||
plot()->setAutoReplot( false );
|
||||
|
||||
item->setVisible( on );
|
||||
|
||||
plot()->setAutoReplot( doAutoReplot );
|
||||
|
||||
/*
|
||||
Avoid replot with a full repaint of the canvas.
|
||||
For special combinations - f.e. using the
|
||||
raster paint engine on a remote display -
|
||||
this makes a difference.
|
||||
*/
|
||||
|
||||
QwtPlotCanvas* canvas =
|
||||
qobject_cast< QwtPlotCanvas* >( plot()->canvas() );
|
||||
if ( canvas )
|
||||
canvas->invalidateBackingStore();
|
||||
|
||||
plot()->canvas()->update( maskHint( item ) );
|
||||
|
||||
}
|
||||
|
||||
#include "moc_Editor.cpp"
|
||||
71
examples/itemeditor/Editor.h
Normal file
71
examples/itemeditor/Editor.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtGlobal>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QPoint>
|
||||
|
||||
class QwtPlot;
|
||||
class QwtPlotShapeItem;
|
||||
class QwtWidgetOverlay;
|
||||
|
||||
class QPainter;
|
||||
class QRegion;
|
||||
|
||||
class Editor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
NoMask,
|
||||
Mask,
|
||||
AlphaMask,
|
||||
AlphaMaskRedraw,
|
||||
AlphaMaskCopyMask
|
||||
};
|
||||
|
||||
Editor( QwtPlot* );
|
||||
virtual ~Editor();
|
||||
|
||||
const QwtPlot* plot() const;
|
||||
QwtPlot* plot();
|
||||
|
||||
virtual void setEnabled( bool on );
|
||||
bool isEnabled() const;
|
||||
|
||||
void drawOverlay( QPainter* ) const;
|
||||
QRegion maskHint() const;
|
||||
|
||||
virtual bool eventFilter( QObject*, QEvent*) QWT_OVERRIDE;
|
||||
|
||||
void setMode( Mode mode );
|
||||
Mode mode() const;
|
||||
|
||||
private:
|
||||
bool pressed( const QPoint& );
|
||||
bool moved( const QPoint& );
|
||||
void released( const QPoint& );
|
||||
|
||||
QwtPlotShapeItem* itemAt( const QPoint& ) const;
|
||||
void raiseItem( QwtPlotShapeItem* );
|
||||
|
||||
QRegion maskHint( QwtPlotShapeItem* ) const;
|
||||
void setItemVisible( QwtPlotShapeItem*, bool on );
|
||||
|
||||
bool m_isEnabled;
|
||||
QPointer< QwtWidgetOverlay > m_overlay;
|
||||
|
||||
// Mouse positions
|
||||
QPointF m_currentPos;
|
||||
QwtPlotShapeItem* m_editedItem;
|
||||
|
||||
Mode m_mode;
|
||||
};
|
||||
134
examples/itemeditor/Plot.cpp
Normal file
134
examples/itemeditor/Plot.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/*****************************************************************************
|
||||
* 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 "Editor.h"
|
||||
|
||||
#include <QwtPlotShapeItem>
|
||||
#include <QwtPlotMagnifier>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtLegend>
|
||||
#include <QwtPlotRenderer>
|
||||
|
||||
#include <QPen>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Legend : public QwtLegend
|
||||
{
|
||||
protected:
|
||||
virtual QWidget* createWidget(
|
||||
const QwtLegendData& legendData ) const QWT_OVERRIDE
|
||||
{
|
||||
QWidget* w = QwtLegend::createWidget( legendData );
|
||||
if ( w )
|
||||
{
|
||||
w->setStyleSheet(
|
||||
"border-radius: 5px;"
|
||||
"padding: 2px;"
|
||||
"background: LemonChiffon;"
|
||||
);
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
{
|
||||
setAutoReplot( false );
|
||||
|
||||
setTitle( "Movable Items" );
|
||||
|
||||
const int margin = 5;
|
||||
setContentsMargins( margin, margin, margin, margin );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
setPalette( QColor( "DimGray" ).lighter( 110 ) );
|
||||
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
#if 0
|
||||
// a gradient making a replot slow on X11
|
||||
canvas->setStyleSheet(
|
||||
"border: 2px solid Black;"
|
||||
"border-radius: 15px;"
|
||||
"background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
|
||||
"stop: 0 LemonChiffon, stop: 0.5 PaleGoldenrod, stop: 1 LemonChiffon );"
|
||||
);
|
||||
#else
|
||||
canvas->setStyleSheet(
|
||||
"border: 2px inset DimGray;"
|
||||
"border-radius: 15px;"
|
||||
"background: LemonChiffon;"
|
||||
);
|
||||
#endif
|
||||
|
||||
setCanvas( canvas );
|
||||
insertLegend( new Legend(), QwtPlot::RightLegend );
|
||||
|
||||
populate();
|
||||
|
||||
updateAxes();
|
||||
for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ )
|
||||
setAxisAutoScale( axis, false );
|
||||
|
||||
m_editor = new Editor( this );
|
||||
( void ) new QwtPlotMagnifier( canvas );
|
||||
}
|
||||
|
||||
void Plot::populate()
|
||||
{
|
||||
addShape( "Rectangle", ShapeFactory::Rect, "RoyalBlue",
|
||||
QPointF( 30.0, 50.0 ), QSizeF( 40.0, 50.0 ) );
|
||||
addShape( "Ellipse", ShapeFactory::Ellipse, "IndianRed",
|
||||
QPointF( 80.0, 130.0 ), QSizeF( 50.0, 40.0 ) );
|
||||
addShape( "Ring", ShapeFactory::Ring, "DarkOliveGreen",
|
||||
QPointF( 30.0, 165.0 ), QSizeF( 40.0, 40.0 ) );
|
||||
addShape( "Triangle", ShapeFactory::Triangle, "SandyBrown",
|
||||
QPointF( 165.0, 165.0 ), QSizeF( 60.0, 40.0 ) );
|
||||
addShape( "Star", ShapeFactory::Star, "DarkViolet",
|
||||
QPointF( 165.0, 50.0 ), QSizeF( 40.0, 50.0 ) );
|
||||
addShape( "Hexagon", ShapeFactory::Hexagon, "DarkSlateGray",
|
||||
QPointF( 120.0, 70.0 ), QSizeF( 50.0, 50.0 ) );
|
||||
|
||||
}
|
||||
|
||||
void Plot::addShape( const QString& title,
|
||||
ShapeFactory::Shape shape, const QColor& color,
|
||||
const QPointF& pos, const QSizeF& size )
|
||||
{
|
||||
QwtPlotShapeItem* item = new QwtPlotShapeItem( title );
|
||||
item->setItemAttribute( QwtPlotItem::Legend, true );
|
||||
item->setLegendMode( QwtPlotShapeItem::LegendShape );
|
||||
item->setLegendIconSize( QSize( 20, 20 ) );
|
||||
item->setRenderHint( QwtPlotItem::RenderAntialiased, true );
|
||||
item->setShape( ShapeFactory::path( shape, pos, size ) );
|
||||
|
||||
QColor fillColor = color;
|
||||
fillColor.setAlpha( 200 );
|
||||
|
||||
QPen pen( color, 3 );
|
||||
pen.setJoinStyle( Qt::MiterJoin );
|
||||
item->setPen( pen );
|
||||
item->setBrush( fillColor );
|
||||
|
||||
item->attach( this );
|
||||
}
|
||||
|
||||
void Plot::exportPlot()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( this, "shapes.pdf" );
|
||||
}
|
||||
|
||||
void Plot::setMode( int mode )
|
||||
{
|
||||
m_editor->setMode( static_cast< Editor::Mode >( mode ) );
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
35
examples/itemeditor/Plot.h
Normal file
35
examples/itemeditor/Plot.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ShapeFactory.h"
|
||||
#include <QwtPlot>
|
||||
|
||||
class QColor;
|
||||
class QSizeF;
|
||||
class QPointF;
|
||||
class Editor;
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot( QWidget* parent = NULL );
|
||||
|
||||
public Q_SLOTS:
|
||||
void exportPlot();
|
||||
void setMode( int );
|
||||
|
||||
private:
|
||||
void populate();
|
||||
|
||||
void addShape( const QString& title,
|
||||
ShapeFactory::Shape, const QColor&,
|
||||
const QPointF&, const QSizeF& );
|
||||
|
||||
Editor* m_editor;
|
||||
};
|
||||
119
examples/itemeditor/ShapeFactory.cpp
Normal file
119
examples/itemeditor/ShapeFactory.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ShapeFactory.h"
|
||||
#include <QPainterPath>
|
||||
|
||||
QPainterPath ShapeFactory::path( Shape shape,
|
||||
const QPointF& pos, const QSizeF& size )
|
||||
{
|
||||
QRectF rect;
|
||||
rect.setSize( size );
|
||||
rect.moveCenter( pos );
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
switch( shape )
|
||||
{
|
||||
case Rect:
|
||||
{
|
||||
path.addRect( rect );
|
||||
break;
|
||||
}
|
||||
case Triangle:
|
||||
{
|
||||
QPolygonF triangle;
|
||||
triangle += rect.bottomLeft();
|
||||
triangle += QPointF( rect.center().x(), rect.top() );
|
||||
triangle += rect.bottomRight();
|
||||
|
||||
path.addPolygon( triangle );
|
||||
break;
|
||||
}
|
||||
case Ellipse:
|
||||
{
|
||||
path.addEllipse( rect );
|
||||
break;
|
||||
}
|
||||
case Ring:
|
||||
{
|
||||
path.addEllipse( rect );
|
||||
|
||||
const double w = 0.25 * rect.width();
|
||||
path.addEllipse( rect.adjusted( w, w, -w, -w ) );
|
||||
break;
|
||||
}
|
||||
case Star:
|
||||
{
|
||||
const double cos30 = 0.866025;
|
||||
|
||||
const double dy = 0.25 * size.height();
|
||||
const double dx = 0.5 * size.width() * cos30 / 3.0;
|
||||
|
||||
double x1 = pos.x() - 3 * dx;
|
||||
double y1 = pos.y() - 2 * dy;
|
||||
|
||||
const double x2 = x1 + 1 * dx;
|
||||
const double x3 = x1 + 2 * dx;
|
||||
const double x4 = x1 + 3 * dx;
|
||||
const double x5 = x1 + 4 * dx;
|
||||
const double x6 = x1 + 5 * dx;
|
||||
const double x7 = x1 + 6 * dx;
|
||||
|
||||
const double y2 = y1 + 1 * dy;
|
||||
const double y3 = y1 + 2 * dy;
|
||||
const double y4 = y1 + 3 * dy;
|
||||
const double y5 = y1 + 4 * dy;
|
||||
|
||||
QPolygonF star;
|
||||
star += QPointF( x4, y1 );
|
||||
star += QPointF( x5, y2 );
|
||||
star += QPointF( x7, y2 );
|
||||
star += QPointF( x6, y3 );
|
||||
star += QPointF( x7, y4 );
|
||||
star += QPointF( x5, y4 );
|
||||
star += QPointF( x4, y5 );
|
||||
star += QPointF( x3, y4 );
|
||||
star += QPointF( x1, y4 );
|
||||
star += QPointF( x2, y3 );
|
||||
star += QPointF( x1, y2 );
|
||||
star += QPointF( x3, y2 );
|
||||
|
||||
path.addPolygon( star );
|
||||
break;
|
||||
}
|
||||
case Hexagon:
|
||||
{
|
||||
const double cos30 = 0.866025;
|
||||
|
||||
const double dx = 0.5 * size.width() - cos30;
|
||||
const double dy = 0.25 * size.height();
|
||||
|
||||
double x1 = pos.x() - dx;
|
||||
double y1 = pos.y() - 2 * dy;
|
||||
|
||||
const double x2 = x1 + 1 * dx;
|
||||
const double x3 = x1 + 2 * dx;
|
||||
|
||||
const double y2 = y1 + 1 * dy;
|
||||
const double y3 = y1 + 3 * dy;
|
||||
const double y4 = y1 + 4 * dy;
|
||||
|
||||
QPolygonF hexagon;
|
||||
hexagon += QPointF( x2, y1 );
|
||||
hexagon += QPointF( x3, y2 );
|
||||
hexagon += QPointF( x3, y3 );
|
||||
hexagon += QPointF( x2, y4 );
|
||||
hexagon += QPointF( x1, y3 );
|
||||
hexagon += QPointF( x1, y2 );
|
||||
|
||||
path.addPolygon( hexagon );
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
path.closeSubpath();
|
||||
return path;
|
||||
}
|
||||
25
examples/itemeditor/ShapeFactory.h
Normal file
25
examples/itemeditor/ShapeFactory.h
Normal 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
|
||||
|
||||
class QPainterPath;
|
||||
class QPointF;
|
||||
class QSizeF;
|
||||
|
||||
namespace ShapeFactory
|
||||
{
|
||||
enum Shape
|
||||
{
|
||||
Rect,
|
||||
Triangle,
|
||||
Ellipse,
|
||||
Ring,
|
||||
Star,
|
||||
Hexagon
|
||||
};
|
||||
|
||||
QPainterPath path( Shape, const QPointF&, const QSizeF& );
|
||||
}
|
||||
20
examples/itemeditor/itemeditor.pro
Normal file
20
examples/itemeditor/itemeditor.pro
Normal file
@@ -0,0 +1,20 @@
|
||||
######################################################################
|
||||
# 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 = itemeditor
|
||||
|
||||
HEADERS = \
|
||||
Editor.h \
|
||||
ShapeFactory.h \
|
||||
Plot.h
|
||||
|
||||
SOURCES = \
|
||||
Editor.cpp \
|
||||
ShapeFactory.cpp \
|
||||
Plot.cpp \
|
||||
main.cpp
|
||||
|
||||
60
examples/itemeditor/main.cpp
Normal file
60
examples/itemeditor/main.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* 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>
|
||||
|
||||
namespace
|
||||
{
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWindow( QWidget* parent = nullptr )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
Plot* plot = new Plot( this );
|
||||
setCentralWidget( plot );
|
||||
|
||||
QToolBar* toolBar = new QToolBar( this );
|
||||
|
||||
QComboBox* modeBox = new QComboBox( toolBar );
|
||||
modeBox->addItem( "No Mask" );
|
||||
modeBox->addItem( "Mask" );
|
||||
modeBox->addItem( "Alpha Mask" );
|
||||
modeBox->addItem( "Alpha Mask/Redraw" );
|
||||
modeBox->addItem( "Alpha Mask/Copy Mask" );
|
||||
modeBox->setCurrentIndex( 1 );
|
||||
modeBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
connect( modeBox, SIGNAL(currentIndexChanged(int)),
|
||||
plot, SLOT(setMode(int)) );
|
||||
|
||||
QToolButton* btnExport = new QToolButton( toolBar );
|
||||
btnExport->setText( "Export" );
|
||||
btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
|
||||
connect( btnExport, SIGNAL(clicked()), plot, SLOT(exportPlot()) );
|
||||
|
||||
toolBar->addWidget( modeBox );
|
||||
toolBar->addWidget( btnExport );
|
||||
addToolBar( toolBar );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
MainWindow window;
|
||||
window.resize( 600, 400 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
69
examples/legends/MainWindow.cpp
Normal file
69
examples/legends/MainWindow.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* 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 "Panel.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QwtPlotRenderer>
|
||||
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QLayout>
|
||||
|
||||
MainWindow::MainWindow( QWidget* parent )
|
||||
: QMainWindow( parent )
|
||||
{
|
||||
m_plot = new Plot();
|
||||
|
||||
Settings settings;
|
||||
settings.legend.isEnabled = true;
|
||||
settings.legend.position = QwtPlot::BottomLegend;
|
||||
|
||||
settings.legendItem.isEnabled = false;
|
||||
settings.legendItem.numColumns = 1;
|
||||
settings.legendItem.alignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||
settings.legendItem.backgroundMode = 0;
|
||||
settings.legendItem.size = m_plot->canvas()->font().pointSize();
|
||||
|
||||
settings.curve.numCurves = 4;
|
||||
settings.curve.title = "Curve";
|
||||
|
||||
m_panel = new Panel();
|
||||
m_panel->setSettings( settings );
|
||||
|
||||
QWidget* box = new QWidget( this );
|
||||
QHBoxLayout* layout = new QHBoxLayout( box );
|
||||
layout->addWidget( m_plot, 10 );
|
||||
layout->addWidget( m_panel );
|
||||
|
||||
setCentralWidget( box );
|
||||
|
||||
QToolBar* toolBar = new QToolBar( this );
|
||||
|
||||
QToolButton* btnExport = new QToolButton( toolBar );
|
||||
btnExport->setText( "Export" );
|
||||
toolBar->addWidget( btnExport );
|
||||
|
||||
addToolBar( toolBar );
|
||||
|
||||
updatePlot();
|
||||
|
||||
connect( m_panel, SIGNAL(edited()), SLOT(updatePlot()) );
|
||||
connect( btnExport, SIGNAL(clicked()), SLOT(exportPlot()) );
|
||||
}
|
||||
|
||||
void MainWindow::updatePlot()
|
||||
{
|
||||
m_plot->applySettings( m_panel->settings() );
|
||||
}
|
||||
|
||||
void MainWindow::exportPlot()
|
||||
{
|
||||
QwtPlotRenderer renderer;
|
||||
renderer.exportTo( m_plot, "legends.pdf" );
|
||||
}
|
||||
|
||||
#include "moc_MainWindow.cpp"
|
||||
27
examples/legends/MainWindow.h
Normal file
27
examples/legends/MainWindow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class Plot;
|
||||
class Panel;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow( QWidget* parent = 0 );
|
||||
|
||||
private Q_SLOTS:
|
||||
void updatePlot();
|
||||
void exportPlot();
|
||||
|
||||
private:
|
||||
Plot* m_plot;
|
||||
Panel* m_panel;
|
||||
};
|
||||
225
examples/legends/Panel.cpp
Normal file
225
examples/legends/Panel.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Panel.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#include <QwtPlot>
|
||||
#include <QwtPlotLegendItem>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QSpinBox>
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
#include <QLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
Panel::Panel( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
// create widgets
|
||||
|
||||
m_legend.checkBox = new QCheckBox( "Enabled" );
|
||||
|
||||
m_legend.positionBox = new QComboBox();
|
||||
m_legend.positionBox->addItem( "Left", QwtPlot::LeftLegend );
|
||||
m_legend.positionBox->addItem( "Right", QwtPlot::RightLegend );
|
||||
m_legend.positionBox->addItem( "Bottom", QwtPlot::BottomLegend );
|
||||
m_legend.positionBox->addItem( "Top", QwtPlot::TopLegend );
|
||||
m_legend.positionBox->addItem( "External", QwtPlot::TopLegend + 1 );
|
||||
|
||||
m_legendItem.checkBox = new QCheckBox( "Enabled" );
|
||||
|
||||
m_legendItem.numColumnsBox = new QSpinBox();
|
||||
m_legendItem.numColumnsBox->setRange( 0, 10 );
|
||||
m_legendItem.numColumnsBox->setSpecialValueText( "Unlimited" );
|
||||
|
||||
m_legendItem.hAlignmentBox = new QComboBox();
|
||||
m_legendItem.hAlignmentBox->addItem( "Left", Qt::AlignLeft );
|
||||
m_legendItem.hAlignmentBox->addItem( "Centered", Qt::AlignHCenter );
|
||||
m_legendItem.hAlignmentBox->addItem( "Right", Qt::AlignRight );
|
||||
|
||||
m_legendItem.vAlignmentBox = new QComboBox();
|
||||
m_legendItem.vAlignmentBox->addItem( "Top", Qt::AlignTop );
|
||||
m_legendItem.vAlignmentBox->addItem( "Centered", Qt::AlignVCenter );
|
||||
m_legendItem.vAlignmentBox->addItem( "Bottom", Qt::AlignBottom );
|
||||
|
||||
m_legendItem.backgroundBox = new QComboBox();
|
||||
m_legendItem.backgroundBox->addItem( "Legend",
|
||||
QwtPlotLegendItem::LegendBackground );
|
||||
m_legendItem.backgroundBox->addItem( "Items",
|
||||
QwtPlotLegendItem::ItemBackground );
|
||||
|
||||
m_legendItem.sizeBox = new QSpinBox();
|
||||
m_legendItem.sizeBox->setRange( 8, 22 );
|
||||
|
||||
m_curve.numCurves = new QSpinBox();
|
||||
m_curve.numCurves->setRange( 0, 99 );
|
||||
|
||||
m_curve.title = new QLineEdit();
|
||||
|
||||
// layout
|
||||
|
||||
QGroupBox* legendBox = new QGroupBox( "Legend" );
|
||||
QGridLayout* legendBoxLayout = new QGridLayout( legendBox );
|
||||
|
||||
int row = 0;
|
||||
legendBoxLayout->addWidget( m_legend.checkBox, row, 0, 1, -1 );
|
||||
|
||||
row++;
|
||||
legendBoxLayout->addWidget( new QLabel( "Position" ), row, 0 );
|
||||
legendBoxLayout->addWidget( m_legend.positionBox, row, 1 );
|
||||
|
||||
|
||||
QGroupBox* legendItemBox = new QGroupBox( "Legend Item" );
|
||||
QGridLayout* legendItemBoxLayout = new QGridLayout( legendItemBox );
|
||||
|
||||
row = 0;
|
||||
legendItemBoxLayout->addWidget( m_legendItem.checkBox, row, 0, 1, -1 );
|
||||
|
||||
row++;
|
||||
legendItemBoxLayout->addWidget( new QLabel( "Columns" ), row, 0 );
|
||||
legendItemBoxLayout->addWidget( m_legendItem.numColumnsBox, row, 1 );
|
||||
|
||||
row++;
|
||||
legendItemBoxLayout->addWidget( new QLabel( "Horizontal" ), row, 0 );
|
||||
legendItemBoxLayout->addWidget( m_legendItem.hAlignmentBox, row, 1 );
|
||||
|
||||
row++;
|
||||
legendItemBoxLayout->addWidget( new QLabel( "Vertical" ), row, 0 );
|
||||
legendItemBoxLayout->addWidget( m_legendItem.vAlignmentBox, row, 1 );
|
||||
|
||||
row++;
|
||||
legendItemBoxLayout->addWidget( new QLabel( "Background" ), row, 0 );
|
||||
legendItemBoxLayout->addWidget( m_legendItem.backgroundBox, row, 1 );
|
||||
|
||||
row++;
|
||||
legendItemBoxLayout->addWidget( new QLabel( "Size" ), row, 0 );
|
||||
legendItemBoxLayout->addWidget( m_legendItem.sizeBox, row, 1 );
|
||||
|
||||
QGroupBox* curveBox = new QGroupBox( "Curves" );
|
||||
QGridLayout* curveBoxLayout = new QGridLayout( curveBox );
|
||||
|
||||
row = 0;
|
||||
curveBoxLayout->addWidget( new QLabel( "Number" ), row, 0 );
|
||||
curveBoxLayout->addWidget( m_curve.numCurves, row, 1 );
|
||||
|
||||
row++;
|
||||
curveBoxLayout->addWidget( new QLabel( "Title" ), row, 0 );
|
||||
curveBoxLayout->addWidget( m_curve.title, row, 1 );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );
|
||||
layout->addWidget( legendBox );
|
||||
layout->addWidget( legendItemBox );
|
||||
layout->addWidget( curveBox );
|
||||
layout->addStretch( 10 );
|
||||
|
||||
connect( m_legend.checkBox,
|
||||
SIGNAL(stateChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legend.positionBox,
|
||||
SIGNAL(currentIndexChanged(int)), SIGNAL(edited()) );
|
||||
|
||||
connect( m_legendItem.checkBox,
|
||||
SIGNAL(stateChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legendItem.numColumnsBox,
|
||||
SIGNAL(valueChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legendItem.hAlignmentBox,
|
||||
SIGNAL(currentIndexChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legendItem.vAlignmentBox,
|
||||
SIGNAL(currentIndexChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legendItem.backgroundBox,
|
||||
SIGNAL(currentIndexChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_curve.numCurves,
|
||||
SIGNAL(valueChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_legendItem.sizeBox,
|
||||
SIGNAL(valueChanged(int)), SIGNAL(edited()) );
|
||||
connect( m_curve.title,
|
||||
SIGNAL(textEdited(const QString&)), SIGNAL(edited()) );
|
||||
}
|
||||
|
||||
void Panel::setSettings( const Settings& settings)
|
||||
{
|
||||
blockSignals( true );
|
||||
|
||||
m_legend.checkBox->setCheckState(
|
||||
settings.legend.isEnabled ? Qt::Checked : Qt::Unchecked );
|
||||
m_legend.positionBox->setCurrentIndex( settings.legend.position );
|
||||
|
||||
m_legendItem.checkBox->setCheckState(
|
||||
settings.legendItem.isEnabled ? Qt::Checked : Qt::Unchecked );
|
||||
|
||||
m_legendItem.numColumnsBox->setValue( settings.legendItem.numColumns );
|
||||
|
||||
int align = settings.legendItem.alignment;
|
||||
|
||||
if ( align & Qt::AlignLeft )
|
||||
m_legendItem.hAlignmentBox->setCurrentIndex( 0 );
|
||||
else if ( align & Qt::AlignRight )
|
||||
m_legendItem.hAlignmentBox->setCurrentIndex( 2 );
|
||||
else
|
||||
m_legendItem.hAlignmentBox->setCurrentIndex( 1 );
|
||||
|
||||
if ( align & Qt::AlignTop )
|
||||
m_legendItem.vAlignmentBox->setCurrentIndex( 0 );
|
||||
else if ( align & Qt::AlignBottom )
|
||||
m_legendItem.vAlignmentBox->setCurrentIndex( 2 );
|
||||
else
|
||||
m_legendItem.vAlignmentBox->setCurrentIndex( 1 );
|
||||
|
||||
m_legendItem.backgroundBox->setCurrentIndex(
|
||||
settings.legendItem.backgroundMode );
|
||||
|
||||
m_legendItem.sizeBox->setValue( settings.legendItem.size );
|
||||
|
||||
m_curve.numCurves->setValue( settings.curve.numCurves );
|
||||
m_curve.title->setText( settings.curve.title );
|
||||
|
||||
blockSignals( false );
|
||||
}
|
||||
|
||||
Settings Panel::settings() const
|
||||
{
|
||||
Settings s;
|
||||
|
||||
s.legend.isEnabled =
|
||||
m_legend.checkBox->checkState() == Qt::Checked;
|
||||
s.legend.position = m_legend.positionBox->currentIndex();
|
||||
|
||||
s.legendItem.isEnabled =
|
||||
m_legendItem.checkBox->checkState() == Qt::Checked;
|
||||
s.legendItem.numColumns = m_legendItem.numColumnsBox->value();
|
||||
|
||||
int align = 0;
|
||||
|
||||
int hIndex = m_legendItem.hAlignmentBox->currentIndex();
|
||||
if ( hIndex == 0 )
|
||||
align |= Qt::AlignLeft;
|
||||
else if ( hIndex == 2 )
|
||||
align |= Qt::AlignRight;
|
||||
else
|
||||
align |= Qt::AlignHCenter;
|
||||
|
||||
int vIndex = m_legendItem.vAlignmentBox->currentIndex();
|
||||
if ( vIndex == 0 )
|
||||
align |= Qt::AlignTop;
|
||||
else if ( vIndex == 2 )
|
||||
align |= Qt::AlignBottom;
|
||||
else
|
||||
align |= Qt::AlignVCenter;
|
||||
|
||||
s.legendItem.alignment = align;
|
||||
|
||||
s.legendItem.backgroundMode =
|
||||
m_legendItem.backgroundBox->currentIndex();
|
||||
s.legendItem.size = m_legendItem.sizeBox->value();
|
||||
|
||||
s.curve.numCurves = m_curve.numCurves->value();
|
||||
s.curve.title = m_curve.title->text();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
#include "moc_Panel.cpp"
|
||||
54
examples/legends/Panel.h
Normal file
54
examples/legends/Panel.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Settings.h"
|
||||
#include <QWidget>
|
||||
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QSpinBox;
|
||||
class QLineEdit;
|
||||
|
||||
class Panel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Panel( QWidget* parent = NULL );
|
||||
|
||||
void setSettings( const Settings&);
|
||||
Settings settings() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void edited();
|
||||
|
||||
private:
|
||||
struct
|
||||
{
|
||||
QCheckBox* checkBox;
|
||||
QComboBox* positionBox;
|
||||
|
||||
} m_legend;
|
||||
|
||||
struct
|
||||
{
|
||||
QCheckBox* checkBox;
|
||||
QSpinBox* numColumnsBox;
|
||||
QComboBox* hAlignmentBox;
|
||||
QComboBox* vAlignmentBox;
|
||||
QComboBox* backgroundBox;
|
||||
QSpinBox* sizeBox;
|
||||
|
||||
} m_legendItem;
|
||||
|
||||
struct
|
||||
{
|
||||
QSpinBox* numCurves;
|
||||
QLineEdit* title;
|
||||
|
||||
} m_curve;
|
||||
};
|
||||
272
examples/legends/Plot.cpp
Normal file
272
examples/legends/Plot.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
/*****************************************************************************
|
||||
* 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 "Settings.h"
|
||||
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtPlotLegendItem>
|
||||
#include <QwtLegend>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtPlotGrid>
|
||||
#include <QwtPlotLayout>
|
||||
#include <QwtMath>
|
||||
|
||||
#include <QPen>
|
||||
|
||||
namespace
|
||||
{
|
||||
class LegendItem : public QwtPlotLegendItem
|
||||
{
|
||||
public:
|
||||
LegendItem()
|
||||
{
|
||||
setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
|
||||
const QColor c1( Qt::white );
|
||||
|
||||
setTextPen( c1 );
|
||||
setBorderPen( c1 );
|
||||
|
||||
QColor c2( Qt::gray );
|
||||
c2.setAlpha( 200 );
|
||||
|
||||
setBackgroundBrush( c2 );
|
||||
}
|
||||
};
|
||||
|
||||
class Curve : public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
Curve( int index ):
|
||||
m_index( index )
|
||||
{
|
||||
setRenderHint( QwtPlotItem::RenderAntialiased );
|
||||
initData();
|
||||
}
|
||||
|
||||
void setCurveTitle( const QString& title )
|
||||
{
|
||||
QString txt("%1 %2");
|
||||
setTitle( QString( "%1 %2" ).arg( title ).arg( m_index ) );
|
||||
}
|
||||
|
||||
void initData()
|
||||
{
|
||||
QVector< QPointF > points;
|
||||
|
||||
double y = qwtRand() % 1000;
|
||||
|
||||
for ( double x = 0.0; x <= 1000.0; x += 100.0 )
|
||||
{
|
||||
double off = qwtRand() % 200 - 100;
|
||||
if ( y + off > 980.0 || y + off < 20.0 )
|
||||
off = -off;
|
||||
|
||||
y += off;
|
||||
|
||||
points += QPointF( x, y );
|
||||
}
|
||||
|
||||
setSamples( points );
|
||||
}
|
||||
|
||||
private:
|
||||
const int m_index;
|
||||
};
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
, m_externalLegend( NULL )
|
||||
, m_legendItem( NULL )
|
||||
, m_isDirty( false )
|
||||
{
|
||||
QwtPlotCanvas* canvas = new QwtPlotCanvas();
|
||||
canvas->setFocusIndicator( QwtPlotCanvas::CanvasFocusIndicator );
|
||||
canvas->setFocusPolicy( Qt::StrongFocus );
|
||||
canvas->setPalette( Qt::black );
|
||||
setCanvas( canvas );
|
||||
|
||||
setAutoReplot( false );
|
||||
|
||||
setTitle( "Legend Test" );
|
||||
setFooter( "Footer" );
|
||||
|
||||
// grid
|
||||
QwtPlotGrid* grid = new QwtPlotGrid;
|
||||
grid->enableXMin( true );
|
||||
grid->setMajorPen( Qt::gray, 0, Qt::DotLine );
|
||||
grid->setMinorPen( Qt::darkGray, 0, Qt::DotLine );
|
||||
grid->attach( this );
|
||||
|
||||
// axis
|
||||
setAxisScale( QwtAxis::YLeft, 0.0, 1000.0 );
|
||||
setAxisScale( QwtAxis::XBottom, 0.0, 1000.0 );
|
||||
}
|
||||
|
||||
Plot::~Plot()
|
||||
{
|
||||
delete m_externalLegend;
|
||||
}
|
||||
|
||||
void Plot::insertCurve()
|
||||
{
|
||||
static int counter = 1;
|
||||
|
||||
const char* colors[] =
|
||||
{
|
||||
"LightSalmon",
|
||||
"SteelBlue",
|
||||
"Yellow",
|
||||
"Fuchsia",
|
||||
"PaleGreen",
|
||||
"PaleTurquoise",
|
||||
"Cornsilk",
|
||||
"HotPink",
|
||||
"Peru",
|
||||
"Maroon"
|
||||
};
|
||||
const int numColors = sizeof( colors ) / sizeof( colors[0] );
|
||||
|
||||
QwtPlotCurve* curve = new Curve( counter++ );
|
||||
curve->setPen( QColor( colors[ counter % numColors ] ), 2 );
|
||||
curve->attach( this );
|
||||
}
|
||||
|
||||
void Plot::applySettings( const Settings& settings )
|
||||
{
|
||||
m_isDirty = false;
|
||||
setAutoReplot( true );
|
||||
|
||||
if ( settings.legend.isEnabled )
|
||||
{
|
||||
if ( settings.legend.position > QwtPlot::TopLegend )
|
||||
{
|
||||
if ( legend() )
|
||||
{
|
||||
// remove legend controlled by the plot
|
||||
insertLegend( NULL );
|
||||
}
|
||||
|
||||
if ( m_externalLegend == NULL )
|
||||
{
|
||||
m_externalLegend = new QwtLegend();
|
||||
m_externalLegend->setWindowTitle("Plot Legend");
|
||||
|
||||
connect(
|
||||
this,
|
||||
SIGNAL(legendDataChanged(const QVariant&,const QList<QwtLegendData>&)),
|
||||
m_externalLegend,
|
||||
SLOT(updateLegend(const QVariant&,const QList<QwtLegendData>&)) );
|
||||
|
||||
m_externalLegend->show();
|
||||
|
||||
// populate the new legend
|
||||
updateLegend();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_externalLegend;
|
||||
m_externalLegend = NULL;
|
||||
|
||||
if ( legend() == NULL ||
|
||||
plotLayout()->legendPosition() != settings.legend.position )
|
||||
{
|
||||
insertLegend( new QwtLegend(),
|
||||
QwtPlot::LegendPosition( settings.legend.position ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
insertLegend( NULL );
|
||||
|
||||
delete m_externalLegend;
|
||||
m_externalLegend = NULL;
|
||||
}
|
||||
|
||||
if ( settings.legendItem.isEnabled )
|
||||
{
|
||||
if ( m_legendItem == NULL )
|
||||
{
|
||||
m_legendItem = new LegendItem();
|
||||
m_legendItem->attach( this );
|
||||
}
|
||||
|
||||
m_legendItem->setMaxColumns( settings.legendItem.numColumns );
|
||||
m_legendItem->setAlignmentInCanvas( Qt::Alignment( settings.legendItem.alignment ) );
|
||||
m_legendItem->setBackgroundMode(
|
||||
QwtPlotLegendItem::BackgroundMode( settings.legendItem.backgroundMode ) );
|
||||
if ( settings.legendItem.backgroundMode ==
|
||||
QwtPlotLegendItem::ItemBackground )
|
||||
{
|
||||
m_legendItem->setBorderRadius( 4 );
|
||||
m_legendItem->setMargin( 0 );
|
||||
m_legendItem->setSpacing( 4 );
|
||||
m_legendItem->setItemMargin( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_legendItem->setBorderRadius( 8 );
|
||||
m_legendItem->setMargin( 4 );
|
||||
m_legendItem->setSpacing( 2 );
|
||||
m_legendItem->setItemMargin( 0 );
|
||||
}
|
||||
|
||||
QFont font = m_legendItem->font();
|
||||
font.setPointSize( settings.legendItem.size );
|
||||
m_legendItem->setFont( font );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_legendItem;
|
||||
m_legendItem = NULL;
|
||||
}
|
||||
|
||||
QwtPlotItemList curveList = itemList( QwtPlotItem::Rtti_PlotCurve );
|
||||
if ( curveList.size() != settings.curve.numCurves )
|
||||
{
|
||||
while ( curveList.size() > settings.curve.numCurves )
|
||||
{
|
||||
QwtPlotItem* curve = curveList.takeFirst();
|
||||
delete curve;
|
||||
}
|
||||
|
||||
for ( int i = curveList.size(); i < settings.curve.numCurves; i++ )
|
||||
insertCurve();
|
||||
}
|
||||
|
||||
curveList = itemList( QwtPlotItem::Rtti_PlotCurve );
|
||||
for ( int i = 0; i < curveList.count(); i++ )
|
||||
{
|
||||
Curve* curve = static_cast< Curve* >( curveList[i] );
|
||||
curve->setCurveTitle( settings.curve.title );
|
||||
|
||||
int sz = 0.5 * settings.legendItem.size;
|
||||
curve->setLegendIconSize( QSize( sz, sz ) );
|
||||
}
|
||||
|
||||
setAutoReplot( false );
|
||||
if ( m_isDirty )
|
||||
{
|
||||
m_isDirty = false;
|
||||
replot();
|
||||
}
|
||||
}
|
||||
|
||||
void Plot::replot()
|
||||
{
|
||||
if ( autoReplot() )
|
||||
{
|
||||
m_isDirty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
QwtPlot::replot();
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
34
examples/legends/Plot.h
Normal file
34
examples/legends/Plot.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*****************************************************************************
|
||||
* 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 Settings;
|
||||
class QwtPlotLegendItem;
|
||||
class QwtLegend;
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot( QWidget* parent = NULL );
|
||||
virtual ~Plot();
|
||||
|
||||
public Q_SLOTS:
|
||||
void applySettings( const Settings& );
|
||||
|
||||
public:
|
||||
virtual void replot() QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
void insertCurve();
|
||||
|
||||
QwtLegend* m_externalLegend;
|
||||
QwtPlotLegendItem* m_legendItem;
|
||||
bool m_isDirty;
|
||||
};
|
||||
49
examples/legends/Settings.h
Normal file
49
examples/legends/Settings.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
Settings()
|
||||
{
|
||||
legend.isEnabled = false;
|
||||
legend.position = 0;
|
||||
|
||||
legendItem.isEnabled = false;
|
||||
legendItem.numColumns = 0;
|
||||
legendItem.alignment = 0;
|
||||
legendItem.backgroundMode = 0;
|
||||
legendItem.size = 12;
|
||||
|
||||
curve.numCurves = 0;
|
||||
curve.title = "Curve";
|
||||
}
|
||||
|
||||
struct
|
||||
{
|
||||
bool isEnabled;
|
||||
int position;
|
||||
} legend;
|
||||
|
||||
struct
|
||||
{
|
||||
bool isEnabled;
|
||||
int numColumns;
|
||||
int alignment;
|
||||
int backgroundMode;
|
||||
int size;
|
||||
|
||||
} legendItem;
|
||||
|
||||
struct
|
||||
{
|
||||
int numCurves;
|
||||
QString title;
|
||||
} curve;
|
||||
};
|
||||
20
examples/legends/legends.pro
Normal file
20
examples/legends/legends.pro
Normal file
@@ -0,0 +1,20 @@
|
||||
######################################################################
|
||||
# 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 = legends
|
||||
|
||||
HEADERS = \
|
||||
MainWindow.h \
|
||||
Panel.h \
|
||||
Settings.h \
|
||||
Plot.h
|
||||
|
||||
SOURCES = \
|
||||
MainWindow.cpp \
|
||||
Panel.cpp \
|
||||
Plot.cpp \
|
||||
main.cpp
|
||||
19
examples/legends/main.cpp
Normal file
19
examples/legends/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
app.setStyle( "Windows" );
|
||||
|
||||
MainWindow window;
|
||||
window.resize( 700, 500 );
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
104
examples/oscilloscope/Knob.cpp
Normal file
104
examples/oscilloscope/Knob.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Knob.h"
|
||||
|
||||
#include <QwtMath>
|
||||
#include <QwtKnob>
|
||||
#include <QwtRoundScaleDraw>
|
||||
#include <QwtScaleEngine>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QResizeEvent>
|
||||
#include <qmath.h>
|
||||
|
||||
Knob::Knob( const QString& title, double min, double max, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QFont font( "Helvetica", 10 );
|
||||
|
||||
m_knob = new QwtKnob( this );
|
||||
m_knob->setFont( font );
|
||||
|
||||
QwtScaleDiv scaleDiv =
|
||||
m_knob->scaleEngine()->divideScale( min, max, 5, 3 );
|
||||
|
||||
QList< double > ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
|
||||
if ( ticks.size() > 0 && ticks[0] > min )
|
||||
{
|
||||
if ( ticks.first() > min )
|
||||
ticks.prepend( min );
|
||||
if ( ticks.last() < max )
|
||||
ticks.append( max );
|
||||
}
|
||||
scaleDiv.setTicks( QwtScaleDiv::MajorTick, ticks );
|
||||
m_knob->setScale( scaleDiv );
|
||||
|
||||
m_knob->setKnobWidth( 50 );
|
||||
|
||||
font.setBold( true );
|
||||
m_label = new QLabel( title, this );
|
||||
m_label->setFont( font );
|
||||
m_label->setAlignment( Qt::AlignTop | Qt::AlignHCenter );
|
||||
|
||||
setSizePolicy( QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::MinimumExpanding );
|
||||
|
||||
connect( m_knob, SIGNAL(valueChanged(double)),
|
||||
this, SIGNAL(valueChanged(double)) );
|
||||
}
|
||||
|
||||
QSize Knob::sizeHint() const
|
||||
{
|
||||
QSize sz1 = m_knob->sizeHint();
|
||||
QSize sz2 = m_label->sizeHint();
|
||||
|
||||
const int w = qMax( sz1.width(), sz2.width() );
|
||||
const int h = sz1.height() + sz2.height();
|
||||
|
||||
int off = qCeil( m_knob->scaleDraw()->extent( m_knob->font() ) );
|
||||
off -= 15; // spacing
|
||||
|
||||
return QSize( w, h - off );
|
||||
}
|
||||
|
||||
void Knob::setValue( double value )
|
||||
{
|
||||
m_knob->setValue( value );
|
||||
}
|
||||
|
||||
double Knob::value() const
|
||||
{
|
||||
return m_knob->value();
|
||||
}
|
||||
|
||||
void Knob::setTheme( const QColor& color )
|
||||
{
|
||||
m_knob->setPalette( color );
|
||||
}
|
||||
|
||||
QColor Knob::theme() const
|
||||
{
|
||||
return m_knob->palette().color( QPalette::Window );
|
||||
}
|
||||
|
||||
void Knob::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
const QSize sz = event->size();
|
||||
const QSize hint = m_label->sizeHint();
|
||||
|
||||
m_label->setGeometry( 0, sz.height() - hint.height(),
|
||||
sz.width(), hint.height() );
|
||||
|
||||
const int knobHeight = m_knob->sizeHint().height();
|
||||
|
||||
int off = qCeil( m_knob->scaleDraw()->extent( m_knob->font() ) );
|
||||
off -= 15; // spacing
|
||||
|
||||
m_knob->setGeometry( 0, m_label->pos().y() - knobHeight + off,
|
||||
sz.width(), knobHeight );
|
||||
}
|
||||
|
||||
#include "moc_Knob.cpp"
|
||||
41
examples/oscilloscope/Knob.h
Normal file
41
examples/oscilloscope/Knob.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtGlobal>
|
||||
#include <QWidget>
|
||||
|
||||
class QwtKnob;
|
||||
class QLabel;
|
||||
|
||||
class Knob : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QColor theme READ theme WRITE setTheme )
|
||||
|
||||
public:
|
||||
Knob( const QString& title,
|
||||
double min, double max, QWidget* parent = NULL );
|
||||
|
||||
virtual QSize sizeHint() const QWT_OVERRIDE;
|
||||
|
||||
void setValue( double value );
|
||||
double value() const;
|
||||
|
||||
void setTheme( const QColor& );
|
||||
QColor theme() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
double valueChanged( double );
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
QwtKnob* m_knob;
|
||||
QLabel* m_label;
|
||||
};
|
||||
77
examples/oscilloscope/MainWindow.cpp
Normal file
77
examples/oscilloscope/MainWindow.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Plot.h"
|
||||
#include "Knob.h"
|
||||
#include "WheelBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
MainWindow::MainWindow( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
const double intervalLength = 10.0; // seconds
|
||||
|
||||
m_plot = new Plot();
|
||||
m_plot->setIntervalLength( intervalLength );
|
||||
|
||||
m_amplitudeKnob = new Knob( "Amplitude", 0.0, 200.0 );
|
||||
m_amplitudeKnob->setValue( 160.0 );
|
||||
|
||||
m_frequencyKnob = new Knob( "Frequency [Hz]", 0.1, 20.0 );
|
||||
m_frequencyKnob->setValue( 17.8 );
|
||||
|
||||
m_intervalWheel = new WheelBox( "Displayed [s]", 1.0, 100.0, 1.0 );
|
||||
m_intervalWheel->setValue( intervalLength );
|
||||
|
||||
m_timerWheel = new WheelBox( "Sample Interval [ms]", 0.0, 20.0, 0.1 );
|
||||
m_timerWheel->setValue( 10.0 );
|
||||
|
||||
QVBoxLayout* vLayout1 = new QVBoxLayout();
|
||||
vLayout1->addWidget( m_intervalWheel );
|
||||
vLayout1->addWidget( m_timerWheel );
|
||||
vLayout1->addStretch( 10 );
|
||||
vLayout1->addWidget( m_amplitudeKnob );
|
||||
vLayout1->addWidget( m_frequencyKnob );
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout( this );
|
||||
layout->addWidget( m_plot, 10 );
|
||||
layout->addLayout( vLayout1 );
|
||||
|
||||
connect( m_amplitudeKnob, SIGNAL(valueChanged(double)),
|
||||
SIGNAL(amplitudeChanged(double)) );
|
||||
|
||||
connect( m_frequencyKnob, SIGNAL(valueChanged(double)),
|
||||
SIGNAL(frequencyChanged(double)) );
|
||||
|
||||
connect( m_timerWheel, SIGNAL(valueChanged(double)),
|
||||
SIGNAL(signalIntervalChanged(double)) );
|
||||
|
||||
connect( m_intervalWheel, SIGNAL(valueChanged(double)),
|
||||
m_plot, SLOT(setIntervalLength(double)) );
|
||||
}
|
||||
|
||||
void MainWindow::start()
|
||||
{
|
||||
m_plot->start();
|
||||
}
|
||||
|
||||
double MainWindow::frequency() const
|
||||
{
|
||||
return m_frequencyKnob->value();
|
||||
}
|
||||
|
||||
double MainWindow::amplitude() const
|
||||
{
|
||||
return m_amplitudeKnob->value();
|
||||
}
|
||||
|
||||
double MainWindow::signalInterval() const
|
||||
{
|
||||
return m_timerWheel->value();
|
||||
}
|
||||
|
||||
#include "moc_MainWindow.cpp"
|
||||
39
examples/oscilloscope/MainWindow.h
Normal file
39
examples/oscilloscope/MainWindow.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class Plot;
|
||||
class Knob;
|
||||
class WheelBox;
|
||||
|
||||
class MainWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow( QWidget* = NULL );
|
||||
|
||||
void start();
|
||||
|
||||
double amplitude() const;
|
||||
double frequency() const;
|
||||
double signalInterval() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void amplitudeChanged( double );
|
||||
void frequencyChanged( double );
|
||||
void signalIntervalChanged( double );
|
||||
|
||||
private:
|
||||
Knob* m_frequencyKnob;
|
||||
Knob* m_amplitudeKnob;
|
||||
WheelBox* m_timerWheel;
|
||||
WheelBox* m_intervalWheel;
|
||||
|
||||
Plot* m_plot;
|
||||
};
|
||||
297
examples/oscilloscope/Plot.cpp
Normal file
297
examples/oscilloscope/Plot.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
/*****************************************************************************
|
||||
* 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 "SignalData.h"
|
||||
|
||||
#include <QwtPlotGrid>
|
||||
#include <QwtPlotLayout>
|
||||
#include <QwtPlotCanvas>
|
||||
#include <QwtPlotMarker>
|
||||
#include <QwtPlotCurve>
|
||||
#include <QwtScaleDiv>
|
||||
#include <QwtScaleMap>
|
||||
#include <QwtPlotDirectPainter>
|
||||
#include <QwtPainter>
|
||||
|
||||
#include <QEvent>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Canvas : public QwtPlotCanvas
|
||||
{
|
||||
public:
|
||||
Canvas( QwtPlot* plot = NULL )
|
||||
: QwtPlotCanvas( plot )
|
||||
{
|
||||
/*
|
||||
The backing store is important, when working with widget
|
||||
overlays ( f.e rubberbands for zooming ).
|
||||
Here we don't have them and the internal
|
||||
backing store of QWidget is good enough.
|
||||
*/
|
||||
|
||||
setPaintAttribute( QwtPlotCanvas::BackingStore, false );
|
||||
setBorderRadius( 10 );
|
||||
|
||||
if ( QwtPainter::isX11GraphicsSystem() )
|
||||
{
|
||||
#if QT_VERSION < 0x050000
|
||||
/*
|
||||
Qt::WA_PaintOutsidePaintEvent works on X11 and has a
|
||||
nice effect on the performance.
|
||||
*/
|
||||
|
||||
setAttribute( Qt::WA_PaintOutsidePaintEvent, true );
|
||||
#endif
|
||||
|
||||
/*
|
||||
Disabling the backing store of Qt improves the performance
|
||||
for the direct painter even more, but the canvas becomes
|
||||
a native window of the window system, receiving paint events
|
||||
for resize and expose operations. Those might be expensive
|
||||
when there are many points and the backing store of
|
||||
the canvas is disabled. So in this application
|
||||
we better don't disable both backing stores.
|
||||
*/
|
||||
|
||||
if ( testPaintAttribute( QwtPlotCanvas::BackingStore ) )
|
||||
{
|
||||
setAttribute( Qt::WA_PaintOnScreen, true );
|
||||
setAttribute( Qt::WA_NoSystemBackground, true );
|
||||
}
|
||||
}
|
||||
|
||||
setupPalette();
|
||||
}
|
||||
|
||||
private:
|
||||
void setupPalette()
|
||||
{
|
||||
QPalette pal = palette();
|
||||
|
||||
QLinearGradient gradient;
|
||||
gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
|
||||
gradient.setColorAt( 0.0, QColor( 0, 49, 110 ) );
|
||||
gradient.setColorAt( 1.0, QColor( 0, 87, 174 ) );
|
||||
|
||||
pal.setBrush( QPalette::Window, QBrush( gradient ) );
|
||||
|
||||
// QPalette::WindowText is used for the curve color
|
||||
pal.setColor( QPalette::WindowText, Qt::green );
|
||||
|
||||
setPalette( pal );
|
||||
}
|
||||
};
|
||||
|
||||
class CurveData : public QwtSeriesData< QPointF >
|
||||
{
|
||||
public:
|
||||
const SignalData& values() const
|
||||
{
|
||||
return SignalData::instance();
|
||||
}
|
||||
|
||||
SignalData& values()
|
||||
{
|
||||
return SignalData::instance();
|
||||
}
|
||||
|
||||
virtual QPointF sample( size_t index ) const QWT_OVERRIDE
|
||||
{
|
||||
return SignalData::instance().value( index );
|
||||
}
|
||||
|
||||
virtual size_t size() const QWT_OVERRIDE
|
||||
{
|
||||
return SignalData::instance().size();
|
||||
}
|
||||
|
||||
virtual QRectF boundingRect() const QWT_OVERRIDE
|
||||
{
|
||||
return SignalData::instance().boundingRect();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
, m_paintedPoints( 0 )
|
||||
, m_interval( 0.0, 10.0 )
|
||||
, m_timerId( -1 )
|
||||
{
|
||||
m_directPainter = new QwtPlotDirectPainter();
|
||||
|
||||
setAutoReplot( false );
|
||||
setCanvas( new Canvas() );
|
||||
|
||||
plotLayout()->setAlignCanvasToScales( true );
|
||||
|
||||
setAxisTitle( QwtAxis::XBottom, "Time [s]" );
|
||||
setAxisScale( QwtAxis::XBottom, m_interval.minValue(), m_interval.maxValue() );
|
||||
setAxisScale( QwtAxis::YLeft, -200.0, 200.0 );
|
||||
|
||||
QwtPlotGrid* grid = new QwtPlotGrid();
|
||||
grid->setPen( Qt::gray, 0.0, Qt::DotLine );
|
||||
grid->enableX( true );
|
||||
grid->enableXMin( true );
|
||||
grid->enableY( true );
|
||||
grid->enableYMin( false );
|
||||
grid->attach( this );
|
||||
|
||||
m_origin = new QwtPlotMarker();
|
||||
m_origin->setLineStyle( QwtPlotMarker::Cross );
|
||||
m_origin->setValue( m_interval.minValue() + m_interval.width() / 2.0, 0.0 );
|
||||
m_origin->setLinePen( Qt::gray, 0.0, Qt::DashLine );
|
||||
m_origin->attach( this );
|
||||
|
||||
m_curve = new QwtPlotCurve();
|
||||
m_curve->setStyle( QwtPlotCurve::Lines );
|
||||
m_curve->setPen( canvas()->palette().color( QPalette::WindowText ) );
|
||||
m_curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
|
||||
m_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
|
||||
m_curve->setData( new CurveData() );
|
||||
m_curve->attach( this );
|
||||
}
|
||||
|
||||
Plot::~Plot()
|
||||
{
|
||||
delete m_directPainter;
|
||||
}
|
||||
|
||||
void Plot::start()
|
||||
{
|
||||
m_elapsedTimer.start();
|
||||
m_timerId = startTimer( 10 );
|
||||
}
|
||||
|
||||
void Plot::replot()
|
||||
{
|
||||
CurveData* curveData = static_cast< CurveData* >( m_curve->data() );
|
||||
curveData->values().lock();
|
||||
|
||||
QwtPlot::replot();
|
||||
m_paintedPoints = curveData->size();
|
||||
|
||||
curveData->values().unlock();
|
||||
}
|
||||
|
||||
void Plot::setIntervalLength( double interval )
|
||||
{
|
||||
if ( interval > 0.0 && interval != m_interval.width() )
|
||||
{
|
||||
m_interval.setMaxValue( m_interval.minValue() + interval );
|
||||
setAxisScale( QwtAxis::XBottom,
|
||||
m_interval.minValue(), m_interval.maxValue() );
|
||||
|
||||
replot();
|
||||
}
|
||||
}
|
||||
|
||||
void Plot::updateCurve()
|
||||
{
|
||||
CurveData* curveData = static_cast< CurveData* >( m_curve->data() );
|
||||
curveData->values().lock();
|
||||
|
||||
const int numPoints = curveData->size();
|
||||
if ( numPoints > m_paintedPoints )
|
||||
{
|
||||
const bool doClip = !canvas()->testAttribute( Qt::WA_PaintOnScreen );
|
||||
if ( doClip )
|
||||
{
|
||||
/*
|
||||
Depending on the platform setting a clip might be an important
|
||||
performance issue. F.e. for Qt Embedded this reduces the
|
||||
part of the backing store that has to be copied out - maybe
|
||||
to an unaccelerated frame buffer device.
|
||||
*/
|
||||
|
||||
const QwtScaleMap xMap = canvasMap( m_curve->xAxis() );
|
||||
const QwtScaleMap yMap = canvasMap( m_curve->yAxis() );
|
||||
|
||||
QRectF br = qwtBoundingRect( *curveData,
|
||||
m_paintedPoints - 1, numPoints - 1 );
|
||||
|
||||
const QRect clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect();
|
||||
m_directPainter->setClipRegion( clipRect );
|
||||
}
|
||||
|
||||
m_directPainter->drawSeries( m_curve,
|
||||
m_paintedPoints - 1, numPoints - 1 );
|
||||
m_paintedPoints = numPoints;
|
||||
}
|
||||
|
||||
curveData->values().unlock();
|
||||
}
|
||||
|
||||
void Plot::incrementInterval()
|
||||
{
|
||||
m_interval = QwtInterval( m_interval.maxValue(),
|
||||
m_interval.maxValue() + m_interval.width() );
|
||||
|
||||
CurveData* curveData = static_cast< CurveData* >( m_curve->data() );
|
||||
curveData->values().clearStaleValues( m_interval.minValue() );
|
||||
|
||||
// To avoid, that the grid is jumping, we disable
|
||||
// the autocalculation of the ticks and shift them
|
||||
// manually instead.
|
||||
|
||||
QwtScaleDiv scaleDiv = axisScaleDiv( QwtAxis::XBottom );
|
||||
scaleDiv.setInterval( m_interval );
|
||||
|
||||
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
|
||||
{
|
||||
QList< double > ticks = scaleDiv.ticks( i );
|
||||
for ( int j = 0; j < ticks.size(); j++ )
|
||||
ticks[j] += m_interval.width();
|
||||
scaleDiv.setTicks( i, ticks );
|
||||
}
|
||||
setAxisScaleDiv( QwtAxis::XBottom, scaleDiv );
|
||||
|
||||
m_origin->setValue( m_interval.minValue() + m_interval.width() / 2.0, 0.0 );
|
||||
|
||||
m_paintedPoints = 0;
|
||||
replot();
|
||||
}
|
||||
|
||||
void Plot::timerEvent( QTimerEvent* event )
|
||||
{
|
||||
if ( event->timerId() == m_timerId )
|
||||
{
|
||||
updateCurve();
|
||||
|
||||
const double elapsed = m_elapsedTimer.elapsed() / 1e3;
|
||||
if ( elapsed > m_interval.maxValue() )
|
||||
incrementInterval();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QwtPlot::timerEvent( event );
|
||||
}
|
||||
|
||||
void Plot::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
m_directPainter->reset();
|
||||
QwtPlot::resizeEvent( event );
|
||||
}
|
||||
|
||||
void Plot::showEvent( QShowEvent* )
|
||||
{
|
||||
replot();
|
||||
}
|
||||
|
||||
bool Plot::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
if ( object == canvas() &&
|
||||
event->type() == QEvent::PaletteChange )
|
||||
{
|
||||
m_curve->setPen( canvas()->palette().color( QPalette::WindowText ) );
|
||||
}
|
||||
|
||||
return QwtPlot::eventFilter( object, event );
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
51
examples/oscilloscope/Plot.h
Normal file
51
examples/oscilloscope/Plot.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************
|
||||
* 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 <QwtInterval>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotMarker;
|
||||
class QwtPlotDirectPainter;
|
||||
|
||||
class Plot : public QwtPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot( QWidget* = NULL );
|
||||
virtual ~Plot();
|
||||
|
||||
void start();
|
||||
virtual void replot() QWT_OVERRIDE;
|
||||
|
||||
virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setIntervalLength( double );
|
||||
|
||||
protected:
|
||||
virtual void showEvent( QShowEvent* ) QWT_OVERRIDE;
|
||||
virtual void resizeEvent( QResizeEvent* ) QWT_OVERRIDE;
|
||||
virtual void timerEvent( QTimerEvent* ) QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateCurve();
|
||||
void incrementInterval();
|
||||
|
||||
QwtPlotMarker* m_origin;
|
||||
QwtPlotCurve* m_curve;
|
||||
int m_paintedPoints;
|
||||
|
||||
QwtPlotDirectPainter* m_directPainter;
|
||||
|
||||
QwtInterval m_interval;
|
||||
int m_timerId;
|
||||
|
||||
QElapsedTimer m_elapsedTimer;
|
||||
};
|
||||
58
examples/oscilloscope/SamplingThread.cpp
Normal file
58
examples/oscilloscope/SamplingThread.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SamplingThread.h"
|
||||
#include "SignalData.h"
|
||||
|
||||
#include <QwtMath>
|
||||
#include <qmath.h>
|
||||
|
||||
SamplingThread::SamplingThread( QObject* parent )
|
||||
: QwtSamplingThread( parent )
|
||||
, m_frequency( 5.0 )
|
||||
, m_amplitude( 20.0 )
|
||||
{
|
||||
}
|
||||
|
||||
void SamplingThread::setFrequency( double frequency )
|
||||
{
|
||||
m_frequency = frequency;
|
||||
}
|
||||
|
||||
double SamplingThread::frequency() const
|
||||
{
|
||||
return m_frequency;
|
||||
}
|
||||
|
||||
void SamplingThread::setAmplitude( double amplitude )
|
||||
{
|
||||
m_amplitude = amplitude;
|
||||
}
|
||||
|
||||
double SamplingThread::amplitude() const
|
||||
{
|
||||
return m_amplitude;
|
||||
}
|
||||
|
||||
void SamplingThread::sample( double elapsed )
|
||||
{
|
||||
if ( m_frequency > 0.0 )
|
||||
{
|
||||
const QPointF s( elapsed, value( elapsed ) );
|
||||
SignalData::instance().append( s );
|
||||
}
|
||||
}
|
||||
|
||||
double SamplingThread::value( double timeStamp ) const
|
||||
{
|
||||
const double period = 1.0 / m_frequency;
|
||||
|
||||
const double x = std::fmod( timeStamp, period );
|
||||
const double v = m_amplitude * qFastSin( x / period * 2 * M_PI );
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
#include "moc_SamplingThread.cpp"
|
||||
32
examples/oscilloscope/SamplingThread.h
Normal file
32
examples/oscilloscope/SamplingThread.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QwtSamplingThread>
|
||||
|
||||
class SamplingThread : public QwtSamplingThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SamplingThread( QObject* parent = NULL );
|
||||
|
||||
double frequency() const;
|
||||
double amplitude() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setAmplitude( double );
|
||||
void setFrequency( double );
|
||||
|
||||
protected:
|
||||
virtual void sample( double elapsed ) QWT_OVERRIDE;
|
||||
|
||||
private:
|
||||
virtual double value( double timeStamp ) const;
|
||||
|
||||
double m_frequency;
|
||||
double m_amplitude;
|
||||
};
|
||||
139
examples/oscilloscope/SignalData.cpp
Normal file
139
examples/oscilloscope/SignalData.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SignalData.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QMutex>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
class SignalData::PrivateData
|
||||
{
|
||||
public:
|
||||
PrivateData()
|
||||
: boundingRect( 1.0, 1.0, -2.0, -2.0 ) // invalid
|
||||
{
|
||||
values.reserve( 1000 );
|
||||
}
|
||||
|
||||
inline void append( const QPointF& sample )
|
||||
{
|
||||
values.append( sample );
|
||||
|
||||
// adjust the bounding rectangle
|
||||
|
||||
if ( boundingRect.width() < 0 || boundingRect.height() < 0 )
|
||||
{
|
||||
boundingRect.setRect( sample.x(), sample.y(), 0.0, 0.0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
boundingRect.setRight( sample.x() );
|
||||
|
||||
if ( sample.y() > boundingRect.bottom() )
|
||||
boundingRect.setBottom( sample.y() );
|
||||
|
||||
if ( sample.y() < boundingRect.top() )
|
||||
boundingRect.setTop( sample.y() );
|
||||
}
|
||||
}
|
||||
|
||||
QReadWriteLock lock;
|
||||
|
||||
QVector< QPointF > values;
|
||||
QRectF boundingRect;
|
||||
|
||||
QMutex mutex; // protecting pendingValues
|
||||
QVector< QPointF > pendingValues;
|
||||
};
|
||||
|
||||
SignalData::SignalData()
|
||||
{
|
||||
m_data = new PrivateData();
|
||||
}
|
||||
|
||||
SignalData::~SignalData()
|
||||
{
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
int SignalData::size() const
|
||||
{
|
||||
return m_data->values.size();
|
||||
}
|
||||
|
||||
QPointF SignalData::value( int index ) const
|
||||
{
|
||||
return m_data->values[index];
|
||||
}
|
||||
|
||||
QRectF SignalData::boundingRect() const
|
||||
{
|
||||
return m_data->boundingRect;
|
||||
}
|
||||
|
||||
void SignalData::lock()
|
||||
{
|
||||
m_data->lock.lockForRead();
|
||||
}
|
||||
|
||||
void SignalData::unlock()
|
||||
{
|
||||
m_data->lock.unlock();
|
||||
}
|
||||
|
||||
void SignalData::append( const QPointF& sample )
|
||||
{
|
||||
m_data->mutex.lock();
|
||||
m_data->pendingValues += sample;
|
||||
|
||||
const bool isLocked = m_data->lock.tryLockForWrite();
|
||||
if ( isLocked )
|
||||
{
|
||||
const int numValues = m_data->pendingValues.size();
|
||||
const QPointF* pendingValues = m_data->pendingValues.data();
|
||||
|
||||
for ( int i = 0; i < numValues; i++ )
|
||||
m_data->append( pendingValues[i] );
|
||||
|
||||
m_data->pendingValues.clear();
|
||||
|
||||
m_data->lock.unlock();
|
||||
}
|
||||
|
||||
m_data->mutex.unlock();
|
||||
}
|
||||
|
||||
void SignalData::clearStaleValues( double limit )
|
||||
{
|
||||
m_data->lock.lockForWrite();
|
||||
|
||||
m_data->boundingRect = QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
|
||||
|
||||
const QVector< QPointF > values = m_data->values;
|
||||
m_data->values.clear();
|
||||
m_data->values.reserve( values.size() );
|
||||
|
||||
int index;
|
||||
for ( index = values.size() - 1; index >= 0; index-- )
|
||||
{
|
||||
if ( values[index].x() < limit )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( index > 0 )
|
||||
m_data->append( values[index++] );
|
||||
|
||||
while ( index < values.size() - 1 )
|
||||
m_data->append( values[index++] );
|
||||
|
||||
m_data->lock.unlock();
|
||||
}
|
||||
|
||||
SignalData& SignalData::instance()
|
||||
{
|
||||
static SignalData valueVector;
|
||||
return valueVector;
|
||||
}
|
||||
34
examples/oscilloscope/SignalData.h
Normal file
34
examples/oscilloscope/SignalData.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QRect>
|
||||
|
||||
class SignalData
|
||||
{
|
||||
public:
|
||||
static SignalData& instance();
|
||||
|
||||
void append( const QPointF& pos );
|
||||
void clearStaleValues( double min );
|
||||
|
||||
int size() const;
|
||||
QPointF value( int index ) const;
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
SignalData();
|
||||
~SignalData();
|
||||
|
||||
Q_DISABLE_COPY( SignalData )
|
||||
|
||||
class PrivateData;
|
||||
PrivateData* m_data;
|
||||
};
|
||||
131
examples/oscilloscope/WheelBox.cpp
Normal file
131
examples/oscilloscope/WheelBox.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "WheelBox.h"
|
||||
|
||||
#include <QwtWheel>
|
||||
#include <QLabel>
|
||||
#include <QLCDNumber>
|
||||
#include <QLayout>
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Wheel : public QwtWheel
|
||||
{
|
||||
public:
|
||||
Wheel( QWidget* parent )
|
||||
: QwtWheel( parent )
|
||||
, m_ignoreWheelEvent( false )
|
||||
{
|
||||
setFocusPolicy( Qt::WheelFocus );
|
||||
parent->installEventFilter( this );
|
||||
}
|
||||
|
||||
virtual bool eventFilter( QObject* object, QEvent* event ) QWT_OVERRIDE
|
||||
{
|
||||
if ( event->type() == QEvent::Wheel && !m_ignoreWheelEvent )
|
||||
{
|
||||
const QWheelEvent* we = static_cast< QWheelEvent* >( event );
|
||||
|
||||
const QPoint pos = wheelRect().center();
|
||||
|
||||
#if QT_VERSION >= 0x050c00
|
||||
QWheelEvent wheelEvent(
|
||||
pos, mapToGlobal( pos ),
|
||||
we->pixelDelta(), we->angleDelta(),
|
||||
we->buttons(), we->modifiers(),
|
||||
we->phase(), we->inverted() );
|
||||
#else
|
||||
QWheelEvent wheelEvent(
|
||||
pos, we->delta(),
|
||||
we->buttons(), we->modifiers(),
|
||||
we->orientation() );
|
||||
#endif
|
||||
|
||||
m_ignoreWheelEvent = true;
|
||||
QApplication::sendEvent( this, &wheelEvent );
|
||||
m_ignoreWheelEvent = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return QwtWheel::eventFilter( object, event );
|
||||
}
|
||||
private:
|
||||
bool m_ignoreWheelEvent;
|
||||
};
|
||||
}
|
||||
|
||||
WheelBox::WheelBox( const QString& title,
|
||||
double min, double max, double stepSize, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_number = new QLCDNumber();
|
||||
m_number->setSegmentStyle( QLCDNumber::Filled );
|
||||
m_number->setAutoFillBackground( true );
|
||||
m_number->setFixedHeight( m_number->sizeHint().height() * 2 );
|
||||
m_number->setFocusPolicy( Qt::WheelFocus );
|
||||
|
||||
QPalette pal( Qt::black );
|
||||
pal.setColor( QPalette::WindowText, Qt::green );
|
||||
m_number->setPalette( pal );
|
||||
|
||||
m_wheel = new Wheel( this );
|
||||
m_wheel->setOrientation( Qt::Vertical );
|
||||
m_wheel->setInverted( true );
|
||||
m_wheel->setRange( min, max );
|
||||
m_wheel->setSingleStep( stepSize );
|
||||
m_wheel->setPageStepCount( 5 );
|
||||
m_wheel->setFixedHeight( m_number->height() );
|
||||
|
||||
m_number->setFocusProxy( m_wheel );
|
||||
|
||||
QFont font( "Helvetica", 10 );
|
||||
font.setBold( true );
|
||||
|
||||
m_label = new QLabel( title );
|
||||
m_label->setFont( font );
|
||||
|
||||
QHBoxLayout* hLayout = new QHBoxLayout;
|
||||
hLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
hLayout->setSpacing( 2 );
|
||||
hLayout->addWidget( m_number, 10 );
|
||||
hLayout->addWidget( m_wheel );
|
||||
|
||||
QVBoxLayout* vLayout = new QVBoxLayout( this );
|
||||
vLayout->addLayout( hLayout, 10 );
|
||||
vLayout->addWidget( m_label, 0, Qt::AlignTop | Qt::AlignHCenter );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
m_number, SLOT(display(double)) );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
this, SIGNAL(valueChanged(double)) );
|
||||
}
|
||||
|
||||
void WheelBox::setTheme( const QColor& color )
|
||||
{
|
||||
m_wheel->setPalette( color );
|
||||
}
|
||||
|
||||
QColor WheelBox::theme() const
|
||||
{
|
||||
return m_wheel->palette().color( QPalette::Window );
|
||||
}
|
||||
|
||||
void WheelBox::setValue( double value )
|
||||
{
|
||||
m_wheel->setValue( value );
|
||||
m_number->display( value );
|
||||
}
|
||||
|
||||
double WheelBox::value() const
|
||||
{
|
||||
return m_wheel->value();
|
||||
}
|
||||
|
||||
#include "moc_WheelBox.cpp"
|
||||
42
examples/oscilloscope/WheelBox.h
Normal file
42
examples/oscilloscope/WheelBox.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QwtWheel;
|
||||
class QLabel;
|
||||
class QLCDNumber;
|
||||
|
||||
class WheelBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QColor theme READ theme WRITE setTheme )
|
||||
|
||||
public:
|
||||
WheelBox( const QString& title,
|
||||
double min, double max, double stepSize,
|
||||
QWidget* parent = NULL );
|
||||
|
||||
void setTheme( const QColor& );
|
||||
QColor theme() const;
|
||||
|
||||
void setUnit( const QString& );
|
||||
QString unit() const;
|
||||
|
||||
void setValue( double value );
|
||||
double value() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
double valueChanged( double );
|
||||
|
||||
private:
|
||||
QLCDNumber* m_number;
|
||||
QwtWheel* m_wheel;
|
||||
QLabel* m_label;
|
||||
|
||||
QString m_unit;
|
||||
};
|
||||
44
examples/oscilloscope/main.cpp
Normal file
44
examples/oscilloscope/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "SamplingThread.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
app.setPalette( Qt::darkGray );
|
||||
|
||||
MainWindow window;
|
||||
window.resize( 800, 400 );
|
||||
|
||||
SamplingThread samplingThread;
|
||||
samplingThread.setFrequency( window.frequency() );
|
||||
samplingThread.setAmplitude( window.amplitude() );
|
||||
samplingThread.setInterval( window.signalInterval() );
|
||||
|
||||
window.connect( &window, SIGNAL(frequencyChanged(double)),
|
||||
&samplingThread, SLOT(setFrequency(double)) );
|
||||
|
||||
window.connect( &window, SIGNAL(amplitudeChanged(double)),
|
||||
&samplingThread, SLOT(setAmplitude(double)) );
|
||||
|
||||
window.connect( &window, SIGNAL(signalIntervalChanged(double)),
|
||||
&samplingThread, SLOT(setInterval(double)) );
|
||||
|
||||
window.show();
|
||||
|
||||
samplingThread.start();
|
||||
window.start();
|
||||
|
||||
const bool ok = app.exec();
|
||||
|
||||
samplingThread.stop();
|
||||
samplingThread.wait( 1000 );
|
||||
|
||||
return ok;
|
||||
}
|
||||
55
examples/oscilloscope/osci.css
Normal file
55
examples/oscilloscope/osci.css
Normal file
@@ -0,0 +1,55 @@
|
||||
MainWindow
|
||||
{
|
||||
border: 1px solid white;
|
||||
border-radius: 20px;
|
||||
padding: 10px;
|
||||
background-color: qlineargradient( x1: 0, y1: 0, x2: 1, y2: 1,
|
||||
stop: 0 #31312C, stop: 0.5 #808080 stop: 1 #31312C );
|
||||
}
|
||||
|
||||
QwtPlotCanvas
|
||||
{
|
||||
border: 1px solid White;
|
||||
border-radius: 10px;
|
||||
background-color: #101010;
|
||||
color: yellow; /* used as curve color */
|
||||
}
|
||||
|
||||
QwtScaleWidget
|
||||
{
|
||||
color: white;
|
||||
}
|
||||
|
||||
WheelBox
|
||||
{
|
||||
qproperty-theme: #878787;
|
||||
}
|
||||
|
||||
QwtWheel
|
||||
{
|
||||
/* background-color: yellow; */
|
||||
qproperty-mass: 0.0;
|
||||
qproperty-tickCount: 5;
|
||||
qproperty-wheelWidth: 15;
|
||||
qproperty-borderWidth: 2;
|
||||
qproperty-wheelBorderWidth: 2;
|
||||
qproperty-wrapping: true;
|
||||
}
|
||||
|
||||
Knob
|
||||
{
|
||||
qproperty-theme: #606060;
|
||||
}
|
||||
|
||||
QwtKnob
|
||||
{
|
||||
qproperty-knobStyle: Sunken;
|
||||
qproperty-markerStyle: Nub;
|
||||
qproperty-markerSize: 8;
|
||||
qproperty-borderWidth: 2;
|
||||
}
|
||||
|
||||
QLCDNumber
|
||||
{
|
||||
color: yellow;
|
||||
}
|
||||
25
examples/oscilloscope/oscilloscope.pro
Normal file
25
examples/oscilloscope/oscilloscope.pro
Normal 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
|
||||
######################################################################
|
||||
|
||||
include( $${PWD}/../examples.pri )
|
||||
|
||||
TARGET = oscilloscope
|
||||
|
||||
HEADERS = \
|
||||
SignalData.h \
|
||||
Plot.h \
|
||||
Knob.h \
|
||||
WheelBox.h \
|
||||
SamplingThread.h \
|
||||
MainWindow.h
|
||||
|
||||
SOURCES = \
|
||||
SignalData.cpp \
|
||||
Plot.cpp \
|
||||
Knob.cpp \
|
||||
WheelBox.cpp \
|
||||
SamplingThread.cpp \
|
||||
MainWindow.cpp \
|
||||
main.cpp
|
||||
96
examples/polardemo/Pixmaps.h
Normal file
96
examples/polardemo/Pixmaps.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
static const char* print_xpm[] =
|
||||
{
|
||||
"32 32 12 1",
|
||||
"a c #ffffff",
|
||||
"h c #ffff00",
|
||||
"c c #ffffff",
|
||||
"f c #dcdcdc",
|
||||
"b c #c0c0c0",
|
||||
"j c #a0a0a4",
|
||||
"e c #808080",
|
||||
"g c #808000",
|
||||
"d c #585858",
|
||||
"i c #00ff00",
|
||||
"# c #000000",
|
||||
". c None",
|
||||
"................................",
|
||||
"................................",
|
||||
"...........###..................",
|
||||
"..........#abb###...............",
|
||||
".........#aabbbbb###............",
|
||||
".........#ddaaabbbbb###.........",
|
||||
"........#ddddddaaabbbbb###......",
|
||||
".......#deffddddddaaabbbbb###...",
|
||||
"......#deaaabbbddddddaaabbbbb###",
|
||||
".....#deaaaaaaabbbddddddaaabbbb#",
|
||||
"....#deaaabbbaaaa#ddedddfggaaad#",
|
||||
"...#deaaaaaaaaaa#ddeeeeafgggfdd#",
|
||||
"..#deaaabbbaaaa#ddeeeeabbbbgfdd#",
|
||||
".#deeefaaaaaaa#ddeeeeabbhhbbadd#",
|
||||
"#aabbbeeefaaa#ddeeeeabbbbbbaddd#",
|
||||
"#bbaaabbbeee#ddeeeeabbiibbadddd#",
|
||||
"#bbbbbaaabbbeeeeeeabbbbbbaddddd#",
|
||||
"#bjbbbbbbaaabbbbeabbbbbbadddddd#",
|
||||
"#bjjjjbbbbbbaaaeabbbbbbaddddddd#",
|
||||
"#bjaaajjjbbbbbbaaabbbbadddddddd#",
|
||||
"#bbbbbaaajjjbbbbbbaaaaddddddddd#",
|
||||
"#bjbbbbbbaaajjjbbbbbbddddddddd#.",
|
||||
"#bjjjjbbbbbbaaajjjbbbdddddddd#..",
|
||||
"#bjaaajjjbbbbbbjaajjbddddddd#...",
|
||||
"#bbbbbaaajjjbbbjbbaabdddddd#....",
|
||||
"###bbbbbbaaajjjjbbbbbddddd#.....",
|
||||
"...###bbbbbbaaajbbbbbdddd#......",
|
||||
"......###bbbbbbjbbbbbddd#.......",
|
||||
".........###bbbbbbbbbdd#........",
|
||||
"............###bbbbbbd#.........",
|
||||
"...............###bbb#..........",
|
||||
"..................###..........."
|
||||
};
|
||||
|
||||
|
||||
static const char* zoom_xpm[] =
|
||||
{
|
||||
"32 32 8 1",
|
||||
"# c #000000",
|
||||
"b c #c0c0c0",
|
||||
"a c #ffffff",
|
||||
"e c #585858",
|
||||
"d c #a0a0a4",
|
||||
"c c #0000ff",
|
||||
"f c #00ffff",
|
||||
". c None",
|
||||
"..######################........",
|
||||
".#a#baaaaaaaaaaaaaaaaaa#........",
|
||||
"#aa#baaaaaaaaaaaaaccaca#........",
|
||||
"####baaaaaaaaaaaaaaaaca####.....",
|
||||
"#bbbbaaaaaaaaaaaacccaaa#da#.....",
|
||||
"#aaaaaaaaaaaaaaaacccaca#da#.....",
|
||||
"#aaaaaaaaaaaaaaaaaccaca#da#.....",
|
||||
"#aaaaaaaaaabe###ebaaaaa#da#.....",
|
||||
"#aaaaaaaaa#########aaaa#da#.....",
|
||||
"#aaaaaaaa###dbbbb###aaa#da#.....",
|
||||
"#aaaaaaa###aaaaffb###aa#da#.....",
|
||||
"#aaaaaab##aaccaaafb##ba#da#.....",
|
||||
"#aaaaaae#daaccaccaad#ea#da#.....",
|
||||
"#aaaaaa##aaaaaaccaab##a#da#.....",
|
||||
"#aaaaaa##aacccaaaaab##a#da#.....",
|
||||
"#aaaaaa##aaccccaccab##a#da#.....",
|
||||
"#aaaaaae#daccccaccad#ea#da#.....",
|
||||
"#aaaaaab##aacccaaaa##da#da#.....",
|
||||
"#aaccacd###aaaaaaa###da#da#.....",
|
||||
"#aaaaacad###daaad#####a#da#.....",
|
||||
"#acccaaaad##########da##da#.....",
|
||||
"#acccacaaadde###edd#eda#da#.....",
|
||||
"#aaccacaaaabdddddbdd#eda#a#.....",
|
||||
"#aaaaaaaaaaaaaaaaaadd#eda##.....",
|
||||
"#aaaaaaaaaaaaaaaaaaadd#eda#.....",
|
||||
"#aaaaaaaccacaaaaaaaaadd#eda#....",
|
||||
"#aaaaaaaaaacaaaaaaaaaad##eda#...",
|
||||
"#aaaaaacccaaaaaaaaaaaaa#d#eda#..",
|
||||
"########################dd#eda#.",
|
||||
"...#dddddddddddddddddddddd##eda#",
|
||||
"...#aaaaaaaaaaaaaaaaaaaaaa#.####",
|
||||
"...########################..##."
|
||||
};
|
||||
300
examples/polardemo/Plot.cpp
Normal file
300
examples/polardemo/Plot.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Polar Examples - Copyright (C) 2008 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Plot.h"
|
||||
|
||||
#include <QwtSeriesData>
|
||||
#include <QwtSymbol>
|
||||
#include <QwtLegend>
|
||||
#include <QwtPolarGrid>
|
||||
#include <QwtPolarCurve>
|
||||
#include <QwtPolarMarker>
|
||||
#include <QwtScaleEngine>
|
||||
|
||||
#include <QPen>
|
||||
|
||||
static const QwtInterval s_radialInterval( 0.0, 10.0 );
|
||||
static const QwtInterval s_azimuthInterval( 0.0, 360.0 );
|
||||
|
||||
namespace
|
||||
{
|
||||
class Data : public QwtSeriesData< QwtPointPolar >
|
||||
{
|
||||
public:
|
||||
Data( const QwtInterval& radialInterval,
|
||||
const QwtInterval& azimuthInterval, size_t size )
|
||||
: m_radialInterval( radialInterval )
|
||||
, m_azimuthInterval( azimuthInterval )
|
||||
, m_size( size )
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t size() const QWT_OVERRIDE
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
protected:
|
||||
QwtInterval m_radialInterval;
|
||||
QwtInterval m_azimuthInterval;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
class SpiralData : public Data
|
||||
{
|
||||
public:
|
||||
SpiralData( const QwtInterval& radialInterval,
|
||||
const QwtInterval& azimuthInterval, size_t size )
|
||||
: Data( radialInterval, azimuthInterval, size )
|
||||
{
|
||||
}
|
||||
|
||||
virtual QwtPointPolar sample( size_t i ) const QWT_OVERRIDE
|
||||
{
|
||||
const double stepA = 4 * m_azimuthInterval.width() / m_size;
|
||||
const double a = m_azimuthInterval.minValue() + i * stepA;
|
||||
|
||||
const double stepR = m_radialInterval.width() / m_size;
|
||||
const double r = m_radialInterval.minValue() + i * stepR;
|
||||
|
||||
return QwtPointPolar( a, r );
|
||||
}
|
||||
|
||||
virtual QRectF boundingRect() const QWT_OVERRIDE
|
||||
{
|
||||
if ( cachedBoundingRect.width() < 0.0 )
|
||||
cachedBoundingRect = qwtBoundingRect( *this );
|
||||
|
||||
return cachedBoundingRect;
|
||||
}
|
||||
};
|
||||
|
||||
class RoseData : public Data
|
||||
{
|
||||
public:
|
||||
RoseData( const QwtInterval& radialInterval,
|
||||
const QwtInterval& azimuthInterval, size_t size )
|
||||
: Data( radialInterval, azimuthInterval, size )
|
||||
{
|
||||
}
|
||||
|
||||
virtual QwtPointPolar sample( size_t i ) const QWT_OVERRIDE
|
||||
{
|
||||
const double stepA = m_azimuthInterval.width() / m_size;
|
||||
const double a = m_azimuthInterval.minValue() + i * stepA;
|
||||
|
||||
const double d = a / 360.0 * M_PI;
|
||||
const double r = m_radialInterval.maxValue() * qAbs( qSin( 4 * d ) );
|
||||
|
||||
return QwtPointPolar( a, r );
|
||||
}
|
||||
|
||||
virtual QRectF boundingRect() const QWT_OVERRIDE
|
||||
{
|
||||
if ( cachedBoundingRect.width() < 0.0 )
|
||||
cachedBoundingRect = qwtBoundingRect( *this );
|
||||
|
||||
return cachedBoundingRect;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Plot::Plot( QWidget* parent )
|
||||
: QwtPolarPlot( QwtText( "Polar Plot Demo" ), parent )
|
||||
{
|
||||
setAutoReplot( false );
|
||||
setPlotBackground( Qt::darkBlue );
|
||||
|
||||
// scales
|
||||
setScale( QwtPolar::Azimuth,
|
||||
s_azimuthInterval.minValue(), s_azimuthInterval.maxValue(),
|
||||
s_azimuthInterval.width() / 12 );
|
||||
|
||||
setScaleMaxMinor( QwtPolar::Azimuth, 2 );
|
||||
setScale( QwtPolar::Radius,
|
||||
s_radialInterval.minValue(), s_radialInterval.maxValue() );
|
||||
|
||||
// grids, axes
|
||||
|
||||
m_grid = new QwtPolarGrid();
|
||||
m_grid->setPen( QPen( Qt::white ) );
|
||||
for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
|
||||
{
|
||||
m_grid->showGrid( scaleId );
|
||||
m_grid->showMinorGrid( scaleId );
|
||||
|
||||
QPen minorPen( Qt::gray );
|
||||
#if 0
|
||||
minorPen.setStyle( Qt::DotLine );
|
||||
#endif
|
||||
m_grid->setMinorGridPen( scaleId, minorPen );
|
||||
}
|
||||
m_grid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) );
|
||||
|
||||
m_grid->showAxis( QwtPolar::AxisAzimuth, true );
|
||||
m_grid->showAxis( QwtPolar::AxisLeft, false );
|
||||
m_grid->showAxis( QwtPolar::AxisRight, true );
|
||||
m_grid->showAxis( QwtPolar::AxisTop, true );
|
||||
m_grid->showAxis( QwtPolar::AxisBottom, false );
|
||||
m_grid->showGrid( QwtPolar::Azimuth, true );
|
||||
m_grid->showGrid( QwtPolar::Radius, true );
|
||||
m_grid->attach( this );
|
||||
|
||||
// curves
|
||||
|
||||
for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
|
||||
{
|
||||
m_curve[curveId] = createCurve( curveId );
|
||||
m_curve[curveId]->attach( this );
|
||||
}
|
||||
|
||||
// markers
|
||||
QwtPolarMarker* marker = new QwtPolarMarker();
|
||||
marker->setPosition( QwtPointPolar( 57.3, 4.72 ) );
|
||||
marker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
|
||||
QBrush( Qt::white ), QPen( Qt::green ), QSize( 9, 9 ) ) );
|
||||
marker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
|
||||
QwtText text( "Marker" );
|
||||
text.setColor( Qt::black );
|
||||
QColor bg( Qt::white );
|
||||
bg.setAlpha( 200 );
|
||||
text.setBackgroundBrush( QBrush( bg ) );
|
||||
|
||||
marker->setLabel( text );
|
||||
marker->attach( this );
|
||||
|
||||
QwtLegend* legend = new QwtLegend;
|
||||
insertLegend( legend, QwtPolarPlot::BottomLegend );
|
||||
}
|
||||
|
||||
PlotSettings Plot::settings() const
|
||||
{
|
||||
PlotSettings s;
|
||||
for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
|
||||
{
|
||||
s.flags[PlotSettings::MajorGridBegin + scaleId] =
|
||||
m_grid->isGridVisible( scaleId );
|
||||
s.flags[PlotSettings::MinorGridBegin + scaleId] =
|
||||
m_grid->isMinorGridVisible( scaleId );
|
||||
}
|
||||
for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
|
||||
{
|
||||
s.flags[PlotSettings::AxisBegin + axisId] =
|
||||
m_grid->isAxisVisible( axisId );
|
||||
}
|
||||
|
||||
s.flags[PlotSettings::AutoScaling] =
|
||||
m_grid->testGridAttribute( QwtPolarGrid::AutoScaling );
|
||||
|
||||
s.flags[PlotSettings::Logarithmic] =
|
||||
scaleEngine( QwtPolar::Radius )->transformation();
|
||||
|
||||
const QwtScaleDiv* sd = scaleDiv( QwtPolar::Radius );
|
||||
s.flags[PlotSettings::Inverted] = sd->lowerBound() > sd->upperBound();
|
||||
|
||||
s.flags[PlotSettings::Antialiasing] =
|
||||
m_grid->testRenderHint( QwtPolarItem::RenderAntialiased );
|
||||
|
||||
for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
|
||||
{
|
||||
s.flags[PlotSettings::CurveBegin + curveId] =
|
||||
m_curve[curveId]->isVisible();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void Plot::applySettings( const PlotSettings& s )
|
||||
{
|
||||
for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
|
||||
{
|
||||
m_grid->showGrid( scaleId,
|
||||
s.flags[PlotSettings::MajorGridBegin + scaleId] );
|
||||
m_grid->showMinorGrid( scaleId,
|
||||
s.flags[PlotSettings::MinorGridBegin + scaleId] );
|
||||
}
|
||||
|
||||
for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
|
||||
{
|
||||
m_grid->showAxis( axisId,
|
||||
s.flags[PlotSettings::AxisBegin + axisId] );
|
||||
}
|
||||
|
||||
m_grid->setGridAttribute( QwtPolarGrid::AutoScaling,
|
||||
s.flags[PlotSettings::AutoScaling] );
|
||||
|
||||
const QwtInterval interval =
|
||||
scaleDiv( QwtPolar::Radius )->interval().normalized();
|
||||
if ( s.flags[PlotSettings::Inverted] )
|
||||
{
|
||||
setScale( QwtPolar::Radius,
|
||||
interval.maxValue(), interval.minValue() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setScale( QwtPolar::Radius,
|
||||
interval.minValue(), interval.maxValue() );
|
||||
}
|
||||
|
||||
if ( s.flags[PlotSettings::Logarithmic] )
|
||||
{
|
||||
setScaleEngine( QwtPolar::Radius, new QwtLogScaleEngine() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setScaleEngine( QwtPolar::Radius, new QwtLinearScaleEngine() );
|
||||
}
|
||||
|
||||
m_grid->setRenderHint( QwtPolarItem::RenderAntialiased,
|
||||
s.flags[PlotSettings::Antialiasing] );
|
||||
|
||||
for ( int curveId = 0; curveId < PlotSettings::NumCurves; curveId++ )
|
||||
{
|
||||
m_curve[curveId]->setRenderHint( QwtPolarItem::RenderAntialiased,
|
||||
s.flags[PlotSettings::Antialiasing] );
|
||||
m_curve[curveId]->setVisible(
|
||||
s.flags[PlotSettings::CurveBegin + curveId] );
|
||||
}
|
||||
|
||||
replot();
|
||||
}
|
||||
|
||||
QwtPolarCurve* Plot::createCurve( int id ) const
|
||||
{
|
||||
const int numPoints = 200;
|
||||
|
||||
QwtPolarCurve* curve = new QwtPolarCurve();
|
||||
curve->setStyle( QwtPolarCurve::Lines );
|
||||
//curve->setLegendAttribute( QwtPolarCurve::LegendShowLine, true );
|
||||
//curve->setLegendAttribute( QwtPolarCurve::LegendShowSymbol, true );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case PlotSettings::Spiral:
|
||||
{
|
||||
curve->setTitle( "Spiral" );
|
||||
curve->setPen( QPen( Qt::yellow, 2 ) );
|
||||
curve->setSymbol( new QwtSymbol( QwtSymbol::Rect,
|
||||
QBrush( Qt::cyan ), QPen( Qt::white ), QSize( 3, 3 ) ) );
|
||||
curve->setData(
|
||||
new SpiralData( s_radialInterval, s_azimuthInterval, numPoints ) );
|
||||
break;
|
||||
}
|
||||
case PlotSettings::Rose:
|
||||
{
|
||||
curve->setTitle( "Rose" );
|
||||
curve->setPen( QPen( Qt::red, 2 ) );
|
||||
curve->setSymbol( new QwtSymbol( QwtSymbol::Rect,
|
||||
QBrush( Qt::cyan ), QPen( Qt::white ), QSize( 3, 3 ) ) );
|
||||
curve->setData(
|
||||
new RoseData( s_radialInterval, s_azimuthInterval, numPoints ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return curve;
|
||||
}
|
||||
|
||||
#include "moc_Plot.cpp"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user