It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, following our effort to integrate klayout within qucs, we are developing a new plugin (entire framework is C++ and we link directly KLayout libraries).
Now, in this plugin (child of edt::Service) we create a lay::Marker to follow some "drag" activity by the mouse.
Here there is something we don't comprehend: at the beginning (blank layout) everything works fine.
After loading a gds in the current layoutView, we switch again the view mode to the new plugin but the marker is not shown anymore.
All events are handled correctly to the plugin and we enforce the layoutView->show_markers(true).
Apparently, loading a gds into the view changes some behaviour of the view itself but we cannot figure out what.
Any hint? Thanks!
Alessio
Comments
Hi Alessio,
do you have some code you can share?
Right now, markers do not survive a change of the files inside the view. Markers are not intended as persisting objects, but rather short-lived annotations - such as error markers.
Maybe you can register your plugin to listen to events on the view and regenerate the markers after such a change, or you use a QTimer to regularly check if the marker is still alive. But I have not tried one of these options myself.
I guess it's possible to change the KLayout code to have markers survive a file operation. But that's worth a ticket on GitHub.
Regards,
Matthias
Hi Matthias,
Thanks for the prompt follow up.
The issue is that, even if we create a new marker (after the layout has been loaded), it's not visible.
Here follows the relevant code:
1. at beginning (empty layout) and
2. after layout load we switch to our plugin which is created from its factory with top (0) priority
Then here the handler of mouse event (overriding edt::Service)
Procedure to update mouse cursor and (hopefully) marker:
Procedure to update the marker
This is called each time mouse is pressed
This is called each time mouse is release (delete the marker)
At mouse release we cancel the marker
So, as you can see, the code is (or should be) pretty straightforward. This means that we are doing something wrong but we really cannot figure out what.
Thank you very much!
Alessio
Hi Matthias,
I have found something that I don't understand. If I create the marker with
It behaves in the "wrong" way (e.g. I am not able to add custom markers after a file is loaded, as described above).
But, if I use the following construction
(e.g. forcing the cellview_index to 1 in the marker creator)
everything works fine.
Do you see any drawback in the second approach?
Thank you for your precious time.
Best
Alessio
Hi Alessio,
I'm sorry, but I can't support you this way. I need the full code and I need to be able to reproduce the problem in order to debug it. Just some code snippets aren't enough.
I also see you're writing C++ plugins - this is also something I don't support. Please use Python or Ruby - this is the only API that is supported and stable. There is very little documentation apart from the code. I take the freedom to change the C++ API without notice and there is no warranty about compatibility or functionality. Please also be aware of the license implications: there is no license exception for C++ plugins. Your C++ plugin needs to be published under the GPL conditions.
I sense that technically the problem in your case is transfer of the ownership of the marker to the view, but it's hard to investigate without a running system. I guess the object is lost when you load a file due to filetime ties with the layout object. It is very easy to introduce memory corruption problems in C++, specifically if ownership is not handled carefully. Objects may seem to be functional, but in reality they are already dead. Setting the cellview to 1 may change the way the marker object's lifetimes are tied to the layout objects, but again, it is very difficult to guess what is happening with a partial code base and don't assume the C++ API is very consistent.
Matthias
I understand that C++ API is not supported.
Anyway, thank you for the follow up and, yes, we are aware of the GPL obligations.