Changeset View
Changeset View
Standalone View
Standalone View
testclient/widgets/movementwidget.cpp
- This file was added.
1 | /* AtCore Test Client | ||||
---|---|---|---|---|---|
2 | Copyright (C) <2018> | ||||
3 | Author: Chris Rizzitello - rizzitello@kde.org | ||||
4 | | ||||
5 | This program is free software: you can redistribute it and/or modify | ||||
6 | it under the terms of the GNU General Public License as published by | ||||
7 | the Free Software Foundation, either version 3 of the License, or | ||||
8 | (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | #include <QHBoxLayout> | ||||
19 | #include <QPushButton> | ||||
20 | #include <QVBoxLayout> | ||||
21 | | ||||
22 | #include "axiscontrol.h" | ||||
23 | #include "movementwidget.h" | ||||
24 | | ||||
25 | MovementWidget::MovementWidget(QWidget *parent) : | ||||
26 | QWidget(parent) | ||||
27 | { | ||||
28 | auto mainLayout = new QVBoxLayout; | ||||
29 | auto hBoxLayout = new QHBoxLayout; | ||||
30 | | ||||
31 | auto newButton = new QPushButton(tr("Home All")); | ||||
32 | hBoxLayout->addWidget(newButton); | ||||
33 | connect(newButton, &QPushButton::clicked, [this] { | ||||
34 | emit(homeAllPressed()); | ||||
35 | }); | ||||
36 | | ||||
37 | newButton = new QPushButton(tr("Home X")); | ||||
38 | hBoxLayout->addWidget(newButton); | ||||
39 | connect(newButton, &QPushButton::clicked, [this] { | ||||
40 | emit(homeXPressed()); | ||||
41 | }); | ||||
42 | | ||||
43 | newButton = new QPushButton(tr("Home Y")); | ||||
44 | hBoxLayout->addWidget(newButton); | ||||
45 | connect(newButton, &QPushButton::clicked, [this] { | ||||
46 | emit(homeYPressed()); | ||||
47 | }); | ||||
48 | | ||||
49 | newButton = new QPushButton(tr("Home Z")); | ||||
50 | hBoxLayout->addWidget(newButton); | ||||
51 | connect(newButton, &QPushButton::clicked, [this] { | ||||
52 | emit(homeZPressed()); | ||||
53 | }); | ||||
54 | mainLayout->addLayout(hBoxLayout); | ||||
55 | | ||||
56 | comboMoveAxis = new QComboBox; | ||||
57 | comboMoveAxis->addItem(tr("Move X Axis to")); | ||||
58 | comboMoveAxis->addItem(tr("Move Y Axis to")); | ||||
59 | comboMoveAxis->addItem(tr("Move Z Axis to")); | ||||
60 | | ||||
61 | sbMoveAxis = new QDoubleSpinBox; | ||||
62 | sbMoveAxis->setRange(0, 200); | ||||
63 | | ||||
64 | newButton = new QPushButton(tr("Go")); | ||||
65 | connect(newButton, &QPushButton::clicked, this, [this] { | ||||
66 | if (comboMoveAxis->currentIndex() == 0) | ||||
67 | { | ||||
68 | emit(absoluteMove(QLatin1Char('X'), sbMoveAxis->value())); | ||||
69 | } else if (comboMoveAxis->currentIndex() == 1) | ||||
70 | { | ||||
71 | emit(absoluteMove(QLatin1Char('Y'), sbMoveAxis->value())); | ||||
72 | } else if (comboMoveAxis->currentIndex() == 2) | ||||
73 | { | ||||
74 | emit(absoluteMove(QLatin1Char('Z'), sbMoveAxis->value())); | ||||
75 | } | ||||
76 | }); | ||||
77 | | ||||
78 | hBoxLayout = new QHBoxLayout; | ||||
79 | hBoxLayout->addWidget(comboMoveAxis); | ||||
80 | hBoxLayout->addWidget(sbMoveAxis); | ||||
81 | hBoxLayout->addWidget(newButton); | ||||
82 | mainLayout->addLayout(hBoxLayout); | ||||
83 | | ||||
84 | newButton = new QPushButton(tr("Disable Motors")); | ||||
85 | mainLayout->addWidget(newButton); | ||||
86 | connect(newButton, &QPushButton::clicked, [this] { | ||||
87 | emit(disableMotorsPressed()); | ||||
88 | }); | ||||
89 | | ||||
90 | auto axisControl = new AxisControl; | ||||
91 | mainLayout->addWidget(axisControl); | ||||
92 | connect(axisControl, &AxisControl::clicked, this, &MovementWidget::relativeMove); | ||||
93 | | ||||
94 | setLayout(mainLayout); | ||||
95 | } |