MCPcopy Create free account
hub / github.com/KDAB/KDChart / MainWidget

Method MainWidget

examples/Plotter/BigDataset/MainWidget.cpp:21–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include <cmath>
20
21MainWidget::MainWidget()
22 : m_controlsContainer(new QWidget(this))
23{
24 // set up the chart
25
26 auto *topLayout = new QHBoxLayout(this);
27 m_controls.setupUi(m_controlsContainer);
28 topLayout->addWidget(m_controlsContainer);
29
30 auto *chart = new KDChart::Chart;
31 topLayout->addWidget(chart);
32
33 m_plotter = new KDChart::Plotter;
34 m_plotter->setModel(&m_model);
35 KDChart::AbstractDiagram::Private::get(m_plotter)->doDumpPaintTime = true;
36 chart->coordinatePlane()->replaceDiagram(m_plotter);
37
38 auto *cPlane = qobject_cast<KDChart::CartesianCoordinatePlane *>(chart->coordinatePlane());
39 Q_ASSERT(cPlane);
40 cPlane->setVerticalRange(QPair<qreal, qreal>(-2, 2));
41
42 auto *xAxis = new KDChart::CartesianAxis(m_plotter);
43 xAxis->setPosition(KDChart::CartesianAxis::Bottom);
44 xAxis->setTitleText("X");
45 m_plotter->addAxis(xAxis);
46
47 auto *yAxis = new KDChart::CartesianAxis(m_plotter);
48 yAxis->setPosition(KDChart::CartesianAxis::Left);
49 yAxis->setTitleText("Y");
50 m_plotter->addAxis(yAxis);
51
52 // wire up the UI
53
54 // index of elements in vector must match corresponding Model::Function enum values
55 m_functionSelector << m_controls.sineRadio << m_controls.triangleRadio << m_controls.squareRadio
56 << m_controls.noiseRadio << m_controls.oneDivSineRadio
57 << m_controls.sineOneDivRadio;
58 foreach (QRadioButton *r, m_functionSelector) {
59 connect(r, SIGNAL(toggled(bool)), SLOT(functionToggled(bool)));
60 }
61
62 connect(m_controls.runButton, SIGNAL(toggled(bool)),
63 &m_model, SLOT(setRunning(bool)));
64
65 // order matters again
66 m_addPointsButtons << m_controls.add1kButton << m_controls.add10kButton << m_controls.add100kButton;
67 foreach (QPushButton *b, m_addPointsButtons) {
68 connect(b, SIGNAL(clicked(bool)), SLOT(addPointsButtonClicked()));
69 }
70}
71
72// slot
73void MainWidget::functionToggled(bool checked)

Callers

nothing calls this directly

Calls 8

setVerticalRangeMethod · 0.80
setupUiMethod · 0.45
setModelMethod · 0.45
replaceDiagramMethod · 0.45
coordinatePlaneMethod · 0.45
setPositionMethod · 0.45
setTitleTextMethod · 0.45
addAxisMethod · 0.45

Tested by

no test coverage detected