[QGIS Commit] r9677 - in branches/vector_overlay_branch/src/plugins: . diagram_overlay

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Nov 21 09:09:59 EST 2008


Author: mhugent
Date: 2008-11-21 09:09:59 -0500 (Fri, 21 Nov 2008)
New Revision: 9677

Added:
   branches/vector_overlay_branch/src/plugins/diagram_overlay/CMakeLists.txt
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramcategory.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramdialog.h
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlayplugin.h
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrendererwidget.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.h
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialogbase.ui
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgspiediagramfactory.cpp
   branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
   branches/vector_overlay_branch/src/plugins/qgsapplydialog.h
   branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.cpp
   branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.h
Log:
Added some new files

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/CMakeLists.txt
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/CMakeLists.txt	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/CMakeLists.txt	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,55 @@
+########################################################
+# Files
+
+SET (DIAGRAMOVERLAY_SRCS
+     qgsdiagramdialog.cpp
+     qgsdiagramcategory.cpp
+     qgswkndiagramfactory.cpp
+     qgsbardiagramfactory.cpp
+     qgspiediagramfactory.cpp
+     qgssvgdiagramfactory.cpp
+     qgsdiagramoverlay.cpp
+     qgsdiagramoverlayplugin.cpp
+     qgsdiagramrenderer.cpp
+     qgsdiagramrendererwidget.cpp
+     qgslinearlyscalingdialog.cpp
+)
+
+SET (DIAGRAMOVERLAY_UIS qgsdiagramdialogbase.ui qgslinearlyscalingdialogbase.ui)
+
+SET (DIAGRAMOVERLAY_MOC_HDRS
+     qgsdiagramoverlayplugin.h
+     qgsdiagramdialog.h
+     qgslinearlyscalingdialog.h
+)
+
+
+########################################################
+# Build
+
+QT4_WRAP_UI (DIAGRAMOVERLAY_UIS_H  ${DIAGRAMOVERLAY_UIS})
+
+QT4_WRAP_CPP (DIAGRAMOVERLAY_MOC_SRCS  ${DIAGRAMOVERLAY_MOC_HDRS})
+
+ADD_LIBRARY (diagramoverlay MODULE ${DIAGRAMOVERLAY_UIS_H} ${DIAGRAMOVERLAY_SRCS} ${DIAGRAMOVERLAY_MOC_SRCS})
+
+INCLUDE_DIRECTORIES(
+     ${CMAKE_CURRENT_BINARY_DIR} ${GEOS_INCLUDE_DIR}
+     ../../core ../../core/pal ../../core/raster ../../core/renderer ../../core/symbology
+     ../../gui
+     ..
+)
+
+TARGET_LINK_LIBRARIES(diagramoverlay
+  ${QT_LIBRARIES}
+  qgis_core
+  qgis_gui
+)
+
+
+########################################################
+# Install
+
+INSTALL(TARGETS diagramoverlay
+  RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
+  LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
\ No newline at end of file

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramcategory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramcategory.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramcategory.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,29 @@
+/***************************************************************************
+                         qgsdiagramcategory.cpp  -  description
+                         ----------------------
+    begin                : December 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgsdiagramcategory.h"
+
+QgsDiagramCategory::QgsDiagramCategory(): mPen(Qt::NoPen), mGap(0)
+{
+  
+}
+
+
+QgsDiagramCategory::~QgsDiagramCategory()
+{
+  
+}

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramdialog.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramdialog.h	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramdialog.h	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,54 @@
+/***************************************************************************
+                         qgsdiagramdialog.h  -  description
+                         ------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSDIAGRAMDIALOG_H
+#define QGSDIAGRAMDIALOG_H
+
+#include "ui_qgsdiagramdialogbase.h"
+#include "qgsapplydialog.h"
+
+class QgsVectorLayer;
+class QgsVectorOverlay;
+
+/**Dialog to enter options for diagram symbolisation*/
+class QgsDiagramDialog: public QgsApplyDialog, private Ui::QgsDiagramDialogBase
+{
+  Q_OBJECT
+ public:
+  QgsDiagramDialog(QgsVectorLayer* vl);
+  ~QgsDiagramDialog();
+  void apply() const;
+
+  private slots:
+  /**Adds name of the attribute combo box into the tree widget*/
+  void addAttribute();
+  /**Removes the current attribute from the tree widget*/
+  void removeAttribute();
+  void changeClassificationType(const QString& newType);
+  void changeClassificationAttribute(const QString& newAttribute);
+  /**Calls the color dialog if column == 1*/
+  void handleItemDoubleClick(QTreeWidgetItem * item, int column);
+
+ private:
+  QgsDiagramDialog();
+  /**Restores the dialog settings from an already existing overlay*/
+  void restoreSettings(const QgsVectorOverlay* overlay);
+  /**Vector layer containing the features to be symbolized with diagrams*/
+  QgsVectorLayer* mVectorLayer;
+};
+
+#endif

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,399 @@
+/***************************************************************************
+                         qgsdiagramoverlay.cpp  -  description
+                         ---------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgsdiagramoverlay.h"
+#include "qgscoordinatetransform.h"
+#include "qgsdiagramfactory.h"
+#include "qgsbardiagramfactory.h"
+#include "qgspiediagramfactory.h"
+#include "qgsdiagramrenderer.h"
+#include "qgsfeature.h"
+#include "qgsfield.h"
+#include "qgsgeometry.h"
+#include "qgsmaptopixel.h"
+#include "qgsoverlayobject.h"
+#include "qgsproject.h"
+#include "qgsrendercontext.h"
+#include "qgssymbologyutils.h"
+#include "qgsvectordataprovider.h"
+#include <QPainter>
+
+QgsDiagramOverlay::QgsDiagramOverlay(QgsVectorLayer* vl): QgsVectorOverlay(vl), mDiagramRenderer(0)
+{
+
+}
+
+QgsDiagramOverlay::~QgsDiagramOverlay()
+{
+  delete mDiagramRenderer;
+}
+
+void QgsDiagramOverlay::setDiagramRenderer(QgsDiagramRenderer* r)
+{
+  delete mDiagramRenderer;
+  mDiagramRenderer = r;
+}
+
+void QgsDiagramOverlay::createOverlayObjects(const QgsRect& viewExtent)
+{
+  //memory cleanup
+  for(QMap<int, QgsOverlayObject*>::iterator it = mOverlayObjects.begin(); it != mOverlayObjects.end(); ++it)
+    {
+      delete it.value();
+    }
+  mOverlayObjects.clear();
+
+  //go through all the features and fill the multimap (query mDiagramRenderer for the correct sizes)
+  if(mVectorLayer && mDiagramRenderer)
+    {
+      QgsVectorDataProvider* theProvider = mVectorLayer->dataProvider();
+      if(theProvider)
+	{
+	  //set spatial filter on data provider
+      theProvider->begin();
+	  theProvider->select(mAttributes, viewExtent);
+
+	  QgsFeature currentFeature;
+	  int width, height;
+
+	  std::list<unsigned char*> wkbBuffers;
+	  std::list<int> wkbSizes;
+
+	  std::list<unsigned char*>::iterator bufferIt;
+	  std::list<int>::iterator sizeIt;
+
+	  int multifeaturecounter = 0;
+
+      while(theProvider->nextFeature(currentFeature))
+      {
+         //todo: insert more objects for multipart features
+       if(mDiagramRenderer->getDiagramDimensions(width, height, currentFeature) != 0)
+        {
+		  //error
+        }
+
+       mOverlayObjects.insert(currentFeature.id(), new QgsOverlayObject(height, width, 0, currentFeature.geometryAndOwnership()));
+      }
+	}
+    }
+}
+
+void QgsDiagramOverlay::drawOverlayObjects(QgsRenderContext& context) const
+{
+  if(!mDisplayFlag)
+    {
+      return;
+    }
+  if(mVectorLayer && mDiagramRenderer)
+    {
+      QgsVectorDataProvider* theProvider = mVectorLayer->dataProvider();
+      if(theProvider)
+	{
+	  //set spatial filter on data provider
+      theProvider->begin();
+      theProvider->select(mAttributes, context.extent());
+
+	  QgsFeature currentFeature;
+	  QImage* currentDiagramImage = 0;
+
+      while(theProvider->nextFeature(currentFeature))
+        {
+	      //request diagram from renderer
+	      currentDiagramImage = mDiagramRenderer->renderDiagram(currentFeature);
+	      if(!currentDiagramImage)
+		{
+		  qWarning("diagram image is 0");
+		  continue;
+		}
+	      //search for overlay object in the multimap, multifeatures still unsolved
+          QMap<int, QgsOverlayObject*>::const_iterator it = mOverlayObjects.find(currentFeature.id());
+          if(it != mOverlayObjects.constEnd())
+          {
+            QgsPoint overlayPosition = it.value()->position();
+            const QgsCoordinateTransform* ct = context.coordinateTransform();
+            if(ct)
+            {
+              overlayPosition = ct->transform(overlayPosition);
+            }
+            context.mapToPixel().transform(&overlayPosition);
+            int shiftX = currentDiagramImage->width()/2;
+            int shiftY = currentDiagramImage->height()/2;
+            if(context.painter())
+            {
+              context.painter()->drawImage((int)overlayPosition.x()-shiftX, (int)overlayPosition.y()-shiftY, *currentDiagramImage);
+            }
+          }
+
+          delete currentDiagramImage;
+	    }
+	}
+    }
+}
+
+int QgsDiagramOverlay::getOverlayObjectSize(int& width, int& height, double value, const QgsFeature& f) const
+{
+  return mDiagramRenderer->getDiagramDimensions(width, height, f);
+}
+
+bool QgsDiagramOverlay::readXML(const QDomNode& overlayNode)
+{
+  QDomElement overlayElem = overlayNode.toElement();
+  
+  //set display flag
+  if(overlayElem.attribute("display") == "true")
+    {
+      mDisplayFlag = true;
+    }
+  else
+    {
+      mDisplayFlag = false;
+    }
+
+  //create a renderer object
+  QgsDiagramRenderer* theDiagramRenderer = 0;
+  QDomNodeList rendererList = overlayNode.toElement().elementsByTagName("renderer");
+  QDomElement rendererElem;
+
+  QString wellKnownName;
+  QgsAttributeList attributeList;
+  QList<QBrush> brushList;
+  QList<QPen> penList;
+  QList<int> classAttrList;
+
+  //wellknownname
+  QDomNodeList wknNodeList = overlayElem.elementsByTagName("wellknownname");
+  if(wknNodeList.size() < 1)
+    {
+      return false;
+    }
+  wellKnownName = wknNodeList.at(0).toElement().text(); 
+  QgsWKNDiagramFactory* wknFactory = 0;
+  if(wellKnownName == "Pie")
+    {
+      wknFactory = new QgsPieDiagramFactory();
+    }
+  else if(wellKnownName == "Bar")
+    {
+      wknFactory = new QgsBarDiagramFactory();
+    }
+  else
+    {
+      return false; //unknown type
+    }
+
+  //classificationField
+  QDomNodeList classificationFieldList = overlayElem.elementsByTagName("classificationfield");
+  for(int i = 0; i < classificationFieldList.size(); ++i)
+    {
+      classAttrList.push_back(classificationFieldList.at(i).toElement().text().toInt());
+    }
+
+  theDiagramRenderer = new QgsDiagramRenderer(classAttrList);
+  wknFactory->setScalingAttributes(classAttrList);
+  wknFactory->setDiagramType(wellKnownName);
+
+  
+  int red, green, blue;
+  QDomElement categoryElem, penElem, brushElem;
+  QDomNodeList categoryList = overlayElem.elementsByTagName("category");
+
+  for(int i = 0; i < categoryList.size(); ++i)
+    {
+      categoryElem = categoryList.at(i).toElement();
+      
+      QgsDiagramCategory newCategory;
+      newCategory.setPropertyIndex(categoryElem.attribute("attribute").toInt());
+      attributeList.push_back(categoryElem.attribute("attribute").toInt());
+      newCategory.setGap(categoryElem.attribute("gap").toInt());
+
+      //pen element
+      penElem = categoryElem.namedItem("pen").toElement();
+      if(!penElem.isNull())
+	{
+	  QPen currentPen;
+	  red = penElem.attribute("red").toInt();
+	  green = penElem.attribute("green").toInt();
+	  blue = penElem.attribute("blue").toInt();
+	  currentPen.setColor(QColor(red, green, blue));
+	  currentPen.setStyle(QgsSymbologyUtils::qString2PenStyle(penElem.attribute("style")));
+	  newCategory.setPen(currentPen);
+	}
+
+      //brush element
+      brushElem = categoryElem.namedItem("brush").toElement();
+      if(!brushElem.isNull())
+	{
+	  QBrush currentBrush;
+	  red = brushElem.attribute("red").toInt();
+	  green = brushElem.attribute("green").toInt();
+	  blue = brushElem.attribute("blue").toInt();
+	  currentBrush.setColor(QColor(red, green, blue));
+	  currentBrush.setStyle(QgsSymbologyUtils::qString2BrushStyle(brushElem.attribute("style")));
+	  newCategory.setBrush(currentBrush);
+	}
+
+      wknFactory->addCategory(newCategory);
+    }
+
+  if(rendererList.size() < 1)
+    {
+      return false;
+    }
+  rendererElem = rendererList.at(0).toElement();
+
+  theDiagramRenderer->setFactory(wknFactory);
+
+  //Read renderer specific settings
+  if(theDiagramRenderer)
+    {
+      theDiagramRenderer->readXML(rendererElem);
+      setDiagramRenderer(theDiagramRenderer);
+      
+      //the overlay may need a different attribute list than the renderer
+      QList<int>::const_iterator it = classAttrList.constBegin();
+      for(; it != classAttrList.constEnd(); ++it)
+	{
+	  if(!attributeList.contains(*it))
+	    {
+	      attributeList.push_back(*it);
+	    }
+	}
+      setAttributes(attributeList);
+      return true;
+    }
+  return false;
+}
+
+bool QgsDiagramOverlay::writeXML(QDomNode& layer_node, QDomDocument& doc) const
+{
+  QDomElement overlayElement = doc.createElement("overlay");
+  overlayElement.setAttribute("type", "diagram");
+  if(mDisplayFlag)
+    {
+      overlayElement.setAttribute("display", "true");
+    }
+  else
+    {
+      overlayElement.setAttribute("display", "false");
+    }
+
+  layer_node.appendChild(overlayElement);
+  if(mDiagramRenderer)
+    {
+      mDiagramRenderer->writeXML(overlayElement, doc);
+      QgsDiagramFactory* f = mDiagramRenderer->factory();
+      if(f)
+	{
+	  f->writeXML(overlayElement, doc);
+	}
+    }
+  return true;
+}
+
+int QgsDiagramOverlay::createLegendContent(std::list<std::pair<QString, QImage*> >& content) const
+{
+#if 0
+  //first make sure the list is clean
+  std::list<std::pair<QString, QImage*> >::iterator it;
+  for(it = content.begin(); it != content.end(); ++it)
+    {
+      delete (it->second);
+    }
+  content.clear();
+  
+  if(mDiagramRenderer)
+    {
+      //first item: name of the classification attribute
+      QString classificationName = QgsDiagramOverlay::attributeNameFromIndex(mDiagramRenderer->classificationField(), mVectorLayer);
+      content.push_back(std::make_pair(classificationName, (QImage*)0));
+
+      //then a descriptive symbol (must come from diagram renderer)
+      QString legendSymbolText;
+      QImage* legendSymbolImage = mDiagramRenderer->getLegendImage(legendSymbolText);
+      content.push_back(std::make_pair(legendSymbolText, legendSymbolImage));
+
+      //then color/attribute pairs
+      std::list<QColor> colorList = mDiagramRenderer->colors();
+      std::list<QColor>::const_iterator color_it = colorList.begin();
+      QgsAttributeList attributeList = mDiagramRenderer->attributes();
+      QgsAttributeList::const_iterator att_it = attributeList.begin();
+      QString attributeName;
+      QImage* colorImage;
+      QPainter p;
+
+      for(; att_it != attributeList.constEnd() && color_it != colorList.end(); ++color_it, ++att_it)
+	{
+	  colorImage = new QImage(15, 15, QImage::Format_ARGB32_Premultiplied);
+	  colorImage->fill(QColor(255,255,255,0).rgba());
+	  p.begin(colorImage);
+	  p.setPen(Qt::NoPen);
+	  p.setBrush(*color_it);
+	  p.drawRect(0, 0, 15, 15);
+	  p.end();
+	  attributeName = QgsDiagramOverlay::attributeNameFromIndex(*att_it, mVectorLayer);
+	  content.push_back(std::make_pair(attributeName, colorImage));
+	}
+
+      
+      
+      return 0;
+    }
+  else
+    {
+      return 1;
+    }
+#endif //0
+  return 1; //todo: adapt to new design
+}
+
+int QgsDiagramOverlay::indexFromAttributeName(const QString& name, const QgsVectorLayer* vl)
+{
+  int error = -1;
+  
+  if(!vl)
+    {
+      return error;
+    }
+
+  const QgsVectorDataProvider *provider;
+
+  if ((provider = dynamic_cast<const QgsVectorDataProvider *>(vl->dataProvider())))
+    {
+      return provider->fieldNameIndex(name);
+    }
+  return error;
+}
+
+QString QgsDiagramOverlay::attributeNameFromIndex(int index, const QgsVectorLayer* vl)
+{
+  if(!vl)
+    {
+      return "";
+    }
+
+  const QgsVectorDataProvider *provider;
+  if ((provider = dynamic_cast<const QgsVectorDataProvider *>(vl->dataProvider())))
+    {
+      const QgsFieldMap & fields = provider->fields();
+      QgsFieldMap::const_iterator field_iter = fields.find(index);
+      if(field_iter != fields.constEnd())
+	{
+	  return field_iter->name();
+	}
+    }
+  return "";
+}

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlayplugin.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlayplugin.h	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramoverlayplugin.h	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,47 @@
+/***************************************************************************
+                         qgsdiagramoverlayplugin.h  -  description
+                         -------------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSDIAGRAMOVERLAYPLUGIN_H
+#define QGSDIAGRAMOVERLAYPLUGIN_H
+
+#include "qgsvectoroverlayplugin.h"
+#include <QObject>
+
+class QgisApp;
+class QgisInterface;
+class QgsApplyDialog;
+
+/**A plugin for placing diagrams on vector layers. The plugin provides a widget that can be embedded into the
+vector layer properties dialog and is able to create and configure a diagram overlay layer*/
+class QgsDiagramOverlayPlugin: public QObject, public QgsVectorOverlayPlugin
+{
+ Q_OBJECT
+ public:
+  QgsDiagramOverlayPlugin(QgisInterface* iface);
+  ~QgsDiagramOverlayPlugin();
+  QgsApplyDialog* dialog(QgsVectorLayer*) const;
+  void initGui(){}
+  void unload(){}
+
+  public slots:
+  void projectRead();
+
+ private:
+  QgisInterface* mInterface;
+};
+
+#endif

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrenderer.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,331 @@
+#include "qgsdiagramrenderer.h"
+#include "qgsdiagramfactory.h"
+#include "qgsfeature.h"
+#include <cmath>
+#include <QDomElement>
+
+QgsDiagramRenderer::QgsDiagramRenderer(const QList<int>& classificationAttributes): mClassificationAttributes(classificationAttributes), mScaleFactor(1.0)
+{
+}
+
+QgsDiagramRenderer::~QgsDiagramRenderer()
+{
+  delete mFactory;
+}
+
+QgsDiagramRenderer::QgsDiagramRenderer()
+{
+}
+
+QImage* QgsDiagramRenderer::renderDiagram(const QgsFeature& f) const
+{
+  if(!mFactory)
+    {
+      return 0;
+    }
+
+  //only scaling according to attributes does not need any items
+  if(mItemInterpretation != QgsDiagramRenderer::ATTRIBUTE && mItems.size() < 1)
+    {
+      return 0;
+    }
+
+  int size;
+  if(calculateDiagramSize(f, size) != 0)
+    {
+      return 0;
+    }
+
+    return mFactory->createDiagram(size, f);
+}
+
+int QgsDiagramRenderer::getDiagramDimensions(int& width, int& height, const QgsFeature& f) const
+{
+  //first find out classification value
+  if(!mFactory || mItems.size() < 1)
+    {
+      return 1;
+    }
+
+  int size;
+  if(calculateDiagramSize(f, size) != 0)
+    {
+      return 2;
+    }
+ 
+  if(mFactory->getDiagramDimensions(size, f, width, height) != 0)
+    {
+      return 3;
+    }
+  return 0;
+}
+
+int QgsDiagramRenderer::classificationValue(const QgsFeature& f, QVariant& value) const
+{
+  //find out attribute value of the feature
+  QgsAttributeMap featureAttributes = f.attributeMap();
+  
+  QgsAttributeMap::const_iterator iter;
+  
+  if(value.type() == QVariant::String) //string type
+    {
+      //we can only handle one classification field for strings
+      if(mClassificationAttributes.size() > 1)
+	{
+	  return 1;
+	}
+      
+      iter = featureAttributes.find(mClassificationAttributes.first());
+      if(iter == featureAttributes.constEnd())
+	{
+	  return 2;
+	}
+      value = iter.value();
+    }
+  else //numeric type
+    {
+      double currentValue;
+      double totalValue = 0;
+
+      QList<int>::const_iterator list_it = mClassificationAttributes.constBegin();
+      for(; list_it != mClassificationAttributes.constEnd(); ++list_it)
+	{
+	  QgsAttributeMap::const_iterator iter = featureAttributes.find(*list_it);
+	  if(iter == featureAttributes.constEnd())
+	    {
+	      continue;
+	    }
+	  currentValue = iter.value().toDouble();
+	  totalValue += currentValue;
+	}
+      value = QVariant(totalValue);
+    }
+  return 0;
+}
+
+void QgsDiagramRenderer::addClassificationAttribute(int attrNr)
+{
+  mClassificationAttributes.push_back(attrNr);
+}
+
+bool QgsDiagramRenderer::readXML(const QDomNode& rendererNode)
+{
+  QDomElement rendererElem = rendererNode.toElement();
+
+  //items
+  QList<QgsDiagramItem> itemList;
+  bool conversionOk;
+
+  QString interpretationName = rendererNode.toElement().attribute("item_interpretation");
+  if(interpretationName == "discrete")
+    {
+      mItemInterpretation = QgsDiagramRenderer::DISCRETE;
+    }
+  else if(interpretationName == "linear")
+    {
+      mItemInterpretation = QgsDiagramRenderer::LINEAR;
+    }
+  else if(interpretationName == "attribute")
+    {
+      mItemInterpretation = QgsDiagramRenderer::ATTRIBUTE;
+    }
+  else if(interpretationName == "constant")
+    {
+      mItemInterpretation = QgsDiagramRenderer::CONSTANT;
+    }
+
+  QDomNodeList itemNodeList = rendererElem.elementsByTagName("diagramitem"); 
+  for(int i = 0; i < itemNodeList.size(); ++i)
+    {
+      QgsDiagramItem currentItem;
+      QVariant currentValue;
+      currentItem.size = itemNodeList.at(i).toElement().attribute("size").toInt();
+      currentValue = QVariant(itemNodeList.at(i).toElement().attribute("value").toDouble(&conversionOk));
+      if(!conversionOk) //string data?
+	{
+	  currentValue = QVariant(itemNodeList.at(i).toElement().attribute("value"));
+	}
+      currentItem.value = currentValue;
+      itemList.push_back(currentItem);
+    }
+  setDiagramItems(itemList);
+  return true;
+}
+
+bool QgsDiagramRenderer::writeXML(QDomNode& overlay_node, QDomDocument& doc) const
+{
+  QDomElement rendererElement = doc.createElement("renderer");
+
+  //write interpolation to xml file
+  QString interpretationName;
+  if(mItemInterpretation == QgsDiagramRenderer::DISCRETE)
+    {
+      interpretationName = "discrete";
+    }
+  else if(mItemInterpretation == QgsDiagramRenderer::LINEAR)
+    {
+      interpretationName = "linear";
+    }
+  else if(mItemInterpretation == QgsDiagramRenderer::ATTRIBUTE)
+    {
+      interpretationName = "attribute";
+    }
+  else if(mItemInterpretation == QgsDiagramRenderer::CONSTANT)
+    {
+      interpretationName = "constant";
+    }
+  rendererElement.setAttribute("item_interpretation", interpretationName);
+
+  QList<QgsDiagramItem>::const_iterator item_it = mItems.constBegin();
+  for(; item_it != mItems.constEnd(); ++item_it)
+    {
+      QDomElement itemElement = doc.createElement("diagramitem");
+      itemElement.setAttribute("size", item_it->size);
+      itemElement.setAttribute("value", item_it->value.toString());
+      rendererElement.appendChild(itemElement);
+    }
+
+  overlay_node.appendChild(rendererElement);
+  return true;
+}
+
+int QgsDiagramRenderer::createLegendContent(QMap<QString, QImage*> items) const
+{
+  if(!mFactory || mItems.size() < 1)
+    {
+      return 1;
+    }
+
+  //determine a size and value for the legend, use the middle item for this
+  int element = (int)(mItems.size()/2);
+  QString value = mItems.at(element).value.toString();
+  int size = mItems.at(element).size;
+
+  if(mFactory->createLegendContent(size, value, items) != 0)
+    {
+      return 2;
+    }
+  return 0;
+}
+
+int QgsDiagramRenderer::calculateDiagramSize(const QgsFeature& f, int& size) const
+{
+  //find out value for classificationAttribute
+  QVariant value;
+  if(classificationValue(f, value) != 0)
+    {
+      return 1;
+    }
+
+  if(mItemInterpretation == ATTRIBUTE)
+    {
+      size = (int)(value.toDouble() * mScaleFactor);
+      return 0;
+    }
+
+  if(mItems.size() < 1)
+    {
+      return 2;
+    }
+
+  if(mItemInterpretation == CONSTANT)
+    {
+      size = (int)(mItems.constBegin()->size * mScaleFactor);
+      return 0; 
+    }
+
+  //find out size
+  bool sizeAssigned = false;
+
+  QList<QgsDiagramItem>::const_iterator current_it = mItems.constBegin();
+  QList<QgsDiagramItem>::const_iterator last_it = mItems.constEnd();
+  
+  if(value.type() == QVariant::String) //string types are handled differently
+    {
+      for(; current_it != mItems.constEnd(); ++current_it)
+	{
+	  if(current_it->value.toString() == value.toString())
+	    {
+	      size = (int)(current_it->size * mScaleFactor);
+	      sizeAssigned = true;
+	    }
+	}
+      if(!sizeAssigned)
+	{
+	  return 3;
+	}
+    }
+  else //numerical types
+    {
+      for(; current_it != mItems.constEnd(); ++current_it)
+	{
+	  if(value.toDouble() < current_it->value.toDouble())
+	    {
+	      if(last_it == mItems.constEnd()) //values below classifications receive first items size
+	    {
+	      size = (int)(current_it->size * mScaleFactor);
+	    }
+	      else
+		{
+		  size = (int)(interpolateSize(value.toDouble(), last_it->value.toDouble(), current_it->value.toDouble(), last_it->size, current_it->size) * mScaleFactor);
+		  
+		}
+	      sizeAssigned = true;
+	      break;
+	    }
+	  last_it = current_it;
+	}
+
+      if(!sizeAssigned)//values above classification receive last items size
+	{
+	  size = (int)(last_it->size * mScaleFactor);
+	}
+    }
+
+  return 0;
+}
+
+int QgsDiagramRenderer::interpolateSize(double value, double lowerValue, double upperValue, \
+						       int lowerSize, int upperSize) const
+{
+  switch(mItemInterpretation)
+    {
+    case DISCRETE:
+      return lowerSize;
+      break;
+
+    case LINEAR:
+      {
+	if(value <= lowerValue)
+	  {
+	    return lowerSize;
+	  }
+	else if(value >= upperValue)
+	  {
+	    return upperSize;
+	  }
+	
+	QgsDiagramFactory::SizeType t;
+	if(mFactory)
+	  {
+	    t = mFactory->sizeType();
+	  }
+	
+	if(!mFactory || t == QgsDiagramFactory::HEIGHT)
+	  {
+	    //do one dimensional linear interpolation
+	    return (int)(((value - lowerValue) * upperSize + (upperValue - value) * lowerSize) / (upperValue - lowerValue));
+	  }
+	else if(t == QgsDiagramFactory::DIAMETER)
+	  {
+	    double lowerArea = (lowerSize/2)*(lowerSize/2)*M_PI;
+	    double upperArea = (upperSize/2)*(upperSize/2)*M_PI;
+	    double valueArea = ((value - lowerValue) * upperArea + (upperValue - value) * lowerArea)/(upperValue - lowerValue);
+	    return (int)(2*sqrt(valueArea/M_PI));
+	  }
+      }
+    default:
+      return 1;
+    }
+  return 0; //something went wrong if we arrive here
+}

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrendererwidget.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrendererwidget.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgsdiagramrendererwidget.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,33 @@
+/***************************************************************************
+                         qgsdiagramrendererwidget.cpp  -  description
+                         ----------------------------
+    begin                : February 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgsdiagramrendererwidget.h"
+
+QgsDiagramRendererWidget::QgsDiagramRendererWidget(QgsVectorLayer* vl): QWidget(), mVectorLayer(vl)
+{
+
+}
+
+QgsDiagramRendererWidget::QgsDiagramRendererWidget()
+{
+
+}
+
+QgsDiagramRendererWidget::~QgsDiagramRendererWidget()
+{
+
+}

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.h	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialog.h	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,49 @@
+/***************************************************************************
+                         qgslinearlyscalingdialog.h  -  description
+                         --------------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSLINEARLYSCALINGDIALOG_H
+#define QGSLINEARLYSCALINGDIALOG_H
+
+#include "ui_qgslinearlyscalingdialogbase.h"
+#include "qgsdiagramrendererwidget.h"
+
+class QgsDiagramRenderer;
+class QgsVectorLayer;
+
+class QgsLinearlyScalingDialog: public QgsDiagramRendererWidget, private Ui::QgsLinearlyScalingDialogBase
+{
+  Q_OBJECT
+ public:
+  QgsLinearlyScalingDialog(QgsVectorLayer* vl);
+  ~QgsLinearlyScalingDialog();
+  QgsDiagramRenderer* createRenderer(const QString& type, int classAttr, const QgsAttributeList& attributes, const std::list<QColor>& colors) const;
+  void applySettings(const QgsDiagramRenderer* renderer);
+  /**Is called from QgsDiagramDialog. Inserts new maximum value into the text widget*/
+  void changeClassificationField(int newField){mClassificationField = newField;}
+  void setWellKnownName(const QString& wkn);
+
+ private:
+  QString mClassificationAttribute;
+  QString mWellKnownName;
+  int mClassificationField;
+
+  private slots:
+  /**Calculates and inserts the maximum attribute value for the classification field*/
+  void insertMaximumAttributeValue();
+};
+
+#endif

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialogbase.ui
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialogbase.ui	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgslinearlyscalingdialogbase.ui	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,57 @@
+<ui version="4.0" >
+ <class>QgsLinearlyScalingDialogBase</class>
+ <widget class="QWidget" name="QgsLinearlyScalingDialogBase" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>609</width>
+    <height>91</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="1" column="2" >
+    <widget class="QLabel" name="mSizeLabel" >
+     <property name="text" >
+      <string>Size:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="3" >
+    <widget class="QSpinBox" name="mSizeSpinBox" >
+     <property name="maximum" >
+      <number>999</number>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" colspan="3" >
+    <widget class="QLabel" name="mTitleLabel" >
+     <property name="text" >
+      <string>Scale linearly between 0 and the following attribute value/ diagram size:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" >
+    <widget class="QLineEdit" name="mValueLineEdit" />
+   </item>
+   <item row="1" column="0" >
+    <widget class="QPushButton" name="mFindMaximumValueButton" >
+     <property name="text" >
+      <string>find maximum Value:</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgspiediagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgspiediagramfactory.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgspiediagramfactory.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,126 @@
+/***************************************************************************
+                         qgspiediagramfactory.cpp  -  description
+                         ------------------------
+    begin                : December 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgspiediagramfactory.h"
+
+QgsPieDiagramFactory::QgsPieDiagramFactory(): QgsWKNDiagramFactory()
+{
+
+}
+
+QgsPieDiagramFactory::~QgsPieDiagramFactory()
+{
+  
+}
+
+QImage* QgsPieDiagramFactory::createDiagram(int size, const QgsFeature& f) const
+{
+  QgsAttributeMap dataValues = f.attributeMap();
+  
+  //create transparent QImage
+  QImage* diagramImage = new QImage(QSize(size + 2 * mMaximumPenWidth + 2 * mMaximumGap, size + 2 * mMaximumPenWidth + 2 * mMaximumGap), QImage::Format_ARGB32_Premultiplied);
+  diagramImage->fill(qRgba(0, 0, 0, 0)); //transparent background
+  QPainter p;
+  p.begin(diagramImage);
+  p.setRenderHint(QPainter::Antialiasing);
+  p.setPen(Qt::NoPen);
+
+  //calculate sum of data values
+  double sum = 0;
+  QList<double> valueList; //cash the values to use them in drawing later
+
+  QgsAttributeMap::const_iterator value_it;
+  QList<QgsDiagramCategory>::const_iterator it = mCategories.constBegin();
+  for(; it != mCategories.constEnd(); ++it)
+    {
+      value_it = dataValues.find(it->propertyIndex());
+      valueList.push_back(value_it->toDouble());
+      if(value_it != dataValues.constEnd())
+	{
+	  sum += value_it->toDouble();
+	}
+    }
+
+  if(sum - 0.0 < 0.000000000000001)
+    {
+      p.end();
+      delete diagramImage;
+      return 0;
+    }
+
+  //draw pies
+
+  int totalAngle = 0;
+  int currentAngle, currentGap;
+  int xGapOffset = 0;
+  int yGapOffset = 0;
+
+  QList<QgsDiagramCategory>::const_iterator category_it = mCategories.constBegin();
+  QList<double>::const_iterator valueList_it = valueList.constBegin();
+  
+  for(; category_it != mCategories.constEnd() && valueList_it != valueList.constEnd(); ++category_it, ++valueList_it)
+    {
+      p.setPen(category_it->pen());
+      currentAngle = (int)((*valueList_it)/sum*360*16);
+      p.setBrush(category_it->brush());
+
+      xGapOffset = 0;
+      yGapOffset = 0;
+      currentGap = category_it->gap();
+      if(currentGap != 0)
+	{
+	  //qt angles are degrees*16 
+	  gapOffsetsForPieSlice(currentGap, totalAngle + currentAngle/2, xGapOffset, yGapOffset);
+	}
+
+      //debug: print out all the parameters for debugging purposes
+#if 0
+      qWarning("x:");
+      qWarning(QString::number(mMaximumPenWidth + mMaximumGap + xGapOffset).toLocal8Bit().data());
+      qWarning("y:");
+      qWarning(QString::number(mMaximumPenWidth + mMaximumGap - yGapOffset).toLocal8Bit().data());
+      qWarning("size: ");
+      qWarning(QString::number(size).toLocal8Bit().data());
+      qWarning("totalAngle: ");
+      qWarning(QString::number(totalAngle).toLocal8Bit().data());
+      qWarning("currentAngle: ");
+      qWarning(QString::number(currentAngle).toLocal8Bit().data());
+#endif //0
+
+        p.drawPie(mMaximumPenWidth + mMaximumGap + xGapOffset, mMaximumPenWidth + mMaximumGap - yGapOffset, size, size, totalAngle, currentAngle);
+      totalAngle += currentAngle;
+    }
+  p.end();
+  
+  return diagramImage;
+}
+
+int QgsPieDiagramFactory::getDiagramDimensions(int size, const QgsFeature& f, int& width, int& height) const
+{
+  width = size + 2 * mMaximumPenWidth + 2 * mMaximumGap;
+  height = size + 2 * mMaximumPenWidth + 2 * mMaximumGap;
+  return 0;
+}
+
+int QgsPieDiagramFactory::gapOffsetsForPieSlice(int gap, int angle, int& xOffset, int& yOffset) const
+{
+   double rad = angle/2880.0*M_PI;
+  xOffset = (int)(cos(rad) * gap);
+  yOffset = (int)(sin(rad) * gap);
+  
+  return 0;
+}

Added: branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/diagram_overlay/qgswkndiagramfactory.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,114 @@
+/***************************************************************************
+                         qgswkndiagramfactory.cpp  -  description
+                         ------------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+
+
+#include "qgswkndiagramfactory.h"
+#include "qgsfeature.h"
+#include "qgssymbologyutils.h"
+#include <QDomDocument>
+#include <QDomElement>
+#include <QImage>
+#include <QPainter>
+#include <cmath>
+
+QgsWKNDiagramFactory::QgsWKNDiagramFactory(): mMaximumPenWidth(0),mMaximumGap(0)
+{
+  
+}
+
+QgsWKNDiagramFactory::~QgsWKNDiagramFactory()
+{
+  
+}
+
+void QgsWKNDiagramFactory::supportedWellKnownNames(std::list<QString>& names)
+{
+  names.clear();
+  names.push_back("Pie");
+  names.push_back("Bar");
+}
+
+bool QgsWKNDiagramFactory::writeXML(QDomNode& overlay_node, QDomDocument& doc) const
+{
+  QDomElement overlayElement = overlay_node.toElement();
+
+  //well known name
+  QDomElement wellKnownNameElem = doc.createElement("wellknownname");
+  QDomText wknText = doc.createTextNode(mDiagramType);
+  wellKnownNameElem.appendChild(wknText);
+  overlayElement.appendChild(wellKnownNameElem);
+	    
+  //classification fields
+  QList<int>::const_iterator scaling_it = mScalingAttributes.constBegin();
+  for(; scaling_it != mScalingAttributes.constEnd(); ++scaling_it)
+    {
+      QDomElement classificationFieldElem = doc.createElement("classificationfield");
+      QDomText classFieldText = doc.createTextNode(QString::number(*scaling_it));
+      classificationFieldElem.appendChild(classFieldText);
+      overlayElement.appendChild(classificationFieldElem);
+    }
+
+  //diagram categories
+  QList<QgsDiagramCategory>::const_iterator c_it = mCategories.constBegin();
+  for(; c_it != mCategories.constEnd(); ++c_it)
+    {
+      QDomElement currentCategoryElem = doc.createElement("category");
+      currentCategoryElem.setAttribute("gap", QString::number(c_it->gap()));
+      currentCategoryElem.setAttribute("attribute", QString::number(c_it->propertyIndex())) ;
+    
+      //brush
+      QDomElement currentBrushElem = doc.createElement("brush");
+      currentBrushElem.setAttribute("red", QString::number(c_it->brush().color().red()));
+      currentBrushElem.setAttribute("green", QString::number(c_it->brush().color().green()));
+      currentBrushElem.setAttribute("blue", QString::number(c_it->brush().color().blue()));
+      currentBrushElem.setAttribute("style", QgsSymbologyUtils::brushStyle2QString(c_it->brush().style()));
+
+      //pen
+      QDomElement currentPenElem = doc.createElement("pen");
+      currentPenElem.setAttribute("red", QString::number(c_it->pen().color().red()));
+      currentPenElem.setAttribute("green", QString::number(c_it->pen().color().green()));
+      currentPenElem.setAttribute("blue", QString::number(c_it->pen().color().blue()));
+      currentPenElem.setAttribute("width", QString::number(c_it->pen().width()));
+      currentPenElem.setAttribute("style", QgsSymbologyUtils::penStyle2QString(c_it->pen().style()));
+
+      currentCategoryElem.appendChild(currentBrushElem);
+      currentCategoryElem.appendChild(currentPenElem);
+      
+      overlayElement.appendChild(currentCategoryElem);
+    }
+  return true;
+}
+
+void QgsWKNDiagramFactory::addCategory(QgsDiagramCategory c)
+{
+  mCategories.push_back(c);
+  
+  //update the maximum pen width if necessary (for proper diagram scaling)
+  int currentPenWidth = c.pen().width();
+  int currentGap = c.gap();
+
+  if(mMaximumPenWidth < currentPenWidth)
+    {
+      mMaximumPenWidth = currentPenWidth;
+    }
+  
+  if(currentGap > mMaximumGap)
+    {
+      mMaximumGap = currentGap;
+    }
+}

Added: branches/vector_overlay_branch/src/plugins/qgsapplydialog.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/qgsapplydialog.h	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/qgsapplydialog.h	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,31 @@
+/***************************************************************************
+                         qgsapplydialog.h  -  description
+                         --------------------------------
+    begin                : November 2008
+    copyright            : (C) 2008 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#ifndef QGSAPPLYDIALOG_H
+#define QGSAPPLYDIALOG_H
+
+#include <QDialog>
+
+/**Interface class for dialogs that have an apply operation (e.g. for symbology)*/
+class QgsApplyDialog: public QDialog
+{
+  public:
+    QgsApplyDialog(): QDialog(){}
+    ~QgsApplyDialog(){}
+    virtual void apply() const = 0;
+};
+
+#endif

