Some questions for developers....

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
DrBwts
Posts: 101
Joined: Sun Oct 26, 2014 5:23 pm

Some questions for developers....

Postby DrBwts » Fri Apr 13, 2018 2:57 pm

I'm primarily interested in graphics & mechanics (my day job is in Biomechanics mostly FEA) & I'm looking into improving my programming skills (intermediate at best). I'm naturally drawn to FreeCAD as a way to explore how computational graphics work & how it is implemented but am well aware that I am a noob. SOooo I have a few questions, if you have the time, about how FreeCAD is developed.

What kind of programming environments do you use, Visual Studio, Code::Blocks, something else?

What compilers are you using?

I'm assuming FreeCAD is written in C++?

How do I access the source code?

What libraries are need besides OpenCASCADE & COIN?

What else should I know? :D

Thanks for any time you can spare with this.
User avatar
tanderson69
Posts: 1537
Joined: Thu Feb 18, 2010 1:07 am

Re: Some questions for developers....

Postby tanderson69 » Fri Apr 13, 2018 3:17 pm

DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
What else should I know? :D
https://www.freecadweb.org/wiki/Developer_hub
chrisb
Posts: 25650
Joined: Tue Mar 17, 2015 9:14 am

Re: Some questions for developers....

Postby chrisb » Fri Apr 13, 2018 3:37 pm

DrBwts
Posts: 101
Joined: Sun Oct 26, 2014 5:23 pm

Re: Some questions for developers....

Postby DrBwts » Fri Apr 13, 2018 3:49 pm

Thanks both that should keep me quiet for a while.
ezzieyguywuf
Posts: 647
Joined: Tue May 19, 2015 1:11 am

Re: Some questions for developers....

Postby ezzieyguywuf » Fri Apr 13, 2018 5:30 pm

The resources linked are probably where you should start. But since a have a few minutes:
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
What kind of programming environments do you use, Visual Studio, Code::Blocks, something else?
I use a plain text editor (my preferred editor is vim, or neovim more lately), and then compile using cmake from the command line. Most would consider this a rather "bare bones" development environment, though, and it's not suited for everyone.
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
What compilers are you using?
I use the gcc compiler exclusively for no other reason than it is what comes with my operating system (gentoo linux).
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
I'm assuming FreeCAD is written in C++?
FreeCAD is written primarily in C++. However, a critical component of FreeCAD is its integration with the python interpreter. FreeCAD is integrated to such an extent that entire portions of the code base are written entirely in python.
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
How do I access the source code?
It's on github.. Since you describe yourself as a "newb", I'd hazard a guess that you're not familiar with git. I'd recommend you learn a tad about it. Mostly what you need to know are:

Code: Select all

git clone <some url> # makes a local copy of a remote git repository
git pull origin # grabs updates from a remote repository and stores them locally
git branch myBranch # creates a branch of the code at the current place in history
git checkout myBranch # begins working on "myBranch"
git add <list of files> # adds changed files to be stored as a commit
git list # lists changes since the last commit
git commit # commits changes
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
What libraries are need besides OpenCASCADE & COIN?
There's a wiki page that discusses this at length.
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
What else should I know? :D
I already mentioned git. If you're not familiar with cmake, I'd recommend learning a tad about that too. Mostly what you need to know:

Code: Select all

git clone <some project that uses cmake>
cd theProject #change into the project dir
mkdir build # we're going to do an "out of source" build. This is the recommended approach
cd build # change to the build directory
cmake .. # initialize the build directory with cmake stuff
cmake-gui ..# open a gui to set variables that cmake needs, as necessary
make -j8 # build the project. "-j8" is optional
You should know about compiling and linking c++ code. In my experience, the best way to do this is find a tutorial (this one looks ok though I've only briefly skimmed it) and compile some basic programs by hand. What I mean by "by hand" is by making calls directly to gcc to compile your program.

The next step would be learn about the program "make", which makes compiling less of a chore by taking care of the gcc calls. I'd write a few Makefiles by hand to get a feel for how make works.

Finally, I'd create a small project and use cmake, which automates the creation of Makefiles for you.

Get comfortable using code documentation. Qt has great documentation online, opencascade has one too, in fact most projects do. I usually do a google search for whatever class I need the documentation on, but always look for a link to the official documentation as that's usually a great first place to start if I have an issue, or if I just need to know what something does.

Hm, probably forgetting some stuff, but I guess that should be a good start :-P
DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
Thanks for any time you can spare with this.
hopefully this was helpful.
dbecad
Posts: 80
Joined: Fri Mar 16, 2018 11:10 pm

Re: Some questions for developers....

Postby dbecad » Fri Apr 13, 2018 9:26 pm

DrBwts wrote:
Fri Apr 13, 2018 2:57 pm
I'm naturally drawn to FreeCAD as a way to explore how computational graphics ...
I have the same ambition as you on the long term, as I'm slowly trying to get familiar with FC to design a mechanical clock my developer instinct is kicking in when i see that some feature could be easier if only I was making some small changes on the current tool...
ezzieyguywuf wrote:
Fri Apr 13, 2018 5:30 pm
Since you describe yourself as a "newb", I'd hazard a guess that you're not familiar with git. I'd recommend you learn a tad about it. Mostly what you need to know are:

Code: Select all

git clone <some url> # makes a local copy of a remote git repository
git pull origin # grabs updates from a remote repository and stores them locally
git branch myBranch # creates a branch of the code at the current place in history
git checkout myBranch # begins working on "myBranch"
git add <list of files> # adds changed files to be stored as a commit
git list # lists changes since the last commit
git commit # commits changes
That said, regarding GIT, I would suggest you stay away from the command line and look at GUI tools like:
Source Tree (windows & mac) https://www.sourcetreeapp.com/
or GIT Kraken (win/mac/linux) https://www.gitkraken.com/

GIT is a best and worst tool for collaborative development, necessary to maintain linux but when it comes to smaller project it gives you a lot of rope to hang yourself. Using GUI will at least give you an easier view of the commit tree (tracking of the successive modifications), and which files have been modified (with a nice visual diff). It makes the experience much more enjoyable and you will not have to dread the "execute a command and pray" each time you want to do an update or merge...

So good luck with your exploration!
Cheers
DrBwts
Posts: 101
Joined: Sun Oct 26, 2014 5:23 pm

Re: Some questions for developers....

Postby DrBwts » Tue Apr 17, 2018 10:57 pm

Thanks ezzieyguywuf & dbecad all very helpful. Just finding my way around the GUT GUI :D