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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2001 by Andreas Zehender
email : zehender@kde.org
**************************************************************************
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#include "pmrendermode.h"
#include <klocale.h>
#include "pmxmlhelper.h"
PMRenderMode::PMRenderMode( )
{
init( );
}
void PMRenderMode::init( )
{
m_width = 640;
m_height = 480;
m_subSection = false;
m_startRow = 1;
m_endRow = m_height;
m_startColumn = 1;
m_endColumn = m_width;
m_quality = 9;
m_radiosity = false;
m_antialiasing = false;
m_samplingMethod = AntialiasingNonRecursive;
m_antialiasThreshold = 0.3;
m_antialiasJitter = false;
m_antialiasJitterAmount = 1.0;
m_antialiasDepth = 2;
m_description = i18n( "New mode" );
m_alpha = false;
}
PMRenderMode::PMRenderMode( const QDomElement& e )
{
init( );
PMXMLHelper hlp( e, 0, 0, 0, 0 );
m_description = hlp.stringAttribute( "description", m_description );
m_height = hlp.intAttribute( "height", m_height );
m_width = hlp.intAttribute( "width", m_width );
m_subSection = hlp.boolAttribute( "subsection", m_subSection );
m_startColumn = hlp.doubleAttribute( "start_column", m_startColumn );
m_endColumn = hlp.doubleAttribute( "end_column", m_endColumn );
m_startRow = hlp.doubleAttribute( "start_row", m_startRow );
m_endRow = hlp.doubleAttribute( "end_row", m_endRow );
m_quality = hlp.intAttribute( "quality", m_quality );
m_radiosity = hlp.boolAttribute( "radiosity", m_radiosity );
m_antialiasing = hlp.boolAttribute( "antialiasing", m_antialiasing );
m_samplingMethod = hlp.intAttribute( "sampling_method", m_samplingMethod );
m_antialiasThreshold = hlp.doubleAttribute( "aa_threshold", m_antialiasThreshold );
m_antialiasJitter = hlp.boolAttribute( "aa_jitter", m_antialiasJitter );
m_antialiasJitterAmount = hlp.doubleAttribute( "aa_jitter_amount", m_antialiasJitterAmount );
m_antialiasDepth = hlp.intAttribute( "aa_depth", m_antialiasDepth );
m_alpha = hlp.boolAttribute( "alpha", m_alpha );
}
void PMRenderMode::serialize( QDomElement& e ) const
{
e.setAttribute( "description", m_description );
e.setAttribute( "height", m_height );
e.setAttribute( "width", m_width );
e.setAttribute( "subsection", m_subSection );
e.setAttribute( "start_row", m_startRow );
e.setAttribute( "end_row", m_endRow );
e.setAttribute( "start_column", m_startColumn );
e.setAttribute( "end_column", m_endColumn );
e.setAttribute( "quality", m_quality );
e.setAttribute( "radiosity", m_radiosity );
e.setAttribute( "antialiasing", m_antialiasing );
e.setAttribute( "sampling_method", m_samplingMethod );
e.setAttribute( "aa_threshold", m_antialiasThreshold );
e.setAttribute( "aa_jitter", m_antialiasJitter );
e.setAttribute( "aa_jitter_amount", m_antialiasJitterAmount );
e.setAttribute( "aa_depth", m_antialiasDepth );
e.setAttribute( "alpha", m_alpha );
}
void PMRenderMode::setHeight( int height )
{
if( height >= 1 )
m_height = height;
}
void PMRenderMode::setWidth( int width )
{
if( width >= 1 )
m_width = width;
}
void PMRenderMode::setStartRow( double startRow )
{
if( startRow >= 0 )
m_startRow = startRow;
}
void PMRenderMode::setEndRow( double endRow )
{
if( endRow >= 0 )
m_endRow = endRow;
}
void PMRenderMode::setStartColumn( double startColumn )
{
if( startColumn >= 0 )
m_startColumn = startColumn;
}
void PMRenderMode::setEndColumn( double endColumn )
{
if( endColumn >= 0 )
m_endColumn = endColumn;
}
void PMRenderMode::setQuality( int quality )
{
if( ( quality >= 0 ) && ( quality <= 11 ) )
m_quality = quality;
}
void PMRenderMode::setAntialiasingDepth( int depth )
{
if( ( depth >= 1 ) && ( depth <= 9 ) )
m_antialiasDepth = depth;
}
void PMRenderMode::setSamplingMethod( int method )
{
if( ( method == AntialiasingNonRecursive )
|| ( method == AntialiasingRecursive ) )
m_samplingMethod = method;
else
m_samplingMethod = AntialiasingNonRecursive;
}
QStringList PMRenderMode::commandLineSwitches( ) const
{
QStringList cl;
QString tmp;
cl.append( QString( "+W%1" ).arg( m_width ) );
cl.append( QString( "+H%1" ).arg( m_height ) );
if( m_subSection )
{
if( m_startRow < 1.0 )
tmp.sprintf( "+SR%4.2f", m_startRow );
else
tmp = QString( "+SR%1" ).arg( ( int ) ( m_startRow + 0.5 ) );
cl.append( tmp );
if( m_endRow < 1.0 )
tmp.sprintf( "+ER%4.2f", m_endRow );
else
tmp = QString( "+ER%1" ).arg( ( int ) ( m_endRow + 0.5 ) );
cl.append( tmp );
if( m_startColumn < 1.0 )
tmp.sprintf( "+SC%4.2f", m_startColumn );
else
tmp = QString( "+SC%1" ).arg( ( int ) ( m_startColumn + 0.5 ) );
cl.append( tmp );
if( m_endColumn < 1.0 )
tmp.sprintf( "+EC%4.2f", m_endColumn );
else
tmp = QString( "+EC%1" ).arg( ( int ) ( m_endColumn + 0.5 ) );
cl.append( tmp );
}
cl.append( QString( "+Q%1" ).arg( m_quality ) );
if( m_radiosity )
cl.append( QString( "+QR" ) );
else
cl.append( QString( "-QR" ) );
if( m_antialiasing )
{
cl.append( QString( "+A" ) );
cl.append( QString( "+AM%1" ).arg( m_samplingMethod ) );
tmp.sprintf( "+A%5.3f", m_antialiasThreshold );
cl.append( tmp );
if( m_antialiasJitter )
{
tmp.sprintf( "+J%5.3f", m_antialiasJitterAmount );
cl.append( tmp );
}
else
cl.append( QString( "-J" ) );
cl.append( QString( "+R%1" ).arg( m_antialiasDepth ) );
}
else
cl.append( QString( "-A" ) );
if( m_alpha )
cl.append( QString( "+UA" ) );
else
cl.append( QString( "-UA" ) );
return cl;
}
|