mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Use enum properly for qgsmaplayer type and refactored 'LAYERS' to LayerType
git-svn-id: http://svn.osgeo.org/qgis/trunk@9483 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d1f02b7de7
commit
06144402cb
@ -798,7 +798,7 @@ All that remains to do now is sort out syncronisation of layer ordering between
|
|||||||
conventions (prefixed with m).
|
conventions (prefixed with m).
|
||||||
|
|
||||||
|
|
||||||
** Import Note *** ONLY THE MAPLAYER REGISTRY SHOULD DELETE LAYERS NOW ***
|
** Import Note *** ONLY THE MAPLAYER REGISTRY SHOULD DELETE QgsMapLayer::LayerType NOW ***
|
||||||
|
|
||||||
2004-06-03 [ts] 0.3.0devel14
|
2004-06-03 [ts] 0.3.0devel14
|
||||||
** Added getPaletteAsPixmap function to raster and display on raster props
|
** Added getPaletteAsPixmap function to raster and display on raster props
|
||||||
|
@ -11,11 +11,11 @@ class QgsMapLayer // TODO: problem when derived from QObject
|
|||||||
|
|
||||||
%ConvertToSubClassCode
|
%ConvertToSubClassCode
|
||||||
|
|
||||||
if (sipCpp->type() == QgsMapLayer::VECTOR)
|
if (sipCpp->type() == QgsMapLayer::VectorLayer)
|
||||||
{
|
{
|
||||||
sipClass = sipClass_QgsVectorLayer;
|
sipClass = sipClass_QgsVectorLayer;
|
||||||
}
|
}
|
||||||
else if (sipCpp->type() == QgsMapLayer::RASTER)
|
else if (sipCpp->type() == QgsMapLayer::RasterLayer)
|
||||||
{
|
{
|
||||||
sipClass = sipClass_QgsRasterLayer;
|
sipClass = sipClass_QgsRasterLayer;
|
||||||
}
|
}
|
||||||
@ -27,20 +27,26 @@ class QgsMapLayer // TODO: problem when derived from QObject
|
|||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** Layers enum defining the types of layers that can be added to a map */
|
||||||
|
enum LayerType
|
||||||
|
{
|
||||||
|
VectorLayer,
|
||||||
|
RasterLayer
|
||||||
|
};
|
||||||
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* @param type Type of layer as defined in LAYERS enum
|
* @param type Type of layer as defined in QgsMapLayer::LayerType enum
|
||||||
* @param lyrname Display Name of the layer
|
* @param lyrname Display Name of the layer
|
||||||
*/
|
*/
|
||||||
QgsMapLayer(int type = 0, QString lyrname = QString::null, QString source = QString::null);
|
QgsMapLayer(QgsMapLayer::LayerType type = QgsMapLayer::VectorLayer, QString lyrname = QString::null, QString source = QString::null);
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
virtual ~QgsMapLayer();
|
virtual ~QgsMapLayer();
|
||||||
|
|
||||||
/** Get the type of the layer
|
/** Get the type of the layer
|
||||||
* @return Integer matching a value in the LAYERS enum
|
* @return Integer matching a value in the QgsMapLayer::LayerType enum
|
||||||
*/
|
*/
|
||||||
int type() const;
|
QgsMapLayer::LayerType type() const;
|
||||||
|
|
||||||
/** Get this layer's unique ID, this ID is used to access this layer from map layer registry */
|
/** Get this layer's unique ID, this ID is used to access this layer from map layer registry */
|
||||||
QString getLayerID() const;
|
QString getLayerID() const;
|
||||||
@ -97,12 +103,6 @@ public:
|
|||||||
/** Set the visibility of the given sublayer name */
|
/** Set the visibility of the given sublayer name */
|
||||||
virtual void setSubLayerVisibility(QString name, bool vis);
|
virtual void setSubLayerVisibility(QString name, bool vis);
|
||||||
|
|
||||||
/** Layers enum defining the types of layers that can be added to a map */
|
|
||||||
enum LAYERS
|
|
||||||
{
|
|
||||||
VECTOR,
|
|
||||||
RASTER
|
|
||||||
};
|
|
||||||
|
|
||||||
/** True if the layer can be edited */
|
/** True if the layer can be edited */
|
||||||
virtual bool isEditable() const = 0;
|
virtual bool isEditable() const = 0;
|
||||||
|
@ -678,7 +678,7 @@ void QgsLegend::legendLayerShowProperties()
|
|||||||
a separate copy of the dialog pointer needs to be stored with each layer.
|
a separate copy of the dialog pointer needs to be stored with each layer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ml->type() == QgsMapLayer::RASTER )
|
if ( ml->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
|
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
|
||||||
if ( rlp )
|
if ( rlp )
|
||||||
|
@ -268,7 +268,7 @@ void QgsLegendLayer::refreshSymbology( const QString& key, double widthScale )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( theMapLayer->type() == QgsMapLayer::VECTOR ) // VECTOR
|
if ( theMapLayer->type() == QgsMapLayer::VectorLayer ) // VECTOR
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( theMapLayer );
|
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( theMapLayer );
|
||||||
vectorLayerSymbology( vlayer, widthScale ); // get and change symbology
|
vectorLayerSymbology( vlayer, widthScale ); // get and change symbology
|
||||||
@ -436,7 +436,7 @@ QPixmap QgsLegendLayer::getOriginalPixmap() const
|
|||||||
QgsMapLayer* firstLayer = firstMapLayer();
|
QgsMapLayer* firstLayer = firstMapLayer();
|
||||||
if ( firstLayer )
|
if ( firstLayer )
|
||||||
{
|
{
|
||||||
if ( firstLayer->type() == QgsMapLayer::VECTOR )
|
if ( firstLayer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( firstLayer );
|
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( firstLayer );
|
||||||
switch ( vlayer->type() )
|
switch ( vlayer->type() )
|
||||||
@ -454,7 +454,7 @@ QPixmap QgsLegendLayer::getOriginalPixmap() const
|
|||||||
return QgisApp::getThemePixmap( "/mIconLayer.png" );
|
return QgisApp::getThemePixmap( "/mIconLayer.png" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( firstLayer->type() == QgsMapLayer::RASTER )
|
else if ( firstLayer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>( firstLayer );
|
QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>( firstLayer );
|
||||||
QPixmap myPixmap( 32, 32 );
|
QPixmap myPixmap( 32, 32 );
|
||||||
@ -479,7 +479,7 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingActio
|
|||||||
// zoom to layer extent
|
// zoom to layer extent
|
||||||
theMenu.addAction( QgisApp::getThemeIcon( "/mActionZoomToLayer.png" ),
|
theMenu.addAction( QgisApp::getThemeIcon( "/mActionZoomToLayer.png" ),
|
||||||
tr( "&Zoom to layer extent" ), legend(), SLOT( legendLayerZoom() ) );
|
tr( "&Zoom to layer extent" ), legend(), SLOT( legendLayerZoom() ) );
|
||||||
if ( firstLayer && firstLayer->type() == QgsMapLayer::RASTER )
|
if ( firstLayer && firstLayer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
theMenu.addAction( tr( "&Zoom to best scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) );
|
theMenu.addAction( tr( "&Zoom to best scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) );
|
||||||
}
|
}
|
||||||
@ -495,7 +495,7 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingActio
|
|||||||
|
|
||||||
theMenu.addSeparator();
|
theMenu.addSeparator();
|
||||||
|
|
||||||
if ( firstLayer && firstLayer->type() == QgsMapLayer::VECTOR )
|
if ( firstLayer && firstLayer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
// attribute table
|
// attribute table
|
||||||
QAction* tableAction = theMenu.addAction( tr( "&Open attribute table" ), this, SLOT( table() ) );
|
QAction* tableAction = theMenu.addAction( tr( "&Open attribute table" ), this, SLOT( table() ) );
|
||||||
|
@ -229,7 +229,7 @@ void QgsLegendLayerFile::saveAsShapefileGeneral( bool saveOnlySelection )
|
|||||||
{
|
{
|
||||||
QgsCoordinateReferenceSystem destCRS;
|
QgsCoordinateReferenceSystem destCRS;
|
||||||
|
|
||||||
if ( mLyr.layer()->type() != QgsMapLayer::VECTOR )
|
if ( mLyr.layer()->type() != QgsMapLayer::VectorLayer )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( mLyr.layer() );
|
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( mLyr.layer() );
|
||||||
@ -374,7 +374,7 @@ void QgsLegendLayerFile::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingA
|
|||||||
|
|
||||||
theMenu.addSeparator();
|
theMenu.addSeparator();
|
||||||
|
|
||||||
if ( lyr->type() == QgsMapLayer::VECTOR )
|
if ( lyr->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr );
|
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr );
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ void QgsLegendLayerFile::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingA
|
|||||||
|
|
||||||
theMenu.addSeparator();
|
theMenu.addSeparator();
|
||||||
}
|
}
|
||||||
else if ( lyr->type() == QgsMapLayer::RASTER )
|
else if ( lyr->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
// TODO: what was this for?
|
// TODO: what was this for?
|
||||||
//QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>(lyr);
|
//QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>(lyr);
|
||||||
|
@ -2971,7 +2971,7 @@ void QgisApp::fileOpen()
|
|||||||
QMessageBox::critical( this,
|
QMessageBox::critical( this,
|
||||||
tr( "QGIS Project Read Error" ),
|
tr( "QGIS Project Read Error" ),
|
||||||
tr( "" ) + "\n" + QString::fromLocal8Bit( e.what() ) );
|
tr( "" ) + "\n" + QString::fromLocal8Bit( e.what() ) );
|
||||||
QgsDebugMsg( "BAD LAYERS FOUND" );
|
QgsDebugMsg( "BAD QgsMapLayer::LayerType FOUND" );
|
||||||
}
|
}
|
||||||
|
|
||||||
mMapCanvas->freeze( false );
|
mMapCanvas->freeze( false );
|
||||||
@ -3040,7 +3040,7 @@ bool QgisApp::addProject( QString projectFile )
|
|||||||
}
|
}
|
||||||
catch ( std::exception & e )
|
catch ( std::exception & e )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "BAD LAYERS FOUND" );
|
QgsDebugMsg( "BAD QgsMapLayer::LayerType FOUND" );
|
||||||
|
|
||||||
QMessageBox::critical( this,
|
QMessageBox::critical( this,
|
||||||
tr( "Unable to open project" ), QString::fromLocal8Bit( e.what() ) );
|
tr( "Unable to open project" ), QString::fromLocal8Bit( e.what() ) );
|
||||||
@ -4943,7 +4943,7 @@ void QgisApp::showMapTip()
|
|||||||
{
|
{
|
||||||
//QgsDebugMsg("Current layer for maptip display is: " + mypLayer->source());
|
//QgsDebugMsg("Current layer for maptip display is: " + mypLayer->source());
|
||||||
// only process vector layers
|
// only process vector layers
|
||||||
if ( mypLayer->type() == QgsMapLayer::VECTOR )
|
if ( mypLayer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
// Show the maptip if the maptips button is depressed
|
// Show the maptip if the maptips button is depressed
|
||||||
if ( mMapTipsVisible )
|
if ( mMapTipsVisible )
|
||||||
@ -5054,7 +5054,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
|||||||
mActionAddToOverview->setEnabled( true );
|
mActionAddToOverview->setEnabled( true );
|
||||||
|
|
||||||
/***********Vector layers****************/
|
/***********Vector layers****************/
|
||||||
if ( layer->type() == QgsMapLayer::VECTOR )
|
if ( layer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
mActionSelect->setEnabled( true );
|
mActionSelect->setEnabled( true );
|
||||||
mActionIdentify->setEnabled( true );
|
mActionIdentify->setEnabled( true );
|
||||||
@ -5198,7 +5198,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*************Raster layers*************/
|
/*************Raster layers*************/
|
||||||
else if ( layer->type() == QgsMapLayer::RASTER )
|
else if ( layer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
mActionSelect->setEnabled( false );
|
mActionSelect->setEnabled( false );
|
||||||
mActionZoomActualSize->setEnabled( true );
|
mActionZoomActualSize->setEnabled( true );
|
||||||
|
@ -205,7 +205,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
// feature type
|
// feature type
|
||||||
QgsDebugMsg( "\tMapsrver Export checking feature type" );
|
QgsDebugMsg( "\tMapsrver Export checking feature type" );
|
||||||
mapFile << " TYPE ";
|
mapFile << " TYPE ";
|
||||||
if ( lyr->type() == QgsMapLayer::VECTOR )
|
if ( lyr->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr );
|
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr );
|
||||||
switch ( vlayer->geometryType() )
|
switch ( vlayer->geometryType() )
|
||||||
@ -227,7 +227,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( lyr->type() == QgsMapLayer::RASTER )
|
if ( lyr->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
mapFile << "RASTER";
|
mapFile << "RASTER";
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
QgsDebugMsg( "\tMapsrver Export checking layer type" );
|
QgsDebugMsg( "\tMapsrver Export checking layer type" );
|
||||||
switch ( lyr->type() )
|
switch ( lyr->type() )
|
||||||
{
|
{
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VectorLayer:
|
||||||
// get the provider type
|
// get the provider type
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vlyr = dynamic_cast<QgsVectorLayer*>( lyr );
|
QgsVectorLayer* vlyr = dynamic_cast<QgsVectorLayer*>( lyr );
|
||||||
@ -286,7 +286,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QgsMapLayer::RASTER:
|
case QgsMapLayer::RasterLayer:
|
||||||
mapFile << " DATA " << lyr->source().toLocal8Bit().data() << std::endl;
|
mapFile << " DATA " << lyr->source().toLocal8Bit().data() << std::endl;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -87,7 +87,7 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
// coordinates are sent back to the server as pixel coordinates
|
// coordinates are sent back to the server as pixel coordinates
|
||||||
// not the layer's native CRS. So identify on screen coordinates!
|
// not the layer's native CRS. So identify on screen coordinates!
|
||||||
if (
|
if (
|
||||||
( mLayer->type() == QgsMapLayer::RASTER )
|
( mLayer->type() == QgsMapLayer::RasterLayer )
|
||||||
&&
|
&&
|
||||||
( dynamic_cast<QgsRasterLayer*>( mLayer )->providerKey() == "wms" )
|
( dynamic_cast<QgsRasterLayer*>( mLayer )->providerKey() == "wms" )
|
||||||
)
|
)
|
||||||
@ -99,11 +99,11 @@ void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent * e )
|
|||||||
// convert screen coordinates to map coordinates
|
// convert screen coordinates to map coordinates
|
||||||
QgsPoint idPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
|
QgsPoint idPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( e->x(), e->y() );
|
||||||
|
|
||||||
if ( mLayer->type() == QgsMapLayer::VECTOR )
|
if ( mLayer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
identifyVectorLayer( idPoint );
|
identifyVectorLayer( idPoint );
|
||||||
}
|
}
|
||||||
else if ( mLayer->type() == QgsMapLayer::RASTER )
|
else if ( mLayer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
identifyRasterLayer( idPoint );
|
identifyRasterLayer( idPoint );
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,10 @@ void QgsLegendModel::setLayerSet( const QStringList& layerIds )
|
|||||||
|
|
||||||
switch ( currentLayer->type() )
|
switch ( currentLayer->type() )
|
||||||
{
|
{
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VectorLayer:
|
||||||
addVectorLayerItems( layerItem, currentLayer );
|
addVectorLayerItems( layerItem, currentLayer );
|
||||||
break;
|
break;
|
||||||
case QgsMapLayer::RASTER:
|
case QgsMapLayer::RasterLayer:
|
||||||
addRasterLayerItem( layerItem, currentLayer );
|
addRasterLayerItem( layerItem, currentLayer );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -246,10 +246,10 @@ void QgsLegendModel::updateLayer( QStandardItem* layerItem )
|
|||||||
//and add the new ones...
|
//and add the new ones...
|
||||||
switch ( mapLayer->type() )
|
switch ( mapLayer->type() )
|
||||||
{
|
{
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VectorLayer:
|
||||||
addVectorLayerItems( layerItem, mapLayer );
|
addVectorLayerItems( layerItem, mapLayer );
|
||||||
break;
|
break;
|
||||||
case QgsMapLayer::RASTER:
|
case QgsMapLayer::RasterLayer:
|
||||||
addRasterLayerItem( layerItem, mapLayer );
|
addRasterLayerItem( layerItem, mapLayer );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -408,10 +408,10 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )
|
|||||||
//and child items of layer
|
//and child items of layer
|
||||||
switch ( theMapLayer->type() )
|
switch ( theMapLayer->type() )
|
||||||
{
|
{
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VectorLayer:
|
||||||
addVectorLayerItems( layerItem, theMapLayer );
|
addVectorLayerItems( layerItem, theMapLayer );
|
||||||
break;
|
break;
|
||||||
case QgsMapLayer::RASTER:
|
case QgsMapLayer::RasterLayer:
|
||||||
addRasterLayerItem( layerItem, theMapLayer );
|
addRasterLayerItem( layerItem, theMapLayer );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "qgsproject.h"
|
#include "qgsproject.h"
|
||||||
#include "qgslogger.h"
|
#include "qgslogger.h"
|
||||||
|
|
||||||
QgsMapLayer::QgsMapLayer( int type,
|
QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
|
||||||
QString lyrname,
|
QString lyrname,
|
||||||
QString source ) :
|
QString source ) :
|
||||||
mTransparencyLevel( 255 ), // 0 is completely transparent
|
mTransparencyLevel( 255 ), // 0 is completely transparent
|
||||||
@ -82,7 +82,7 @@ QgsMapLayer::~QgsMapLayer()
|
|||||||
delete mCRS;
|
delete mCRS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QgsMapLayer::type() const
|
QgsMapLayer::LayerType QgsMapLayer::type() const
|
||||||
{
|
{
|
||||||
return mLayerType;
|
return mLayerType;
|
||||||
}
|
}
|
||||||
|
@ -43,20 +43,26 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** Layers enum defining the types of layers that can be added to a map */
|
||||||
|
enum LayerType
|
||||||
|
{
|
||||||
|
VectorLayer,
|
||||||
|
RasterLayer
|
||||||
|
};
|
||||||
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* @param type Type of layer as defined in LAYERS enum
|
* @param type Type of layer as defined in QgsMapLayer::LayerType enum
|
||||||
* @param lyrname Display Name of the layer
|
* @param lyrname Display Name of the layer
|
||||||
*/
|
*/
|
||||||
QgsMapLayer( int type = 0, QString lyrname = QString::null, QString source = QString::null );
|
QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, QString lyrname = QString::null, QString source = QString::null );
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
virtual ~QgsMapLayer();
|
virtual ~QgsMapLayer();
|
||||||
|
|
||||||
/** Get the type of the layer
|
/** Get the type of the layer
|
||||||
* @return Integer matching a value in the LAYERS enum
|
* @return Integer matching a value in the QgsMapLayer::LayerType enum
|
||||||
*/
|
*/
|
||||||
int type() const;
|
QgsMapLayer::LayerType type() const;
|
||||||
|
|
||||||
/** Get this layer's unique ID, this ID is used to access this layer from map layer registry */
|
/** Get this layer's unique ID, this ID is used to access this layer from map layer registry */
|
||||||
QString getLayerID() const;
|
QString getLayerID() const;
|
||||||
@ -111,12 +117,6 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
/** Set the visibility of the given sublayer name */
|
/** Set the visibility of the given sublayer name */
|
||||||
virtual void setSubLayerVisibility( QString name, bool vis );
|
virtual void setSubLayerVisibility( QString name, bool vis );
|
||||||
|
|
||||||
/** Layers enum defining the types of layers that can be added to a map */
|
|
||||||
enum LAYERS
|
|
||||||
{
|
|
||||||
VECTOR,
|
|
||||||
RASTER
|
|
||||||
};
|
|
||||||
|
|
||||||
/** True if the layer can be edited */
|
/** True if the layer can be edited */
|
||||||
virtual bool isEditable() const = 0;
|
virtual bool isEditable() const = 0;
|
||||||
@ -344,7 +344,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
QString mID;
|
QString mID;
|
||||||
|
|
||||||
/** Type of the layer (eg. vector, raster) */
|
/** Type of the layer (eg. vector, raster) */
|
||||||
int mLayerType;
|
QgsMapLayer::LayerType mLayerType;
|
||||||
|
|
||||||
/** Tag for embedding additional information */
|
/** Tag for embedding additional information */
|
||||||
QString mTag;
|
QString mTag;
|
||||||
|
@ -321,7 +321,7 @@ void QgsMapRenderer::render( QPainter* painter )
|
|||||||
QgsMapToPixel rasterMapToPixel;
|
QgsMapToPixel rasterMapToPixel;
|
||||||
QgsMapToPixel bk_mapToPixel;
|
QgsMapToPixel bk_mapToPixel;
|
||||||
|
|
||||||
if ( ml->type() == QgsMapLayer::RASTER && fabs( rasterScaleFactor - 1.0 ) > 0.000001 )
|
if ( ml->type() == QgsMapLayer::RasterLayer && fabs( rasterScaleFactor - 1.0 ) > 0.000001 )
|
||||||
{
|
{
|
||||||
scaleRaster = true;
|
scaleRaster = true;
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void QgsMapRenderer::render( QPainter* painter )
|
|||||||
// TODO: emit drawingProgress((myRenderCounter++),zOrder.size());
|
// TODO: emit drawingProgress((myRenderCounter++),zOrder.size());
|
||||||
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
|
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
|
||||||
|
|
||||||
if ( ml && ( ml->type() != QgsMapLayer::RASTER ) )
|
if ( ml && ( ml->type() != QgsMapLayer::RasterLayer ) )
|
||||||
{
|
{
|
||||||
// only make labels if the layer is visible
|
// only make labels if the layer is visible
|
||||||
// after scale dep viewing settings are checked
|
// after scale dep viewing settings are checked
|
||||||
|
@ -89,7 +89,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
|
|||||||
QString baseName,
|
QString baseName,
|
||||||
QString providerKey,
|
QString providerKey,
|
||||||
bool loadDefaultStyleFlag )
|
bool loadDefaultStyleFlag )
|
||||||
: QgsMapLayer( VECTOR, baseName, vectorLayerPath ),
|
: QgsMapLayer( VectorLayer, baseName, vectorLayerPath ),
|
||||||
mUpdateThreshold( 0 ), // XXX better default value?
|
mUpdateThreshold( 0 ), // XXX better default value?
|
||||||
mDataProvider( NULL ),
|
mDataProvider( NULL ),
|
||||||
mProviderKey( providerKey ),
|
mProviderKey( providerKey ),
|
||||||
|
@ -304,7 +304,7 @@ QgsRasterLayer::QgsRasterLayer(
|
|||||||
QString const & path,
|
QString const & path,
|
||||||
QString const & baseName,
|
QString const & baseName,
|
||||||
bool loadDefaultStyleFlag )
|
bool loadDefaultStyleFlag )
|
||||||
: QgsMapLayer( RASTER, baseName, path ),
|
: QgsMapLayer( RasterLayer, baseName, path ),
|
||||||
// Constant that signals property not used.
|
// Constant that signals property not used.
|
||||||
QSTRING_NOT_SET( "Not Set" ),
|
QSTRING_NOT_SET( "Not Set" ),
|
||||||
TRSTRING_NOT_SET( tr( "Not Set" ) ),
|
TRSTRING_NOT_SET( tr( "Not Set" ) ),
|
||||||
@ -4572,7 +4572,7 @@ QgsRasterLayer::QgsRasterLayer( int dummy,
|
|||||||
QStringList const & styles,
|
QStringList const & styles,
|
||||||
QString const & format,
|
QString const & format,
|
||||||
QString const & crs )
|
QString const & crs )
|
||||||
: QgsMapLayer( RASTER, baseName, rasterLayerPath ),
|
: QgsMapLayer( RasterLayer, baseName, rasterLayerPath ),
|
||||||
mRasterXDim( std::numeric_limits<int>::max() ),
|
mRasterXDim( std::numeric_limits<int>::max() ),
|
||||||
mRasterYDim( std::numeric_limits<int>::max() ),
|
mRasterYDim( std::numeric_limits<int>::max() ),
|
||||||
mInvertPixelsFlag( false ),
|
mInvertPixelsFlag( false ),
|
||||||
|
@ -94,7 +94,7 @@ void QgsPgGeoprocessing::buffer()
|
|||||||
{
|
{
|
||||||
QgsVectorLayer *lyr = ( QgsVectorLayer* )layer;
|
QgsVectorLayer *lyr = ( QgsVectorLayer* )layer;
|
||||||
// check the layer to see if its a postgres layer
|
// check the layer to see if its a postgres layer
|
||||||
if ( layer->type() != QgsMapLayer::RASTER &&
|
if ( layer->type() != QgsMapLayer::RasterLayer &&
|
||||||
lyr->providerType() == "postgres" )
|
lyr->providerType() == "postgres" )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void QgsGPSPlugin::run()
|
|||||||
for ( iter = registry->mapLayers().begin();
|
for ( iter = registry->mapLayers().begin();
|
||||||
iter != registry->mapLayers().end(); ++iter )
|
iter != registry->mapLayers().end(); ++iter )
|
||||||
{
|
{
|
||||||
if ( iter.value()->type() == QgsMapLayer::VECTOR )
|
if ( iter.value()->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer*>( iter.value() );
|
QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer*>( iter.value() );
|
||||||
if ( vLayer->providerType() == "gpx" )
|
if ( vLayer->providerType() == "gpx" )
|
||||||
|
@ -186,7 +186,7 @@ bool QgsGrassEdit::isEditable( QgsMapLayer *layer )
|
|||||||
|
|
||||||
QgsDebugMsg( "layer name: " + layer->name() );
|
QgsDebugMsg( "layer name: " + layer->name() );
|
||||||
|
|
||||||
if ( layer->type() != QgsMapLayer::VECTOR )
|
if ( layer->type() != QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( "The selected layer is not vector." );
|
QgsDebugMsg( "The selected layer is not vector." );
|
||||||
return false;
|
return false;
|
||||||
|
@ -847,7 +847,7 @@ void QgsGrassMapcalc::updateMaps()
|
|||||||
{
|
{
|
||||||
QgsMapLayer *layer = canvas->layer( i );
|
QgsMapLayer *layer = canvas->layer( i );
|
||||||
|
|
||||||
if ( layer->type() != QgsMapLayer::RASTER ) continue;
|
if ( layer->type() != QgsMapLayer::RasterLayer ) continue;
|
||||||
|
|
||||||
// Check if it is GRASS raster
|
// Check if it is GRASS raster
|
||||||
QString source = QDir::cleanPath( layer->source() );
|
QString source = QDir::cleanPath( layer->source() );
|
||||||
|
@ -601,7 +601,7 @@ void QgsGrassModuleStandardOptions::freezeOutput()
|
|||||||
{
|
{
|
||||||
QgsMapLayer *layer = mCanvas->layer( i );
|
QgsMapLayer *layer = mCanvas->layer( i );
|
||||||
|
|
||||||
if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
if ( layer->type() != QgsMapLayer::VectorLayer ) continue;
|
||||||
|
|
||||||
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
||||||
if ( vector->providerType() != "grass" ) continue;
|
if ( vector->providerType() != "grass" ) continue;
|
||||||
@ -673,7 +673,7 @@ void QgsGrassModuleStandardOptions::thawOutput()
|
|||||||
{
|
{
|
||||||
QgsMapLayer *layer = mCanvas->layer( i );
|
QgsMapLayer *layer = mCanvas->layer( i );
|
||||||
|
|
||||||
if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
if ( layer->type() != QgsMapLayer::VectorLayer ) continue;
|
||||||
|
|
||||||
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
||||||
if ( vector->providerType() != "grass" ) continue;
|
if ( vector->providerType() != "grass" ) continue;
|
||||||
@ -2262,7 +2262,7 @@ void QgsGrassModuleInput::updateQgisLayers()
|
|||||||
|
|
||||||
QgsDebugMsg( "layer->type() = " + QString::number( layer->type() ) );
|
QgsDebugMsg( "layer->type() = " + QString::number( layer->type() ) );
|
||||||
|
|
||||||
if ( mType == Vector && layer->type() == QgsMapLayer::VECTOR )
|
if ( mType == Vector && layer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
||||||
QgsDebugMsg( "vector->providerType() = " + vector->providerType() );
|
QgsDebugMsg( "vector->providerType() = " + vector->providerType() );
|
||||||
@ -2363,7 +2363,7 @@ void QgsGrassModuleInput::updateQgisLayers()
|
|||||||
fields.push_back( it.value() );
|
fields.push_back( it.value() );
|
||||||
mVectorFields.push_back( fields );
|
mVectorFields.push_back( fields );
|
||||||
}
|
}
|
||||||
else if ( mType == Raster && layer->type() == QgsMapLayer::RASTER )
|
else if ( mType == Raster && layer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
// Check if it is GRASS raster
|
// Check if it is GRASS raster
|
||||||
QString source = QDir::cleanPath( layer->source() );
|
QString source = QDir::cleanPath( layer->source() );
|
||||||
@ -2673,7 +2673,7 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
|
|||||||
{
|
{
|
||||||
QgsMapLayer *layer = canvas->layer( i );
|
QgsMapLayer *layer = canvas->layer( i );
|
||||||
|
|
||||||
if ( mType == Ogr && layer->type() == QgsMapLayer::VECTOR )
|
if ( mType == Ogr && layer->type() == QgsMapLayer::VectorLayer )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
|
||||||
if ( vector->providerType() != "ogr"
|
if ( vector->providerType() != "ogr"
|
||||||
@ -2715,7 +2715,7 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
|
|||||||
mOgrLayers.push_back( ogrLayer );
|
mOgrLayers.push_back( ogrLayer );
|
||||||
mOgrWheres.push_back( ogrWhere );
|
mOgrWheres.push_back( ogrWhere );
|
||||||
}
|
}
|
||||||
else if ( mType == Gdal && layer->type() == QgsMapLayer::RASTER )
|
else if ( mType == Gdal && layer->type() == QgsMapLayer::RasterLayer )
|
||||||
{
|
{
|
||||||
QString uri = layer->source();
|
QString uri = layer->source();
|
||||||
mLayerComboBox->addItem( layer->name() );
|
mLayerComboBox->addItem( layer->name() );
|
||||||
|
@ -395,7 +395,7 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p
|
|||||||
url += "&";
|
url += "&";
|
||||||
url += "HEIGHT=" + height;
|
url += "HEIGHT=" + height;
|
||||||
url += "&";
|
url += "&";
|
||||||
url += "LAYERS=" + layers;
|
url += "QgsMapLayer::LayerType=" + layers;
|
||||||
url += "&";
|
url += "&";
|
||||||
url += "STYLES=" + styles;
|
url += "STYLES=" + styles;
|
||||||
url += "&";
|
url += "&";
|
||||||
@ -424,7 +424,7 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p
|
|||||||
mGetFeatureInfoUrlBase += "&";
|
mGetFeatureInfoUrlBase += "&";
|
||||||
mGetFeatureInfoUrlBase += "HEIGHT=" + height;
|
mGetFeatureInfoUrlBase += "HEIGHT=" + height;
|
||||||
mGetFeatureInfoUrlBase += "&";
|
mGetFeatureInfoUrlBase += "&";
|
||||||
mGetFeatureInfoUrlBase += "LAYERS=" + layers;
|
mGetFeatureInfoUrlBase += "QgsMapLayer::LayerType=" + layers;
|
||||||
mGetFeatureInfoUrlBase += "&";
|
mGetFeatureInfoUrlBase += "&";
|
||||||
mGetFeatureInfoUrlBase += "STYLES=" + styles;
|
mGetFeatureInfoUrlBase += "STYLES=" + styles;
|
||||||
mGetFeatureInfoUrlBase += "&";
|
mGetFeatureInfoUrlBase += "&";
|
||||||
@ -2152,7 +2152,7 @@ QString QgsWmsProvider::identifyAsText( const QgsPoint& point )
|
|||||||
QString layer = QUrl::toPercentEncoding( *it );
|
QString layer = QUrl::toPercentEncoding( *it );
|
||||||
|
|
||||||
requestUrl += "&";
|
requestUrl += "&";
|
||||||
requestUrl += "QUERY_LAYERS=" + layer ;
|
requestUrl += "QUERY_QgsMapLayer::LayerType=" + layer ;
|
||||||
requestUrl += "&";
|
requestUrl += "&";
|
||||||
//! \todo Need to tie this into the options provided by GetCapabilities
|
//! \todo Need to tie this into the options provided by GetCapabilities
|
||||||
requestUrl += "INFO_FORMAT=text/plain";
|
requestUrl += "INFO_FORMAT=text/plain";
|
||||||
|
@ -357,7 +357,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(lyr->type() == QgsMapLayer::RASTER)
|
if(lyr->type() == QgsMapLayer::RasterLayer)
|
||||||
{
|
{
|
||||||
mapFile << "RASTER";
|
mapFile << "RASTER";
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
#endif
|
#endif
|
||||||
switch (lyr->type())
|
switch (lyr->type())
|
||||||
{
|
{
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VectorLayer:
|
||||||
// get the provider type
|
// get the provider type
|
||||||
{
|
{
|
||||||
QString providerType =
|
QString providerType =
|
||||||
@ -419,7 +419,7 @@ void QgsMapserverExport::writeMapFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QgsMapLayer::RASTER:
|
case QgsMapLayer::RasterLayer:
|
||||||
mapFile << " DATA " << lyr->source().toLocal8Bit().data() << std::endl;
|
mapFile << " DATA " << lyr->source().toLocal8Bit().data() << std::endl;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user