31 for (
int i = 0; i < thePipe.
size(); i++ )
36 Role role = interfaceRole( clone );
37 QgsDebugMsg( QString(
"cloned inerface with role %1" ).arg( role ) );
40 clone->setInput( mInterfaces.at( i - 1 ) );
42 mInterfaces.append( clone );
45 mRoleMap.insert( role, i );
58 bool QgsRasterPipe::connect( QVector<QgsRasterInterface*> theInterfaces )
61 for (
int i = 1; i < theInterfaces.size(); i++ )
63 if ( ! theInterfaces[i]->setInput( theInterfaces[i-1] ) )
65 QgsDebugMsg( QString(
"cannot connect %1 to %2" ).arg(
typeid( *( theInterfaces[i] ) ).name() ).arg(
typeid( *( theInterfaces[i-1] ) ).name() ) );
74 QgsDebugMsg( QString(
"insert %1 at %2" ).arg(
typeid( *theInterface ).name() ).arg( idx ) );
75 if ( idx > mInterfaces.size() )
77 idx = mInterfaces.size();
81 QVector<QgsRasterInterface*> interfaces = mInterfaces;
83 interfaces.insert( idx, theInterface );
85 if ( connect( interfaces ) )
88 mInterfaces.insert( idx, theInterface );
89 setRole( theInterface, idx );
94 connect( mInterfaces );
100 if ( !theInterface )
return false;
102 QgsDebugMsg( QString(
"replace by %1 at %2" ).arg(
typeid( *theInterface ).name() ).arg( idx ) );
103 if ( !checkBounds( idx ) )
return false;
107 QVector<QgsRasterInterface*> interfaces = mInterfaces;
109 interfaces[idx] = theInterface;
110 bool success =
false;
111 if ( connect( interfaces ) )
114 delete mInterfaces[idx];
115 mInterfaces[idx] = theInterface;
116 setRole( theInterface, idx );
121 connect( mInterfaces );
128 if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role =
ProviderRole;
129 else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role =
RendererRole;
130 else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role =
ResamplerRole;
131 else if ( dynamic_cast<QgsBrightnessContrastFilter *>( interface ) ) role =
BrightnessRole;
132 else if ( dynamic_cast<QgsHueSaturationFilter *>( interface ) ) role =
HueSaturationRole;
133 else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role =
ProjectorRole;
134 else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role =
NullerRole;
136 QgsDebugMsg( QString(
"%1 role = %2" ).arg(
typeid( *interface ).name() ).arg( role ) );
142 Role role = interfaceRole( theInterface );
144 mRoleMap.insert( role, idx );
149 Role role = interfaceRole( theInterface );
151 mRoleMap.remove( role );
156 if ( !theInterface )
return false;
158 QgsDebugMsg( QString(
"%1" ).arg(
typeid( *theInterface ).name() ) );
159 Role role = interfaceRole( theInterface );
165 if ( mRoleMap.contains( role ) )
169 return replace( mRoleMap.value( role ), theInterface );
192 idx = providerIdx + 1;
196 idx = qMax( providerIdx, rendererIdx ) + 1;
200 idx = qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ) + 1;
204 idx = qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
208 idx = qMax( qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
211 return insert( idx, theInterface );
217 if ( mRoleMap.contains( role ) )
219 return mInterfaces.value( mRoleMap.value( role ) );
261 QgsDebugMsg( QString(
"remove at %1" ).arg( idx ) );
263 if ( !checkBounds( idx ) )
return false;
267 QVector<QgsRasterInterface*> interfaces = mInterfaces;
269 interfaces.remove( idx );
270 bool success =
false;
271 if ( connect( interfaces ) )
274 unsetRole( mInterfaces[idx] );
275 delete mInterfaces[idx];
276 mInterfaces.remove( idx );
281 connect( mInterfaces );
287 if ( !theInterface )
return false;
289 return remove( mInterfaces.indexOf( theInterface ) );
294 QgsDebugMsg( QString(
"idx = %1 on = %2" ).arg( idx ).arg( on ) );
295 if ( !checkBounds( idx ) )
return false;
299 bool onOrig = mInterfaces[idx]->on();
301 if ( onOrig == on )
return true;
303 mInterfaces[idx]->setOn( on );
305 bool success = connect( mInterfaces );
307 mInterfaces[idx]->setOn( onOrig );
308 connect( mInterfaces );
314 QgsDebugMsg( QString(
"idx = %1 on = %2" ).arg( idx ).arg( on ) );
315 if ( !checkBounds( idx ) )
return false;
317 bool onOrig = mInterfaces[idx]->on();
319 if ( onOrig == on )
return true;
321 mInterfaces[idx]->setOn( on );
323 if ( connect( mInterfaces ) )
return true;
325 mInterfaces[idx]->setOn( onOrig );
326 connect( mInterfaces );
331 bool QgsRasterPipe::checkBounds(
int idx )
const
333 if ( idx < 0 || idx >= mInterfaces.size() )
return false;