Registered Member
|
Hi all,
I'm using Marble to incorporate a more sophisticated looking map into an existing piece of software. I have been using the LayerInterface class to draw markers, such as simple rectangles and circles. My class is derived from the example in the "Documentation" section of the website. The GeoPainter::drawRect() and GeoPainter::drawEllipse() overloaded functions have an instance where I can declare the center point using GeoDataCoordinates and then describe the width and height. I would like to implement this for different shaped polygons (say, for a diamond) because I haven't found any existing functions in GeoPainter for this. Yes, I do realize there are the drawConvexPolygon() and drawPolygon() functions, but they don't have an instance for me to set it as a fixed size at a specified location on the map. If anyone knows of a way to do what I'm asking for please let me know. Thanks, Matt |
KDE Developer
|
The simplest way is to do the GeoDataCoordinates/ScreenCoordinates transformation yourself and use GeoPainter like a plain QPainter. Similar to this example drawing a big star:
|
Registered Member
|
Thank you so much Earthwings. I was unaware of that screenCoordinates() call. I was wondering if you could answer me this though. I'm trying to draw an open polygon, but the drawPolygon() function keeps connecting the last QPointF with the first. Here is my code:
The QPointF m_center is what I fed into the screenCoordinates() call and int m_targetSize is the height and width of the marker I am trying to draw. This should be the bottom half of a "plus sign", without the line going horizontally across the center. Should I possibly simply try drawing lines instead of using a polygon, because the GeoDataLinearRing doesn't work either? |
KDE Developer
|
QPainter has drawPolygon and drawPolyline - the latter is the one that does not connect the last point to the first. If you switch to it, you should get the behavior you're looking for.
|
KDE Developer
|
Note that the preferred way for adding contents to the map is this approach
http://techbase.kde.org/Projects/Marble ... aPlacemark This is much more highlevel than using GeoPainter and has lots of advantages. |
Registered Member
|
Yes, I initially tried that route, but the symbols I'm trying to overlay are of specific shapes. The GeoDataPlacemark class only provides certain symbols. |
KDE Developer
|
Well you can assign any icon bitmap to the placemark - if that is the issue. Just have a look at the tutorial how it's done with the "Arc of Triumph" photo. You basically create an IconStyle and adjust it to your needs.
If on the other hand you really want some crisp drawn polygons in screencoordinates then the approach Dennis showed is the right one. |
Registered Member
|
Right. I also need to provide the user with the availability to change the linewidth and symbol size in pixels. This seemed like the better approach for that, rather than loading different bitmaps for different symbol sizes/linewidths. Thank you though!
|
KDE Developer
|
Ok, just wanted to make sure you get the best possible solution
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell