mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
A bit of const-correctness and new convenience methods for edit tools
This commit is contained in:
parent
90ae728294
commit
fd616ae94e
@ -26,7 +26,7 @@ class QgsDatumTransformStore
|
|||||||
* @returns transformation associated with layer, or an invalid QgsCoordinateTransform
|
* @returns transformation associated with layer, or an invalid QgsCoordinateTransform
|
||||||
* if no transform is associated with the layer
|
* if no transform is associated with the layer
|
||||||
*/
|
*/
|
||||||
QgsCoordinateTransform transformation( QgsMapLayer* layer ) const;
|
QgsCoordinateTransform transformation( const QgsMapLayer* layer ) const;
|
||||||
|
|
||||||
void readXml( const QDomNode& parentNode );
|
void readXml( const QDomNode& parentNode );
|
||||||
|
|
||||||
|
@ -177,54 +177,54 @@ class QgsMapSettings
|
|||||||
* @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
|
* @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
|
||||||
* @note added in QGIS 2.12
|
* @note added in QGIS 2.12
|
||||||
*/
|
*/
|
||||||
double layerToMapUnits( QgsMapLayer* layer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;
|
double layerToMapUnits( const QgsMapLayer* layer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform bounding box from layer's CRS to output CRS
|
* @brief transform bounding box from layer's CRS to output CRS
|
||||||
* @see layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) if you want to transform a rectangle
|
* @see layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) if you want to transform a rectangle
|
||||||
* @return a bounding box (aligned rectangle) containing the transformed extent
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
||||||
*/
|
*/
|
||||||
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* layer, QgsRectangle extent ) const;
|
QgsRectangle layerExtentToOutputExtent( const QgsMapLayer* layer, QgsRectangle extent ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform bounding box from output CRS to layer's CRS
|
* @brief transform bounding box from output CRS to layer's CRS
|
||||||
* @see mapToLayerCoordinates( QgsMapLayer* layer,QgsRectangle rect ) if you want to transform a rectangle
|
* @see mapToLayerCoordinates( QgsMapLayer* layer,QgsRectangle rect ) if you want to transform a rectangle
|
||||||
* @return a bounding box (aligned rectangle) containing the transformed extent
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
||||||
*/
|
*/
|
||||||
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* layer, QgsRectangle extent ) const;
|
QgsRectangle outputExtentToLayerExtent( const QgsMapLayer* layer, QgsRectangle extent ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform point coordinates from layer's CRS to output CRS
|
* @brief transform point coordinates from layer's CRS to output CRS
|
||||||
* @return the transformed point
|
* @return the transformed point
|
||||||
*/
|
*/
|
||||||
QgsPoint layerToMapCoordinates( QgsMapLayer* layer, QgsPoint point ) const;
|
QgsPoint layerToMapCoordinates( const QgsMapLayer* layer, QgsPoint point ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform rectangle from layer's CRS to output CRS
|
* @brief transform rectangle from layer's CRS to output CRS
|
||||||
* @see layerExtentToOutputExtent() if you want to transform a bounding box
|
* @see layerExtentToOutputExtent() if you want to transform a bounding box
|
||||||
* @return the transformed rectangle
|
* @return the transformed rectangle
|
||||||
*/
|
*/
|
||||||
QgsRectangle layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const;
|
QgsRectangle layerToMapCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform point coordinates from output CRS to layer's CRS
|
* @brief transform point coordinates from output CRS to layer's CRS
|
||||||
* @return the transformed point
|
* @return the transformed point
|
||||||
*/
|
*/
|
||||||
QgsPoint mapToLayerCoordinates( QgsMapLayer* layer, QgsPoint point ) const;
|
QgsPoint mapToLayerCoordinates( const QgsMapLayer* layer, QgsPoint point ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform rectangle from output CRS to layer's CRS
|
* @brief transform rectangle from output CRS to layer's CRS
|
||||||
* @see outputExtentToLayerExtent() if you want to transform a bounding box
|
* @see outputExtentToLayerExtent() if you want to transform a bounding box
|
||||||
* @return the transformed rectangle
|
* @return the transformed rectangle
|
||||||
*/
|
*/
|
||||||
QgsRectangle mapToLayerCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const;
|
QgsRectangle mapToLayerCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return coordinate transform from layer's CRS to destination CRS
|
* @brief Return coordinate transform from layer's CRS to destination CRS
|
||||||
* @param layer
|
* @param layer
|
||||||
* @return transform - may be invalid if the transform is not needed
|
* @return transform - may be invalid if the transform is not needed
|
||||||
*/
|
*/
|
||||||
QgsCoordinateTransform layerTransform( QgsMapLayer *layer ) const;
|
QgsCoordinateTransform layerTransform( const QgsMapLayer *layer ) const;
|
||||||
|
|
||||||
//! returns current extent of layer set
|
//! returns current extent of layer set
|
||||||
QgsRectangle fullExtent() const;
|
QgsRectangle fullExtent() const;
|
||||||
|
@ -96,6 +96,8 @@ class QgsPointLocator : QObject
|
|||||||
|
|
||||||
//! Only for a valid edge match - obtain endpoints of the edge
|
//! Only for a valid edge match - obtain endpoints of the edge
|
||||||
void edgePoints( QgsPoint& pt1 /Out/, QgsPoint& pt2 /Out/ ) const;
|
void edgePoints( QgsPoint& pt1 /Out/, QgsPoint& pt2 /Out/ ) const;
|
||||||
|
|
||||||
|
bool operator==( const QgsPointLocator::Match& other ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<QgsPointLocator::Match> MatchList;
|
typedef QList<QgsPointLocator::Match> MatchList;
|
||||||
|
@ -144,20 +144,20 @@ class QgsMapTool : QObject
|
|||||||
QgsPoint toMapCoordinates( QPoint point );
|
QgsPoint toMapCoordinates( QPoint point );
|
||||||
|
|
||||||
//! transformation from screen coordinates to layer's coordinates
|
//! transformation from screen coordinates to layer's coordinates
|
||||||
QgsPoint toLayerCoordinates( QgsMapLayer* layer, QPoint point );
|
QgsPoint toLayerCoordinates( const QgsMapLayer* layer, QPoint point );
|
||||||
|
|
||||||
//! transformation from map coordinates to layer's coordinates
|
//! transformation from map coordinates to layer's coordinates
|
||||||
QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point );
|
QgsPoint toLayerCoordinates( const QgsMapLayer* layer, const QgsPoint& point );
|
||||||
|
|
||||||
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
||||||
QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point );
|
QgsPoint toMapCoordinates( const QgsMapLayer* layer, const QgsPoint& point );
|
||||||
|
|
||||||
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
||||||
//! @note available in python bindings as toMapCoordinatesV2
|
//! @note available in python bindings as toMapCoordinatesV2
|
||||||
QgsPointV2 toMapCoordinates( QgsMapLayer* layer, const QgsPointV2 &point ) /PyName=toMapCoordinatesV2/;
|
QgsPointV2 toMapCoordinates( const QgsMapLayer* layer, const QgsPointV2 &point ) /PyName=toMapCoordinatesV2/;
|
||||||
|
|
||||||
//! trnasformation of the rect from map coordinates to layer's coordinates
|
//! trnasformation of the rect from map coordinates to layer's coordinates
|
||||||
QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect );
|
QgsRectangle toLayerCoordinates( const QgsMapLayer* layer, const QgsRectangle& rect );
|
||||||
|
|
||||||
//! transformation from map coordinates to screen coordinates
|
//! transformation from map coordinates to screen coordinates
|
||||||
QPoint toCanvasCoordinates( const QgsPoint& point );
|
QPoint toCanvasCoordinates( const QgsPoint& point );
|
||||||
|
@ -30,6 +30,10 @@ class QgsMapToolEdit: QgsMapTool
|
|||||||
double defaultZValue() const;
|
double defaultZValue() const;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
static QColor digitizingStrokeColor();
|
||||||
|
static int digitizingStrokeWidth();
|
||||||
|
static QColor digitizingFillColor();
|
||||||
|
|
||||||
/** Creates a rubber band with the color/line width from
|
/** Creates a rubber band with the color/line width from
|
||||||
* the QGIS settings. The caller takes ownership of the
|
* the QGIS settings. The caller takes ownership of the
|
||||||
* returned object
|
* returned object
|
||||||
|
@ -50,7 +50,7 @@ bool QgsDatumTransformStore::hasEntryForLayer( QgsMapLayer* layer ) const
|
|||||||
return mEntries.contains( layer->id() );
|
return mEntries.contains( layer->id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsCoordinateTransform QgsDatumTransformStore::transformation( QgsMapLayer* layer ) const
|
QgsCoordinateTransform QgsDatumTransformStore::transformation( const QgsMapLayer* layer ) const
|
||||||
{
|
{
|
||||||
if ( !layer )
|
if ( !layer )
|
||||||
return QgsCoordinateTransform();
|
return QgsCoordinateTransform();
|
||||||
|
@ -48,7 +48,7 @@ class CORE_EXPORT QgsDatumTransformStore
|
|||||||
* @returns transformation associated with layer, or an invalid QgsCoordinateTransform
|
* @returns transformation associated with layer, or an invalid QgsCoordinateTransform
|
||||||
* if no transform is associated with the layer
|
* if no transform is associated with the layer
|
||||||
*/
|
*/
|
||||||
QgsCoordinateTransform transformation( QgsMapLayer* layer ) const;
|
QgsCoordinateTransform transformation( const QgsMapLayer* layer ) const;
|
||||||
|
|
||||||
void readXml( const QDomNode& parentNode );
|
void readXml( const QDomNode& parentNode );
|
||||||
|
|
||||||
|
@ -377,13 +377,13 @@ double QgsMapSettings::scale() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsCoordinateTransform QgsMapSettings::layerTransform( QgsMapLayer *layer ) const
|
QgsCoordinateTransform QgsMapSettings::layerTransform( const QgsMapLayer *layer ) const
|
||||||
{
|
{
|
||||||
return mDatumTransformStore.transformation( layer );
|
return mDatumTransformStore.transformation( layer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double QgsMapSettings::layerToMapUnits( QgsMapLayer *layer, const QgsRectangle& referenceExtent ) const
|
double QgsMapSettings::layerToMapUnits( const QgsMapLayer *layer, const QgsRectangle& referenceExtent ) const
|
||||||
{
|
{
|
||||||
QgsRectangle extent = referenceExtent.isEmpty() ? layer->extent() : referenceExtent;
|
QgsRectangle extent = referenceExtent.isEmpty() ? layer->extent() : referenceExtent;
|
||||||
QgsPoint l1( extent.xMinimum(), extent.yMinimum() );
|
QgsPoint l1( extent.xMinimum(), extent.yMinimum() );
|
||||||
@ -396,7 +396,7 @@ double QgsMapSettings::layerToMapUnits( QgsMapLayer *layer, const QgsRectangle&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsRectangle QgsMapSettings::layerExtentToOutputExtent( QgsMapLayer* layer, QgsRectangle extent ) const
|
QgsRectangle QgsMapSettings::layerExtentToOutputExtent( const QgsMapLayer* layer, QgsRectangle extent ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
@ -423,7 +423,7 @@ QgsRectangle QgsMapSettings::layerExtentToOutputExtent( QgsMapLayer* layer, QgsR
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsRectangle QgsMapSettings::outputExtentToLayerExtent( QgsMapLayer* layer, QgsRectangle extent ) const
|
QgsRectangle QgsMapSettings::outputExtentToLayerExtent( const QgsMapLayer* layer, QgsRectangle extent ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ QgsRectangle QgsMapSettings::outputExtentToLayerExtent( QgsMapLayer* layer, QgsR
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsPoint QgsMapSettings::layerToMapCoordinates( QgsMapLayer* layer, QgsPoint point ) const
|
QgsPoint QgsMapSettings::layerToMapCoordinates( const QgsMapLayer* layer, QgsPoint point ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
@ -473,7 +473,7 @@ QgsPoint QgsMapSettings::layerToMapCoordinates( QgsMapLayer* layer, QgsPoint poi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsRectangle QgsMapSettings::layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const
|
QgsRectangle QgsMapSettings::layerToMapCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
@ -496,7 +496,7 @@ QgsRectangle QgsMapSettings::layerToMapCoordinates( QgsMapLayer* layer, QgsRecta
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsPoint QgsMapSettings::mapToLayerCoordinates( QgsMapLayer* layer, QgsPoint point ) const
|
QgsPoint QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer* layer, QgsPoint point ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
@ -519,7 +519,7 @@ QgsPoint QgsMapSettings::mapToLayerCoordinates( QgsMapLayer* layer, QgsPoint poi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsRectangle QgsMapSettings::mapToLayerCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const
|
QgsRectangle QgsMapSettings::mapToLayerCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const
|
||||||
{
|
{
|
||||||
if ( hasCrsTransformEnabled() )
|
if ( hasCrsTransformEnabled() )
|
||||||
{
|
{
|
||||||
|
@ -228,54 +228,54 @@ class CORE_EXPORT QgsMapSettings
|
|||||||
* @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
|
* @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
|
||||||
* @note added in QGIS 2.12
|
* @note added in QGIS 2.12
|
||||||
*/
|
*/
|
||||||
double layerToMapUnits( QgsMapLayer* layer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;
|
double layerToMapUnits( const QgsMapLayer* layer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform bounding box from layer's CRS to output CRS
|
* @brief transform bounding box from layer's CRS to output CRS
|
||||||
* @see layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) if you want to transform a rectangle
|
* @see layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) if you want to transform a rectangle
|
||||||
* @return a bounding box (aligned rectangle) containing the transformed extent
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
||||||
*/
|
*/
|
||||||
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* layer, QgsRectangle extent ) const;
|
QgsRectangle layerExtentToOutputExtent( const QgsMapLayer* layer, QgsRectangle extent ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform bounding box from output CRS to layer's CRS
|
* @brief transform bounding box from output CRS to layer's CRS
|
||||||
* @see mapToLayerCoordinates( QgsMapLayer* layer,QgsRectangle rect ) if you want to transform a rectangle
|
* @see mapToLayerCoordinates( QgsMapLayer* layer,QgsRectangle rect ) if you want to transform a rectangle
|
||||||
* @return a bounding box (aligned rectangle) containing the transformed extent
|
* @return a bounding box (aligned rectangle) containing the transformed extent
|
||||||
*/
|
*/
|
||||||
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* layer, QgsRectangle extent ) const;
|
QgsRectangle outputExtentToLayerExtent( const QgsMapLayer* layer, QgsRectangle extent ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform point coordinates from layer's CRS to output CRS
|
* @brief transform point coordinates from layer's CRS to output CRS
|
||||||
* @return the transformed point
|
* @return the transformed point
|
||||||
*/
|
*/
|
||||||
QgsPoint layerToMapCoordinates( QgsMapLayer* layer, QgsPoint point ) const;
|
QgsPoint layerToMapCoordinates( const QgsMapLayer* layer, QgsPoint point ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform rectangle from layer's CRS to output CRS
|
* @brief transform rectangle from layer's CRS to output CRS
|
||||||
* @see layerExtentToOutputExtent() if you want to transform a bounding box
|
* @see layerExtentToOutputExtent() if you want to transform a bounding box
|
||||||
* @return the transformed rectangle
|
* @return the transformed rectangle
|
||||||
*/
|
*/
|
||||||
QgsRectangle layerToMapCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const;
|
QgsRectangle layerToMapCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform point coordinates from output CRS to layer's CRS
|
* @brief transform point coordinates from output CRS to layer's CRS
|
||||||
* @return the transformed point
|
* @return the transformed point
|
||||||
*/
|
*/
|
||||||
QgsPoint mapToLayerCoordinates( QgsMapLayer* layer, QgsPoint point ) const;
|
QgsPoint mapToLayerCoordinates( const QgsMapLayer* layer, QgsPoint point ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief transform rectangle from output CRS to layer's CRS
|
* @brief transform rectangle from output CRS to layer's CRS
|
||||||
* @see outputExtentToLayerExtent() if you want to transform a bounding box
|
* @see outputExtentToLayerExtent() if you want to transform a bounding box
|
||||||
* @return the transformed rectangle
|
* @return the transformed rectangle
|
||||||
*/
|
*/
|
||||||
QgsRectangle mapToLayerCoordinates( QgsMapLayer* layer, QgsRectangle rect ) const;
|
QgsRectangle mapToLayerCoordinates( const QgsMapLayer* layer, QgsRectangle rect ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return coordinate transform from layer's CRS to destination CRS
|
* @brief Return coordinate transform from layer's CRS to destination CRS
|
||||||
* @param layer
|
* @param layer
|
||||||
* @return transform - may be invalid if the transform is not needed
|
* @return transform - may be invalid if the transform is not needed
|
||||||
*/
|
*/
|
||||||
QgsCoordinateTransform layerTransform( QgsMapLayer *layer ) const;
|
QgsCoordinateTransform layerTransform( const QgsMapLayer *layer ) const;
|
||||||
|
|
||||||
//! returns current extent of layer set
|
//! returns current extent of layer set
|
||||||
QgsRectangle fullExtent() const;
|
QgsRectangle fullExtent() const;
|
||||||
|
@ -160,6 +160,17 @@ class CORE_EXPORT QgsPointLocator : public QObject
|
|||||||
pt2 = mEdgePoints[1];
|
pt2 = mEdgePoints[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==( const Match& other ) const
|
||||||
|
{
|
||||||
|
return mType == other.mType &&
|
||||||
|
mDist == other.mDist &&
|
||||||
|
mPoint == other.mPoint &&
|
||||||
|
mLayer == other.mLayer &&
|
||||||
|
mFid == other.mFid &&
|
||||||
|
mVertexIndex == other.mVertexIndex &&
|
||||||
|
mEdgePoints == other.mEdgePoints;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Type mType;
|
Type mType;
|
||||||
double mDist;
|
double mDist;
|
||||||
|
@ -43,30 +43,30 @@ QgsPoint QgsMapTool::toMapCoordinates( QPoint point )
|
|||||||
return mCanvas->getCoordinateTransform()->toMapCoordinates( point );
|
return mCanvas->getCoordinateTransform()->toMapCoordinates( point );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPointV2 QgsMapTool::toMapCoordinates( QgsMapLayer* layer, const QgsPointV2& point )
|
QgsPointV2 QgsMapTool::toMapCoordinates( const QgsMapLayer* layer, const QgsPointV2& point )
|
||||||
{
|
{
|
||||||
QgsPoint result = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPoint( point.x(), point.y() ) );
|
QgsPoint result = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPoint( point.x(), point.y() ) );
|
||||||
return QgsPointV2( result.x(), result.y() );
|
return QgsPointV2( result.x(), result.y() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsPoint QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, QPoint point )
|
QgsPoint QgsMapTool::toLayerCoordinates( const QgsMapLayer* layer, QPoint point )
|
||||||
{
|
{
|
||||||
QgsPoint pt = toMapCoordinates( point );
|
QgsPoint pt = toMapCoordinates( point );
|
||||||
return toLayerCoordinates( layer, pt );
|
return toLayerCoordinates( layer, pt );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPoint QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point )
|
QgsPoint QgsMapTool::toLayerCoordinates( const QgsMapLayer* layer, const QgsPoint& point )
|
||||||
{
|
{
|
||||||
return mCanvas->mapSettings().mapToLayerCoordinates( layer, point );
|
return mCanvas->mapSettings().mapToLayerCoordinates( layer, point );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsPoint QgsMapTool::toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point )
|
QgsPoint QgsMapTool::toMapCoordinates( const QgsMapLayer* layer, const QgsPoint& point )
|
||||||
{
|
{
|
||||||
return mCanvas->mapSettings().layerToMapCoordinates( layer, point );
|
return mCanvas->mapSettings().layerToMapCoordinates( layer, point );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsRectangle QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect )
|
QgsRectangle QgsMapTool::toLayerCoordinates( const QgsMapLayer* layer, const QgsRectangle& rect )
|
||||||
{
|
{
|
||||||
return mCanvas->mapSettings().mapToLayerCoordinates( layer, rect );
|
return mCanvas->mapSettings().mapToLayerCoordinates( layer, rect );
|
||||||
}
|
}
|
||||||
|
@ -170,20 +170,20 @@ class GUI_EXPORT QgsMapTool : public QObject
|
|||||||
QgsPoint toMapCoordinates( QPoint point );
|
QgsPoint toMapCoordinates( QPoint point );
|
||||||
|
|
||||||
//! transformation from screen coordinates to layer's coordinates
|
//! transformation from screen coordinates to layer's coordinates
|
||||||
QgsPoint toLayerCoordinates( QgsMapLayer* layer, QPoint point );
|
QgsPoint toLayerCoordinates( const QgsMapLayer* layer, QPoint point );
|
||||||
|
|
||||||
//! transformation from map coordinates to layer's coordinates
|
//! transformation from map coordinates to layer's coordinates
|
||||||
QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point );
|
QgsPoint toLayerCoordinates( const QgsMapLayer* layer, const QgsPoint& point );
|
||||||
|
|
||||||
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
||||||
QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point );
|
QgsPoint toMapCoordinates( const QgsMapLayer* layer, const QgsPoint& point );
|
||||||
|
|
||||||
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
//!transformation from layer's coordinates to map coordinates (which is different in case reprojection is used)
|
||||||
//! @note available in python bindings as toMapCoordinatesV2
|
//! @note available in python bindings as toMapCoordinatesV2
|
||||||
QgsPointV2 toMapCoordinates( QgsMapLayer* layer, const QgsPointV2 &point );
|
QgsPointV2 toMapCoordinates( const QgsMapLayer* layer, const QgsPointV2 &point );
|
||||||
|
|
||||||
//! trnasformation of the rect from map coordinates to layer's coordinates
|
//! trnasformation of the rect from map coordinates to layer's coordinates
|
||||||
QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect );
|
QgsRectangle toLayerCoordinates( const QgsMapLayer* layer, const QgsRectangle& rect );
|
||||||
|
|
||||||
//! transformation from map coordinates to screen coordinates
|
//! transformation from map coordinates to screen coordinates
|
||||||
QPoint toCanvasCoordinates( const QgsPoint& point );
|
QPoint toCanvasCoordinates( const QgsPoint& point );
|
||||||
|
@ -34,34 +34,52 @@ double QgsMapToolEdit::defaultZValue() const
|
|||||||
return QSettings().value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble();
|
return QSettings().value( QStringLiteral( "/qgis/digitizing/default_z_value" ), Qgis::DEFAULT_Z_COORDINATE ).toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsRubberBand* QgsMapToolEdit::createRubberBand( QgsWkbTypes::GeometryType geometryType, bool alternativeBand )
|
QColor QgsMapToolEdit::digitizingStrokeColor()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QgsRubberBand* rb = new QgsRubberBand( mCanvas, geometryType );
|
|
||||||
rb->setWidth( settings.value( QStringLiteral( "/qgis/digitizing/line_width" ), 1 ).toInt() );
|
|
||||||
QColor color(
|
QColor color(
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/line_color_red" ), 255 ).toInt(),
|
settings.value( QStringLiteral( "/qgis/digitizing/line_color_red" ), 255 ).toInt(),
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/line_color_green" ), 0 ).toInt(),
|
settings.value( QStringLiteral( "/qgis/digitizing/line_color_green" ), 0 ).toInt(),
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/line_color_blue" ), 0 ).toInt() );
|
settings.value( QStringLiteral( "/qgis/digitizing/line_color_blue" ), 0 ).toInt() );
|
||||||
double myAlpha = settings.value( QStringLiteral( "/qgis/digitizing/line_color_alpha" ), 200 ).toInt() / 255.0;
|
double myAlpha = settings.value( QStringLiteral( "/qgis/digitizing/line_color_alpha" ), 200 ).toInt() / 255.0;
|
||||||
if ( alternativeBand )
|
|
||||||
{
|
|
||||||
myAlpha = myAlpha * settings.value( QStringLiteral( "/qgis/digitizing/line_color_alpha_scale" ), 0.75 ).toDouble();
|
|
||||||
rb->setLineStyle( Qt::DotLine );
|
|
||||||
}
|
|
||||||
if ( geometryType == QgsWkbTypes::PolygonGeometry )
|
|
||||||
{
|
|
||||||
color.setAlphaF( myAlpha );
|
|
||||||
}
|
|
||||||
color.setAlphaF( myAlpha );
|
color.setAlphaF( myAlpha );
|
||||||
rb->setColor( color );
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QgsMapToolEdit::digitizingStrokeWidth()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
return settings.value( QStringLiteral( "/qgis/digitizing/line_width" ), 1 ).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor QgsMapToolEdit::digitizingFillColor()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
QColor fillColor(
|
QColor fillColor(
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_red" ), 255 ).toInt(),
|
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_red" ), 255 ).toInt(),
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_green" ), 0 ).toInt(),
|
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_green" ), 0 ).toInt(),
|
||||||
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_blue" ), 0 ).toInt() );
|
settings.value( QStringLiteral( "/qgis/digitizing/fill_color_blue" ), 0 ).toInt() );
|
||||||
myAlpha = settings.value( QStringLiteral( "/qgis/digitizing/fill_color_alpha" ), 30 ).toInt() / 255.0 ;
|
double myAlpha = settings.value( QStringLiteral( "/qgis/digitizing/fill_color_alpha" ), 30 ).toInt() / 255.0 ;
|
||||||
fillColor.setAlphaF( myAlpha );
|
fillColor.setAlphaF( myAlpha );
|
||||||
|
return fillColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QgsRubberBand* QgsMapToolEdit::createRubberBand( QgsWkbTypes::GeometryType geometryType, bool alternativeBand )
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
QgsRubberBand* rb = new QgsRubberBand( mCanvas, geometryType );
|
||||||
|
rb->setWidth( digitizingStrokeWidth() );
|
||||||
|
QColor color = digitizingStrokeColor();
|
||||||
|
if ( alternativeBand )
|
||||||
|
{
|
||||||
|
double alphaScale = settings.value( QStringLiteral( "/qgis/digitizing/line_color_alpha_scale" ), 0.75 ).toDouble();
|
||||||
|
color.setAlphaF( color.alphaF() * alphaScale );
|
||||||
|
rb->setLineStyle( Qt::DotLine );
|
||||||
|
}
|
||||||
|
rb->setStrokeColor( color );
|
||||||
|
|
||||||
|
QColor fillColor = digitizingFillColor();
|
||||||
rb->setFillColor( fillColor );
|
rb->setFillColor( fillColor );
|
||||||
|
|
||||||
rb->show();
|
rb->show();
|
||||||
|
@ -45,6 +45,13 @@ class GUI_EXPORT QgsMapToolEdit: public QgsMapTool
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
//! Returns stroke color for rubber bands (from global settings)
|
||||||
|
static QColor digitizingStrokeColor();
|
||||||
|
//! Returns stroke width for rubber bands (from global settings)
|
||||||
|
static int digitizingStrokeWidth();
|
||||||
|
//! Returns fill color for rubber bands (from global settings)
|
||||||
|
static QColor digitizingFillColor();
|
||||||
|
|
||||||
/** Creates a rubber band with the color/line width from
|
/** Creates a rubber band with the color/line width from
|
||||||
* the QGIS settings. The caller takes ownership of the
|
* the QGIS settings. The caller takes ownership of the
|
||||||
* returned object
|
* returned object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user