mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #8480 from lbartoletti/rectangle3PointsProjected
[FEATURE][needs-docs]Add map tool: rectangle 3 points (projected)
This commit is contained in:
commit
b089b57681
@ -673,7 +673,8 @@
|
||||
<file>themes/default/mActionEllipseCenterPoint.svg</file>
|
||||
<file>themes/default/mActionEllipseExtent.svg</file>
|
||||
<file>themes/default/mActionRectangleExtent.svg</file>
|
||||
<file>themes/default/mActionRectangle3Points.svg</file>
|
||||
<file>themes/default/mActionRectangle3PointsDistance.svg</file>
|
||||
<file>themes/default/mActionRectangle3PointsProjected.svg</file>
|
||||
<file>themes/default/mActionRectangleCenter.svg</file>
|
||||
<file>themes/default/mActionRegularPolygonCenterCorner.svg</file>
|
||||
<file>themes/default/mActionRegularPolygon2Points.svg</file>
|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
122
images/themes/default/mActionRectangle3PointsProjected.svg
Normal file
122
images/themes/default/mActionRectangle3PointsProjected.svg
Normal file
@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
version="1.1"
|
||||
id="svg4016"
|
||||
sodipodi:docname="mActionRectangle3PointsProjected.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata4022">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs4020" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1024"
|
||||
id="namedview4018"
|
||||
showgrid="false"
|
||||
inkscape:zoom="31.083333"
|
||||
inkscape:cx="12.637688"
|
||||
inkscape:cy="11.065086"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="31"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4016"
|
||||
inkscape:measure-start="7.94638,12.8686"
|
||||
inkscape:measure-end="4.08579,12.8365" />
|
||||
<linearGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="-10"
|
||||
x2="-10"
|
||||
y1="15"
|
||||
y2="21"
|
||||
id="linearGradient3996">
|
||||
<stop
|
||||
offset="0"
|
||||
stop-color="#555753"
|
||||
id="stop3992" />
|
||||
<stop
|
||||
offset="1"
|
||||
stop-color="#555753"
|
||||
stop-opacity="0"
|
||||
id="stop3994" />
|
||||
</linearGradient>
|
||||
<g
|
||||
id="g855">
|
||||
<rect
|
||||
y="5.1101041"
|
||||
x="4.1102462"
|
||||
height="11.779792"
|
||||
width="15.779792"
|
||||
id="rect5757"
|
||||
style="fill:none;stroke:#8cbe8c;stroke-width:3.22020817;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<g
|
||||
transform="translate(26.66234,-1.5120644)"
|
||||
id="g4004">
|
||||
<rect
|
||||
height="11"
|
||||
rx="2.0114901"
|
||||
width="11"
|
||||
x="-20"
|
||||
y="13"
|
||||
id="rect3998"
|
||||
style="fill:#c4a000" />
|
||||
<path
|
||||
d="m -15,14 v 2.0625 c -0.537663,0.111041 -1.024662,0.383291 -1.375,0.78125 l -1.78125,-1.03125 -0.5,0.875 1.78125,1.03125 C -16.957063,17.966182 -17,18.225145 -17,18.5 c 0,0.274855 0.04294,0.533818 0.125,0.78125 l -1.78125,1.03125 0.5,0.875 1.78125,-1.03125 c 0.352503,0.40042 0.832682,0.670182 1.375,0.78125 V 23 h 1 v -2.0625 c 0.537663,-0.111041 1.024662,-0.383291 1.375,-0.78125 l 1.78125,1.03125 0.5,-0.875 -1.78125,-1.03125 C -12.042937,19.033818 -12,18.774855 -12,18.5 c 0,-0.274855 -0.04294,-0.533818 -0.125,-0.78125 l 1.78125,-1.03125 -0.5,-0.875 -1.78125,1.03125 C -12.977503,16.44333 -13.457682,16.173568 -14,16.0625 V 14 Z m 0.5,3.5 c 0.552,0 1,0.448 1,1 0,0.552 -0.448,1 -1,1 -0.552,0 -1,-0.448 -1,-1 0,-0.552 0.448,-1 1,-1 z"
|
||||
id="path4000"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#fcffff" />
|
||||
<path
|
||||
d="m -19,19 9,-0.0096 c 0,0 0,0 0,-2 C -10,14 -11,14 -14.5,14 c -3.5,0 -4.5,0 -4.5,3 0,2 0,2 0,2 z"
|
||||
id="path4002"
|
||||
inkscape:connector-curvature="0"
|
||||
style="opacity:0.3;fill:#fcffff;fill-rule:evenodd" />
|
||||
</g>
|
||||
<path
|
||||
d="m 18.403627,3.6286861 h 3 v 3.0000002 h -3 z"
|
||||
id="path4008"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#bebebe;stroke:#8c8c8c;stroke-width:0.99999994" />
|
||||
<path
|
||||
d="m 2.661,15.274799 h 3 v 3 h -3 z"
|
||||
id="path4012"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#bebebe;stroke:#8c8c8c;stroke-width:1" />
|
||||
<path
|
||||
d="m 2.661,3.6286862 h 3 v 3 h -3 z"
|
||||
id="path4012-3"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#bebebe;stroke:#8c8c8c;stroke-width:1" />
|
||||
<path
|
||||
d="m 18.403627,15.274799 h 3 v 3 h -3 z"
|
||||
id="path4008-3"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#bebebe;stroke:#8c8c8c;stroke-width:0.99999994" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.2 KiB |
@ -1,12 +1,12 @@
|
||||
/***************************************************************************
|
||||
qgisapp.cpp - description
|
||||
-------------------
|
||||
qgisapp.cpp - description
|
||||
-------------------
|
||||
|
||||
begin : Sat Jun 22 2002
|
||||
copyright : (C) 2002 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
Romans 3:23=>Romans 6:23=>Romans 10:9,10=>Romans 12
|
||||
***************************************************************************/
|
||||
begin : Sat Jun 22 2002
|
||||
copyright : (C) 2002 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
Romans 3:23=>Romans 6:23=>Romans 10:9,10=>Romans 12
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
@ -1531,7 +1531,8 @@ QgisApp::~QgisApp()
|
||||
delete mMapTools.mEllipseFoci;
|
||||
delete mMapTools.mRectangleCenterPoint;
|
||||
delete mMapTools.mRectangleExtent;
|
||||
delete mMapTools.mRectangle3Points;
|
||||
delete mMapTools.mRectangle3PointsDistance;
|
||||
delete mMapTools.mRectangle3PointsProjected;
|
||||
delete mMapTools.mRegularPolygon2Points;
|
||||
delete mMapTools.mRegularPolygonCenterPoint;
|
||||
delete mMapTools.mRegularPolygonCenterCorner;
|
||||
@ -2091,7 +2092,8 @@ void QgisApp::createActions()
|
||||
connect( mActionEllipseFoci, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mEllipseFoci, true ); } );
|
||||
connect( mActionRectangleCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangleCenterPoint, true ); } );
|
||||
connect( mActionRectangleExtent, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangleExtent, true ); } );
|
||||
connect( mActionRectangle3Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangle3Points, true ); } );
|
||||
connect( mActionRectangle3PointsDistance, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangle3PointsDistance, true ); } );
|
||||
connect( mActionRectangle3PointsProjected, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangle3PointsProjected, true ); } );
|
||||
connect( mActionRegularPolygon2Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygon2Points, true ); } );
|
||||
connect( mActionRegularPolygonCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygonCenterPoint, true ); } );
|
||||
connect( mActionRegularPolygonCenterCorner, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygonCenterCorner, true ); } );
|
||||
@ -2376,7 +2378,8 @@ void QgisApp::createActionGroups()
|
||||
mMapToolGroup->addAction( mActionEllipseFoci );
|
||||
mMapToolGroup->addAction( mActionRectangleCenterPoint );
|
||||
mMapToolGroup->addAction( mActionRectangleExtent );
|
||||
mMapToolGroup->addAction( mActionRectangle3Points );
|
||||
mMapToolGroup->addAction( mActionRectangle3PointsDistance );
|
||||
mMapToolGroup->addAction( mActionRectangle3PointsProjected );
|
||||
mMapToolGroup->addAction( mActionRegularPolygon2Points );
|
||||
mMapToolGroup->addAction( mActionRegularPolygonCenterPoint );
|
||||
mMapToolGroup->addAction( mActionRegularPolygonCenterCorner );
|
||||
@ -2935,7 +2938,8 @@ void QgisApp::createToolBars()
|
||||
tbAddRectangle->setPopupMode( QToolButton::MenuButtonPopup );
|
||||
tbAddRectangle->addAction( mActionRectangleCenterPoint );
|
||||
tbAddRectangle->addAction( mActionRectangleExtent );
|
||||
tbAddRectangle->addAction( mActionRectangle3Points );
|
||||
tbAddRectangle->addAction( mActionRectangle3PointsDistance );
|
||||
tbAddRectangle->addAction( mActionRectangle3PointsProjected );
|
||||
tbAddRectangle->setDefaultAction( mActionRectangleCenterPoint );
|
||||
connect( tbAddRectangle, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
|
||||
mShapeDigitizeToolBar->insertWidget( mActionVertexTool, tbAddRectangle );
|
||||
@ -3576,8 +3580,10 @@ void QgisApp::createCanvasTools()
|
||||
mMapTools.mRectangleCenterPoint->setAction( mActionRectangleCenterPoint );
|
||||
mMapTools.mRectangleExtent = new QgsMapToolRectangleExtent( mMapTools.mAddFeature, mMapCanvas );
|
||||
mMapTools.mRectangleExtent->setAction( mActionRectangleExtent );
|
||||
mMapTools.mRectangle3Points = new QgsMapToolRectangle3Points( mMapTools.mAddFeature, mMapCanvas );
|
||||
mMapTools.mRectangle3Points->setAction( mActionRectangle3Points );
|
||||
mMapTools.mRectangle3PointsDistance = new QgsMapToolRectangle3Points( mMapTools.mAddFeature, mMapCanvas, QgsMapToolRectangle3Points::DistanceMode );
|
||||
mMapTools.mRectangle3PointsDistance->setAction( mActionRectangle3PointsDistance );
|
||||
mMapTools.mRectangle3PointsProjected = new QgsMapToolRectangle3Points( mMapTools.mAddFeature, mMapCanvas, QgsMapToolRectangle3Points::ProjectedMode );
|
||||
mMapTools.mRectangle3PointsProjected->setAction( mActionRectangle3PointsProjected );
|
||||
mMapTools.mRegularPolygon2Points = new QgsMapToolRegularPolygon2Points( mMapTools.mAddFeature, mMapCanvas );
|
||||
mMapTools.mRegularPolygon2Points->setAction( mActionRegularPolygon2Points );
|
||||
mMapTools.mRegularPolygonCenterPoint = new QgsMapToolRegularPolygonCenterPoint( mMapTools.mAddFeature, mMapCanvas );
|
||||
@ -12543,7 +12549,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
|
||||
mActionEllipseFoci->setEnabled( enableShapeTools );
|
||||
mActionRectangleCenterPoint->setEnabled( enableShapeTools );
|
||||
mActionRectangleExtent->setEnabled( enableShapeTools );
|
||||
mActionRectangle3Points->setEnabled( enableShapeTools );
|
||||
mActionRectangle3PointsDistance->setEnabled( enableShapeTools );
|
||||
mActionRectangle3PointsProjected->setEnabled( enableShapeTools );
|
||||
mActionRegularPolygon2Points->setEnabled( enableShapeTools );
|
||||
mActionRegularPolygonCenterPoint->setEnabled( enableShapeTools );
|
||||
mActionRegularPolygonCenterCorner->setEnabled( enableShapeTools );
|
||||
|
@ -1,10 +1,10 @@
|
||||
/***************************************************************************
|
||||
qgisapp.h - description
|
||||
-------------------
|
||||
begin : Sat Jun 22 2002
|
||||
copyright : (C) 2002 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
qgisapp.h - description
|
||||
-------------------
|
||||
begin : Sat Jun 22 2002
|
||||
copyright : (C) 2002 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
@ -2044,7 +2044,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
QgsMapTool *mEllipseFoci = nullptr;
|
||||
QgsMapTool *mRectangleCenterPoint = nullptr;
|
||||
QgsMapTool *mRectangleExtent = nullptr;
|
||||
QgsMapTool *mRectangle3Points = nullptr;
|
||||
QgsMapTool *mRectangle3PointsDistance = nullptr;
|
||||
QgsMapTool *mRectangle3PointsProjected = nullptr;
|
||||
QgsMapTool *mRegularPolygon2Points = nullptr;
|
||||
QgsMapTool *mRegularPolygonCenterPoint = nullptr;
|
||||
QgsMapTool *mRegularPolygonCenterCorner = nullptr;
|
||||
|
@ -1,18 +1,18 @@
|
||||
/***************************************************************************
|
||||
qgsmaptoolrectangle3points.cpp - map tool for adding rectangle
|
||||
from 3 points
|
||||
---------------------
|
||||
begin : September 2017
|
||||
copyright : (C) 2017 by Loïc Bartoletti
|
||||
email : lbartoletti at tuxfamily dot org
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
qgsmaptoolrectangle3points.cpp - map tool for adding rectangle
|
||||
from 3 points
|
||||
---------------------
|
||||
begin : September 2017
|
||||
copyright : (C) 2017 by Loïc Bartoletti
|
||||
email : lbartoletti at tuxfamily dot org
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmaptoolrectangle3points.h"
|
||||
#include "qgsgeometryrubberband.h"
|
||||
@ -25,8 +25,9 @@
|
||||
#include "qgssnapindicator.h"
|
||||
|
||||
QgsMapToolRectangle3Points::QgsMapToolRectangle3Points( QgsMapToolCapture *parentTool,
|
||||
QgsMapCanvas *canvas, CaptureMode mode )
|
||||
: QgsMapToolAddRectangle( parentTool, canvas, mode )
|
||||
QgsMapCanvas *canvas, CreateMode createMode, CaptureMode mode )
|
||||
: QgsMapToolAddRectangle( parentTool, canvas, mode ),
|
||||
mCreateMode( createMode )
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,7 +78,15 @@ void QgsMapToolRectangle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e )
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
setDistance2( mPoints.at( 1 ).distance( point ) );
|
||||
switch ( mCreateMode )
|
||||
{
|
||||
case DistanceMode:
|
||||
setDistance2( mPoints.at( 1 ).distance( point ) );
|
||||
break;
|
||||
case ProjectedMode:
|
||||
setDistance2( QgsGeometryUtils::perpendicularSegment( point, mPoints.at( 0 ), mPoints.at( 1 ) ).length() );
|
||||
break;
|
||||
}
|
||||
int side = QgsGeometryUtils::leftOfLine( point.x(), point.y(),
|
||||
mPoints.at( 0 ).x(), mPoints.at( 0 ).y(),
|
||||
mPoints.at( 1 ).x(), mPoints.at( 1 ).y() );
|
||||
|
@ -1,18 +1,18 @@
|
||||
/***************************************************************************
|
||||
qgsmaptoolrectangle3points.h - map tool for adding rectangle
|
||||
from 3 points
|
||||
---------------------
|
||||
begin : September 2017
|
||||
copyright : (C) 2017 by Loïc Bartoletti
|
||||
email : lbartoletti at tuxfamily dot org
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
qgsmaptoolrectangle3points.h - map tool for adding rectangle
|
||||
from 3 points
|
||||
---------------------
|
||||
begin : September 2017
|
||||
copyright : (C) 2017 by Loïc Bartoletti
|
||||
email : lbartoletti at tuxfamily dot org
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSMAPTOOLRECTANGLE3POINTS_H
|
||||
#define QGSMAPTOOLRECTANGLE3POINTS_H
|
||||
@ -25,11 +25,19 @@ class APP_EXPORT QgsMapToolRectangle3Points: public QgsMapToolAddRectangle
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QgsMapToolRectangle3Points( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
|
||||
enum CreateMode
|
||||
{
|
||||
DistanceMode,
|
||||
ProjectedMode,
|
||||
};
|
||||
QgsMapToolRectangle3Points( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CreateMode createMode, CaptureMode mode = CaptureLine );
|
||||
|
||||
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
|
||||
void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;
|
||||
|
||||
private:
|
||||
CreateMode mCreateMode;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSMAPTOOLRECTANGLE3POINTS_H
|
||||
|
@ -316,7 +316,8 @@
|
||||
</property>
|
||||
<addaction name="mActionRectangleExtent"/>
|
||||
<addaction name="mActionRectangleCenterPoint"/>
|
||||
<addaction name="mActionRectangle3Points"/>
|
||||
<addaction name="mActionRectangle3PointsDistance"/>
|
||||
<addaction name="mActionRectangle3PointsProjected"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="mMenuRegularPolygon">
|
||||
<property name="title">
|
||||
@ -2961,19 +2962,19 @@ Acts on currently active editable layer</string>
|
||||
<string>Add circle from 3 tangents</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionRectangle3Points">
|
||||
<action name="mActionRectangle3PointsDistance">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionRectangle3Points.svg</normaloff>:/images/themes/default/mActionRectangle3Points.svg</iconset>
|
||||
<iconset>
|
||||
<normaloff>:/images/themes/default/mActionRectangle3PointsDistance.svg</normaloff>:/images/themes/default/mActionRectangle3PointsDistance.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Rectangle &from 3 Points</string>
|
||||
<string>Add Rectangle &from 3 Points (Distance from 2nd and 3rd point)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add rectangle from 3 points</string>
|
||||
<string>Add rectangle from 3 points (Distance from 2nd and 3rd point)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionCircle2TangentsPoint">
|
||||
@ -3112,6 +3113,21 @@ Acts on currently active editable layer</string>
|
||||
<string>Vertex Tool (Current Layer)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionRectangle3PointsProjected">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/images/themes/default/mActionRectangle3PointsProjected.svg</normaloff>:/images/themes/default/mActionRectangle3PointsProjected.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Rectangle &from 3 Points (Distance from projected point on segment p1 and p2)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add rectangle from 3 points (Distance from projected point on segment p1 and p2)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../images/images.qrc"/>
|
||||
|
@ -1,17 +1,17 @@
|
||||
/***************************************************************************
|
||||
testqgsmaptoolrectangle.cpp
|
||||
---------------------------
|
||||
Date : January 2018
|
||||
Copyright : (C) 2018 by Paul Blottiere
|
||||
Email : paul.blottiere@oslandia.com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
testqgsmaptoolrectangle.cpp
|
||||
---------------------------
|
||||
Date : January 2018
|
||||
Copyright : (C) 2018 by Paul Blottiere
|
||||
Email : paul.blottiere@oslandia.com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgstest.h"
|
||||
|
||||
@ -42,7 +42,8 @@ class TestQgsMapToolRectangle : public QObject
|
||||
|
||||
void testRectangleFromCenter();
|
||||
void testRectangleFromExtent();
|
||||
void testRectangleFrom3Points();
|
||||
void testRectangleFrom3PointsDistance();
|
||||
void testRectangleFrom3PointsProjected();
|
||||
|
||||
private:
|
||||
QgisApp *mQgisApp = nullptr;
|
||||
@ -130,12 +131,12 @@ void TestQgsMapToolRectangle::testRectangleFromExtent()
|
||||
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
|
||||
}
|
||||
|
||||
void TestQgsMapToolRectangle::testRectangleFrom3Points()
|
||||
void TestQgsMapToolRectangle::testRectangleFrom3PointsDistance()
|
||||
{
|
||||
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 111 );
|
||||
mLayer->startEditing();
|
||||
|
||||
QgsMapToolRectangle3Points mapTool( mParentTool, mCanvas );
|
||||
QgsMapToolRectangle3Points mapTool( mParentTool, mCanvas, QgsMapToolRectangle3Points::DistanceMode );
|
||||
mCanvas->setMapTool( &mapTool );
|
||||
|
||||
TestQgsMapToolAdvancedDigitizingUtils utils( &mapTool );
|
||||
@ -156,5 +157,30 @@ void TestQgsMapToolRectangle::testRectangleFrom3Points()
|
||||
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
|
||||
}
|
||||
|
||||
void TestQgsMapToolRectangle::testRectangleFrom3PointsProjected()
|
||||
{
|
||||
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 111 );
|
||||
mLayer->startEditing();
|
||||
|
||||
QgsMapToolRectangle3Points mapTool( mParentTool, mCanvas, QgsMapToolRectangle3Points::ProjectedMode );
|
||||
mCanvas->setMapTool( &mapTool );
|
||||
|
||||
TestQgsMapToolAdvancedDigitizingUtils utils( &mapTool );
|
||||
utils.mouseClick( 0, 0, Qt::LeftButton );
|
||||
utils.mouseMove( 2, 0 );
|
||||
utils.mouseClick( 2, 0, Qt::LeftButton );
|
||||
utils.mouseMove( 2, 1 );
|
||||
utils.mouseClick( 2, 1, Qt::RightButton );
|
||||
QgsFeatureId newFid = utils.newFeatureId();
|
||||
|
||||
QCOMPARE( mLayer->featureCount(), ( long )1 );
|
||||
QgsFeature f = mLayer->getFeature( newFid );
|
||||
|
||||
QString wkt = "LineStringZ (0 0 111, 2 0 111, 2 1 111, 0 1 111, 0 0 111)";
|
||||
QCOMPARE( f.geometry().asWkt( 0 ), wkt );
|
||||
|
||||
mLayer->rollBack();
|
||||
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
|
||||
}
|
||||
QGSTEST_MAIN( TestQgsMapToolRectangle )
|
||||
#include "testqgsmaptoolrectangle.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user