New feature: Quicklook for macOS, make a pull request?

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!
User avatar
matthiaswm
Posts: 35
Joined: Wed Nov 18, 2020 11:41 am
Location: Düsseldorf, Germany

New feature: Quicklook for macOS, make a pull request?

Post by matthiaswm »

Hi devs,

I wrote a QuickLook plugin that shows the contents of an FCStd file already in the Finder ("Browser" on MSWindows). In macOS, this is a super convenient function of the OS. Similar apps exist for Windows and Linux, in case someone feels like implementing this for this platforms as well.

Are you interested in this addition? If so, I would make it part of the CMake build, and I assume I make that into a GitHub Pull Request to the current HEAD? If included, it becomes transparent in the build process and installs itself as part of the package. Signiing may be needed when that is implemented.

- Matthias
Attachments
Screenshot 2022-09-10 at 16.49.34.jpg
Screenshot 2022-09-10 at 16.49.34.jpg (467.49 KiB) Viewed 1685 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by Kunda1 »

Yes indeed! Please make a PR and reference this forum thread!
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
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by adrianinsaval »

is it actually rendering the 3d object or just using the embedded thumbnail image?
User avatar
matthiaswm
Posts: 35
Joined: Wed Nov 18, 2020 11:41 am
Location: Düsseldorf, Germany

Re: New feature: Quicklook for macOS, make a pull request?

Post by matthiaswm »

Kunda1 wrote: Sun Sep 11, 2022 1:14 am Yes indeed! Please make a PR and reference this forum thread!
Pull request is in: https://github.com/FreeCAD/FreeCAD/pull/7491 . Looking forward to get feedback.

I will elsewhere try to get some more information how to better build the macOS M1 app bundle. Testing via homebrew was quite time consuming.
adrianinsaval wrote: Sun Sep 11, 2022 10:04 pm is it actually rendering the 3d object or just using the embedded thumbnail image?
It is extracting the embedded thumbnail. For the icon preview, the resolution is good enough, and extracting the png form the zip archive should be fast enough, even for directories with many project files.

For the preview function, I feel that launching FreeCAD, even if it is only the command line version, to generate the view is almost as time consuming as just launching the app, so I decided to use a scaled up version of the embedded thumbnail. It's not beautiful, but it does the job of telling the user what's inside the file.

I would like to improve the thumbnail quality at some point though by using oversampling to get better scaling.

Matthias
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by Kunda1 »

matthiaswm wrote: Wed Sep 14, 2022 10:28 pm Pull request is in: https://github.com/FreeCAD/FreeCAD/pull/7491 . Looking forward to get feedback.
Sweet Thank you!
matthiaswm wrote: Wed Sep 14, 2022 10:28 pm I will elsewhere try to get some more information how to better build the macOS M1 app bundle. Testing via homebrew was quite time consuming.
Indeed. lots of devs use ccache (https://wiki.freecadweb.org/Compiling_(Speeding_up).
matthiaswm wrote: Wed Sep 14, 2022 10:28 pm I would like to improve the thumbnail quality at some point though by using oversampling to get better scaling.
Do you mind opening a feature request ticket for this so we can keep track of it ?
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
matthiaswm
Posts: 35
Joined: Wed Nov 18, 2020 11:41 am
Location: Düsseldorf, Germany

Re: New feature: Quicklook for macOS, make a pull request?

Post by matthiaswm »

Kunda1 wrote: Thu Sep 15, 2022 2:22 pm
matthiaswm wrote: Wed Sep 14, 2022 10:28 pm I would like to improve the thumbnail quality at some point though by using oversampling to get better scaling.
Do you mind opening a feature request ticket for this so we can keep track of it ?
Done: https://github.com/FreeCAD/FreeCAD/issues/7501

Edit: Formatting
User avatar
jonasb
Posts: 162
Joined: Tue Dec 22, 2020 7:57 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by jonasb »

matthiaswm wrote: Wed Sep 14, 2022 10:28 pm For the preview function, I feel that launching FreeCAD, even if it is only the command line version, to generate the view is almost as time consuming as just launching the app, so I decided to use a scaled up version of the embedded thumbnail.
This is something I cannot confirm, here on some older hardware. Launching FreeCAD takes at least 20 Seconds while using the CLI only (i.e. with launching `--console`) takes perhaps half a Second.

Have you seen Yorik's Offscreen Render Utils? While I could not get the png export to work (apparently there's a lib missing in the conda bundle, I get Coin error in SbBool SoOffscreenRenderer::writeToFile(const SbString &, const SbName &) const(): simage library not available.) I tried another route: export to obj, which my Finder can display directly (maybe because of an installed XCode, though).

This little snipped, saved as "offscreenrendertest.py", ...

Code: Select all

# found here: https://forum.freecadweb.org/viewtopic.php?t=37384
# https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Arch/OfflineRenderingUtils.py

import FreeCAD
import OfflineRenderingUtils
import importOBJ

doc = FreeCAD.open("...../some.FCStd")
importOBJ.export(doc.Objects, "...../some.obj")

exit()
... and executed with ...

Code: Select all

time /Applications/FreeCAD.app/Contents/MacOS/FreeCAD --console offscreenrendertest.py
produced the .obj in 0.539 Seconds, and Finder's preview renders it nicely as 3D object. You can even change the camera by dragging the mouse around.

I did not found the time to try your patch yet, but I find it a very welcome contribution, thanks a lot!
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by adrianinsaval »

I think 0.539 can be a lot if there are many files in a folder, if producing just an image is more performant then that could be usable.
User avatar
jonasb
Posts: 162
Joined: Tue Dec 22, 2020 7:57 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by jonasb »

adrianinsaval wrote: Thu Sep 15, 2022 9:34 pm I think 0.539 can be a lot if there are many files in a folder, if producing just an image is more performant then that could be usable.
Absolutely right. For the preview image in the file browser, I also think that using the embedded thumbnail is the way to go.

My suggestion, using FreeCAD's CLI to convert an FCStd into something (3D) macOS can display natively, aims at this "quick look" feature. This is where you can see the big, upscaled, image in the OP's screenshot. This feature is not trigged automatically for all files in a folder, but rather explicitly by the user for a single file. And for that, half a Second is just fine. Especially when you get not only an image, but a fully rotatable 3D view.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: New feature: Quicklook for macOS, make a pull request?

Post by adrianinsaval »

I see, then it makes a lot of sense
Post Reply