MOOC Workbench create tutorial in GUI

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
dxp.dev
Posts: 280
Joined: Tue Dec 11, 2018 12:57 pm

Re: MOOC Workbench create tutorial in GUI

Post by dxp.dev »

I can translate from French, that's why I asked. If in a first phase we can translate it into english from CrowdIn, in a second phase would it be easier to change the code from what CrowdIn generated ?

EDIT : or is it better to translate first inside the code and then expose it in CrowdIn ?
Find your user.cfg and system.cfg files : Macro_findConfigFiles

Imperial system makes no sense, go metric ! ! !
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: MOOC Workbench create tutorial in GUI

Post by onekk »

KAKM wrote: Fri Jul 30, 2021 4:48 pm The MOOC Workbench is an external workbench that currently has a tool that plays interactive tutorials and a function that compares the model you have created with the model intended by the creator of the tutorial. More information is available in this forum thread: https://forum.freecadweb.org/viewtopic.php?t=37584 and in the documentation here: https://wiki.freecadweb.org/MOOC_Workbench
Thanks
KAKM wrote: Fri Jul 30, 2021 4:48 pm ...
The "interactive tutorial" is exactly what I'm aiming for: a tutorial that will highlight GUI buttons or show you keyboard commands, has a place to show written instructions and possibly separate hints, that you can run by loading a tutorial file. The thing that I am currently working on is the ability to create that tutorial file from a previously recorded macro of creating a model. Basically, it will allow you to load a macro, then divide the commands in the macro into tutorial steps, and add instructions/comments/hints/links to a video.
Great!
KAKM wrote: Fri Jul 30, 2021 4:48 pm ...
do you think it would make sense to have an icon like a little bullseye appear where you need to click?
Yes or some other marker on screen, to show user were to click.

KAKM wrote: Fri Jul 30, 2021 4:48 pm Or would it be better to have a simulated pointer appear at the current location of the real mouse and move to the point where you need to click?

In the sense that there will be a pointer that appear at the mouse "current position" and then move to the "click location"?

KAKM wrote: Fri Jul 30, 2021 4:48 pm Maybe the simulated pointer could look like a freecad/mooc workbench logo next to a pointer, so you can tell it apart from your real pointer.
Good idea, probably not too big as it may hid some UI elements, maybe a point in a "different color" could suffice.
KAKM wrote: Fri Jul 30, 2021 4:48 pm I don't understand how that would help with wiki page creation, though.
The idea, maybe a fool idea is to have some way to take "screenshots" of "part of the interface only".

The ideal case would be if a "macro language" has to be implementd to have a way to take a screenshot of the "Properties" window or maybe the "3d window" alone or the "Python Console" once you have similar screenshots, maybe stored in a file, you could use them to create some wiki pages let's try to implement an example in pseudo code:

Code: Select all

Open > File > "/home/user/file.FCStd"
activate("Part WB")
select("pippo", "Line1")
Screenshot("3DView", "step1_3d")
Screenshot("TreeView", "step1_tv")
....
and so on
....


Make("wikipage", "test wb").

Title("Bla, Bla and Bla")

open the file, and then select the element, see <fig1>:

Insert_screenshot("step1_tv", <fig1>)

make these actions and you will see: <fig2>

Insert_screenshot("step1_3d", <fig2>)


Same things would be useful if the macro language could compose pages maybe using some "latex code" to convert them in a pdf document

But maybe this is something out of the scope of the WB you are developing.

Hoping having explained my thoughts in a "decent" way:

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: MOOC Workbench create tutorial in GUI

Post by KAKM »

Kunda1 wrote: Sat Jul 31, 2021 12:11 pm We could probably add it. But I was referring to changing the source code.
You're talking about the lines like this, right?

Code: Select all

self.setWindowTitle(app.Qt.translate("MOOC", "Tutoriels FreeCAD"))
The comments and most of the internal code are in English already.
Anything I add will also be in English.
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: MOOC Workbench create tutorial in GUI

Post by KAKM »

onekk wrote: Sat Jul 31, 2021 3:14 pm In the sense that there will be a pointer that appear at the mouse "current position" and then move to the "click location"?
Exactly.
onekk wrote: Sat Jul 31, 2021 3:14 pm Good idea, probably not too big as it may hid some UI elements, maybe a point in a "different color" could suffice.
Good point. A different color might be hard to distinguish–maybe a different shape?

