Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
silas
Posts: 17
Joined: Tue Jun 05, 2018 2:42 pm

Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by silas »

Hello guys. Silas from Wikilab here (more about Wikilab here).

With our small team of beginners, we have sucessfully solved issue 0003499. Tomorrow we are going to make a pull request. Although it is a simple change (only three lines of code!) people got a bit scared with C++, which is not a problem for students that are just starting.

So we are thinking about making a more complex change, but in Python this time. So we have choose issue 0003393: Configuration wizard when launching FreeCAD for the first time. On the issue tracker the reporter sugests a window from LibreCAD, which I found interesting and a good starting point.

So, as a good starting point, our plan is to allow the user to chose the following options:

* Default unit
* GUI Language (fetchs a initial option from the system language)

And, later, we can implement other features the NormandC (a commenter) tells on the tracker.

Any tips about that?

Ah, I'd also like to ask you if you have some tip about a good starting point at the code so we can take a look at. We want to maximize Python and minimize C++. Anyway, we can deal with some C++, if necessary.

Thanks!
chrisb
Veteran
Posts: 52169
Joined: Tue Mar 17, 2015 9:14 am

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by chrisb »

Congratulations to your first FreeCAD contribution. Three lines of code is a good amount for a start. Simply double the number of lines on each contribution! You might have heard about the story of the invention of the chess game.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13443
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by Kunda1 »

@silas :+1:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Opus
Posts: 91
Joined: Wed Nov 08, 2017 5:36 pm

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by Opus »

silas wrote: Wed Jul 04, 2018 7:41 pm So we are thinking about making a more complex change, but in Python this time. So we have choose issue 0003393: Configuration wizard when launching FreeCAD for the first time. On the issue tracker the reporter sugests a window from LibreCAD, which I found interesting and a good starting point.
Maybe you can look at BIM workbench, developped by Yorik: https://github.com/yorikvanhavre/BIM_Workbench

Video presentation where you could see the setup dialog (between 1'15'' and 3'00''):
phpBB [video]


[EDIT] BIM workbench topic for inspiration too: https://forum.freecadweb.org/viewtopic.php?f=9&t=27237
User avatar
wandererfan
Veteran
Posts: 5992
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by wandererfan »

silas wrote: Wed Jul 04, 2018 7:41 pm Ah, I'd also like to ask you if you have some tip about a good starting point at the code so we can take a look at. We want to maximize Python and minimize C++. Anyway, we can deal with some C++, if necessary.
In Mod/Draft/Draft.py approximately line #117 2 functions will be helpful:
- def getParam(param,default=None): and
- def setParam(param,value):.
User avatar
yorik
Founder
Posts: 13527
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by yorik »

Starting from a dialog similar to the librecad one seems a very good idea indeed.
This is pretty simple to do fully in python. I did one for BIM (that appears in the video), that is basically one ui file designed in qt designer (dialogSetup.ui) , and one python file:

https://github.com/yorikvanhavre/BIM_Wo ... imSetup.py

I think you can do something very similar...

In FreeCAD, Tools -> Edit parameters is very useful to know all the settings and their types.

To launch your screen at FreeCAD startup, when it's the first launch, you can implement a separate workbench, but it's much just to show a dialog, or I would suggest to hook it to the Mod/Tux module, which contains several other utilities that are run at FreeCAD startup.
User avatar
Kunda1
Veteran
Posts: 13443
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by Kunda1 »

Maybe the wizard could also ask user what type of mouse navigation methodology users perfer? Maybe a scrollbar just like in the taskbar ?
mouse-navigation.png
mouse-navigation.png (25.85 KiB) Viewed 2508 times
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
silas
Posts: 17
Joined: Tue Jun 05, 2018 2:42 pm

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by silas »

Hello.

Although drawing the wizard UI and writing its related code are not difficult, we are stuck at where (and how to) show the window.

We have two choices:

1. Show it just after the splash screen gets closed (add these lines on lines 1838 of Gui/Application.cpp). Something like:

Code: Select all

if (firstTime) {
	WizardConfigDialog wizardDlg;
	wizardDlg.exec();
}
The exec() function blocks until the user closes the dialog.

2. Write a Python module.

We've made a very small prototype with [1] (C++ only) and it seems to work, but we would really like to implement it in Python, if possible. Looking at the documentation, we figured out a python module can be loaded with:

Code: Select all

Base::Interpreter().loadModule("WizardConfig");
And we create a directory within the Mod directory. We tested it and it works fine for arbitrary Python code (like creating a file) but when we try to create a window in our Python code (by creating a class that subclass QtGui.QDialog) we get the following error:

Code: Select all

QWidget: Must construct a QApplication before a QPaintDevice
zsh: abort (core dumped)  ./bin/FreeCAD
Python script cannot detect we have a QApplication at the Python side (that makes sense, since it would allow the Python interpreter to have full access of the hosting app). I am probably missing something.

We can probably implement that feature in Python in other manners that not a standalone window at the beginning of the application, but a standalone would be the "classic" way :-)

What you recommend? It is not a problem the WizardConfig window have to be done only in C++ at this level. We just would like to know :-)

Thanks!
User avatar
Kunda1
Veteran
Posts: 13443
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by Kunda1 »

Hey Silas,
I hope some devs are able to address your questions. Thanks again for working on this. Also I'm going to link this thread with:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
wmayer
Founder
Posts: 20074
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Ideas for implementing 0003393: Configuration wizard when launching FreeCAD for the first time

Post by wmayer »

And we create a directory within the Mod directory. We tested it and it works fine for arbitrary Python code (like creating a file) but when we try to create a window in our Python code (by creating a class that subclass QtGui.QDialog) we get the following error:
This simply means that you create that dialog too early. Before creating any kind of widget a QApplication must exist.

Could it be that you load it from the Init.py file of your application module? If yes then move it to the initGui.py file. If this is not the case you should explain the way how you invoke your Python module.
Post Reply