00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef QGSMAPLAYER_H
00020 #define QGSMAPLAYER_H
00021
00022
00023 #include <QObject>
00024 #include <QUndoStack>
00025 #include <QVariant>
00026 #include <QImage>
00027
00028 #include "qgsrectangle.h"
00029
00030 class QgsRenderContext;
00031 class QgsCoordinateReferenceSystem;
00032
00033 class QDomNode;
00034 class QDomDocument;
00035 class QKeyEvent;
00036 class QPainter;
00037
00042 class CORE_EXPORT QgsMapLayer : public QObject
00043 {
00044 Q_OBJECT
00045
00046 public:
00048 enum LayerType
00049 {
00050 VectorLayer,
00051 RasterLayer,
00052 PluginLayer
00053 };
00054
00060 QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, QString lyrname = QString::null, QString source = QString::null );
00061
00063 virtual ~QgsMapLayer();
00064
00068 QgsMapLayer::LayerType type() const;
00069
00071 QString getLayerID() const;
00072
00076 void setLayerName( const QString & name );
00077
00081 QString const & name() const;
00082
00085 virtual void reload() {}
00086
00093 virtual bool draw( QgsRenderContext& rendererContext );
00094
00098 virtual void drawLabels( QgsRenderContext& rendererContext );
00099
00101 QgsRectangle extent() const;
00102
00107 bool isValid();
00108
00113 QString publicSource() const;
00114
00116 QString const & source() const;
00117
00122 virtual QStringList subLayers();
00123
00128 virtual void setLayerOrder( QStringList layers );
00129
00131 virtual void setSubLayerVisibility( QString name, bool vis );
00132
00133
00135 virtual bool isEditable() const;
00136
00151 bool readXML( QDomNode & layer_node );
00152
00153
00169 bool writeXML( QDomNode & layer_node, QDomDocument & document );
00170
00173 void setCustomProperty( const QString& key, const QVariant& value );
00176 QVariant customProperty( const QString& value, const QVariant& defaultValue = QVariant() ) const;
00179 void removeCustomProperty( const QString& key );
00180
00182 virtual bool copySymbologySettings( const QgsMapLayer& other ) = 0;
00183
00185 virtual bool hasCompatibleSymbology( const QgsMapLayer& other ) const = 0;
00186
00188 unsigned int getTransparency();
00189
00191 void setTransparency( unsigned int );
00192
00199 virtual QString lastErrorTitle();
00200
00207 virtual QString lastError();
00208
00212 const QgsCoordinateReferenceSystem& crs();
00213
00219 const QgsCoordinateReferenceSystem& srs();
00220
00223 void setCrs( const QgsCoordinateReferenceSystem& srs, bool emitSignal = true );
00224
00225
00227 static QString capitaliseLayerName( const QString name );
00228
00237 virtual QString loadDefaultStyle( bool & theResultFlag );
00238
00252 virtual QString loadNamedStyle( const QString theURI, bool & theResultFlag );
00253
00254 virtual bool loadNamedStyleFromDb( const QString db, const QString theURI, QString &qml );
00255
00264 virtual QString saveDefaultStyle( bool & theResultFlag );
00265
00279 virtual QString saveNamedStyle( const QString theURI, bool & theResultFlag );
00280
00286 virtual bool readSymbology( const QDomNode& node, QString& errorMessage ) = 0;
00287
00294 virtual bool writeSymbology( QDomNode &node, QDomDocument& doc, QString& errorMessage ) const = 0;
00295
00297 QUndoStack* undoStack();
00298
00301 QImage * cacheImage() { return mpCacheImage; }
00304 void setCacheImage( QImage * thepImage );
00305
00306 public slots:
00307
00309 virtual void invalidTransformInput();
00310
00312 void setMinimumScale( float theMinScale );
00313 float minimumScale();
00314
00316 void setMaximumScale( float theMaxScale );
00317 float maximumScale();
00318
00320 void toggleScaleBasedVisibility( bool theVisibilityFlag );
00321 bool hasScaleBasedVisibility();
00322
00325 void clearCacheImage();
00326
00327 signals:
00328
00330 void drawingProgress( int theProgress, int theTotalSteps );
00331
00333 void statusChanged( QString theStatus );
00334
00336 void layerNameChanged();
00337
00341 void layerCrsChanged();
00342
00346 void repaintRequested();
00347
00350 void screenUpdateRequested();
00351
00353 void recalculateExtents();
00354
00357 void dataChanged();
00358
00359 protected:
00360
00363 void setValid( bool valid );
00364
00368 virtual bool readXml( QDomNode & layer_node );
00369
00373 virtual bool writeXml( QDomNode & layer_node, QDomDocument & document );
00374
00375
00377 void readCustomProperties( QDomNode & layerNode );
00378
00380 void writeCustomProperties( QDomNode & layerNode, QDomDocument & doc );
00381
00383 void connectNotify( const char * signal );
00384
00386 unsigned int mTransparencyLevel;
00387
00389 QgsRectangle mLayerExtent;
00390
00392 bool mValid;
00393
00395 QString mDataSource;
00396
00398 QString mLayerName;
00399
00401 QgsCoordinateReferenceSystem* mCRS;
00402
00403 private:
00404
00406 QgsMapLayer( QgsMapLayer const & );
00407
00409 QgsMapLayer & operator=( QgsMapLayer const & );
00410
00412 QString mID;
00413
00415 QgsMapLayer::LayerType mLayerType;
00416
00418 QString mTag;
00419
00421 float mMinScale;
00423 float mMaxScale;
00425 bool mScaleBasedVisibility;
00426
00428 QUndoStack mUndoStack;
00429
00430 QMap<QString, QVariant> mCustomProperties;
00431
00434 QImage * mpCacheImage;
00435
00436 };
00437
00438 #endif