Ticket #1903 (closed feature: fixed)

Opened 4 years ago

Last modified 4 years ago

add support for modify callback to sketch handlers

Reported by: tschaub Owned by: tschaub
Priority: minor Milestone: 2.8 Release
Component: Handler Version: 2.7
Keywords: Cc:
State: Complete

Description

The sketch handlers currently let their control know when they are done, and in the case of line and poly, when each new point is added. It is also useful to know of every change in the sketch (each mouse movement).

Attachments

sketch_handlers.patch Download (27.0 KB) - added by tschaub 4 years ago.
add modify callback support to sketch handlers

Change History

Changed 4 years ago by tschaub

  • state set to Review

What this patch does:

  1. Adds tests to Path.html, Polygon.html, and Point.html for named callbacks. There were no tests for callbacks before. Relevant to this ticket are tests for the new "modify" callback.
  1. In Polygon.js, the createFeature method is modified so that all sketch features (point, line, and polygon) share geometries. This is useful for managing geometries. If something else wants to change the sketch, all parts are affected.
  1. In Polygon.js, the modifyFeature method now gets a pixel arg. The translation from pixel to map location is written once here (instead of twice in Path.js methods). The modifyFeature method calls the named "modify" callback with each modification of the sketch. Because geometries are shared, we modify just the point (and clear bounds there). The rest of the sketch parts are modified for free.
  1. In Polygon.js, we no longer conditionally destroy the left over point if persist is true. Instead we always remove it (remove makes sure it exists). We don't want to destroy this feature because it shares a geometry with the other sketch parts.
  1. In Point.js, a modifyFeature method is added that does the pixel to map location translation and calls the named "modify" callback.
  1. In Path.js, the createFeature method (as with other sketch handlers) now takes a pixel and does the translation. Again, geometries are shared among sketch parts.
  1. In Path.js, the destroyPoint method becomes removePoint since we need to preserve the geometry for other sketch parts.
  1. In Path.js, the addPoint method (as with createFeature and modifyFeature) takes a pixel.
  1. In Path.js, the modifyFeature method does the pixel to map location translation, modifies the point geometry, and calls the "modify" callback.

All tests pass (in FF3). All relevant examples work (draw-feature.html, modify-feature.html, drag-feature.html, measure.html). Thanks for the review.

Changed 4 years ago by tschaub

add modify callback support to sketch handlers

Changed 4 years ago by ahocevar

  • state changed from Review to Commit

Great work Tim! A few very minor things:

  • in Handler/Polygon.js::createFeature: the pixel argument is not mentioned in the ND comment
  • in Handler/Path.js::createFeature, ::addPoint and ::modifyFeature: same as above

I also ran relevant tests and examples in IE7, and they pass. Please commit.

Changed 4 years ago by tschaub

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [8831]) Adding support for a modify callback in the sketch handlers. This lets controls know about each sketch modification as a sketch is being drawn. Also a bit of a refactor of the sketch handlers to share sketch geometry parts. r=ahocevar (closes #1903)

Note: See TracTickets for help on using tickets.