Skip to content
Permalink
Browse files
Enable streaming/curve digitizing modes also for polygon/line annotation
item creation
  • Loading branch information
nyalldawson committed Sep 8, 2021
1 parent 0464eec commit 6a7f8823266c81c26711602f86b338e97a119c91
@@ -802,10 +802,19 @@ void QgisApp::annotationItemTypeAdded( int id )
mAnnotationsToolBar->addAction( action );
}

connect( action, &QAction::triggered, this, [this, id]()
connect( action, &QAction::toggled, this, [this, action, id]( bool checked )
{
if ( !checked )
return;

QgsCreateAnnotationItemMapToolInterface *tool = QgsGui::annotationItemGuiRegistry()->itemMetadata( id )->createMapTool( mMapCanvas, mAdvancedDigitizingDockWidget );
tool->mapTool()->setAction( action );
mMapCanvas->setMapTool( tool->mapTool() );
if ( qobject_cast< QgsMapToolCapture * >( tool->mapTool() ) )
{
enableDigitizeTechniqueActions( checked, action );
}

connect( tool->mapTool(), &QgsMapTool::deactivated, tool->mapTool(), &QObject::deleteLater );
connect( tool->handler(), &QgsCreateAnnotationItemMapToolHandler::itemCreated, this, [ = ]
{
@@ -3122,6 +3131,7 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionChangeLabelProperties );
mMapToolGroup->addAction( mActionReverseLine );
mMapToolGroup->addAction( mActionTrimExtendFeature );
mMapToolGroup->addAction( mActionModifyAnnotation );

//
// Preview Modes Group
@@ -10290,8 +10300,8 @@ void QgisApp::enableDigitizeWithCurve( bool enable )
QgsSettings().setValue( QStringLiteral( "UI/digitizeTechnique" ), 0 );
}

const QList< QgsMapToolCapture * > captureTools = mMapTools->captureTools();
for ( QgsMapToolCapture *tool : captureTools )
const QList< QgsMapToolCapture * > tools = captureTools();
for ( QgsMapToolCapture *tool : tools )
{
if ( tool->supportsTechnique( QgsMapToolCapture::CircularString ) )
tool->setCircularDigitizingEnabled( enable );
@@ -10314,8 +10324,8 @@ void QgisApp::enableStreamDigitizing( bool enable )
QgsSettings().setValue( QStringLiteral( "UI/digitizeTechnique" ), 1 );
}

const QList< QgsMapToolCapture * > captureTools = mMapTools->captureTools();
for ( QgsMapToolCapture *tool : captureTools )
const QList< QgsMapToolCapture * > tools = captureTools();
for ( QgsMapToolCapture *tool : tools )
{
if ( tool->supportsTechnique( QgsMapToolCapture::Streaming ) )
tool->setStreamDigitizingEnabled( enable );
@@ -10331,10 +10341,10 @@ void QgisApp::enableDigitizeTechniqueActions( bool enable, QAction *triggeredFro

QgsSettings settings;

const QList< QgsMapToolCapture * > captureTools = mMapTools->captureTools();
const QList< QgsMapToolCapture * > tools = captureTools();

QSet< QgsMapToolCapture::CaptureTechnique > supportedTechniques;
for ( QgsMapToolCapture *tool : captureTools )
for ( QgsMapToolCapture *tool : tools )
{
if ( triggeredFromToolAction == tool->action() || ( !triggeredFromToolAction && mMapCanvas->mapTool() == tool ) )
{
@@ -10355,7 +10365,7 @@ void QgisApp::enableDigitizeTechniqueActions( bool enable, QAction *triggeredFro
const bool streamIsChecked = settings.value( QStringLiteral( "UI/digitizeWithStream" ) ).toInt();
mActionStreamDigitize->setChecked( streamIsChecked && mActionStreamDigitize->isEnabled() );

for ( QgsMapToolCapture *tool : captureTools )
for ( QgsMapToolCapture *tool : tools )
{
if ( tool->supportsTechnique( QgsMapToolCapture::CircularString ) )
tool->setCircularDigitizingEnabled( mActionDigitizeWithCurve->isChecked() );
@@ -11559,6 +11569,18 @@ void QgisApp::enableMeshEditingTools( bool enable )
}
}

QList<QgsMapToolCapture *> QgisApp::captureTools()
{
QList< QgsMapToolCapture * > res = mMapTools->captureTools();
// also check current tool, in case it's a custom tool
if ( QgsMapToolCapture *currentTool = qobject_cast< QgsMapToolCapture * >( mMapCanvas->mapTool() ) )
{
if ( !res.contains( currentTool ) )
res.append( currentTool );
}
return res;
}

void QgisApp::saveEdits()
{
const auto constSelectedLayers = mLayerTreeView->selectedLayers();
@@ -15825,7 +15847,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer )
mActionLabeling->setEnabled( false );
mActionDiagramProperties->setEnabled( false );
mActionIdentify->setEnabled( true );
enableDigitizeTechniqueActions( false );
enableDigitizeTechniqueActions( true );
mActionToggleEditing->setEnabled( false );
mActionToggleEditing->setChecked( true ); // always editable
mActionUndo->setEnabled( false );
@@ -149,6 +149,8 @@ class QgsDevToolsPanelWidget;
class QgsDevToolWidgetFactory;
class QgsNetworkLogger;
class QgsNetworkLoggerWidgetFactory;
class QgsMapToolCapture;

#include <QMainWindow>
#include <QToolBar>
#include <QAbstractSocket>
@@ -2379,6 +2381,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void enableMeshEditingTools( bool enable );

/**
* Returns a list of all capture map tools.
*/
QList< QgsMapToolCapture * > captureTools();

QgisAppStyleSheet *mStyleSheetBuilder = nullptr;

@@ -123,6 +123,11 @@ QgsMapToolCapture::Capabilities QgsMapToolCaptureAnnotationItem::capabilities()
return SupportsCurves;
}

bool QgsMapToolCaptureAnnotationItem::supportsTechnique( CaptureTechnique ) const
{
return true;
}


//
// QgsCreateLineMapTool
@@ -69,7 +69,7 @@ class QgsMapToolCaptureAnnotationItem : public QgsMapToolCapture
QgsMapToolCaptureAnnotationItem( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode );

QgsMapToolCapture::Capabilities capabilities() const override;

bool supportsTechnique( CaptureTechnique technique ) const override;

};

0 comments on commit 6a7f882

Please sign in to comment.