Skip to content
Permalink
Browse files

Fixes #18252 - Shape digitize (and circular string) tools do not show

rubberband fill color when drawing polygons
  • Loading branch information
lbartoletti authored and nyalldawson committed Sep 25, 2018
1 parent e8c98f8 commit c0ff2f48f13b918db8b8cef27d889d753868f80a
@@ -110,4 +110,8 @@ void QgsMapToolAddCircle::clean()
}

mCircle = QgsCircle();

QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
if ( vLayer )
layerType = vLayer->geometryType();
}
@@ -56,6 +56,8 @@ class APP_EXPORT QgsMapToolAddCircle: public QgsMapToolCapture
QgsGeometryRubberBand *mTempRubberBand = nullptr;
//! Circle
QgsCircle mCircle;
//! Layertype which will be used for rubberband
QgsWkbTypes::GeometryType layerType = QgsWkbTypes::LineGeometry;

};

@@ -106,6 +106,10 @@ void QgsMapToolAddCircularString::deactivate()

void QgsMapToolAddCircularString::activate()
{

QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
if ( vLayer )
layerType = vLayer->geometryType();
if ( mParentTool )
{
mParentTool->deleteTempRubberBand();
@@ -124,7 +128,7 @@ void QgsMapToolAddCircularString::activate()
mPoints.append( QgsPoint( mapPoint ) );
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
QgsCircularString *c = new QgsCircularString();
@@ -59,6 +59,8 @@ class APP_EXPORT QgsMapToolAddCircularString: public QgsMapToolCapture
void createCenterPointRubberBand();
void updateCenterPointRubberBand( const QgsPoint &pt );
void removeCenterPointRubberBand();
//! Layertype which will be used for rubberband
QgsWkbTypes::GeometryType layerType = QgsWkbTypes::LineGeometry;
};

#endif // QGSMAPTOOLADDCIRCULARSTRING_H
@@ -110,4 +110,8 @@ void QgsMapToolAddEllipse::clean()
}

mEllipse = QgsEllipse();

QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
if ( vLayer )
layerType = vLayer->geometryType();
}
@@ -54,6 +54,8 @@ class APP_EXPORT QgsMapToolAddEllipse: public QgsMapToolCapture
QgsEllipse mEllipse;
//! convenient method to return the number of segments
unsigned int segments( ) { return QgsSettings().value( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), 8 ).toInt() * 12; }
//! Layertype which will be used for rubberband
QgsWkbTypes::GeometryType layerType = QgsWkbTypes::LineGeometry;

};

@@ -183,4 +183,8 @@ void QgsMapToolAddRectangle::clean()
}

mRectangle = QgsBox3d();

QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
if ( vLayer )
layerType = vLayer->geometryType();
}
@@ -77,6 +77,9 @@ class APP_EXPORT QgsMapToolAddRectangle: public QgsMapToolCapture
//! Returns the side. \see mSide
int side( ) const { return mSide; }

//! Layertype which will be used for rubberband
QgsWkbTypes::GeometryType layerType = QgsWkbTypes::LineGeometry;

private:
//! Convenient member for the azimuth of the rotated rectangle or when map is rotated.
double mAzimuth = 0.0;
@@ -134,4 +134,9 @@ void QgsMapToolAddRegularPolygon::clean()
}

mRegularPolygon = QgsRegularPolygon();


QgsVectorLayer *vLayer = static_cast<QgsVectorLayer *>( QgisApp::instance()->activeLayer() );
if ( vLayer )
layerType = vLayer->geometryType();
}
@@ -62,6 +62,9 @@ class APP_EXPORT QgsMapToolAddRegularPolygon: public QgsMapToolCapture
//! Regular shape as a regular polygon
QgsRegularPolygon mRegularPolygon;

//! Layertype which will be used for rubberband
QgsWkbTypes::GeometryType layerType = QgsWkbTypes::LineGeometry;

};

#endif // QGSMAPTOOLADDREGULARPOLYGON_H
@@ -36,7 +36,7 @@ void QgsMapToolCircle2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -108,10 +108,7 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent *e )
{
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand->setFillColor( QColor( 0, 0, 255 ) );
mTempRubberBand->setStrokeColor( QColor( 0, 0, 255 ) );
mTempRubberBand->setStrokeWidth( 2 );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
else
@@ -37,7 +37,7 @@ void QgsMapToolCircle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mPoints.append( point );
if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -79,10 +79,7 @@ void QgsMapToolCircle3Tangents::cadCanvasMoveEvent( QgsMapMouseEvent *e )

if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand->setFillColor( QColor( 0, 0, 255 ) );
mTempRubberBand->setStrokeColor( QColor( 0, 0, 255 ) );
mTempRubberBand->setStrokeWidth( 2 );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
else
@@ -37,7 +37,7 @@ void QgsMapToolCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}

@@ -43,7 +43,7 @@ void QgsMapToolCircularStringCurvePoint::cadCanvasReleaseEvent( QgsMapMouseEvent
{
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}

@@ -57,7 +57,7 @@ void QgsMapToolCircularStringCurvePoint::cadCanvasReleaseEvent( QgsMapMouseEvent
{
if ( !mRubberBand )
{
mRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry );
mRubberBand = createGeometryRubberBand( layerType );
mRubberBand->show();
}

@@ -110,7 +110,7 @@ void QgsMapToolCircularStringRadius::recalculateRubberBand()
int rubberBandSize = mPoints.size() - ( mPoints.size() + 1 ) % 2;
cString->setPoints( mPoints.mid( 0, rubberBandSize ) );
delete mRubberBand;
mRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry );
mRubberBand = createGeometryRubberBand( layerType );
mRubberBand->setGeometry( cString );
mRubberBand->show();
}
@@ -141,7 +141,7 @@ void QgsMapToolCircularStringRadius::recalculateTempRubberBand( const QgsPointXY
QgsCircularString *cString = new QgsCircularString();
cString->setPoints( rubberBandPoints );
delete mTempRubberBand;
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->setGeometry( cString );
mTempRubberBand->show();
}
@@ -40,7 +40,7 @@ void QgsMapToolEllipseCenter2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -36,7 +36,7 @@ void QgsMapToolEllipseCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -38,7 +38,7 @@ void QgsMapToolEllipseExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -38,7 +38,7 @@ void QgsMapToolEllipseFoci::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -40,7 +40,7 @@ void QgsMapToolRectangle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -39,7 +39,7 @@ void QgsMapToolRectangleCenter::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -39,7 +39,7 @@ void QgsMapToolRectangleExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

if ( !mPoints.isEmpty() && !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();
}
}
@@ -46,7 +46,7 @@ void QgsMapToolRegularPolygon2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
{
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();

createNumberSidesSpinBox();
@@ -30,6 +30,7 @@ class APP_EXPORT QgsMapToolRegularPolygon2Points: public QgsMapToolAddRegularPol

void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;

};

#endif // QGSMAPTOOLREGULARPOLYGON2POINTS_H
@@ -43,7 +43,7 @@ void QgsMapToolRegularPolygonCenterCorner::cadCanvasReleaseEvent( QgsMapMouseEve
{
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();

createNumberSidesSpinBox();
@@ -43,7 +43,7 @@ void QgsMapToolRegularPolygonCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEven
{
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );
mTempRubberBand = createGeometryRubberBand( layerType, true );
mTempRubberBand->show();

createNumberSidesSpinBox();

0 comments on commit c0ff2f4

Please sign in to comment.
You can’t perform that action at this time.