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 );
56 const auto constMInterfaces = mInterfaces;
63 bool QgsRasterPipe::connect( QVector<QgsRasterInterface *> interfaces )
66 for (
int i = 1; i < interfaces.size(); i++ )
68 if ( ! interfaces[i]->setInput( interfaces[i - 1] ) )
73 QgsDebugMsg( QStringLiteral(
"cannot connect %1 to %2" ).arg(
typeid( a ).name(),
typeid( b ).name() ) );
83 QgsDebugMsgLevel( QStringLiteral(
"insert %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
84 if ( idx > mInterfaces.size() )
86 idx = mInterfaces.size();
90 QVector<QgsRasterInterface *> interfaces = mInterfaces;
92 interfaces.insert( idx, interface );
94 if ( connect( interfaces ) )
97 mInterfaces.insert( idx, interface );
98 setRole( interface, idx );
103 connect( mInterfaces );
109 if ( !interface )
return false;
111 QgsDebugMsgLevel( QStringLiteral(
"replace by %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
112 if ( !checkBounds( idx ) )
return false;
116 QVector<QgsRasterInterface *> interfaces = mInterfaces;
118 interfaces[idx] = interface;
119 bool success =
false;
120 if ( connect( interfaces ) )
123 delete mInterfaces.at( idx );
124 mInterfaces[idx] = interface;
125 setRole( interface, idx );
130 connect( mInterfaces );
145 QgsDebugMsgLevel( QStringLiteral(
"%1 role = %2" ).arg(
typeid( *interface ).name() ).arg( role ), 4 );
151 Role role = interfaceRole( interface );
153 mRoleMap.insert( role, idx );
158 Role role = interfaceRole( interface );
160 mRoleMap.remove( role );
165 if ( !interface )
return false;
168 Role role = interfaceRole( interface );
174 if ( mRoleMap.contains( role ) )
178 return replace( mRoleMap.value( role ), interface );
201 idx = providerIdx + 1;
205 idx = std::max( providerIdx, rendererIdx ) + 1;
209 idx = std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ) + 1;
213 idx = std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
217 idx = std::max( std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
220 return insert( idx, interface );
226 if ( mRoleMap.contains( role ) )
228 return mInterfaces.value( mRoleMap.value( role ) );
272 if ( !checkBounds( idx ) )
return false;
276 QVector<QgsRasterInterface *> interfaces = mInterfaces;
278 interfaces.remove( idx );
279 bool success =
false;
280 if ( connect( interfaces ) )
283 unsetRole( mInterfaces.at( idx ) );
284 delete mInterfaces.at( idx );
285 mInterfaces.remove( idx );
290 connect( mInterfaces );
296 if ( !interface )
return false;
298 return remove( mInterfaces.indexOf( interface ) );
303 QgsDebugMsgLevel( QStringLiteral(
"idx = %1 on = %2" ).arg( idx ).arg( on ), 4 );
304 if ( !checkBounds( idx ) )
return false;
308 bool onOrig = mInterfaces.at( idx )->on();
310 if ( onOrig == on )
return true;
312 mInterfaces.at( idx )->setOn( on );
314 bool success = connect( mInterfaces );
316 mInterfaces.at( idx )->setOn( onOrig );
317 connect( mInterfaces );
323 QgsDebugMsgLevel( QStringLiteral(
"idx = %1 on = %2" ).arg( idx ).arg( on ), 4 );
324 if ( !checkBounds( idx ) )
return false;
326 bool onOrig = mInterfaces.at( idx )->on();
328 if ( onOrig == on )
return true;
330 mInterfaces.at( idx )->setOn( on );
332 if ( connect( mInterfaces ) )
return true;
334 mInterfaces.at( idx )->setOn( onOrig );
335 connect( mInterfaces );
340 bool QgsRasterPipe::checkBounds(
int idx )
const
342 return !( idx < 0 || idx >= mInterfaces.size() );
347 mResamplingStage = stage;