mirror of
https://github.com/qgis/QGIS.git
synced 2025-07-04 00:02:42 -04:00
Compare commits
5 Commits
1ed3db1067
...
c326006598
Author | SHA1 | Date | |
---|---|---|---|
|
c326006598 | ||
|
09ce65b93f | ||
|
8d122f0778 | ||
|
79a76da7d9 | ||
|
68dbf86a59 |
@ -63,6 +63,9 @@ bool QgsMapToolShapeCircle2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mCircle.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( mParentTool->mapPoint( *e ) );
|
mPoints.append( mParentTool->mapPoint( *e ) );
|
||||||
addCircleToParentTool();
|
addCircleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -100,6 +100,9 @@ bool QgsMapToolShapeCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEven
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mPoints.size() < 4 || mCircle.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addCircleToParentTool();
|
addCircleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,9 @@ bool QgsMapToolShapeCircle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mCircle.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( mParentTool->mapPoint( *e ) );
|
mPoints.append( mParentTool->mapPoint( *e ) );
|
||||||
addCircleToParentTool();
|
addCircleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,6 +92,9 @@ bool QgsMapToolShapeCircle3Tangents::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mCircle.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( match.isValid() && ( mPoints.size() == 4 ) )
|
if ( match.isValid() && ( mPoints.size() == 4 ) )
|
||||||
{
|
{
|
||||||
match.edgePoints( p1, p2 );
|
match.edgePoints( p1, p2 );
|
||||||
|
@ -68,6 +68,9 @@ bool QgsMapToolShapeCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mCircle.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addCircleToParentTool();
|
addCircleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -106,6 +106,9 @@ bool QgsMapToolShapeCircularStringRadius::cadCanvasReleaseEvent( QgsMapMouseEven
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mPoints.size() < 3 )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( !( mPoints.size() % 2 ) )
|
if ( !( mPoints.size() % 2 ) )
|
||||||
mPoints.removeLast();
|
mPoints.removeLast();
|
||||||
addCurveToParentTool();
|
addCurveToParentTool();
|
||||||
|
@ -68,6 +68,9 @@ bool QgsMapToolShapeEllipseCenter2Points::cadCanvasReleaseEvent( QgsMapMouseEven
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mEllipse.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addEllipseToParentTool();
|
addEllipseToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,9 @@ bool QgsMapToolShapeEllipseCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mEllipse.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addEllipseToParentTool();
|
addEllipseToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ bool QgsMapToolShapeEllipseExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Q
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mEllipse.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addEllipseToParentTool();
|
addEllipseToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ bool QgsMapToolShapeEllipseFoci::cadCanvasReleaseEvent( QgsMapMouseEvent *e, Qgs
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mEllipse.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addEllipseToParentTool();
|
addEllipseToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,9 @@ bool QgsMapToolShapeRectangle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( !mRectangle.isValid() )
|
||||||
|
return false;
|
||||||
|
|
||||||
addRectangleToParentTool();
|
addRectangleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,9 @@ bool QgsMapToolShapeRectangleCenter::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( !mRectangle.isValid() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addRectangleToParentTool();
|
addRectangleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,6 +68,9 @@ bool QgsMapToolShapeRectangleExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e,
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( !mRectangle.isValid() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addRectangleToParentTool();
|
addRectangleToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -78,6 +78,9 @@ bool QgsMapToolShapeRegularPolygon2Points::cadCanvasReleaseEvent( QgsMapMouseEve
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mRegularPolygon.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addRegularPolygonToParentTool();
|
addRegularPolygonToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -75,6 +75,9 @@ bool QgsMapToolShapeRegularPolygonCenterCorner::cadCanvasReleaseEvent( QgsMapMou
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mRegularPolygon.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addRegularPolygonToParentTool();
|
addRegularPolygonToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -77,6 +77,9 @@ bool QgsMapToolShapeRegularPolygonCenterPoint::cadCanvasReleaseEvent( QgsMapMous
|
|||||||
}
|
}
|
||||||
else if ( e->button() == Qt::RightButton )
|
else if ( e->button() == Qt::RightButton )
|
||||||
{
|
{
|
||||||
|
if ( mRegularPolygon.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
mPoints.append( point );
|
mPoints.append( point );
|
||||||
addRegularPolygonToParentTool();
|
addRegularPolygonToParentTool();
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "qgsmaptoolshapecircle2points.h"
|
#include "qgsmaptoolshapecircle2points.h"
|
||||||
#include "qgsmaptoolshapecircle3points.h"
|
#include "qgsmaptoolshapecircle3points.h"
|
||||||
#include "qgsmaptoolshapecirclecenterpoint.h"
|
#include "qgsmaptoolshapecirclecenterpoint.h"
|
||||||
|
#include "qgsmaptoolshapecircle3tangents.h"
|
||||||
|
#include "qgsmaptoolshapecircle2tangentspoint.h"
|
||||||
|
|
||||||
|
|
||||||
class TestQgsMapToolCircle : public QObject
|
class TestQgsMapToolCircle : public QObject
|
||||||
@ -45,6 +47,11 @@ class TestQgsMapToolCircle : public QObject
|
|||||||
|
|
||||||
void testCircle_data();
|
void testCircle_data();
|
||||||
void testCircle();
|
void testCircle();
|
||||||
|
void testDrawCircleFrom2PointsNotEnoughPoints();
|
||||||
|
void testDrawCircleFrom3PointsNotEnoughPoints();
|
||||||
|
void testDrawCircleFromCenterPointNotEnoughPoints();
|
||||||
|
void testDrawCircleFrom3TangentsNotEnoughPoints();
|
||||||
|
void testDrawCircleFrom2TangentsNotEnoughPoints();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
||||||
@ -334,7 +341,6 @@ QgsFeatureId TestQgsMapToolCircle::drawCircleFromCenterPointWithDeletedVertex()
|
|||||||
return utils.newFeatureId();
|
return utils.newFeatureId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestQgsMapToolCircle::testCircle_data()
|
void TestQgsMapToolCircle::testCircle_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>( "wktGeometry" );
|
QTest::addColumn<QString>( "wktGeometry" );
|
||||||
@ -392,6 +398,107 @@ void TestQgsMapToolCircle::testCircle()
|
|||||||
QCOMPARE( wktGeometry, wktExpected );
|
QCOMPARE( wktGeometry, wktExpected );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircle::testDrawCircleFrom2PointsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircle2PointsMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircle::testDrawCircleFrom3PointsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircle3PointsMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircle::testDrawCircleFromCenterPointNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircleCenterPointMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircle::testDrawCircleFrom3TangentsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircle3TangentsMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 2, Qt::RightButton );
|
||||||
|
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircle::testDrawCircleFrom2TangentsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircle2TangentsPointMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 2, Qt::RightButton );
|
||||||
|
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsMapToolCircle )
|
QGSTEST_MAIN( TestQgsMapToolCircle )
|
||||||
#include "testqgsmaptoolcircle.moc"
|
#include "testqgsmaptoolcircle.moc"
|
||||||
|
@ -41,6 +41,7 @@ class TestQgsMapToolCircularString : public QObject
|
|||||||
void testAddCircularStringCurvePoint();
|
void testAddCircularStringCurvePoint();
|
||||||
void testAddCircularStringRadius();
|
void testAddCircularStringRadius();
|
||||||
void testAddCircularStringRadiusWithDeletedVertex();
|
void testAddCircularStringRadiusWithDeletedVertex();
|
||||||
|
void testAddCircularStringRadiusNotEnoughPoints();
|
||||||
void testAddCircularStringAfterClassicDigitizing();
|
void testAddCircularStringAfterClassicDigitizing();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -175,6 +176,34 @@ void TestQgsMapToolCircularString::testAddCircularStringRadiusWithDeletedVertex(
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolCircularString::testAddCircularStringRadiusNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeCircularStringRadiusMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 2, 2 );
|
||||||
|
utils.mouseClick( 2, 2, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 2, 2, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 2 );
|
||||||
|
utils.mouseClick( 1, 2, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing()
|
void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing()
|
||||||
{
|
{
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 333 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 333 );
|
||||||
|
@ -46,6 +46,11 @@ class TestQgsMapToolEllipse : public QObject
|
|||||||
void testEllipse_data();
|
void testEllipse_data();
|
||||||
void testEllipse();
|
void testEllipse();
|
||||||
|
|
||||||
|
void testEllipseFromCenterAndPointNotEnoughPoints();
|
||||||
|
void testEllipseFromCenterAnd2PointsNotEnoughPoints();
|
||||||
|
void testEllipseFromExtentNotEnoughPoints();
|
||||||
|
void testEllipseFromFociNotEnoughPoints();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QgisApp *mQgisApp = nullptr;
|
QgisApp *mQgisApp = nullptr;
|
||||||
QgsMapToolCapture *mMapTool = nullptr;
|
QgsMapToolCapture *mMapTool = nullptr;
|
||||||
@ -450,6 +455,115 @@ void TestQgsMapToolEllipse::testEllipse()
|
|||||||
QCOMPARE( wktGeometry, wktExpected );
|
QCOMPARE( wktGeometry, wktExpected );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolEllipse::testEllipseFromCenterAndPointNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeEllipseCenterPointMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolEllipse::testEllipseFromCenterAnd2PointsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeEllipseCenter2PointsMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolEllipse::testEllipseFromExtentNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeEllipseExtentMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolEllipse::testEllipseFromFociNotEnoughPoints()
|
||||||
|
{
|
||||||
|
QgsVectorLayer *layer = mVectorLayerMap["XY"].get();
|
||||||
|
mCanvas->setCurrentLayer( layer );
|
||||||
|
layer->startEditing();
|
||||||
|
const long long count = layer->featureCount();
|
||||||
|
|
||||||
|
QgsMapToolShapeEllipseFociMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( layer->featureCount(), count );
|
||||||
|
|
||||||
|
layer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsMapToolEllipse )
|
QGSTEST_MAIN( TestQgsMapToolEllipse )
|
||||||
#include "testqgsmaptoolellipse.moc"
|
#include "testqgsmaptoolellipse.moc"
|
||||||
|
@ -43,12 +43,16 @@ class TestQgsMapToolRectangle : public QObject
|
|||||||
|
|
||||||
void testRectangleFromCenter();
|
void testRectangleFromCenter();
|
||||||
void testRectangleFromCenterWithDeletedVertex();
|
void testRectangleFromCenterWithDeletedVertex();
|
||||||
|
void testRectangleFromCenterNotEnoughPoints();
|
||||||
void testRectangleFromExtent();
|
void testRectangleFromExtent();
|
||||||
void testRectangleFromExtentWithDeletedVertex();
|
void testRectangleFromExtentWithDeletedVertex();
|
||||||
|
void testRectangleFromExtentNotEnoughPoints();
|
||||||
void testRectangleFrom3PointsDistance();
|
void testRectangleFrom3PointsDistance();
|
||||||
void testRectangleFrom3PointsDistanceWithDeletedVertex();
|
void testRectangleFrom3PointsDistanceWithDeletedVertex();
|
||||||
|
void testRectangleFrom3PointsDistanceNotEnoughPoints();
|
||||||
void testRectangleFrom3PointsProjected();
|
void testRectangleFrom3PointsProjected();
|
||||||
void testRectangleFrom3PointsProjectedWithDeletedVertex();
|
void testRectangleFrom3PointsProjectedWithDeletedVertex();
|
||||||
|
void testRectangleFrom3PointsProjectedNotEnoughPoints();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
||||||
@ -157,6 +161,27 @@ void TestQgsMapToolRectangle::testRectangleFromCenterWithDeletedVertex()
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRectangle::testRectangleFromCenterNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRectangleCenterMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsMapToolRectangle::testRectangleFromExtent()
|
void TestQgsMapToolRectangle::testRectangleFromExtent()
|
||||||
{
|
{
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 222 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 222 );
|
||||||
@ -210,6 +235,27 @@ void TestQgsMapToolRectangle::testRectangleFromExtentWithDeletedVertex()
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRectangle::testRectangleFromExtentNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRectangleExtentMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistance()
|
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistance()
|
||||||
{
|
{
|
||||||
@ -268,6 +314,35 @@ void TestQgsMapToolRectangle::testRectangleFrom3PointsDistanceWithDeletedVertex(
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistanceNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRectangle3PointsMetadata md( QgsMapToolShapeRectangle3PointsMetadata::CreateMode::Distance );
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjected()
|
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjected()
|
||||||
{
|
{
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
||||||
@ -324,5 +399,34 @@ void TestQgsMapToolRectangle::testRectangleFrom3PointsProjectedWithDeletedVertex
|
|||||||
mLayer->rollBack();
|
mLayer->rollBack();
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjectedNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRectangle3PointsMetadata md( QgsMapToolShapeRectangle3PointsMetadata::CreateMode::Projected );
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseMove( 1, 1 );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 1, 1, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
QGSTEST_MAIN( TestQgsMapToolRectangle )
|
QGSTEST_MAIN( TestQgsMapToolRectangle )
|
||||||
#include "testqgsmaptoolrectangle.moc"
|
#include "testqgsmaptoolrectangle.moc"
|
||||||
|
@ -43,10 +43,13 @@ class TestQgsMapToolRegularPolygon : public QObject
|
|||||||
|
|
||||||
void testRegularPolygonFrom2Points();
|
void testRegularPolygonFrom2Points();
|
||||||
void testRegularPolygonFrom2PointsWithDeletedVertex();
|
void testRegularPolygonFrom2PointsWithDeletedVertex();
|
||||||
|
void testRegularPolygonFrom2PointsNotEnoughPoints();
|
||||||
void testRegularPolygonFromCenterAndPoint();
|
void testRegularPolygonFromCenterAndPoint();
|
||||||
void testRegularPolygonFromCenterAndPointWithDeletedVertex();
|
void testRegularPolygonFromCenterAndPointWithDeletedVertex();
|
||||||
void testRegularPolygonFromCenterAndCroner();
|
void testRegularPolygonFromCenterAndPointNotEnoughPoints();
|
||||||
void testRegularPolygonFromCenterAndCronerWithDeletedVertex();
|
void testRegularPolygonFromCenterAndCorner();
|
||||||
|
void testRegularPolygonFromCenterAndCornerWithDeletedVertex();
|
||||||
|
void testRegularPolygonFromCenterAndCornerNotEnoughPoints();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
void resetMapTool( QgsMapToolShapeMetadata *metadata );
|
||||||
@ -150,6 +153,27 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2PointsWithDeletedVerte
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2PointsNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRegularPolygon2PointsMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPoint()
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPoint()
|
||||||
{
|
{
|
||||||
@ -200,8 +224,29 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPointWithDelet
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPointNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCroner()
|
QgsMapToolShapeRegularPolygonCenterPointMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCorner()
|
||||||
{
|
{
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
||||||
mLayer->startEditing();
|
mLayer->startEditing();
|
||||||
@ -224,7 +269,8 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCroner()
|
|||||||
mLayer->rollBack();
|
mLayer->rollBack();
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCronerWithDeletedVertex()
|
|
||||||
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCornerWithDeletedVertex()
|
||||||
{
|
{
|
||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 111 );
|
||||||
mLayer->startEditing();
|
mLayer->startEditing();
|
||||||
@ -250,6 +296,27 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCronerWithDele
|
|||||||
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
QgsSettingsRegistryCore::settingsDigitizingDefaultZValue->setValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCornerNotEnoughPoints()
|
||||||
|
{
|
||||||
|
const long long count = mLayer->featureCount();
|
||||||
|
mLayer->startEditing();
|
||||||
|
|
||||||
|
QgsMapToolShapeRegularPolygonCenterCornerMetadata md;
|
||||||
|
resetMapTool( &md );
|
||||||
|
|
||||||
|
TestQgsMapToolAdvancedDigitizingUtils utils( mMapTool );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
utils.keyClick( Qt::Key_Escape );
|
||||||
|
|
||||||
|
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||||
|
utils.mouseClick( 0, 0, Qt::RightButton );
|
||||||
|
QCOMPARE( mLayer->featureCount(), count );
|
||||||
|
|
||||||
|
mLayer->rollBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsMapToolRegularPolygon )
|
QGSTEST_MAIN( TestQgsMapToolRegularPolygon )
|
||||||
#include "testqgsmaptoolregularpolygon.moc"
|
#include "testqgsmaptoolregularpolygon.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user