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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Feb 17 07:51:45 EST 2009


Author: mhugent
Date: 2009-02-17 07:51:45 -0500 (Tue, 17 Feb 2009)
New Revision: 10186

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/qgsdiagramoverlay.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
Log:
read/write support also for proportional svg symbols

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:22:25 UTC (rev 10185)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
@@ -46,43 +46,3 @@
 
      return 1.0;
  }
-
- bool QgsDiagramFactory::writeScalingAttributesToXML(QDomElement& factoryElem, QDomDocument& doc) const
- {
-    if(factoryElem.isNull())
-     {
-        return false;
-    }
-
-     QgsAttributeList::const_iterator it = mScalingAttributes.constBegin();
-     for(; it != mScalingAttributes.constEnd(); ++it)
-     {
-        QDomElement scalingAttributeElem = doc.createElement("scalingAttribute");
-        QDomText scalingAttributeText = doc.createTextNode(QString::number(*it));
-        scalingAttributeElem.appendChild(scalingAttributeText);
-        factoryElem.appendChild(scalingAttributeElem);
-     }
-     return false;
- }
-
- bool QgsDiagramFactory::readScalingAttributesFromXML(const QDomElement& factoryElem)
- {
-     if(factoryElem.isNull())
-     {
-        return false;
-     }
-
-     mScalingAttributes.clear();
-     QDomNodeList scalingAttributeList = factoryElem.elementsByTagName("scalingAttribute");
-     for(int i = 0; i < scalingAttributeList.size(); ++i)
-     {
-        QDomElement currentScalingElem = scalingAttributeList.at(i).toElement();
-        bool conversionSuccess = false;
-        int currentIndex = currentScalingElem.text().toInt(&conversionSuccess);
-        if(conversionSuccess)
-        {
-            mScalingAttributes.push_back(currentIndex);
-        }
-     }
-     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:22:25 UTC (rev 10185)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramfactory.h	2009-02-17 12:51:45 UTC (rev 10186)
@@ -98,12 +98,6 @@
   /**List of scaling attribute indexes (the values are summed up to
      receive the value that is used for diagram size calculation)*/
   QgsAttributeList mScalingAttributes;
-
-  /**Writes the scaling attributes indices to project file. Usually called from subclasses*/
-  bool writeScalingAttributesToXML(QDomElement& factoryElem, QDomDocument& doc) const;
-
-  /**Reads the scaling attributes from project file. Usually called from subclasses*/
-  bool readScalingAttributesFromXML(const QDomElement& factoryElem);
 };
 
 #endif

Modified: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	2009-02-17 12:22:25 UTC (rev 10185)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	2009-02-17 12:51:45 UTC (rev 10186)
@@ -186,10 +186,15 @@
   QList<int> classAttrList;
 
   //classificationField
-  QDomNodeList classificationFieldList = overlayElem.elementsByTagName("classificationfield");
+  QDomNodeList classificationFieldList = overlayElem.elementsByTagName("scalingAttribute");
   for(int i = 0; i < classificationFieldList.size(); ++i)
     {
-      classAttrList.push_back(classificationFieldList.at(i).toElement().text().toInt());
+      bool conversionSuccess = false;
+      int classificationField = classificationFieldList.at(i).toElement().text().toInt(&conversionSuccess);
+      if(conversionSuccess)
+      {
+        classAttrList.push_back(classificationFieldList.at(i).toElement().text().toInt());
+       }
     }
 
   theDiagramRenderer = new QgsDiagramRenderer(classAttrList);
@@ -243,6 +248,7 @@
         delete newFactory;
         return false;
     }
+    newFactory->setScalingAttributes(classAttrList);
    theDiagramRenderer->setFactory(newFactory);
 
   //Read renderer specific settings
@@ -287,7 +293,18 @@
       if(f)
 	{
 	  f->writeXML(overlayElement, doc);
-	}
+        }
+
+      //write classification attributes
+       QList<int> scalingAttributes = mDiagramRenderer->classificationAttributes();
+       QList<int>::const_iterator it = scalingAttributes.constBegin();
+       for(; it != scalingAttributes.constEnd(); ++it)
+       {
+            QDomElement scalingAttributeElem = doc.createElement("scalingAttribute");
+            QDomText scalingAttributeText = doc.createTextNode(QString::number(*it));
+            scalingAttributeElem.appendChild(scalingAttributeText);
+            overlayElement.appendChild(scalingAttributeElem);
+       }
     }
   return true;
 }

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:22:25 UTC (rev 10185)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgssvgdiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
@@ -98,9 +98,6 @@
     factoryElem.appendChild(svgPathElem);
     overlay_node.appendChild(factoryElem);
 
-    //and superclass specific information
-    writeScalingAttributesToXML(factoryElem, doc);
-
     return true;
 }
 
@@ -126,9 +123,6 @@
     }
     mSvgFilePath = svgFilePath;
 
-    //read scaling attributes by superclass
-    readScalingAttributesFromXML(factoryElem);
-
     return true;
 }
 

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:22:25 UTC (rev 10185)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp	2009-02-17 12:51:45 UTC (rev 10186)
@@ -99,9 +99,6 @@
   //write subclass specific information
   _writeXML(factoryElement, doc);
 
-  //and superclass specific information
-  writeScalingAttributesToXML(factoryElement, doc);
-
   return true;
 }
 
@@ -195,8 +192,5 @@
       mCategories.push_back(newCategory);
     }
 
-  //read scaling attributes by superclass
-  readScalingAttributesFromXML(factoryElem);
-
   return true;
 }



More information about the QGIS-commit mailing list