Skip to content

Commit

Permalink
Merge pull request #8429 from lbartoletti/extendMapTool
Browse files Browse the repository at this point in the history
[needs-docs][FEATURE] Trim/extend
  • Loading branch information
3nids committed Nov 21, 2018
2 parents f3fbd06 + 792546c commit d1d3a51
Show file tree
Hide file tree
Showing 13 changed files with 1,060 additions and 3 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -732,6 +732,7 @@
<file>themes/default/mIconExteriorRing.svg</file>
<file>themes/default/mIconInteriorRings.svg</file>
<file>themes/default/mIconFieldBinary.svg</file>
<file>themes/default/mActionTrimExtendFeature.svg</file>
<file>themes/default/mActionTerminal.svg</file>
<file>themes/default/mIconFolder24.svg</file>
<file>themes/default/mActionNewFolder.svg</file>
Expand Down
196 changes: 196 additions & 0 deletions images/themes/default/mActionTrimExtendFeature.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion python/core/auto_generated/geometry/qgsgeometryutils.sip.in
Expand Up @@ -217,13 +217,24 @@ Project the point on a segment



static int leftOfLine( double x, double y, double x1, double y1, double x2, double y2 );
static int leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 );
%Docstring
Returns a value < 0 if the point (``x``, ``y``) is left of the line from (``x1``, ``y1``) -> ( ``x2``, ``y2``).
A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly
on the line, or exactly in line with the segment) and the result is undefined.
%End

static int leftOfLine( const QgsPoint &point, const QgsPoint &p1, const QgsPoint &p2 );
%Docstring
Returns a value < 0 if the point ``point`` is left of the line from ``p1`` -> ``p2``.
A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly
on the line, or exactly in line with the segment) and the result is undefined.

.. versionadded:: 3.6
%End

static QgsPoint pointOnLineWithDistance( const QgsPoint &startPoint, const QgsPoint &directionPoint, double distance );
Expand Down
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -81,6 +81,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolchangelabelproperties.cpp
qgsmaptooldeletering.cpp
qgsmaptooldeletepart.cpp
qgsmaptooltrimextendfeature.cpp
qgsmaptoolfeatureaction.cpp
qgsmaptoolformannotation.cpp
qgsmaptoolhtmlannotation.cpp
Expand Down Expand Up @@ -317,6 +318,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolchangelabelproperties.h
qgsmaptooldeletepart.h
qgsmaptooldeletering.h
qgsmaptooltrimextendfeature.h
qgsmaptoolfeatureaction.h
qgsmaptoolformannotation.h
qgsmaptoolhtmlannotation.h
Expand Down
11 changes: 11 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -418,6 +418,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgsmaptoolreverseline.h"
#include "qgsgeometryvalidationmodel.h"
#include "qgsgeometryvalidationdock.h"
#include "qgsmaptooltrimextendfeature.h"

#include "vertextool/qgsvertextool.h"

Expand Down Expand Up @@ -1488,6 +1489,7 @@ QgisApp::~QgisApp()
delete mMapTools.mChangeLabelProperties;
delete mMapTools.mDeletePart;
delete mMapTools.mDeleteRing;
delete mMapTools.mTrimExtendFeature;
delete mMapTools.mFeatureAction;
delete mMapTools.mFormAnnotation;
delete mMapTools.mHtmlAnnotation;
Expand Down Expand Up @@ -2121,6 +2123,7 @@ void QgisApp::createActions()
connect( mActionSnappingOptions, &QAction::triggered, this, &QgisApp::snappingOptions );
connect( mActionOffsetCurve, &QAction::triggered, this, &QgisApp::offsetCurve );
connect( mActionReverseLine, &QAction::triggered, this, &QgisApp::reverseLine );
connect( mActionTrimExtendFeature, &QAction::triggered, this, [ = ] { mMapCanvas->setMapTool( mMapTools.mTrimExtendFeature ); } );

// View Menu Items
connect( mActionPan, &QAction::triggered, this, &QgisApp::pan );
Expand Down Expand Up @@ -2409,6 +2412,7 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionRotateLabel );
mMapToolGroup->addAction( mActionChangeLabelProperties );
mMapToolGroup->addAction( mActionReverseLine );
mMapToolGroup->addAction( mActionTrimExtendFeature );

//
// Preview Modes Group
Expand Down Expand Up @@ -3387,6 +3391,7 @@ void QgisApp::setTheme( const QString &themeName )
mActionDecorationScaleBar->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionScaleBar.svg" ) ) );
mActionDecorationGrid->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/grid.svg" ) ) );
mActionReverseLine->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionReverseLine.svg" ) ) );
mActionTrimExtendFeature->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionTrimExtendFeature.svg" ) ) );

emit currentThemeChanged( themeName );
}
Expand Down Expand Up @@ -3638,6 +3643,8 @@ void QgisApp::createCanvasTools()
mMapTools.mRotatePointSymbolsTool->setAction( mActionRotatePointSymbols );
mMapTools.mOffsetPointSymbolTool = new QgsMapToolOffsetPointSymbol( mMapCanvas );
mMapTools.mOffsetPointSymbolTool->setAction( mActionOffsetPointSymbol );
mMapTools.mTrimExtendFeature = new QgsMapToolTrimExtendFeature( mMapCanvas );
mMapTools.mTrimExtendFeature->setAction( mActionTrimExtendFeature );

mMapTools.mPinLabels = new QgsMapToolPinLabels( mMapCanvas );
mMapTools.mPinLabels->setAction( mActionPinLabels );
Expand Down Expand Up @@ -12407,6 +12414,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
mActionCopyLayer->setEnabled( false );
mActionPasteLayer->setEnabled( false );
mActionReverseLine->setEnabled( false );
mActionTrimExtendFeature->setEnabled( false );

mUndoDock->widget()->setEnabled( false );
mActionUndo->setEnabled( false );
Expand Down Expand Up @@ -12482,6 +12490,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
mActionLabeling->setEnabled( isSpatial );
mActionDiagramProperties->setEnabled( isSpatial );
mActionReverseLine->setEnabled( false );
mActionTrimExtendFeature->setEnabled( false );

mActionSelectFeatures->setEnabled( isSpatial );
mActionSelectPolygon->setEnabled( isSpatial );
Expand Down Expand Up @@ -12627,6 +12636,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
mActionSimplifyFeature->setEnabled( isEditable && canChangeGeometry );
mActionOffsetCurve->setEnabled( isEditable && canAddFeatures && canChangeAttributes );
mActionReverseLine->setEnabled( isEditable && canChangeGeometry );
mActionTrimExtendFeature->setEnabled( isEditable && canChangeGeometry );

mActionAddRing->setEnabled( false );
mActionFillRing->setEnabled( false );
Expand All @@ -12647,6 +12657,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
mActionSimplifyFeature->setEnabled( isEditable && canChangeGeometry );
mActionDeleteRing->setEnabled( isEditable && canChangeGeometry );
mActionOffsetCurve->setEnabled( isEditable && canAddFeatures && canChangeAttributes );
mActionTrimExtendFeature->setEnabled( isEditable && canChangeGeometry );
}
else if ( vlayer->geometryType() == QgsWkbTypes::NullGeometry )
{
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisapp.h
Expand Up @@ -2084,6 +2084,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool *mRotateLabel = nullptr;
QgsMapTool *mChangeLabelProperties = nullptr;
QgsMapTool *mReverseLine = nullptr ;
QgsMapTool *mTrimExtendFeature = nullptr ;
} mMapTools;

QgsMapTool *mNonEditMapTool = nullptr;
Expand Down

0 comments on commit d1d3a51

Please sign in to comment.