Do not snap features that are invisible

Added by Mathieu Leplatre almost 2 years ago

If a feature is not drawn on screen (because of zoom level for example), the mouse will snap it regardless of its visibility. IHMO, this could be optional.

I looked into Interaction::updateSnap(QMouseEvent*), and indeed it only checks if the layer is visible, but does not check whether the painter should draw it or not.

How would you design this optimization ?

I thought of :

  • adding a method on painters :
bool FeaturePainter::isDrawn(Way *R)
{  
    qreal WW = PixelPerM*R->widthOf()*ForegroundScale+ForegroundOffset;
    return WW > 0;
}
  • testing it in Interaction::updateSnap()
    const FeaturePainter* paintsel = F->getPainter(view()->pixelPerM());
    if (paintsel && !paintsel->isDrawn(F))
        continue;

Would it be acceptable ?
If you're interested, I can work on it to make it a Merkaartor preference, otherwise I'll do it on my branch.

Thanks again,
Mathieu