[QGIS Commit] r9623 - in trunk/qgis: python/gui src/app src/gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Nov 11 09:47:49 EST 2008
Author: mhugent
Date: 2008-11-11 09:47:48 -0500 (Tue, 11 Nov 2008)
New Revision: 9623
Modified:
trunk/qgis/python/gui/qgsrubberband.sip
trunk/qgis/src/app/qgsmaptoolidentify.cpp
trunk/qgis/src/app/qgsmaptoolmovefeature.cpp
trunk/qgis/src/gui/qgsrubberband.cpp
trunk/qgis/src/gui/qgsrubberband.h
Log:
Allow a 0 pointer for the vector layer in QgsRubberBand::setToGeometry
Modified: trunk/qgis/python/gui/qgsrubberband.sip
===================================================================
--- trunk/qgis/python/gui/qgsrubberband.sip 2008-11-11 14:33:01 UTC (rev 9622)
+++ trunk/qgis/python/gui/qgsrubberband.sip 2008-11-11 14:47:48 UTC (rev 9623)
@@ -29,9 +29,10 @@
/**Sets this rubber band to the geometry of an existing feature.
This is usefull for feature highlighting.
@param geom the geometry object
- @param layer the layer containing the feature (used for coord transformation)
+ @param layer the layer containing the feature, used for coord transformation to map
+ crs. In case of 0 pointer, the coordinates are not going to be transformed.
@param render the maprender object (used for coord transformation)*/
- void setToGeometry(QgsGeometry* geom, QgsVectorLayer& layer);
+ void setToGeometry(QgsGeometry* geom, QgsVectorLayer* layer);
/**Adds translation to original coordinates (all in map coordinates)*/
void setTranslationOffset(double dx, double dy);
Modified: trunk/qgis/src/app/qgsmaptoolidentify.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolidentify.cpp 2008-11-11 14:33:01 UTC (rev 9622)
+++ trunk/qgis/src/app/qgsmaptoolidentify.cpp 2008-11-11 14:47:48 UTC (rev 9623)
@@ -465,7 +465,7 @@
if ( mRubberBand )
{
- mRubberBand->setToGeometry( feat.geometry(), *layer );
+ mRubberBand->setToGeometry( feat.geometry(), layer );
mRubberBand->setWidth( 2 );
mRubberBand->setColor( Qt::red );
mRubberBand->show();
Modified: trunk/qgis/src/app/qgsmaptoolmovefeature.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolmovefeature.cpp 2008-11-11 14:33:01 UTC (rev 9622)
+++ trunk/qgis/src/app/qgsmaptoolmovefeature.cpp 2008-11-11 14:47:48 UTC (rev 9623)
@@ -109,7 +109,7 @@
mStartPointMapCoords = toMapCoordinates( e->pos() );
mMovedFeature = cf.id(); //todo: take the closest feature, not the first one...
mRubberBand = createRubberBand();
- mRubberBand->setToGeometry( cf.geometry(), *vlayer );
+ mRubberBand->setToGeometry( cf.geometry(), vlayer );
mRubberBand->setColor( Qt::red );
mRubberBand->setWidth( 2 );
mRubberBand->show();
Modified: trunk/qgis/src/gui/qgsrubberband.cpp
===================================================================
--- trunk/qgis/src/gui/qgsrubberband.cpp 2008-11-11 14:33:01 UTC (rev 9622)
+++ trunk/qgis/src/gui/qgsrubberband.cpp 2008-11-11 14:47:48 UTC (rev 9623)
@@ -153,7 +153,7 @@
update();
}
-void QgsRubberBand::setToGeometry( QgsGeometry* geom, QgsVectorLayer& layer )
+void QgsRubberBand::setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
{
if ( !geom )
{
@@ -177,7 +177,15 @@
{
mIsPolygon = true;
double d = mMapCanvas->extent().width() * 0.005;
- QgsPoint pt = mr->layerToMapCoordinates( &layer, geom->asPoint() );
+ QgsPoint pt;
+ if(layer)
+ {
+ pt = mr->layerToMapCoordinates( layer, geom->asPoint() );
+ }
+ else
+ {
+ pt = geom->asPoint();
+ }
addPoint( QgsPoint( pt.x() - d, pt.y() - d ) );
addPoint( QgsPoint( pt.x() + d, pt.y() - d ) );
addPoint( QgsPoint( pt.x() + d, pt.y() + d ) );
@@ -194,10 +202,20 @@
for ( int i = 0; i < mpt.size(); ++i )
{
QgsPoint pt = mpt[i];
- addPoint( mr->layerToMapCoordinates( &layer, QgsPoint( pt.x() - d, pt.y() - d ) ) );
- addPoint( mr->layerToMapCoordinates( &layer, QgsPoint( pt.x() + d, pt.y() - d ) ) );
- addPoint( mr->layerToMapCoordinates( &layer, QgsPoint( pt.x() + d, pt.y() + d ) ) );
- addPoint( mr->layerToMapCoordinates( &layer, QgsPoint( pt.x() - d, pt.y() + d ) ) );
+ if(layer)
+ {
+ addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() - d, pt.y() - d ) ) );
+ addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() + d, pt.y() - d ) ) );
+ addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() + d, pt.y() + d ) ) );
+ addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() - d, pt.y() + d ) ) );
+ }
+ else
+ {
+ addPoint(QgsPoint( pt.x() - d, pt.y() - d ) );
+ addPoint(QgsPoint( pt.x() + d, pt.y() - d ) );
+ addPoint(QgsPoint( pt.x() + d, pt.y() + d ) );
+ addPoint(QgsPoint( pt.x() - d, pt.y() + d ) );
+ }
}
}
break;
@@ -209,7 +227,14 @@
QgsPolyline line = geom->asPolyline();
for ( int i = 0; i < line.count(); i++ )
{
- addPoint( mr->layerToMapCoordinates( &layer, line[i] ) );
+ if(layer)
+ {
+ addPoint( mr->layerToMapCoordinates( layer, line[i] ) );
+ }
+ else
+ {
+ addPoint(line[i]);
+ }
}
}
break;
@@ -228,7 +253,14 @@
QgsPolyline line = mline[i];
for ( int j = 0; j < line.size(); ++j )
{
- addPoint( mr->layerToMapCoordinates( &layer, line[j] ), false, i );
+ if(layer)
+ {
+ addPoint( mr->layerToMapCoordinates( layer, line[j] ), false, i );
+ }
+ else
+ {
+ addPoint(line[j]);
+ }
}
}
}
@@ -242,7 +274,14 @@
QgsPolyline line = poly[0];
for ( int i = 0; i < line.count(); i++ )
{
- addPoint( mr->layerToMapCoordinates( &layer, line[i] ) );
+ if(layer)
+ {
+ addPoint( mr->layerToMapCoordinates( layer, line[i] ) );
+ }
+ else
+ {
+ addPoint(line[i]);
+ }
}
}
break;
@@ -262,7 +301,14 @@
QgsPolyline line = poly[0];
for ( int j = 0; j < line.count(); ++j )
{
- addPoint( mr->layerToMapCoordinates( &layer, line[j] ), false, i );
+ if(layer)
+ {
+ addPoint( mr->layerToMapCoordinates( layer, line[j] ), false, i );
+ }
+ else
+ {
+ addPoint(line[j]);
+ }
}
}
}
Modified: trunk/qgis/src/gui/qgsrubberband.h
===================================================================
--- trunk/qgis/src/gui/qgsrubberband.h 2008-11-11 14:33:01 UTC (rev 9622)
+++ trunk/qgis/src/gui/qgsrubberband.h 2008-11-11 14:47:48 UTC (rev 9623)
@@ -56,9 +56,10 @@
/**Sets this rubber band to the geometry of an existing feature.
This is usefull for feature highlighting.
@param geom the geometry object
- @param layer the layer containing the feature (used for coord transformation)
+ @param layer the layer containing the feature, used for coord transformation to map
+ crs. In case of 0 pointer, the coordinates are not going to be transformed.
@param render the maprender object (used for coord transformation)*/
- void setToGeometry( QgsGeometry* geom, QgsVectorLayer& layer );
+ void setToGeometry( QgsGeometry* geom, QgsVectorLayer* layer );
/**Adds translation to original coordinates (all in map coordinates)*/
void setTranslationOffset( double dx, double dy );
More information about the QGIS-commit
mailing list