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] ) )
65 QgsDebugMsg(
QString(
"cannot connect %1 to %2" ).arg(
typeid( *( theInterfaces[i] ) ).name() ).arg(
typeid( *( theInterfaces[i-1] ) ).name() ) );
74 QgsDebugMsg(
QString(
"insert %1 at %2" ).arg(
typeid( *theInterface ).name() ).arg( idx ) );
75 if ( idx > mInterfaces.
size() )
77 idx = mInterfaces.
size();
83 interfaces.
insert( idx, theInterface );
85 if ( connect( interfaces ) )
88 mInterfaces.
insert( idx, theInterface );
89 setRole( theInterface, idx );
94 connect( mInterfaces );
100 if ( !theInterface )
return false;
102 QgsDebugMsg(
QString(
"replace by %1 at %2" ).arg(
typeid( *theInterface ).name() ).arg( idx ) );
103 if ( !checkBounds( idx ) )
return false;
109 interfaces[idx] = theInterface;
110 bool success =
false;
111 if ( connect( interfaces ) )
114 delete mInterfaces[idx];
115 mInterfaces[idx] = theInterface;
116 setRole( theInterface, idx );
121 connect( mInterfaces );
128 if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role =
ProviderRole;
129 else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role =
RendererRole;
130 else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role =
ResamplerRole;
131 else if ( dynamic_cast<QgsBrightnessContrastFilter *>( interface ) ) role =
BrightnessRole;
132 else if ( dynamic_cast<QgsHueSaturationFilter *>( interface ) ) role =
HueSaturationRole;
133 else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role =
ProjectorRole;
134 else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role =
NullerRole;
136 QgsDebugMsg(
QString(
"%1 role = %2" ).arg(
typeid( *interface ).name() ).arg( role ) );
142 Role role = interfaceRole( theInterface );
144 mRoleMap.
insert( role, idx );
149 Role role = interfaceRole( theInterface );
156 if ( !theInterface )
return false;
159 Role role = interfaceRole( theInterface );
192 idx = providerIdx + 1;
196 idx = qMax( providerIdx, rendererIdx ) + 1;
200 idx = qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ) + 1;
204 idx = qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ) + 1;
208 idx = qMax( qMax( qMax( qMax( providerIdx, rendererIdx ), brightnessIdx ), hueSaturationIdx ), resamplerIdx ) + 1;
211 return insert( idx, theInterface );
219 return mInterfaces.
value( mRoleMap.
value( role ) );
263 if ( !checkBounds( idx ) )
return false;
270 bool success =
false;
271 if ( connect( interfaces ) )
274 unsetRole( mInterfaces[idx] );
275 delete mInterfaces[idx];
276 mInterfaces.
remove( idx );
281 connect( mInterfaces );
287 if ( !theInterface )
return false;
289 return remove( mInterfaces.
indexOf( theInterface ) );
295 if ( !checkBounds( idx ) )
return false;
299 bool onOrig = mInterfaces[idx]->on();
301 if ( onOrig == on )
return true;
303 mInterfaces[idx]->setOn( on );
305 bool success = connect( mInterfaces );
307 mInterfaces[idx]->setOn( onOrig );
308 connect( mInterfaces );
315 if ( !checkBounds( idx ) )
return false;
317 bool onOrig = mInterfaces[idx]->on();
319 if ( onOrig == on )
return true;
321 mInterfaces[idx]->setOn( on );
323 if ( connect( mInterfaces ) )
return true;
325 mInterfaces[idx]->setOn( onOrig );
326 connect( mInterfaces );
331 bool QgsRasterPipe::checkBounds(
int idx )
const
333 if ( idx < 0 || idx >= mInterfaces.
size() )
return false;
Base class for processing modules.
QgsRasterNuller * nuller() const
bool contains(const Key &key) const
void append(const T &value)
QgsBrightnessContrastFilter * brightnessFilter() const
int indexOf(const T &value, int from) const
Raster pipe that deals with null values.
void insert(int i, const T &value)
Resample filter pipe for rasters.
QgsRasterDataProvider * provider() const
QgsRasterProjector * projector() const
Base class for processing filters like renderers, reprojector, resampler etc.
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.
bool insert(int idx, QgsRasterInterface *theInterface)
Try to insert interface at specified index and connect if connection would fail, the interface is not...
iterator insert(const Key &key, const T &value)
QgsHueSaturationFilter * hueSaturationFilter() const
bool replace(int idx, QgsRasterInterface *theInterface)
Try to replace interface at specified index and connect if connection would fail, the interface is no...
QgsRasterRenderer * renderer() const
bool set(QgsRasterInterface *theInterface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
QgsRasterResampleFilter * resampleFilter() const
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)