-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteract.h
77 lines (68 loc) · 2.39 KB
/
interact.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
#ifndef INTERACT_H
#define INTERACT_H
#include "datatypes.h"
#include <QGraphicsView>
class ColourMap;
/** ****************************************************************************
* @brief The Interact class
*/
class Interact : public QObject {
Q_OBJECT
public:
enum Type : int {
null,
arrangement, // Length/radius + rotation
arrangement2,// Count (+ span for arc)
location, // Group center
wavelength, // + linearity
colours,
mask,
// Four bar linkage
lengths,
angleInc,
position,
drawRange,
angleInit, // Unused
};
static constexpr Type defaultTypeWaves = Type::arrangement;
static constexpr Type defaultTypeFourBar = Type::lengths;
private:
MainWindow& mainWindow;
ImageGen & imgGen;
ColourMap & colourMap;
Type active = Type::null; // Saves the active interact type upon mouse press.
Type typeSelected = defaultTypeWaves;
QPointF pressPos; // Where the interaction started
bool ctrlPressed; // If the 'control' key was pressed at the start of the interaction
// For emitter arrangement changes:
EmArrangement grpBackup;
EmArrangement * grpActive;
qreal wavelengthBackup;
qreal distOffsetBackup;
// For mask changes
MaskCfg maskConfigBackup;
// For colour list changes
ColourList clrListBackup;
FourBarCfg fourBarBackup;
private:
void Cancel();
void SelectDefaultType();
public:
Interact(MainWindow& mainWindowIn, ImageGen& imgGenIn);
void mousePressEvent(QGraphicsSceneMouseEvent *event, PreviewScene * scene);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event, PreviewScene * scene);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event, PreviewScene * scene);
bool IsActive() {return active != Type::null;}
bool TypeIsSelected(Type type) {return typeSelected == type;}
Type GetTypeSelected() {return typeSelected;}
bool TypeIsActive(Type type) {return active == type;} // Active == currently pressed
void SelectType(Type type);
void DeselectType(Type type);
void SetTypeSelect(Type type, bool en) {if (en) SelectType(type);
else DeselectType(type);}
EmArrangement * GetActiveArrangement() { return grpActive; }
void KeyPressEvent(QKeyEvent * event);
signals:
void InteractTypeChanged(QVariant type);
};
#endif // INTERACT_H