Quantum GIS API Documentation  1.7.4
src/core/qgsmaplayer.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsmaplayer.h  -  description
00003                              -------------------
00004     begin                : Fri Jun 28 2002
00005     copyright            : (C) 2002 by Gary E.Sherman
00006     email                : sherman at mrcc.com
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 /* $Id$ */
00018 
00019 #ifndef QGSMAPLAYER_H
00020 #define QGSMAPLAYER_H
00021 
00022 #include <QDateTime>
00023 #include <QObject>
00024 #include <QUndoStack>
00025 #include <QVariant>
00026 #include <QImage>
00027 
00028 #include "qgis.h"
00029 #include "qgsrectangle.h"
00030 
00031 class QgsRenderContext;
00032 class QgsCoordinateReferenceSystem;
00033 
00034 class QDomNode;
00035 class QDomDocument;
00036 class QKeyEvent;
00037 class QPainter;
00038 
00043 class CORE_EXPORT QgsMapLayer : public QObject
00044 {
00045     Q_OBJECT
00046 
00047   public:
00049     enum LayerType
00050     {
00051       VectorLayer,
00052       RasterLayer,
00053       PluginLayer // added in 1.5
00054     };
00055 
00061     QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, QString lyrname = QString::null, QString source = QString::null );
00062 
00064     virtual ~QgsMapLayer();
00065 
00069     QgsMapLayer::LayerType type() const;
00070 
00074     QString id() const;
00075 
00079     Q_DECL_DEPRECATED QString getLayerID() const { return id(); }
00080 
00084     void setLayerName( const QString & name );
00085 
00089     QString const & name() const;
00090 
00093     virtual void reload() {}
00094 
00101     virtual bool draw( QgsRenderContext& rendererContext );
00102 
00106     virtual void drawLabels( QgsRenderContext& rendererContext );
00107 
00109     QgsRectangle extent() const;
00110 
00115     bool isValid();
00116 
00121     QString publicSource() const;
00122 
00124     QString const & source() const;
00125 
00130     virtual QStringList subLayers();
00131 
00136     virtual void setLayerOrder( QStringList layers );
00137 
00139     virtual void setSubLayerVisibility( QString name, bool vis );
00140 
00141 
00143     virtual bool isEditable() const;
00144 
00159     bool readXML( QDomNode & layer_node );
00160 
00161 
00177     bool writeXML( QDomNode & layer_node, QDomDocument & document );
00178 
00181     void setCustomProperty( const QString& key, const QVariant& value );
00184     QVariant customProperty( const QString& value, const QVariant& defaultValue = QVariant() ) const;
00187     void removeCustomProperty( const QString& key );
00188 
00190     virtual bool copySymbologySettings( const QgsMapLayer& other ) = 0;
00191 
00193     virtual bool hasCompatibleSymbology( const QgsMapLayer& other ) const = 0;
00194 
00196     unsigned int getTransparency();
00197 
00199     void setTransparency( unsigned int );
00200 
00207     virtual QString lastErrorTitle();
00208 
00215     virtual QString lastError();
00216 
00220     const QgsCoordinateReferenceSystem& crs();
00221 
00227     Q_DECL_DEPRECATED const QgsCoordinateReferenceSystem& srs();
00228 
00231     void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );
00232 
00233 
00235     static QString capitaliseLayerName( const QString name );
00236 
00245     virtual QString loadDefaultStyle( bool & theResultFlag );
00246 
00260     virtual QString loadNamedStyle( const QString theURI, bool & theResultFlag );
00261 
00262     virtual bool loadNamedStyleFromDb( const QString db, const QString theURI, QString &qml );
00263 
00272     virtual QString saveDefaultStyle( bool & theResultFlag );
00273 
00287     virtual QString saveNamedStyle( const QString theURI, bool & theResultFlag );
00288 
00294     virtual bool readSymbology( const QDomNode& node, QString& errorMessage ) = 0;
00295 
00302     virtual bool writeSymbology( QDomNode &node, QDomDocument& doc, QString& errorMessage ) const = 0;
00303 
00305     QUndoStack* undoStack();
00306 
00309     QImage * cacheImage() { return mpCacheImage; }
00312     void setCacheImage( QImage * thepImage );
00313 
00314   public slots:
00315 
00317     virtual void invalidTransformInput();
00318 
00320     void setMinimumScale( float theMinScale );
00321     float minimumScale();
00322 
00324     void setMaximumScale( float theMaxScale );
00325     float maximumScale();
00326 
00328     void toggleScaleBasedVisibility( bool theVisibilityFlag );
00329     bool hasScaleBasedVisibility();
00330 
00333     void clearCacheImage();
00334 
00336     virtual QDateTime timestamp() const { return QDateTime() ; }
00337 
00338   signals:
00339 
00341     void drawingProgress( int theProgress, int theTotalSteps );
00342 
00344     void statusChanged( QString theStatus );
00345 
00347     void layerNameChanged();
00348 
00352     void layerCrsChanged();
00353 
00357     void repaintRequested();
00358 
00361     void screenUpdateRequested();
00362 
00364     void recalculateExtents();
00365 
00368     void dataChanged();
00369 
00370   protected:
00371 
00374     void setValid( bool valid );
00375 
00379     virtual bool readXml( QDomNode & layer_node );
00380 
00384     virtual bool writeXml( QDomNode & layer_node, QDomDocument & document );
00385 
00386 
00390     void readCustomProperties( const QDomNode& layerNode, const QString& keyStartsWith = "" );
00391 
00393     void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const;
00394 
00396     void connectNotify( const char * signal );
00397 
00399     unsigned int mTransparencyLevel;
00400 
00402     QgsRectangle mLayerExtent;
00403 
00405     bool mValid;
00406 
00408     QString mDataSource;
00409 
00411     QString mLayerName;
00412 
00414     QgsCoordinateReferenceSystem* mCRS;
00415 
00416   private:
00417 
00419     QgsMapLayer( QgsMapLayer const & );
00420 
00422     QgsMapLayer & operator=( QgsMapLayer const & );
00423 
00425     QString mID;
00426 
00428     QgsMapLayer::LayerType mLayerType;
00429 
00431     QString mTag;
00432 
00434     float mMinScale;
00436     float mMaxScale;
00438     bool mScaleBasedVisibility;
00439 
00441     QUndoStack mUndoStack;
00442 
00443     QMap<QString, QVariant> mCustomProperties;
00444 
00447     QImage * mpCacheImage;
00448 
00449 };
00450 
00451 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines