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;
Brightness/contrast and gamma correction filter pipe for rasters.
Color and saturation filter pipe for rasters.
Base class for raster data providers.
virtual bool enableProviderResampling(bool enable)
Enable or disable provider-level resampling.
Base class for processing filters like renderers, reprojector, resampler etc.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Raster pipe that deals with null values.
Base class for processing modules.
bool set(QgsRasterInterface *interface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
QgsRasterPipe()=default
Constructor for QgsRasterPipe.
ResamplingStage
Stage at which resampling occurs.
@ Provider
Resampling occurs in Provider.
@ ResampleFilter
Resampling occurs in ResamplingFilter.
QgsRasterResampleFilter * resampleFilter() const
bool replace(int idx, QgsRasterInterface *interface)
Try to replace interface at specified index and connect if connection would fail, the interface is no...
QgsRasterDataProvider * provider() const
bool canSetOn(int idx, bool on)
Test if interface at index may be switched on/off.
bool insert(int idx, QgsRasterInterface *interface)
Try to insert interface at specified index and connect if connection would fail, the interface is not...
QgsRasterProjector * projector() const
bool remove(int idx)
Remove and delete interface at given index if possible.
QgsRasterRenderer * renderer() const
ResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
void setResamplingStage(ResamplingStage stage)
Select which stage of the pipe should apply resampling.
QgsBrightnessContrastFilter * brightnessFilter() const
QgsHueSaturationFilter * hueSaturationFilter() const
QgsRasterNuller * nuller() const
bool setOn(int idx, bool on)
Set interface at index on/off Returns true on success.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Raster renderer pipe that applies colors to a raster.
Resample filter pipe for rasters.
#define QgsDebugMsgLevel(str, level)