Skip to content

Commit

Permalink
[advanced digitizing] Add circles intersection digitizing tool
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jun 4, 2024
1 parent df2c182 commit c17a5f1
Show file tree
Hide file tree
Showing 17 changed files with 787 additions and 31 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@
<file>themes/default/mActionPanHighlightFeature.svg</file>
<file>themes/default/mActionPrevious.svg</file>
<file>themes/default/mActionPlay.svg</file>
<file>themes/default/cadtools/circlesintersection.svg</file>
<file>themes/default/cadtools/construction.svg</file>
<file>themes/default/cadtools/delta.svg</file>
<file>themes/default/cadtools/floater.svg</file>
Expand Down
19 changes: 19 additions & 0 deletions images/themes/default/cadtools/circlesintersection.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ Removes unit suffix from the constraint text.

};

explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = 0 );
explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = 0, QgsUserInputWidget *userInputWidget = 0 );
%Docstring
Create an advanced digitizing dock widget

:param canvas: The map canvas on which the widget operates
:param parent: The parent
:param userInputWidget: The user input widget on which tools can add widget overlays on top of the map canvas (since QGIS 3.40)
%End
~QgsAdvancedDigitizingDockWidget();

bool canvasKeyPressEventFilter( QKeyEvent *e );
%Docstring
Expand All @@ -232,6 +234,24 @@ apply the CAD constraints. The will modify the position of the map event in map
%Docstring
align to segment for between line constraint.
If between line constraints are used, this will determine the angle to be locked depending on the snapped segment.
%End

bool processCanvasPressEvent( QgsMapMouseEvent *e );
bool processCanvasMoveEvent( QgsMapMouseEvent *e );
bool processCanvasReleaseEvent( QgsMapMouseEvent *e );

void setTool( QgsAdvancedDigitizingTool *tool );
%Docstring
Sets an advanced digitizing tool which will take over digitizing until the tool is close.

.. versionadded:: 3.40
%End

QgsAdvancedDigitizingTool *tool() const;
%Docstring
Returns the current advanced digitizing tool. Returns ``None`` if not set.

.. versionadded:: 3.40
%End

void releaseLocks( bool releaseRepeatingLocks = true );
Expand Down
84 changes: 84 additions & 0 deletions python/PyQt6/gui/auto_generated/qgsadvanceddigitizingtools.sip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsadvanceddigitizingtools.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsAdvancedDigitizingTool : QWidget
{
%Docstring(signature="appended")
An abstract class for advanced digitizing tools.

.. versionadded:: 3.40
%End

%TypeHeaderCode
#include "qgsadvanceddigitizingtools.h"
%End
public:

explicit QgsAdvancedDigitizingTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
%Docstring
The advanced digitizing tool constructor.

:param canvas: The map canvas on which the widget operates
:param cadDockWidget: The cadDockWidget to which the floater belongs
%End

QgsMapCanvas *mapCanvas() const;
%Docstring
Returns the map canvas associated with the tool.
%End

QgsAdvancedDigitizingDockWidget *cadDockWidget() const;
%Docstring
Returns the advanced digitizing widget associated with the tool.
%End

virtual void paint( QPainter *painter );
%Docstring
Paints tool content onto the advanced digitizing canvas item.
%End

virtual bool canvasPressEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas press event. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

virtual bool canvasMoveEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas press move. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

virtual bool canvasReleaseEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas release event. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

signals:

void paintRequested();
%Docstring
Requests a new painting event to the advanced digitizing canvas item.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsadvanceddigitizingtools.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/PyQt6/gui/gui_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
%Include auto_generated/qgsadvanceddigitizingcanvasitem.sip
%Include auto_generated/qgsadvanceddigitizingdockwidget.sip
%Include auto_generated/qgsadvanceddigitizingfloater.sip
%Include auto_generated/qgsadvanceddigitizingtools.sip
%Include auto_generated/qgsaggregatetoolbutton.sip
%Include auto_generated/qgsalignmentcombobox.sip
%Include auto_generated/qgsapplicationexitblockerinterface.sip
Expand Down
22 changes: 21 additions & 1 deletion python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ Removes unit suffix from the constraint text.

};

explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = 0 );
explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = 0, QgsUserInputWidget *userInputWidget = 0 );
%Docstring
Create an advanced digitizing dock widget

:param canvas: The map canvas on which the widget operates
:param parent: The parent
:param userInputWidget: The user input widget on which tools can add widget overlays on top of the map canvas (since QGIS 3.40)
%End
~QgsAdvancedDigitizingDockWidget();

