-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTrackedElementView.cpp
More file actions
72 lines (57 loc) · 1.94 KB
/
Copy pathTrackedElementView.cpp
File metadata and controls
72 lines (57 loc) · 1.94 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
#include "TrackedElementView.h"
#include "Model/TrackedComponents/TrackedElement.h"
#include "Model/TrackedComponents/TrackingRectElement.h"
#include "Model/TrackedComponents/TrackedTrajectory.h"
#include "QBrush"
#include "QPainter"
#include <QGraphicsSceneHoverEvent>
#include "settings/Settings.h"
#include "Model/TrackingAlgorithm/property/ParamNames.h"
#include "util/misc.h"
class QGraphicsSceneHoverEvent;
TrackedElementView::TrackedElementView(QGraphicsItem *parent, IController *controller, IModel *model) :
IViewTrackedComponent(parent, controller, model)
{
TrackedElement *elem = dynamic_cast<TrackedElement *>(getModel());
m_boundingRect = QRectF(0,0, 100, 100);
}
void TrackedElementView::rcvDimensionUpdate(int x, int y) {
m_boundingRect = QRectF(0, 0, x, y);
update();
}
QRectF TrackedElementView::boundingRect() const
{
return m_boundingRect;
}
void TrackedElementView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
TrackedTrajectory *all = dynamic_cast<TrackedTrajectory *>(getModel());
if (!all)
return;
for (int i = 0; i < all->size(); i++) {
TrackedTrajectory *t = dynamic_cast<TrackedTrajectory *>(all->getChild(i));
if (t) {
TrackedElement *elem = (TrackedElement *)t->getLastChild();
int x = elem->getFishPose().position_px().x;
int y = elem->getFishPose().position_px().y;
int w = 40;
int h = 40;
QRectF rec = QRectF(x, y, 20, 20);
QBrush brush(Qt::green);
painter->setBrush(brush);
painter->drawEllipse(x - w / 2, y - h / 2, w, h);
painter->setPen(QPen(Qt::yellow, 5));
QLineF angleline;
angleline.setP1(QPointF(x, y));
angleline.setAngle(elem->getFishPose().orientation_deg());
angleline.setLength(80);
painter->drawLine(angleline);
}
}
QBrush brush(Qt::blue);
painter->setPen(QPen(Qt::blue, 3));
}
void TrackedElementView::getNotified()
{
update();
}