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
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2003 by Leon Pennington
email : leon@leonscape.co.uk
**************************************************************************
**************************************************************************
* *
* 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 "pmradiosityedit.h"
#include "pmradiosity.h"
#include "pmlineedits.h"
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <klocale.h>
#include <kdialog.h>
#include <kmessagebox.h>
PMRadiosityEdit::PMRadiosityEdit( TQWidget* parent, const char* name )
: Base( parent, name )
{
m_pDisplayedObject = 0;
}
void PMRadiosityEdit::createTopWidgets( )
{
TQHBoxLayout* hl;
TQGridLayout *gl;
TQLabel* lbl;
Base::createTopWidgets( );
hl = new TQHBoxLayout( topLayout( ) );
gl = new TQGridLayout( hl, 15, 2 );
lbl = new TQLabel( i18n( "Adc bailout:" ), this );
m_pAdcBailout = new PMFloatEdit( this );
m_pAdcBailout->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 0, 0 );
gl->addWidget( m_pAdcBailout, 0, 1 );
m_pAlwaysSample = new TQCheckBox( i18n( "Always sample" ), this );
gl->addMultiCellWidget( m_pAlwaysSample, 1, 1, 0, 1 );
lbl = new TQLabel( i18n( "Brightness:" ), this );
m_pBrightness = new PMFloatEdit( this );
m_pBrightness->setValidation( true, 0, false, 0 );
gl->addWidget( lbl, 2, 0 );
gl->addWidget( m_pBrightness, 2, 1 );
lbl = new TQLabel( i18n( "Count:" ), this );
m_pCount = new PMIntEdit( this );
m_pCount->setValidation( true, 0, true, 1600 );
gl->addWidget( lbl, 3, 0 );
gl->addWidget( m_pCount, 3, 1 );
lbl = new TQLabel( i18n( "Error boundary:" ), this );
m_pErrorBound = new PMFloatEdit( this );
m_pErrorBound->setValidation( true, 0, false, 0 );
gl->addWidget( lbl, 4, 0 );
gl->addWidget( m_pErrorBound, 4, 1 );
lbl = new TQLabel( i18n( "Gray threshold:" ), this );
m_pGrayThreshold = new PMFloatEdit( this );
m_pGrayThreshold->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 5, 0 );
gl->addWidget( m_pGrayThreshold, 5, 1 );
lbl = new TQLabel( i18n( "Low error factor:" ), this );
m_pLowErrorFactor = new PMFloatEdit( this );
m_pLowErrorFactor->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 6, 0 );
gl->addWidget( m_pLowErrorFactor, 6, 1 );
lbl = new TQLabel( i18n( "Maximum sample:" ), this );
m_pMaxSample = new PMFloatEdit( this );
m_pMaxSample->setValidation( true, -1, false, 0 );
gl->addWidget( lbl, 7, 0 );
gl->addWidget( m_pMaxSample, 7, 1 );
m_pMedia = new TQCheckBox( i18n( "Media" ), this );
gl->addMultiCellWidget( m_pMedia, 8, 8, 0, 1 );
lbl = new TQLabel( i18n( "Minimum reuse:" ), this );
m_pMinimumReuse = new PMFloatEdit( this );
m_pMinimumReuse->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 9, 0 );
gl->addWidget( m_pMinimumReuse, 9, 1 );
lbl = new TQLabel( i18n( "Nearest count:" ), this );
m_pNearestCount = new PMIntEdit( this );
m_pNearestCount->setValidation( true, 0, true, 20 );
gl->addWidget( lbl, 10, 0 );
gl->addWidget( m_pNearestCount, 10, 1 );
m_pNormal = new TQCheckBox( i18n( "Normal" ), this );
gl->addMultiCellWidget( m_pNormal, 11, 11, 0, 1 );
lbl = new TQLabel( i18n( "Pretrace start:" ), this );
m_pPretraceStart = new PMFloatEdit( this );
m_pPretraceStart->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 12, 0 );
gl->addWidget( m_pPretraceStart, 12, 1 );
lbl = new TQLabel( i18n( "Pretrace end:" ), this );
m_pPretraceEnd = new PMFloatEdit( this );
m_pPretraceEnd->setValidation( true, 0, true, 1 );
gl->addWidget( lbl, 13, 0 );
gl->addWidget( m_pPretraceEnd, 13, 1 );
lbl = new TQLabel( i18n( "Recursion limit:" ), this );
m_pRecursionLimit = new PMIntEdit( this );
m_pRecursionLimit->setValidation( true, 1, true, 20 );
gl->addWidget( lbl, 14, 0 );
gl->addWidget( m_pRecursionLimit, 14, 1 );
hl->addStretch( 1 );
connect( m_pAdcBailout, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pAlwaysSample, TQT_SIGNAL( clicked( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pBrightness, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pCount, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pErrorBound, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pGrayThreshold, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pLowErrorFactor, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pMaxSample, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pMedia, TQT_SIGNAL( clicked( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pMinimumReuse, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pNearestCount, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pNormal, TQT_SIGNAL( clicked( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pPretraceStart, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pPretraceEnd, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
connect( m_pRecursionLimit, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
}
void PMRadiosityEdit::displayObject( PMObject* o )
{
if( o->isA( "Radiosity" ) )
{
bool readOnly = o->isReadOnly( );
m_pDisplayedObject = ( PMRadiosity* ) o;
m_pAdcBailout->setValue( m_pDisplayedObject->adcBailout( ) );
m_pAdcBailout->setReadOnly( readOnly );
m_pAlwaysSample->setChecked( m_pDisplayedObject->alwaysSample( ) );
m_pAlwaysSample->setEnabled( !readOnly );
m_pBrightness->setValue( m_pDisplayedObject->brightness( ) );
m_pBrightness->setReadOnly( readOnly );
m_pCount->setValue( m_pDisplayedObject->count( ) );
m_pCount->setReadOnly( readOnly );
m_pErrorBound->setValue( m_pDisplayedObject->errorBound( ) );
m_pErrorBound->setReadOnly( readOnly );
m_pGrayThreshold->setValue( m_pDisplayedObject->grayThreshold( ) );
m_pGrayThreshold->setReadOnly( readOnly );
m_pLowErrorFactor->setValue( m_pDisplayedObject->lowErrorFactor( ) );
m_pLowErrorFactor->setReadOnly( readOnly );
m_pMaxSample->setValue( m_pDisplayedObject->maxSample( ) );
m_pMaxSample->setReadOnly( readOnly );
m_pMedia->setChecked( m_pDisplayedObject->media( ) );
m_pMedia->setEnabled( !readOnly );
m_pMinimumReuse->setValue( m_pDisplayedObject->minimumReuse( ) );
m_pMinimumReuse->setReadOnly( readOnly );
m_pNearestCount->setValue( m_pDisplayedObject->nearestCount( ) );
m_pNearestCount->setReadOnly( readOnly );
m_pNormal->setChecked( m_pDisplayedObject->normal( ) );
m_pNormal->setEnabled( !readOnly );
m_pPretraceStart->setValue( m_pDisplayedObject->pretraceStart( ) );
m_pPretraceStart->setReadOnly( readOnly );
m_pPretraceEnd->setValue( m_pDisplayedObject->pretraceEnd( ) );
m_pPretraceEnd->setReadOnly( readOnly );
m_pRecursionLimit->setValue( m_pDisplayedObject->recursionLimit( ) );
m_pRecursionLimit->setReadOnly( readOnly );
Base::displayObject( o );
}
else
kdError( PMArea ) << "PMRadiosityEdit: Can't display object\n";
}
void PMRadiosityEdit::saveContents( )
{
if( m_pDisplayedObject )
{
Base::saveContents( );
m_pDisplayedObject->setAdcBailout( m_pAdcBailout->value( ) );
m_pDisplayedObject->setAlwaysSample( m_pAlwaysSample->isChecked( ) );
m_pDisplayedObject->setBrightness( m_pBrightness->value( ) );
m_pDisplayedObject->setCount( m_pCount->value( ) );
m_pDisplayedObject->setErrorBound( m_pErrorBound->value( ) );
m_pDisplayedObject->setGrayThreshold( m_pGrayThreshold->value( ) );
m_pDisplayedObject->setLowErrorFactor( m_pLowErrorFactor->value( ) );
m_pDisplayedObject->setMaxSample( m_pMaxSample->value( ) );
m_pDisplayedObject->setMedia( m_pMedia->isChecked( ) );
m_pDisplayedObject->setMinimumReuse( m_pMinimumReuse->value( ) );
m_pDisplayedObject->setNearestCount( m_pNearestCount->value( ) );
m_pDisplayedObject->setNormal( m_pNormal->isChecked( ) );
m_pDisplayedObject->setPretraceStart( m_pPretraceStart->value( ) );
m_pDisplayedObject->setPretraceEnd( m_pPretraceEnd->value( ) );
m_pDisplayedObject->setRecursionLimit( m_pRecursionLimit->value( ) );
}
}
bool PMRadiosityEdit::isDataValid( )
{
if( !m_pAdcBailout->isDataValid( ) ) return false;
if( !m_pBrightness->isDataValid( ) ) return false;
if( !m_pCount->isDataValid( ) ) return false;
if( !m_pErrorBound->isDataValid( ) ) return false;
if( !m_pGrayThreshold->isDataValid( ) ) return false;
if( !m_pLowErrorFactor->isDataValid( ) ) return false;
if( !m_pMaxSample->isDataValid( ) ) return false;
if( !m_pMinimumReuse->isDataValid( ) ) return false;
if( !m_pNearestCount->isDataValid( ) ) return false;
if( !m_pPretraceStart->isDataValid( ) ) return false;
if( !m_pPretraceEnd->isDataValid( ) ) return false;
if( !m_pRecursionLimit->isDataValid( ) ) return false;
return Base::isDataValid( );
}
#include "pmradiosityedit.moc"
|