From 5bdb63fa02b9c445453380f38848ad9b54f89ce6 Mon Sep 17 00:00:00 2001 From: rabla Date: Fri, 13 May 2005 15:40:26 +0000 Subject: [PATCH] Qt bug fix for markers git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3371 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgsmarkercatalogue.cpp | 20 +++++++++++++++----- src/qgsmarkercatalogue.h | 4 ++-- src/qgssymbol.cpp | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/qgsmarkercatalogue.cpp b/src/qgsmarkercatalogue.cpp index 6f958c3c604..1d6f27c0bf5 100644 --- a/src/qgsmarkercatalogue.cpp +++ b/src/qgsmarkercatalogue.cpp @@ -88,13 +88,13 @@ QgsMarkerCatalogue *QgsMarkerCatalogue::instance() return QgsMarkerCatalogue::mMarkerCatalogue; } -QPicture QgsMarkerCatalogue::marker ( QString fullName, int size, QPen pen, QBrush brush, int oversampling ) +QPicture QgsMarkerCatalogue::marker ( QString fullName, int size, QPen pen, QBrush brush, int oversampling, bool qtBug ) { //std::cerr << "QgsMarkerCatalogue::marker" << std::endl; QPicture picture; if ( fullName.left(5) == "hard:" ) { - return hardMarker ( fullName.mid(5), size, pen, brush, oversampling ); + return hardMarker ( fullName.mid(5), size, pen, brush, oversampling, qtBug ); } else if ( fullName.left(4) == "svg:" ) { return svgMarker ( fullName.mid(4), size, oversampling ); } @@ -136,7 +136,7 @@ QPicture QgsMarkerCatalogue::svgMarker ( QString name, int s, int oversampling ) return picture; } -QPicture QgsMarkerCatalogue::hardMarker ( QString name, int s, QPen pen, QBrush brush, int oversampling ) +QPicture QgsMarkerCatalogue::hardMarker ( QString name, int s, QPen pen, QBrush brush, int oversampling, bool qtBug ) { // Size of polygon symbols is calculated so that the area is equal to circle with // diameter mPointSize @@ -184,7 +184,12 @@ QPicture QgsMarkerCatalogue::hardMarker ( QString name, int s, QPen pen, QBrush // -> reset boundingRect for cross, cross2 else if ( name == "cross" ) { - int add = 1; // lw always > 0 + int add; + if ( qtBug ) { + add = 1; // lw always > 0 + } else { + add = 0; + } picpainter.drawLine(0, half, size-1+add, half); // horizontal picpainter.drawLine(half, 0, half, size-1+add); // vertical @@ -195,7 +200,12 @@ QPicture QgsMarkerCatalogue::hardMarker ( QString name, int s, QPen pen, QBrush half = (int) floor( s/2/sqrt(2)); size = 2*half + 1; - int add = 1; // lw always > 0 + int add; + if ( qtBug ) { + add = 1; // lw always > 0 + } else { + add = 0; + } int addwidth = (int) ( 0.5 * lw ); // width correction, cca lw/2 * cos(45) diff --git a/src/qgsmarkercatalogue.h b/src/qgsmarkercatalogue.h index 6326ea383f4..1db58eca4bd 100644 --- a/src/qgsmarkercatalogue.h +++ b/src/qgsmarkercatalogue.h @@ -43,7 +43,7 @@ public: /** Returns picture of the marker * \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg */ - QPicture marker ( QString fullName, int size, QPen pen, QBrush brush, int oversampling = 1 ); + QPicture marker ( QString fullName, int size, QPen pen, QBrush brush, int oversampling = 1, bool qtBug = true ); private: @@ -56,7 +56,7 @@ private: QStringList mList; /** Hard coded */ - QPicture hardMarker ( QString name, int size, QPen pen, QBrush brush, int oversampling = 1 ); + QPicture hardMarker ( QString name, int size, QPen pen, QBrush brush, int oversampling = 1, bool qtBug = true ); /** Hard coded */ QPicture svgMarker ( QString name, int size, int oversampling = 1 ); diff --git a/src/qgssymbol.cpp b/src/qgssymbol.cpp index b2c396de5ce..bcbe99d0860 100644 --- a/src/qgssymbol.cpp +++ b/src/qgssymbol.cpp @@ -230,14 +230,14 @@ void QgsSymbol::cache2( double widthScale, QColor selectionColor ) mPointSymbolPicture2 = QgsMarkerCatalogue::instance()->marker ( mPointSymbolName, mPointSize, - pen, mBrush, 1 ); + pen, mBrush, 1, false ); QBrush brush = mBrush; brush.setColor ( selectionColor ); pen.setColor ( selectionColor ); mPointSymbolPictureSelected2 = QgsMarkerCatalogue::instance()->marker ( - mPointSymbolName, mPointSize, pen, brush, 1 ); + mPointSymbolName, mPointSize, pen, brush, 1, false ); mSelectionColor2 = selectionColor;