1 #include <QBrush>
2
3 #include "cvvpointmatch.hpp"
4
5 namespace cvv
6 {
7 namespace qtutil
8 {
9
CVVPointMatch(CVVKeyPoint * left_key,CVVKeyPoint * right_key,const cv::DMatch & match,bool isLeftKey,qreal radius,const QPen & pen,const QBrush & brush,QGraphicsItem * parent)10 CVVPointMatch::CVVPointMatch(CVVKeyPoint *left_key, CVVKeyPoint *right_key,
11 const cv::DMatch &match, bool isLeftKey,
12 qreal radius, const QPen &pen, const QBrush &brush,
13 QGraphicsItem *parent)
14 : CVVMatch{ left_key, right_key, match, pen, parent },
15 isLeftKey_{ isLeftKey },
16 radius_{ std::min(radius * match.distance, 10.0) }, brush_{ brush }
17 {
18 if (isLeftKey_)
19 {
20 right_key_visible_ = true;
21 setVisible(left_key_visible_);
22 }
23 else
24 {
25 left_key_visible_ = true;
26 setVisible(right_key_visible_);
27 }
28 }
29
boundingRect() const30 QRectF CVVPointMatch::boundingRect() const
31 {
32 QPointF point =
33 (isLeftKey_ ? leftImPointInScene() : rightImPointInScene());
34 return QRectF{ QPointF{ point.x() - radius_, point.y() - radius_ },
35 QPointF{ point.x() + radius_, point.y() + radius_ } };
36 }
37
paint(QPainter * painter,const QStyleOptionGraphicsItem *,QWidget *)38 void CVVPointMatch::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
39 QWidget *)
40 {
41 painter->setPen(pen_);
42 painter->setBrush(brush_);
43 painter->drawEllipse(boundingRect());
44 }
45
updateRightKey(bool visible)46 void CVVPointMatch::updateRightKey(bool visible)
47 {
48 if (!isLeftKey_)
49 {
50 CVVMatch::updateRightKey(visible);
51 }
52 }
53
updateLeftKey(bool visible)54 void CVVPointMatch::updateLeftKey(bool visible)
55 {
56 if (isLeftKey_)
57 {
58 CVVMatch::updateLeftKey(visible);
59 }
60 }
61 }
62 }
63