File: main.cpp

package info (click to toggle)
qwt 6.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 23,808 kB
  • sloc: cpp: 57,687; xml: 182; makefile: 32
file content (66 lines) | stat: -rw-r--r-- 1,656 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "plotmatrix.h"
#include <qwt_plot_grid.h>
#include <qwt_scale_widget.h>
#include <qapplication.h>
#include <qpen.h>
#include <qmath.h>

class MainWindow: public PlotMatrix
{
public:
    MainWindow();
};

MainWindow::MainWindow():
    PlotMatrix( 3, 4 )
{
    enableAxis( QwtPlot::yLeft );
    enableAxis( QwtPlot::yRight );
    enableAxis( QwtPlot::xBottom );

    for ( int row = 0; row < numRows(); row++ )
    {
        const double v = qPow( 10.0, row );
        setAxisScale( QwtPlot::yLeft, row, -v, v );
        setAxisScale( QwtPlot::yRight, row, -v, v );
    }

    for ( int col = 0; col < numColumns(); col++ )
    {
        const double v = qPow( 10.0, col );
        setAxisScale( QwtPlot::xBottom, col, -v, v );
        setAxisScale( QwtPlot::xTop, col, -v, v );
    }

    for ( int row = 0; row < numRows(); row++ )
    {
        for ( int col = 0; col < numColumns(); col++ )
        {
            QwtPlot *plot = plotAt( row, col );
            plot->setCanvasBackground( QColor( Qt::darkGray ) );

            QwtPlotGrid *grid = new QwtPlotGrid();
            grid->enableXMin( true );
            grid->setMajorPen( Qt::white, 0, Qt::DotLine );
            grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
            grid->attach( plot );
        }
    }

    plotAt( 1, 0 )->axisWidget( QwtPlot::yLeft )->setLabelRotation( 45 );
    plotAt( 1, numColumns() - 1 )->axisWidget( QwtPlot::yRight )->setLabelRotation( -45 );

    updateLayout();
}

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    MainWindow mainWindow;

    mainWindow.resize( 800, 600 );
    mainWindow.show();

    return a.exec();
}