[QGIS Commit] r8447 - trunk/qgis/src/core/symbology

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat May 17 05:58:15 EDT 2008


Author: mhugent
Date: 2008-05-17 05:58:15 -0400 (Sat, 17 May 2008)
New Revision: 8447

Modified:
   trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp
   trunk/qgis/src/core/symbology/qgsmarkercatalogue.h
   trunk/qgis/src/core/symbology/qgssymbol.cpp
Log:
Fix for problems with floating point outline width for hard markers

Modified: trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp
===================================================================
--- trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp	2008-05-16 00:56:34 UTC (rev 8446)
+++ trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp	2008-05-17 09:58:15 UTC (rev 8447)
@@ -91,7 +91,7 @@
   return QgsMarkerCatalogue::mMarkerCatalogue;
 }
 
-QImage QgsMarkerCatalogue::imageMarker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
+QImage QgsMarkerCatalogue::imageMarker ( QString fullName, double size, QPen pen, QBrush brush, bool qtBug )
 {
       
   // 
@@ -100,7 +100,7 @@
   QImage myImage;
   if ( fullName.left(5) == "hard:" )
   {
-    myImage = QImage (size, size, QImage::Format_ARGB32_Premultiplied);
+    myImage = QImage (size + 1, size + 1, QImage::Format_ARGB32_Premultiplied);
   }
   else
   {
@@ -108,7 +108,7 @@
     // proportion of scale factor as in oritignal SVG TS XXX
     if (size < 1) size=1;
     //QPixmap myPixmap = QPixmap(width,height);
-    myImage = QImage(size,size, QImage::Format_ARGB32_Premultiplied);
+    myImage = QImage(size ,size , QImage::Format_ARGB32_Premultiplied);
   }
 
   // starting with transparent QImage
@@ -141,7 +141,7 @@
   return QImage(); // empty
 }
 
-QPicture QgsMarkerCatalogue::pictureMarker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
+QPicture QgsMarkerCatalogue::pictureMarker ( QString fullName, double size, QPen pen, QBrush brush, bool qtBug )
 {
 
   //
@@ -182,25 +182,25 @@
   return QPicture(); // empty
 }
 
-void QgsMarkerCatalogue::svgMarker ( QPainter * thepPainter, QString filename, int scaleFactor)
+void QgsMarkerCatalogue::svgMarker ( QPainter * thepPainter, QString filename, double scaleFactor)
 {
   QSvgRenderer mySVG;
   mySVG.load(filename);
   mySVG.render(thepPainter);
 }
 
-void QgsMarkerCatalogue::hardMarker (QPainter * thepPainter, QString name, int s, QPen pen, QBrush brush, bool qtBug )
+void QgsMarkerCatalogue::hardMarker (QPainter * thepPainter, QString name, double s, QPen pen, QBrush brush, bool qtBug )
 {
   // Size of polygon symbols is calculated so that the boundingbox is circumscribed
   // around a circle with diameter mPointSize
 
-  int half = s/2; // number of points from center
+  double half = s/2; // number of points from center
 
   QgsDebugMsg(QString("Hard marker size %1").arg(s));
 
   // Find out center coordinates.
-  int x_c = s/2;
-  int y_c = x_c;
+  double x_c = s/2;
+  double y_c = x_c;
 
   // Picture
   QPicture picture;
@@ -208,8 +208,8 @@
   thepPainter->setRenderHint(QPainter::Antialiasing);
 
   // Also width must be odd otherwise there are discrepancies visible in canvas!
-  int lw = (int)(2*floor((double)pen.width()/2)+1); // -> lw > 0
-  pen.setWidth(lw);
+  double lw = pen.widthF();//(int)(2*floor((double)pen.widthF()/2)+1); // -> lw > 0
+  pen.setWidthF(lw);
   thepPainter->setPen ( pen );
   thepPainter->setBrush( brush);
   QRect box;
@@ -217,7 +217,7 @@
   // Circle radius, is used for other figures also, when compensating for line
   // width is necessary.
 
-  int r = (s-2*lw)/2-1;
+  double r = (s-2*lw)/2-1;
   QgsDebugMsg(QString("Hard marker radius %1").arg(r));
 
   if ( name == "circle" ) 

Modified: trunk/qgis/src/core/symbology/qgsmarkercatalogue.h
===================================================================
--- trunk/qgis/src/core/symbology/qgsmarkercatalogue.h	2008-05-16 00:56:34 UTC (rev 8446)
+++ trunk/qgis/src/core/symbology/qgsmarkercatalogue.h	2008-05-17 09:58:15 UTC (rev 8447)
@@ -43,16 +43,16 @@
     /** Returns pixmap of the marker
      * \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
      */
-    QImage imageMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );
+    QImage imageMarker (QString fullName, double size, QPen pen, QBrush brush, bool qtBug = true );
 
     /** Returns qpicture of the marker
      * \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
      */
-    QPicture pictureMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );
+    QPicture pictureMarker (QString fullName, double size, QPen pen, QBrush brush, bool qtBug = true );
     
     /** Returns a pixmap given a filename of a svg marker
      *  NOTE: this method needs to be public static for QgsMarkerDialog::visualizeMarkers */
-    static void svgMarker (QPainter * thepPainter, QString name, int size );
+    static void svgMarker (QPainter * thepPainter, QString name, double size );
 private:
 
     /**Constructor*/
@@ -64,7 +64,7 @@
     QStringList mList;
 
     /** Hard coded */
-    void hardMarker (QPainter * thepPainter, QString name, int size, QPen pen, QBrush brush, bool qtBug = true );
+    void hardMarker (QPainter * thepPainter, QString name, double size, QPen pen, QBrush brush, bool qtBug = true );
 
 };
     

Modified: trunk/qgis/src/core/symbology/qgssymbol.cpp
===================================================================
--- trunk/qgis/src/core/symbology/qgssymbol.cpp	2008-05-16 00:56:34 UTC (rev 8446)
+++ trunk/qgis/src/core/symbology/qgssymbol.cpp	2008-05-17 09:58:15 UTC (rev 8447)
@@ -384,8 +384,7 @@
     //std::cerr << "QgsSymbol::cache2 widthScale = " << widthScale << std::endl;
 
     QPen pen = mPen;
-    pen.setWidth ( (int) ( widthScale * pen.width() ) );
-
+    pen.setWidthF(widthScale * pen.widthF());
     
     mPointSymbolImage2 = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, mPointSize * widthScale,
 	                        pen, mBrush, false );



More information about the QGIS-commit mailing list