edi wrote: ↑
Fri May 07, 2021 3:46 pm
The goal of TechDrawTools.FCMacro was, to create a container which stays active - whatever is done in FC - until it is closed by the user. chrisb gave me a hint to Macro_FCCamera.FCMacro published by mario52, which I used as guide.
Unfortunately this (wrong) usage of QMainWindow+StayOnTopHint is present a lot in FreeCAD wiki and probably had spread itself in the past. That's why I started the tutorial (WIP).
I adopted your method which is using PySide2. It is working. In PySide2 many methods changed from QtGui to QtWidgets.
You may actually have kept PySide. The important thing is to use QDialog+Tool.
Compared with the old method (using PySide) the difference is, that the window disappeares if the user swaps from FreeCAD to another program, and is back if the user returns to FreeCAD again.
That's it. Which is far better (IMO) particularly if you have only one screen. I don't want to go doing some web browsing and get the TechDrawTools window over my browser.
Also there are other differences you may not have seen :
* With new method, you have only one FC window in the OS task bar. With old QMainWindow, you had 2 which is a bit weird
* With new method you keep only one Qt event loop. QMainWindow creates a second independent event loop, which may lead to issues if you close FC main window while TechDrawTools dialog is open. Now it's clean.
To your macro: I am far away from appreciating it in detail, but tested the selection observer using a TechDraw document.
Not sure this is a good idea. There is some specific things with selection in TechDraw and maybe SelectionObserver isn't really friend with them.
- If selecting a TechDraw geometric element (vertex or line) then addselection is called twice:
at "mouse DOWN" the selected view is returned in obj, an empty string in sub is returned
at "mouse UP" the selected view is returned in obj and the selected vertex or line is returned in sub
pnt is allways returned as (0.0,0.0,0.0)
I guess it is a problem of defining the type of the event in addEventCallback.
My guess is that you maybe found a bug in TechDraw.
Is it possible to obtain the mouse status (UP, DOWN, LEFT, RIGHT) ?
No it isn't. The selection observer is just propagating the 'addSelection' to a custom class. It ignores the way/reason 'addSelection' has been originally called.