LiveFit
Track and plot projectiles for in-class demonstration
ProjectorWindow.hpp
1 /*
2  * LiveFit
3  * Copyright (C) 2016 The University of Georgia
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef PROJECTORWINDOW_HPP
21 #define PROJECTORWINDOW_HPP
22 
23 #include "KFPrediction.hpp"
24 #include "TrackingBall.hpp"
25 
26 #include <QOpenGLWidget>
27 #include <QWidget>
28 
35 class ProjectorWindow : public QOpenGLWidget
36 {
37  Q_OBJECT
38 
40  QSize mProjSize;
41 
43  QList<TrackingBall> mBalls;
45  QList<KFPrediction> mPreds;
47  QList<KFPrediction> mFitPreds;
48 
50  double mFitLineX[2];
52  double mFitParabolaY[3];
53 
55  QList<KFPrediction> mMarkedPoints;
56 
58  bool mDataStale = false;
59 
61  bool mLockFit = false;
66  bool mFitLocked = false;
67 
69  bool mWaitTilFall = false;
72 
75  bool mFitPoints = true;
77  bool mShowFit = false;
79  bool mShowParam = false;
81  bool mShowJet = false;
83  bool mColorMiss = false;
86  bool mVerboseKF = false;
88  bool mShowParabola = true;
89 
90  int mFontSize = 12;
95  QColor mColorFitLock;
96 
98  double mPointThickness;
99  double mFitThickness;
100 public:
101  explicit ProjectorWindow(QWidget* parent = 0);
102 
104  QRectF relRectToWindow(QRectF rect);
106  QPointF relPointToWindow(QPointF pt);
107 
108 public slots:
110  void pushBall(TrackingBall ball);
112  void pushPred(KFPrediction pred);
113 
115  void markDataStale() {
116  // Indicate that the data we have is stale, and to be dropped.
117  mDataStale = true;
118  }
120  void clearTrack();
121 
123  void toggleLockFit(bool lockFit)
124  {
125  mLockFit = lockFit;
126  }
127 
129  void toggleShowFit(bool showFit)
130  {
131  mShowFit = showFit;
132  update();
133  }
135  void toggleShowParam(bool showParam)
136  {
137  mShowParam = showParam;
138  update();
139  }
141  void toggleShowJet(bool showJet)
142  {
143  mShowJet = showJet;
144  update();
145  }
147  void toggleColorMiss(bool colorMiss)
148  {
149  mColorMiss = colorMiss;
150  update();
151  }
153  void toggleVerboseKF(bool verboseKF)
154  {
155  mVerboseKF = verboseKF;
156  update();
157  }
158 
160  void toggleShowParabola(bool showParabola)
161  {
162  mShowParabola = showParabola;
163  update();
164  }
166  void setPointRadius(int pointRadius)
167  {
168  mPointRadius = pointRadius;
169  update();
170  }
172  void setPointThickness(double pointThickness)
173  {
174  mPointThickness = pointThickness;
175  update();
176  }
178  void setFitThickness(double fitThickness)
179  {
180  mFitThickness = fitThickness;
181  update();
182  }
184  void setFontSize(int fontSize)
185  {
186  mFontSize = fontSize;
187  update();
188  }
189 
191  void setColorFitLock(QString color) {
192  mColorFitLock = QColor(color);
193  }
194 
196  void setMinFallSpeed(int minFallSpeed)
197  {
198  mMinFallSpeed = minFallSpeed;
199  }
201  void toggleWaitTilFall(bool waitTilFall)
202  {
203  mWaitTilFall = waitTilFall;
204  }
205 
207  void setProjW(int w) { mProjSize.setWidth(w); }
209  void setProjH(int h) { mProjSize.setHeight(h); }
210 
211 protected:
218  void paintEvent(QPaintEvent* ev);
219 };
220 
221 #endif // PROJECTORWINDOW_HPP
double mFitThickness
Thickness of the track fit parabola.
Definition: ProjectorWindow.hpp:99
void toggleShowJet(bool showJet)
toggle whether to show jet ((dx,dy)) of tracked ball
Definition: ProjectorWindow.hpp:141
int mPointRadius
Radius of circles denoting tracked ball.
Definition: ProjectorWindow.hpp:97
void setProjW(int w)
set the projector width (in inches)
Definition: ProjectorWindow.hpp:207
bool mDataStale
whether data should be cleared on next track
Definition: ProjectorWindow.hpp:58
bool mShowParam
Whether we show the parametrized equation for the fit or not.
Definition: ProjectorWindow.hpp:79
A display widget for projector coordinates on the projector.
Definition: ProjectorWindow.hpp:35
void setPointThickness(double pointThickness)
set thickness of ball track marks
Definition: ProjectorWindow.hpp:172
QSize mProjSize
The size of the projector (in inches)
Definition: ProjectorWindow.hpp:40
bool mColorMiss
Whether we should color differently the predictions for unseen balls.
Definition: ProjectorWindow.hpp:83
QColor mColorFitLock
The color of the fit curve projection, after lock.
Definition: ProjectorWindow.hpp:95
void setFitThickness(double fitThickness)
set thickness of fit parabola
Definition: ProjectorWindow.hpp:178
void toggleColorMiss(bool colorMiss)
toggle color difference between seen/unseen KF hits
Definition: ProjectorWindow.hpp:147
bool mVerboseKF
Whether we should include width, height, etc from KF prediction data in display.
Definition: ProjectorWindow.hpp:86
QList< KFPrediction > mPreds
A list of predictions of ball location in the projector.
Definition: ProjectorWindow.hpp:45
void toggleShowFit(bool showFit)
toggle whether to show fit information for tracked ball
Definition: ProjectorWindow.hpp:129
void setProjH(int h)
set the projector height (in inches)
Definition: ProjectorWindow.hpp:209
void setColorFitLock(QString color)
Set the after-lock fit curve color.
Definition: ProjectorWindow.hpp:191
void setFontSize(int fontSize)
set font size for data display
Definition: ProjectorWindow.hpp:184
bool mShowFit
Whether we show the fit or not.
Definition: ProjectorWindow.hpp:77
int mNumPointFit
Number of tracked points to wait for until the curve is fit.
Definition: ProjectorWindow.hpp:63
void pushBall(TrackingBall ball)
push a raw tracked ball to projector
Definition: ProjectorWindow.cpp:55
void setPointRadius(int pointRadius)
set radius of ball track circles
Definition: ProjectorWindow.hpp:166
QPointF relPointToWindow(QPointF pt)
convert a relative point in the projector to window coords
Definition: ProjectorWindow.cpp:194
bool mWaitTilFall
Whether we should wait until the ball is falling to lock/fit a curve.
Definition: ProjectorWindow.hpp:69
void toggleLockFit(bool lockFit)
toggle whether to wait until manual clear for tracked ball
Definition: ProjectorWindow.hpp:123
void markDataStale()
mark data stale, ie ready to wipe on next track.
Definition: ProjectorWindow.hpp:115
int mFontSize
Data display font size in pt.
Definition: ProjectorWindow.hpp:90
void setMinFallSpeed(int minFallSpeed)
set minimum y-velocity for lock
Definition: ProjectorWindow.hpp:196
A ball which has been tracked by the software.
Definition: TrackingBall.hpp:30
QList< KFPrediction > mMarkedPoints
list of points marked and selected to be solved for x(t), y(t)
Definition: ProjectorWindow.hpp:55
QList< TrackingBall > mBalls
A list of raw spotted balls in the projector.
Definition: ProjectorWindow.hpp:43
void toggleVerboseKF(bool verboseKF)
toggle verbose display [size, etc] of track/predict info
Definition: ProjectorWindow.hpp:153
bool mShowJet
Whether we show (dx,dy) vectors on the display.
Definition: ProjectorWindow.hpp:81
QRectF relRectToWindow(QRectF rect)
convert a relative rect in projector to window coords
Definition: ProjectorWindow.cpp:186
Object which represents a prediction from the Kalman filter.
Definition: KFPrediction.hpp:34
bool mLockFit
Whether to lock the fit curve and track until manual clear.
Definition: ProjectorWindow.hpp:61
QList< KFPrediction > mFitPreds
A [sub]list of predictions which are used for the fit curve.
Definition: ProjectorWindow.hpp:47
QColor mColorFitNoLock
The color of the fit curve projection, pre-lock.
Definition: ProjectorWindow.hpp:93
void pushPred(KFPrediction pred)
push a predicted ball (ie a KF prediction) to projector
Definition: ProjectorWindow.cpp:112
void toggleWaitTilFall(bool waitTilFall)
set whether we should wait until given y-velocity to lock
Definition: ProjectorWindow.hpp:201
void clearTrack()
clear all data immediately
Definition: ProjectorWindow.cpp:175
bool mFitPoints
Whether we fit a degree-d curve exactly to (d+1) points, or use a regression.
Definition: ProjectorWindow.hpp:75
int mMinFallSpeed
Minimum fall speed to determine that the ball is "falling".
Definition: ProjectorWindow.hpp:71
bool mFitLocked
Whether the fit is &#39;locked&#39; for the time being, until reset either manually or after sufficient time ...
Definition: ProjectorWindow.hpp:66
void paintEvent(QPaintEvent *ev)
Draw the data on the projector screen widget.
Definition: ProjectorWindow.cpp:200
void toggleShowParabola(bool showParabola)
set whether we should show the fit parabola
Definition: ProjectorWindow.hpp:160
double mFitLineX[2]
linear coefficients of x(t) equation, (b,m)
Definition: ProjectorWindow.hpp:50
void toggleShowParam(bool showParam)
toggle whether to show parametrized equations y(t), x(t)
Definition: ProjectorWindow.hpp:135
double mPointThickness
Thickness of circle lines for balls.
Definition: ProjectorWindow.hpp:98
double mFitParabolaY[3]
quadratic coefficients of y(t) equation, (C,B,A)
Definition: ProjectorWindow.hpp:52
bool mShowParabola
Whether we should show the fit parabola curve.
Definition: ProjectorWindow.hpp:88