-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[needs-docs][FEATURE] Add reverse line maptools AKA swap direction #7659
Conversation
b7d4054
to
81974f9
Compare
Nice feature, and much needed! However, I'm a -0 on adding this as a new map tool. I don't think adding extra map tools for every geometry operation like this will scale, especially when we're already fighting UI complexity with the current set of tools. I'd personally rather see this implemented using the approach from qgis/QGIS-Enhancement-Proposals#114 - where we reuse the Processing toolbox for additional geometry editing tools. I'm going to be launching a crowdfunding campaign for this shortly, so hopefully we'll get it implemented soon. If everyone else agrees that reusing the toolbox is a better approach, I'd suggest we leave this PR open (fighting off the stale bot as we go!) and if QEP #114 isn't implemented by 3.4, then we merge this approach instead. |
@nyalldawson , I disagree here. While we definitively want a reverse line algorithm that'll be compatible with the processing's in-place editing, this is one function that very much deserves a tool of its own when digitizing features, it's a basic function that's no different from our reshape features tool. More importantly here, solely having a processing in-place editing function is not enough, as we need to be able to reverse direction of single part(s) within a multipart line / polygon. |
That argument's a slippery slope. There's lot of other tools I'd consider "essential" which we don't have - e.g. split multipart feature to single parts. So I'd argue that any geometry operation which doesn't require a "draw something on the canvas" interaction should be done through the toolbox instead.
That's a fair point, I'll concede that one! (But I'll counter it by asking how often you really find you need to do that...) |
@nyalldawson , it's indeed a slippery slope here, various workflows would bring a different set of tools as "basic" for different users. That said, the multi-part handling here is IMHO what tips off the balance here :) Similarly, while we have an offset / buffer algorithm, I still think the tool is useful as it can offset / buffer individual parts. |
src/app/qgsmaptoolreverseline.cpp
Outdated
|
||
QgsMapToolReverseLine::QgsMapToolReverseLine( QgsMapCanvas *canvas ) | ||
: QgsMapToolEdit( canvas ) | ||
, mPressedFid( 0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move initialization to header
src/app/qgsmaptoolreverseline.cpp
Outdated
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mPressedFid ) ).nextFeature( f ); | ||
QgsGeometry geom; | ||
|
||
if ( f.geometry().constGet() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( f.hasGeometry() )
src/app/qgsmaptoolreverseline.cpp
Outdated
else | ||
{ | ||
|
||
std::unique_ptr<QgsCurve> line( static_cast<QgsCurve *>( f.geometry().constGet()->clone() ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra clone happening here which isn't needed - you should be able to get away with
geom = QgsGeometry( static_cast< const QgsCurve* >( f.geometry().constGet() )->reversed() );
I agree that this can be done by an in place treatment through the toolbox, but I'm +1 with @nirvn From a draftsman's point of view, we more often use the "click-click" tools rather than the toolbox or the expression calc. @nyalldawson thanks for the review |
@lbartoletti , regarding the "click-click" behavior, that's something that could be achieved via in-place processing algorithm (for e.g., we could "select" an algorithm, and a click on a given feature on the canvas could apply that algorithm to this singular feature). That could be nice in addition to "selected features". |
I'm a bit concerned by adding more and more map tools too. |
A small argument in favor of a graphical user interface for this kind of tool is that I have difficulty to imagine (more simply) the change of direction of only one part of a multilinestring since a select feature does not allow to choose the part of its geometry. |
f3d8ec0
to
921bf0a
Compare
@lbartoletti You may want to look at testqgsvertextool.cpp (if you haven't already!). @wonder-sk fought with Travis a lot to get that test working, so maybe there's some clues there which will help get your test passing on Travis too. |
921bf0a
to
52f7f3a
Compare
52f7f3a
to
fb45c27
Compare
@nyalldawson thanks, I changed the point so it clicks on a node and Travis is happy. |
src/app/qgsmaptoolreverseline.cpp
Outdated
Q_UNUSED( e ); | ||
|
||
delete mRubberBand; | ||
mRubberBand = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that a unique_ptr could be used instead?
afbac01
to
e72879e
Compare
I had to remove the Z for circularstring because it was flaky on linux (debian) |
OK to merge? |
Just needs the conflicts fixed.. |
Which conflicts? |
@lbartoletti There's rebase conflicts. Don't worry - a merge would still work. @3nids is this OK to merge for you? |
I proposed to embed it with the reshape tool. I am not fully convinced about this approach though. |
Embedding with reshape action sounds reasonable to me |
I am not so convinced that introducing more and more submenus for buttons is the way to go. But you would probably hide away a lot of other toolbars. If you are into digitizing, then you don't want a lot of these drop down sub menus. You want immediate access to the tools you need. I have waited for ages for a tool to swap line directions. I have instructed my users to go into DB manager and do ST_Reverse in the combination with the primary key in the meantime. Very inconvenient. Now that we have such a tool, please don't hide it away in sub menus. Now that we have user profiles and customization options, why don't we leave it to the user to introduce different profiles where they show and hide various combinations of toolbars and panels? |
You are pretty convincing 😉 Indeed it might only make sense for variations of the same map tool and not for different ones. |
+1 to that! (I'm curious what I'm missing here, but I only can see find 2 merge feature tools?) |
Right, let's merge. THere's universal agreement that the tool is useful, and the code is good. We can tweak ui later ;) |
Description
A new maptools to reverse a (multi)linestring. Very useful for water/road digitzing.
REF: qgis/QGIS-Enhancement-Proposals#106 6. Swap Direction
Demonstration
data's demonstration:
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and contain sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit