Navigation Menu

Skip to content

Commit

Permalink
init trim/extend feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Nov 13, 2018
1 parent 530cd5c commit abcf2aa
Show file tree
Hide file tree
Showing 14 changed files with 1,067 additions and 0 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -728,6 +728,7 @@
<file>themes/default/mIconAllRings.svg</file>
<file>themes/default/mIconExteriorRing.svg</file>
<file>themes/default/mIconInteriorRings.svg</file>
<file>themes/default/mActionTrimExtendFeature.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</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.
11 changes: 11 additions & 0 deletions python/core/auto_generated/geometry/qgsgeometryutils.sip.in
Expand Up @@ -224,6 +224,17 @@ 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( QgsPoint point, QgsPoint p1, 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 @@ -315,6 +316,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolchangelabelproperties.h
qgsmaptooldeletepart.h
qgsmaptooldeletering.h
qgsmaptooltrimextendfeature.h
qgsmaptoolfeatureaction.h
qgsmaptoolformannotation.h
qgsmaptoolhtmlannotation.h
Expand Down
16 changes: 16 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -417,6 +417,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 @@ -1489,6 +1490,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 @@ -2120,6 +2122,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, &QgisApp::trimExtendFeature );

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

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

emit currentThemeChanged( themeName );
}
Expand Down Expand Up @@ -3644,6 +3649,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 @@ -7857,6 +7864,11 @@ void QgisApp::reverseLine()
mMapCanvas->setMapTool( mMapTools.mReverseLine );
}

void QgisApp::trimExtendFeature()
{
mMapCanvas->setMapTool( mMapTools.mTrimExtendFeature );
}

QgsGeometry QgisApp::unionGeometries( const QgsVectorLayer *vl, QgsFeatureList &featureList, bool &canceled )
{
canceled = false;
Expand Down Expand Up @@ -12415,6 +12427,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 @@ -12490,6 +12503,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 @@ -12634,6 +12648,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 @@ -12654,6 +12669,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
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -1432,6 +1432,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void offsetPointSymbol();
//! activates the reverse line tool
void reverseLine();
//! activates the trim/extend feature tool
void trimExtendFeature();
//! activates the tool
void setMapTool( QgsMapTool *tool, bool clean = false );

Expand Down Expand Up @@ -2085,6 +2087,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 abcf2aa

Please sign in to comment.