Feature request #3583

patch to use the same pal instance for labeling-ng and for diagrams

Added by Marco Hugentobler over 9 years ago. Updated over 9 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Build/Install
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13643

Description

Attached is a patch that implements a new diagram mechanism using QgsPalLabling, thus considering the positions of diagrams and labels. It is the idea to remove the vector overlay classes and its diagram implementation after 1.7

110309_qgis_diagrams.diff Magnifier (81.9 KB) Marco Hugentobler, 2011-03-09 05:39 AM

110309_qgis_diagrams_2.diff Magnifier (70.5 KB) Marco Hugentobler, 2011-03-09 08:27 AM

110309_qgis_diagrams_3.diff Magnifier (86.8 KB) Marco Hugentobler, 2011-03-09 08:30 AM

vector.tar.bz2 - lancover sample data (211 KB) Tim Sutton, 2011-03-14 08:25 AM

History

#1 Updated by Tim Sutton over 9 years ago

Hi MArco

I tried to test your patch against trunk caa0cae3 (SVN r15389) but it fails to compile with:

[ 68%] Building CXX object src/providers/grass/CMakeFiles/grassprovider.dir/provider.cpp.o
In file included from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsdiagramrendererv2.h:10,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsvectorlayer.h:29,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsvectordataprovider.h:29,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/qgsgrassprovider.h:24,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/provider.cpp:38:
/home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/pal/layer.h:50: error: expected ‘>’ before numeric constant
In file included from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsdiagramrendererv2.h:10,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsvectorlayer.h:29,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/qgsvectordataprovider.h:29,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/qgsgrassprovider.h:24,
                 from /home/timlinux/dev/cpp/qgis/src/providers/grass/provider.cpp:38:
/home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/pal/layer.h:108: error: wrong number of template arguments (6, should be 3)
/home/timlinux/dev/cpp/qgis/src/providers/grass/../../core/pal/layer.h:50: error: provided for ‘template<class DATATYPE, class ELEMTYPE, int <anonymous> > struct pal::RTree’
maker2: *** [src/providers/grass/CMakeFiles/grassprovider.dir/provider.cpp.o] Error 1
maker1: *** [src/providers/grass/CMakeFiles/grassprovider.dir/all] Error 2
make: *** [all] Error 2

Regards

Tim

#2 Updated by Marco Hugentobler over 9 years ago

Hi Tim

Please try the second patch. It should fix the build issue (by removing the vectorlayer include in the provider class). Hopefully it works...

Regards,
Marco

#3 Updated by Marco Hugentobler over 9 years ago

Wait, better go with the third one

#4 Updated by Tim Sutton over 9 years ago

With patch 3 I now get:

