Smoothly painting a path of straight line segments in Qt5 - qt5

I have a series of straight line segments of varying thickness connected end-to-end to create meandering path. Does anyone know a way to paint this as a smooth meandering line, sort of like vectorizing it? I am using QPainter. I haven't had any success finding an appropriate function in QPainterPath.
The data looks something like this:
[(QPointF, width), (QPointF, width), (QPointF, width), ... ]
Thanks!
EDIT: Added example image
I wanted to leave it open to creative responses, but I am just looking to move from linear interpolation (QPainter::drawLine()) to spline interpolation.

If I understand your question correctly...
Don't draw a line, draw a filled polygon that encloses your line data with the right thickness. Drawback: That requires calculations on your data beforehand.

Related

Halcon - Extract straight edge from XLD

I have a XLD edge, like the one in red in the sample picture below.
I need to extract start/endpoint of straight lines that reppresent it. Hough lines sort of work for this, but the results are not really replicable. minor changes in the contour produce unexpected results.
How can the contours be extracted as straight lines? (blue) with start and finish coordinates?
lines shorter than a specified length should not be counted as separate line.
Contour needs to be converted to a polygon using the following function:
gen_polygons_xld (Object, Polygons, 'ramer', 25.0)
The only adjustable parameter is the alpha (25.0) which decides the approximation threshold.

how can I generate suface mesh non-uniformly using CGAL?

I want to generate surface mesh(3d triangle mesh) non-uniformly,How can I do it with CGAL?
when I use Polygon Mesh Processing package,I got result like this:
all the triangle have almostly same size
But I want to generate triangle mesh like this:
different area have different triangle size, I mean it is adaptively.
It also called anisotropic mesh
Thanks very much!
The function you used in the Polygon Mesh Processing package is named isotropic_remeshing(). Isotropic basically means that all triangles will have the same size. If you want to have more control on the size of the triangles you need to use another method like those in the Mesh_3 package.
You can have a look at this example.

Cartopy aliasing

I have the following issue:
When I transform from one map projection to another using Cartopy, the output picture displays a quite ugly aliasing with "steps" larger than one pixel. I attach the input and output pictures as example.
Input - PlateCarree:
Output - Transformed:
Could anyone explain me why that happens? Is it possible to correct it?

How do I fit a function to a candle plot TH2 in ROOT?

I've collected test data for a system and would like to fit a line to the linear portion of the system.
Here's my current plot, which is very barebones:
This was generated by drawing a TH2D with the CANDLE option, which gives nice error bars. However, neither of the two obvious TH2 fit options, both of which take slices and fit to slices, seems to be able to fit a line to this candle plot. The only clear solution I see is to make an array of TH1Ds corresponding to my X axis, filling them, then extracting their means and standard deviations and using those in a TGraphErrors plot, which makes fitting easy.
Is there a way to fit a line directly in the candle plot? If not, is there a more elegant solution than the one that I outlined above?

Drawing a chart with gradient in Objective C

I'm trying to make a simple app where a chart is drawn with a line and X axis. I want to fill parts of the view enclosed by chart and X axis with gradient. To fill them I use the following code
CGContextSaveGState(c);
CGContextAddPath(c, CGContextCopyPath(c));
CGContextClip(c);
CGContextDrawLinearGradient(c, g, previousPointOfIntersection, intersectionPoint, 0);
CGContextRestoreGState(c);
every time the line crosses the X axis. However, the problem is that the gradient fills the whole view between previous point of intersection and current one.
Is this a right way to draw a gradient for a part of view enclosed by lines?
I'd be very happy to hear any suggestions regarding my problem :)
P.S. here's the code of my class http://pastebin.com/wYiHkuVi
I'd say you don't have the path in the context that you think you do.
If you've "stroked" the path for your graph it's been used up.
Replace your Add Path with:
CGContextAddEllipseInRect(c, self.bounds);
to see if you get some clipping occurring.
If so, then you need to rebuild your path here instead of the AddPath/Ellipse code.