← Back to team overview

kicad-developers team mailing list archive

Re: constness of HitTest(const wxPoint&)

 

On Fri, May 02, 2014 at 06:27:02PM +0200, Maciej Sumiński wrote:
> With the new tool framework, the currently modified part of zone (be it
> corner or edge) is stored internally in the tool that does the modification
> (pcbnew/tools/point_editor.cpp in lp:~cern-kicad/kicad/drawing_tool). To be
> more precise - while editing, you modify location of EDIT_POINTs and when
> you stop dragging, zone corners are updated.

That would be a further evolution of my idea... however I'm trying to
fix *one* thing at a time:P currently I'm proposing to split off the
'implicit' selection change to achieve HitTest constness. Getters with
side effects tend to be quite nasty.

A common pattern I've seen is:

- Set something busy (to exclude it from the search results)
- Do a search
- Remove the busy status

Luckily there aren't many exception around to guard against :P

In an "ideal world" you would say "search excluding this/these"; too bad
that in C++ that's quite involved to achieve (however the collector
classes seems a good step on the right way).

Beyond the risk of forgetting the status change, the above pattern makes
multiple (nested) processes quite difficult (recursive ones even
harder... you did work on the router, think about that:P)

OTOH a good case for the mutable approach is the bounding radius for
a pad: is set to -1 and computed the first time the getter is called;
the getter would be const and m_boundingRadius would be usefully
mutable.

As for the 'current selection' issue many designs could be usefully
done: either use subobjects for the points, parenting to the zone
(picking pads on modules does this); declaring some kind of composite
'current object' (like iterators in STL) or simply ad-hoc processing for
these composite objects (I guess the 'current point' is somewhere in the
'tool' state, instead of modifying the global 'object' state).

(sadly they did this at a very lower level... on the small PICs there is
*exactly one* indirect access register: simply copying a string is
hell...)

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups

References