-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalState.h
More file actions
102 lines (87 loc) · 2.66 KB
/
Copy pathGlobalState.h
File metadata and controls
102 lines (87 loc) · 2.66 KB
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
#pragma once
#ifndef GLOBALSTATE_H
#define GLOBALSTATE_H
#define SCREEN_COUNT 2
#define BASELINE_COUNT 2
#define SPINE_COUNT 5
#define POINT_COUNT_FOR_ONE_SPINE 4
#define SPINOUS_PROCESS_POINT_COUNT 5
#define CLICK_CORRECTION_WIDTH 20
#define CLICK_RANGE_WIDTH 50
#define POINT_RADIUS 50
#define DEFAULT_BASELINE_AP_X 1920
#define DEFAULT_BASELINE_AP_Y 2800
#define DEFAULT_BASELINE_LAT_Y 2876
#define DEFAULT_BASELINE_LAT_Z 1513
#define IMAGE_HEIGHT 4480
#define PELVIS_POINT_COUNT 2
#define TAILBONE_POINT_COUNT 3
#include <qbrush.h>
#include <qgraphicsitem.h>
#include <qpen.h>
#include <qpoint>
#include <stack>
#include "BaseLineStatus.h"
typedef struct {
QGraphicsEllipseItem* item;
QPointF position;
} point;
typedef enum Screen { AP, LAT } SCR;
class GlobalState {
public:
GlobalState* instance;
BaseLineStatus baseLineStatus[SCREEN_COUNT];
QGraphicsLineItem* baseLine[SCREEN_COUNT][BASELINE_COUNT];
point spinePoint[SCREEN_COUNT][SPINE_COUNT][POINT_COUNT_FOR_ONE_SPINE];
QGraphicsLineItem* spineLine[SCREEN_COUNT][SPINE_COUNT]
[POINT_COUNT_FOR_ONE_SPINE];
QPointF spineCenter[SCREEN_COUNT][SPINE_COUNT];
int currentSpine[SCREEN_COUNT];
int currentSpinePoint[SCREEN_COUNT];
std::stack<std::pair<int, int>> removedSpinePoint[SCREEN_COUNT];
point spinousProcessPoint[SCREEN_COUNT][SPINOUS_PROCESS_POINT_COUNT];
int currentSpinousProcessPoint[SCREEN_COUNT];
std::stack<int> removedSpinousProcessPoint[SCREEN_COUNT];
// ViewAP data
point pelvisPoint[PELVIS_POINT_COUNT];
QGraphicsItem* pelvisLine;
QPointF pelvisCenter;
int currentPelvisPoint;
std::stack<int> removedPelvisPoint;
// ViewLAT data
point tailbonePoint[TAILBONE_POINT_COUNT];
QGraphicsItem* tailboneLine[TAILBONE_POINT_COUNT];
int currentTailbonePoint;
std::stack<int> removedTailbonePoint;
QPen* pen[SCREEN_COUNT];
QBrush* brush[SCREEN_COUNT];
public:
static GlobalState& getIncetance() {
static GlobalState gs;
return gs;
}
static void initPoint(point* p) {
p->position = {-FLT_MAX, -FLT_MAX};
p->item = nullptr;
}
static bool isDataValid(const point& p) {
return isDataValid(p.item) && isDataValid(p.position);
};
static bool isDataValid(const QPointF& f) {
return f.x() != -FLT_MAX && f.y() != -FLT_MAX;
};
static bool isDataValid(const QGraphicsItem* i) { return i != nullptr; };
bool isAllDataSet();
private:
void initState();
GlobalState() { initState(); }
GlobalState(const GlobalState& ref) { initState(); }
GlobalState& operator=(const GlobalState& ref) {}
~GlobalState() {
for (int scr = 0; scr < SCREEN_COUNT; ++scr) {
delete pen[scr];
delete brush[scr];
}
}
};
#endif