Update copyright headers
[qt:qt.git] / demos / affine / xform.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the demonstration applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "xform.h"
43 #include "hoverpoints.h"
44
45 #include <QLayout>
46 #include <QPainter>
47 #include <QPainterPath>
48
49 const int alpha = 155;
50
51 XFormView::XFormView(QWidget *parent)
52     : ArthurFrame(parent)
53 {
54     setAttribute(Qt::WA_MouseTracking);
55     m_type = VectorType;
56     m_rotation = 0.0;
57     m_scale = 1.0;
58     m_shear = 0.0;
59
60     m_pixmap = QPixmap(":res/affine/bg1.jpg");
61     pts = new HoverPoints(this, HoverPoints::CircleShape);
62     pts->setConnectionType(HoverPoints::LineConnection);
63     pts->setEditable(false);
64     pts->setPointSize(QSize(15, 15));
65     pts->setShapeBrush(QBrush(QColor(151, 0, 0, alpha)));
66     pts->setShapePen(QPen(QColor(255, 100, 50, alpha)));
67     pts->setConnectionPen(QPen(QColor(151, 0, 0, 50)));
68     pts->setBoundingRect(QRectF(0, 0, 500, 500));
69     ctrlPoints << QPointF(250, 250) << QPointF(350, 250);
70     pts->setPoints(ctrlPoints);
71     connect(pts, SIGNAL(pointsChanged(QPolygonF)),
72             this, SLOT(updateCtrlPoints(QPolygonF)));
73     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
74 }
75
76 XFormView::XFormType XFormView::type() const
77 {
78     return m_type;
79 }
80
81 QPixmap XFormView::pixmap() const
82 {
83     return m_pixmap;
84 }
85
86 QString XFormView::text() const
87 {
88     return m_text;
89 }
90
91 void XFormView::setText(const QString &t)
92 {
93     m_text = t;
94     update();
95 }
96
97 void XFormView::setPixmap(const QPixmap &p)
98 {
99     m_pixmap = p;
100     update();
101 }
102
103 void XFormView::setType(XFormType t)
104 {
105     m_type = t;
106     update();
107 }
108
109 void XFormView::mousePressEvent(QMouseEvent *)
110 {
111     setDescriptionEnabled(false);
112 }
113
114 void XFormView::resizeEvent(QResizeEvent *e)
115 {
116     pts->setBoundingRect(rect());
117     ArthurFrame::resizeEvent(e);
118 }
119
120 void XFormView::paint(QPainter *p)
121 {
122     p->save();
123     p->setRenderHint(QPainter::Antialiasing);
124     p->setRenderHint(QPainter::SmoothPixmapTransform);
125     switch (m_type) {
126     case VectorType:
127         drawVectorType(p);
128         break;
129     case PixmapType:
130         drawPixmapType(p);
131         break;
132     case TextType:
133         drawTextType(p);
134         break;
135     }
136     p->restore();
137 }
138
139 void XFormView::updateCtrlPoints(const QPolygonF &points)
140 {
141     QPointF trans = points.at(0) - ctrlPoints.at(0);
142
143     if (qAbs(points.at(0).x() - points.at(1).x()) < 10
144         && qAbs(points.at(0).y() - points.at(1).y()) < 10)
145         pts->setPoints(ctrlPoints);
146     if (!trans.isNull()) {
147         ctrlPoints[0] = points.at(0);
148         ctrlPoints[1] += trans;
149         pts->setPoints(ctrlPoints);
150     }
151     ctrlPoints = points;
152
153     QLineF line(ctrlPoints.at(0), ctrlPoints.at(1));
154     m_rotation = line.angle(QLineF(0, 0, 1, 0));
155     if (line.dy() < 0)
156         m_rotation = 360 - m_rotation;
157
158     if (trans.isNull())
159         emit rotationChanged(int(m_rotation*10));
160 }
161
162 void XFormView::setVectorType()
163 {
164     m_type = VectorType;
165     update();
166 }
167
168 void XFormView::setPixmapType()
169 {
170     m_type = PixmapType;
171     update();
172 }
173
174 void XFormView::setTextType()
175 {
176     m_type = TextType;
177     update();
178 }
179
180 void XFormView::setAnimation(bool animate)
181 {
182     timer.stop();
183     if (animate)
184         timer.start(25, this);
185 }
186
187 void XFormView::changeRotation(int r)
188 {
189     setRotation(qreal(r) / 10);
190 }
191
192 void XFormView::changeScale(int s)
193 {
194     setScale(qreal(s) / 1000);
195 }
196
197 void XFormView::changeShear(int s)
198 {
199     setShear(qreal(s) / 1000);
200 }
201
202 void XFormView::setShear(qreal s)
203 {
204     m_shear = s;
205     update();
206 }
207
208 void XFormView::setScale(qreal s)
209 {
210     m_scale = s;
211     update();
212 }
213
214 void XFormView::setRotation(qreal r)
215 {
216     qreal old_rot = m_rotation;
217     m_rotation = r;
218
219     QPointF center(pts->points().at(0));
220     QMatrix m;
221     m.translate(center.x(), center.y());
222     m.rotate(m_rotation - old_rot);
223     m.translate(-center.x(), -center.y());
224     pts->setPoints(pts->points() * m);
225
226     update();
227 }
228
229 void XFormView::timerEvent(QTimerEvent *e)
230 {
231     if (e->timerId() == timer.timerId()) {
232         QPointF center(pts->points().at(0));
233         QMatrix m;
234         m.translate(center.x(), center.y());
235         m.rotate(0.2);
236         m.translate(-center.x(), -center.y());
237         pts->setPoints(pts->points() * m);
238
239         setUpdatesEnabled(false);
240         static qreal scale_inc = 0.003;
241         static qreal shear_inc = -0.001;
242         emit scaleChanged(int((m_scale + scale_inc) * 1000));
243         emit shearChanged(int((m_shear + shear_inc) * 1000));
244         if (m_scale >= 4.0 || m_scale <= 0.1)
245             scale_inc = -scale_inc;
246         if (m_shear >= 1.0 || m_shear <= -1.0)
247             shear_inc = -shear_inc;
248         setUpdatesEnabled(true);
249
250         pts->firePointChange();
251     }
252 }
253
254 void XFormView::wheelEvent(QWheelEvent *e)
255 {
256     m_scale += e->delta() / qreal(600);
257     m_scale = qMax(qreal(0.1), qMin(qreal(4), m_scale));
258     emit scaleChanged(int(m_scale*1000));
259 }
260
261 void XFormView::reset()
262 {
263     emit rotationChanged(0);
264     emit scaleChanged(1000);
265     emit shearChanged(0);
266     ctrlPoints = QPolygonF();
267     ctrlPoints << QPointF(250, 250) << QPointF(350, 250);
268     pts->setPoints(ctrlPoints);
269     pts->firePointChange();
270 }
271
272 void XFormView::drawPixmapType(QPainter *painter)
273 {
274     QPointF center(m_pixmap.width() / qreal(2), m_pixmap.height() / qreal(2));
275     painter->translate(ctrlPoints.at(0) - center);
276
277     painter->translate(center);
278     painter->rotate(m_rotation);
279     painter->scale(m_scale, m_scale);
280     painter->shear(0, m_shear);
281     painter->translate(-center);
282
283     painter->drawPixmap(QPointF(0, 0), m_pixmap);
284     painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
285     painter->setBrush(Qt::NoBrush);
286     painter->drawRect(QRectF(0, 0, m_pixmap.width(), m_pixmap.height()).adjusted(-2, -2, 2, 2));
287 }
288
289 void XFormView::drawTextType(QPainter *painter)
290 {
291     QPainterPath path;
292     QFont f("times new roman,utopia");
293     f.setStyleStrategy(QFont::ForceOutline);
294     f.setPointSize(72);
295     f.setStyleHint(QFont::Times);
296     path.addText(0, 0, f, m_text);
297
298     QFontMetrics fm(f);
299     QRectF br(fm.boundingRect(m_text));
300     QPointF center(br.center());
301     painter->translate(ctrlPoints.at(0) - center);
302
303     painter->translate(center);
304     painter->rotate(m_rotation);
305     painter->scale(m_scale, m_scale);
306     painter->shear(0, m_shear);
307     painter->translate(-center);
308
309     painter->fillPath(path, Qt::black);
310
311     painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
312     painter->setBrush(Qt::NoBrush);
313     painter->drawRect(br.adjusted(-1, -1, 1, 1));
314 }
315
316 void XFormView::drawVectorType(QPainter *painter)
317 {
318     QPainterPath path;
319     painter->translate(ctrlPoints.at(0) - QPointF(250,250));
320
321     painter->scale(0.77, 0.77);
322     painter->translate(98.9154 + 30 , -217.691 - 20);
323
324     QRect br(-55, 275, 500, 590);
325     QPoint center = br.center();
326     painter->translate(center.x(), center.y());
327     painter->rotate(m_rotation);
328     painter->scale(m_scale, m_scale);
329     painter->shear(0, m_shear);
330     painter->translate(-center.x(), -center.y());
331
332     painter->setPen(Qt::NoPen);
333     path.moveTo(120, 470);
334     path.lineTo(60+245, 470);
335     path.lineTo(60+245, 470+350);
336     path.lineTo(60, 470+350);
337     path.lineTo(60, 470+80);
338
339     painter->setBrush(Qt::white);
340     painter->drawPath(path);
341     path = QPainterPath();
342
343     painter->setBrush(QColor( 193, 193, 191, 255));
344     path.moveTo(329.336, 727.552);
345     path.cubicTo(QPointF(315.224, 726.328), QPointF(304.136, 715.816), QPointF(303.128, 694.936));
346     path.cubicTo(QPointF(306.368, 639.496), QPointF(309.608, 582.112), QPointF(271.232, 545.104));
347     path.cubicTo(QPointF(265.256, 499.024), QPointF(244.016, 482.104), QPointF(234.008, 452.512));
348     path.lineTo(218.24, 441.208);
349     path.lineTo(237.104, 411.688);
350     path.lineTo(245.168, 411.904);
351     path.lineTo(323.936, 571.168);
352     path.lineTo(340.424, 651.448);
353     path.closeSubpath();
354     painter->drawPath(path);
355     path = QPainterPath();
356
357     painter->setBrush(QColor(193, 193, 191, 255));
358     path.moveTo(136.232, 439.696);
359     path.cubicTo(QPointF(133.856, 455.248), QPointF(132.56, 470.512), QPointF(134.792, 485.272));
360     path.cubicTo(QPointF(118.376, 507.592), QPointF(105.92, 530.128), QPointF(104.48, 553.312));
361     path.cubicTo(QPointF(92.024, 586.504), QPointF(62.432, 614.584), QPointF(67.544, 680.104));
362     path.cubicTo(QPointF(84.176, 697.456), QPointF(107.432, 713.584), QPointF(127.376, 730.36));
363     path.cubicTo(QPointF(152.432, 751.312), QPointF(137.528, 778.96), QPointF(102.248, 772.408));
364     path.cubicTo(QPointF(94.4, 763.768), QPointF(76.616, 709.624), QPointF(42.92, 676.288));
365     path.lineTo(49.544, 632.584);
366     path.lineTo(81.368, 547.408);
367     path.lineTo(120.968, 484.048);
368     path.lineTo(125.36, 456.688);
369     path.lineTo(119.816, 386.776);
370     path.lineTo(124.424, 361.216);
371     path.lineTo(136.232, 439.696);
372     path.closeSubpath();
373     painter->drawPath(path);
374     path = QPainterPath();
375
376     painter->setBrush(QColor(193, 193, 191, 255));
377     path.moveTo(115.64, 341.416);
378     path.cubicTo(QPointF(116.576, 336.376), QPointF(117.8, 331.624), QPointF(119.312, 327.16));
379     path.lineTo(121.688, 342.784);
380     path.closeSubpath();
381     painter->drawPath(path);
382     path = QPainterPath();
383
384     painter->setBrush(QColor(193, 193, 191, 255));
385     path.moveTo(120.968, 500.464);
386     path.cubicTo(QPointF(108.368, 523.792), QPointF(103.976, 546.256), QPointF(132.92, 550.216));
387     path.cubicTo(QPointF(117.008, 553.888), QPointF(97.208, 568.648), QPointF(77.192, 593.488));
388     path.lineTo(77.624, 543.016);
389     path.lineTo(101.456, 503.272);
390     path.closeSubpath();
391     painter->drawPath(path);
392     path = QPainterPath();
393
394     painter->setBrush(QColor(193, 193, 191, 255));
395     path.moveTo(-33.256, 818.488);
396     path.cubicTo(QPointF(10.52, 838.144), QPointF(41.408, 837.064), QPointF(69.272, 850.96));
397     path.cubicTo(QPointF(91.304, 862.552), QPointF(113.552, 861.184), QPointF(126.944, 847.144));
398     path.cubicTo(QPointF(138.32, 832.456), QPointF(146.744, 831.736), QPointF(163.52, 830.224));
399     path.cubicTo(QPointF(190.952, 828.568), QPointF(217.736, 828.28), QPointF(241.928, 830.8));
400     path.lineTo(269.576, 833.032);
401     path.cubicTo(QPointF(269.072, 864.064), QPointF(328.04, 867.88), QPointF(345.392, 844.336));
402     path.cubicTo(QPointF(366.344, 819.424), QPointF(395.144, 808.264), QPointF(419.84, 790.192));
403     path.lineTo(289.304, 725.536);
404     path.cubicTo(QPointF(255.824, 806.464), QPointF(131.048, 827.632), QPointF(113.768, 763.264));
405     path.closeSubpath();
406     painter->drawPath(path);
407     path = QPainterPath();
408
409     painter->setBrush(QColor(193, 193, 191, 255));
410     path.moveTo(286.424, 711.568);
411     path.cubicTo(QPointF(273.824, 711.496), QPointF(260.936, 715.6), QPointF(261.944, 732.16));
412     path.lineTo(266.192, 776.44);
413     path.lineTo(304.424, 756.64);
414     path.closeSubpath();
415     painter->drawPath(path);
416     path = QPainterPath();
417
418     painter->setBrush(QColor(0, 0, 0, 255));
419     path.moveTo(-37.36, 821.224);
420     path.cubicTo(QPointF(7.136, 840.88), QPointF(38.6, 839.728), QPointF(66.968, 853.696));
421     path.cubicTo(QPointF(89.36, 865.216), QPointF(111.968, 863.92), QPointF(125.648, 849.808));
422     path.cubicTo(QPointF(137.24, 835.192), QPointF(145.808, 834.472), QPointF(162.872, 832.96));
423     path.cubicTo(QPointF(190.736, 831.232), QPointF(218.024, 831.016), QPointF(242.648, 833.464));
424     path.lineTo(270.728, 835.768);
425     path.cubicTo(QPointF(270.224, 866.8), QPointF(330.272, 870.544), QPointF(347.912, 847));
426     path.cubicTo(QPointF(369.224, 822.088), QPointF(398.528, 811), QPointF(423.656, 792.856));
427     path.lineTo(290.816, 728.272);
428     path.cubicTo(QPointF(256.76, 809.128), QPointF(129.824, 830.296), QPointF(112.256, 766));
429     path.closeSubpath();
430     painter->drawPath(path);
431     path = QPainterPath();
432
433     painter->setBrush(QColor(183, 114, 0, 255));
434     path.moveTo(382.328, 691.984);
435     path.cubicTo(QPointF(403.64, 698.968), QPointF(389.888, 720.28), QPointF(400.76, 732.52));
436     path.cubicTo(QPointF(405.44, 742.888), QPointF(415.304, 752.032), QPointF(431.792, 760.528));
437     path.cubicTo(QPointF(459.368, 774.424), QPointF(426.248, 799.336), QPointF(392.768, 812.08));
438     path.cubicTo(QPointF(351.944, 825.616), QPointF(344.024, 862.912), QPointF(299.312, 851.896));
439     path.cubicTo(QPointF(283.112, 846.496), QPointF(278.36, 831.808), QPointF(278.864, 809.128));
440     path.cubicTo(QPointF(284.264, 762.76), QPointF(277.784, 730.432), QPointF(278.792, 698.824));
441     path.cubicTo(QPointF(278.72, 686.152), QPointF(283.544, 684.64), QPointF(307.232, 687.952));
442     path.cubicTo(QPointF(310.04, 726.328), QPointF(352.376, 727.336), QPointF(382.328, 691.984));
443     path.closeSubpath();
444     painter->drawPath(path);
445     path = QPainterPath();
446
447     painter->setBrush(QColor(242, 183, 0, 255));
448     path.moveTo(339.632, 826.624);
449     path.cubicTo(QPointF(371.6, 814.312), QPointF(403.856, 798.112), QPointF(429.848, 782.128));
450     path.cubicTo(QPointF(437.84, 777.448), QPointF(438.92, 765.928), QPointF(427.688, 762.328));
451     path.cubicTo(QPointF(403.352, 748.504), QPointF(390.104, 731.224), QPointF(392.912, 708.76));
452     path.cubicTo(QPointF(393.344, 700.912), QPointF(383.696, 692.56), QPointF(381.104, 700.048));
453     path.cubicTo(QPointF(359.864, 771.472), QPointF(291.32, 767.656), QPointF(300.752, 696.952));
454     path.cubicTo(QPointF(301.256, 694.864), QPointF(301.76, 692.776), QPointF(302.264, 690.76));
455     path.cubicTo(QPointF(289.952, 688.24), QPointF(285.2, 690.976), QPointF(285.776, 700.408));
456     path.lineTo(295.28, 806.608);
457     path.cubicTo(QPointF(297.656, 830.8), QPointF(317.312, 836.128), QPointF(339.632, 826.624));
458     path.closeSubpath();
459     painter->drawPath(path);
460     path = QPainterPath();
461
462     painter->setBrush(QColor(0, 0, 0, 255));
463     path.moveTo(354.464, 537.544);
464     path.cubicTo(QPointF(379.16, 569.8), QPointF(404.432, 651.088), QPointF(384.416, 691.552));
465     path.cubicTo(QPointF(360.944, 737.776), QPointF(307.808, 743.248), QPointF(305.504, 695.8));
466     path.cubicTo(QPointF(308.816, 639.64), QPointF(311.984, 581.536), QPointF(273.68, 544.096));
467     path.cubicTo(QPointF(267.704, 497.368), QPointF(246.392, 480.232), QPointF(236.384, 450.28));
468     path.lineTo(203.12, 426.088);
469     path.lineTo(133.568, 435.088);
470     path.cubicTo(QPointF(130.76, 452.152), QPointF(129.104, 468.784), QPointF(131.552, 484.912));
471     path.cubicTo(QPointF(115.064, 507.376), QPointF(102.608, 530.056), QPointF(101.168, 553.312));
472     path.cubicTo(QPointF(88.712, 586.648), QPointF(59.12, 614.944), QPointF(64.232, 680.752));
473     path.cubicTo(QPointF(80.864, 698.248), QPointF(104.12, 714.448), QPointF(124.064, 731.296));
474     path.cubicTo(QPointF(149.12, 752.392), QPointF(135.512, 776.296), QPointF(100.232, 769.672));
475     path.cubicTo(QPointF(78.848, 746.056), QPointF(56.744, 722.872), QPointF(35.288, 699.328));
476     path.cubicTo(QPointF(12.392, 683.056), QPointF(3.896, 662.176), QPointF(27.368, 630.496));
477     path.cubicTo(QPointF(43.424, 609.04), QPointF(47.96, 562.456), QPointF(62, 543.664));
478     path.cubicTo(QPointF(74.312, 525.16), QPointF(92.24, 508.6), QPointF(105.272, 490.096));
479     path.cubicTo(QPointF(112.184, 477.928), QPointF(114.344, 468.568), QPointF(113.264, 454.456));
480     path.lineTo(110.312, 369.136);
481     path.cubicTo(QPointF(108.368, 307.216), QPointF(142.424, 274.24), QPointF(189.8, 275.248));
482     path.cubicTo(QPointF(243.512, 275.752), QPointF(287.576, 312.472), QPointF(288.152, 378.28));
483     path.cubicTo(QPointF(292.688, 410.32), QPointF(283.256, 428.68), QPointF(308.672, 474.472));
484     path.cubicTo(QPointF(334.52, 522.712), QPointF(338.552, 520.12), QPointF(354.464, 537.544));
485     path.closeSubpath();
486     painter->drawPath(path);
487     path = QPainterPath();
488
489     painter->setBrush(QColor(193, 193, 191, 255));
490     path.moveTo(261.296, 503.632);
491     path.lineTo(263.528, 512.2);
492     path.cubicTo(QPointF(257.696, 501.688), QPointF(250.712, 483.616), QPointF(241.928, 475.696));
493     path.cubicTo(QPointF(239.264, 473.536), QPointF(235.808, 473.608), QPointF(233.72, 475.624));
494     path.cubicTo(QPointF(222.056, 486.928), QPointF(193.112, 510.112), QPointF(169.928, 507.088));
495     path.cubicTo(QPointF(152.072, 505.288), QPointF(134.648, 493.264), QPointF(130.832, 480.232));
496     path.cubicTo(QPointF(128.816, 470.872), QPointF(129.752, 463.168), QPointF(130.976, 455.32));
497     path.lineTo(240.704, 453.52);
498     path.cubicTo(QPointF(238.472, 463.168), QPointF(253.088, 487), QPointF(261.296, 503.632));
499     path.closeSubpath();
500     painter->drawPath(path);
501     path = QPainterPath();
502
503     painter->setBrush(QColor(193, 193, 191, 255));
504     path.moveTo(143.144, 363.232);
505     path.cubicTo(QPointF(154.088, 363.232), QPointF(163.88, 376.84), QPointF(163.808, 395.632));
506     path.cubicTo(QPointF(163.736, 408.232), QPointF(155.528, 411.472), QPointF(149.336, 417.016));
507     path.cubicTo(QPointF(146.6, 419.536), QPointF(145.952, 433.144), QPointF(142.568, 433.144));
508     path.cubicTo(QPointF(131.696, 433.144), QPointF(123.488, 413.776), QPointF(123.488, 395.632));
509     path.cubicTo(QPointF(123.488, 377.56), QPointF(132.272, 363.232), QPointF(143.144, 363.232));
510     path.closeSubpath();
511     painter->drawPath(path);
512     path = QPainterPath();
513
514     painter->setBrush(QColor(255, 255, 255, 255));
515     path.moveTo(144.368, 375.04);
516     path.cubicTo(QPointF(154.088, 375.04), QPointF(160.856, 379.936), QPointF(161.648, 391.312));
517     path.cubicTo(QPointF(162.224, 399.16), QPointF(160.136, 411.76), QPointF(154.664, 414.424));
518     path.cubicTo(QPointF(152.144, 415.648), QPointF(143.432, 426.664), QPointF(140.408, 426.52));
519     path.cubicTo(QPointF(128.096, 425.944), QPointF(125, 402.112), QPointF(125.936, 390.736));
520     path.cubicTo(QPointF(126.8, 379.36), QPointF(134.72, 375.04), QPointF(144.368, 375.04));
521     path.closeSubpath();
522     painter->drawPath(path);
523     path = QPainterPath();
524
525     painter->setBrush(QColor(0, 0, 0, 255));
526     path.moveTo(141.848, 382.672);
527     path.cubicTo(QPointF(148.544, 382.096), QPointF(154.736, 389.728), QPointF(155.6, 399.664));
528     path.cubicTo(QPointF(156.464, 409.6), QPointF(151.64, 418.24), QPointF(144.944, 418.816));
529     path.cubicTo(QPointF(138.248, 419.392), QPointF(132.056, 411.76), QPointF(131.192, 401.752));
530     path.cubicTo(QPointF(130.328, 391.816), QPointF(135.152, 383.248), QPointF(141.848, 382.672));
531     path.closeSubpath();
532     painter->drawPath(path);
533     path = QPainterPath();
534
535     painter->setBrush(QColor(193, 193, 191, 255));
536     path.moveTo(151.064, 397.288);
537     path.cubicTo(QPointF(151.424, 399.088), QPointF(149.408, 400.024), QPointF(148.832, 398.224));
538     path.cubicTo(QPointF(148.256, 395.992), QPointF(146.888, 393.328), QPointF(145.088, 391.168));
539     path.cubicTo(QPointF(143.936, 389.872), QPointF(145.088, 388.432), QPointF(146.528, 389.44));
540     path.cubicTo(QPointF(149.048, 391.528), QPointF(150.488, 394.12), QPointF(151.064, 397.288));
541     path.closeSubpath();
542     painter->drawPath(path);
543     path = QPainterPath();
544
545     painter->setBrush(QColor(193, 193, 191, 255));
546     path.moveTo(216.944, 360.712);
547     path.cubicTo(QPointF(232.712, 360.712), QPointF(245.6, 377.416), QPointF(245.6, 397.792));
548     path.cubicTo(QPointF(245.6, 418.24), QPointF(232.712, 434.872), QPointF(216.944, 434.872));
549     path.cubicTo(QPointF(201.176, 434.872), QPointF(188.432, 418.24), QPointF(188.432, 397.792));
550     path.cubicTo(QPointF(188.432, 377.416), QPointF(201.176, 360.712), QPointF(216.944, 360.712));
551     path.closeSubpath();
552     painter->drawPath(path);
553     path = QPainterPath();
554
555     painter->setBrush(QColor(255, 255, 255, 255));
556     path.moveTo(224.792, 374.968);
557     path.cubicTo(QPointF(235.664, 378.856), QPointF(241.928, 387.424), QPointF(242.72, 396.568));
558     path.cubicTo(QPointF(243.656, 407.08), QPointF(239.408, 418.96), QPointF(230.264, 425.944));
559     path.cubicTo(QPointF(227.672, 427.888), QPointF(197.72, 416.08), QPointF(195.992, 411.616));
560     path.cubicTo(QPointF(193.4, 405.208), QPointF(191.816, 392.896), QPointF(193.76, 385.624));
561     path.cubicTo(QPointF(194.552, 382.744), QPointF(197.216, 378.568), QPointF(201.176, 376.336));
562     path.cubicTo(QPointF(207.44, 372.808), QPointF(216.656, 372.088), QPointF(224.792, 374.968));
563     path.closeSubpath();
564     painter->drawPath(path);
565     path = QPainterPath();
566
567     painter->setBrush(QColor(0, 0, 0, 255));
568     path.moveTo(216.872, 380.944);
569     path.cubicTo(QPointF(225.584, 380.944), QPointF(232.712, 389.296), QPointF(232.712, 399.448));
570     path.cubicTo(QPointF(232.712, 409.672), QPointF(225.584, 418.024), QPointF(216.872, 418.024));
571     path.cubicTo(QPointF(208.16, 418.024), QPointF(201.032, 409.672), QPointF(201.032, 399.448));
572     path.cubicTo(QPointF(201.032, 389.296), QPointF(208.16, 380.944), QPointF(216.872, 380.944));
573     path.closeSubpath();
574     painter->drawPath(path);
575     path = QPainterPath();
576
577     painter->setBrush(QColor(193, 193, 191, 255));
578     path.moveTo(227.096, 392.392);
579     path.cubicTo(QPointF(228.104, 394.048), QPointF(226.448, 395.776), QPointF(225.224, 394.12));
580     path.cubicTo(QPointF(223.784, 392.104), QPointF(221.408, 389.944), QPointF(218.888, 388.432));
581     path.cubicTo(QPointF(217.232, 387.568), QPointF(217.808, 385.624), QPointF(219.68, 386.2));
582     path.cubicTo(QPointF(222.92, 387.28), QPointF(225.368, 389.368), QPointF(227.096, 392.392));
583     path.closeSubpath();
584     painter->drawPath(path);
585     path = QPainterPath();
586
587     painter->setBrush(QColor(183, 114, 0, 255));
588     path.moveTo(164.96, 404.488);
589     path.cubicTo(QPointF(172.376, 402.328), QPointF(184.112, 403.048), QPointF(192.248, 404.632));
590     path.cubicTo(QPointF(200.384, 406.792), QPointF(222.056, 418.24), QPointF(245.024, 430.696));
591     path.cubicTo(QPointF(247.976, 432.208), QPointF(248.84, 437.104), QPointF(245.024, 438.688));
592     path.cubicTo(QPointF(239.12, 439.12), QPointF(249.272, 453.664), QPointF(238.904, 458.848));
593     path.cubicTo(QPointF(223.352, 462.88), QPointF(198.44, 485.992), QPointF(186.128, 487.864));
594     path.cubicTo(QPointF(179.288, 489.376), QPointF(172.232, 489.592), QPointF(164.6, 487.864));
595     path.cubicTo(QPointF(140.552, 482.968), QPointF(134.216, 455.608), QPointF(122.912, 450.064));
596     path.cubicTo(QPointF(119.816, 446.824), QPointF(121.4, 441.208), QPointF(122.408, 440.056));
597     path.cubicTo(QPointF(123.632, 434.224), QPointF(149.696, 406.216), QPointF(164.96, 404.488));
598     path.closeSubpath();
599     painter->drawPath(path);
600     path = QPainterPath();
601
602     painter->setBrush(QColor(242, 183, 0, 255));
603     path.moveTo(185.408, 405.856);
604     path.cubicTo(QPointF(198.44, 407.296), QPointF(226.088, 423.928), QPointF(239.408, 430.624));
605     path.cubicTo(QPointF(242.72, 432.424), QPointF(242.504, 437.824), QPointF(239.552, 438.688));
606     path.cubicTo(QPointF(236.384, 440.488), QPointF(235.448, 438.256), QPointF(232.928, 437.896));
607     path.cubicTo(QPointF(228.896, 435.736), QPointF(222.272, 440.92), QPointF(217.016, 444.88));
608     path.cubicTo(QPointF(186.704, 467.776), QPointF(180.656, 465.256), QPointF(156.176, 462.664));
609     path.cubicTo(QPointF(147.68, 460.576), QPointF(142.136, 457.984), QPointF(139.688, 455.968));
610     path.cubicTo(QPointF(141.488, 445.888), QPointF(160.496, 407.656), QPointF(166.76, 406.792));
611     path.cubicTo(QPointF(168.344, 404.704), QPointF(179.936, 404.632), QPointF(185.408, 405.856));
612     path.closeSubpath();
613     painter->drawPath(path);
614     path = QPainterPath();
615
616     painter->setBrush(QColor(183, 114, 0, 255));
617     path.moveTo(190.664, 412.048);
618     path.lineTo(193.76, 413.416);
619     path.cubicTo(QPointF(196.064, 414.712), QPointF(193.256, 418.168), QPointF(190.736, 417.088));
620     path.lineTo(186.2, 415.504);
621     path.cubicTo(QPointF(183.536, 413.272), QPointF(186.704, 410.104), QPointF(190.664, 412.048));
622     path.closeSubpath();
623     painter->drawPath(path);
624     path = QPainterPath();
625
626     painter->setBrush(QColor(193, 193, 191, 255));
627     path.moveTo(268.568, 452.368);
628     path.cubicTo(QPointF(273.032, 454.384), QPointF(279.224, 457.192), QPointF(282.536, 460.144));
629     path.cubicTo(QPointF(285.488, 464.104), QPointF(286.784, 468.064), QPointF(286.424, 472.024));
630     path.cubicTo(QPointF(285.776, 474.544), QPointF(284.12, 476.344), QPointF(281.24, 477.424));
631     path.cubicTo(QPointF(277.856, 478.216), QPointF(273.68, 477.424), QPointF(271.376, 474.112));
632     path.cubicTo(QPointF(269.864, 471.448), QPointF(265.256, 462.16), QPointF(263.96, 460.576));
633     path.cubicTo(QPointF(262.232, 457.12), QPointF(261.944, 454.456), QPointF(262.88, 452.368));
634     path.cubicTo(QPointF(264.032, 451.288), QPointF(266.048, 451), QPointF(268.568, 452.368));
635     path.closeSubpath();
636     painter->drawPath(path);
637     path = QPainterPath();
638
639     painter->setBrush(QColor(255, 255, 255, 255));
640     path.moveTo(273.752, 461.584);
641     path.cubicTo(QPointF(275.48, 462.376), QPointF(277.928, 463.456), QPointF(279.224, 464.68));
642     path.cubicTo(QPointF(280.376, 466.264), QPointF(280.88, 467.776), QPointF(280.736, 469.36));
643     path.cubicTo(QPointF(280.52, 470.296), QPointF(279.8, 471.016), QPointF(278.72, 471.448));
644     path.cubicTo(QPointF(277.352, 471.808), QPointF(275.768, 471.448), QPointF(274.832, 470.152));
645     path.cubicTo(QPointF(274.256, 469.144), QPointF(272.456, 465.472), QPointF(271.952, 464.824));
646     path.cubicTo(QPointF(271.232, 463.456), QPointF(271.088, 462.448), QPointF(271.448, 461.584));
647     path.cubicTo(QPointF(271.952, 461.152), QPointF(272.744, 461.08), QPointF(273.752, 461.584));
648     path.closeSubpath();
649     painter->drawPath(path);
650     path = QPainterPath();
651
652     painter->setBrush(QColor(193, 193, 191, 255));
653     path.moveTo(238.616, 358.552);
654     path.cubicTo(QPointF(239.048, 359.2), QPointF(238.976, 359.776), QPointF(238.4, 360.28));
655     path.cubicTo(QPointF(237.896, 360.784), QPointF(237.176, 360.712), QPointF(236.24, 360.208));
656     path.lineTo(231.632, 356.248);
657     path.cubicTo(QPointF(231.056, 355.744), QPointF(230.912, 354.952), QPointF(231.272, 354.088));
658     path.cubicTo(QPointF(232.28, 353.44), QPointF(233.144, 353.44), QPointF(233.936, 354.088));
659     path.closeSubpath();
660     painter->drawPath(path);
661     path = QPainterPath();
662
663     painter->setBrush(QColor(193, 193, 191, 255));
664     path.moveTo(235.592, 305.992);
665     path.cubicTo(QPointF(239.624, 308.224), QPointF(240.848, 313.912), QPointF(238.184, 318.592));
666     path.cubicTo(QPointF(235.592, 323.2), QPointF(230.12, 325.144), QPointF(226.016, 322.84));
667     path.cubicTo(QPointF(221.984, 320.536), QPointF(220.76, 314.92), QPointF(223.424, 310.24));
668     path.cubicTo(QPointF(226.016, 305.56), QPointF(231.488, 303.688), QPointF(235.592, 305.992));
669     path.closeSubpath();
670     painter->drawPath(path);
671     path = QPainterPath();
672
673     painter->setBrush(QColor(193, 193, 191, 255));
674     path.moveTo(374.912, 680.536);
675     path.cubicTo(QPointF(378.296, 683.128), QPointF(373.256, 687.376), QPointF(371.024, 686.296));
676     path.cubicTo(QPointF(369.152, 685.648), QPointF(367.784, 683.488), QPointF(366.92, 682.408));
677     path.cubicTo(QPointF(366.128, 681.184), QPointF(366.2, 679.168), QPointF(366.92, 678.448));
678     path.cubicTo(QPointF(367.712, 677.44), QPointF(369.728, 677.656), QPointF(371.024, 678.52));
679     path.cubicTo(QPointF(372.32, 679.168), QPointF(373.616, 679.888), QPointF(374.912, 680.536));
680     path.closeSubpath();
681     painter->drawPath(path);
682     path = QPainterPath();
683
684     painter->setBrush(QColor(193, 193, 191, 255));
685     path.moveTo(297.44, 551.512);
686     path.cubicTo(QPointF(338.984, 572.896), QPointF(350, 611.56), QPointF(332.072, 664.192));
687     path.cubicTo(QPointF(330.992, 666.64), QPointF(334.16, 668.368), QPointF(335.24, 666.064));
688     path.cubicTo(QPointF(354.824, 610.336), QPointF(341.432, 571.312), QPointF(299.024, 548.56));
689     path.cubicTo(QPointF(296.864, 547.552), QPointF(295.28, 550.432), QPointF(297.44, 551.512));
690     path.closeSubpath();
691     painter->drawPath(path);
692     path = QPainterPath();
693
694     painter->setBrush(QColor(193, 193, 191, 255));
695     path.moveTo(72.008, 569.512);
696     path.cubicTo(QPointF(38.312, 627.256), QPointF(38.096, 662.68), QPointF(62.504, 681.328));
697     path.cubicTo(QPointF(63.728, 682.264), QPointF(64.448, 680.032), QPointF(63.296, 679.168));
698     path.cubicTo(QPointF(36.296, 655.48), QPointF(48.896, 615.52), QPointF(74.168, 570.88));
699     path.cubicTo(QPointF(74.888, 569.584), QPointF(72.512, 568.432), QPointF(72.008, 569.512));
700     path.closeSubpath();
701     painter->drawPath(path);
702     path = QPainterPath();
703
704     painter->setBrush(QColor(193, 193, 191, 255));
705     path.moveTo(289.376, 586.864);
706     path.cubicTo(QPointF(289.232, 589.168), QPointF(288.368, 589.528), QPointF(286.424, 587.368));
707     path.cubicTo(QPointF(279.8, 575.848), QPointF(235.088, 551.44), QPointF(213.344, 548.704));
708     path.cubicTo(QPointF(209.24, 547.264), QPointF(209.456, 545.392), QPointF(213.488, 544.816));
709     path.cubicTo(QPointF(229.184, 544.816), QPointF(241.28, 537.904), QPointF(254.96, 537.904));
710     path.cubicTo(QPointF(258.704, 538.048), QPointF(262.304, 539.488), QPointF(264.392, 541.648));
711     path.cubicTo(QPointF(269.504, 544.96), QPointF(288.08, 570.592), QPointF(289.376, 586.864));
712     path.closeSubpath();
713     painter->drawPath(path);
714     path = QPainterPath();
715
716     painter->setBrush(QColor(193, 193, 191, 255));
717     path.moveTo(180.152, 546.832);
718     path.cubicTo(QPointF(180.872, 550.792), QPointF(163.808, 545.68), QPointF(164.744, 556.696));
719     path.cubicTo(QPointF(165.032, 559.72), QPointF(160.496, 561.376), QPointF(160.64, 556.696));
720     path.cubicTo(QPointF(160.64, 548.272), QPointF(161.072, 548.416), QPointF(152.72, 546.832));
721     path.cubicTo(QPointF(151.208, 546.76), QPointF(151.352, 544.528), QPointF(152.72, 544.816));
722     path.lineTo(152.72, 544.816);
723     path.cubicTo(QPointF(158.696, 546.472), QPointF(166.76, 542.872), QPointF(166.4, 538.84));
724     path.cubicTo(QPointF(166.256, 537.472), QPointF(168.56, 537.688), QPointF(168.488, 538.84));
725     path.cubicTo(QPointF(167.984, 545.248), QPointF(181.664, 542.152), QPointF(180.152, 546.832));
726     path.closeSubpath();
727     painter->drawPath(path);
728     path = QPainterPath();
729
730     painter->setBrush(QColor(193, 193, 191, 255));
731     path.moveTo(151.568, 705.376);
732     path.cubicTo(QPointF(151.64, 708.328), QPointF(148.76, 707.68), QPointF(148.544, 705.592));
733     path.cubicTo(QPointF(140.192, 680.536), QPointF(143.72, 618.832), QPointF(151.856, 598.96));
734     path.cubicTo(QPointF(152.432, 596.08), QPointF(156.248, 596.944), QPointF(155.744, 598.96));
735     path.cubicTo(QPointF(147.104, 635.464), QPointF(147.248, 673.048), QPointF(151.568, 705.376));
736     path.closeSubpath();
737     painter->drawPath(path);
738     path = QPainterPath();
739
740     painter->setBrush(QColor(183, 114, 0, 255));
741     path.moveTo(51.704, 684.424);
742     path.cubicTo(QPointF(75.68, 707.824), QPointF(91.376, 743.248), QPointF(114.632, 775.288));
743     path.cubicTo(QPointF(148.472, 816.04), QPointF(121.472, 858.304), QPointF(66.464, 845.56));
744     path.cubicTo(QPointF(38.888, 835.192), QPointF(-0.784, 836.344), QPointF(-32.68, 825.832));
745     path.cubicTo(QPointF(-55.072, 820.36), QPointF(-55.864, 809.272), QPointF(-44.416, 787.6));
746     path.cubicTo(QPointF(-40.384, 773.776), QPointF(-40.024, 751.312), QPointF(-43.768, 732.592));
747     path.cubicTo(QPointF(-45.784, 718.408), QPointF(-39.232, 710.488), QPointF(-24.112, 708.832));
748     path.lineTo(-24.112, 708.832);
749     path.cubicTo(QPointF(-11.296, 708.688), QPointF(6.56, 713.872), QPointF(16.28, 686.44));
750     path.cubicTo(QPointF(23.552, 673.336), QPointF(40.976, 672.976), QPointF(51.704, 684.424));
751     path.closeSubpath();
752     painter->drawPath(path);
753     path = QPainterPath();
754
755     painter->setBrush(QColor(242, 183, 0, 255));
756     path.moveTo(24.632, 699.04);
757     path.cubicTo(QPointF(23.84, 680.968), QPointF(39.32, 677.296), QPointF(49.688, 688.312));
758     path.cubicTo(QPointF(68.192, 710.992), QPointF(85.112, 736.048), QPointF(100.376, 764.992));
759     path.cubicTo(QPointF(124.712, 804.16), QPointF(104.624, 842.68), QPointF(67.904, 828.064));
760     path.cubicTo(QPointF(49.688, 817.84), QPointF(6.128, 813.304), QPointF(-17.344, 809.128));
761     path.cubicTo(QPointF(-33.04, 807.832), QPointF(-35.128, 797.608), QPointF(-29.152, 791.848));
762     path.cubicTo(QPointF(-20.944, 782.416), QPointF(-20.08, 759.808), QPointF(-27.856, 740.512));
763     path.cubicTo(QPointF(-35.56, 728.56), QPointF(-21.088, 715.384), QPointF(-9.712, 720.856));
764     path.cubicTo(QPointF(0.8, 727.048), QPointF(25.64, 713.08), QPointF(24.632, 699.04));
765     path.closeSubpath();
766     painter->drawPath(path);
767
768     painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
769     painter->setBrush(Qt::NoBrush);
770     painter->drawRect(br.adjusted(-1, -1, 1, 1));
771 }
772
773
774 XFormWidget::XFormWidget(QWidget *parent)
775     : QWidget(parent), textEditor(new QLineEdit)
776 {
777     setWindowTitle(tr("Affine Transformations"));
778
779     view = new XFormView(this);
780     view->setMinimumSize(200, 200);
781
782     QGroupBox *mainGroup = new QGroupBox(this);
783     mainGroup->setFixedWidth(180);
784     mainGroup->setTitle(tr("Affine Transformations"));
785
786     QGroupBox *rotateGroup = new QGroupBox(mainGroup);
787     rotateGroup->setTitle(tr("Rotate"));
788     QSlider *rotateSlider = new QSlider(Qt::Horizontal, rotateGroup);
789     rotateSlider->setRange(0, 3600);
790     rotateSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
791
792     QGroupBox *scaleGroup = new QGroupBox(mainGroup);
793     scaleGroup->setTitle(tr("Scale"));
794     QSlider *scaleSlider = new QSlider(Qt::Horizontal, scaleGroup);
795     scaleSlider->setRange(1, 4000);
796     scaleSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
797
798     QGroupBox *shearGroup = new QGroupBox(mainGroup);
799     shearGroup->setTitle(tr("Shear"));
800     QSlider *shearSlider = new QSlider(Qt::Horizontal, shearGroup);
801     shearSlider->setRange(-990, 990);
802     shearSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
803
804     QGroupBox *typeGroup = new QGroupBox(mainGroup);
805     typeGroup->setTitle(tr("Type"));
806     QRadioButton *vectorType = new QRadioButton(typeGroup);
807     QRadioButton *pixmapType = new QRadioButton(typeGroup);
808     QRadioButton *textType= new QRadioButton(typeGroup);
809     vectorType->setText(tr("Vector Image"));
810     pixmapType->setText(tr("Pixmap"));
811     textType->setText(tr("Text"));
812
813     QPushButton *resetButton = new QPushButton(mainGroup);
814     resetButton->setText(tr("Reset Transform"));
815
816     QPushButton *animateButton = new QPushButton(mainGroup);
817     animateButton->setText(tr("Animate"));
818     animateButton->setCheckable(true);
819
820     QPushButton *showSourceButton = new QPushButton(mainGroup);
821     showSourceButton->setText(tr("Show Source"));
822 #ifdef QT_OPENGL_SUPPORT
823     QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
824     enableOpenGLButton->setText(tr("Use OpenGL"));
825     enableOpenGLButton->setCheckable(true);
826     enableOpenGLButton->setChecked(view->usesOpenGL());
827     if (!QGLFormat::hasOpenGL())
828         enableOpenGLButton->hide();
829 #endif
830     QPushButton *whatsThisButton = new QPushButton(mainGroup);
831     whatsThisButton->setText(tr("What's This?"));
832     whatsThisButton->setCheckable(true);
833
834     QHBoxLayout *viewLayout = new QHBoxLayout(this);
835     viewLayout->addWidget(view);
836     viewLayout->addWidget(mainGroup);
837
838     QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup);
839     rotateGroupLayout->addWidget(rotateSlider);
840
841     QVBoxLayout *scaleGroupLayout = new QVBoxLayout(scaleGroup);
842     scaleGroupLayout->addWidget(scaleSlider);
843
844     QVBoxLayout *shearGroupLayout = new QVBoxLayout(shearGroup);
845     shearGroupLayout->addWidget(shearSlider);
846
847     QVBoxLayout *typeGroupLayout = new QVBoxLayout(typeGroup);
848     typeGroupLayout->addWidget(vectorType);
849     typeGroupLayout->addWidget(pixmapType);
850     typeGroupLayout->addWidget(textType);
851     typeGroupLayout->addSpacing(4);
852     typeGroupLayout->addWidget(textEditor);
853
854     QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup);
855     mainGroupLayout->addWidget(rotateGroup);
856     mainGroupLayout->addWidget(scaleGroup);
857     mainGroupLayout->addWidget(shearGroup);
858     mainGroupLayout->addWidget(typeGroup);
859     mainGroupLayout->addStretch(1);
860     mainGroupLayout->addWidget(resetButton);
861     mainGroupLayout->addWidget(animateButton);
862     mainGroupLayout->addWidget(showSourceButton);
863 #ifdef QT_OPENGL_SUPPORT
864     mainGroupLayout->addWidget(enableOpenGLButton);
865 #endif
866     mainGroupLayout->addWidget(whatsThisButton);
867
868     connect(rotateSlider, SIGNAL(valueChanged(int)), view, SLOT(changeRotation(int)));
869     connect(shearSlider, SIGNAL(valueChanged(int)), view, SLOT(changeShear(int)));
870     connect(scaleSlider, SIGNAL(valueChanged(int)), view, SLOT(changeScale(int)));
871
872     connect(vectorType, SIGNAL(clicked()), view, SLOT(setVectorType()));
873     connect(pixmapType, SIGNAL(clicked()), view, SLOT(setPixmapType()));
874     connect(textType, SIGNAL(clicked()), view, SLOT(setTextType()));
875     connect(textType, SIGNAL(toggled(bool)), textEditor, SLOT(setEnabled(bool)));
876     connect(textEditor, SIGNAL(textChanged(QString)), view, SLOT(setText(QString)));
877
878     connect(view, SIGNAL(rotationChanged(int)), rotateSlider, SLOT(setValue(int)));
879     connect(view, SIGNAL(scaleChanged(int)), scaleSlider, SLOT(setValue(int)));
880     connect(view, SIGNAL(shearChanged(int)), shearSlider, SLOT(setValue(int)));
881
882     connect(resetButton, SIGNAL(clicked()), view, SLOT(reset()));
883     connect(animateButton, SIGNAL(clicked(bool)), view, SLOT(setAnimation(bool)));
884     connect(whatsThisButton, SIGNAL(clicked(bool)), view, SLOT(setDescriptionEnabled(bool)));
885     connect(whatsThisButton, SIGNAL(clicked(bool)), view->hoverPoints(), SLOT(setDisabled(bool)));
886     connect(view, SIGNAL(descriptionEnabledChanged(bool)), view->hoverPoints(), SLOT(setDisabled(bool)));
887     connect(view, SIGNAL(descriptionEnabledChanged(bool)), whatsThisButton, SLOT(setChecked(bool)));
888     connect(showSourceButton, SIGNAL(clicked()), view, SLOT(showSource()));
889 #ifdef QT_OPENGL_SUPPORT
890     connect(enableOpenGLButton, SIGNAL(clicked(bool)), view, SLOT(enableOpenGL(bool)));
891 #endif
892     view->loadSourceFile(":res/affine/xform.cpp");
893     view->loadDescription(":res/affine/xform.html");
894
895     // defaults
896     view->reset();
897     vectorType->setChecked(true);
898     textEditor->setText("Qt Affine Transformation Demo");
899     textEditor->setEnabled(false);
900
901     animateButton->animateClick();
902 }