Registered Member
|
I'm interested in drawing on a MarbleWidget, and the Marble tutorials present two ways to do this: subclass MarbleWidget and override the customPaint function, or subclass LayerInterface and write a render function. I like LayerInterface, but I'd like the objects I draw to stay the same size as users zoom in and out of the map. This seems to work well enough using the customPaint approach, but I'd like to paint in the "HOVERS_ABOVE_SURFACE" layer.
1) Is it possible to use LayerInterface, but to somehow specify that objects shouldn't respond to geometry changes? 2) Is there a better way to do this? What I'd really like is to have something like a GeoDataPlacemark, but that gets drawn very differently (I need pie charts). I considered subclassing GeoDataPlacemark, but it looks like the drawing is done by a GeoGraphicsItem subclass in GeometryLayer, and subclassing GeoGraphicsItem would be fine, but GeometryLayer wouldn't know what kind of GeoGraphicsItem to return, and subclassing GeometryLayer looks like a nightmare that would basically involve rewriting the whole class to be nearly identical, except that it could return my custom GeoGraphicsItem subclass, and then subclassing a whole lot of other classes to use my custom GeometryLayer subclass. Thanks for any thoughts. |
KDE Developer
|
Here's a solution using a custom rendering class derived from LayerInterface. To keep it simple I implemented only basic culling and no collision detection. Pies are kept at the same size by using (mostly) the original QPainter methods for drawing and doing the geo coordinates => screen coordinates conversion via ViewportParams. It looks like that:
Source (compiles against current master, older versions will need some slight changes. Data is public domain from CIA World Factbook):
Another possible approach would be to implement a new online service for it (see e.g. src/plugins/render/earthquake/). Being able to provide a custom placemark render delegate would indeed be nice, but so far nobody worked on that. Maybe you can file a feature request for it? |
Registered Member
|
Thanks! I actually came up with a similar solution on my own, and forgot to check back in.
A feature request is a great idea, though. I'll do that. |
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]