31 for (
int i = 0; i < thePipe.
size(); i++ )
36 Role role = interfaceRole( clone );
40 clone->setInput( mInterfaces.
at( i - 1 ) );
42 mInterfaces.
append( clone );
45 mRoleMap.
insert( role, i );
61 for (
int i = 1; i < theInterfaces.
size(); i++ )
63 if ( ! theInterfaces[i]->setInput( theInterfaces[i-1] ) )
68 QgsDebugMsg(
QString(
"cannot connect %1 to %2" ).arg(
typeid( a ).name(),
typeid( b ).name() ) );
79 if ( idx > mInterfaces.
size() )
81 idx = mInterfaces.
size();
87 interfaces.
insert( idx, theInterface );
89 if ( connect( interfaces ) )
92 mInterfaces.
insert( idx, theInterface );
93 setRole( theInterface, idx );
98 connect( mInterfaces );
104 if ( !theInterface )
return false;
107 if ( !checkBounds( idx ) )
return false;
113 interfaces[idx] = theInterface;
114 bool success =
false;
115 if ( connect( interfaces ) )
118 delete mInterfaces.
at( idx );
119 mInterfaces[idx] = theInterface;
120 setRole( theInterface, idx );
125 connect( mInterfaces );
132 if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role =
ProviderRole;
133 else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role =
RendererRole;
134 else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role =
ResamplerRole;
135 else if ( dynamic_cast<QgsBrightnessContrastFilter *>( interface ) ) role =
BrightnessRole;
136 else if ( dynamic_cast<QgsHueSaturationFilter *>( interface ) ) role =
HueSaturationRole;
137 else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role =
ProjectorRole;
138 else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role =
NullerRole;
146 Role role = interfaceRole( theInterface );
148 mRoleMap.
insert( role, idx );
153 Role role = interfaceRole( theInterface );
160 if ( !theInterface )
return false;
163 Role role = interfaceRole( theInterface );
196 idx = providerIdx + 1;
200 idx = qMax( providerIdx, rendererIdx ) + 1;
204 idx = qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ) + 1;
208 idx = qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
212 idx = qMax( qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
215 return insert( idx, theInterface );
223 return mInterfaces.
value( mRoleMap.
value( role ) );
267 if ( !checkBounds( idx ) )
return false;
274 bool success =
false;
275 if ( connect( interfaces ) )
278 unsetRole( mInterfaces.
at( idx ) );
279 delete mInterfaces.
at( idx );
280 mInterfaces.
remove( idx );
285 connect( mInterfaces );
291 if ( !theInterface )
return false;
293 return remove( mInterfaces.
indexOf( theInterface ) );
299 if ( !checkBounds( idx ) )
return false;
303 bool onOrig = mInterfaces.
at( idx )->on();
305 if ( onOrig == on )
return true;
307 mInterfaces.
at( idx )->setOn( on );
309 bool success = connect( mInterfaces );
311 mInterfaces.
at( idx )->setOn( onOrig );
312 connect( mInterfaces );
319 if ( !checkBounds( idx ) )
return false;
321 bool onOrig = mInterfaces.
at( idx )->on();
323 if ( onOrig == on )
return true;
325 mInterfaces.
at( idx )->setOn( on );
327 if ( connect( mInterfaces ) )
return true;
329 mInterfaces.
at( idx )->setOn( onOrig );
330 connect( mInterfaces );
335 bool QgsRasterPipe::checkBounds(
int idx )
const 337 if ( idx < 0 || idx >= mInterfaces.
size() )
return false;
Base class for processing modules.
bool contains(const Key &key) const
void append(const T &value)
QgsRasterRenderer * renderer() const
int indexOf(const T &value, int from) const
QgsRasterResampleFilter * resampleFilter() const
QgsRasterProjector * projector() const
Raster pipe that deals with null values.
void insert(int i, const T &value)
Resample filter pipe for rasters.
#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.
const T & at(int i) const
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
bool insert(int idx, QgsRasterInterface *theInterface)
Try to insert interface at specified index and connect if connection would fail, the interface is not...
QgsRasterNuller * nuller() const
iterator insert(const Key &key, const T &value)
bool replace(int idx, QgsRasterInterface *theInterface)
Try to replace interface at specified index and connect if connection would fail, the interface is no...
QgsBrightnessContrastFilter * brightnessFilter() const
QgsHueSaturationFilter * hueSaturationFilter() const
bool set(QgsRasterInterface *theInterface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
Raster renderer pipe that applies colors to a raster.
const T value(const Key &key) const
Base class for raster data providers.
int remove(const Key &key)