-
Notifications
You must be signed in to change notification settings - Fork 0
/
cd.cpp
80 lines (71 loc) · 1.7 KB
/
cd.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
#include "cd.h"
#include "ui_centraldialog.h"
CentralDialog::CentralDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::CentralDialog)
{
ui->setupUi(this);
wdjts = new SingleJointUnit*[MaxJoints];
for(int i=0; i < MaxJoints; ++i)
{
wdjts[i] = new SingleJointUnit(i+1, this);
ui->verticalLayout->addWidget(wdjts[i]);
connect(wdjts[i], SIGNAL(moveRequest(int, int)), this, SLOT(onMoveRequest(int, int)));
}
connect(this, SIGNAL(stScan()), ui->widget, SLOT(StartScan()));
}
CentralDialog::~CentralDialog()
{
for(int i=0; i < MaxJoints; ++i)
{
delete wdjts[i];
}
delete[] wdjts;
delete ui;
}
void CentralDialog::startScan()
{
emit stScan();
}
void CentralDialog::onMoveRequest(int slot, int direction)
{
int step;
int speed;
bool ok;
step = ui->lineStep->text().toInt(&ok);
if(ok)
{
if( step > 180 )
{
step = 180;
ui->lineStep->setText(QString("%1").arg(step));
}
if (step < 10)
{
step = 10;
ui->lineStep->setText(QString("%1").arg(step));
}
} else
{
return;
}
speed = ui->lineSpeed->text().toInt(&ok);
if(ok)
{
if( speed > 100 )
{
speed = 100;
ui->lineSpeed->setText(QString("%1").arg(speed));
}
if (speed < 30)
{
speed = 30;
ui->lineSpeed->setText(QString("%1").arg(speed));
}
} else
{
return;
}
ui->widget->makeMove(slot, direction, step, speed);
}
const int CentralDialog::MaxJoints = 6;