~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to src/core/renderer/qgssinglesymbolrenderer.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                         qgssinglesymbolrenderer.h  -  description
 
3
                             -------------------
 
4
    begin                : Oct 2003
 
5
    copyright            : (C) 2003 by Marco Hugentobler
 
6
    email                : mhugent@geo.unizh.ch
 
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: qgssinglesymbolrenderer.h 5371 2006-04-25 01:52:13Z wonder $ */
 
18
 
 
19
#ifndef QGSSINGLESYMBOLRENDERER_H
 
20
#define QGSSINGLESYMBOLRENDERER_H
 
21
 
 
22
#include <QMap>
 
23
#include "qgsrenderer.h"
 
24
#include "qgsrendercontext.h"
 
25
 
 
26
 
 
27
/**Render class to display all the features with a single QgsSymbol*/
 
28
class CORE_EXPORT QgsSingleSymbolRenderer: public QgsRenderer
 
29
{
 
30
  public:
 
31
    QgsSingleSymbolRenderer( QGis::GeometryType type );
 
32
    QgsSingleSymbolRenderer( const QgsSingleSymbolRenderer& other );
 
33
    QgsSingleSymbolRenderer& operator=( const QgsSingleSymbolRenderer& other );
 
34
    virtual ~QgsSingleSymbolRenderer();
 
35
 
 
36
    /**Replaces the current mSymbol by sy*/
 
37
    void addSymbol( QgsSymbol* sy );
 
38
    /*Returns a pointer to mSymbol*/
 
39
    const QgsSymbol* symbol() const;
 
40
 
 
41
    /**Renders a feature
 
42
     * added in 1.2 */
 
43
    void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* img, bool selected, double opacity = 1.0 );
 
44
 
 
45
    /**Reads the renderer configuration from an XML file
 
46
     @param rnode the Dom node to read
 
47
     @param vl the vector layer which will be associated with the renderer
 
48
     @return 0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found
 
49
    */
 
50
    virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl );
 
51
    /**Writes the contents of the renderer to a configuration file*/
 
52
    /*virtual void writeXML(std::ostream& xml);*/
 
53
    /**Writes the contents of the renderer to a configuration file
 
54
     @ return true in case of success*/
 
55
    virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const;
 
56
    /**Returns true, attributes needed for single symbol*/
 
57
    bool needsAttributes() const;
 
58
    /**Returns a list of all needed attributes*/
 
59
    QgsAttributeList classificationAttributes() const;
 
60
    void updateSymbolAttributes();
 
61
    /**Returns the renderers name*/
 
62
    virtual QString name() const;
 
63
    /**Returns a list containing mSymbol*/
 
64
    const QList<QgsSymbol*> symbols() const;
 
65
    /**Returns a deep copy of this renderer*/
 
66
    QgsRenderer* clone() const;
 
67
  protected:
 
68
    /**Object containing symbology information*/
 
69
    QgsSymbol *mSymbol0;
 
70
    QMap<QString, QgsSymbol*> mSymbols;
 
71
    /**Cached copy of all underlying symbols required attribute fields*/
 
72
    QgsAttributeList mSymbolAttributes;
 
73
};
 
74
 
 
75
inline const QgsSymbol* QgsSingleSymbolRenderer::symbol() const
 
76
{
 
77
  return mSymbol0;
 
78
}
 
79
 
 
80
inline bool QgsSingleSymbolRenderer::needsAttributes() const
 
81
{
 
82
  return true;
 
83
}
 
84
 
 
85
#endif