File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -387,8 +387,25 @@ void QgsMapToolTrimExtendFeature::reset()
387
387
mVlayer = nullptr ;
388
388
mLimitLayer = nullptr ;
389
389
}
390
+ void QgsMapToolTrimExtendFeature::activate ()
391
+ {
392
+ QgsMapTool::activate ();
393
+
394
+ // Save the original snapping configuration
395
+ mOriginalSnappingConfig = mCanvas ->snappingUtils ()->config ();
396
+
397
+ // Enable Snapping & Snapping on Segment
398
+ QgsSnappingConfig snappingConfig = mOriginalSnappingConfig ;
399
+ snappingConfig.setEnabled ( true );
400
+ Qgis::SnappingTypes flags = snappingConfig.typeFlag ();
401
+ flags |= Qgis::SnappingType::Segment;
402
+ snappingConfig.setTypeFlag ( flags );
403
+ mCanvas ->snappingUtils ()->setConfig ( snappingConfig );
404
+ }
390
405
void QgsMapToolTrimExtendFeature::deactivate ()
391
406
{
392
407
reset ();
408
+ // Restore the original snapping configuration
409
+ mCanvas ->snappingUtils ()->setConfig ( mOriginalSnappingConfig );
393
410
QgsMapTool::deactivate ();
394
411
}
Original file line number Diff line number Diff line change 19
19
#include " qgsmaptooledit.h"
20
20
#include " qgis_app.h"
21
21
#include " qgsrubberband.h"
22
+ #include " qgssnappingconfig.h"
22
23
23
24
class APP_EXPORT QgsMapToolTrimExtendFeature : public QgsMapToolEdit
24
25
{
@@ -35,6 +36,9 @@ class APP_EXPORT QgsMapToolTrimExtendFeature : public QgsMapToolEdit
35
36
36
37
void keyPressEvent ( QKeyEvent *e ) override ;
37
38
39
+ // ! called when map tool is being activated
40
+ void activate () override ;
41
+
38
42
// ! called when map tool is being deactivated
39
43
void deactivate () override ;
40
44
@@ -81,6 +85,9 @@ class APP_EXPORT QgsMapToolTrimExtendFeature : public QgsMapToolEdit
81
85
};
82
86
// ! The first step (0): choose the limit. The second step (1): choose the segment to trim/extend
83
87
Step mStep = StepLimit;
88
+
89
+ // ! Snapping config that will be restored on deactivation
90
+ QgsSnappingConfig mOriginalSnappingConfig ;
84
91
};
85
92
86
93
#endif // QGSMAPTOOLTRIMEXTENDFEATURE_H
You can’t perform that action at this time.
0 commit comments