[Merkaartor] Something about Interaction/Interaction.h

Yves Goergen nospam.list at unclassified.de
Fri Jan 2 23:45:47 GMT 2009


I'm currently on my way through the Merkaartor source code. My first
goal is to implement the following functionality:

* Add toolbar buttons for creating a node/way/area [done]
* Make those toolbuttons and Select and Move checkable [done]
* Always check the one of those buttons depending on which mode we're in

When the active "edit mode" button is checked, you can see very quickly
what the mouse button is going to do when you press it. (Also good to
know if the mode changes after an action, like creating an area, but not
after creating a node. Good visualisation is part of good usability.)
Since the only place that has the definite control over those
interaction modes is the MapView, this should be the class that tells
the others what's the active mode. I'd add a signal to MapView and a
slot to MainWindow. I'd pass that signal the current Interaction object,
so that the signal receiver (here MainWindow) can decide upon the
subtype what button should be set checked. This makes the event
mechanism extensible to other interactions.

Now comes one of the major problems I have with C++: The compiler is
basically dumb and helpless. It needs to be told where to find what
type. Every single header file must be included in the correct order,
cycles must be avoided. It's very hard to include all required header
files if one of those header files includes code that itself requires
other types which cannot be included because it would end up in a cycle.
(C# or Java are much nicer here because they find types on their own and
don't need such advance declaration.)

Interaction/Interaction.h is one of them, as far as I can see. It
contains the class declaration of Interaction, but also contains the
class declaration *and* definition (= code) of another class that I'm
not interested in for now, but that uses a type whose header file again
includes MainWindow.h, which at that inclusion cycle point is not
declared yet. So I cannot include Interaction.h in MainWindow.h. I need
to include Interaction.h because otherwise the slot signature won't work.

Is there a chance that Interaction.h could be split up in Interaction.h,
GenericFeatureSnapInteraction.h and GenericFeatureSnapInteraction.cpp to
clean it up and make that header inclusion possible?

-- 
Yves Goergen "LonelyPixel" <nospam.list at unclassified.de>
Visit my web laboratory at http://beta.unclassified.de




More information about the Merkaartor mailing list