-
Notifications
You must be signed in to change notification settings - Fork 0
/
LineChartWidget.cpp
151 lines (108 loc) · 4.47 KB
/
LineChartWidget.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "LineChartWidget.h"
#include <QAction>
#include <QMenu>
#include <QMenuBar>
#include <QToolBar>
#include <QStatusBar>
LineChartWidget::LineChartWidget(const QVector<QString> &vectorDate, const QVector<QVector<double> > &vectorSensorReadings2D, QWidget *parent)
: QMainWindow(parent)
{
lineChart = new LineChart(vectorDate, vectorSensorReadings2D);
createActions();
createMenus();
createToolBars();
createCentralWidget();
createStatusBar();
settingsWidget();
retranslateUi();
}
void LineChartWidget::createActions()
{
exportPlotToImageAction = new QAction(this);
exportPlotToImageAction->setIcon(QIcon("://icons/chart_icons/export_chart_icon.png"));
exportPlotToImageAction->setShortcut(QKeySequence::Save);
connect(exportPlotToImageAction, SIGNAL(triggered()), lineChart, SLOT(exportPlotToImage()));
printChartAction = new QAction(this);
printChartAction->setIcon(QIcon("://icons/chart_icons/print_chart_icon.png"));
printChartAction->setShortcut(QKeySequence::Print);
connect(printChartAction, SIGNAL(triggered()), lineChart, SLOT(printPlot()));
closeChartWindowAction = new QAction(this);
closeChartWindowAction->setIcon(QIcon("://icons/chart_icons/close_chart_icon.png"));
closeChartWindowAction->setShortcut(Qt::Key_F10);
connect(closeChartWindowAction, SIGNAL(triggered()), this, SLOT(close()));
}
void LineChartWidget::createMenus()
{
fileChartMenu = new QMenu(this);
fileChartMenu->addAction(exportPlotToImageAction);
fileChartMenu->addAction(printChartAction);
fileChartMenu->addSeparator();
fileChartMenu->addAction(closeChartWindowAction);
menuBar()->setStyleSheet("QMenuBar {"
"background-color: #0099CC "
"}"
"QMenuBar::item {"
"color: #FFFFFF;"
"background-color: #0099CC"
"}"
"QMenuBar::item:selected {"
"color: #000000;"
"background: orange"
"}"
"QMenuBar::item:pressed {"
"color: #000000;"
"background: #FFCC33"
"}");
menuBar()->addMenu(fileChartMenu);
}
void LineChartWidget::createToolBars()
{
chartToolBar = new QToolBar(this);
chartToolBar->addAction(exportPlotToImageAction);
chartToolBar->addAction(printChartAction);
chartToolBar->addSeparator();
chartToolBar->addAction(closeChartWindowAction);
chartToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
chartToolBar->setStyleSheet("QToolBar {background-color: #D9F1FF}");
addToolBar(Qt::LeftToolBarArea, chartToolBar);
}
void LineChartWidget::createCentralWidget()
{
centralPlotWidget = new QWidget(this);
layToCentralWidget = new QVBoxLayout(centralPlotWidget);
tabPlotWidget = new QTabWidget(centralPlotWidget);
layToCentralWidget->addWidget(tabPlotWidget);
tabPlotWidget->addTab(lineChart, tr("Chart"));
centralPlotWidget->setLayout(layToCentralWidget);
setCentralWidget(centralPlotWidget);
}
void LineChartWidget::createStatusBar()
{
statusBar()->setStyleSheet("QStatusBar { color: #FFFFFF; background-color: #0099CC }");
}
void LineChartWidget::settingsWidget()
{
setAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_ShowModal);
resize(1024, 650);
setMinimumSize(800, 480);
}
void LineChartWidget::retranslateUi()
{
exportPlotToImageAction->setText(tr("&Export"));
exportPlotToImageAction->setStatusTip(tr("Export current chart to various image formats, like as PNG or PDF"));
printChartAction->setText(tr("&Print"));
printChartAction->setStatusTip(tr("Send current chart to printer"));
closeChartWindowAction->setText(tr("&Close"));
closeChartWindowAction->setStatusTip(tr("Close Chart window"));
fileChartMenu->setTitle(tr("&File"));
fileChartMenu->setToolTip(tr("File Menu"));
chartToolBar->setWindowTitle(tr("Chart ToolBar"));
lineChart->setStatusTip(tr("Curves sensors"));
statusBar()->showMessage(tr("Ready"));
setWindowTitle(tr("LineChart of Sensors Readings"));
}
LineChartWidget::~LineChartWidget()
{
/* Empty Destructor */
}