On 7 December 2016 at 21:13, Michael Sué <s...@sf.mpg.de> wrote: > Hi, > >>I used some naive approach, based on QPainter world transform, and the width, >>height and area of the bounding box. > > You probably know that there is system support for this with the function > "QStyleOptionGraphicsItem::levelOfDetailFromTransform". And there is an > example on how to use it: > http://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
Yes, this is exactly how I use it: lod = option->levelOfDetailFromTransform(painter->worldTransform()); Now AFAIU, lod units are pixels per scene's unit. so to know how many pixel wide is a given scene rect, i have to multiply the rect widh by lod. My scene unity can be either 1 micro-meter, 1 milli-metre or 1 inch (dictated by the input document, i might change this in the future). I cannot rely solely on lod, as the graphical feature are in the order of 100 micro-meter to 10 centi-metres (physical size in the real world), and their scene size is expressed in whatever the unit used by the input document. 0.1mm feature is 0.004 in an inch-based scene, and 100.0 in a micro-metre based scene. > >> QRegion seems to be geared toward painting >> management of QWidget, if anyone knows a way to convert a QPainterPath >> into a QRegion, please share! > > You probably read that the docu explicitly recommends to NOT use QRegion in > this way: "This class is not suitable for constructing shapes for rendering, > especially as outlines. Use QPainterPath to create paths and shapes for use > with QPainter." Yes i saw that while looking for more information, I'm not actually using QRegion, but a vector of (potentially intersecting) rectangles. My approach so far is a choice based on lod, from low to high: - draw nothing - draw the bounding rect - draw the rectangles decomposition - draw the polygon decomposition - draw the real path All intermediate representations are pre-calculated and stored, this way paint() is kept lightweight. I still need to experiment to find the right way to take the decision on which painting method is used, and i need as well to "prove" it's worth having 5 different methods. A quick profiling session shows me that drawPath is still the bottleneck, so i might have hit the limit of this technique to improve performance. Thanks a lot for sharing. Chris > > -Michael. > > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest