Hi Andrea, I have a little time before I start my work-day, but at a glance, I suspect what the issue here is a difference between painter coordinates and a difference between viewbox coordinates, which don't match up.
For your distance object, I would highly recommend you inherit from TextItem <https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/textitem.html>, it offers anchor/position capability, and the text size will remain the same regardless of the zoom level, which appears to be a good chunk of the code that you're trying to manage there. You can add just the little bits you need The example you're trying to work with feels *really* close to the InfiniteLine.py example <https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/InfiniteLine.py>'s usage of pg.TargetItem <https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/graphicsItems/TargetItem.py> (docs for TargetItem <https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/targetitem.html>) (in the examples, the target is a symbol, but it supports drawing any QPainterPath object, and maybe the line underneath the text readout can just be a QPainterPath object that just represents 1 line. Sorry I can't be more specific with where the bug is, but debugging a 500 line python file before my work starts isn't always feasible. Oh, and lastly I would suggest not setting `useOpenGL` while getting the initial version working. While OpenGL can add significant performance boosts, there are a number of bugs (in our library, Qt and the openGL implementations on each OS) that could cause confusion. Best get a non-openGL version working first and go from there. Sorry I can't be more specific. On Wed, May 26, 2021 at 07:50 Andrea Manghi <[email protected]> wrote: > > Hello, > I'm trying to make a little project with PyQtGraph. > Briefly, my goal is to draw a sort of ruler that measures the distance > between three points. > One point is the origin of the measure, and the other two are independent > points. > Something like this: > [image: Screenshot (36).png] > I've tried everything and the best result I managed to obtain is this. > The problem I'm facing is that when I put one line on the common point and > the other under it, like this: > [image: Immagine 2021-05-26 162818.png] > If I click one of the two lines, the design brokes, and I can't understand > why this happens and how to prevent it. > [image: Immagine 2021-05-26 162846.png] > I'd like to understand more precisely how PyQtGraph handles the drawing of > the objects because at the moment I can't comprehend how I could change my > code to make it work as I want. > > -- > You received this message because you are subscribed to the Google Groups > "pyqtgraph" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/43e59f9c-5faf-46d5-8684-8b7e53d3d6f1n%40googlegroups.com > <https://groups.google.com/d/msgid/pyqtgraph/43e59f9c-5faf-46d5-8684-8b7e53d3d6f1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CA%2BnduTFh4njU8ONMJ%2BWMGf1%2B5kXJVanA8Vi-K-nLoR4XBjsDFg%40mail.gmail.com.
