Skip to content

Commit 0b22e53

Browse files
author
homann
committed
Upgrade point size when reading old project to make it look the same. Also change default point size to same loko as previously
git-svn-id: http://svn.osgeo.org/qgis/trunk@7962 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 06e44dc commit 0b22e53

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/core/qgsprojectfiletransform.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,35 @@ void QgsProjectFileTransform::transform091to092()
200200
rasterProperty.namedItem("grayBandNameQString").toElement().setTagName("mGrayBandName");
201201
}
202202

203+
// Changing symbol size for hard: symbols
204+
QDomNodeList symbolPropertyList = mDom.elementsByTagName("symbol");
205+
for (int i = 0; i < symbolPropertyList.count(); i++)
206+
{
207+
// Get the <poinmtsymbol> to check for 'hard:' for each <symbol>
208+
QDomNode symbolProperty = symbolPropertyList.item(i);
209+
210+
QDomElement pointSymbol = symbolProperty.firstChildElement("pointsymbol");
211+
if ( pointSymbol.text().startsWith("hard:") )
212+
{
213+
// Get pointsize and line width
214+
int lineWidth = symbolProperty.firstChildElement("outlinewidth").text().toInt();
215+
int pointSize = symbolProperty.firstChildElement("pointsize").text().toInt();
216+
// Just a precaution, checking for 0
217+
if (pointSize != 0)
218+
{
219+
// int r = (s-2*lw)/2-1 --> 2r = (s-2*lw)-2 --> 2r+2 = s-2*lw
220+
// --> 2r+2+2*lw = s
221+
// where '2r' is the old size.
222+
pointSize = pointSize+2+2*lineWidth;
223+
QgsDebugMsg(QString("Setting point size to %1").arg(pointSize));
224+
QDomElement newPointSizeProperty=mDom.createElement("pointsize");
225+
QDomText newPointSizeTxt=mDom.createTextNode( QString::number(pointSize) );
226+
newPointSizeProperty.appendChild(newPointSizeTxt);
227+
symbolProperty.replaceChild(newPointSizeProperty, pointSymbol);
228+
}
229+
}
230+
}
231+
203232
}
204233
return;
205234

src/core/symbology/qgssymbol.cpp

Lines changed: 1 addition & 1 deletion
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( 11 ),
43+
mPointSize( 10 ),
4444
mPointSymbolImage(1,1, QImage::Format_ARGB32_Premultiplied),
4545
mWidthScale(1.0),
4646
mCacheUpToDate( false ),

0 commit comments

Comments
 (0)