[Qgis-developer] Layer Visibility and Transparency

Peter Ersts ersts at amnh.org
Fri Oct 23 10:17:37 EDT 2009


Sergio,

After either of these steps you would have to refresh the map canvas to 
see the changes, which would will mean redrawing all of the visible layers.

I don't know exactly how you are trying to implement this, but your best 
approach may be render each layer as an image ( "off screen" ) then have 
your application/plugin cycle through these images instead of using the 
map canvas, if that is what you are doing.

The transparency block looks fine at first glance ( you can use 
qgsrasterlayerproperties.cpp as an example if you have not already ) but 
take in mind you have to apply that to _each_ raster layer after it has 
been initialized.

-pete


sergio cavalcante wrote:
> Hello guys,
>
> I'm developing a tool using the great qgis api, but i've got some 
> problems to use some features, and after search a lot, I need your 
> help. That are two issues.
>
> 1 - I need to make an animation mode for raster images. So first, I've 
> tried to make a list with all raster images, and, using a QTimeLine, 
> set them visible or not. but the comand
> QgsMapCanvasLayer(LayerSet.at(0)).SetVisible(FALSE); //Layerset is the 
> MapCanvas LayerSet.
> it didin't work. So, to make the animation possible, I've had to 
> replace the current layerset of the mapcanvas, but this is too memory 
> expensive. So why possibly this setVisible didn't work?
>
> 2 - I need to make a pixel color transparent. I've achieved that using 
> the setNoDataValue, but what I really need is, instead of make the 
> pixel completely transparent, a transparency of, for example 50%. I've 
> also tried with this function:
>
>    QgsRasterTransparency::TransparentSingleValuePixel myTransparentPixel;
>     QList<QgsRasterTransparency::TransparentSingleValuePixel> 
> myTransparentSingleValuePixelList;
>
>     myTransparentPixel.pixelValue = 0.0;
>     myTransparentPixel.percentTransparent = 50.0;
>
>     myTransparentSingleValuePixelList.append( myTransparentPixel );
>     
> mRasterLayer->rasterTransparency()->setTransparentSingleValuePixelList( 
> myTransparentSingleValuePixelList );
>     m_qgsImage->refresh();
>
> but, it also didn't work.
>
> Any Ideas?
>
> Best Regards,
> ------------------------------
> Sérgio Cavalcante


-- 
====================================
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