Source code architecture

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
paddle
Veteran
Posts: 1413
Joined: Mon Feb 03, 2020 4:47 pm

Source code architecture

Post by paddle »

Hi there,

I was wondering if there are some documentation explaining the source code structure?
I seen the ebook (https://github.com/qingfengxia/FreeCAD_Mod_Dev_Guide) which already explained some of the structure. So basically I understood there is one folder for each workbench in scr/mod folder. So my question is more about the structure of the workbench themself.

Specially for the sketcher workbench as I'm trying to add some features there. I tried to compare different workbench (draft for example) and structure seems very different between each workbench.

Even inside the sketcher workbench, it looks like the different commands are not implemented the same way. Some seems to be writen in python, others in Cpp. The core command for fillet and others seems to be located in SketchObject.cpp
But for some reason draw Rectangle or draw circle are not in this file.

And there are very little documentation to explain the structure.

Anyone can introduce me the structure of the sketcher code perhaps?

Also maybe what could be great is a readme file in each workbench to explain how features are implemented to help new comers?
Last edited by paddle on Sun Feb 23, 2020 7:32 pm, edited 3 times in total.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Source code architecture

Post by vocx »

paddle wrote: Sun Feb 23, 2020 1:38 pm ...
I seen the ebook which already explained some of the structure.
...
Also maybe what could be great is a readme file in each workbench to explain how features are implemented to help new comers?
It would be great if you linked to this "ebook". Otherwise how are you going to help newcomers?

You see? This is the problem with documentation. People don't leave bread crumbs for others to follow. You are making the same mistake.

The truth is workbenches are completely flexible in how they are defined.

Draft is a Python only workbench, so it is much more flexible in terms of code architecture.

Most C++ workbenches define App/ and Gui/ directories where they split the inherently non-visual and visual code. The former corresponds to new internal classes, while the latter deals with "view providers" and user interfaces ("GuiCommands", task panels, .ui files, icons, etc.).

To define a workbench you only need the toplevel directory inside Mod/, and the files Init.py and InitGui.py that initialize that workbench for non-GUI, and GUI aspects. They mostly load other modules, which have the real code.

There is a second way to define a Python-only workbench, which is explained in the Workbench-Starterkit.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply