| Line 1... |
Line 1... |
| 1 |
#include "PasteController.h"
|
1 |
#include "PasteController.h"
|
| 2 |
|
2 |
|
| 3 |
PasteController::PasteController(QWidget *parent) : QWidget(parent)
|
3 |
PasteController::PasteController(QWidget *parent) : QWidget(parent)
|
| 4 |
{
|
4 |
{
|
| - |
|
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 |
|
| 5 |
QString helpString = "";
|
13 |
QString helpString = "";
|
| 6 |
helpString.append("XY Control: Arrow Keys or H/J/K/L\n");
|
14 |
helpString.append("XY Control: Arrow Keys or H/J/K/L\n");
|
| 7 |
helpString.append("Z Control: PgUp/PgDown\n");
|
15 |
helpString.append("Z Control: PgUp/PgDown\n");
|
| 8 |
helpString.append("Extruder Control: Space");
|
16 |
helpString.append("Extruder Control: Space");
|
| 9 |
labelHelp = new QLabel(helpString);
|
17 |
labelHelp = new QLabel(helpString);
|
| Line 12... |
Line 20... |
| 12 |
helpLayout->addWidget(labelHelp);
|
20 |
helpLayout->addWidget(labelHelp);
|
| 13 |
|
21 |
|
| 14 |
QGroupBox *helpBox = new QGroupBox("Hotkeys:");
|
22 |
QGroupBox *helpBox = new QGroupBox("Hotkeys:");
|
| 15 |
helpBox->setLayout(helpLayout);
|
23 |
helpBox->setLayout(helpLayout);
|
| 16 |
|
24 |
|
| 17 |
btnEnableHotkeys = new QPushButton("Enable Hotkeys");
|
25 |
btnEnableHotkeys = new QPushButton("&Enable Hotkeys");
|
| - |
|
26 |
connect(btnEnableHotkeys, SIGNAL(clicked()), this, SLOT(ToggleHotkeys()));
|
| - |
|
27 |
|
| 18 |
btnInit = new QPushButton("Initialize Printer");
|
28 |
btnInit = new QPushButton("&Initialize Printer");
|
| - |
|
29 |
|
| 19 |
btnHome = new QPushButton("Home Printhead");
|
30 |
btnHome = new QPushButton("&Home Printhead");
|
| - |
|
31 |
connect(btnHome, SIGNAL(clicked()), this, SLOT(ResetPosition()));
|
| 20 |
|
32 |
|
| 21 |
QVBoxLayout *miscBtnLayout = new QVBoxLayout();
|
33 |
QVBoxLayout *miscBtnLayout = new QVBoxLayout();
|
| 22 |
miscBtnLayout->addWidget(btnEnableHotkeys);
|
34 |
miscBtnLayout->addWidget(btnEnableHotkeys);
|
| 23 |
miscBtnLayout->addWidget(btnInit);
|
35 |
miscBtnLayout->addWidget(btnInit);
|
| 24 |
miscBtnLayout->addWidget(btnHome);
|
36 |
miscBtnLayout->addWidget(btnHome);
|
| Line 38... |
Line 50... |
| 38 |
|
50 |
|
| 39 |
btnForward = new QToolButton();
|
51 |
btnForward = new QToolButton();
|
| 40 |
btnForward->setIcon(iconUp);
|
52 |
btnForward->setIcon(iconUp);
|
| 41 |
btnForward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
53 |
btnForward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 42 |
btnForward->setAutoRaise(true);
|
54 |
btnForward->setAutoRaise(true);
|
| - |
|
55 |
connect(btnForward, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 43 |
btnBackward = new QToolButton();
|
56 |
btnBackward = new QToolButton();
|
| 44 |
btnBackward->setIcon(iconDown);
|
57 |
btnBackward->setIcon(iconDown);
|
| 45 |
btnBackward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
58 |
btnBackward->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 46 |
btnBackward->setAutoRaise(true);
|
59 |
btnBackward->setAutoRaise(true);
|
| - |
|
60 |
connect(btnBackward, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 47 |
btnLeft = new QToolButton();
|
61 |
btnLeft = new QToolButton();
|
| 48 |
btnLeft->setIcon(iconLeft);
|
62 |
btnLeft->setIcon(iconLeft);
|
| 49 |
btnLeft->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
63 |
btnLeft->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 50 |
btnLeft->setAutoRaise(true);
|
64 |
btnLeft->setAutoRaise(true);
|
| - |
|
65 |
connect(btnLeft, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 51 |
btnRight = new QToolButton();
|
66 |
btnRight = new QToolButton();
|
| 52 |
btnRight->setIcon(iconRight);
|
67 |
btnRight->setIcon(iconRight);
|
| 53 |
btnRight->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
68 |
btnRight->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 54 |
btnRight->setAutoRaise(true);
|
69 |
btnRight->setAutoRaise(true);
|
| - |
|
70 |
connect(btnRight, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 55 |
btnUp = new QToolButton();
|
71 |
btnUp = new QToolButton();
|
| 56 |
btnUp->setIcon(iconAdd);
|
72 |
btnUp->setIcon(iconAdd);
|
| 57 |
btnUp->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
73 |
btnUp->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 58 |
btnUp->setAutoRaise(true);
|
74 |
btnUp->setAutoRaise(true);
|
| - |
|
75 |
connect(btnUp, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 59 |
btnDown = new QToolButton();
|
76 |
btnDown = new QToolButton();
|
| 60 |
btnDown->setIcon(iconRemove);
|
77 |
btnDown->setIcon(iconRemove);
|
| 61 |
btnDown->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
78 |
btnDown->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 62 |
btnDown->setAutoRaise(true);
|
79 |
btnDown->setAutoRaise(true);
|
| - |
|
80 |
connect(btnDown, SIGNAL(clicked()), this, SLOT(UpdatePositionSingle()));
|
| 63 |
btnExtrude = new QToolButton();
|
81 |
btnExtrude = new QToolButton();
|
| 64 |
btnExtrude->setIcon(iconDelete);
|
82 |
btnExtrude->setIcon(iconDelete);
|
| 65 |
btnExtrude->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
83 |
btnExtrude->setIconSize(QSize(BTN_ICON_SIZE,BTN_ICON_SIZE));
|
| 66 |
btnExtrude->setAutoRaise(true);
|
84 |
btnExtrude->setAutoRaise(true);
|
| 67 |
|
85 |
|
| Line 83... |
Line 101... |
| 83 |
QGroupBox *controlBox = new QGroupBox("Manual Printer Control");
|
101 |
QGroupBox *controlBox = new QGroupBox("Manual Printer Control");
|
| 84 |
controlBox->setLayout(btnNavLayout);
|
102 |
controlBox->setLayout(btnNavLayout);
|
| 85 |
controlBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
103 |
controlBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
| 86 |
|
104 |
|
| 87 |
labelXPos = new QLabel("X :");
|
105 |
labelXPos = new QLabel("X :");
|
| 88 |
labelXPos->setFont(QFont("", 14, 1));
|
106 |
labelXPos->setFont(QFont("", 14, QFont::Normal));
|
| 89 |
labelYPos = new QLabel("Y :");
|
107 |
labelYPos = new QLabel("Y :");
|
| 90 |
labelYPos->setFont(QFont("", 14, 1));
|
108 |
labelYPos->setFont(QFont("", 14, QFont::Normal));
|
| 91 |
labelZPos = new QLabel("Z :");
|
109 |
labelZPos = new QLabel("Z :");
|
| 92 |
labelZPos->setFont(QFont("", 14, 1));
|
110 |
labelZPos->setFont(QFont("", 14, QFont::Normal));
|
| 93 |
textXValue = new QLineEdit();
|
111 |
textXValue = new QLineEdit();
|
| 94 |
textXValue->setReadOnly(true);
|
112 |
textXValue->setReadOnly(true);
|
| 95 |
textXValue->setMaximumWidth(60);
|
113 |
textXValue->setMaximumWidth(60);
|
| - |
|
114 |
textXValue->setFont(QFont("", 10, QFont::Bold));
|
| - |
|
115 |
textXValue->setAlignment(Qt::AlignCenter);
|
| 96 |
textYValue = new QLineEdit();
|
116 |
textYValue = new QLineEdit();
|
| 97 |
textYValue->setReadOnly(true);
|
117 |
textYValue->setReadOnly(true);
|
| 98 |
textYValue->setMaximumWidth(60);
|
118 |
textYValue->setMaximumWidth(60);
|
| - |
|
119 |
textYValue->setFont(QFont("", 10, QFont::Bold));
|
| - |
|
120 |
textYValue->setAlignment(Qt::AlignCenter);
|
| 99 |
textZValue = new QLineEdit();
|
121 |
textZValue = new QLineEdit();
|
| 100 |
textZValue->setReadOnly(true);
|
122 |
textZValue->setReadOnly(true);
|
| 101 |
textZValue->setMaximumWidth(60);
|
123 |
textZValue->setMaximumWidth(60);
|
| - |
|
124 |
textZValue->setFont(QFont("", 10, QFont::Bold));
|
| - |
|
125 |
textZValue->setAlignment(Qt::AlignCenter);
|
| - |
|
126 |
UpdatePosition();
|
| 102 |
|
127 |
|
| 103 |
QHBoxLayout *posValueLayout = new QHBoxLayout();
|
128 |
QHBoxLayout *posValueLayout = new QHBoxLayout();
|
| 104 |
posValueLayout->addWidget(labelXPos);
|
129 |
posValueLayout->addWidget(labelXPos);
|
| 105 |
posValueLayout->addWidget(textXValue);
|
130 |
posValueLayout->addWidget(textXValue);
|
| 106 |
posValueLayout->addWidget(labelYPos);
|
131 |
posValueLayout->addWidget(labelYPos);
|
| Line 110... |
Line 135... |
| 110 |
|
135 |
|
| 111 |
QGroupBox *toolheadPosBox = new QGroupBox("Toolhead Position");
|
136 |
QGroupBox *toolheadPosBox = new QGroupBox("Toolhead Position");
|
| 112 |
toolheadPosBox->setLayout(posValueLayout);
|
137 |
toolheadPosBox->setLayout(posValueLayout);
|
| 113 |
toolheadPosBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
138 |
toolheadPosBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
| 114 |
|
139 |
|
| - |
|
140 |
labelXYSteps = new QLabel("XY Axis Step (mm):");
|
| - |
|
141 |
sliderXYSteps = new QSlider(Qt::Horizontal);
|
| - |
|
142 |
textXYSteps = new QDoubleSpinBox();
|
| - |
|
143 |
textXYSteps->setMinimumWidth(60);
|
| 115 |
labelXYSpeed = new QLabel("XY Axis Speed:");
|
144 |
labelXYSpeed = new QLabel("XY Axis Speed (mm/s):");
|
| 116 |
sliderXYSpeed = new QSlider(Qt::Horizontal);
|
145 |
sliderXYSpeed = new QSlider(Qt::Horizontal);
|
| 117 |
textXYSpeed = new QSpinBox();
|
146 |
textXYSpeed = new QSpinBox();
|
| 118 |
textXYSpeed->setMinimumWidth(60);
|
147 |
textXYSpeed->setMinimumWidth(60);
|
| 119 |
labelXYAmount = new QLabel("XY Axis Steps:");
|
148 |
labelZSteps = new QLabel("Z Axis Step (mm):");
|
| 120 |
sliderXYAmount = new QSlider(Qt::Horizontal);
|
149 |
sliderZSteps = new QSlider(Qt::Horizontal);
|
| 121 |
textXYAmount = new QSpinBox();
|
150 |
textZSteps = new QDoubleSpinBox();
|
| 122 |
textXYAmount->setMinimumWidth(60);
|
151 |
textZSteps->setMinimumWidth(60);
|
| 123 |
labelZSpeed = new QLabel("Z Axis Speed:");
|
152 |
labelZSpeed = new QLabel("Z Axis Speed (mm/s):");
|
| 124 |
sliderZSpeed = new QSlider(Qt::Horizontal);
|
153 |
sliderZSpeed = new QSlider(Qt::Horizontal);
|
| 125 |
textZSpeed = new QSpinBox();
|
154 |
textZSpeed = new QSpinBox();
|
| 126 |
textZSpeed->setMinimumWidth(60);
|
155 |
textZSpeed->setMinimumWidth(60);
|
| 127 |
labelZAmount = new QLabel("Z Axis Steps:");
|
- |
|
| 128 |
sliderZAmount = new QSlider(Qt::Horizontal);
|
- |
|
| 129 |
textZAmount = new QSpinBox();
|
- |
|
| 130 |
textZAmount->setMinimumWidth(60);
|
- |
|
| 131 |
labelRepeatDelay = new QLabel("Repeat Delay:");
|
156 |
labelRepeatDelay = new QLabel("Repeat Delay (ms):");
|
| 132 |
sliderRepeatDelay = new QSlider(Qt::Horizontal);
|
157 |
sliderRepeatDelay = new QSlider(Qt::Horizontal);
|
| 133 |
textRepeatDelay = new QSpinBox();
|
158 |
textRepeatDelay = new QSpinBox();
|
| 134 |
textRepeatDelay->setMinimumWidth(60);
|
159 |
textRepeatDelay->setMinimumWidth(60);
|
| 135 |
|
160 |
|
| - |
|
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 |
|
| 136 |
QGridLayout *xyRepeatLayout = new QGridLayout();
|
211 |
QGridLayout *xyRepeatLayout = new QGridLayout();
|
| 137 |
xyRepeatLayout->addWidget(labelXYAmount, 0, 0);
|
212 |
xyRepeatLayout->addWidget(labelXYSteps, 0, 0);
|
| 138 |
xyRepeatLayout->addWidget(sliderXYAmount, 0, 1);
|
213 |
xyRepeatLayout->addWidget(sliderXYSteps, 0, 1);
|
| 139 |
xyRepeatLayout->addWidget(textXYAmount, 0, 2);
|
214 |
xyRepeatLayout->addWidget(textXYSteps, 0, 2);
|
| 140 |
xyRepeatLayout->addWidget(labelXYSpeed, 1, 0);
|
215 |
xyRepeatLayout->addWidget(labelXYSpeed, 1, 0);
|
| 141 |
xyRepeatLayout->addWidget(sliderXYSpeed, 1, 1);
|
216 |
xyRepeatLayout->addWidget(sliderXYSpeed, 1, 1);
|
| 142 |
xyRepeatLayout->addWidget(textXYSpeed, 1, 2);
|
217 |
xyRepeatLayout->addWidget(textXYSpeed, 1, 2);
|
| 143 |
xyRepeatLayout->addWidget(labelZAmount, 2, 0);
|
218 |
xyRepeatLayout->addWidget(labelZSteps, 2, 0);
|
| 144 |
xyRepeatLayout->addWidget(sliderZAmount, 2, 1);
|
219 |
xyRepeatLayout->addWidget(sliderZSteps, 2, 1);
|
| 145 |
xyRepeatLayout->addWidget(textZAmount, 2, 2);
|
220 |
xyRepeatLayout->addWidget(textZSteps, 2, 2);
|
| 146 |
xyRepeatLayout->addWidget(labelZSpeed, 3, 0);
|
221 |
xyRepeatLayout->addWidget(labelZSpeed, 3, 0);
|
| 147 |
xyRepeatLayout->addWidget(sliderZSpeed, 3, 1);
|
222 |
xyRepeatLayout->addWidget(sliderZSpeed, 3, 1);
|
| 148 |
xyRepeatLayout->addWidget(textZSpeed, 3, 2);
|
223 |
xyRepeatLayout->addWidget(textZSpeed, 3, 2);
|
| 149 |
xyRepeatLayout->addWidget(labelRepeatDelay, 4, 0);
|
224 |
xyRepeatLayout->addWidget(labelRepeatDelay, 4, 0);
|
| 150 |
xyRepeatLayout->addWidget(sliderRepeatDelay, 4, 1);
|
225 |
xyRepeatLayout->addWidget(sliderRepeatDelay, 4, 1);
|
| 151 |
xyRepeatLayout->addWidget(textRepeatDelay, 4, 2);
|
226 |
xyRepeatLayout->addWidget(textRepeatDelay, 4, 2);
|
| 152 |
|
227 |
|
| 153 |
QGroupBox *xyRepeatBox = new QGroupBox("Movement Settings");
|
228 |
QGroupBox *xyRepeatBox = new QGroupBox("Movement Settings");
|
| 154 |
xyRepeatBox->setLayout(xyRepeatLayout);
|
229 |
xyRepeatBox->setLayout(xyRepeatLayout);
|
| 155 |
|
230 |
|
| 156 |
labelEForwardSpeed = new QLabel("Extrude Speed:");
|
231 |
connect(sliderEForwardSteps, SIGNAL(valueChanged(int)), textEForwardSteps, SLOT(setValue(int)));
|
| - |
|
232 |
connect(textEForwardSteps, SIGNAL(valueChanged(int)), sliderEForwardSteps, SLOT(setValue(int)));
|
| 157 |
sliderEForwardSpeed = new QSlider(Qt::Horizontal);
|
233 |
sliderEForwardSteps->setRange(1, 10000);
|
| 158 |
textEForwardSpeed = new QSpinBox();
|
234 |
textEForwardSteps->setRange(1, 10000);
|
| 159 |
textEForwardSpeed->setMinimumWidth(60);
|
235 |
textEForwardSteps->setValue(4000);
|
| 160 |
labelEBackwardSpeed = new QLabel("Retract Speed:");
|
236 |
connect(sliderEForwardSpeed, SIGNAL(valueChanged(int)), textEForwardSpeed, SLOT(setValue(int)));
|
| - |
|
237 |
connect(textEForwardSpeed, SIGNAL(valueChanged(int)), sliderEForwardSpeed, SLOT(setValue(int)));
|
| 161 |
sliderEBackwardSpeed = new QSlider(Qt::Horizontal);
|
238 |
sliderEForwardSpeed->setRange(1, 10000);
|
| 162 |
textEBackwardSpeed = new QSpinBox();
|
239 |
textEForwardSpeed->setRange(1, 10000);
|
| 163 |
textEBackwardSpeed->setMinimumWidth(60);
|
240 |
textEForwardSpeed->setValue(1000);
|
| 164 |
labelEForwardAmount = new QLabel("Extrude Steps:");
|
241 |
connect(sliderEBackwardSteps, SIGNAL(valueChanged(int)), textEBackwardSteps, SLOT(setValue(int)));
|
| - |
|
242 |
connect(textEBackwardSteps, SIGNAL(valueChanged(int)), sliderEBackwardSteps, SLOT(setValue(int)));
|
| 165 |
sliderEForwardAmount = new QSlider(Qt::Horizontal);
|
243 |
sliderEBackwardSteps->setRange(1, 10000);
|
| 166 |
textEForwardAmount = new QSpinBox();
|
244 |
textEBackwardSteps->setRange(1, 10000);
|
| 167 |
textEForwardAmount->setMinimumWidth(60);
|
245 |
textEBackwardSteps->setValue(2000);
|
| 168 |
labelEBackwardAmount = new QLabel("Retract Steps:");
|
246 |
connect(sliderEBackwardSpeed, SIGNAL(valueChanged(int)), textEBackwardSpeed, SLOT(setValue(int)));
|
| - |
|
247 |
connect(textEBackwardSpeed, SIGNAL(valueChanged(int)), sliderEBackwardSpeed, SLOT(setValue(int)));
|
| 169 |
sliderEBackwardAmount = new QSlider(Qt::Horizontal);
|
248 |
sliderEBackwardSpeed->setRange(1, 10000);
|
| 170 |
textEBackwardAmount = new QSpinBox();
|
249 |
textEBackwardSpeed->setRange(1, 10000);
|
| 171 |
textEBackwardAmount->setMinimumWidth(60);
|
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);
|
| 172 |
|
257 |
|
| 173 |
QGridLayout *extruderLayout = new QGridLayout();
|
258 |
QGridLayout *extruderLayout = new QGridLayout();
|
| 174 |
extruderLayout->addWidget(labelEForwardAmount, 0, 0);
|
259 |
extruderLayout->addWidget(labelEForwardSteps, 0, 0);
|
| 175 |
extruderLayout->addWidget(sliderEForwardAmount, 0, 1);
|
260 |
extruderLayout->addWidget(sliderEForwardSteps, 0, 1);
|
| 176 |
extruderLayout->addWidget(textEForwardAmount, 0, 2);
|
261 |
extruderLayout->addWidget(textEForwardSteps, 0, 2);
|
| 177 |
extruderLayout->addWidget(labelEForwardSpeed, 1, 0);
|
262 |
extruderLayout->addWidget(labelEForwardSpeed, 1, 0);
|
| 178 |
extruderLayout->addWidget(sliderEForwardSpeed, 1, 1);
|
263 |
extruderLayout->addWidget(sliderEForwardSpeed, 1, 1);
|
| 179 |
extruderLayout->addWidget(textEForwardSpeed, 1, 2);
|
264 |
extruderLayout->addWidget(textEForwardSpeed, 1, 2);
|
| 180 |
extruderLayout->addWidget(labelEBackwardAmount, 2, 0);
|
265 |
extruderLayout->addWidget(labelEBackwardSteps, 2, 0);
|
| 181 |
extruderLayout->addWidget(sliderEBackwardAmount, 2, 1);
|
266 |
extruderLayout->addWidget(sliderEBackwardSteps, 2, 1);
|
| 182 |
extruderLayout->addWidget(textEBackwardAmount, 2, 2);
|
267 |
extruderLayout->addWidget(textEBackwardSteps, 2, 2);
|
| 183 |
extruderLayout->addWidget(labelEBackwardSpeed, 4, 0);
|
268 |
extruderLayout->addWidget(labelEBackwardSpeed, 4, 0);
|
| 184 |
extruderLayout->addWidget(sliderEBackwardSpeed, 4, 1);
|
269 |
extruderLayout->addWidget(sliderEBackwardSpeed, 4, 1);
|
| 185 |
extruderLayout->addWidget(textEBackwardSpeed, 4, 2);
|
270 |
extruderLayout->addWidget(textEBackwardSpeed, 4, 2);
|
| - |
|
271 |
extruderLayout->addWidget(labelEZSteps, 5, 0);
|
| - |
|
272 |
extruderLayout->addWidget(sliderEZSteps, 5, 1);
|
| - |
|
273 |
extruderLayout->addWidget(textEZSteps, 5, 2);
|
| 186 |
|
274 |
|
| 187 |
QGroupBox *extruderBox = new QGroupBox("Extruder Settings");
|
275 |
QGroupBox *extruderBox = new QGroupBox("Extruder Settings");
|
| 188 |
extruderBox->setLayout(extruderLayout);
|
276 |
extruderBox->setLayout(extruderLayout);
|
| 189 |
|
277 |
|
| 190 |
QVBoxLayout *column1Layout = new QVBoxLayout();
|
278 |
QVBoxLayout *column1Layout = new QVBoxLayout();
|
| Line 201... |
Line 289... |
| 201 |
mainLayout->addLayout(column1Layout);
|
289 |
mainLayout->addLayout(column1Layout);
|
| 202 |
mainLayout->addLayout(column2Layout);
|
290 |
mainLayout->addLayout(column2Layout);
|
| 203 |
|
291 |
|
| 204 |
setLayout(mainLayout);
|
292 |
setLayout(mainLayout);
|
| 205 |
setFixedSize(sizeHint());
|
293 |
setFixedSize(sizeHint());
|
| - |
|
294 |
|
| 206 |
}
|
295 |
}
|
| 207 |
|
296 |
|
| 208 |
PasteController::~PasteController()
|
297 |
PasteController::~PasteController()
|
| 209 |
{
|
298 |
{
|
| 210 |
|
299 |
|
| 211 |
}
|
300 |
}
|
| 212 |
|
301 |
|
| - |
|
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 |
}
|