~ubuntu-branches/ubuntu/hardy/qgis/hardy

« back to all changes in this revision

Viewing changes to src/qgsrenderer.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                         qgsrenderer.h  -  description
3
 
                             -------------------
4
 
    begin                : Sat Jan 4 2003
5
 
    copyright            : (C) 2003 by Gary E.Sherman
6
 
    email                : sherman at mrcc.com
7
 
 ***************************************************************************/
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 ***************************************************************************/
17
 
/* $Id: qgsrenderer.h,v 1.24 2005/04/02 09:42:45 rabla Exp $ */
18
 
#ifndef QGSRENDERER_H
19
 
#define QGSRENDERER_H
20
 
 
21
 
class QgsFeature;
22
 
class QgsMapToPixel;
23
 
class QgsVectorLayer;
24
 
class QPainter;
25
 
class QgsDlgVectorLayerProperties;
26
 
class QPicture;
27
 
class QDomNode;
28
 
class QColor;
29
 
 
30
 
#include <fstream>
31
 
#include <list>
32
 
#include <qstring.h>
33
 
#include <qdom.h>
34
 
 
35
 
#include "qgis.h"
36
 
#include "qgsproject.h"
37
 
#include <qcolor.h>
38
 
 
39
 
class QgsRenderItem;
40
 
 
41
 
/**Abstract base class for renderers. A renderer holds all the information necessary to draw the contents of a vector layer to a map canvas. The vector layer then passes each feature to paint to the renderer*/
42
 
class QgsRenderer
43
 
{
44
 
 public:
45
 
    /** Default ctor sets up selection colour from project properties */
46
 
    QgsRenderer();
47
 
    /**Sets the initial symbology configuration for a layer. Besides of applying default symbology settings, an instance of the corresponding renderer dialog is created and associated with the layer (or with the property dialog, if pr is not 0). Finally, a pixmap for the legend is drawn (or, if pr is not 0, it is stored in the property dialog, until the settings are applied).
48
 
     @param layer the vector layer associated with the renderer
49
 
     @param pr the property dialog. This is only needed if the renderer is created from the property dialog and not yet associated with the vector layer, otherwise 0*/
50
 
    virtual void initializeSymbology(QgsVectorLayer* layer, QgsDlgVectorLayerProperties* pr=0)=0;
51
 
    /**A vector layer passes features to a renderer object to change the brush and pen of the qpainter
52
 
     @param p the painter storing brush and pen
53
 
     @param f a pointer to the feature to be rendered
54
 
     @param pic pointer to a marker from SVG (is only used by marker renderers)
55
 
     @param scalefactor pointer to the scale factor for the marker image*/
56
 
    virtual void renderFeature(QPainter* p, QgsFeature* f,QPicture* pic, double* scalefactor, bool selected, int oversampling = 1, double widthScale = 1.)=0;
57
 
    /**Reads the renderer configuration from an XML file
58
 
     @param rnode the DOM node to read 
59
 
     @param vl the vector layer which will be associated with the renderer*/
60
 
    virtual void readXML(const QDomNode& rnode, QgsVectorLayer& vl)=0;
61
 
    /**Writes the contents of the renderer to a configuration file*/
62
 
    // virtual void writeXML(std::ostream& xml)=0;
63
 
    /**Writes the contents of the renderer to a configuration file
64
 
     @ return true in case of success*/
65
 
    virtual bool writeXML( QDomNode & layer_node, QDomDocument & document )=0;
66
 
    /** Returns true, if attribute values are used by the renderer and false otherwise*/
67
 
    virtual bool needsAttributes()=0;
68
 
    /**Returns a list with indexes of classification attributes*/
69
 
    virtual std::list<int> classificationAttributes()=0;
70
 
    /**Returns the renderers name*/
71
 
    virtual QString name()=0;    
72
 
    /** Set up the selection color by reading approriate values from project props */
73
 
    void initialiseSelectionColor();
74
 
    /**Return symbology items*/
75
 
    virtual const std::list<QgsRenderItem*> items() const=0;
76
 
    /**Color to draw selected features - static so we can change it in proj props and automatically 
77
 
       all renderers are updated*/
78
 
    static QColor mSelectionColor;
79
 
    /**Layer type*/
80
 
    QGis::VectorType mVectorType;
81
 
    
82
 
};
83
 
 
84
 
inline void QgsRenderer::initialiseSelectionColor()
85
 
{
86
 
    int myRedInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorRedPart",255);
87
 
    int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorGreenPart",255);
88
 
    int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorBluePart",0);
89
 
    mSelectionColor = QColor(myRedInt,myGreenInt,myBlueInt);
90
 
}
91
 
#endif // QGSRENDERER_H