Released version 6.1.3

This commit is contained in:
Wodann 2018-08-02 11:01:31 -04:00
commit a94503cb82
1885 changed files with 276310 additions and 0 deletions

View file

@ -0,0 +1,13 @@
#include <qapplication.h>
#include "mainwindow.h"
int main( int argc, char **argv )
{
QApplication a( argc, argv );
MainWindow w;
w.resize( 800, 600 );
w.show();
return a.exec();
}

View file

@ -0,0 +1,35 @@
#include "mainwindow.h"
#include "plot.h"
#include <qmath.h>
static double randomValue()
{
// a number between [ 0.0, 1.0 ]
return ( qrand() % 100000 ) / 100000.0;
}
MainWindow::MainWindow()
{
d_plot = new Plot( this );
d_plot->setTitle( "Scatter Plot" );
setCentralWidget( d_plot );
// a million points
setSamples( 100000 );
}
void MainWindow::setSamples( int numPoints )
{
QPolygonF samples;
for ( int i = 0; i < numPoints; i++ )
{
const double x = randomValue() * 24.0 + 1.0;
const double y = ::log( 10.0 * ( x - 1.0 ) + 1.0 )
* ( randomValue() * 0.5 + 0.9 );
samples += QPointF( x, y );
}
d_plot->setSamples( samples );
}

View file

@ -0,0 +1,22 @@
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_ 1
#include <qmainwindow.h>
class Plot;
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow();
private:
void setSamples( int samples );
private:
Plot *d_plot;
};
#endif

View file

@ -0,0 +1,91 @@
#include "plot.h"
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <qwt_plot_curve.h>
class DistancePicker: public QwtPlotPicker
{
public:
DistancePicker( QWidget *canvas ):
QwtPlotPicker( canvas )
{
setTrackerMode( QwtPicker::ActiveOnly );
setStateMachine( new QwtPickerDragLineMachine() );
setRubberBand( QwtPlotPicker::PolygonRubberBand );
}
virtual QwtText trackerTextF( const QPointF &pos ) const
{
QwtText text;
const QPolygon points = selection();
if ( !points.isEmpty() )
{
QString num;
num.setNum( QLineF( pos, invTransform( points[0] ) ).length() );
QColor bg( Qt::white );
bg.setAlpha( 200 );
text.setBackgroundBrush( QBrush( bg ) );
text.setText( num );
}
return text;
}
};
Plot::Plot( QWidget *parent ):
QwtPlot( parent ),
d_curve( NULL )
{
canvas()->setStyleSheet(
"border: 2px solid Black;"
"border-radius: 15px;"
"background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );"
);
// attach curve
d_curve = new QwtPlotCurve( "Scattered Points" );
d_curve->setPen( QColor( "Purple" ) );
// when using QwtPlotCurve::ImageBuffer simple dots can be
// rendered in parallel on multicore systems.
d_curve->setRenderThreadCount( 0 ); // 0: use QThread::idealThreadCount()
d_curve->attach( this );
setSymbol( NULL );
// panning with the left mouse button
(void )new QwtPlotPanner( canvas() );
// zoom in/out with the wheel
QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
magnifier->setMouseButton( Qt::NoButton );
// distanve measurement with the right mouse button
DistancePicker *picker = new DistancePicker( canvas() );
picker->setMousePattern( QwtPlotPicker::MouseSelect1, Qt::RightButton );
picker->setRubberBandPen( QPen( Qt::blue ) );
}
void Plot::setSymbol( QwtSymbol *symbol )
{
d_curve->setSymbol( symbol );
if ( symbol == NULL )
{
d_curve->setStyle( QwtPlotCurve::Dots );
}
}
void Plot::setSamples( const QVector<QPointF> &samples )
{
d_curve->setPaintAttribute(
QwtPlotCurve::ImageBuffer, samples.size() > 1000 );
d_curve->setSamples( samples );
}

View file

@ -0,0 +1,23 @@
#ifndef _PLOT_H_
#define _PLOT_H_ 1
#include <qwt_plot.h>
class QwtPlotCurve;
class QwtSymbol;
class Plot : public QwtPlot
{
Q_OBJECT
public:
Plot( QWidget *parent = NULL );
void setSymbol( QwtSymbol * );
void setSamples( const QVector<QPointF> &samples );
private:
QwtPlotCurve *d_curve;
};
#endif // _PLOT_H_

View file

@ -0,0 +1,22 @@
################################################################
# Qwt Widget Library
# Copyright (C) 1997 Josef Wilgen
# Copyright (C) 2002 Uwe Rathmann
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the Qwt License, Version 1.0
################################################################
include( $${PWD}/../examples.pri )
TARGET = scatterplot
HEADERS = \
mainwindow.h \
plot.h
SOURCES = \
main.cpp \
mainwindow.cpp \
plot.cpp