Skip to content
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

[FEATURE] Map guides #55883

Closed
wants to merge 10 commits into from
Closed

[FEATURE] Map guides #55883

wants to merge 10 commits into from

Conversation

3nids
Copy link
Member

@3nids 3nids commented Jan 18, 2024

This introduces map guides in advanced digitizing.

Map guides are saved in an annotation layer (i.e. in the project) and can be either points or lines/curves.

For now, this introduces 4 map tools to create guides:

  • distance to 2 points
  • line extension
  • parallel
  • perpendicular

There is no spatial index of the guides. We assume for now that the number of guides will not be large enough to justify this.

Once the CRS is set (as soon as the first guide is added), it is kept even if the project CRS changes. This means that a transform will take place in the snapping.
Introducing a process to transform the guides sounds like an overkill.

cad.mov

@github-actions github-actions bot added this to the 3.36.0 milestone Jan 18, 2024
@3nids
Copy link
Member Author

3nids commented Jan 18, 2024

I would have like to get this in for 3.36, but couldn't make it soon enough. Let's see if this raises discussions :)

Tests for the snapping are coming.

/**
* \ingroup gui
* \brief The QgsDigitizingGuideMapTool is a base class for map tools drawing map guides
* \since QGIS 3.34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.36 or 3.38. Several similar instances below

@@ -0,0 +1,561 @@
/***************************************************************************
qgsdigitizingguidemaptool.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
qgsdigitizingguidemaptool.h
qgsdigitizingguidemaptool.cpp

{
mCenterRubberBand.reset( new QgsRubberBand( mCanvas, Qgis::GeometryType::Point ) );
mCenterRubberBand->setIcon( QgsRubberBand::ICON_CROSS );
//mCenterRubberBand->setWidth( QgsGuiUtils::scaleIconSize( 8 ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//mCenterRubberBand->setWidth( QgsGuiUtils::scaleIconSize( 8 ) );

if ( mDistances.count() < 2 )
{
QInputDialog *d = new QInputDialog;
//d->setDialogTitle( tr( "Distance to point" ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//d->setDialogTitle( tr( "Distance to point" ) );

const QgsPointXY &s1 = mSegment->first;
const QgsPointXY &s2 = mSegment->second;

const double nx = s2.y() - s1.y();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some high level comment about what all the below maths is trying to accomplish would be welcome :-)
I'd note that there's a division by zero if s1 == s2

Wondering if there wouldn't be value to move the computation part to some non-GUI method in case it might be helpful (but no strong opinion)

QList< QgsAnnotationItemNode > nodes() const override;
Qgis::AnnotationItemEditOperationResult applyEdit( QgsAbstractAnnotationItemEditOperation *operation ) override;
QgsAnnotationItemEditOperationTransientResults *transientEditResults( QgsAbstractAnnotationItemEditOperation *operation ) override SIP_FACTORY;
virtual bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why adding virtual here ? override already indicates this (not sure about QGIS habits though)

@@ -649,7 +649,7 @@ std::vector<LayerRenderJob> QgsMapRendererJob::prepareJobs( QPainter *painter, Q
job.context()->setElevationMap( job.elevationMap );
}

if ( ( job.renderer->flags() & Qgis::MapLayerRendererFlag::RenderPartialOutputs ) && ( mSettings.flags() & Qgis::MapSettingsFlag::RenderPartialOutput ) )
if ( job.renderer && ( job.renderer->flags() & Qgis::MapLayerRendererFlag::RenderPartialOutputs ) && ( mSettings.flags() & Qgis::MapSettingsFlag::RenderPartialOutput ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are this additional check and the one in qgsmaprenderedparalleljob.cpp specific to the new dev, or bug fixes ? If the later, they should probably be in a separate commit (apologies if it is already the case, but wasn't obvious from looking at commit titles)

@nyalldawson
Copy link
Collaborator

Hmm -- I have reservations. The approach here of storing the guides in an annotation layer makes me uneasy. Why go for this approach? As far as I can see, we'd never want guides to be rendered outside of the mapcanvas so my gut instinct is that rubber bands / canvas items would be a better fit for rendering the guides. And then there's other things which look odd to me, eg why are we needing a creation datetime value for the guide model?

The UI also looks very rough to me. A collapsed group doesn't seem at all appropriate here. I'd prefer a panel stack there. And a proper toolbar instead of the row of custom buttons.

How does this feature relate to the other guides option in the CAD panel? Does it ultimately supersede that? Or will we have two approaches to this?

@uclaros
Copy link
Contributor

uclaros commented Jan 19, 2024

Hmm -- I have reservations.

👍

A plugin to assist drawing such guides in an annotation layer would be more appropriate imho, instead of adding another hidden entity in the project (I'm looking at you default annotation layer!)

@3nids
Copy link
Member Author

3nids commented Jan 22, 2024

Thank you for the valuable feedback.

Canvas Item sounds indeed like a wiser choice, I'll come back later with a refactored implementation.

Regarding the coexistence with current helpers/guides in the Advanced Digitizing tools, the idea here is that you take time to build the guides and keep them around for a while, rather than having them placed during the digitizing process. There are a few reasons to this:

  • guides can be (re)used for several digitizations
  • it's easier to lose time when making error (no need to restart a complete digitization) and the process is more obvious
  • you avoid switching map tools while digitizing

The only overlap I see is with the line extension (but again, having a clear construction process of the guides makes sense).

I will try to improve UX following the comments.
Cheers.

@3nids 3nids marked this pull request as draft January 22, 2024 14:40
@uclaros
Copy link
Contributor

uclaros commented Jan 23, 2024

One can achieve the same goal by adding a point and a line layer to his project and store features as snapping guides. This will have all the proposed pros but also have lots of extra benefits, off the top of my head:

  • Customized symbology / labeling
  • Visibility toggling
  • Tools to spatially select, modify, and export/import such guides to reuse in other project
  • Attributes (creation date, user name, metadata ...)
  • CRS transformation
  • Snap to intersections with other layers
  • Construction mode for complex guides (eg parallel to endpoints of two separate features etc...)
  • Less code

The only overlap I see is with the line extension

Actually, IMO the only non-ovelap is the two circle intersection, which now requires two actual circles to be added as guides.

I would suggest we come up with an elegant way to add the two distances tool to the existing advanced digitizing tools/locks (so far such attempts had a very intrusive ui and terrible ux) and let user manage their guides on their layers of choice.

@nyalldawson nyalldawson added the Frozen Feature freeze - Do not merge! label Feb 1, 2024
@nyalldawson nyalldawson removed the Frozen Feature freeze - Do not merge! label Apr 5, 2024
Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Apr 20, 2024
Copy link

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Apr 27, 2024
@3nids
Copy link
Member Author

3nids commented May 28, 2024

superseded by #57584

@3nids 3nids removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants