[Marble-devel] User interaction with data in a LayerInterface subclass

Amit Chaudhuri amit.k.chaudhuri at gmail.com
Sun May 13 09:38:31 UTC 2012

Torsten, Dennis, (Konrad),

Many thanks for the pointers.  Below is an outline of the approach I've
used and some questions about the GeoGraphicsLineString idea.

For my working proof of concept [?] based on
Geopainter::regionFromEllipse...the approach eventually taken was as

   - create a simple class to hold string info I am interested in (e.g.
   name of thing being hovered over) plus a QRegion object
   - hold a QList of pointers to heap objects of above class (enables
   calling of methods to report e.g. 'name' or 'contains') in the
   LayerInterface subclass
   - also hold a QHash of strings & pointers to the class heap objects  to
   uniquely id each item and to allow pointer look up from string
   - eventFilter picks up MouseMove events and I iterate over the QList
   calling 'contains' - a method in my simple class which uses the
   QRegion::contains(QPoint) method
   - render clears both the QList & QHash and deletes heap objects
   - render calls my database to get the info I paint into the layer and
   checks each item agains the QHash. Items not hashed are drawn by a method
   which wraps Geopainter::drawEllipsecreated and extracts the corresponding
   QRegion.  This is checked to make sure it is non-empty  and if ok we create
   the simple class instance on the heap including the crucial QRegion.

I found I had to be careful to not consume the mouse events in order to
preserve MarbleWidget's own mouse interactions.  Also, it was important to
refresh my containers to avoid remembering an old position for a previous
view of the map.  Will extend to cover lines next perhaps and look at how
to report the hover results to the user. [ At present I only report to
qDebug() ]

I'd be interested in exploring the alternative idea of using
GeoGraphicsLineString.  And I'd be happy to look at the possibility of
adding the missing mouse support. But a few things are unclear to me at
this stage:

   - what additional advantage does the GeoGraphicsLineString route promise?
   - IIRC GeoGraphicsLineString has no draw or paint method but acts as a
   container for points; how would you see the drawing being done?
   - can such an implementation still use the LayerInterface style of
   approach, or does it require a completely different starting point (e.g.
   creating GraphicsScenes etc)?
   - logically where do you see the missing mouse event handling being



On Wed, May 9, 2012 at 1:00 PM, <marble-devel-request at kde.org> wrote:

> Today's Topics:
>   1. Re: User interaction with data in a LayerInterface        subclass
>      (Torsten Rahn)
>   2. Re: User interaction with data in a LayerInterface subclass
>      (Dennis Nienh?ser)
> ----------------------------------------------------------------------
> Message: 1
> Date: Wed, 9 May 2012 08:06:24 +0200
> From: "Torsten Rahn" <tackat at t-online.de>
> To: marble-devel at kde.org
> Subject: Re: [Marble-devel] User interaction with data in a
>        LayerInterface  subclass
> Message-ID: <201205090806.24649.torsten at kde.org>
> Content-Type: Text/Plain;  charset="iso-8859-15"
> On Dienstag, 8. Mai 2012 21:08:18 Amit Chaudhuri wrote:
> > I want to be able to interact with individual lines or nodes by hovering
> > with a mouse, double clicking or selection through a menu.  I want to
> show
> > data such as a node code or a description when an item is hovered over.
> Ideally the solution would be to use GeoGraphicsLineString  from
> marble/src/lib/geodata/graphicsitem (This should work in a similar manner
> to
> GraphicsView), but IIRC it lacks mouse interaction so far (we'd be happy
> about
> patches that would provide this functionality though).
> For its implementation (or for your own GeoPainter based one) you need a
> way
> to interact with the drawn line though: In order to determine whether the
> linestring  is "hovered" by the mouse you could use
>  QRegion GeoPainter::regionFromPolyline ( const GeoDataLineString &
> lineString,  qreal strokeWidth = 3 ) const;
> which has been there for this actual purpose.
> BR,
> Torsten
> Message: 2
> Date: Wed, 9 May 2012 09:42:39 +0200
> From: Dennis Nienh?ser <earthwings at gentoo.org>
> To: <marble-devel at kde.org>
> Subject: Re: [Marble-devel] User interaction with data in a
>        LayerInterface subclass
> Message-ID: <4FAA1FEF.9030003 at gentoo.org>
> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
> Am 09.05.2012 08:06, schrieb Torsten Rahn:
> > On Dienstag, 8. Mai 2012 21:08:18 Amit Chaudhuri wrote:

> An example implementation of an interactive layer is in
> src/lib/routing/RoutingLayer. Among other things it implements reaction
> to hovering using the regionFromPolyline method.
> Regards,
> Dennis
> ------------------------------
> _______________________________________________
> Marble-devel mailing list
> Marble-devel at kde.org
> https://mail.kde.org/mailman/listinfo/marble-devel
> End of Marble-devel Digest, Vol 57, Issue 17
> ********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20120513/3ee0a6c4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 330.gif
Type: image/gif
Size: 96 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20120513/3ee0a6c4/attachment-0001.gif>

More information about the Marble-devel mailing list