Skip to content

Commit

Permalink
Allow point symbol sizes to be specifed in double format and allow sy…
Browse files Browse the repository at this point in the history
…mbols 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
  • Loading branch information
timlinux committed Aug 2, 2008
1 parent ee34205 commit e0692ef
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
8 changes: 8 additions & 0 deletions python/core/qgis.sip
Expand Up @@ -108,3 +108,11 @@ public:
* or user (~/.qgis.qgis.db) defined projection. */
const int USER_PROJECTION_START_ID;

//
// Constants for point symbols
//

/** Magic number that determines the minimum allowable point size for point symbols */
const float MINIMUM_POINT_SIZE;
/** Magic number that determines the minimum allowable point size for point symbols */
const float DEFAULT_POINT_SIZE;
4 changes: 2 additions & 2 deletions python/core/qgssymbol.sip
Expand Up @@ -51,9 +51,9 @@ class QgsSymbol
/**Get point symbol*/
virtual QString pointSymbolName() const;
/**Set size*/
virtual void setPointSize(int s);
virtual void setPointSize(double s);
/**Get size*/
virtual int pointSize() const;
virtual double pointSize() const;
//! Destructor
virtual ~QgsSymbol();

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgssinglesymboldialog.cpp
Expand Up @@ -184,7 +184,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer, bool disabl
connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged()));
connect (lstSymbols,SIGNAL(currentItemChanged ( QListWidgetItem * , QListWidgetItem * )),
this, SLOT (symbolChanged (QListWidgetItem * , QListWidgetItem * )));
connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
connect(mPointSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(resendSettingsChanged()));
connect(mRotationClassificationComboBox, SIGNAL(currentIndexChanged(const QString &)),
this, SLOT(resendSettingsChanged()));
connect(mScaleClassificationComboBox, SIGNAL(currentIndexChanged(const QString &)),
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgis.h
Expand Up @@ -133,6 +133,15 @@ class CORE_EXPORT QGis
* or user (~/.qgis.qgis.db) defined projection. */
const int USER_PROJECTION_START_ID=100000;

//
// Constants for point symbols
//

/** Magic number that determines the minimum allowable point size for point symbols */
const float MINIMUM_POINT_SIZE=0.1;
/** Magic number that determines the minimum allowable point size for point symbols */
const float DEFAULT_POINT_SIZE=2.0;

// FIXME: also in qgisinterface.h
#ifndef QGISEXTERN
#ifdef WIN32
Expand Down
2 changes: 2 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -3658,6 +3658,8 @@ QString QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramid
//
// Note: Make sure the raster is not opened in write mode
// in order to force overviews to be written to a separate file.
// Otherwise reoopen it in read/write mode to stick overviews
// into the same file (if supported)
//


Expand Down
28 changes: 14 additions & 14 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -40,7 +40,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString
mLabel(label),
mType(t),
mPointSymbolName( "hard:circle" ),
mPointSize( 3 ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
mWidthScale(1.0),
mCacheUpToDate( false ),
Expand All @@ -58,7 +58,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString
mPen( c ),
mBrush( c ),
mPointSymbolName( "hard:circle" ),
mPointSize( 3 ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
mWidthScale(1.0),
mCacheUpToDate( false ),
Expand All @@ -69,7 +69,7 @@ QgsSymbol::QgsSymbol(QGis::VectorType t, QString lvalue, QString uvalue, QString

QgsSymbol::QgsSymbol()
: mPointSymbolName( "hard:circle" ),
mPointSize( 3 ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
mWidthScale(1.0),
mCacheUpToDate( false ),
Expand All @@ -83,7 +83,7 @@ QgsSymbol::QgsSymbol(QColor c)
: mPen( c ),
mBrush( c ),
mPointSymbolName( "hard:circle" ),
mPointSize( 3 ),
mPointSize( DEFAULT_POINT_SIZE ),
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
mWidthScale(1.0),
mCacheUpToDate( false ),
Expand Down Expand Up @@ -227,17 +227,17 @@ QString QgsSymbol::pointSymbolName() const
return mPointSymbolName;
}

void QgsSymbol::setPointSize(int s)
void QgsSymbol::setPointSize(double s)
{
if ( s < 3 )
mPointSize = 3;
else
mPointSize = s;
if ( s < MINIMUM_POINT_SIZE )
mPointSize = MINIMUM_POINT_SIZE;
else
mPointSize = s;

mCacheUpToDate = mCacheUpToDate2 = false;
mCacheUpToDate = mCacheUpToDate2 = false;
}

int QgsSymbol::pointSize() const
double QgsSymbol::pointSize() const
{
return mPointSize;
}
Expand Down Expand Up @@ -343,12 +343,12 @@ QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QCol
{
pen.setColor ( selectionColor );
QBrush brush = mBrush;
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (float)(mPointSize * scale * widthScale * rasterScaleFactor),
pen, mBrush );
}
else
{
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (int)(mPointSize * scale * widthScale * rasterScaleFactor),
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, (float)(mPointSize * scale * widthScale * rasterScaleFactor),
pen, mBrush );
}

Expand Down Expand Up @@ -517,7 +517,7 @@ bool QgsSymbol::readXML( QDomNode & synode )
if ( ! psizenode.isNull() )
{
QDomElement psizeelement = psizenode.toElement();
setPointSize( psizeelement.text().toInt() );
setPointSize( psizeelement.text().toFloat() );
}

mRotationClassificationField = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology/qgssymbol.h
Expand Up @@ -83,9 +83,9 @@ class CORE_EXPORT QgsSymbol{
/**Get point symbol*/
virtual QString pointSymbolName() const;
/**Set size*/
virtual void setPointSize(int s);
virtual void setPointSize(double s);
/**Get size*/
virtual int pointSize() const;
virtual double pointSize() const;
//! Destructor
virtual ~QgsSymbol();

Expand Down Expand Up @@ -145,7 +145,7 @@ class CORE_EXPORT QgsSymbol{
/* Point symbol name */
QString mPointSymbolName;
/* Point size */
int mPointSize;
double mPointSize;

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

0 comments on commit e0692ef

Please sign in to comment.