23
23
#include < QByteArray>
24
24
25
25
QgsRasterPipe::QgsRasterPipe ()
26
- : mProvider( 0 )
27
- , mRenderer( 0 )
28
- , mResampleFilter( 0 )
29
- , mProjector( 0 )
30
26
{
31
27
}
32
28
33
29
QgsRasterPipe::~QgsRasterPipe ()
34
30
{
35
- foreach ( QgsRasterInterface* filter, mFilters )
31
+ foreach ( QgsRasterInterface* interface, mInterfaces )
36
32
{
37
- delete filter ;
33
+ delete interface ;
38
34
}
39
35
}
40
36
41
- bool QgsRasterPipe::connectFilters ( QVector<QgsRasterInterface*> theFilters )
37
+ bool QgsRasterPipe::connect ( QVector<QgsRasterInterface*> theInterfaces )
42
38
{
43
39
QgsDebugMsg ( " Entered" );
44
- for ( int i = 1 ; i < theFilters .size (); i++ )
40
+ for ( int i = 1 ; i < theInterfaces .size (); i++ )
45
41
{
46
- if ( ! theFilters [i]->setInput ( theFilters [i-1 ] ) )
42
+ if ( ! theInterfaces [i]->setInput ( theInterfaces [i-1 ] ) )
47
43
{
48
- QgsDebugMsg ( QString ( " cannot connect %1 to %2" ).arg ( typeid ( *( theFilters [i] ) ).name () ).arg ( typeid ( *( theFilters [i-1 ] ) ).name () ) );
44
+ QgsDebugMsg ( QString ( " cannot connect %1 to %2" ).arg ( typeid ( *( theInterfaces [i] ) ).name () ).arg ( typeid ( *( theInterfaces [i-1 ] ) ).name () ) );
49
45
return false ;
50
46
}
51
47
}
52
48
return true ;
53
49
}
54
50
55
- bool QgsRasterPipe::insert ( int idx, QgsRasterInterface* theFilter )
51
+ bool QgsRasterPipe::insert ( int idx, QgsRasterInterface* theInterface )
56
52
{
57
- QgsDebugMsg ( QString ( " insert %1 at %2" ).arg ( typeid ( *theFilter ).name () ).arg ( idx ) );
58
- if ( idx > mFilters .size () )
53
+ QgsDebugMsg ( QString ( " insert %1 at %2" ).arg ( typeid ( *theInterface ).name () ).arg ( idx ) );
54
+ if ( idx > mInterfaces .size () )
59
55
{
60
- idx = mFilters .size ();
56
+ idx = mInterfaces .size ();
61
57
}
62
58
// make a copy of pipe to test connection, we test the connections
63
59
// of the whole pipe, because the types and band numbers may change
64
- QVector<QgsRasterInterface*> filters = mFilters ;
60
+ QVector<QgsRasterInterface*> interfaces = mInterfaces ;
65
61
66
- filters .insert ( idx, theFilter );
62
+ interfaces .insert ( idx, theInterface );
67
63
bool success = false ;
68
- if ( connectFilters ( filters ) )
64
+ if ( connect ( interfaces ) )
69
65
{
70
66
success = true ;
71
- mFilters .insert ( idx, theFilter );
72
- setRole ( theFilter , idx );
67
+ mInterfaces .insert ( idx, theInterface );
68
+ setRole ( theInterface , idx );
73
69
QgsDebugMsg ( " inserted ok" );
74
70
}
75
71
76
- // Connect or reconnect (after the test) filters
77
- connectFilters ( mFilters );
72
+ // Connect or reconnect (after the test) interfaces
73
+ connect ( mInterfaces );
78
74
return success;
79
75
}
80
76
81
- bool QgsRasterPipe::replace ( int idx, QgsRasterInterface* theFilter )
77
+ bool QgsRasterPipe::replace ( int idx, QgsRasterInterface* theInterface )
82
78
{
83
- QgsDebugMsg ( QString ( " replace by %1 at %2" ).arg ( typeid ( *theFilter ).name () ).arg ( idx ) );
84
- if ( idx < 0 || idx >= mFilters .size () )
79
+ QgsDebugMsg ( QString ( " replace by %1 at %2" ).arg ( typeid ( *theInterface ).name () ).arg ( idx ) );
80
+ if ( idx < 0 || idx >= mInterfaces .size () )
85
81
{
86
82
return false ;
87
83
}
88
- if ( !theFilter ) return false ;
84
+ if ( !theInterface ) return false ;
89
85
90
86
// make a copy of pipe to test connection, we test the connections
91
87
// of the whole pipe, because the types and band numbers may change
92
- QVector<QgsRasterInterface*> filters = mFilters ;
88
+ QVector<QgsRasterInterface*> interfaces = mInterfaces ;
93
89
94
- filters [idx] = theFilter ;
90
+ interfaces [idx] = theInterface ;
95
91
bool success = false ;
96
- if ( connectFilters ( filters ) )
92
+ if ( connect ( interfaces ) )
97
93
{
98
94
success = true ;
99
- delete mFilters [idx];
100
- mFilters [idx] = theFilter ;
101
- setRole ( theFilter , idx );
95
+ delete mInterfaces [idx];
96
+ mInterfaces [idx] = theInterface ;
97
+ setRole ( theInterface , idx );
102
98
QgsDebugMsg ( " replaced ok" );
103
99
}
104
100
105
- // Connect or reconnect (after the test) filters
106
- connectFilters ( mFilters );
101
+ // Connect or reconnect (after the test) interfaces
102
+ connect ( mInterfaces );
107
103
return success;
108
104
}
109
105
110
- QgsRasterPipe::Role QgsRasterPipe::filterRole ( QgsRasterInterface * filter ) const
106
+ QgsRasterPipe::Role QgsRasterPipe::interfaceRole ( QgsRasterInterface * interface ) const
111
107
{
112
- if ( dynamic_cast <QgsRasterDataProvider *>( filter ) ) return ProviderRole;
113
- if ( dynamic_cast <QgsRasterRenderer *>( filter ) ) return RendererRole;
114
- if ( dynamic_cast <QgsRasterResampleFilter *>( filter ) ) return ResamplerRole;
115
- if ( dynamic_cast <QgsRasterProjector *>( filter ) ) return ProjectorRole;
108
+ if ( dynamic_cast <QgsRasterDataProvider *>( interface ) ) return ProviderRole;
109
+ if ( dynamic_cast <QgsRasterRenderer *>( interface ) ) return RendererRole;
110
+ if ( dynamic_cast <QgsRasterResampleFilter *>( interface ) ) return ResamplerRole;
111
+ if ( dynamic_cast <QgsRasterProjector *>( interface ) ) return ProjectorRole;
116
112
return UnknownRole;
117
113
}
118
114
119
- void QgsRasterPipe::setRole ( QgsRasterInterface * theFilter , int idx )
115
+ void QgsRasterPipe::setRole ( QgsRasterInterface * theInterface , int idx )
120
116
{
121
- Role role = filterRole ( theFilter );
117
+ Role role = interfaceRole ( theInterface );
122
118
if ( role == UnknownRole ) return ;
123
119
mRoleMap .insert ( role, idx );
124
120
}
125
121
126
- void QgsRasterPipe::unsetRole ( QgsRasterInterface * theFilter )
122
+ void QgsRasterPipe::unsetRole ( QgsRasterInterface * theInterface )
127
123
{
128
- Role role = filterRole ( theFilter );
124
+ Role role = interfaceRole ( theInterface );
129
125
if ( role == UnknownRole ) return ;
130
126
mRoleMap .remove ( role );
131
127
}
132
128
133
- bool QgsRasterPipe::setFilter ( QgsRasterInterface* theFilter )
129
+ bool QgsRasterPipe::set ( QgsRasterInterface* theInterface )
134
130
{
135
- QgsDebugMsg ( QString ( " %1" ).arg ( typeid ( *theFilter ).name () ) );
131
+ QgsDebugMsg ( QString ( " %1" ).arg ( typeid ( *theInterface ).name () ) );
136
132
137
- if ( !theFilter ) return false ;
133
+ if ( !theInterface ) return false ;
138
134
139
- QgsRasterDataProvider * provider = dynamic_cast <QgsRasterDataProvider *>( theFilter );
135
+ QgsRasterDataProvider * provider = dynamic_cast <QgsRasterDataProvider *>( theInterface );
140
136
QgsRasterRenderer * renderer;
141
137
QgsRasterResampleFilter * resampleFilter;
142
138
QgsRasterProjector * projector;
143
139
144
- Role role = filterRole ( theFilter );
140
+ Role role = interfaceRole ( theInterface );
145
141
146
- // We dont know where to place unknown filter
142
+ // We dont know where to place unknown interface
147
143
if ( role == UnknownRole ) return false ;
148
144
149
- // if ( mFiltersMap .value ( role ) )
145
+ // if ( mInterfacesMap .value ( role ) )
150
146
if ( mRoleMap .contains ( role ) )
151
147
{
152
- // An old filter of the same role exists -> replace
148
+ // An old interface of the same role exists -> replace
153
149
// replace may still fail and return false
154
- return replace ( mRoleMap .value ( role ), theFilter );
150
+ return replace ( mRoleMap .value ( role ), theInterface );
155
151
}
156
152
157
153
int idx = 0 ;
158
154
159
- // Not found, find the best default position for this kind of filter
155
+ // Not found, find the best default position for this kind of interface
160
156
// QgsRasterDataProvider - ProviderRole
161
157
// QgsRasterRenderer - RendererRole
162
158
// QgsRasterResampler - ResamplerRole
@@ -183,71 +179,71 @@ bool QgsRasterPipe::setFilter( QgsRasterInterface* theFilter )
183
179
idx = qMax ( qMax ( providerIdx, rendererIdx ), resamplerIdx ) + 1 ;
184
180
}
185
181
186
- return insert ( idx, theFilter ); // insert may still fail and return false
182
+ return insert ( idx, theInterface ); // insert may still fail and return false
187
183
}
188
184
189
- QgsRasterInterface * QgsRasterPipe::filter ( Role role ) const
190
- {
191
- QgsDebugMsg ( QString ( " role = %1" ).arg ( role ) );
192
- if ( mRoleMap .contains ( role ) )
185
+ QgsRasterInterface * QgsRasterPipe::interface ( Role role ) const
193
186
{
194
- return mFilters .value ( mRoleMap .value ( role ) );
187
+ QgsDebugMsg ( QString ( " role = %1" ).arg ( role ) );
188
+ if ( mRoleMap .contains ( role ) )
189
+ {
190
+ return mInterfaces .value ( mRoleMap .value ( role ) );
191
+ }
192
+ return 0 ;
195
193
}
196
- return 0 ;
197
- }
198
194
199
195
QgsRasterDataProvider * QgsRasterPipe::provider () const
200
196
{
201
- return dynamic_cast <QgsRasterDataProvider *>( filter ( ProviderRole ) );
197
+ return dynamic_cast <QgsRasterDataProvider *>( interface ( ProviderRole ) );
202
198
}
203
199
204
200
QgsRasterRenderer * QgsRasterPipe::renderer () const
205
201
{
206
- return dynamic_cast <QgsRasterRenderer *>( filter ( RendererRole ) );
202
+ return dynamic_cast <QgsRasterRenderer *>( interface ( RendererRole ) );
207
203
}
208
204
209
205
QgsRasterResampleFilter * QgsRasterPipe::resampleFilter () const
210
206
{
211
- return dynamic_cast <QgsRasterResampleFilter *>( filter ( ResamplerRole ) );
207
+ return dynamic_cast <QgsRasterResampleFilter *>( interface ( ResamplerRole ) );
212
208
}
213
209
214
210
QgsRasterProjector * QgsRasterPipe::projector () const
215
211
{
216
- return dynamic_cast <QgsRasterProjector*>( filter ( ProjectorRole ) );
212
+ return dynamic_cast <QgsRasterProjector*>( interface ( ProjectorRole ) );
217
213
}
218
214
219
215
bool QgsRasterPipe::remove ( int idx )
220
216
{
221
217
QgsDebugMsg ( QString ( " remove at %1" ).arg ( idx ) );
222
218
223
- if ( idx < 0 || idx >= mFilters .size () )
219
+ if ( idx < 0 || idx >= mInterfaces .size () )
224
220
{
225
221
return false ;
226
222
}
227
223
228
224
// make a copy of pipe to test connection, we test the connections
229
225
// of the whole pipe, because the types and band numbers may change
230
- QVector<QgsRasterInterface*> filters = mFilters ;
226
+ QVector<QgsRasterInterface*> interfaces = mInterfaces ;
231
227
232
- filters .remove ( idx );
228
+ interfaces .remove ( idx );
233
229
bool success = false ;
234
- if ( connectFilters ( filters ) )
230
+ if ( connect ( interfaces ) )
235
231
{
236
232
success = true ;
237
- unsetRole ( mFilters [idx] );
238
- delete mFilters [idx];
239
- mFilters .remove ( idx );
233
+ unsetRole ( mInterfaces [idx] );
234
+ delete mInterfaces [idx];
235
+ mInterfaces .remove ( idx );
240
236
QgsDebugMsg ( " removed ok" );
241
237
}
242
238
243
- // Connect or reconnect (after the test) filters
244
- connectFilters ( mFilters );
239
+ // Connect or reconnect (after the test) interfaces
240
+ connect ( mInterfaces );
245
241
return success;
246
242
}
247
243
248
- bool QgsRasterPipe::remove ( QgsRasterInterface * theFilter )
244
+ bool QgsRasterPipe::remove ( QgsRasterInterface * theInterface )
249
245
{
250
- if ( !theFilter ) return false ;
246
+ if ( !theInterface ) return false ;
251
247
252
- return remove ( mFilters .indexOf ( theFilter ) );
248
+ return remove ( mInterfaces .indexOf ( theInterface ) );
253
249
}
0 commit comments