-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lay.Marker missing in python standalone module #1655
Comments
Hi Sebastian, Markers are not singletons - you can add as many markers as you like. Display gets kind of sluggish when you have 1 million markers or so, but a thousand should not be an issue. I need to debug why markers don't show with standalong LayoutView. Maybe a similar issue than what we had in the past. The standalone view is special because there is no event loop running in the background and some essential update events may not happen. Thanks for reporting this issue, Matthias |
Thanks Matthias! I am pretty sure the marker class behaves kind of singleton-ish even in the macroeditor in klayout. I will update it later today. I think I won't need 1 million markers ;). I was planning to hard-limit it to a default of 100 anyway, since I need to serialize and deserialize the markers (and RdbItems) and send them through the websocket. |
I think I get some understanding what is going on. First, the functionality of the marker seems to be okay in the standalone module. This code works:
which produces this image: However, this code does not produce two markers, but only one:
The reason is that marker appearance is tied to the object lifetime. When the second object is created, it will replace the first one as they use the same variable. Because of this, the first object is deleted and vanishes. For the same reason, this code does not produce any marker at all:
Here the reason is scope: when the "make_marker" function returns, the marker object stored inside the "marker" variable is destroyed and the marker vanishes. To solve the issue, a reference to the markers need to be kept. A way to doing that is to attach them to the view:
And here are the two markers :) I can basically change the lifetime management for the markers and transfer ownership to the layout view. I just wonder whether that would break existing code. Matthias |
Thanks Matthias! I will use this. Whether to attach it to the LayoutView; I would suggest to do so (I would have expected it to behave similar to a |
Yes, I admit that is kind of freaky, but it has been like this for long now. I could provide an alternative path of creating markers and adding them to the view, thus transferring ownership. Maybe that is easier to work with than to manage the ownership separately. |
I provided the following alternative way for Marker lifetime management:
Matthias |
Thank you Matthias! |
Hello Matthias,
I hope you are doing well.
I am currently trying to use markers in the python qt-less LayoutView (totally not related to #1632 ;) ). I noticed that in KLayout GUI
pya.Marker
works like I would expect (to some degree see bottom). In python (or more specifically the rdb view of kweb 2.0) I cannot get marker(s) to show.I assume there is some backend magic which is disabled (or straight up missing because it's part of the gui) for the python binding?
Best,
Sebastian
P.S. is it possible to make multiple markers show up at the same time? My uneducated guess is the marker is a singleton in C++ (per LayoutView) and thererfore they erase each other, but the marker browser can do it, so I assume there is at least a possibility to do so.
The text was updated successfully, but these errors were encountered: