[QGIS Commit] r8283 -
branches/diagram-branch/src/plugins/diagram_overlay
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Mar 26 10:18:28 EDT 2008
Author: mhugent
Date: 2008-03-26 10:18:27 -0400 (Wed, 26 Mar 2008)
New Revision: 8283
Modified:
branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp
branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h
branches/diagram-branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.cpp
Log:
Added scale factor for diagrams
Modified: branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp
===================================================================
--- branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp 2008-03-26 08:30:20 UTC (rev 8282)
+++ branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp 2008-03-26 14:18:27 UTC (rev 8283)
@@ -4,7 +4,7 @@
#include <cmath>
#include <QDomElement>
-QgsDiagramRenderer::QgsDiagramRenderer(const QList<int>& classificationAttributes): mClassificationAttributes(classificationAttributes)
+QgsDiagramRenderer::QgsDiagramRenderer(const QList<int>& classificationAttributes): mClassificationAttributes(classificationAttributes), mScaleFactor(1.0)
{
}
@@ -219,7 +219,7 @@
if(mItemInterpretation == ATTRIBUTE)
{
- size = value.toInt();
+ size = (int)(value.toDouble() * mScaleFactor);
return 0;
}
@@ -230,7 +230,7 @@
if(mItemInterpretation == CONSTANT)
{
- size = mItems.constBegin()->size;
+ size = (int)(mItems.constBegin()->size * mScaleFactor);
return 0;
}
@@ -246,7 +246,7 @@
{
if(current_it->value.toString() == value.toString())
{
- size = current_it->size;
+ size = (int)(current_it->size * mScaleFactor);
sizeAssigned = true;
}
}
@@ -263,13 +263,12 @@
{
if(last_it == mItems.constEnd()) //values below classifications receive first items size
{
- size = current_it->size;
+ size = (int)(current_it->size * mScaleFactor);
}
else
{
- size = interpolateSize(value.toDouble(), last_it->value.toDouble(), \
- current_it->value.toDouble(), \
- last_it->size, current_it->size);
+ size = (int)(interpolateSize(value.toDouble(), last_it->value.toDouble(), current_it->value.toDouble(), last_it->size, current_it->size) * mScaleFactor);
+
}
sizeAssigned = true;
break;
@@ -279,7 +278,7 @@
if(!sizeAssigned)//values above classification receive last items size
{
- size = last_it->size;
+ size = (int)(last_it->size * mScaleFactor);
}
}
Modified: branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h
===================================================================
--- branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h 2008-03-26 08:30:20 UTC (rev 8282)
+++ branches/diagram-branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h 2008-03-26 14:18:27 UTC (rev 8283)
@@ -79,6 +79,7 @@
QList<QgsDiagramItem> diagramItems() const {return mItems;}
void setItemInterpretation(ItemInterpretation i){mItemInterpretation = i;}
QgsDiagramRenderer::ItemInterpretation itemInterpretation() const {return mItemInterpretation;}
+ void setScaleFactor(double f){mScaleFactor = f;}
private:
QgsDiagramRenderer();
@@ -93,6 +94,8 @@
QList<QgsDiagramItem> mItems;
/**Describes the type of interpolation (linear by default)*/
ItemInterpretation mItemInterpretation;
+ /**Factor to multiply the sizes*/
+ double mScaleFactor;
/**Searches the value of the classification attribute(s). Considers that there
may be several attributes in case of numeric values (sum).
Modified: branches/diagram-branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.cpp
===================================================================
--- branches/diagram-branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.cpp 2008-03-26 08:30:20 UTC (rev 8282)
+++ branches/diagram-branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.cpp 2008-03-26 14:18:27 UTC (rev 8283)
@@ -58,6 +58,7 @@
itemList.push_back(firstItem);
itemList.push_back(secondItem);
renderer->setDiagramItems(itemList);
+ renderer->setItemInterpretation(QgsDiagramRenderer::LINEAR);
QgsWKNDiagramFactory* f = 0;//new QgsWKNDiagramFactory();
if(type == "Bar")
More information about the QGIS-commit
mailing list