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
88
89
90
91
92
93
94
95
96
97
|
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <iostream>
#include "wmfcontext.h"
using namespace std;
WMFGraphicsState::WMFGraphicsState(void)
: windowOrg(0.0, 0.0),
windowExt(1.0, 1.0),
viewportOrg(0.0, 0.0),
viewportExt(1.0, 1.0),
position (0.0, 0.0),
backgroundMode(Qt::TransparentMode),
textAlign(0),
textCharset(1), //DEFAULT_CHARSET
textRotation(0),
windingFill(false)
{
}
void WMFGraphicsState::setWindowOrg(double x, double y)
{
windowOrg = QPointF(x, y);
updateWorldMatrix();
}
void WMFGraphicsState::setWindowExt(double x, double y)
{
windowExt = QSizeF(x, y);
updateWorldMatrix();
}
void WMFGraphicsState::setViewportOrg(double x, double y)
{
viewportOrg = QPointF(x, y);
updateWorldMatrix();
}
void WMFGraphicsState::setViewportExt(double x, double y)
{
viewportExt = QSizeF(x, y);
updateWorldMatrix();
}
void WMFGraphicsState::updateWorldMatrix(void)
{
double xscale = (windowExt.width() != 0.0) ? (viewportExt.width() / windowExt.width()) : 1.0;
double yscale = (windowExt.height() != 0.0) ? (viewportExt.height() / windowExt.height()) : 1.0;
double dx = viewportOrg.x() - xscale * windowOrg.x();
double dy = viewportOrg.y() - yscale * windowOrg.y();
worldMatrix.setMatrix( xscale, 0, 0, yscale, dx, dy );
}
WMFContext::WMFContext(void)
{
push( WMFGraphicsState() ) ;
}
void WMFContext::save(void)
{
if ( this->count() > 0 )
push( WMFGraphicsState(top()) );
else
{
cerr << "WMFContext : unexpected save call" << endl;
}
}
void WMFContext::restore(void)
{
if ( this->count() > 1 )
pop();
else
{
cerr << "WMFContext : unexpected restore call" << endl;
}
}
void WMFContext::reset(void)
{
clear();
push( WMFGraphicsState() ) ;
}
WMFGraphicsState& WMFContext::current(void)
{
if ( this->count() <= 0 )
push( WMFGraphicsState() ) ;
return top();
}
|