[ 12%] Building CXX object src/core/CMakeFiles/qgis_core.dir/qgspallabeling.cpp.o
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:195: error: redefinition of ‘QgsTextDiagram::QgsTextDiagram()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:7: error: ‘QgsTextDiagram::QgsTextDiagram()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:203: error: redefinition of ‘QgsTextDiagram::~QgsTextDiagram()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:15: error: ‘QgsTextDiagram::~QgsTextDiagram()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:207: error: redefinition of ‘void [[QgsTextDiagram]]::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const [[QgsDiagramSettings]]&, const QPointF&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:19: error: ‘virtual void [[QgsTextDiagram]]::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const [[QgsDiagramSettings]]&, const QPointF&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:292: error: redefinition of ‘void [[QgsTextDiagram]]::lineEllipseIntersection(const QPointF&, const QPointF&, const QPointF&, double, double, QList<QPointF>&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:104: error: ‘void [[QgsTextDiagram]]::lineEllipseIntersection(const QPointF&, const QPointF&, const QPointF&, double, double, QList<QPointF>&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:323: error: redefinition of ‘QgsPieDiagram::QgsPieDiagram()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:135: error: ‘QgsPieDiagram::QgsPieDiagram()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:329: error: redefinition of ‘QgsPieDiagram::~QgsPieDiagram()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:141: error: ‘QgsPieDiagram::~QgsPieDiagram()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:333: error: redefinition of ‘void [[QgsPieDiagram]]::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const [[QgsDiagramSettings]]&, const QPointF&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagram.cpp:145: error: ‘virtual void [[QgsPieDiagram]]::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const [[QgsDiagramSettings]]&, const QPointF&)’ previously defined here
maker2: *** [src/core/CMakeFiles/qgis_core.dir/qgsdiagram.cpp.o] Error 1
maker2: *** Waiting for unfinished jobs....
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:313: error: redefinition of ‘void [[QgsDiagramLayerSettings]]::readXML(const QDomElement&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:8: error: ‘void [[QgsDiagramLayerSettings]]::readXML(const QDomElement&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:324: error: redefinition of ‘void [[QgsDiagramLayerSettings]]::writeXML(QDomElement&, QDomDocument&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:19: error: ‘void [[QgsDiagramLayerSettings]]::writeXML(QDomElement&, QDomDocument&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:337: error: redefinition of ‘void [[QgsDiagramSettings]]::readXML(const QDomElement&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:32: error: ‘void [[QgsDiagramSettings]]::readXML(const QDomElement&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:362: error: redefinition of ‘void [[QgsDiagramSettings]]::writeXML(QDomElement&, QDomDocument&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:57: error: ‘void [[QgsDiagramSettings]]::writeXML(QDomElement&, QDomDocument&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:396: error: redefinition of ‘QgsDiagramRendererV2::QgsDiagramRendererV2()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:91: error: ‘QgsDiagramRendererV2::QgsDiagramRendererV2()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:400: error: redefinition of ‘QgsDiagramRendererV2::~QgsDiagramRendererV2()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:95: error: ‘virtual [[QgsDiagramRendererV]]2::~QgsDiagramRendererV2()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:405: error: redefinition of ‘void [[QgsDiagramRendererV]]2::setDiagram(QgsDiagram*)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:100: error: ‘void [[QgsDiagramRendererV]]2::setDiagram(QgsDiagram*)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:411: error: redefinition of ‘void [[QgsDiagramRendererV]]2::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const QPointF&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:106: error: ‘void [[QgsDiagramRendererV]]2::renderDiagram(const [[QgsAttributeMap]]&, [[QgsRenderContext]]&, const QPointF&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:427: error: redefinition of ‘QSizeF [[QgsDiagramRendererV]]2::sizeMapUnits(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:122: error: ‘virtual QSizeF [[QgsDiagramRendererV]]2::sizeMapUnits(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:434: error: redefinition of ‘void [[QgsDiagramRendererV]]2::convertSizeToMapUnits(QSizeF&, const [[QgsRenderContext]]&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:129: error: ‘void [[QgsDiagramRendererV]]2::convertSizeToMapUnits(QSizeF&, const [[QgsRenderContext]]&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:452: error: redefinition of ‘static int [[QgsDiagramRendererV]]2::dpiPaintDevice(const QPainter*)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:147: error: ‘static int [[QgsDiagramRendererV]]2::dpiPaintDevice(const QPainter*)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:465: error: redefinition of ‘void [[QgsDiagramRendererV]]2::_readXML(const QDomElement&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:160: error: ‘void [[QgsDiagramRendererV]]2::_readXML(const QDomElement&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:483: error: redefinition of ‘void [[QgsDiagramRendererV]]2::_writeXML(QDomElement&, QDomDocument&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:178: error: ‘void [[QgsDiagramRendererV]]2::_writeXML(QDomElement&, QDomDocument&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:491: error: redefinition of ‘QgsSingleCategoryDiagramRenderer::QgsSingleCategoryDiagramRenderer()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:186: error: ‘QgsSingleCategoryDiagramRenderer::QgsSingleCategoryDiagramRenderer()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:495: error: redefinition of ‘QgsSingleCategoryDiagramRenderer::~QgsSingleCategoryDiagramRenderer()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:190: error: ‘virtual [[QgsSingleCategoryDiagramRenderer]]::~QgsSingleCategoryDiagramRenderer()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:499: error: redefinition of ‘bool [[QgsSingleCategoryDiagramRenderer]]::diagramSettings(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&, [[QgsDiagramSettings]]&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:194: error: ‘virtual bool [[QgsSingleCategoryDiagramRenderer]]::diagramSettings(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&, [[QgsDiagramSettings]]&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:505: error: redefinition of ‘QList<QgsDiagramSettings> [[QgsSingleCategoryDiagramRenderer]]::diagramSettings() const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:200: error: ‘virtual QList<QgsDiagramSettings> [[QgsSingleCategoryDiagramRenderer]]::diagramSettings() const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:512: error: redefinition of ‘void [[QgsSingleCategoryDiagramRenderer]]::readXML(const QDomElement&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:207: error: ‘virtual void [[QgsSingleCategoryDiagramRenderer]]::readXML(const QDomElement&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:524: error: redefinition of ‘void [[QgsSingleCategoryDiagramRenderer]]::writeXML(QDomElement&, QDomDocument&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:219: error: ‘virtual void [[QgsSingleCategoryDiagramRenderer]]::writeXML(QDomElement&, QDomDocument&) const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:533: error: redefinition of ‘QgsLinearlyInterpolatedDiagramRenderer::QgsLinearlyInterpolatedDiagramRenderer()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:228: error: ‘QgsLinearlyInterpolatedDiagramRenderer::QgsLinearlyInterpolatedDiagramRenderer()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:537: error: redefinition of ‘QgsLinearlyInterpolatedDiagramRenderer::~QgsLinearlyInterpolatedDiagramRenderer()’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:232: error: ‘virtual [[QgsLinearlyInterpolatedDiagramRenderer]]::~QgsLinearlyInterpolatedDiagramRenderer()’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:541: error: redefinition of ‘QList<QgsDiagramSettings> [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSettings() const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:236: error: ‘virtual QList<QgsDiagramSettings> [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSettings() const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:548: error: redefinition of ‘bool [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSettings(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&, [[QgsDiagramSettings]]&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:243: error: ‘virtual bool [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSettings(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&, [[QgsDiagramSettings]]&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:555: error: redefinition of ‘QList<int> [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramAttributes() const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:250: error: ‘virtual QList<int> [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramAttributes() const’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:565: error: redefinition of ‘QSizeF [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSize(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:260: error: ‘virtual QSizeF [[QgsLinearlyInterpolatedDiagramRenderer]]::diagramSize(const [[QgsAttributeMap]]&, const [[QgsRenderContext]]&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:580: error: redefinition of ‘void [[QgsLinearlyInterpolatedDiagramRenderer]]::readXML(const QDomElement&)’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:275: error: ‘virtual void [[QgsLinearlyInterpolatedDiagramRenderer]]::readXML(const QDomElement&)’ previously defined here
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:597: error: redefinition of ‘void [[QgsLinearlyInterpolatedDiagramRenderer]]::writeXML(QDomElement&, QDomDocument&) const’
/home/timlinux/dev/cpp/qgis/src/core/qgsdiagramrendererv2.cpp:292: error: ‘virtual void [[QgsLinearlyInterpolatedDiagramRenderer]]::writeXML(QDomElement&, QDomDocument&) const’ previously defined here
maker2: *** [src/core/CMakeFiles/qgis_core.dir/qgsdiagramrendererv2.cpp.o] Error 1
/home/timlinux/dev/cpp/qgis/src/core/qgspallabeling.cpp: In member function ‘virtual int [[QgsPalLabeling]]::addDiagramLayer(QgsVectorLayer*, [[QgsDiagramLayerSettings]]&)’:
/home/timlinux/dev/cpp/qgis/src/core/qgspallabeling.cpp:764: warning: ‘const [[QgsCoordinateReferenceSystem]]& [[QgsMapLayer]]::srs()’ is deprecated (declared at /home/timlinux/dev/cpp/qgis/src/core/qgsmaplayer.h:227)
maker1: *** [src/core/CMakeFiles/qgis_core.dir/all] Error 2
make: *** [all] Error 2

Sorry I didnt have time to try to work out the problem myself.

Regards

Tim

#5 Updated by Marco Hugentobler over 9 years ago

Hi Tim

With svn patches, you always need to remove added files before applying a second time (otherwise, the content of the added file is just appended to the existing one and you get the redefinition errors).

the following should work:
rm src/core/qgsdiagram.h
rm src/core/qgsdiagram.cpp
rm src/core/qgsdiagramrendererv2.h
rm src/core/qgsdiagramrendererv2.cpp
svn revert -R .
patch -p0 < patchfile

then compile again

#6 Updated by Tim Sutton over 9 years ago

Replying to [comment:6 mhugent]:

Hi Tim

With svn patches, you always need to remove added files before applying a second time (otherwise, the content of the added file is just appended to the existing one and you get the redefinition errors).

Hi. Sorry I did git reset --hard before building but I didnt notice your patch added new files so those never got cleaned away. It built successfully now.

Regards

Tim

the following should work:
rm src/core/qgsdiagram.h
rm src/core/qgsdiagram.cpp
rm src/core/qgsdiagramrendererv2.h
rm src/core/qgsdiagramrendererv2.cpp
svn revert -R .
patch -p0 < patchfile

then compile again

#7 Updated by Tim Sutton over 9 years ago

Hi Marco

I wanted to comment that the 'Fixed Size' box was checked for me by default, but the size defaults to 0. In the beginning of testing I couldnt figure out why no diagrams were rendering and I am sure 'normal' users will be caught out by this too.

Lastly I had issues trying to make it work together with labels for the same layer. When I enabled labelling, no diagrams showed (no matter what scale). Even after turning off labels, you have to go back to layer properties and press apply before the diagrams reappear.

Lastly it seems priority for the diagrams is set to 0 by default which I thought might be the cause of the above, but changing priority had no effect.

I'm going to attach the sample dataset I used.

Regards

Tim

#8 Updated by Marco Hugentobler over 9 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

Applied in c3ac6df9 (SVN r15504). The mentioned issues are fixed, however there is still a couple of smaller problems that will need to be adressed in trunk (e.g. printing).

#9 Updated by John Tull over 9 years ago

I've no idea if this might be related, but I now seem to have very few labels showing on the canvas. I.e., for a point file, labels seem to not be drawing as if collision avoidance is coming into play. Ticking the "Features don't act as obstacles" option does not change anything.

Also available in: Atom PDF