[Interest] Zooming with QGraphicsView/QGraphicsItem

Israel Brewster ijbrewster at alaska.edu
Sat Aug 10 16:44:29 CEST 2019


> On Aug 10, 2019, at 12:08 AM, Nyall Dawson <nyall.dawson at gmail.com> wrote:
> 
> On Sat, 10 Aug 2019 at 01:55, Israel Brewster <ijbrewster at alaska.edu <mailto:ijbrewster at alaska.edu>> wrote:
>> 
>> Thank you. QGis did indeed allow me to open my Shapefiles and save them as SVG (though it messed up the viewBox attribute, so I’m still trying to figure out how to get that to not crop the image).
> 
> That's due to an unfortunate, long-standing Qt bug (Qt SVG export from
> QPainter ignores clipping paths).
> 
> Nyall

I see. Well, in a sense it actually worked out well for me. When I tried to export the full map image, some of the smaller features (particularly some of the Aleutian islands in which I am most interested) weren’t saved to the SVG at all (even when zooming in on the resulting SVG they didn’t show up). It was only when I limited the save to a portion of the map that I got all the features. I was thinking I was going to have to use two or three smaller SVG’s, each with a portion of the globe, but since the clipping paths were ignored, the SVG I got actually *did* contain all the data - I just had to futz around with the viewBox to get it to show it all :-)

So yeah, that’s a bug, but in this *specific* case the bug actually worked in my favor :-)
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

> 
> 
>> ---
>> Israel Brewster
>> Software Engineer
>> Alaska Volcano Observatory
>> Geophysical Institute - UAF
>> 2156 Koyukuk Drive
>> Fairbanks AK 99775-7320
>> Work: 907-474-5172
>> cell:  907-328-9145
>> 
>> On Aug 8, 2019, at 8:19 AM, Francis Herne <mail at flherne.uk> wrote:
>> 
>> You should definitely look at QGIS:
>> https://qgis.org/en/site/index.html
>> 
>> It's open-source and has an excellent map-rendering implementation including shapefile support.
>> 
>> -Francis H
>> 
>> ________________________________
>> From: Israel Brewster <ijbrewster at alaska.edu>
>> Sent: 8 August 2019 16:55:49 BST
>> To: Brad Pepers <bpepers at me.com>
>> Cc: Interest <interest at qt-project.org>
>> Subject: Re: [Interest] Zooming with QGraphicsView/QGraphicsItem
>> 
>> I do have .shp files for the coastlines - perhaps I could convert those to something I could use? If I can get vector data, how would I go about utilizing it?
>> 
>> I played around a bit with loading different image files, but so far the performance has been unacceptable - the entire app locks up for several seconds when displaying the higher resolution images. I think Vector would be a better way to go, if I can figure out how. Thanks!
>> ---
>> Israel Brewster
>> Software Engineer
>> Alaska Volcano Observatory
>> Geophysical Institute - UAF
>> 2156 Koyukuk Drive
>> Fairbanks AK 99775-7320
>> Work: 907-474-5172
>> cell:  907-328-9145
>> 
>> On Aug 7, 2019, at 10:12 PM, Brad Pepers <bpepers at me.com> wrote:
>> 
>> In the end the answer is to get the coast as vector data instead of a raster. The raster is going to be at a fixed map scale and any scale above or below is going to extrapolate or interpolate the results eventually ending in poor results because there just isn’t the information needed or too much information is being lost. Having different resolutions should help and you can keep multiple levels and switch between them at appropriate times (LOD). Those are your best bets if you can’t get the actual vector data!
>> 
>> --
>> Brad
>> 
>> 
>> On Aug 7, 2019, at 12:01 PM, Israel Brewster <ijbrewster at alaska.edu> wrote:
>> 
>> I have a QGraphicsScene/QGraphicsView that I am using to display a map (and some data). The map is in the mercator projection, with the x and y coordinates of the scene corresponding to map coordinates, so the background images are rather large. Images are loaded into a QGraphicsObject which is then added to the scene. The object types are defined by a third-party library, so I don’t have the option of using different objects, such as QGraphicsPixmapObject or something.
>> 
>> This works fine when I’m zoomed in to the map. Coastlines are nice and sharp, with no issues:
>> <Screen Shot 2019-08-07 at 9.50.10 AM.png>
>> 
>> However, when I zoom out, the coastline becomes quite pixelated, and difficult to see in places:
>> <Screen Shot 2019-08-07 at 9.50.28 AM.png>
>> 
>> How can I fix this? My first thought was to change the size of the background image so it could scale better, but that didn’t seem to help. In retrospect, this makes sense: at the end of the day, the background image has to be the correct size for the mercator projection, so while I can certainly change the pixel density, the overall size, and thus how much scaling is needed to display a given area, is fixed.
>> 
>> ---
>> Israel Brewster
>> Software Engineer
>> Alaska Volcano Observatory
>> Geophysical Institute - UAF
>> 2156 Koyukuk Drive
>> Fairbanks AK 99775-7320
>> Work: 907-474-5172
>> cell:  907-328-9145
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> https://lists.qt-project.org/listinfo/interest
>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> https://lists.qt-project.org/listinfo/interest <https://lists.qt-project.org/listinfo/interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190810/1f3952c0/attachment.html>


More information about the Interest mailing list