Skip to content

Commit

Permalink
Cleanup for type accessors on maplayer and subclasses
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9493 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 18, 2008
1 parent f6a690f commit a8daacf
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public:
void setRenderer(QgsRenderer * r /Transfer/);

/** Returns point, line or polygon */
QGis::GeometryType type() const;
QGis::GeometryType geometryType() const;

/**Returns the WKBType or WKBUnknown in case of error*/
QGis::WkbType geometryType() const;
QGis::WkbType wkbType() const;

/** Return the provider type for this layer */
QString providerType() const;
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5100,7 +5100,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
}


if ( vlayer->type() == QGis::Point )
if ( vlayer->geometryType() == QGis::Point )
{
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
Expand All @@ -5123,15 +5123,15 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries )
{
//don't enable vertex move for single point
if ( vlayer->geometryType() != QGis::WKBPoint && vlayer->geometryType() != QGis::WKBPoint25D )
if ( vlayer->wkbType() != QGis::WKBPoint && vlayer->wkbType() != QGis::WKBPoint25D )
{
mActionMoveVertex->setEnabled( true );
}
mActionMoveFeature->setEnabled( true );
}
return;
}
else if ( vlayer->type() == QGis::Line )
else if ( vlayer->geometryType() == QGis::Line )
{
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
Expand All @@ -5150,7 +5150,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddRing->setEnabled( false );
mActionAddIsland->setEnabled( false );
}
else if ( vlayer->type() == QGis::Polygon )
else if ( vlayer->geometryType() == QGis::Polygon )
{
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
Expand Down Expand Up @@ -5179,7 +5179,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionMoveVertex->setEnabled( true );
mActionDeleteVertex->setEnabled( true );
mActionMoveFeature->setEnabled( true );
if ( vlayer->type() == QGis::Polygon )
if ( vlayer->geometryType() == QGis::Polygon )
{
mActionAddRing->setEnabled( true );
//some polygon layers contain also multipolygon features.
Expand Down
16 changes: 8 additions & 8 deletions src/app/qgscontinuouscolordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
const QgsSymbol* minsymbol = renderer->minimumSymbol();
const QgsSymbol* maxsymbol = renderer->maximumSymbol();

if ( mVectorLayer->type() == QGis::Line || mVectorLayer->type() == QGis::Point )
if ( mVectorLayer->geometryType() == QGis::Line || mVectorLayer->geometryType() == QGis::Point )
{
btnMinValue->setColor( minsymbol->pen().color() );
btnMaxValue->setColor( maxsymbol->pen().color() );
Expand All @@ -114,7 +114,7 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
cb_polygonOutline->setCheckState( Qt::Unchecked );
}

if ( mVectorLayer->type() != QGis::Polygon )
if ( mVectorLayer->geometryType() != QGis::Polygon )
{
cb_polygonOutline->setVisible( false );
}
Expand All @@ -123,7 +123,7 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
{
cb_polygonOutline->setCheckState( Qt::Checked );
outlinewidthspinbox->setValue( 0.4 );
if ( mVectorLayer->type() != QGis::Polygon )
if ( mVectorLayer->geometryType() != QGis::Polygon )
cb_polygonOutline->setVisible( false );

btnMinValue->setColor( Qt::black );
Expand Down Expand Up @@ -179,11 +179,11 @@ void QgsContinuousColorDialog::apply()


//create the render items for minimum and maximum value
QgsSymbol* minsymbol = new QgsSymbol( mVectorLayer->type(), QString::number( minimum, 'f' ), "", "" );
QgsSymbol* minsymbol = new QgsSymbol( mVectorLayer->geometryType(), QString::number( minimum, 'f' ), "", "" );
QPen minPen;
minPen.setColor( btnMinValue->color() );
minPen.setWidthF( outlinewidthspinbox->value() );
if ( mVectorLayer->type() == QGis::Line || mVectorLayer->type() == QGis::Point )
if ( mVectorLayer->geometryType() == QGis::Line || mVectorLayer->geometryType() == QGis::Point )
{
minsymbol->setPen( minPen );
}
Expand All @@ -193,11 +193,11 @@ void QgsContinuousColorDialog::apply()
minsymbol->setPen( minPen );
}

QgsSymbol* maxsymbol = new QgsSymbol( mVectorLayer->type(), QString::number( maximum, 'f' ), "", "" );
QgsSymbol* maxsymbol = new QgsSymbol( mVectorLayer->geometryType(), QString::number( maximum, 'f' ), "", "" );
QPen maxPen;
maxPen.setColor( btnMaxValue->color() );
maxPen.setWidthF( outlinewidthspinbox->value() );
if ( mVectorLayer->type() == QGis::Line || mVectorLayer->type() == QGis::Point )
if ( mVectorLayer->geometryType() == QGis::Line || mVectorLayer->geometryType() == QGis::Point )
{
maxsymbol->setPen( maxPen );
}
Expand All @@ -207,7 +207,7 @@ void QgsContinuousColorDialog::apply()
maxsymbol->setPen( maxPen );
}

QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer( mVectorLayer->type() );
QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer( mVectorLayer->geometryType() );
mVectorLayer->setRenderer( renderer );

renderer->setMinimumSymbol( minsymbol );
Expand Down
14 changes: 7 additions & 7 deletions src/app/qgsgraduatedsymboldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog( QgsVectorLayer * layer ): QD
{
//todo: make an assignment operator and a copy constructor for QgsSymbol
QString classbreak = ( *it )->lowerValue() + " - " + ( *it )->upperValue();
QgsSymbol* sym = new QgsSymbol( mVectorLayer->type(), ( *it )->lowerValue(), ( *it )->upperValue(), ( *it )->label() );
QgsSymbol* sym = new QgsSymbol( mVectorLayer->geometryType(), ( *it )->lowerValue(), ( *it )->upperValue(), ( *it )->label() );
sym->setPen(( *it )->pen() );
sym->setCustomTexture(( *it )->customTexture() );
sym->setBrush(( *it )->brush() );
Expand Down Expand Up @@ -175,7 +175,7 @@ void QgsGraduatedSymbolDialog::apply()
return;
}

QgsGraduatedSymbolRenderer* renderer = new QgsGraduatedSymbolRenderer( mVectorLayer->type() );
QgsGraduatedSymbolRenderer* renderer = new QgsGraduatedSymbolRenderer( mVectorLayer->geometryType() );

//
// First the mode
Expand Down Expand Up @@ -208,21 +208,21 @@ void QgsGraduatedSymbolDialog::apply()
QString upper_bound = it->second->upperValue();
QString label = it->second->label();

QgsSymbol* sy = new QgsSymbol( mVectorLayer->type(), lower_bound, upper_bound, label );
QgsSymbol* sy = new QgsSymbol( mVectorLayer->geometryType(), lower_bound, upper_bound, label );

sy->setColor( it->second->pen().color() );
sy->setLineStyle( it->second->pen().style() );
sy->setLineWidth( it->second->pen().widthF() );

if ( mVectorLayer->type() == QGis::Point )
if ( mVectorLayer->geometryType() == QGis::Point )
{
sy->setNamedPointSymbol( it->second->pointSymbolName() );
sy->setPointSize( it->second->pointSize() );
sy->setScaleClassificationField( it->second->scaleClassificationField() );
sy->setRotationClassificationField( it->second->rotationClassificationField() );
}

if ( mVectorLayer->type() != QGis::Line )
if ( mVectorLayer->geometryType() != QGis::Line )
{
sy->setFillColor( it->second->brush().color() );
sy->setCustomTexture( it->second->customTexture() );//necessary?
Expand Down Expand Up @@ -270,7 +270,7 @@ void QgsGraduatedSymbolDialog::apply()
void QgsGraduatedSymbolDialog::adjustClassification()
{
mClassListWidget->clear();
QGis::GeometryType m_type = mVectorLayer->type();
QGis::GeometryType m_type = mVectorLayer->geometryType();
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>( mVectorLayer->dataProvider() );
double minimum = 0;
double maximum = 0;
Expand Down Expand Up @@ -586,7 +586,7 @@ QColor QgsGraduatedSymbolDialog::getColorFromRamp( QString ramp, int step, int t
void QgsGraduatedSymbolDialog::updateEntryIcon( QgsSymbol * thepSymbol,
QListWidgetItem * thepItem )
{
QGis::GeometryType myType = mVectorLayer->type();
QGis::GeometryType myType = mVectorLayer->geometryType();
switch ( myType )
{
case QGis::Point:
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmapserverexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void QgsMapserverExport::writeMapFile()
if ( lyr->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr );
switch ( vlayer->geometryType() )
switch ( vlayer->wkbType() )
{
case QGis::WKBPoint:
case QGis::WKBMultiPoint:
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmaptooladdfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
return;
}

QGis::WkbType layerWKBType = vlayer->geometryType();
QGis::WkbType layerWKBType = vlayer->wkbType();

//no support for adding features to 2.5D types yet
if ( layerWKBType == QGis::WKBLineString25D || layerWKBType == QGis::WKBPolygon25D ||
Expand Down Expand Up @@ -86,7 +86,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
if ( mTool == CapturePoint )
{
//check we only use this tool for point/multipoint layers
if ( vlayer->type() != QGis::Point )
if ( vlayer->geometryType() != QGis::Point )
{
QMessageBox::information( 0, QObject::tr( "Wrong editing tool" ),
QObject::tr( "Cannot apply the 'capture point' tool on this vector layer" ) );
Expand Down Expand Up @@ -194,15 +194,15 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
else if ( mTool == CaptureLine || mTool == CapturePolygon )
{
//check we only use the line tool for line/multiline layers
if ( mTool == CaptureLine && vlayer->type() != QGis::Line )
if ( mTool == CaptureLine && vlayer->geometryType() != QGis::Line )
{
QMessageBox::information( 0, QObject::tr( "Wrong editing tool" ),
QObject::tr( "Cannot apply the 'capture line' tool on this vector layer" ) );
return;
}

//check we only use the polygon tool for polygon/multipolygon layers
if ( mTool == CapturePolygon && vlayer->type() != QGis::Polygon )
if ( mTool == CapturePolygon && vlayer->geometryType() != QGis::Polygon )
{
QMessageBox::information( 0, QObject::tr( "Wrong editing tool" ),
QObject::tr( "Cannot apply the 'capture polygon' tool on this vector layer" ) );
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void QgsMapToolIdentify::identifyVectorLayer( const QgsPoint& point )

// Calculate derived attributes and insert:
// measure distance or area depending on geometry type
if ( layer->type() == QGis::Line )
if ( layer->geometryType() == QGis::Line )
{
double dist = calc.measure( f_it->geometry() );
QString str = calc.textUnit( dist, 3, mCanvas->mapUnits(), false );
Expand All @@ -357,13 +357,13 @@ void QgsMapToolIdentify::identifyVectorLayer( const QgsPoint& point )
mResults->addDerivedAttribute( featureNode, "endY", str );
}
}
else if ( layer->type() == QGis::Polygon )
else if ( layer->geometryType() == QGis::Polygon )
{
double area = calc.measure( f_it->geometry() );
QString str = calc.textUnit( area, 3, mCanvas->mapUnits(), true );
mResults->addDerivedAttribute( featureNode, QObject::tr( "Area" ), str );
}
else if ( layer->type() == QGis::Point )
else if ( layer->geometryType() == QGis::Point )
{
// Include the x and y coordinates of the point as a derived attribute
QString str;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
if ( !mDragging )
{
int boxSize = 0;
if ( vlayer->type() != QGis::Polygon )
if ( vlayer->geometryType() != QGis::Polygon )
{
//if point or line use an artificial bounding box of 10x10 pixels
//to aid the user to click on a feature accurately
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgssinglesymboldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
mypItem->setText( "" );
//store the symbol offset in the UserData role for later retrieval
mypItem->setData( Qt::UserRole, *it );
if ( layer->type() != QGis::Point )
if ( layer->geometryType() != QGis::Point )
{
break;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "NoBrush" ) ), tr( "No Brush" ), "NoBrush" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "TexturePattern" ) ), tr( "Texture" ), "TexturePattern" );

if ( mVectorLayer && mVectorLayer->type() != QGis::Point )
if ( mVectorLayer && layer->geometryType() != QGis::Point )
{
mGroupPoint->setVisible( false );
mGroupPoint->setEnabled( false );
Expand All @@ -162,7 +162,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog( QgsVectorLayer * layer, bool disab
else
{
// Take values from an example instance
QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->type() );
QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->geometryType() );
set( exampleRenderer.symbols().first() );
}
}
Expand Down Expand Up @@ -307,10 +307,10 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )

void QgsSingleSymbolDialog::apply()
{
QgsSymbol* sy = new QgsSymbol( mVectorLayer->type() );
QgsSymbol* sy = new QgsSymbol( mVectorLayer->geometryType() );
apply( sy );

QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer( mVectorLayer->type() );
QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer( mVectorLayer->geometryType() );
renderer->addSymbol( sy );
renderer->updateSymbolAttributes();

Expand Down Expand Up @@ -423,7 +423,7 @@ void QgsSingleSymbolDialog::set( const QgsSymbol *sy )
btnOutlineColor->setEnabled( true );
cboOutlineStyle->setEnabled( true );

if ( mVectorLayer && mVectorLayer->type() != QGis::Line )
if ( mVectorLayer && mVectorLayer->geometryType() != QGis::Line )
{
btnFillColor->setEnabled( true );
cboFillStyle->setEnabled( true );
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsuniquevaluedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ QgsUniqueValueDialog::QgsUniqueValueDialog( QgsVectorLayer* vl ): QDialog(), mVe
{
QgsSymbol* symbol = ( *iter );
QString symbolvalue = symbol->lowerValue();
QgsSymbol* sym = new QgsSymbol( mVectorLayer->type(), symbol->lowerValue(), symbol->upperValue(), symbol->label() );
QgsSymbol* sym = new QgsSymbol( mVectorLayer->geometryType(), symbol->lowerValue(), symbol->upperValue(), symbol->label() );
sym->setPen( symbol->pen() );
sym->setCustomTexture( symbol->customTexture() );
sym->setBrush( symbol->brush() );
Expand Down Expand Up @@ -128,13 +128,13 @@ QgsUniqueValueDialog::~QgsUniqueValueDialog()
void QgsUniqueValueDialog::apply()
{
QgsDebugMsg( "called." );
QgsUniqueValueRenderer *renderer = new QgsUniqueValueRenderer( mVectorLayer->type() );
QgsUniqueValueRenderer *renderer = new QgsUniqueValueRenderer( mVectorLayer->geometryType() );

//go through mValues and add the entries to the renderer
for ( QMap<QString, QgsSymbol*>::iterator it = mValues.begin();it != mValues.end();++it )
{
QgsSymbol* symbol = it.value();
QgsSymbol* newsymbol = new QgsSymbol( mVectorLayer->type(), symbol->lowerValue(), symbol->upperValue(), symbol->label() );
QgsSymbol* newsymbol = new QgsSymbol( mVectorLayer->geometryType(), symbol->lowerValue(), symbol->upperValue(), symbol->label() );
newsymbol->setPen( symbol->pen() );
newsymbol->setCustomTexture( symbol->customTexture() );
newsymbol->setBrush( symbol->brush() );
Expand Down Expand Up @@ -179,7 +179,7 @@ void QgsUniqueValueDialog::setSymbolColor( QgsSymbol *symbol, QColor thecolor )
{
QPen pen;
QBrush brush;
if ( mVectorLayer->type() == QGis::Line )
if ( mVectorLayer->geometryType() == QGis::Line )
{
pen.setColor( thecolor );
pen.setStyle( Qt::SolidLine );
Expand Down Expand Up @@ -208,7 +208,7 @@ void QgsUniqueValueDialog::addClass( QString value )
value += QString::number( i );
}

QgsSymbol *symbol = new QgsSymbol( mVectorLayer->type(), value );
QgsSymbol *symbol = new QgsSymbol( mVectorLayer->geometryType(), value );
mValues.insert( value, symbol );

QListWidgetItem *item = new QListWidgetItem( value );
Expand Down Expand Up @@ -434,7 +434,7 @@ void QgsUniqueValueDialog::applySymbologyChanges()
void QgsUniqueValueDialog::updateEntryIcon( QgsSymbol * thepSymbol,
QListWidgetItem * thepItem )
{
QGis::GeometryType myType = mVectorLayer->type();
QGis::GeometryType myType = mVectorLayer->geometryType();
switch ( myType )
{
case QGis::Point:
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,15 @@ QString QgsVectorLayerProperties::getMetadata()

//geom type

QGis::GeometryType type = layer->type();
QGis::GeometryType type = layer->geometryType();

if ( type < 0 || type > QGis::Polygon )
{
QgsDebugMsg( "Invalid vector type" );
}
else
{
QString typeString( QGis::qgisVectorGeometryType[layer->type()] );
QString typeString( QGis::qgisVectorGeometryType[layer->geometryType()] );

myMetadata += "<tr><td>";
myMetadata += tr( "Geometry type of the features in this layer : " ) +
Expand Down
Loading

0 comments on commit a8daacf

Please sign in to comment.