Added: branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.cpp
===================================================================
--- branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.cpp	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.cpp	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1 @@
+ 

Added: branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.h
===================================================================
--- branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.h	                        (rev 0)
+++ branches/vector_overlay_branch/src/plugins/qgsvectoroverlayplugin.h	2008-11-21 14:09:59 UTC (rev 9677)
@@ -0,0 +1,39 @@
+ /***************************************************************************
+                         qgsvectoroverlayplugin.h  -  description
+                         ------------------------
+    begin                : January 2007
+    copyright            : (C) 2007 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSVECTOROVERLAYPLUGIN_H
+#define QGSVECTOROVERLAYPLUGIN_H
+
+#include "qgisplugin.h"
+
+class QgsApplyDialog;
+class QgsVectorLayer;
+class QWidget;
+
+/**Interface class for vector overlay plugins*/
+class QgsVectorOverlayPlugin: public QgisPlugin
+{
+ public:
+  QgsVectorOverlayPlugin(const QString& name, const QString& description, const QString& version): QgisPlugin(name, description, version, QgisPlugin::VECTOR_OVERLAY){}
+
+  virtual ~QgsVectorOverlayPlugin(){}
+
+  /**Returns a dialog which can be embedded into the vector layer properties*/
+  virtual QgsApplyDialog* dialog(QgsVectorLayer* vl) const = 0;
+};
+
+#endif



More information about the QGIS-commit mailing list