Regarding the screenshot/wiki/PDF feature(s): I can see how that would be handy, and I don't think it's outside the scope of the workbench overall, but it is a bit outside the scope of what I'm going to be doing in the immediate future, particularly since it's outside of the critical functionality path.

Creating a "save tutorial to PDF" function would be pretty easy–all that would require is a function that would convert the tutorial file to LaTeX code, and I use LaTeX frequently, so I could do that off the top of my head.

I'm not even going to attempt converting a tutorial into the wiki format until I've spent time in the wiki, which I won't be doing until I have the basic tutorial creation functionality working. It may get delayed significantly longer than that, depending on how difficult it would be to implement and the relative priority of other features.

It would be pretty easy to create an "add screenshot" function to the tutorial where you upload an image taken with the screenshot utility on your computer–the only thing I'm not sure about is how to make sure the image file "sticks" to the tutorial file so that it's accessible when someone else downloads and runs the tutorial. I know .FCStd is a zipped file, is .FCMacro? I don't think it would make much sense to have the ability to save a PDF/create a wikipage without at least this much functionality, but I'd like to have the basic "create a tutorial" tool solid before I start expanding out in this direction.

It would be a lot harder (I suspect) to create a screenshot function in the FreeCAD interface where it saves what a particular window on the screen is rendering–that would involve working with the Qt at a level that would probably take me quite a bit of time to learn. I do think it's doable, since it would basically involve sending a group of data to a .png (or similar) file that is already being sent to the renderer. I just don't know Qt well enough to know where that might be and if there are built in functions I could make use of. So that is at the bottom of my priority list.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: MOOC Workbench create tutorial in GUI

Post by heda »

KAKM wrote: Sun Aug 01, 2021 8:57 pm It would be a lot harder (I suspect) to create a screenshot function in the FreeCAD interface...
not necessarily...
Macro_Snip
https://www.forum.freecadweb.org/viewto ... 20#p480412

are both using qt to take screenshots and the later one also controls the ui through a thread.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: MOOC Workbench create tutorial in GUI

Post by onekk »

KAKM wrote: Sun Aug 01, 2021 8:57 pm Good point. A different color might be hard to distinguish–maybe a different shape?
Yes, my concern is that a "different shape" would hide some UI elements, in particular when you are selecting objects, but a different arrow would be a solution, maybe an arrow with some little symbol superimposed, to not make thing too difficult.

KAKM wrote: Sun Aug 01, 2021 8:57 pm Regarding the screenshot/wiki/PDF feature(s)
...
so I could do that off the top of my head.
The point is to have a mean to produce documentation maybe when writing tutorials.

I think that having a WB that could fulfill many "aspects" of the "tutorial thing" and more in general a "normalized way" to produce a variety of tutorial, teaching, and exercise, all the things that could be called "user friendly documentation" would be a great improvement for FreeCAD in general.

KAKM wrote: Sun Aug 01, 2021 8:57 pm I'm not even going to attempt converting a tutorial into the wiki format ...
Not "mandatory" it only a way to have some "HTML" formatted thing, to make more easy to create html pages, not a "full blown" wiki formatter, the format of the wiki pages could vary in times, so "a ready made" page maybe will last for some months, better to have a more general html formatter that would translate the "macro actions" in "natural language" code like:

Open edit menu then select this, select this and then do this thing..

quote=KAKM post_id=521322 time=1627851421 user_id=41920]
It would be pretty easy to create an "add screenshot"
...
So that is at the bottom of my priority list.
[/quote]

The proposal is made considering the fact that many times, I answer a post is "time consuming" to save the screenshot and then "crop" the image with an external tool.

This discussion is somewhat a brainstorming, not a "feature request", more a "talk" than other thing, I'm happy that my proposal are considered a "matter of discussion", they are only some ideas about a more general and standardized "way to document and explain to user" FreeCAD workflow.

