Addition to QgsRenderContext

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Addition to QgsRenderContext

Magnus Homann
Is it OK to add transparency setting into the render context? This would make it much easier to
cache point symbols with transparency.

Current contents:

---
     /**Painter for rendering operations*/
     QPainter* mPainter;

     /**For transformation between coordinate systems. Can be 0 if on-the-fly reprojection is not used*/
     QgsCoordinateTransform* mCoordTransform;

     /**True if vertex markers for editing should be drawn*/
     bool mDrawEditingInformation;

     QgsRectangle mExtent;

     /**If true then no rendered vector elements should be cached as image*/
     bool mForceVectorOutput;

     QgsMapToPixel mMapToPixel;

     /**True if the rendering has been canceled*/
     bool mRenderingStopped;

     /**Factor to scale line widths and point marker sizes*/
     double mScaleFactor;

     /**Factor to scale rasters*/
     double mRasterScaleFactor;

     /**Map scale*/
     double mRendererScale;
---
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

AW: Addition to QgsRenderContext

Hugentobler  Marco
Hi Magnus

How would you add the transparency to the render context?
The rendercontext is meant to contain information about the rendering procedure as a whole (so not information that is layer or even symbol specific). Is it perhaps possible to extend the cache such that it stores the transparency value for which it is valid (and the resolution, that would be great for printing)?

Regards,
Marco


-----Ursprüngliche Nachricht-----
Von: [hidden email] im Auftrag von Magnus Homann
Gesendet: Di 04.08.2009 17:29
An: [hidden email]
Betreff: [Qgis-developer] Addition to QgsRenderContext
 
Is it OK to add transparency setting into the render context? This would make it much easier to
cache point symbols with transparency.

Current contents:

---
     /**Painter for rendering operations*/
     QPainter* mPainter;

     /**For transformation between coordinate systems. Can be 0 if on-the-fly reprojection is not used*/
     QgsCoordinateTransform* mCoordTransform;

     /**True if vertex markers for editing should be drawn*/
     bool mDrawEditingInformation;

     QgsRectangle mExtent;

     /**If true then no rendered vector elements should be cached as image*/
     bool mForceVectorOutput;

     QgsMapToPixel mMapToPixel;

     /**True if the rendering has been canceled*/
     bool mRenderingStopped;

     /**Factor to scale line widths and point marker sizes*/
     double mScaleFactor;

     /**Factor to scale rasters*/
     double mRasterScaleFactor;

     /**Map scale*/
     double mRendererScale;
---
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: AW: Addition to QgsRenderContext

Magnus Homann
Hugentobler Marco skrev:
> Hi Magnus
>
> How would you add the transparency to the render context?
> The rendercontext is meant to contain information about the rendering procedure as a whole (so not information that is layer or even symbol specific).

Thanks, I probably misunderstood the purpose of the render context.

Yes, the cache stores transparency, but to send the wanted transprancey down from QgsVectorLayer through QgsRenderer to QgsSymbol requiers an extra parameter in the interfaces. Maybe that's the best way?

Well, if we want to keep it within Qgsvectorlayer, we could:
1) Set alpha channel dynamically, or
2) Cache in QgsVectorLayer

Magnus
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

AW: AW: Addition to QgsRenderContext

Hugentobler  Marco
Hi Magnus

>1) Set alpha channel dynamically, or
>2) Cache in QgsVectorLayer

What do you mean with 'set alpha channel dynamically'?

Adding an extra parameter to the interfaces, as you suggested, sounds reasonable to me. Keep attention to add default values for it in the function signatures (to not break API compatibility for plugins and third party applications).

Regards,
Marco


-----Ursprüngliche Nachricht-----
Von: [hidden email] im Auftrag von Magnus Homann
Gesendet: Di 04.08.2009 21:22
An: qgis-developer
Betreff: Re: AW: [Qgis-developer] Addition to QgsRenderContext
 
Hugentobler Marco skrev:
> Hi Magnus
>
> How would you add the transparency to the render context?
> The rendercontext is meant to contain information about the rendering procedure as a whole (so not information that is layer or even symbol specific).

Thanks, I probably misunderstood the purpose of the render context.

Yes, the cache stores transparency, but to send the wanted transprancey down from QgsVectorLayer through QgsRenderer to QgsSymbol requiers an extra parameter in the interfaces. Maybe that's the best way?

Well, if we want to keep it within Qgsvectorlayer, we could:
1) Set alpha channel dynamically, or
2) Cache in QgsVectorLayer

Magnus
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

AW: AW: AW: Addition to QgsRenderContext

Hugentobler  Marco
Hi Magnus

The way to pass opacity as rendering argument looks good, thank you for fixing the transparency issue!

Still there is an issue with backwards compatibility. The purpose of b.c. is that plugins and third party apps don't need to be changed for the 1.x versions.

Take QgsRenderer and assume someone wrote a plugin or an application that has its custom renderer class (e.g. QGIS mapserver has QgsSLDRenderer which implements a rule based renderer as in SLD).
Now QgsRenderer changed to:

void renderFeature(QPainter* p, QgsFeature& f,QImage* pic, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected );
virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0;

This means that QgsSLDRenderer needs to add the third function, otherwise the compiler complains and the vector layer won't call the old function (compatibility broken).

Isn't it possible to work with default arguments? As far as I see from the .sip files, SIP supports the use of default arguments such that API compatibility also would work for the bindings. But I'm not an export in SIP, so please Martin or someone else correct me if I'm wrong.

Regards,
Marco


-----Ursprüngliche Nachricht-----
Von: Magnus Homann [mailto:[hidden email]]
Gesendet: Mi 05.08.2009 17:26
An: Hugentobler  Marco
Betreff: Re: AW: AW: [Qgis-developer] Addition to QgsRenderContext
 
Hugentobler Marco skrev:
> Hi Magnus
>
>> 1) Set alpha channel dynamically, or
>> 2) Cache in QgsVectorLayer
>
> What do you mean with 'set alpha channel dynamically'?
>
> Adding an extra parameter to the interfaces, as you suggested, sounds reasonable to me. Keep attention to add default values for it in the function signatures (to not break API compatibility for plugins and third party applications).

I comitted r11275, please have a look if it is OK.

Magnus

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer