| 363 |
Kevin |
1 |
#include "PasteController.h"
|
|
|
2 |
|
|
|
3 |
PasteController::PasteController(QWidget *parent) : QWidget(parent)
|
|
|
4 |
{
|
| 364 |
Kevin |
5 |
connected = false;
|
|
|
6 |
hotkeysEnabled = false;
|
|
|
7 |
xPos = yPos = zPos = 0.0;
|
|
|
8 |
X_Incr = X_Decr = Y_Incr = Y_Decr = Z_Incr = Z_Decr = E_Incr = false;
|
|
|
9 |
|
|
|
10 |
tmrUpdate = new QTimer(this);
|
|
|
11 |
connect(tmrUpdate, SIGNAL(timeout()), this, SLOT(UpdatePosition()));
|
|
|
12 |
|
| 363 |
Kevin |
13 |
QString helpString = "";
|
|
|
14 |
helpString.append("XY Control: Arrow Keys or H/J/K/L\n");
|
|
|
15 |
helpString.append("Z Control: PgUp/PgDown\n");
|
|
|
16 |
helpString.append("Extruder Control: Space");
|
|
|
17 |
labelHelp = new QLabel(helpString);
|
|
|
18 |
|
|
|
19 |
QVBoxLayout *helpLayout = new QVBoxLayout();
|
|
|
20 |
helpLayout->addWidget(labelHelp);
|
|
|
21 |
|
|
|
22 |
QGroupBox *helpBox = new QGroupBox("Hotkeys:");
|
|
|
23 |
helpBox->setLayout(helpLayout);
|
|
|
24 |
|
| 364 |
Kevin |
25 |
btnEnableHotkeys = new QPushButton("&Enable Hotkeys");
|
|
|
26 |
connect(btnEnableHotkeys, SIGNAL(clicked()), this, SLOT(ToggleHotkeys()));
|
| 363 |
Kevin |
27 |
|
| 364 |
Kevin |
28 |
btnInit = new QPushButton("&Initialize Printer");
|
|
|
29 |
|
|
|
30 |
btnHome = new QPushButton("&Home Printhead");
|
|
|
31 |
connect(btnHome, SIGNAL(clicked()), this, SLOT(ResetPosition()));
|
|
|
32 |
|
| 363 |
Kevin |
33 |
QVBoxLayout *miscBtnLayout = new QVBoxLayout();
|
|
|
34 |
miscBtnLayout->addWidget(btnEnableHotkeys);
|
|
|
35 |
miscBtnLayout->addWidget(btnInit);
|
|
|
36 |
miscBtnLayout->addWidget(btnHome);
|
|
|
37 |
|
|
|
38 |
QGroupBox *miscBtnBox = new QGroupBox("Preset Commands");
|
|
|
39 |
miscBtnBox->setLayout(miscBtnLayout);
|
|
|
40 |
miscBtnBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
|
|
|
41 |
|
|
|
42 |
// Icons from http://ikons.piotrkwiatkowski.co.uk/index.html
|
|
|
43 |
QIcon iconUp(":/External/Resources/arrow_up.png");
|
|
|
44 |
QIcon iconDown(":/External/Resources/arrow_down.png");
|
|
|
45 |
QIcon iconLeft(":/External/Resources/arrow_left.png");
|
|
|
46 |
QIcon iconRight(":/External/Resources/arrow_right.png");
|
|
|
47 |
QIcon iconAdd(":/External/Resources/upload.png");
|
|
|
48 |
QIcon iconRemove(":/External/Resources/download.png");
|
|
|
49 |
QIcon iconDelete(":/External/Resources/close.png");
|
|
|
50 |
|
|
|
51 |
btnForward = new QToolButton();
|
|
|
52 |
btnForward->setIcon(iconUp);
|
|
|
53 |
btnForward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
54 |
btnForward->setAutoRaise(true);
|
| 364 |
Kevin |
55 |
connect(btnForward, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
56 |
btnBackward = new QToolButton();
|
|
|
57 |
btnBackward->setIcon(iconDown);
|
|
|
58 |
btnBackward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
59 |
btnBackward->setAutoRaise(true);
|
| 364 |
Kevin |
60 |
connect(btnBackward, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
61 |
btnLeft = new QToolButton();
|
|
|
62 |
btnLeft->setIcon(iconLeft);
|
|
|
63 |
btnLeft->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
64 |
btnLeft->setAutoRaise(true);
|
| 364 |
Kevin |
65 |
connect(btnLeft, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
66 |
btnRight = new QToolButton();
|
|
|
67 |
btnRight->setIcon(iconRight);
|
|
|
68 |
btnRight->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
69 |
btnRight->setAutoRaise(true);
|
| 364 |
Kevin |
70 |
connect(btnRight, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
71 |
btnUp = new QToolButton();
|
|
|
72 |
btnUp->setIcon(iconAdd);
|
|
|
73 |
btnUp->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
74 |
btnUp->setAutoRaise(true);
|
| 364 |
Kevin |
75 |
connect(btnUp, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
76 |
btnDown = new QToolButton();
|
|
|
77 |
btnDown->setIcon(iconRemove);
|
|
|
78 |
btnDown->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
79 |
btnDown->setAutoRaise(true);
|
| 364 |
Kevin |
80 |
connect(btnDown, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 363 |
Kevin |
81 |
btnExtrude = new QToolButton();
|
|
|
82 |
btnExtrude->setIcon(iconDelete);
|
|
|
83 |
btnExtrude->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
|
|
84 |
btnExtrude->setAutoRaise(true);
|
|
|
85 |
|
|
|
86 |
QGridLayout *btnXYELayout = new QGridLayout();
|
|
|
87 |
btnXYELayout->addWidget(btnForward, 0, 1, 1, 1);
|
|
|
88 |
btnXYELayout->addWidget(btnLeft, 1, 0, 1, 1);
|
|
|
89 |
btnXYELayout->addWidget(btnExtrude, 1, 1, 1, 1);
|
|
|
90 |
btnXYELayout->addWidget(btnRight, 1, 2, 1, 1);
|
|
|
91 |
btnXYELayout->addWidget(btnBackward, 2, 1, 1, 1);
|
|
|
92 |
|
|
|
93 |
QVBoxLayout *btnZLayout = new QVBoxLayout();
|
|
|
94 |
btnZLayout->addWidget(btnUp);
|
|
|
95 |
btnZLayout->addWidget(btnDown);
|
|
|
96 |
|
|
|
97 |
QHBoxLayout *btnNavLayout = new QHBoxLayout();
|
|
|
98 |
btnNavLayout->addLayout(btnXYELayout);
|
|
|
99 |
btnNavLayout->addLayout(btnZLayout);
|
|
|
100 |
|
|
|
101 |
QGroupBox *controlBox = new QGroupBox("Manual Printer Control");
|
|
|
102 |
controlBox->setLayout(btnNavLayout);
|
|
|
103 |
controlBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
|
|
104 |
|
|
|
105 |
labelXPos = new QLabel("X :");
|
| 364 |
Kevin |
106 |
labelXPos->setFont(QFont("", 14, QFont::Normal));
|
| 363 |
Kevin |
107 |
labelYPos = new QLabel("Y :");
|
| 364 |
Kevin |
108 |
labelYPos->setFont(QFont("", 14, QFont::Normal));
|
| 363 |
Kevin |
109 |
labelZPos = new QLabel("Z :");
|
| 364 |
Kevin |
110 |
labelZPos->setFont(QFont("", 14, QFont::Normal));
|
| 363 |
Kevin |
111 |
textXValue = new QLineEdit();
|
|
|
112 |
textXValue->setReadOnly(true);
|
|
|
113 |
textXValue->setMaximumWidth(60);
|
| 364 |
Kevin |
114 |
textXValue->setFont(QFont("", 10, QFont::Bold));
|
|
|
115 |
textXValue->setAlignment(Qt::AlignCenter);
|
| 363 |
Kevin |
116 |
textYValue = new QLineEdit();
|
|
|
117 |
textYValue->setReadOnly(true);
|
|
|
118 |
textYValue->setMaximumWidth(60);
|
| 364 |
Kevin |
119 |
textYValue->setFont(QFont("", 10, QFont::Bold));
|
|
|
120 |
textYValue->setAlignment(Qt::AlignCenter);
|
| 363 |
Kevin |
121 |
textZValue = new QLineEdit();
|
|
|
122 |
textZValue->setReadOnly(true);
|
|
|
123 |
textZValue->setMaximumWidth(60);
|
| 364 |
Kevin |
124 |
textZValue->setFont(QFont("", 10, QFont::Bold));
|
|
|
125 |
textZValue->setAlignment(Qt::AlignCenter);
|
|
|
126 |
UpdatePosition();
|
| 363 |
Kevin |
127 |
|
|
|
128 |
QHBoxLayout *posValueLayout = new QHBoxLayout();
|
|
|
129 |
posValueLayout->addWidget(labelXPos);
|
|
|
130 |
posValueLayout->addWidget(textXValue);
|
|
|
131 |
posValueLayout->addWidget(labelYPos);
|
|
|
132 |
posValueLayout->addWidget(textYValue);
|
|
|
133 |
posValueLayout->addWidget(labelZPos);
|
|
|
134 |
posValueLayout->addWidget(textZValue);
|
|
|
135 |
|
|
|
136 |
QGroupBox *toolheadPosBox = new QGroupBox("Toolhead Position");
|
|
|
137 |
toolheadPosBox->setLayout(posValueLayout);
|
|
|
138 |
toolheadPosBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
|
|
139 |
|
| 364 |
Kevin |
140 |
labelXYSteps = new QLabel("XY Axis Step (mm):");
|
|
|
141 |
sliderXYSteps = new QSlider(Qt::Horizontal);
|
|
|
142 |
textXYSteps = new QDoubleSpinBox();
|
|
|
143 |
textXYSteps->setMinimumWidth(60);
|
|
|
144 |
labelXYSpeed = new QLabel("XY Axis Speed (mm/s):");
|
| 363 |
Kevin |
145 |
sliderXYSpeed = new QSlider(Qt::Horizontal);
|
|
|
146 |
textXYSpeed = new QSpinBox();
|
|
|
147 |
textXYSpeed->setMinimumWidth(60);
|
| 364 |
Kevin |
148 |
labelZSteps = new QLabel("Z Axis Step (mm):");
|
|
|
149 |
sliderZSteps = new QSlider(Qt::Horizontal);
|
|
|
150 |
textZSteps = new QDoubleSpinBox();
|
|
|
151 |
textZSteps->setMinimumWidth(60);
|
|
|
152 |
labelZSpeed = new QLabel("Z Axis Speed (mm/s):");
|
| 363 |
Kevin |
153 |
sliderZSpeed = new QSlider(Qt::Horizontal);
|
|
|
154 |
textZSpeed = new QSpinBox();
|
|
|
155 |
textZSpeed->setMinimumWidth(60);
|
| 364 |
Kevin |
156 |
labelRepeatDelay = new QLabel("Repeat Delay (ms):");
|
| 363 |
Kevin |
157 |
sliderRepeatDelay = new QSlider(Qt::Horizontal);
|
|
|
158 |
textRepeatDelay = new QSpinBox();
|
|
|
159 |
textRepeatDelay->setMinimumWidth(60);
|
|
|
160 |
|
| 364 |
Kevin |
161 |
labelEForwardSteps = new QLabel("Extrude Step (mm):");
|
|
|
162 |
sliderEForwardSteps = new QSlider(Qt::Horizontal);
|
|
|
163 |
textEForwardSteps = new QSpinBox();
|
|
|
164 |
textEForwardSteps->setMinimumWidth(60);
|
|
|
165 |
labelEForwardSpeed = new QLabel("Extrude Speed (mm/s):");
|
|
|
166 |
sliderEForwardSpeed = new QSlider(Qt::Horizontal);
|
|
|
167 |
textEForwardSpeed = new QSpinBox();
|
|
|
168 |
textEForwardSpeed->setMinimumWidth(60);
|
|
|
169 |
labelEBackwardSteps = new QLabel("Retract Step (mm):");
|
|
|
170 |
sliderEBackwardSteps = new QSlider(Qt::Horizontal);
|
|
|
171 |
textEBackwardSteps = new QSpinBox();
|
|
|
172 |
textEBackwardSteps->setMinimumWidth(60);
|
|
|
173 |
labelEBackwardSpeed = new QLabel("Retract Speed: (mm/s)");
|
|
|
174 |
sliderEBackwardSpeed = new QSlider(Qt::Horizontal);
|
|
|
175 |
textEBackwardSpeed = new QSpinBox();
|
|
|
176 |
textEBackwardSpeed->setMinimumWidth(60);
|
|
|
177 |
labelEZSteps = new QLabel("Z Axis Step (mm):");
|
|
|
178 |
sliderEZSteps = new QSlider(Qt::Horizontal);
|
|
|
179 |
textEZSteps = new QDoubleSpinBox();
|
|
|
180 |
textEZSteps->setMinimumWidth(60);
|
|
|
181 |
|
|
|
182 |
connect(sliderXYSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int)));
|
|
|
183 |
connect(textXYSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double)));
|
|
|
184 |
sliderXYSteps->setRange(0, 5000);
|
|
|
185 |
textXYSteps->setRange(0,50);
|
|
|
186 |
textXYSteps->setSingleStep(0.1);
|
|
|
187 |
textXYSteps->setValue(10);
|
|
|
188 |
connect(sliderXYSpeed, SIGNAL(valueChanged(int)), textXYSpeed, SLOT(setValue(int)));
|
|
|
189 |
connect(textXYSpeed, SIGNAL(valueChanged(int)), sliderXYSpeed, SLOT(setValue(int)));
|
|
|
190 |
sliderXYSpeed->setRange(1, 10000);
|
|
|
191 |
textXYSpeed->setRange(1, 10000);
|
|
|
192 |
textXYSpeed->setValue(4000);
|
|
|
193 |
connect(sliderZSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int)));
|
|
|
194 |
connect(textZSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double)));
|
|
|
195 |
sliderZSteps->setRange(0, 5000);
|
|
|
196 |
textZSteps->setRange(0, 50);
|
|
|
197 |
textZSteps->setSingleStep(0.1);
|
|
|
198 |
textZSteps->setValue(10);
|
|
|
199 |
connect(sliderZSpeed, SIGNAL(valueChanged(int)), textZSpeed, SLOT(setValue(int)));
|
|
|
200 |
connect(textZSpeed, SIGNAL(valueChanged(int)), sliderZSpeed, SLOT(setValue(int)));
|
|
|
201 |
sliderZSpeed->setRange(1, 10000);
|
|
|
202 |
textZSpeed->setRange(1, 10000);
|
|
|
203 |
textZSpeed->setValue(1000);
|
|
|
204 |
connect(sliderRepeatDelay, SIGNAL(valueChanged(int)), textRepeatDelay, SLOT(setValue(int)));
|
|
|
205 |
connect(textRepeatDelay, SIGNAL(valueChanged(int)), sliderRepeatDelay, SLOT(setValue(int)));
|
|
|
206 |
connect(textRepeatDelay, SIGNAL(valueChanged(int)), this, SLOT(UpdateTimer(int)));
|
|
|
207 |
sliderRepeatDelay->setRange(20, 500);
|
|
|
208 |
textRepeatDelay->setRange(20, 500);
|
|
|
209 |
textRepeatDelay->setValue(100);
|
|
|
210 |
|
| 363 |
Kevin |
211 |
QGridLayout *xyRepeatLayout = new QGridLayout();
|
| 364 |
Kevin |
212 |
xyRepeatLayout->addWidget(labelXYSteps, 0, 0);
|
|
|
213 |
xyRepeatLayout->addWidget(sliderXYSteps, 0, 1);
|
|
|
214 |
xyRepeatLayout->addWidget(textXYSteps, 0, 2);
|
| 363 |
Kevin |
215 |
xyRepeatLayout->addWidget(labelXYSpeed, 1, 0);
|
|
|
216 |
xyRepeatLayout->addWidget(sliderXYSpeed, 1, 1);
|
|
|
217 |
xyRepeatLayout->addWidget(textXYSpeed, 1, 2);
|
| 364 |
Kevin |
218 |
xyRepeatLayout->addWidget(labelZSteps, 2, 0);
|
|
|
219 |
xyRepeatLayout->addWidget(sliderZSteps, 2, 1);
|
|
|
220 |
xyRepeatLayout->addWidget(textZSteps, 2, 2);
|
| 363 |
Kevin |
221 |
xyRepeatLayout->addWidget(labelZSpeed, 3, 0);
|
|
|
222 |
xyRepeatLayout->addWidget(sliderZSpeed, 3, 1);
|
|
|
223 |
xyRepeatLayout->addWidget(textZSpeed, 3, 2);
|
|
|
224 |
xyRepeatLayout->addWidget(labelRepeatDelay, 4, 0);
|
|
|
225 |
xyRepeatLayout->addWidget(sliderRepeatDelay, 4, 1);
|
|
|
226 |
xyRepeatLayout->addWidget(textRepeatDelay, 4, 2);
|
|
|
227 |
|
|
|
228 |
QGroupBox *xyRepeatBox = new QGroupBox("Movement Settings");
|
|
|
229 |
xyRepeatBox->setLayout(xyRepeatLayout);
|
|
|
230 |
|
| 364 |
Kevin |
231 |
connect(sliderEForwardSteps, SIGNAL(valueChanged(int)), textEForwardSteps, SLOT(setValue(int)));
|
|
|
232 |
connect(textEForwardSteps, SIGNAL(valueChanged(int)), sliderEForwardSteps, SLOT(setValue(int)));
|
|
|
233 |
sliderEForwardSteps->setRange(1, 10000);
|
|
|
234 |
textEForwardSteps->setRange(1, 10000);
|
|
|
235 |
textEForwardSteps->setValue(4000);
|
|
|
236 |
connect(sliderEForwardSpeed, SIGNAL(valueChanged(int)), textEForwardSpeed, SLOT(setValue(int)));
|
|
|
237 |
connect(textEForwardSpeed, SIGNAL(valueChanged(int)), sliderEForwardSpeed, SLOT(setValue(int)));
|
|
|
238 |
sliderEForwardSpeed->setRange(1, 10000);
|
|
|
239 |
textEForwardSpeed->setRange(1, 10000);
|
|
|
240 |
textEForwardSpeed->setValue(1000);
|
|
|
241 |
connect(sliderEBackwardSteps, SIGNAL(valueChanged(int)), textEBackwardSteps, SLOT(setValue(int)));
|
|
|
242 |
connect(textEBackwardSteps, SIGNAL(valueChanged(int)), sliderEBackwardSteps, SLOT(setValue(int)));
|
|
|
243 |
sliderEBackwardSteps->setRange(1, 10000);
|
|
|
244 |
textEBackwardSteps->setRange(1, 10000);
|
|
|
245 |
textEBackwardSteps->setValue(2000);
|
|
|
246 |
connect(sliderEBackwardSpeed, SIGNAL(valueChanged(int)), textEBackwardSpeed, SLOT(setValue(int)));
|
|
|
247 |
connect(textEBackwardSpeed, SIGNAL(valueChanged(int)), sliderEBackwardSpeed, SLOT(setValue(int)));
|
|
|
248 |
sliderEBackwardSpeed->setRange(1, 10000);
|
|
|
249 |
textEBackwardSpeed->setRange(1, 10000);
|
|
|
250 |
textEBackwardSpeed->setValue(2000);
|
|
|
251 |
connect(sliderEZSteps, SIGNAL(valueChanged(int)), this, SLOT(QSliderToQDoubleSpinBox(int)));
|
|
|
252 |
connect(textEZSteps, SIGNAL(valueChanged(double)), this, SLOT(QDoubleSpinBoxToQSlider(double)));
|
|
|
253 |
sliderEZSteps->setRange(0, 1000);
|
|
|
254 |
textEZSteps->setRange(0, 10);
|
|
|
255 |
textEZSteps->setSingleStep(0.1);
|
|
|
256 |
textEZSteps->setValue(2);
|
| 363 |
Kevin |
257 |
|
|
|
258 |
QGridLayout *extruderLayout = new QGridLayout();
|
| 364 |
Kevin |
259 |
extruderLayout->addWidget(labelEForwardSteps, 0, 0);
|
|
|
260 |
extruderLayout->addWidget(sliderEForwardSteps, 0, 1);
|
|
|
261 |
extruderLayout->addWidget(textEForwardSteps, 0, 2);
|
| 363 |
Kevin |
262 |
extruderLayout->addWidget(labelEForwardSpeed, 1, 0);
|
|
|
263 |
extruderLayout->addWidget(sliderEForwardSpeed, 1, 1);
|
|
|
264 |
extruderLayout->addWidget(textEForwardSpeed, 1, 2);
|
| 364 |
Kevin |
265 |
extruderLayout->addWidget(labelEBackwardSteps, 2, 0);
|
|
|
266 |
extruderLayout->addWidget(sliderEBackwardSteps, 2, 1);
|
|
|
267 |
extruderLayout->addWidget(textEBackwardSteps, 2, 2);
|
| 363 |
Kevin |
268 |
extruderLayout->addWidget(labelEBackwardSpeed, 4, 0);
|
|
|
269 |
extruderLayout->addWidget(sliderEBackwardSpeed, 4, 1);
|
|
|
270 |
extruderLayout->addWidget(textEBackwardSpeed, 4, 2);
|
| 364 |
Kevin |
271 |
extruderLayout->addWidget(labelEZSteps, 5, 0);
|
|
|
272 |
extruderLayout->addWidget(sliderEZSteps, 5, 1);
|
|
|
273 |
extruderLayout->addWidget(textEZSteps, 5, 2);
|
| 363 |
Kevin |
274 |
|
|
|
275 |
QGroupBox *extruderBox = new QGroupBox("Extruder Settings");
|
|
|
276 |
extruderBox->setLayout(extruderLayout);
|
|
|
277 |
|
|
|
278 |
QVBoxLayout *column1Layout = new QVBoxLayout();
|
|
|
279 |
column1Layout->addWidget(controlBox, 0, Qt::AlignTop);
|
|
|
280 |
column1Layout->addWidget(miscBtnBox, 0, Qt::AlignTop);
|
|
|
281 |
column1Layout->addWidget(helpBox, 1, Qt::AlignTop);
|
|
|
282 |
|
|
|
283 |
QVBoxLayout *column2Layout = new QVBoxLayout();
|
|
|
284 |
column2Layout->addWidget(toolheadPosBox);
|
|
|
285 |
column2Layout->addWidget(xyRepeatBox);
|
|
|
286 |
column2Layout->addWidget(extruderBox);
|
|
|
287 |
|
|
|
288 |
QHBoxLayout *mainLayout = new QHBoxLayout();
|
|
|
289 |
mainLayout->addLayout(column1Layout);
|
|
|
290 |
mainLayout->addLayout(column2Layout);
|
|
|
291 |
|
|
|
292 |
setLayout(mainLayout);
|
|
|
293 |
setFixedSize(sizeHint());
|
| 364 |
Kevin |
294 |
|
| 363 |
Kevin |
295 |
}
|
|
|
296 |
|
|
|
297 |
PasteController::~PasteController()
|
|
|
298 |
{
|
|
|
299 |
|
|
|
300 |
}
|
|
|
301 |
|
| 364 |
Kevin |
302 |
void PasteController::EnableTransmit(bool en) {
|
|
|
303 |
connected = en;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
void PasteController::ToggleHotkeys() {
|
|
|
307 |
if (hotkeysEnabled) {
|
|
|
308 |
qApp->removeEventFilter(this);
|
|
|
309 |
btnEnableHotkeys->setText("&Enable Hotkeys");
|
|
|
310 |
} else {
|
|
|
311 |
qApp->installEventFilter(this);
|
|
|
312 |
btnEnableHotkeys->setText("&Disable Hotkeys");
|
|
|
313 |
}
|
|
|
314 |
hotkeysEnabled = !hotkeysEnabled;
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
void PasteController::UpdatePosition() {
|
|
|
318 |
if (X_Incr && !X_Decr) xPos += textXYSteps->value();
|
|
|
319 |
if (!X_Incr && X_Decr) xPos -= textXYSteps->value();
|
|
|
320 |
if (Y_Incr && !Y_Decr) yPos += textXYSteps->value();
|
|
|
321 |
if (!Y_Incr && Y_Decr) yPos -= textXYSteps->value();
|
|
|
322 |
if (Z_Incr && !Z_Decr) zPos += textZSteps->value();
|
|
|
323 |
if (!Z_Incr && Z_Decr) zPos -= textZSteps->value();
|
|
|
324 |
|
|
|
325 |
textXValue->setText(QString::number(xPos, 'f', 2));
|
|
|
326 |
textYValue->setText(QString::number(yPos, 'f', 2));
|
|
|
327 |
textZValue->setText(QString::number(zPos, 'f', 2));
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
void PasteController::UpdatePositionSingle() {
|
|
|
331 |
if (QObject::sender() == btnRight) xPos += textXYSteps->value();
|
|
|
332 |
if (QObject::sender() == btnLeft) xPos -= textXYSteps->value();
|
|
|
333 |
if (QObject::sender() == btnForward) yPos += textXYSteps->value();
|
|
|
334 |
if (QObject::sender() == btnBackward) yPos -= textXYSteps->value();
|
|
|
335 |
if (QObject::sender() == btnUp) zPos += textZSteps->value();
|
|
|
336 |
if (QObject::sender() == btnDown) zPos -= textZSteps->value();
|
|
|
337 |
|
|
|
338 |
textXValue->setText(QString::number(xPos, 'f', 2));
|
|
|
339 |
textYValue->setText(QString::number(yPos, 'f', 2));
|
|
|
340 |
textZValue->setText(QString::number(zPos, 'f', 2));
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
void PasteController::UpdateTimer(int delay) {
|
|
|
344 |
tmrUpdate->setInterval(delay);
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
void PasteController::QSliderToQDoubleSpinBox(int) {
|
|
|
348 |
textXYSteps->setValue((double)sliderXYSteps->value()/100);
|
|
|
349 |
textZSteps->setValue((double)sliderZSteps->value()/100);
|
|
|
350 |
textEZSteps->setValue((double)sliderEZSteps->value()/100);
|
|
|
351 |
}
|
|
|
352 |
|
|
|
353 |
void PasteController::QDoubleSpinBoxToQSlider(double) {
|
|
|
354 |
sliderXYSteps->setValue(textXYSteps->value()*100);
|
|
|
355 |
sliderZSteps->setValue(textZSteps->value()*100);
|
|
|
356 |
sliderEZSteps->setValue(textEZSteps->value()*100);
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
void PasteController::ResetPosition() {
|
|
|
360 |
xPos = yPos = zPos = 0;
|
|
|
361 |
UpdatePosition();
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
bool PasteController::eventFilter(QObject *obj, QEvent *event)
|
|
|
365 |
{
|
|
|
366 |
// Only process keyboard press and release events
|
|
|
367 |
if (event->type() == QEvent::KeyPress) {
|
|
|
368 |
QKeyEvent *keyevent = static_cast<QKeyEvent*>(event);
|
|
|
369 |
// QKeySequence seq = keyevent->modifiers() + keyevent->key();
|
|
|
370 |
|
|
|
371 |
if (hotkeysEnabled) {
|
|
|
372 |
if (keyevent->isAutoRepeat()) return true;
|
|
|
373 |
bool keychange = false;
|
|
|
374 |
if (keyevent->key() == Qt::Key_Left || keyevent->key() == Qt::Key_H) {
|
|
|
375 |
btnLeft->setDown(true);
|
|
|
376 |
X_Decr = keychange = true;
|
|
|
377 |
}
|
|
|
378 |
if (keyevent->key() == Qt::Key_Right || keyevent->key() == Qt::Key_L) {
|
|
|
379 |
btnRight->setDown(true);
|
|
|
380 |
X_Incr = keychange = true;
|
|
|
381 |
}
|
|
|
382 |
if (keyevent->key() == Qt::Key_Up || keyevent->key() == Qt::Key_K) {
|
|
|
383 |
btnForward->setDown(true);
|
|
|
384 |
Y_Incr = keychange = true;
|
|
|
385 |
}
|
|
|
386 |
if (keyevent->key() == Qt::Key_Down || keyevent->key() == Qt::Key_J) {
|
|
|
387 |
btnBackward->setDown(true);
|
|
|
388 |
Y_Decr = keychange = true;
|
|
|
389 |
}
|
|
|
390 |
if (keyevent->key() == Qt::Key_PageDown) {
|
|
|
391 |
btnDown->setDown(true);
|
|
|
392 |
Z_Decr = keychange = true;
|
|
|
393 |
}
|
|
|
394 |
if (keyevent->key() == Qt::Key_PageUp) {
|
|
|
395 |
btnUp->setDown(true);
|
|
|
396 |
Z_Incr = keychange = true;
|
|
|
397 |
}
|
|
|
398 |
if (keyevent->key() == Qt::Key_Space) {
|
|
|
399 |
btnExtrude->setDown(true);
|
|
|
400 |
E_Incr = keychange = true;
|
|
|
401 |
}
|
|
|
402 |
if (X_Incr || X_Decr || Y_Incr || Y_Decr || Z_Incr || Z_Decr || E_Incr) {
|
|
|
403 |
UpdatePosition();
|
|
|
404 |
tmrUpdate->start();
|
|
|
405 |
}
|
|
|
406 |
if (keychange) return true;
|
|
|
407 |
}
|
|
|
408 |
} else if (event->type() == QEvent::KeyRelease) {
|
|
|
409 |
QKeyEvent *keyevent = static_cast<QKeyEvent*>(event);
|
|
|
410 |
// QKeySequence seq = keyevent->modifiers() + keyevent->key();
|
|
|
411 |
|
|
|
412 |
if (hotkeysEnabled) {
|
|
|
413 |
if (keyevent->isAutoRepeat()) return true;
|
|
|
414 |
bool keychange = false;
|
|
|
415 |
if (keyevent->key() == Qt::Key_Left || keyevent->key() == Qt::Key_H) {
|
|
|
416 |
btnLeft->setDown(false);
|
|
|
417 |
X_Decr = keychange = false;
|
|
|
418 |
}
|
|
|
419 |
if (keyevent->key() == Qt::Key_Right || keyevent->key() == Qt::Key_L) {
|
|
|
420 |
btnRight->setDown(false);
|
|
|
421 |
X_Incr = keychange = false;
|
|
|
422 |
}
|
|
|
423 |
if (keyevent->key() == Qt::Key_Up || keyevent->key() == Qt::Key_K) {
|
|
|
424 |
btnForward->setDown(false);
|
|
|
425 |
Y_Incr = keychange = false;
|
|
|
426 |
}
|
|
|
427 |
if (keyevent->key() == Qt::Key_Down || keyevent->key() == Qt::Key_J) {
|
|
|
428 |
btnBackward->setDown(false);
|
|
|
429 |
Y_Decr = keychange = false;
|
|
|
430 |
}
|
|
|
431 |
if (keyevent->key() == Qt::Key_PageDown) {
|
|
|
432 |
btnDown->setDown(false);
|
|
|
433 |
Z_Decr = keychange = false;
|
|
|
434 |
}
|
|
|
435 |
if (keyevent->key() == Qt::Key_PageUp) {
|
|
|
436 |
btnUp->setDown(false);
|
|
|
437 |
Z_Incr = keychange = false;
|
|
|
438 |
}
|
|
|
439 |
if (keyevent->key() == Qt::Key_Space) {
|
|
|
440 |
btnExtrude->setDown(false);
|
|
|
441 |
E_Incr = keychange = false;
|
|
|
442 |
}
|
|
|
443 |
if (!X_Incr && !X_Decr && !Y_Incr && !Y_Decr && !Z_Incr && !Z_Decr && !E_Incr) {
|
|
|
444 |
tmrUpdate->stop();
|
|
|
445 |
}
|
|
|
446 |
if (keychange) return true;
|
|
|
447 |
}
|
|
|
448 |
}
|
|
|
449 |
|
|
|
450 |
return QWidget::eventFilter(obj, event);
|
|
|
451 |
}
|