-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectorWindow.hpp
221 lines (195 loc) · 6.75 KB
/
ProjectorWindow.hpp
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
/*
* LiveFit
* Copyright (C) 2016 The University of Georgia
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PROJECTORWINDOW_HPP
#define PROJECTORWINDOW_HPP
#include "KFPrediction.hpp"
#include "TrackingBall.hpp"
#include <QOpenGLWidget>
#include <QWidget>
/**
* @brief A display widget for projector coordinates on the projector.
*
* The idea is that this displays full screen behind the demonstration
* and shows the ball "where it is"
*/
class ProjectorWindow : public QOpenGLWidget
{
Q_OBJECT
/** The size of the projector (in inches) */
QSize mProjSize;
/** A list of raw spotted balls in the projector */
QList<TrackingBall> mBalls;
/** A list of predictions of ball location in the projector */
QList<KFPrediction> mPreds;
/** A [sub]list of predictions which are used for the fit curve */
QList<KFPrediction> mFitPreds;
/** @brief linear coefficients of x(t) equation, (b,m) */
double mFitLineX[2];
/** @brief quadratic coefficients of y(t) equation, (C,B,A) */
double mFitParabolaY[3];
/** @brief list of points marked and selected to be solved for x(t), y(t) */
QList<KFPrediction> mMarkedPoints;
/** @brief whether data should be cleared on next track */
bool mDataStale = false;
/** Whether to lock the fit curve and track until manual clear */
bool mLockFit = false;
/** Number of tracked points to wait for until the curve is fit */
int mNumPointFit;
/** Whether the fit is 'locked' for the time being, until reset either
* manually or after sufficient time and another track */
bool mFitLocked = false;
/** Whether we should wait until the ball is falling to lock/fit a curve */
bool mWaitTilFall = false;
/** Minimum fall speed to determine that the ball is "falling" */
int mMinFallSpeed;
/** Whether we fit a degree-d curve exactly to (d+1) points, or use a
* regression */
bool mFitPoints = true;
/** Whether we show the fit or not */
bool mShowFit = false;
/** Whether we show the parametrized equation for the fit or not */
bool mShowParam = false;
/** Whether we show (dx,dy) vectors on the display */
bool mShowJet = false;
/** Whether we should color differently the predictions for unseen balls */
bool mColorMiss = false;
/** Whether we should include width, height, etc from KF prediction data in
* display */
bool mVerboseKF = false;
/** Whether we should show the fit parabola curve */
bool mShowParabola = true;
int mFontSize = 12; /**< @brief Data display font size in pt */
/** @brief The color of the fit curve projection, pre-lock */
QColor mColorFitNoLock;
/** @brief The color of the fit curve projection, after lock */
QColor mColorFitLock;
int mPointRadius; /**< @brief Radius of circles denoting tracked ball */
double mPointThickness; /**< @brief Thickness of circle lines for balls */
double mFitThickness; /**< @brief Thickness of the track fit parabola */
public:
explicit ProjectorWindow(QWidget* parent = 0);
/** @brief convert a relative rect in projector to window coords */
QRectF relRectToWindow(QRectF rect);
/** @brief convert a relative point in the projector to window coords */
QPointF relPointToWindow(QPointF pt);
public slots:
/** @brief push a raw tracked ball to projector */
void pushBall(TrackingBall ball);
/** @brief push a predicted ball (ie a KF prediction) to projector */
void pushPred(KFPrediction pred);
/** @brief mark data stale, ie ready to wipe on next track. */
void markDataStale() {
// Indicate that the data we have is stale, and to be dropped.
mDataStale = true;
}
/** @brief clear all data immediately */
void clearTrack();
/** @brief toggle whether to wait until manual clear for tracked ball */
void toggleLockFit(bool lockFit)
{
mLockFit = lockFit;
}
/** @brief toggle whether to show fit information for tracked ball */
void toggleShowFit(bool showFit)
{
mShowFit = showFit;
update();
}
/** @brief toggle whether to show parametrized equations y(t), x(t) */
void toggleShowParam(bool showParam)
{
mShowParam = showParam;
update();
}
/** @brief toggle whether to show jet ((dx,dy)) of tracked ball */
void toggleShowJet(bool showJet)
{
mShowJet = showJet;
update();
}
/** @brief toggle color difference between seen/unseen KF hits */
void toggleColorMiss(bool colorMiss)
{
mColorMiss = colorMiss;
update();
}
/** @brief toggle verbose display [size, etc] of track/predict info */
void toggleVerboseKF(bool verboseKF)
{
mVerboseKF = verboseKF;
update();
}
/** @brief set whether we should show the fit parabola */
void toggleShowParabola(bool showParabola)
{
mShowParabola = showParabola;
update();
}
/** @brief set radius of ball track circles */
void setPointRadius(int pointRadius)
{
mPointRadius = pointRadius;
update();
}
/** @brief set thickness of ball track marks */
void setPointThickness(double pointThickness)
{
mPointThickness = pointThickness;
update();
}
/** @brief set thickness of fit parabola */
void setFitThickness(double fitThickness)
{
mFitThickness = fitThickness;
update();
}
/** @brief set font size for data display */
void setFontSize(int fontSize)
{
mFontSize = fontSize;
update();
}
/** @brief Set the after-lock fit curve color */
void setColorFitLock(QString color) {
mColorFitLock = QColor(color);
}
/** @brief set minimum y-velocity for lock */
void setMinFallSpeed(int minFallSpeed)
{
mMinFallSpeed = minFallSpeed;
}
/** @brief set whether we should wait until given y-velocity to lock */
void toggleWaitTilFall(bool waitTilFall)
{
mWaitTilFall = waitTilFall;
}
/** @brief set the projector width (in inches) */
void setProjW(int w) { mProjSize.setWidth(w); }
/** @brief set the projector height (in inches) */
void setProjH(int h) { mProjSize.setHeight(h); }
protected:
/**
* @brief Draw the data on the projector screen widget
*
* All drawing logic for the widget goes in here!
* @param ev The QPaintEvent for this paint
*/
void paintEvent(QPaintEvent* ev);
};
#endif // PROJECTORWINDOW_HPP