|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HGTRANSFORMEDQUAD_H |
|
19 #define HGTRANSFORMEDQUAD_H |
|
20 |
|
21 #include <qvector2d> |
|
22 |
|
23 class HgQuad; |
|
24 class QMatrix4x4; |
|
25 class QPointF; |
|
26 class QSizeF; |
|
27 class QPolygonF; |
|
28 class QPainter; |
|
29 |
|
30 /** |
|
31 * Base class for transformed quads, to be used by renderers. |
|
32 */ |
|
33 class HgTransformedQuad |
|
34 { |
|
35 public: |
|
36 HgTransformedQuad(qreal yDir=1); |
|
37 virtual ~HgTransformedQuad(); |
|
38 |
|
39 int index() const; |
|
40 |
|
41 bool isPointInside(const QPointF& point) const; |
|
42 |
|
43 void transformQuad(int index, const QMatrix4x4& projView, HgQuad* quad, |
|
44 qreal mirroringPlaneY, const QVector2D& translate, const QPointF& center, |
|
45 const QSizeF& windowSize); |
|
46 |
|
47 void getTransformedPoints(QPolygonF& poly) const; |
|
48 |
|
49 HgQuad* quad() const; |
|
50 |
|
51 virtual void draw(QPainter* painter, const QRectF& rect)=0; |
|
52 |
|
53 static bool quadSorter(HgTransformedQuad* a, HgTransformedQuad* b); |
|
54 |
|
55 protected: |
|
56 |
|
57 void computeMirroredPoints(const QMatrix4x4& trans, const QMatrix4x4& projView, |
|
58 qreal mirroringPlaneY, const QVector2D& translate, const QPointF& center, |
|
59 const QSizeF& windowSize); |
|
60 |
|
61 void perspectiveTransformPoints(QVector2D* outPoints, const QMatrix4x4& matrix, |
|
62 const QPointF& center, const QSizeF& windowSize); |
|
63 |
|
64 protected: |
|
65 int mIndex; |
|
66 HgQuad* mQuad; |
|
67 QVector2D mTransformedPoints[4]; |
|
68 QVector2D mMirroredPoints[4]; |
|
69 qreal mYDir; |
|
70 }; |
|
71 |
|
72 #endif |