[Marble-commits] KDE/kdeedu/marble/src
Thibaut Gridel
tgridel at free.fr
Sat Jul 17 11:00:09 CEST 2010
SVN commit 1150961 by tgridel:
GeoDataGeometry: get rid of geometryId for type determination
M +1 -1 lib/MarblePlacemarkModel.cpp
M +6 -6 lib/PlacemarkLayout.cpp
M +1 -1 lib/geodata/data/GeoDataGeometry.h
M +4 -8 lib/geodata/data/GeoDataPlacemark.cpp
M +1 -2 lib/geodata/handlers/kml/KmlAltitudeModeTagHandler.cpp
M +0 -3 lib/routing/RoutingModel.cpp
M +4 -4 plugins/render/geodata/GeoRendererView.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarblePlacemarkModel.cpp #1150960:1150961
@@ -111,7 +111,7 @@
} else if ( role == StyleRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style() );
} else if ( role == GeometryRole ) {
- return qVariantFromValue( *d->m_placemarkContainer->at( index.row() )->geometry() );
+ return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->geometry() );
/* } else if ( role == ObjectPointerRole ) {
return qVariantFromValue( dynamic_cast<GeoDataObject*>( d->m_placemarkContainer->at( index.row() ) ) );*/
} else
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.cpp #1150960:1150961
@@ -251,9 +251,9 @@
for ( int i = 0; i < selectedIndexes.count(); ++i ) {
const QModelIndex index = selectedIndexes.at( i );
- GeoDataGeometry geometry
- = qvariant_cast<GeoDataGeometry>( index.data( MarblePlacemarkModel::GeometryRole ) );
- if( geometry.geometryId() != GeoDataPointId ) {
+ GeoDataGeometry *geometry
+ = qvariant_cast<GeoDataGeometry*>( index.data( MarblePlacemarkModel::GeometryRole ) );
+ if( !dynamic_cast<GeoDataPoint*>(geometry) ) {
continue;
}
@@ -346,9 +346,9 @@
continue;
}
- GeoDataGeometry geometry
- = qvariant_cast<GeoDataGeometry>( index.data( MarblePlacemarkModel::GeometryRole ) );
- if( geometry.geometryId() != GeoDataPointId ) {
+ GeoDataGeometry *geometry
+ = qvariant_cast<GeoDataGeometry*>( index.data( MarblePlacemarkModel::GeometryRole ) );
+ if( !dynamic_cast<GeoDataPoint*>(geometry) ) {
continue;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataGeometry.h #1150960:1150961
@@ -84,6 +84,6 @@
}
-Q_DECLARE_METATYPE( Marble::GeoDataGeometry )
+Q_DECLARE_METATYPE( Marble::GeoDataGeometry* )
#endif
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.cpp #1150960:1150961
@@ -68,11 +68,9 @@
GeoDataCoordinates GeoDataPlacemark::coordinate() const
{
- if( p()->m_geometry &&
- ( p()->m_geometry->geometryId() == GeoDataLineStringId ||
- p()->m_geometry->geometryId() == GeoDataLinearRingId ) ) {
+ if( dynamic_cast<GeoDataLineString*>( p()->m_geometry ) ) {
return GeoDataLatLonAltBox::fromLineString( *p()->m_geometry ).center();
- } else if( p()->m_geometry && p()->m_geometry->geometryId() == GeoDataPolygonId ) {
+ } else if( dynamic_cast<GeoDataPolygon*>( p()->m_geometry ) ) {
return GeoDataLatLonAltBox::fromLineString( static_cast<GeoDataPolygon*>(p()->m_geometry)->outerBoundary() ).center();
} else {
return static_cast<GeoDataCoordinates>( p()->m_coordinate );
@@ -81,13 +79,11 @@
void GeoDataPlacemark::coordinate( qreal& lon, qreal& lat, qreal& alt ) const
{
- if( p()->m_geometry &&
- ( p()->m_geometry->geometryId() == GeoDataLineStringId ||
- p()->m_geometry->geometryId() == GeoDataLinearRingId ) ) {
+ if( dynamic_cast<GeoDataLineString*>( p()->m_geometry ) ) {
const GeoDataCoordinates coord = GeoDataLatLonAltBox::fromLineString( *p()->m_geometry ).center();
coord.geoCoordinates( lon, lat );
alt = coord.altitude();
- } else if( p()->m_geometry && p()->m_geometry->geometryId() == GeoDataPolygonId ) {
+ } else if( dynamic_cast<GeoDataPolygon*>( p()->m_geometry ) ) {
const GeoDataCoordinates coord = GeoDataLatLonAltBox::fromLineString( static_cast<GeoDataPolygon*>(p()->m_geometry)->outerBoundary() ).center();
coord.geoCoordinates( lon, lat );
alt = coord.altitude();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlAltitudeModeTagHandler.cpp #1150960:1150961
@@ -62,8 +62,7 @@
{
parentItem.nodeAs<GeoDataPlacemark>()->geometry()->setAltitudeMode( mode );
}
- else if ( parentItem.is<GeoDataGeometry>()
- && parentItem.nodeAs<GeoDataPoint>()->geometryId() == GeoDataPointId )
+ else if ( parentItem.is<GeoDataPoint>() )
{
parentItem.nodeAs<GeoDataPoint>()->setAltitudeMode( mode );
}
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingModel.cpp #1150960:1150961
@@ -278,9 +278,7 @@
foreach( const GeoDataFolder *folder, folders ) {
foreach( const GeoDataPlacemark *placemark, folder->placemarkList() ) {
GeoDataGeometry* geometry = placemark->geometry();
- if ( geometry->geometryId() == GeoDataLineStringId ) {
GeoDataLineString* lineString = dynamic_cast<GeoDataLineString*>( geometry );
- Q_ASSERT( lineString && "Internal error: geometry ID does not match class type" );
if ( lineString ) {
for ( int i=0; i<lineString->size(); ++i ) {
RouteElement element;
@@ -291,7 +289,6 @@
}
}
}
- }
reset();
return true;
--- trunk/KDE/kdeedu/marble/src/plugins/render/geodata/GeoRendererView.cpp #1150960:1150961
@@ -125,7 +125,7 @@
GeoDataObject* object = static_cast<GeoDataObject*>( childIndex.internalPointer() );
if( dynamic_cast<GeoDataGeometry*>( object ) ) {
- if( static_cast<GeoDataGeometry*>( object )->geometryId() != GeoDataMultiGeometryId ) {
+ if( !dynamic_cast<GeoDataMultiGeometry*>( object ) ) {
renderGeoDataGeometry( static_cast<GeoDataGeometry*>( object ), m_styleUrl );
} else {
if( childIndex.isValid() && model()->rowCount( childIndex ) > 0 ) {
@@ -229,20 +229,20 @@
mapped.remove( '#' );
- if( object->geometryId() == GeoDataPolygonId ) {
+ if( dynamic_cast<GeoDataPolygon*>( object ) ) {
setBrushStyle( mapped );
setPenStyle( mapped );
// geometries are implicitly shared, this shouldn't hurt
GeoDataPolygon polygon( *object );
m_painter->drawPolygon( polygon );
}
- if( object->geometryId() == GeoDataLinearRingId ) {
+ if( dynamic_cast<GeoDataLinearRing*>( object ) ) {
m_painter->setBrush( QColor( 0, 0, 0, 0 ) );
setPenStyle( mapped );
GeoDataLinearRing linearRing( *object );
m_painter->drawPolygon( linearRing );
}
- if( object->geometryId() == GeoDataLineStringId ) {
+ if( dynamic_cast<GeoDataLineString*>( object ) ) {
setPenStyle( mapped );
GeoDataLineString lineString( *object );
m_painter->drawPolyline( lineString );
More information about the Marble-commits
mailing list