[Qgis-developer] Information about Progress in diagram branch

Marco Hugentobler marco.hugentobler at karto.baug.ethz.ch
Sat Feb 17 04:24:59 EST 2007


Dear qgis developers,

You may have noticed my activities in the diagram branch in the last time. My 
progresses are quite good and I hope that it can be merged into svn head 
before 0.9 release (whenever this will be). If you like to try out the new 
feature, you may download the sources with:

 svn co https://svn.qgis.org/repos/qgis/branches/diagram-branch

I'd like to give some information here about what I'm doing there. I'm also 
preparing a pdf with detailed technical description and I'll send a link to 
it to the devel list as soon as it's available.

The main technical change in the branch is the class QgsVectorOverlay. A 
vector overlay is anything on top of a vectorlayer which relates to the 
position of the features. An example of a vector overlay are diagrams placed 
on a map (for which there is an early implementation in the branch). Another 
example would be labels (but the branch still uses the current label 
implementation). 

In the diagram branch, there is the interface QgsVectorOverlay and a subclass 
of it QgsDiagramOverlay. A vector overlay stores a multimap of 
QgsOverlayObjects (basically position, bounding box and feature geometry) and 
is able to draw those objects (which is specific to subclasses). It is a 
multimap because multitype objects may have several overlay objects.

To manage the positioning of the overlay objects, there is the interface 
QgsOverlayObjectPositionManager and the subclass 
QgsCentralPointPositionManager. The idea of the position manager is that it 
may evaluate the overlay objects of one or more vector overlay together with 
the feature geometries to achieve an optimal placement. E.g. if there is a 
diagram overlay and labels at the same time, it would be great if they do not 
overlap each other and not the labels/diagrams of other features. The current 
implementation in the class QgsCentralPointPositionManager implements the 
simplest behaviour by placing the objects on the center point of a feature 
(without considerating other vector overlays). But the architecture in the 
diagram branch makes it possible to implement sophisticated placement in the 
future.

The implementation of the diagram overlay in the branch is done as plugin. For 
this, a new plugin type has been introduced (QgisPlugin::VECTOR_OVERLAY). 
Vector overlay plugins are subclasses of QgsVectorOverlayPlugin and provide a 
method for the vector properties dialog to request an input dialog suitable 
for the specific vector overlay type. So QgsVectorLayerProperties checks if 
there are any overlay plugins loaded and inserts a new tab with the specific 
dialog for each. Vector overlays could of course also be implemented as part 
of the core.

The current implementation of diagrams provides support for pie- and barcharts 
and for linear scaling of the diagram size according to a classification 
attribute. These behaviours are also extendable by implementing interfaces, 
but I don't want to bore you here with the exact details. The implementation 
does not yet support loading/saving to/from project file and does not yet 
generate an entry in the qgis legend. Once these points are solved, I will 
try to request permission for a merge to svn head. From my explanations above 
you can see that the impact of the changes on qgis core stability are minimal 
because most of the actual actions are done in the diagram plugin.


All the best,
Marco





More information about the Qgis-developer mailing list