1
/***************************************************************************
2
qgscomposervectorlegend.h
5
copyright : (C) 2005 by Radim Blazek
7
***************************************************************************/
9
/***************************************************************************
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. *
16
***************************************************************************/
17
#ifndef QGSCOMPOSERVECTORLEGEND_H
18
#define QGSCOMPOSERVECTORLEGEND_H
23
* +----------------------+
30
* mSymbolHeight | | | | Item Label | __| - mFont->pointSize()
32
* | | | - mSymbolSpace (vertical space between symbo, boxes)
37
* +----------------------+
40
* |<--->| - mSymbolWidth (lines and areas)
44
#include "ui_qgscomposervectorlegendbase.h"
45
#include "qgscomposeritem.h"
46
#include <Q3CanvasPolygonalItem>
60
/** \class QgsComposerVectorLegend
61
* \brief Object representing map window.
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
72
/** \brief Constructor
74
* \param fontSize font size in typographic points!
76
QgsComposerVectorLegend( QgsComposition *composition, int id, int x, int y, int fontSize = 0 );
78
/** \brief Constructor. Settings are read from project.
81
QgsComposerVectorLegend( QgsComposition *composition, int id );
82
~QgsComposerVectorLegend();
84
/** \brief Preview style */
86
Cache = 0, // Use raster cache
87
Render, // Render the map
88
Rectangle // Display only rectangle
91
/** \brief Initialise GUI etc., share by constructors. */
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 );
104
/** \brief Draw to paint device, internal use
105
* \param painter painter or 0
106
* \return bounding box
108
QRect render (QPainter *painter);
110
/** \brief Reimplementation of QCanvasItem::draw - draw on canvas */
111
void draw ( QPainter & painter );
113
/** \brief Calculate size according to current settings */
114
void recalculate ( void );
116
/** \brief Create cache image */
119
/** \brief Set values in GUI to current values */
120
void setOptions ( void );
122
/** \brief Is layer on/off ? */
123
bool layerOn ( QString id );
125
/** \brief set layer on/off */
126
void setLayerOn ( QString id, bool on );
128
/** \brief get layer group, 0 == no group */
129
int layerGroup ( QString id );
131
/** \brief set layer group, 0 == no group */
132
void setLayerGroup ( QString id, int group );
136
void on_mFontButton_clicked ( void );
139
void on_mTitleLineEdit_returnPressed ( void );
141
// Called by GUI if preview style was changed
142
void on_mPreviewModeComboBox_activated ( int i );
144
// Called by GUI when map selection changed
145
void on_mMapComboBox_activated ( int i );
147
// Called when map was changed
148
void mapChanged ( int id );
151
void showLayersPopupMenu ( Q3ListViewItem * lvi, const QPoint & pt, int );
153
// Layer status changed
154
void layerChanged ( Q3ListViewItem *lvi );
156
// Combine selected layers
157
void groupLayers( void );
159
// Frame settings changed
160
void on_mFrameCheckBox_stateChanged ( int i );
163
// Pointer to composition
164
QgsComposition *mComposition;
166
// Pointer to map canvas
167
QgsMapCanvas *mMapCanvas;
169
// Composer map id or 0
172
// Vector of map id for maps in combobox
173
std::vector<int> mMaps;
178
// Font. Font size in typographic points!
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;
197
// Is cache up to date
200
/** \brief Preview style */
201
PreviewMode mPreviewMode;
203
/** \brief Number of layers when cache was created */
204
int mNumCachedLayers;
206
/** \brief Keeps info if the layer is on or off */
207
std::map<QString,bool> mLayersOn;
209
/** \brief layer groups */
210
std::map<QString,int> mLayersGroups;
212
/** \brief new layer group id */
215
/** \brief Layers list popup menu */
216
Q3PopupMenu *mLayersPopupMenu;
218
/** \brief Draw frame */