Wt examples: ShapesWidget Class Reference

Wt examples 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ShapesWidget Class Reference

`#include <ShapesWidget.h>`

Inheritance diagram for ShapesWidget:
[legend]

## Public Member Functions
| ShapesWidget ()
void | setAngle (double angle)
double | angle () const
void | setRelativeSize (double size)
double | relativeSize () const

## Protected Member Functions
virtual void | paintEvent (WPaintDevice *paintDevice) override

## Private Member Functions
void | drawEmwebLogo (WPainter &p)
void | drawEmwebE (WPainter &p)
void | drawEmwebMW (WPainter &p)

## Private Attributes
double | angle_
double | size_

## Detailed Description

Definition at line 19 of file ShapesWidget.h.

## Constructor & Destructor Documentation

## ◆ ShapesWidget()

ShapesWidget::ShapesWidget | ( |  | ) |

Definition at line 25 of file ShapesWidget.C.

26 : WPaintedWidget(),
27 angle_(0),
28 size_(1)
29{
30 resize(710, 400);
31}
ShapesWidget::size_
double size_
Definition ShapesWidget.h:35
ShapesWidget::angle_
double angle_
Definition ShapesWidget.h:34

## Member Function Documentation

## ◆ angle()

double ShapesWidget::angle | ( |  | ) | const
| inline

Definition at line 25 of file ShapesWidget.h.

25{ return angle_; }

## ◆ drawEmwebE()

void ShapesWidget::drawEmwebE | ( | WPainter & | p | ) |
| private

Definition at line 68 of file ShapesWidget.C.

69{
70 WPainterPath p;
71
72 /* Path copied from our SVG for half of the E */
73
74 p.moveTo(46.835084,58.783624);
75 p.cubicTo(45.700172,58.783624,35.350098,58.911502,24.656354,63.283309);
76 p.cubicTo(8.7595992,69.78907,0,82.38499,0,98.809238);
77 p.cubicTo(0,115.20152,08.7595992,127.82141,24.656354,134.31119);
78 p.cubicTo(35.350098,138.69099,45.700172,138.81088,46.835084,138.81088);
79 p.lineTo(94.509362,138.81088);
80 p.lineTo(94.509362,117.58323);
81 p.lineTo(46.835084,117.58323);
82 p.cubicTo(46.811106,117.58323,39.466151,117.47134,32.608727,114.53815);
83 p.cubicTo(25.095932,111.34122,21.747144,106.47389,21.747144,98.809238);
84 p.cubicTo(21.747144,91.120612,25.095932,86.269265,32.608727,83.064338);
85 p.cubicTo(39.466151,80.123159,46.811106,80.027251,46.89103,80.027251);
86 p.lineTo(94.509362,80.027251);
87 p.lineTo(94.509362,58.783624);
88 p.lineTo(46.835084,58.783624);
89
90 painter.drawPath(p);
91
92 painter.save();
93 painter.translate(0,-58.783624);
94 painter.drawPath(p);
95 painter.restore();
96}

## ◆ drawEmwebLogo()

void ShapesWidget::drawEmwebLogo | ( | WPainter & | p | ) |
| private

Definition at line 146 of file ShapesWidget.C.

147{
148 painter.save();
149 painter.setPen(WPen(PenStyle::None));
150
151 /*
152 * The emweb logo can be drawn as 3 e's, and one combined m/w
153 */
154
155 // Emweb
156 painter.setBrush(WColor(StandardColor::Black));
157 drawEmwebE(painter);
158
159 // emwEb
160 painter.save();
161 painter.translate(397, 0);
162 drawEmwebE(painter);
163
164 // emweB
165 painter.translate(210, 0);
166 painter.scale(-1, 1);
167 drawEmwebE(painter);
168
169 painter.restore();
170
171 // eMWeb
172 painter.setBrush(emweb);
173 drawEmwebMW(painter);
174
175 painter.restore();
176}
ShapesWidget::drawEmwebMW
void drawEmwebMW(WPainter &p)
Definition ShapesWidget.C:98
ShapesWidget::drawEmwebE
void drawEmwebE(WPainter &p)
Definition ShapesWidget.C:68

