-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.cpp
More file actions
61 lines (52 loc) · 1.37 KB
/
window.cpp
File metadata and controls
61 lines (52 loc) · 1.37 KB
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
#include "window.h"
//
Window::Window(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
map = new Map(this); //Adding Map widged to central layout
map->setData(this->getData());
ui.mapLayout->addWidget(map, 0, 0);
QObject::connect(ui.connectButton, SIGNAL(clicked()), this, SLOT(connect())); //Buttons logic connections
QObject::connect(this, SIGNAL(portConnected()), this, SLOT(enableDisconnectButton()));
QObject::connect(this, SIGNAL(portConnected()), this, SLOT(enableScanButton()));
QObject::connect(ui.scanButton, SIGNAL(clicked()), this, SLOT(scan()));
QObject::connect(ui.disconnectButton, SIGNAL(clicked()), this, SLOT(disconnect()));
}
Window::~Window()
{
}
void Window::enableDisconnectButton() //Slots and signals
{
ui.disconnectButton->setEnabled(true);
}
void Window::enableScanButton()
{
ui.scanButton->setEnabled(true);
}
void Window::connect()
{
this->port.connect("COM3", 9600);
if(this->port.connected == true)
emit portConnected();
}
void Window::disconnect()
{
this->port.disconnect();
ui.disconnectButton->setEnabled(false);
ui.scanButton->setEnabled(false);
}
void Window::scan()
{
this->port.gatherData();
for( auto x : port.getData())
{
std::cout << x.first << '\t' << x.second << std::endl;
}
map->setData(this->getData());
map->repaint();
}
pointList Window::getData()
{
return port.getData();
}