Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Draft label with hyperlink to internal/external doc/pdf/txt #7062

Closed
2 tasks done
PeterPNoster opened this issue Jun 20, 2022 · 12 comments · Fixed by #10878
Closed
2 tasks done

[Feature Request] Draft label with hyperlink to internal/external doc/pdf/txt #7062

PeterPNoster opened this issue Jun 20, 2022 · 12 comments · Fixed by #10878
Assignees
Labels
Feature FR for improvements or new features File format: WebGL Good first issue Suitable issues for potential first-time contributors UI/UX WB Draft Related to the Draft Workbench

Comments

@PeterPNoster
Copy link

PeterPNoster commented Jun 20, 2022

Is there an existing request for this?

  • I have searched the existing requests

Forums discussion

https://forum.freecadweb.org/viewtopic.php?f=23&t=69528

Subproject(s) affected?

Draft, Export

Idea description

Is it possible to set an draft label on the 3D Part and set up an hyperlink, to an internal/external document, such as a pdf drawing or a text document?
Click on the draft label and the system viewer displays the document.
It would be great if such a function could be exported and used as well after an export as an webGL file.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@yorikvanhavre
Copy link
Member

Clicking an object and immediately open an URL is IMHO delicate, as people will constantly pop up browsers when working...
What we could do is

  1. Detect when a label text contains an URL (begins with http, basically...)
  2. If yes, add a context menu option to open the URL

It would be great if such a function could be exported and used as well in a n .xhtml file.

I didn't understand that?

@yorikvanhavre yorikvanhavre added WB Draft Related to the Draft Workbench Feature FR for improvements or new features labels Jun 21, 2022
@yorikvanhavre yorikvanhavre self-assigned this Jun 21, 2022
@PeterPNoster
Copy link
Author

The solution with a context menu would be absolutely ok, to avoid the constant popping up.

Sorry, I wasn't really clear on that point. I mean, if we have the function to open an external application within a FC model, it would be greath if, after an export as .xhtml, the functionality (hyperlink on label) would be available within the .xhtml file.

@yorikvanhavre
Copy link
Member

Oh I see, you mean the webGL export. I think we still need to support 2D objects and texts there, but will have a look.

@PeterPNoster
Copy link
Author

An webGL export would be nice to have.

@luzpaz
Copy link
Contributor

luzpaz commented Jul 9, 2022

@PeterPNoster than can you update the ticket summary to indicate hyperlink for webGL export perhaps?

@PeterPNoster
Copy link
Author

PeterPNoster commented Jul 9, 2022

@luzpaz I've updated the summary.

@luzpaz luzpaz changed the title [Feature Request] Draft label with hyperlink [Feature Request] Draft label with hyperlink to internal/external doc/pdf/txt Jul 10, 2022
@luzpaz
Copy link
Contributor

luzpaz commented Sep 4, 2023

Anyone interested in working on this ?

@luzpaz luzpaz added the Good first issue Suitable issues for potential first-time contributors label Sep 4, 2023
@luzpaz
Copy link
Contributor

luzpaz commented Sep 14, 2023

@CalligaroV interested to take a stab at this ?

@CalligaroV
Copy link
Contributor

@luzpaz I think I can at least try 😉
Speaking the truth ATM I was preparing a couple of pull requests for https://forum.freecad.org/viewtopic.php?t=80253 and https://forum.freecad.org/viewtopic.php?t=80696 but I think I can use some time for this issue too in the next days.

However ATM I can't say if I'll be able to come out with something useful and how much time I could need, I haven't even started reading the related forum topic yet 😅

@luzpaz
Copy link
Contributor

luzpaz commented Sep 14, 2023

@CalligaroV all good. No rush. Just putting it on your radar.

@yorikvanhavre
Copy link
Member

yorikvanhavre commented Sep 18, 2023

What I would do:

  1. Create a function in Draft that finds, extracts and returns an URL from a piece of text (there are certainly thousands of regexes to do that ready on the net)
  2. Create a new Draft command that picks the URL of a selected text, and opens a browser to it
  3. In the Draft's Workbench code (IntiGui.py), in the context menu setup, if the selection contains just one Draft text and that texts contains an URL, display the command

For the webGL export I'm not sure, more research is needed there...

@CalligaroV
Copy link
Contributor

CalligaroV commented Oct 1, 2023

Hi Everyone! 😃

After some research, coding and tests, I just opened a pull request for the modifications needed to use the hyperlinks in Draft WB, following @yorikvanhavre tips.
you can see above the link, Pull Request #10878.

How it works:

  • the command allows the selection of multiple object, even multiple texts.
  • for every text a regex will be applied. If at least one text contains at least one hyperlink the command will be added to the context menu.
  • when called the command, in case of multiple hyperlinks a message box will inform that multiple windows could open (one for every hyperlink)
  • for every hyperlink a subprocess will launch the application related to the file type / protocol and open the file/page described by the hyperlink

Some notes:

  • the regex accepts spaces in the hyperlink only before the first dot, which is supposed to be the beginning of the file extension. Issues may arise if there are combinations of dots and spaces in the path of the file or in the filename itself (for example /home/vincenzo.calligaro/some folder with spaces/file.txt will fail due to the dot in the folder vincenzo.calligaro and the following spaces in the folder "some folder with spaces")
  • the code should already be platform independent and support Windows, macOS and Linux but ATM I tested it only on Linux (Linux Mint 21 Cinnamon)
  • the code to actually open the files in the hyperlinks, launching the correct application, is more or less what I found here: https://stackoverflow.com/questions/17317219/is-there-an-platform-independent-equivalent-of-os-startfile

Final note: haven't done any research for the WebGL

As always, feedback are very welcome! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature FR for improvements or new features File format: WebGL Good first issue Suitable issues for potential first-time contributors UI/UX WB Draft Related to the Draft Workbench
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants