forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShapesWidget.cpp
85 lines (71 loc) · 1.85 KB
/
ShapesWidget.cpp
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
#include <iostream>
// Tell GCC to ignore implicitly declared copy methods as long as
// Qt is not compliant.
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-copy"
#endif
#include <QtGui/QtGui>
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#include <ShapesWidget.hpp>
#include "dds/DCPS/Service_Participant.h"
namespace {
const char* logoFile()
{
return
#ifdef OPENDDS_SECURITY
TheServiceParticipant->get_security() ? ":/images/logo_secure_beta.png" :
#endif
":/images/logo.png";
}
}
ShapesWidget::ShapesWidget(QWidget *parent)
: QWidget(parent),
showCurrentFilter_(false),
logo_(logoFile())
{
this->setBackgroundRole(QPalette::Base);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
ShapesWidget::~ShapesWidget() {
}
void
ShapesWidget::addShape(std::shared_ptr<Shape> shape) {
shapeList_.push_back(shape);
}
void
ShapesWidget::nextAnimationFrame() {
this->update();
ShapeList::iterator index = shapeList_.begin();
while (index != shapeList_.end()) {
(*index)->update();
++index;
}
}
void
ShapesWidget::paintEvent(QPaintEvent*) {
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawPixmap(0, height() - logo_.height(), logo_);
if (showCurrentFilter_) {
QBrush brush(QColor(0x99,0x99,0x99,0x99), Qt::SolidPattern);
painter.setBrush(brush);
painter.drawRect(currentFilter_);
}
ShapeList::iterator index = shapeList_.begin();
while (index != shapeList_.end()) {
(*index)->paint(painter);
++index;
}
}
void
ShapesWidget::addFilter(const QRect& filter) {
filterList_.push_back(filter);
}
void ShapesWidget::displayFilter(const QRect& currentFilter) {
currentFilter_ = currentFilter;
showCurrentFilter_ = true;
this->update();
}