Skip to content

Commit e0692ef

Browse files
author
timlinux
committed
Allow point symbol sizes to be specifed in double format and allow symbols smaller than 3. Added some constants in qgis.h to default and minimum allowable point sizes.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8976 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ee34205 commit e0692ef

File tree

7 files changed

+39
-20
lines changed

7 files changed

+39
-20
lines changed

python/core/qgis.sip

+8
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,11 @@ public:
108108
* or user (~/.qgis.qgis.db) defined projection. */
109109
const int USER_PROJECTION_START_ID;
110110

111+
//
112+
// Constants for point symbols
113+
//
114+
115+
/** Magic number that determines the minimum allowable point size for point symbols */
116+
const float MINIMUM_POINT_SIZE;
117+
/** Magic number that determines the minimum allowable point size for point symbols */
118+
const float DEFAULT_POINT_SIZE;

python/core/qgssymbol.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class QgsSymbol
5151
/**Get point symbol*/
5252
virtual QString pointSymbolName() const;
5353
/**Set size*/
54-
virtual void setPointSize(int s);
54+
virtual void setPointSize(double s);
5555
/**Get size*/
56-
virtual int pointSize() const;
56+
virtual double pointSize() const;
5757
//! Destructor
5858
virtual ~QgsSymbol();
5959

src/app/qgssinglesymboldialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer, bool disabl
184184
connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged()));
185185
connect (lstSymbols,SIGNAL(currentItemChanged ( QListWidgetItem * , QListWidgetItem * )),
186186
this, SLOT (symbolChanged (QListWidgetItem * , QListWidgetItem * )));
187-
connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
187+
connect(mPointSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(resendSettingsChanged()));
188188
connect(mRotationClassificationComboBox, SIGNAL(currentIndexChanged(const QString &)),
189189
this, SLOT(resendSettingsChanged()));
190190
connect(mScaleClassificationComboBox, SIGNAL(currentIndexChanged(const QString &)),

src/core/qgis.h

+9
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ class CORE_EXPORT QGis
133133
* or user (~/.qgis.qgis.db) defined projection. */
134134
const int USER_PROJECTION_START_ID=100000;
135135

136+
//
137+
// Constants for point symbols
138+
//
139+
140+
/** Magic number that determines the minimum allowable point size for point symbols */
141+
const float MINIMUM_POINT_SIZE=0.1;
142+
/** Magic number that determines the minimum allowable point size for point symbols */
143+
const float DEFAULT_POINT_SIZE=2.0;
144+
136145
// FIXME: also in qgisinterface.h
137146
#ifndef QGISEXTERN
138147
#ifdef WIN32

src/core/raster/qgsrasterlayer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -3658,6 +3658,8 @@ QString QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramid
36583658
//
36593659
// Note: Make sure the raster is not opened in write mode
36603660
// in order to force overviews to be written to a separate file.
3661+
// Otherwise reoopen it in read/write mode to stick overviews
3662+
// into the same file (if supported)
36613663
//
36623664

36633665

src/core/symbology/qgssymbol.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString
4040
mLabel(label),
4141
mType(t),
4242
mPointSymbolName( "hard:circle" ),
43-
mPointSize( 3 ),
43+
mPointSize( DEFAULT_POINT_SIZE ),
4444
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
4545
mWidthScale(1.0),
4646
mCacheUpToDate( false ),
@@ -58,7 +58,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString
5858
mPen( c ),
5959
mBrush( c ),
6060
mPointSymbolName( "hard:circle" ),
61-
mPointSize( 3 ),
61+
mPointSize( DEFAULT_POINT_SIZE ),
6262
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
6363
mWidthScale(1.0),
6464
mCacheUpToDate( false ),
@@ -69,7 +69,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString
6969

7070
QgsSymbol::QgsSymbol()
7171
: mPointSymbolName( "hard:circle" ),
72-
mPointSize( 3 ),
72+
mPointSize( DEFAULT_POINT_SIZE ),
7373
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
7474
mWidthScale(1.0),
7575
mCacheUpToDate( false ),
@@ -83,7 +83,7 @@ QgsSymbol::QgsSymbol(QColor c)
8383
: mPen( c ),
8484
mBrush( c ),
8585
mPointSymbolName( "hard:circle" ),
86-
mPointSize( 3 ),
86+
mPointSize( DEFAULT_POINT_SIZE ),
8787
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
8888
mWidthScale(1.0),
8989
mCacheUpToDate( false ),
@@ -227,17 +227,17 @@ QString QgsSymbol::pointSymbolName() const
227227
return mPointSymbolName;
228228
}
229229

230-
void QgsSymbol::setPointSize(int s)
230+
void QgsSymbol::setPointSize(double s)
231231
{
232-
if ( s < 3 )
233-
mPointSize = 3;
234-
else
235-
mPointSize = s;
232+
if ( s < MINIMUM_POINT_SIZE )
233+
mPointSize = MINIMUM_POINT_SIZE;
234+
else
235+
mPointSize = s;
236236

237-
mCacheUpToDate = mCacheUpToDate2 = false;
237+
mCacheUpToDate = mCacheUpToDate2 = false;
238238
}
239239

240-
int QgsSymbol::pointSize() const
240+
double QgsSymbol::pointSize() const
241241
{
242242
return mPointSize;
243243
}
@@ -343,12 +343,12 @@ QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QCol
343343
{
344344
pen.setColor ( selectionColor );
345345
QBrush brush = mBrush;
346-
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
346+
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (float)(mPointSize * scale * widthScale * rasterScaleFactor),
347347
pen, mBrush );
348348
}
349349
else
350350
{
351-
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
351+
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (float)(mPointSize * scale * widthScale * rasterScaleFactor),
352352
pen, mBrush );
353353
}
354354

@@ -517,7 +517,7 @@ bool QgsSymbol::readXML( QDomNode & synode )
517517
if ( ! psizenode.isNull() )
518518
{
519519
QDomElement psizeelement = psizenode.toElement();
520-
setPointSize( psizeelement.text().toInt() );
520+
setPointSize( psizeelement.text().toFloat() );
521521
}
522522

523523
mRotationClassificationField = -1;

src/core/symbology/qgssymbol.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class CORE_EXPORT QgsSymbol{
8383
/**Get point symbol*/
8484
virtual QString pointSymbolName() const;
8585
/**Set size*/
86-
virtual void setPointSize(int s);
86+
virtual void setPointSize(double s);
8787
/**Get size*/
88-
virtual int pointSize() const;
88+
virtual double pointSize() const;
8989
//! Destructor
9090
virtual ~QgsSymbol();
9191

@@ -145,7 +145,7 @@ class CORE_EXPORT QgsSymbol{
145145
/* Point symbol name */
146146
QString mPointSymbolName;
147147
/* Point size */
148-
int mPointSize;
148+
double mPointSize;
149149

150150
/* TODO Because for printing we always need a symbol without oversampling but with line width scale,
151151
* we keep also separate picture with line width scale */

0 commit comments

Comments
 (0)