But with the fact that i have not give an eye to the MOOC WB and to his code, as I program a little with FreeCAD (I'm doing scripting, more using Part and Draft WB, some Path and recently Sketcher to see "how it works"), I'm aware of the difficulties in using FreeCAD as the UI is a different thing from the "3D engine" and another different thing is "3d View" each of them has different "toolkits" and each has his own "programming style" so it is not a "cup of tea" to manage such things.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: MOOC Workbench create tutorial in GUI

Post by KAKM »

onekk wrote: Mon Aug 02, 2021 3:02 pm I think that having a WB that could fulfill many "aspects" of the "tutorial thing" and more in general a "normalized way" to produce a variety of tutorial, teaching, and exercise, all the things that could be called "user friendly documentation" would be a great improvement for FreeCAD in general.
I agree, and I think that's a good vision for this workbench. I do plan on eventually implementing the functionality you have suggested previously, though some of it may take awhile because there is other functionality I would like to add first, (some of which is necessary to create that functionality), and because it will take me some time to learn how the GUI operates.
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: MOOC Workbench create tutorial in GUI

Post by KAKM »

An update: I have discovered a couple of flaws with my original implementation plan.

It turns out that the MOOC workbench is licensed under the GPL rather than the LGPL, so building on that directly would have made integrating the results into the main code...interesting, and I got the impression that there may be features in this workbench that it would be desirable to add into the main code. It also turns out that it was storing all the information for a tutorial as a dictionary inside the init function of the tutorial class (called Lesson in the code). So I've worked out how to make a tutorial an object group and a step in the tutorial an object, which has the handy advantage of letting you use the tree view to do a pretty high percentage of the editing/creation of a tutorial.

The other major flaw is that a macro contains a python console instruction, but as far as I can tell, there's no easy way to find out which GUI element is associated with that instruction. It looks to me like it would require taking apart the command to see which workbench/command class(es) it's associated with (relatively easy), and then finding that code file (tricky) and finding the name of the associated GUI action (also tricky). If anyone has better ideas on how to approach that problem, or suggestions for implementation, I would love to hear them. An alternate possibility would be to start with capturing the next user interface commands when an "add step" button has been selected in the workbench.

I do intend to have both of those routes possible methods of making a tutorial eventually, but I'm trying to pick the shortest route first so that I can get a minimally-functional product working as soon as possible.
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: MOOC Workbench create tutorial in GUI

Post by KAKM »

I have one last big piece to get working before I can shift from the backend of this to the UI, but I'm a bit stuck. There is an event filter on the app to get the user events, but I then need to get the information about the user event out of the event handler so I can store it as part of the tutorial. Currently, this is being done through creating a custom signal class that sends a dictionary containing the event information (e.g., which key was pressed, the widget that was clicked on). Sending that signal will crash FreeCAD more often than not, and from what I've gathered from this forum and a couple others, it's because of an underlying bug in PySide.

Does anyone have ideas for an alternate way to get information from the event handler to my tutorial object? Or a workaround to keep this approach from crashing so often it's unusable?
Attachments
Tutorial-dev.zip
(207.32 KiB) Downloaded 14 times
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: MOOC Workbench create tutorial in GUI

Post by onekk »

KAKM wrote: Mon Sep 12, 2022 2:47 pm ...
There is an event filter on the app to get the user events, but I then need to get the information about the user event out of the event handler so I can store it as part of the tutorial. Currently, this is being done through creating a custom signal class that sends a dictionary containing the event information (e.g., which key was pressed, the widget that was clicked on). Sending that signal will crash FreeCAD more often than not, and from what I've gathered from this forum and a couple others, it's because of an underlying bug in PySide.
....

Hello.

Every Object could have his ViewProvider that is taking charge of visualizing the "Shape" on the 3DView, that is managed by Coin3D, and probably this could lead to some problems with Qt events.

As the documentation between interaction between Qt and Coin3D is scarce and some "elements" of FC Gui are derived from Qt and maybe inherit and modify standard Qt "event management", this could be the source of the problem.

Maybe asking [@wmayer would be a good thing.
wmayer wrote:
Sorry for poking, but this could be a very handy way to make tutorials without making videos and maybe automating across FC version changes.

He has not yet been here :D.

Hope it helps

Regards

Carlo D.

Edited: use a direct quote instead of mention
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply