-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.h
377 lines (307 loc) · 10.2 KB
/
commands.h
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#ifndef COMMANDS_H
#define COMMANDS_H
#include <QUndoCommand>
#include <QPointF>
#include <QVector3D>
#include <QVector4D>
#include <QSlider>
#include <QSpinBox>
#include <QComboBox>
#include <QRadioButton>
#include <QPushButton>
#include <QCheckBox>
#include <QStackedWidget>
#include "displayinfo.h"
// Since AxialSliceWidget and MainWindow include this file in its header, it would be an infinite loop if this file included them in their header
// To get around this, the classes are simply declared here and the headers for these classes are included in the source file
class AxialSliceWidget;
class CoronalSliceWidget;
class MainWindow;
// These command IDs are used for merging commands. Only commands with the same ID will be merged.
enum class CommandID : int
{
AxialMove = 1,
AxialMoveEnd = 10,
CoronalMove = 11,
CoronalMoveEnd = 20,
AxialScale,
CoronalScale,
ResetView,
LocationChange,
BrightnessChange,
BrightnessThresChange,
ContrastChange,
PrimOpacityChange,
SecdOpacityChange
};
class AxialMoveCommand : public QUndoCommand
{
private:
QVector3D delta;
AxialSliceWidget *widget;
CommandID ID;
public:
AxialMoveCommand(QPointF delta, AxialSliceWidget *widget, CommandID ID, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)ID; }
};
class CoronalMoveCommand : public QUndoCommand
{
private:
QVector3D delta;
CoronalSliceWidget *widget;
CommandID ID;
public:
CoronalMoveCommand(QPointF delta, CoronalSliceWidget *widget, CommandID ID, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)ID; }
};
class AxialScaleCommand : public QUndoCommand
{
private:
float scaling;
AxialSliceWidget *widget;
public:
AxialScaleCommand(float scaling, AxialSliceWidget *widget, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::AxialScale; }
};
class CoronalScaleCommand : public QUndoCommand
{
private:
float scaling;
CoronalSliceWidget *widget;
public:
CoronalScaleCommand(float scaling, CoronalSliceWidget *widget, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::CoronalScale; }
};
class ResetViewCommand : public QUndoCommand
{
private:
QVector3D oldAxialTranslate;
float oldAxialScaling;
QVector3D oldCoronalTranslate;
float oldCoronalScaling;
AxialSliceWidget *axialWidget;
CoronalSliceWidget *coronalWidget;
public:
ResetViewCommand(AxialSliceWidget *axialWidget, CoronalSliceWidget *coronalWidget, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::ResetView; }
};
class LocationChangeCommand : public QUndoCommand
{
private:
QVector4D oldLocation;
QVector4D newLocation;
AxialSliceWidget *axialWidget;
CoronalSliceWidget *coronalWidget;
QSlider *axialSlider;
QSpinBox *axialSpinBox;
QSlider *coronalSlider;
QSpinBox *coronalSpinBox;
QSlider *saggitalSlider;
QSpinBox *saggitalSpinBox;
public:
LocationChangeCommand(QVector4D newLocation, AxialSliceWidget *axialWidget, CoronalSliceWidget *coronalWidget,
QSlider *axialSlider, QSpinBox *axialSpinBox, QSlider *coronalSlider, QSpinBox *coronalSpinBox,
QSlider *saggitalSlider, QSpinBox *saggitalSpinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::LocationChange; }
};
class BrightnessChangeCommand : public QUndoCommand
{
private:
float oldBrightness;
float newBrightness;
AxialSliceWidget *widget;
QSlider *slider;
QSpinBox *spinBox;
public:
BrightnessChangeCommand(float newBrightness, AxialSliceWidget *widget, QSlider *slider, QSpinBox *spinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::BrightnessChange; }
};
class BrightnessThresChangeCommand : public QUndoCommand
{
private:
float oldThreshold;
float newThreshold;
AxialSliceWidget *widget;
QSpinBox *spinBox;
public:
BrightnessThresChangeCommand(float newThreshold, AxialSliceWidget *widget, QSpinBox *spinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::BrightnessThresChange; }
};
class ContrastChangeCommand : public QUndoCommand
{
private:
float oldContrast;
float newContrast;
AxialSliceWidget *widget;
QSlider *slider;
QSpinBox *spinBox;
public:
ContrastChangeCommand(float newContrast, AxialSliceWidget *widget, QSlider *slider, QSpinBox *spinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::ContrastChange; }
};
class PrimColorMapChangeCommand : public QUndoCommand
{
private:
ColorMap oldColor;
ColorMap newColor;
AxialSliceWidget *widget;
QComboBox *comboBox;
public:
PrimColorMapChangeCommand(ColorMap newColor, AxialSliceWidget *widget, QComboBox *comboBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class SecdColorMapChangeCommand : public QUndoCommand
{
private:
ColorMap oldColor;
ColorMap newColor;
AxialSliceWidget *widget;
QComboBox *comboBox;
public:
SecdColorMapChangeCommand(ColorMap newColor, AxialSliceWidget *widget, QComboBox *comboBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class PrimOpacityChangeCommand : public QUndoCommand
{
private:
float oldOpacity;
float newOpacity;
AxialSliceWidget *widget;
QSlider *slider;
QSpinBox *spinBox;
public:
PrimOpacityChangeCommand(float newOpacity, AxialSliceWidget *widget, QSlider *slider, QSpinBox *spinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::PrimOpacityChange; }
};
class SecdOpacityChangeCommand : public QUndoCommand
{
private:
float oldOpacity;
float newOpacity;
AxialSliceWidget *widget;
QSlider *slider;
QSpinBox *spinBox;
public:
SecdOpacityChangeCommand(float newOpacity, AxialSliceWidget *widget, QSlider *slider, QSpinBox *spinBox, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return (int)CommandID::SecdOpacityChange; }
};
class SliceViewChangeCommand : public QUndoCommand
{
private:
SliceDisplayType oldDT;
SliceDisplayType newDT;
AxialSliceWidget *widget;
QRadioButton *oldBtn;
QRadioButton *newBtn;
public:
SliceViewChangeCommand(SliceDisplayType newDT, AxialSliceWidget *widget, QRadioButton *oldBtn, QRadioButton *newBtn, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class TracingLayerChangeCommand : public QUndoCommand
{
private:
TracingLayer oldTracingLayer;
TracingLayer newTracingLayer;
AxialSliceWidget *widget;
QRadioButton *oldBtn;
QRadioButton *newBtn;
public:
TracingLayerChangeCommand(TracingLayer newTracingLayer, AxialSliceWidget *widget, QRadioButton *oldBtn, QRadioButton *newBtn, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class TracingLayerVisibleChangeCommand : public QUndoCommand
{
private:
TracingLayer tracingLayer;
bool newValue;
AxialSliceWidget *widget;
QCheckBox *btn;
public:
TracingLayerVisibleChangeCommand(TracingLayer tracingLayer, bool newValue, AxialSliceWidget *widget, QCheckBox *btn, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class TracingCommand : public QUndoCommand
{
protected:
std::vector<QPoint> points;
public:
TracingCommand(QUndoCommand *parent = NULL) : QUndoCommand(parent) { }
void addPoint(QPoint newPoint) { points.push_back(newPoint); }
void addPoint(std::vector<QPoint> &newPoints) { points.insert(std::end(points), std::begin(newPoints), std::end(newPoints)); }
};
/* Note: This class will assume that the layer and axial slice that is being drawn on is the current layer and axial slice.
* This is a safe assumption so long as QUndoStack keeps track of all layer changes and axial slice changes. This will cause
* a new class to be made for each axial slice AND layer. Also, the user must release their mouse before they can change the
* slice or layer. (Which will cause the command to be done)
*/
class TracingPointsAddCommand : public TracingCommand
{
private:
AxialSliceWidget *widget;
public:
TracingPointsAddCommand(AxialSliceWidget *widget, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class TracingPointsEraseCommand : public TracingCommand
{
private:
AxialSliceWidget *widget;
public:
TracingPointsEraseCommand(AxialSliceWidget *widget, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
class DrawModeChangeCommand : public QUndoCommand
{
private:
DrawMode oldDrawMode;
DrawMode newDrawMode;
AxialSliceWidget *widget;
QStackedWidget *stackWidget;
QPushButton *oldBtn;
QPushButton *newBtn;
public:
DrawModeChangeCommand(DrawMode newDrawMode, AxialSliceWidget *widget, QStackedWidget *stackWidget, QPushButton *oldBtn, QPushButton *newBtn, QString str, QUndoCommand *parent = NULL);
void undo() override;
void redo() override;
};
#endif // COMMANDS_H