Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsmaplayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayer.h - description
3  -------------------
4  begin : Fri Jun 28 2002
5  copyright : (C) 2002 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$ */
18 
19 #ifndef QGSMAPLAYER_H
20 #define QGSMAPLAYER_H
21 
22 #include <QDateTime>
23 #include <QObject>
24 #include <QUndoStack>
25 #include <QVariant>
26 #include <QImage>
27 
28 #include "qgis.h"
29 #include "qgsrectangle.h"
30 
31 class QgsRenderContext;
33 
34 class QDomNode;
35 class QDomDocument;
36 class QKeyEvent;
37 class QPainter;
38 
43 class CORE_EXPORT QgsMapLayer : public QObject
44 {
45  Q_OBJECT
46 
47  public:
49  enum LayerType
50  {
53  PluginLayer // added in 1.5
54  };
55 
61  QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, QString lyrname = QString::null, QString source = QString::null );
62 
64  virtual ~QgsMapLayer();
65 
69  QgsMapLayer::LayerType type() const;
70 
74  QString id() const;
75 
79  Q_DECL_DEPRECATED QString getLayerID() const { return id(); }
80 
84  void setLayerName( const QString & name );
85 
89  QString const & name() const;
90 
93  virtual void reload() {}
94 
101  virtual bool draw( QgsRenderContext& rendererContext );
102 
106  virtual void drawLabels( QgsRenderContext& rendererContext );
107 
109  QgsRectangle extent() const;
110 
115  bool isValid();
116 
121  QString publicSource() const;
122 
124  QString const & source() const;
125 
130  virtual QStringList subLayers();
131 
136  virtual void setLayerOrder( QStringList layers );
137 
139  virtual void setSubLayerVisibility( QString name, bool vis );
140 
141 
143  virtual bool isEditable() const;
144 
159  bool readXML( QDomNode & layer_node );
160 
161 
177  bool writeXML( QDomNode & layer_node, QDomDocument & document );
178 
181  void setCustomProperty( const QString& key, const QVariant& value );
184  QVariant customProperty( const QString& value, const QVariant& defaultValue = QVariant() ) const;
187  void removeCustomProperty( const QString& key );
188 
190  virtual bool copySymbologySettings( const QgsMapLayer& other ) = 0;
191 
193  virtual bool hasCompatibleSymbology( const QgsMapLayer& other ) const = 0;
194 
196  unsigned int getTransparency();
197 
199  void setTransparency( unsigned int );
200 
207  virtual QString lastErrorTitle();
208 
215  virtual QString lastError();
216 
220  const QgsCoordinateReferenceSystem& crs();
221 
227  Q_DECL_DEPRECATED const QgsCoordinateReferenceSystem& srs();
228 
231  void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );
232 
233 
235  static QString capitaliseLayerName( const QString name );
236 
245  virtual QString loadDefaultStyle( bool & theResultFlag );
246 
260  virtual QString loadNamedStyle( const QString theURI, bool & theResultFlag );
261 
262  virtual bool loadNamedStyleFromDb( const QString db, const QString theURI, QString &qml );
263 
272  virtual QString saveDefaultStyle( bool & theResultFlag );
273 
287  virtual QString saveNamedStyle( const QString theURI, bool & theResultFlag );
288 
294  virtual bool readSymbology( const QDomNode& node, QString& errorMessage ) = 0;
295 
302  virtual bool writeSymbology( QDomNode &node, QDomDocument& doc, QString& errorMessage ) const = 0;
303 
305  QUndoStack* undoStack();
306 
309  QImage * cacheImage() { return mpCacheImage; }
312  void setCacheImage( QImage * thepImage );
313 
314  public slots:
315 
317  virtual void invalidTransformInput();
318 
320  void setMinimumScale( float theMinScale );
321  float minimumScale();
322 
324  void setMaximumScale( float theMaxScale );
325  float maximumScale();
326 
328  void toggleScaleBasedVisibility( bool theVisibilityFlag );
329  bool hasScaleBasedVisibility();
330 
333  void clearCacheImage();
334 
336  virtual QDateTime timestamp() const { return QDateTime() ; }
337 
338  signals:
339 
341  void drawingProgress( int theProgress, int theTotalSteps );
342 
344  void statusChanged( QString theStatus );
345 
347  void layerNameChanged();
348 
352  void layerCrsChanged();
353 
357  void repaintRequested();
358 
361  void screenUpdateRequested();
362 
364  void recalculateExtents();
365 
368  void dataChanged();
369 
370  protected:
371 
374  void setValid( bool valid );
375 
379  virtual bool readXml( QDomNode & layer_node );
380 
384  virtual bool writeXml( QDomNode & layer_node, QDomDocument & document );
385 
386 
390  void readCustomProperties( const QDomNode& layerNode, const QString& keyStartsWith = "" );
391 
393  void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const;
394 
396  void connectNotify( const char * signal );
397 
399  unsigned int mTransparencyLevel;
400 
403 
405  bool mValid;
406 
408  QString mDataSource;
409 
411  QString mLayerName;
412 
415 
416  private:
417 
419  QgsMapLayer( QgsMapLayer const & );
420 
422  QgsMapLayer & operator=( QgsMapLayer const & );
423 
425  QString mID;
426 
429 
431  QString mTag;
432 
434  float mMinScale;
436  float mMaxScale;
439 
441  QUndoStack mUndoStack;
442 
443  QMap<QString, QVariant> mCustomProperties;
444 
447  QImage * mpCacheImage;
448 
449 };
450 
451 #endif