[QGIS Commit] r10180 -
branches/vector_overlay_branch/src/plugins/diagram_overlay
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Feb 16 10:44:43 EST 2009
Author: mhugent
Date: 2009-02-16 10:44:43 -0500 (Mon, 16 Feb 2009)
New Revision: 10180
Modified:
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.cpp
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.h
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.h
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.h
Log:
save also svg diagram types to project
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.cpp 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.cpp 2009-02-16 15:44:43 UTC (rev 10180)
@@ -151,3 +151,11 @@
//calculate value/pixel ratio
return (size / scalingValue);
}
+
+bool QgsBarDiagramFactory::_writeXML(QDomNode& factory_node, QDomDocument& doc) const
+{
+ QDomElement barWidthElem = doc.createElement("barWidth");
+ QDomText barWidthText = doc.createTextNode(QString::number(mBarWidth));
+ barWidthElem.appendChild(barWidthText);
+ factory_node.appendChild(barWidthElem);
+}
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.h 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsbardiagramfactory.h 2009-02-16 15:44:43 UTC (rev 10180)
@@ -45,6 +45,9 @@
know if e.g. size has to be calculated proportional to pie area*/
QgsDiagramFactory::SizeType sizeType() const {return QgsDiagramFactory::HEIGHT;}
+ /**Writes bar with into the project file*/
+ bool _writeXML(QDomNode& factory_node, QDomDocument& doc) const;
+
private:
/**width of one bar (default 5 mm)*/
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h 2009-02-16 15:44:43 UTC (rev 10180)
@@ -90,6 +90,9 @@
/**Returns the attributes represented in the pies / bars*/
virtual QgsAttributeList categoryAttributes() const {return QgsAttributeList();}
+ /**Read settings from project file*/
+ virtual bool readXML(const QDomNode& factoryNode) = 0;
+
protected:
/**Size units of diagram items*/
SizeUnit mSizeUnit;
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.h 2009-02-16 15:44:43 UTC (rev 10180)
@@ -96,7 +96,7 @@
QList<QgsDiagramItem> mItems;
/**Describes the type of interpolation (linear by default)*/
ItemInterpretation mItemInterpretation;
- /**Factor to multiply the sizes*/
+ /**Factor to multiply the sizes (e.g. used by QGIS mapserver dependent on the current scale)*/
double mScaleFactor;
/**Searches the value of the classification attribute(s). Considers that there
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp 2009-02-16 15:44:43 UTC (rev 10180)
@@ -88,5 +88,22 @@
return mRenderer.load(data);
}
+bool QgsSVGDiagramFactory::writeXML(QDomNode& overlay_node, QDomDocument& doc) const
+{
+ QDomElement factoryElem = doc.createElement("factory");
+ factoryElem.setAttribute("type", "svg");
+ QDomElement svgPathElem = doc.createElement("svgPath");
+ QDomText svgPathText = doc.createTextNode(mSvgFilePath);
+ svgPathElem.appendChild(svgPathText);
+ factoryElem.appendChild(svgPathElem);
+ overlay_node.appendChild(factoryElem);
+ return true;
+}
+bool QgsSVGDiagramFactory::readXML(const QDomNode& factoryNode)
+{
+ //soon...
+}
+
+
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.h 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.h 2009-02-16 15:44:43 UTC (rev 10180)
@@ -49,7 +49,7 @@
@param height out: the height of the diagram image in pixels*/
int getDiagramDimensions(int size, const QgsFeature& f, const QgsRenderContext& context, int& width, int& height) const;
- bool writeXML(QDomNode& overlay_node, QDomDocument& doc) const {return false;} //later...
+ bool writeXML(QDomNode& overlay_node, QDomDocument& doc) const;
/**Sets the SVG data to be rendered.
@return true in case of success*/
@@ -57,6 +57,9 @@
QString svgFilePath() const {return mSvgFilePath;}
+ /**Read settings from project file*/
+ bool readXML(const QDomNode& factoryNode);
+
private:
mutable QSvgRenderer mRenderer;
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp 2009-02-16 15:44:43 UTC (rev 10180)
@@ -47,11 +47,15 @@
{
QDomElement overlayElement = overlay_node.toElement();
+ QDomElement factoryElement = doc.createElement("factory");
+ factoryElement.setAttribute("type", diagramType());
+ overlay_node.appendChild(factoryElement);
+
//well known name
QDomElement wellKnownNameElem = doc.createElement("wellknownname");
QDomText wknText = doc.createTextNode(mDiagramType);
wellKnownNameElem.appendChild(wknText);
- overlayElement.appendChild(wellKnownNameElem);
+ factoryElement.appendChild(wellKnownNameElem);
//classification fields
QList<int>::const_iterator scaling_it = mScalingAttributes.constBegin();
@@ -60,7 +64,7 @@
QDomElement classificationFieldElem = doc.createElement("classificationfield");
QDomText classFieldText = doc.createTextNode(QString::number(*scaling_it));
classificationFieldElem.appendChild(classFieldText);
- overlayElement.appendChild(classificationFieldElem);
+ factoryElement.appendChild(classificationFieldElem);
}
//diagram categories
@@ -89,8 +93,12 @@
currentCategoryElem.appendChild(currentBrushElem);
currentCategoryElem.appendChild(currentPenElem);
- overlayElement.appendChild(currentCategoryElem);
+ factoryElement.appendChild(currentCategoryElem);
}
+
+ //write subclass specific information
+ _writeXML(factoryElement, doc);
+
return true;
}
@@ -123,3 +131,8 @@
}
return categoryAttList;
}
+
+bool QgsWKNDiagramFactory::readXML(const QDomNode& factoryNode)
+{
+ return false; //soon...
+}
Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.h 2009-02-16 15:27:13 UTC (rev 10179)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.h 2009-02-16 15:44:43 UTC (rev 10180)
@@ -38,8 +38,11 @@
public:
QgsWKNDiagramFactory();
virtual ~QgsWKNDiagramFactory();
-
+
+ /**Writes the wkn diagram information into a <factory> tag*/
bool writeXML(QDomNode& overlay_node, QDomDocument& doc) const;
+ /**Possibility for wkn subclasses to write specific information into the XML document*/
+ virtual bool _writeXML(QDomNode& factory_node, QDomDocument& doc) const {};
/**Returns the property described by the size (e.g. diameter or height). This can be important to
know if e.g. size has to be calculated proportional to pie area*/
virtual QgsDiagramFactory::SizeType sizeType() const = 0;
@@ -58,6 +61,9 @@
/**Returns the supported well known names in a list*/
static void supportedWellKnownNames(std::list<QString>& names);
+ /**Read wkn settings from project file*/
+ bool readXML(const QDomNode& factoryNode);
+
protected:
/**Well known diagram name (e.g. pie, bar, line)*/
More information about the QGIS-commit
mailing list