34 for (
int i = 0; i < pipe.
size(); i++ )
39 Role role = interfaceRole( clone );
40 QgsDebugMsgLevel( QString(
"cloned interface with role %1" ).arg( role ), 4 );
43 clone->setInput( mInterfaces.at( i - 1 ) );
45 mInterfaces.append( clone );
48 mRoleMap.insert( role, i );
61 bool QgsRasterPipe::connect( QVector<QgsRasterInterface *> interfaces )
64 for (
int i = 1; i < interfaces.size(); i++ )
66 if ( ! interfaces[i]->setInput( interfaces[i - 1] ) )
71 QgsDebugMsg( QString(
"cannot connect %1 to %2" ).arg(
typeid( a ).name(),
typeid( b ).name() ) );
81 QgsDebugMsgLevel( QString(
"insert %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
82 if ( idx > mInterfaces.size() )
84 idx = mInterfaces.size();
88 QVector<QgsRasterInterface *> interfaces = mInterfaces;
90 interfaces.insert( idx, interface );
92 if ( connect( interfaces ) )
95 mInterfaces.insert( idx, interface );
96 setRole( interface, idx );
101 connect( mInterfaces );
107 if ( !interface )
return false;
109 QgsDebugMsgLevel( QString(
"replace by %1 at %2" ).arg(
typeid( *interface ).name() ).arg( idx ), 4 );
110 if ( !checkBounds( idx ) )
return false;
114 QVector<QgsRasterInterface *> interfaces = mInterfaces;
116 interfaces[idx] = interface;
117 bool success =
false;
118 if ( connect( interfaces ) )
121 delete mInterfaces.at( idx );
122 mInterfaces[idx] = interface;
123 setRole( interface, idx );
128 connect( mInterfaces );
135 if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role =
ProviderRole;
136 else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role =
RendererRole;
137 else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role =
ResamplerRole;
138 else if ( dynamic_cast<QgsBrightnessContrastFilter *>( interface ) ) role =
BrightnessRole;
139 else if ( dynamic_cast<QgsHueSaturationFilter *>( interface ) ) role =
HueSaturationRole;
140 else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role =
ProjectorRole;
141 else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role =
NullerRole;
143 QgsDebugMsgLevel( QString(
"%1 role = %2" ).arg(
typeid( *interface ).name() ).arg( role ), 4 );
149 Role role = interfaceRole( interface );
151 mRoleMap.insert( role, idx );
156 Role role = interfaceRole( interface );
158 mRoleMap.remove( role );
163 if ( !interface )
return false;
166 Role role = interfaceRole( interface );
172 if ( mRoleMap.contains( role ) )
176 return replace( mRoleMap.value( role ), interface );
199 idx = providerIdx + 1;
203 idx = std::max( providerIdx, rendererIdx ) + 1;
207 idx = std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ) + 1;
211 idx = std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
215 idx = std::max( std::max( std::max( std::max( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
218 return insert( idx, interface );
224 if ( mRoleMap.contains( role ) )
226 return mInterfaces.value( mRoleMap.value( role ) );
270 if ( !checkBounds( idx ) )
return false;
274 QVector<QgsRasterInterface *> interfaces = mInterfaces;
276 interfaces.remove( idx );
277 bool success =
false;
278 if ( connect( interfaces ) )
281 unsetRole( mInterfaces.at( idx ) );
282 delete mInterfaces.at( idx );
283 mInterfaces.remove( idx );
288 connect( mInterfaces );
294 if ( !interface )
return false;
296 return remove( mInterfaces.indexOf( interface ) );
302 if ( !checkBounds( idx ) )
return false;
306 bool onOrig = mInterfaces.at( idx )->on();
308 if ( onOrig == on )
return true;
310 mInterfaces.at( idx )->setOn( on );
312 bool success = connect( mInterfaces );
314 mInterfaces.at( idx )->setOn( onOrig );
315 connect( mInterfaces );
322 if ( !checkBounds( idx ) )
return false;
324 bool onOrig = mInterfaces.at( idx )->on();
326 if ( onOrig == on )
return true;
328 mInterfaces.at( idx )->setOn( on );
330 if ( connect( mInterfaces ) )
return true;
332 mInterfaces.at( idx )->setOn( onOrig );
333 connect( mInterfaces );
338 bool QgsRasterPipe::checkBounds(
int idx )
const 340 return !( idx < 0 || idx >= mInterfaces.size() );
Base class for processing modules.
QgsRasterRenderer * renderer() const
QgsRasterResampleFilter * resampleFilter() const
QgsRasterProjector * projector() const
Raster pipe that deals with null values.
bool insert(int idx, QgsRasterInterface *interface)
Try to insert interface at specified index and connect if connection would fail, the interface is not...
Resample filter pipe for rasters.
bool replace(int idx, QgsRasterInterface *interface)
Try to replace interface at specified index and connect if connection would fail, the interface is no...
#define QgsDebugMsgLevel(str, level)
Base class for processing filters like renderers, reprojector, resampler etc.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
bool canSetOn(int idx, bool on)
Test if interface at index may be swithed on/off.
bool set(QgsRasterInterface *interface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
bool remove(int idx)
Remove and delete interface at given index if possible.
bool setOn(int idx, bool on)
Set interface at index on/off Returns true on success.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Brightness/contrast filter pipe for rasters.
Color and saturation filter pipe for rasters.
QgsRasterDataProvider * provider() const
QgsRasterNuller * nuller() const
QgsBrightnessContrastFilter * brightnessFilter() const
QgsHueSaturationFilter * hueSaturationFilter() const
Raster renderer pipe that applies colors to a raster.
Base class for raster data providers.
QgsRasterPipe()=default
Constructor for QgsRasterPipe.