icons and overlays with python

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

icons and overlays with python

Post by sliptonic »

I like how the the PDN tip object icon gets the overlay. Also items in the sketcher with errors or needing recompute.

I'd like to do something similar in Path to indicate disabled operations but I'm not sure how to get started. Can someone point me to relevant sample code or at least some 'google-ons' where I can get educated?

As the title indicates, I need to do this in python.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: icons and overlays with python

Post by triplus »

AFAIK such functionality was added to the Assembly 3 branch. As there wasn't much interest and to try to upstream the work done in scopes. Like Links, overlay icons ... likely a few more months will be needed before anything happens. If you don't need such functionality ASAP i would suggest to give the AppImage a try:

https://github.com/realthunder/FreeCAD_ ... 3/releases

And test the available overlay icons functionality. You can ask for guidance here:

https://forum.freecadweb.org/viewtopic.php?f=20&t=25712

P.S. If it does exactly what you are after you could i guess try to convince all parties involved to upstream the overlay icons functionality before FreeCAD 0.18 gets released. For Links we are likely too late now and have missed that chance. Overlay icons scope likely still is achievable. Especially if you will be able to confirm it is the functionality you need and it does the job.
User avatar
wandererfan
Veteran
Posts: 6324
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: icons and overlays with python

Post by wandererfan »

sliptonic wrote: Thu Oct 18, 2018 7:21 pm I like how the the PDN tip object icon gets the overlay. Also items in the sketcher with errors or needing recompute.
Not exactly what you asked for, but look at ../Mod/PartDesign/Gui/ViewProvider.cpp - specifically
"QIcon ViewProvider::mergeTip(QIcon orig) const".

It uses XPM icons. :(

I'd just make 2 icons, one for enabled, one for disabled, and tell your ViewProvider(or button or ???) to change over when condition changes.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: icons and overlays with python

Post by wmayer »

The actual algorithm is implemented here: https://github.com/FreeCAD/FreeCAD/blob ... y.cpp#L571

The whole trick is to open a QPainter on an existing QPixmap and then use drawPixmap to paint the overlay icon on top of it. Important for the overlay icon is that the background is transparent.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: icons and overlays with python

Post by Kunda1 »

The actual algorithm is implemented here: https://github.com/FreeCAD/FreeCAD/blob ... y.cpp#L571

The whole trick is to open a QPainter on an existing QPixmap and then use drawPixmap to paint the overlay icon on top of it. Important for the overlay icon is that the background is transparent.
related:
Overlaying icons over a feature https://forum.freecadweb.org/viewtopic. ... 48#p263148
https://github.com/reox/FreeCAD_gitproject/issues/7
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: icons and overlays with python

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply