~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/composer/qgscomposervectorlegend.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
 
                         qgscomposervectorlegend.h
3
 
                             -------------------
4
 
    begin                : January 2005
5
 
    copyright            : (C) 2005 by Radim Blazek
6
 
    email                : blazek@itc.it
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
 
#ifndef QGSCOMPOSERVECTORLEGEND_H
18
 
#define QGSCOMPOSERVECTORLEGEND_H
19
 
 
20
 
/*           
21
 
 *                    |<>| - mMargin         
22
 
 *           
23
 
 *                    +----------------------+
24
 
 *                    |                      |        
25
 
 *                    |    Legend Title      |
26
 
 *                    |                      |
27
 
 *                    |  Section             |
28
 
 *                    |                      |
29
 
 *                --  |  +-----+             |  __ 
30
 
 *  mSymbolHeight |   |  |     | Item Label  |  __| - mFont->pointSize()
31
 
 *                --  |  +-----+             |  --          
32
 
 *                    |                      |    | - mSymbolSpace (vertical space between symbo, boxes)
33
 
 *                    |  +-----+             |  --
34
 
 *                    |  |     | Item Label  |
35
 
 *                    |  +-----+             |            
36
 
 *                    |                      |
37
 
 *                    +----------------------+
38
 
 *
39
 
 *                             
40
 
 *                       |<--->| - mSymbolWidth (lines and areas)
41
 
 *                   
42
 
 */ 
43
 
 
44
 
#include "ui_qgscomposervectorlegendbase.h"
45
 
#include "qgscomposeritem.h"
46
 
#include <Q3CanvasPolygonalItem>
47
 
#include <QPixmap>
48
 
#include <map>
49
 
 
50
 
class QgsComposition;
51
 
class QgsMapCanvas;
52
 
class QDomNode;
53
 
class QDomDocument;
54
 
class QFont;
55
 
class QPainter;
56
 
class QPen;
57
 
class Q3PopupMenu;
58
 
class QRect;
59
 
 
60
 
/** \class QgsComposerVectorLegend 
61
 
 *  \brief Object representing map window. 
62
 
 */
63
 
// NOTE: QgsComposerVectorLegendBase must be first, otherwise does not compile
64
 
class QgsComposerVectorLegend : public QWidget,
65
 
                                private Ui::QgsComposerVectorLegendBase, 
66
 
                                public Q3CanvasRectangle, 
67
 
                                public QgsComposerItem
68
 
{
69
 
    Q_OBJECT
70
 
 
71
 
public:
72
 
    /** \brief Constructor  
73
 
     *  \param id object id
74
 
     *  \param fontSize font size in typographic points!
75
 
     */
76
 
    QgsComposerVectorLegend( QgsComposition *composition, int id, int x, int y, int fontSize = 0 );
77
 
 
78
 
    /** \brief Constructor. Settings are read from project. 
79
 
     *  \param id object id
80
 
     */
81
 
    QgsComposerVectorLegend( QgsComposition *composition, int id );
82
 
    ~QgsComposerVectorLegend();
83
 
 
84
 
    /** \brief Preview style  */
85
 
    enum PreviewMode {
86
 
        Cache = 0,   // Use raster cache 
87
 
        Render,      // Render the map
88
 
        Rectangle    // Display only rectangle
89
 
    };
90
 
 
91
 
    /** \brief Initialise GUI etc., share by constructors. */
92
 
    void init(void);
93
 
 
94
 
    // Reimplement QgsComposerItem:
95
 
    void setSelected( bool s );
96
 
    bool selected( void );
97
 
    QWidget *options ( void );
98
 
    bool writeSettings ( void );
99
 
    bool readSettings ( void );
100
 
    bool removeSettings ( void );
101
 
    bool writeXML( QDomNode & node, QDomDocument & document, bool temp = false );
102
 
    bool readXML( QDomNode & node );
103
 
     
104
 
    /** \brief Draw to paint device, internal use 
105
 
     *  \param painter painter or 0
106
 
     *  \return bounding box 
107
 
     */
108
 
    QRect render (QPainter *painter);
109
 
 
110
 
    /** \brief Reimplementation of QCanvasItem::draw - draw on canvas */
111
 
    void draw ( QPainter & painter );
112
 
    
113
 
    /** \brief Calculate size according to current settings */
114
 
    void recalculate ( void );
115
 
    
116
 
    /** \brief Create cache image */
117
 
    void cache ( void );
118
 
 
119
 
    /** \brief Set values in GUI to current values */
120
 
    void setOptions ( void );
121
 
 
122
 
    /** \brief Is layer on/off ? */
123
 
    bool layerOn ( QString id );
124
 
 
125
 
    /** \brief set layer on/off */
126
 
    void setLayerOn ( QString id, bool on );
127
 
 
128
 
    /** \brief get layer group, 0 == no group */
129
 
    int layerGroup ( QString id );
130
 
 
131
 
    /** \brief set layer group, 0 == no group */
132
 
    void setLayerGroup ( QString id, int group );
133
 
 
134
 
public slots:
135
 
    // Open font dialog
136
 
    void on_mFontButton_clicked ( void );
137
 
 
138
 
    // Title changed
139
 
    void on_mTitleLineEdit_returnPressed ( void );
140
 
    
141
 
    // Called by GUI if preview style was changed
142
 
    void on_mPreviewModeComboBox_activated ( int i );
143
 
 
144
 
    // Called by GUI when map selection changed
145
 
    void on_mMapComboBox_activated ( int i );
146
 
 
147
 
    // Called when map was changed
148
 
    void mapChanged ( int id );
149
 
 
150
 
    // Show popup menu
151
 
    void showLayersPopupMenu ( Q3ListViewItem * lvi, const QPoint & pt, int );
152
 
 
153
 
    // Layer status changed
154
 
    void layerChanged ( Q3ListViewItem *lvi );
155
 
 
156
 
    // Combine selected layers
157
 
    void groupLayers( void );
158
 
 
159
 
    // Frame settings changed
160
 
    void on_mFrameCheckBox_stateChanged ( int i );
161
 
 
162
 
private:
163
 
    // Pointer to composition
164
 
    QgsComposition *mComposition;
165
 
    
166
 
    // Pointer to map canvas
167
 
    QgsMapCanvas *mMapCanvas;
168
 
    
169
 
    // Composer map id or 0
170
 
    int mMap;
171
 
 
172
 
    // Vector of map id for maps in combobox
173
 
    std::vector<int> mMaps;
174
 
 
175
 
    // Title 
176
 
    QString mTitle;
177
 
 
178
 
    // Font. Font size in typographic points!
179
 
    QFont mTitleFont;
180
 
    QFont mSectionFont;
181
 
    QFont mFont;
182
 
 
183
 
    // Pen
184
 
    QPen  mPen;
185
 
 
186
 
    int mMargin;
187
 
    int mSymbolHeight;
188
 
    int mSymbolWidth;
189
 
    int mSymbolSpace;
190
 
 
191
 
    // Cache used in composer preview
192
 
    // NOTE:  QCanvasView is slow with bigger images but the spped does not decrease with image size.
193
 
    //        It is very slow, with zoom in in QCanvasView, it seems, that QCanvas is stored as a big image
194
 
    //        with resolution necessary for current zoom and so always a big image mus be redrawn. 
195
 
    QPixmap mCachePixmap; 
196
 
 
197
 
    // Is cache up to date
198
 
    bool mCacheUpdated;
199
 
    
200
 
    /** \brief Preview style  */
201
 
    PreviewMode mPreviewMode;
202
 
 
203
 
    /** \brief Number of layers when cache was created  */
204
 
    int mNumCachedLayers;
205
 
 
206
 
    /** \brief Keeps info if the layer is on or off */
207
 
    std::map<QString,bool> mLayersOn;
208
 
 
209
 
    /** \brief layer groups */
210
 
    std::map<QString,int> mLayersGroups;
211
 
 
212
 
    /** \brief new layer group id */
213
 
    int mNextLayerGroup;
214
 
 
215
 
    /** \brief Layers list popup menu */
216
 
    Q3PopupMenu *mLayersPopupMenu;
217
 
 
218
 
    /** \brief Draw frame  */
219
 
    bool mFrame;
220
 
};
221
 
 
222
 
#endif