← Back to team overview

kicad-developers team mailing list archive

constness of HitTest(const wxPoint&)

 

I've seen the notice in the base class and dug around. More than
intermediate values it seems that the only thing get modified around is
the 'selected corner' in ZONE_CONTAINER. It works like a 'last
picked' corner for the zone object (and also as a 'current corner' for
some operations).

Wouldn't be better to rework the class so to set the selected corner
only when sensible (i.e. on a user action, most probably whatever sets
m_CurrentItem would be enough... first guess,
PcbGeneralLocateAndDisplay?) instead of every hit testing (which would
occur even on internal computations, for example)? That would make
*every* HitTest variant const (if I didn't miss something)

I think the design issue is that the zone has the selected part as an
internal state, but I reckon that would be very difficult to fix (I have
no better place to store it, at the moment, especially during edit): the
problem is that a zone is a composite object, so m_CurrentItem is not
enough to address it.
But, for example, MoveEdge could have the edge passed as an argument
instead of using object state (would you use a string class with only
embedded pointers and no positions in member calls?)

(By the way, it's fun that, except on adding a new corner, the
SetSelectedCorner is always called with the result of
GetSelectedCorner...)

Any comment?

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups