-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtransform.cpp
More file actions
73 lines (57 loc) · 2.25 KB
/
transform.cpp
File metadata and controls
73 lines (57 loc) · 2.25 KB
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
#include "transform.h"
Transform::Transform()
{
// translate = QPointF(0,0);
// rotation.angle = 0;
// matrix.isSet = false;
}
QList<AbstractTransform*> Transform::getTransforms(QString transform)
{
// translate = QPointF(0,0);
// rotation.angle = 0;
// matrix.isSet = false;
QStringList cmds = transform.split(")");
foreach(QString cmd, cmds)
{
cmd = cmd.simplified();
if(cmd.contains("translate"))
{
QString translateStr = cmd.mid( cmd.indexOf("(")+1, cmd.indexOf(")")-1 );
translateStr.replace(",", " ");
QStringList numStr = translateStr.split(" ");
Translate *trans = new Translate( QPointF( numStr[0].toDouble(), numStr[1].toDouble()) );
trList.push_back( trans );
}
else if(cmd.contains("rotate"))
{
QString rotateStr = cmd.mid( cmd.indexOf("(")+1, cmd.indexOf(")")-1 );
rotateStr = rotateStr.simplified();
QStringList numStr = rotateStr.split( "," );
RotationTransform *rotation = new RotationTransform(0, QPointF());
rotation->angle = numStr.at(0).toDouble();
if(numStr.size() > 1)
{
rotation->center = QPointF(numStr[1].toDouble() , numStr[2].toDouble());
}
trList.push_back( rotation );
}
else if(cmd.contains("matrix"))
{
QString matrixStr = cmd.mid( cmd.indexOf("(")+1, cmd.indexOf(")")-1 );
matrixStr = matrixStr.simplified();
QStringList numStr = matrixStr.split( "," );
Matrix3x3 *matrix = new Matrix3x3();
matrix->m11 = numStr[0].toDouble();
matrix->m21 = numStr[1].toDouble();
matrix->m12 = numStr[2].toDouble();
matrix->m22 = numStr[3].toDouble();
matrix->m13 = numStr[4].toDouble();
matrix->m23 = numStr[5].toDouble();
matrix->isSet = true;
trList.push_back( matrix );
/*qDebug() << "matrix: " << matrix.m11 << matrix.m21 << matrix.m12 << matrix.m22
<< matrix.m13 << matrix.m23;*/
}
}
return trList;
}