34 for (
int i = 0; i < pipe.
size(); i++ )
39 Role role = interfaceRole( clone );
40 QgsDebugMsgLevel( QStringLiteral(
"cloned interface with role %1" ).arg( role ), 4 );
43 clone->setInput( mInterfaces.at( i - 1 ) );
45 mInterfaces.append( clone );
48 mRoleMap.insert( role, i );
55 const auto constMInterfaces = mInterfaces;
62 bool QgsRasterPipe::connect( QVector<QgsRasterInterface *> interfaces )
65 for (
int i = 1; i < interfaces.size(); i++ )
67 if ( ! interfaces[i]->setInput( interfaces[i - 1] ) )
72 QgsDebugMsg( QStringLiteral(
"cannot connect %1 to %2" ).arg(
typeid( a ).name(),
typeid( b ).name() ) );
82 QgsDebugMsgLevel( QStringLiteral(
"insert %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
83 if ( idx > mInterfaces.size() )
85 idx = mInterfaces.size();
89 QVector<QgsRasterInterface *> interfaces = mInterfaces;
91 interfaces.insert( idx, interface );
93 if ( connect( interfaces ) )
96 mInterfaces.insert( idx, interface );
97 setRole( interface, idx );
102 connect( mInterfaces );
108 if ( !interface )
return false;
110 QgsDebugMsgLevel( QStringLiteral(
"replace by %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
111 if ( !checkBounds( idx ) )
return false;
115 QVector<QgsRasterInterface *> interfaces = mInterfaces;
117 interfaces[idx] = interface;
118 bool success =
false;
119 if ( connect( interfaces ) )
122 delete mInterfaces.at( idx );
123 mInterfaces[idx] = interface;
124 setRole( interface, idx );
129 connect( mInterfaces );
144 QgsDebugMsgLevel( QStringLiteral(
"%1 role = %2" ).arg(
typeid( *interface ).name() ).arg( role ), 4 );
150 Role role = interfaceRole( interface );
152 mRoleMap.insert( role, idx );
157 Role role = interfaceRole( interface );
159 mRoleMap.remove( role );
164 if ( !interface )
return false;
166 QgsDebugMsgLevel( QStringLiteral(
"%1" ).arg(
typeid( *interface ).name() ), 4 );
167 Role role = interfaceRole( interface );
173 if ( mRoleMap.contains( role ) )
177 return replace( mRoleMap.value( role ), interface );
200 idx = providerIdx + 1;
204 idx = std::max( providerIdx, rendererIdx ) + 1;
208 idx = std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ) + 1;
212 idx = std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
216 idx = std::max( std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
219 return insert( idx, interface );
225 if ( mRoleMap.contains( role ) )
227 return mInterfaces.value( mRoleMap.value( role ) );
271 if ( !checkBounds( idx ) )
return false;
275 QVector<QgsRasterInterface *> interfaces = mInterfaces;
277 interfaces.remove( idx );
278 bool success =
false;
279 if ( connect( interfaces ) )
282 unsetRole( mInterfaces.at( idx ) );
283 delete mInterfaces.at( idx );
284 mInterfaces.remove( idx );
289 connect( mInterfaces );
295 if ( !interface )
return false;
297 return remove( mInterfaces.indexOf( interface ) );
302 QgsDebugMsgLevel( QStringLiteral(
"idx = %1 on = %2" ).arg( idx ).arg( on ), 4 );
303 if ( !checkBounds( idx ) )
return false;
307 bool onOrig = mInterfaces.at( idx )->on();
309 if ( onOrig == on )
return true;
311 mInterfaces.at( idx )->setOn( on );
313 bool success = connect( mInterfaces );
315 mInterfaces.at( idx )->setOn( onOrig );
316 connect( mInterfaces );
322 QgsDebugMsgLevel( QStringLiteral(
"idx = %1 on = %2" ).arg( idx ).arg( on ), 4 );
323 if ( !checkBounds( idx ) )
return false;
325 bool onOrig = mInterfaces.at( idx )->on();
327 if ( onOrig == on )
return true;
329 mInterfaces.at( idx )->setOn( on );
331 if ( connect( mInterfaces ) )
return true;
333 mInterfaces.at( idx )->setOn( onOrig );
334 connect( mInterfaces );
339 bool QgsRasterPipe::checkBounds(
int idx )
const
341 return !( idx < 0 || idx >= mInterfaces.size() );