Skip to content

[Feat] Add screenshot to clipboard interaction#3184

Draft
yashnator wants to merge 1 commit into
f3d-app:masterfrom
yashnator:feat/clip-screenshot-to-clipboard
Draft

[Feat] Add screenshot to clipboard interaction#3184
yashnator wants to merge 1 commit into
f3d-app:masterfrom
yashnator:feat/clip-screenshot-to-clipboard

Conversation

@yashnator

Copy link
Copy Markdown
Contributor

Describe your changes

Adds the feature to take a screenshot to the clipboard by using Shift + F12

  • Modifies F3DStarter.cxx to handle screenshot to clipboard using clip
  • Modifies CMakeLists for importing clip

Issue ticket number and link if any

Resolves #2304

Checklist for finalizing the PR

AI Disclosure

  • I did not use AI to generate any of the content of that pull request

Continuous integration

Please write a comment to run CI, eg: \ci fast.
See here for more info.

- Modifies F3DStarter.cxx to handle screenshot to clipboard using clip
- Modifies CMakeLists for importing clip

Resolves f3d-app#2304
@mwestphal

Copy link
Copy Markdown
Member

We discussed using a script to test it. Can you tell what exactly the test script should do?

Hum, a bash script could run f3d, trigger the screenshot to clipboard interaction then write the clipboard to a file, then compare that file with a baseline ?

@yashnator

Copy link
Copy Markdown
Contributor Author

write the clipboard to a file

I think that would make the implementation platform-dependent and might require additional dependencies (like pngpaste on macOS). I suggest we write a C++ test that reads the clipboard contents using clip after taking the screenshot, opens a baseline PNG using vtk, and compares the data. What do you think?

@mwestphal

Copy link
Copy Markdown
Member

@Meakk

@Meakk

Meakk commented May 26, 2026

Copy link
Copy Markdown
Member

@yashnator I agree we cannot really rely on a script based test.
We do not have c++ based unit tests in the application though. Also, integrating clip at the library level instead of the application would make sense to me.

Here's my suggestion:

  • Add a new f3d::image API: const image& toClipboard() const;
  • Add a new f3d::image API: const image& setFromClipboard();
  • New APIs throw if F3D_MODULE_CLIP is disabled
  • Add a new libf3d unit test that render to an image and call toClipboard(), creates a new image and call setFromClipboard() and compare images.

The new application command take_screenshot_to_clipboard will look like:

      this->Internals->Engine->getWindow().renderToImage().toClipboard();

Is clip::set_image likely to fail? If not just throw, otherwise toClipboard() may have to return a bool.

When this will be done, you will have to add python/C/Java/JS bindings but focus on the C++ implementation for now.

@yashnator

Copy link
Copy Markdown
Contributor Author

Sounds good. I will update the PR

@mwestphal

Copy link
Copy Markdown
Member

Need any help moving forward @yashnator ?

@yashnator

Copy link
Copy Markdown
Contributor Author

@mwestphal Not yet, I will update the PR tomorrow with some changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "Screenshot to clipboard" interaction

3 participants