So I'm using PyQt5 to do 2D rendering for an LED light show creator app. The light shows are graphs where the $Y$-axis is LED brightness level and the $X$-axis is usually time.
I have a zoom feature in my "view" class that zooms the entire scene in or out depending on user input. When you do this, by default, everything in the scene shrinks or explodes just like you're coming closer to or moving farther away from some structures on land and you're at some vertical distance in the air right above the structures.
The zoom feature is needed in case there are extra long light shows in time and the user would like to view the whole graph at once, for example.
I've already gotten the $X$ and $Y$-axes to scale properly, and this was easier than my current problem, since of course the $X$,$Y$-axes are in parallel with the used 2D coordinate system.
It wasn't a simple matter of calling
axesItem.scale(1/sx, 1/sy)("naive") on the axes where $sx, sy$ is the scaling of the view port in the respective directions. I had to individually address each object making up the drawing algorithm of the axes and perform a custom scale to each, so that the end result is correct.
I tried the naive scaling again on the polyline item (what makes up the graph), and that does not work either. So i need to scale the polyline.lineWidth variable that is used in the painting algorithm, instead. However the polyline segments maybe at various angles different from $0$ or $90$ degrees. So given a view scaling of $sx, sy$, what is the formula for scaling the width of a line segment, so that the width alone is perfectly preserved in the eye of the user?