## ◆ drawEmwebMW()

void ShapesWidget::drawEmwebMW | ( | WPainter & | p | ) |
| private

Definition at line 98 of file ShapesWidget.C.

99{
100 WPainterPath p;
101
102 /* Path copied from our SVG for one fourth of the MW */
103
104 p.moveTo(120.59634,24.072913);
105 p.cubicTo(116.12064,34.518895,115.98477,44.605222,115.98477,45.732141);
106 p.lineTo(115.98477,138.81088);
107 p.lineTo(137.7399,138.81088);
108 p.lineTo(137.7399,45.732141);
109 p.cubicTo(137.7399,45.708164,137.83581,38.53904,140.84892,31.841463);
110 p.cubicTo(144.14176,24.512492,149.113,21.235634,156.98545,21.235634);
111 p.cubicTo(164.8499,21.235634,169.81314,24.512492,173.10599,31.841463);
112 p.cubicTo(176.10311,38.53904,176.215,45.708164,176.215,45.780095);
113 p.lineTo(176.215,70.41343);
114 p.lineTo(197.97014,70.41343);
115 p.lineTo(197.97014,45.732141);
116 p.cubicTo(197.97014,44.605222,197.83427,34.518895,193.35057,24.072913);
117 p.cubicTo(186.70894,8.5517985,173.77734,0,156.99344,0);
118 p.cubicTo(140.17756,0,127.25396,8.5517985,120.59634,24.072913);
119
120 /*
121 * Paint it four times, translated and inverted
122 */
123
124 painter.drawPath(p);
125
126 const double dx = 176. - 115.98477;
127
128 painter.save();
129
130 painter.translate(dx, 0);
131 painter.drawPath(p);
132
133 painter.translate(dx, 0);
134
135 painter.scale(-1, -1);
136 painter.translate(0, -138.81088);
137 painter.translate(-115.98477 - 197.95 - dx, 0);
138 painter.drawPath(p);
139
140 painter.translate(dx, 0);
141 painter.drawPath(p);
142
143 painter.restore();
144}

## ◆ paintEvent()

void ShapesWidget::paintEvent | ( | WPaintDevice * | paintDevice | ) |
| overrideprotectedvirtual

Definition at line 53 of file ShapesWidget.C.

54{
55 WPainter painter(paintDevice);
56
57 painter.setShadow(WShadow(10, 10, WColor(0, 0, 0, 50), 10));
58 painter.setRenderHint(RenderHint::Antialiasing);
59
60 painter.translate(width().value()/2, height().value()/2);
61 painter.rotate(angle_);
62 painter.scale(size_, size_);
63 painter.translate(-width().value()/2 + 50, -height().value()/2 + 150);
64
65 drawEmwebLogo(painter);
66}
ShapesWidget::drawEmwebLogo
void drawEmwebLogo(WPainter &p)
Definition ShapesWidget.C:146

## ◆ relativeSize()

double ShapesWidget::relativeSize | ( |  | ) | const
| inline

Definition at line 28 of file ShapesWidget.h.

28{ return size_; }

## ◆ setAngle()

void ShapesWidget::setAngle | ( | double | angle | ) |

Definition at line 33 of file ShapesWidget.C.

34{
35 angle = std::max(-30.0, std::min(30.0, angle));
36
37 if (angle_ != angle) {
38 angle_ = angle;
39 update();
40 }
41}
ShapesWidget::angle
double angle() const
Definition ShapesWidget.h:25

## ◆ setRelativeSize()

void ShapesWidget::setRelativeSize | ( | double | size | ) |

Definition at line 43 of file ShapesWidget.C.

44{
45 size = std::max(0.1, std::min(1.0, size));
46
47 if (size_ != size) {
48 size_ = size;
49 update();
50 }
51}

## Member Data Documentation

## ◆ angle_

double ShapesWidget::angle_
| private

Definition at line 34 of file ShapesWidget.h.

## ◆ size_

double ShapesWidget::size_
| private

Definition at line 35 of file ShapesWidget.h.

The documentation for this class was generated from the following files:

- painting/ShapesWidget.h
- painting/ShapesWidget.C