# -*- mode: org  -*-
#+STARTUP: content

* Fixing bugs

** Proximity of the cursor to a vertex / edge-intersection should depend on the zoom level.

* Adding features

** Disable vertex snapping when vertices not drawn.

** Disable intersection snapping when edges not drawn.

** Add a changeable threshold value for when a label counts as free.

   Currently a label's complete area must be free for it to count as
   free for the "Free labels"-graph.  Perhaps the user might like,
   say, 75% freeness to be enough.

** Add helpful status bar texts.

   - Explain the format of label template.

   - Explain use of mouse buttons.

** Allow network vertices, edges, and routes to be edited/moved/deleted.

   Including undo/redo.

** Show trimmed LabelCandidates on map.

   Currently only the non-trimmed LabelCandidates can be drawn.

   The cleanest way to go about this is to first apply the first two
   refactorings below, so that hourglasses are actually stored with
   routes.  Then, instead of only trimming their start and end
   portals, we need to trim the entire hourglasses.  Once trimmed
   Hourglasses are stored with the routes, this feature is easy to
   add.

** Apart from the "map view", also add an "hourglass view".

   This would show the hourglasses, along with their trimmings, and
   the multitude of paths computed through them.  Currently these
   visualizations can only be produced as Ipe files.

* Code refactoring

** Make new Hourglass a facade for Portals, Funnel, and old Hourglass.

   - Remove Portals class, merging its functionality into Hourglass
     class.

   - Move point-to-point and point-to-edge path computation from
     Funnel into Hourglass.  (May need to re-read the Guibas &
     Hershberger paper for the implementation details.)

   - Move Funnel from hourglass.h into hourglass.cpp, as it is then
     only needed in the Hourglass constructor.

** Remove unnecessary recomputation.

   - Make Hourglass x-coordinates correspond to *distance* along
     route, not *time* along route.

   - Compute Hourglasses + trimmings only once per route (but
     recompute whenever changes to the problem instance demand,
     obviously).

** Speed up finding the vertex or intersection of edges closest to the cursor.

   Currently done by linear search over the graph's O(n) vertices and
   O(m^2) edge-pairs.

   Locating vertices could be done by maintaining a space
   partitioning, such as a quad tree, kd-tree, BSP tree, or Voronoi
   diagram.  A simple non-hierarchical grid will probably work just
   fine for our purposes, however.

   Locating edge-intersections could be done maintaining the
   trapezoidal decomposition induced by the edges.  More simply, we
   could make inserting a new edge take O(m) time to maintain the
   set of edge intersections.  On this set we can then use the same
   point location structure as for the vertices.

** Multi-threaded implementation of statistics gathering.

   This would have been fairly easy to add into the design from the
   start, but at this point it's probably not worth the pain of
   retro-fitting the single-threaded design for multi-threading.

** Make more use of Boost.Range, C++11 auto/lambda, etc. where appropriate.
   - Use STL functions with lambda's.
     (Instead of hand-written loops, or STL functions with function
     objects.)

   - Use rvalue references not just for own/STL classes, but also
     Qt's.

   - Use enum classes.

** Switch from O(n) to O(log n) search where appropriate.

   Usually, this can be done with the STL binary search functions
   (lower_bound, upper_bound, equal_range).

   In some places, however, we seek the minimum or maximum of a
   unimodal array, and I do not believe the STL has a standard
   function for ternary search.  Writing one ourselves is easy,
   though.

** Check if there are any non-static member functions that could be made static.

   Such functions should be made static if they are public or
   protected, and if they are private they can be pulled out of the .h
   file, and into an anonymous namespace in the .cpp file.

** Switch from QPainter to QGraphicsView (?)


