[Qgis-developer] [QGIS Commit] SVN [ersts] r7424

Martin Dobias wonder.sk at gmail.com
Fri Nov 16 17:30:43 EST 2007


On Nov 16, 2007 10:21 PM, Peter Ersts <ersts at amnh.org> wrote:
> Martin,
>
> I was just going to write you shortly because I need your help with it
> anyway ;) The custom enhancement function is a bit of a test at the
> moment anyway. As for keeping it only adding to the in the bindings that
> may not be possible, in which case we may choose to remove it.
>
> At the moment I have implemented the custom enhancement function as a
> callback. The idea was to you allow the user to just pass a function
> pointer to the contrast enhancement class. Your function simple needs to
> take in a double and return a int. The proof-of-concept I wrote in
> python (which I know next to nothing about) did work, but the same code
> is not working when added to the QgsContastEnhancement class. The C++
> call back works fine. Implementing it as a callback is what introduces
> the dependency on python. If you have a suggestion on how to do with
> from python without using a callback approach thus not introducing a
> dependency on python I am very interested in hearing your idea.

Looking at the implementation of QgsContrastEnhancement, this class
looks like a perfect candidate for delegation of
calculateContrastEnhancementValue() function to derived classes. How
should it look like:
- that function will become a pure virtual function
- derived classes (e.g. QgsContrastNoStretch,
QgsContrastStretchToMinMax etc.) will implement only that function
- creating a new algorithm would mean creating another class with
implementation of that function

This can be easily used in PyQGIS - it's quite straightforward to
derive own QgsContrastEnhancement class and assign it to raster layer.

What do you think?

Martin



More information about the Qgis-developer mailing list