bool canvasKeyPressEventFilter( QKeyEvent *e );
%Docstring
Expand All @@ -232,6 +234,24 @@ apply the CAD constraints. The will modify the position of the map event in map
%Docstring
align to segment for between line constraint.
If between line constraints are used, this will determine the angle to be locked depending on the snapped segment.
%End

bool processCanvasPressEvent( QgsMapMouseEvent *e );
bool processCanvasMoveEvent( QgsMapMouseEvent *e );
bool processCanvasReleaseEvent( QgsMapMouseEvent *e );

void setTool( QgsAdvancedDigitizingTool *tool );
%Docstring
Sets an advanced digitizing tool which will take over digitizing until the tool is close.

.. versionadded:: 3.40
%End

QgsAdvancedDigitizingTool *tool() const;
%Docstring
Returns the current advanced digitizing tool. Returns ``None`` if not set.

.. versionadded:: 3.40
%End

void releaseLocks( bool releaseRepeatingLocks = true );
Expand Down
84 changes: 84 additions & 0 deletions python/gui/auto_generated/qgsadvanceddigitizingtools.sip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsadvanceddigitizingtools.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsAdvancedDigitizingTool : QWidget
{
%Docstring(signature="appended")
An abstract class for advanced digitizing tools.

.. versionadded:: 3.40
%End

%TypeHeaderCode
#include "qgsadvanceddigitizingtools.h"
%End
public:

explicit QgsAdvancedDigitizingTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
%Docstring
The advanced digitizing tool constructor.

:param canvas: The map canvas on which the widget operates
:param cadDockWidget: The cadDockWidget to which the floater belongs
%End

QgsMapCanvas *mapCanvas() const;
%Docstring
Returns the map canvas associated with the tool.
%End

QgsAdvancedDigitizingDockWidget *cadDockWidget() const;
%Docstring
Returns the advanced digitizing widget associated with the tool.
%End

virtual void paint( QPainter *painter );
%Docstring
Paints tool content onto the advanced digitizing canvas item.
%End

virtual bool canvasPressEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas press event. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

virtual bool canvasMoveEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas press move. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

virtual bool canvasReleaseEvent( QgsMapMouseEvent *event );
%Docstring
Handles canvas release event. If ``True`` is returned, the tool will have
blocked the event for propagating.
%End

signals:

void paintRequested();
%Docstring
Requests a new painting event to the advanced digitizing canvas item.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsadvanceddigitizingtools.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
%Include auto_generated/qgsadvanceddigitizingcanvasitem.sip
%Include auto_generated/qgsadvanceddigitizingdockwidget.sip
%Include auto_generated/qgsadvanceddigitizingfloater.sip
%Include auto_generated/qgsadvanceddigitizingtools.sip
%Include auto_generated/qgsaggregatetoolbutton.sip
%Include auto_generated/qgsalignmentcombobox.sip
%Include auto_generated/qgsapplicationexitblockerinterface.sip
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers

// Advanced Digitizing dock
startProfile( tr( "Advanced digitize panel" ) );
mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mMapCanvas, this );
mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mMapCanvas, this, mUserInputDockWidget );
mAdvancedDigitizingDockWidget->setWindowTitle( tr( "Advanced Digitizing" ) );
mAdvancedDigitizingDockWidget->setObjectName( QStringLiteral( "AdvancedDigitizingTools" ) );

Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ set(QGIS_GUI_SRCS
qgsadvanceddigitizingcanvasitem.cpp
qgsadvanceddigitizingdockwidget.cpp
qgsadvanceddigitizingfloater.cpp
qgsadvanceddigitizingtools.cpp
qgsaggregatetoolbutton.cpp
qgsalignmentcombobox.cpp
qgsapplicationexitblockerinterface.cpp
Expand Down Expand Up @@ -783,6 +784,7 @@ set(QGIS_GUI_HDRS
qgsadvanceddigitizingcanvasitem.h
qgsadvanceddigitizingdockwidget.h
qgsadvanceddigitizingfloater.h
qgsadvanceddigitizingtools.h
qgsaggregatetoolbutton.h
qgsalignmentcombobox.h
qgsapplicationexitblockerinterface.h
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsadvanceddigitizingcanvasitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
}
}

// Draw current intersection tool
if ( mAdvancedDigitizingDockWidget->tool() )
{
mAdvancedDigitizingDockWidget->tool()->paint( painter );
return;
}

// Use visible polygon rather than extent to properly handle rotated maps
QPolygonF mapPoly = mMapCanvas->mapSettings().visiblePolygon();
const double canvasWidth = QLineF( mapPoly[0], mapPoly[1] ).length();
Expand Down
Loading

0 comments on commit c17a5f1

Please sign in to comment.