[QGIS Commit] r10187 - branches/vector_overlay_branch/src/plugins/diagram_overlay

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Feb 17 08:09:03 EST 2009


Author: mhugent
Date: 2009-02-17 08:09:03 -0500 (Tue, 17 Feb 2009)
New Revision: 10187

Modified:
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
Log:
Read and save diagram units to xml (can be mm or map units)

Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.cpp	2009-02-17 13:09:03 UTC (rev 10187)
@@ -46,3 +46,40 @@
 
      return 1.0;
  }
+
+bool QgsDiagramFactory::writeSizeUnits(QDomElement& factoryElem, QDomDocument& doc) const
+{
+    if(factoryElem.isNull())
+    {
+        return false;
+    }
+
+    if(mSizeUnit == MM)
+    {
+        factoryElem.setAttribute("sizeUnits", "MM");
+    }
+    else if(mSizeUnit == MapUnits)
+    {
+        factoryElem.setAttribute("sizeUnits", "MapUnits");
+    }
+    return true;
+}
+
+bool QgsDiagramFactory::readSizeUnits(const QDomElement& factoryElem)
+{
+    if(factoryElem.isNull())
+    {
+        return false;
+    }
+
+    QString unitString = factoryElem.attribute("sizeUnits");
+    if(unitString == "MapUnits")
+    {
+        mSizeUnit = MapUnits;
+    }
+    else
+    {
+        mSizeUnit = MM;
+    }
+    return true;
+}

Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h	2009-02-17 12:51:45 UTC (rev 10186)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h	2009-02-17 13:09:03 UTC (rev 10187)
@@ -91,6 +91,9 @@
   /**Read settings from project file*/
   virtual bool readXML(const QDomNode& factoryNode) = 0;
 
+  bool writeSizeUnits(QDomElement& factoryElem, QDomDocument& doc) const;
+  bool readSizeUnits(const QDomElement& factoryElem);
+
  protected:
   /**Size units of diagram items*/
   SizeUnit mSizeUnit;

Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp	2009-02-17 13:09:03 UTC (rev 10187)
@@ -92,6 +92,9 @@
 {
     QDomElement factoryElem = doc.createElement("factory");
     factoryElem.setAttribute("type", "svg");
+    //add size units as an attribute to the factory element
+    writeSizeUnits(factoryElem, doc);
+
     QDomElement svgPathElem = doc.createElement("svgPath");
     QDomText svgPathText = doc.createTextNode(mSvgFilePath);
     svgPathElem.appendChild(svgPathText);
@@ -109,6 +112,9 @@
         return false;
     }
 
+    //size units
+    readSizeUnits(factoryElem);
+
     //get <svgPath> element
     QDomElement svgPathElem = factoryElem.namedItem("svgPath").toElement();
     if(svgPathElem.isNull())

Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp	2009-02-17 13:09:03 UTC (rev 10187)
@@ -49,6 +49,8 @@
 
   QDomElement factoryElement = doc.createElement("factory");
   factoryElement.setAttribute("type", diagramType());
+    //add size units as an attribute to the factory element
+  writeSizeUnits(factoryElement, doc);
   overlay_node.appendChild(factoryElement);
 
   //well known name
@@ -98,7 +100,6 @@
 
   //write subclass specific information
   _writeXML(factoryElement, doc);
-
   return true;
 }
 
@@ -140,6 +141,9 @@
         return false;
     }
 
+    //size units
+    readSizeUnits(factoryElem);
+
     //wellknownname
   QDomNodeList wknNodeList = factoryElem.elementsByTagName("wellknownname");
   if(wknNodeList.size() < 1)



More information about the QGIS-commit mailing list