[Qgis-developer] Re: Colormap

Peter Ersts ersts at amnh.org
Wed Aug 12 11:33:50 EDT 2009


Glad you found a solution. This highlights something of a problem that 
has come up before in the raster class itself, it has to do with the cast

QgsColorRampShader* myRasterShaderFunction = ( 

and the need to get to methods specific to the shader. In this case the 
cast will work even if the current shader function is not a color ramp 
shader, but of course when you go to use it as a color ramp shader, 
crash. I think the solution is to use dynamic_cast then check to make 
sure the pointer is not null.

I think it also might be useful if the shaders had ids or names as 
another way of knowing what type of shader you currently have. If you 
think this would be helpful, feel free to file a ticket so that it can 
be added to the growing todo list.


sergio cavalcante wrote:
> Hey guys,
> I've solved the problem.
> It was just use the function :
> mRasterLayer->setRasterShaderFunction(myRasterShaderFunction);
> at the end of the applypalette() , and and create the 
> myRasterShaderFunction this way:
> QgsColorRampShader* myRasterShaderFunction = new 
> QgsColorRampShader(0,255);
> instead of this way:
> QgsRasterLayer * mypLayer = new
>  QgsRasterLayer(myRasterFileInfo.filePath(),myRasterFileInfo.completeBaseName());

Peter J. Ersts, Software Developer
American Museum of Natural History
Center for Biodiversity and Conservation
Central Park West at 79th Street
New York, New York 10024
Web: http://biodiversityinformatics.amnh.org
Web: http://cbc.amnh.org

Open Source,
...evolving through community cooperation to change the world bit by bit

Quantum GIS Raster Development Team. 

More information about the Qgis-developer mailing list