-
Notifications
You must be signed in to change notification settings - Fork 5
/
ShapesWidget.cpp
87 lines (76 loc) · 1.71 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
86
87
/**
* @file
*/
#include <iostream>
#include <QtWidgets/QtWidgets>
#include "ShapesWidget.hpp"
#include "config.hpp"
#ifdef Ospl
#define LOGO ":/images/ospl-dds-br.png"
#elif Cyclone
#define LOGO ":/images/cyclone-dds-br.png"
#endif
namespace demo { namespace ishapes {
ShapesWidget::ShapesWidget(QWidget *parent)
: QWidget(parent),
showCurrentFilter_(false),
logo_(LOGO),
paused_(false)
{
this->setBackgroundRole(QPalette::Base);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
ShapesWidget::~ShapesWidget()
{
}
void
ShapesWidget::addShape(Shape::ref_type shape)
{
shapeList_.push_back(shape);
}
void
ShapesWidget::nextAnimationFrame()
{
if(!this->paused())
{
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(ISOCPP_LOGO_X, ISOCPP_LOGO_Y, 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;
}
painter.end();
}
void
ShapesWidget::addFilter(const QRect& filter)
{
filterList_.push_back(filter);
}
void ShapesWidget::displayFilter(const QRect& currentFilter)
{
currentFilter_ = currentFilter;
showCurrentFilter_ = true;
this->update();
}
}}