Part module preference option not activated at startup ?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
vejmarie
Posts: 713
Joined: Mon Jan 04, 2016 4:52 pm
Location: Somewhere between France, USA and Taiwan
Contact:

Part module preference option not activated at startup ?

Post by vejmarie »

Hi,

As to enhance the STEP importer/exporter, I need to add a user variable parameter, and wanted to make it happen into the Part modules parameter, but I am currently unable to enable it at FreeCAD startup which is frustrating. Is there any specific reason for that ? I am lost into the way we activate/deactivate options into the preferences menu for file format importer/exporter. Looks like each module is deciding when to activate them when the end user is moving through them.

I tried to change the CMakeLists.txt to get the right ui into the Mod/Part/Gui directory during build but without any success. My idea was to activate the stuff using example from Yorik into draft

and doing a call like this FreeCADGui.addPreferencePage(":/ui/preferences-dxf.ui","Import-Export") just after Part initialization to force ui init but Part is definitly not designed that way.

I must admit I don't know anything about Python and CMake (boooo), and got the feeling I need to learn now which is fine, but I will appreciate some help on just trying to find a way to have preferences options activated at FreeCAD startup and perhaps not at module startup at least for the file format at Importer/Exporter level.

vejmarie
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Part module preference option not activated at startup ?

Post by sgrogan »

vejmarie wrote: Wed Jul 12, 2017 8:50 pm perhaps not at module startup at least for the file format at Importer/Exporter level.
Have you seen this thread? https://forum.freecadweb.org/viewtopic.php?f=8&t=14211
I think having all the import/export stuff available at start-up would be very convenient.
"fight the good fight"
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Part module preference option not activated at startup ?

Post by triplus »

Hi vejmarie.

As for the more general issue. Workbench name and icon is available when FreeCAD starts. No resource files are involved and nothing needs to be loaded. Therefore Preferences sidebar could be turned into a workbench switcher. That is all workbenches would be listed and when user clicks on an icon corresponding workbench gets loaded. Things like workbench specific preferences page therefore gets loaded. That would resolve the confusion for new users as now you have to first load the workbench to see the corresponding workbench icon/name in Preferences. I never tackled this as it would involve C++ and i somehow settled for Python for now.

As for your problem. I have a feeling it's a different one. Variable/parameter gets set in Preferences and after it is stored as parameter. You can therefore always check for the value set at FreeCAD start. Regardless of the fact if STEP importer/exporter preferences page was already loaded or not. Look under Tools -> Edit parameters ... All sorts of stored settings are located there. And the same can be done for your (user set) STEP importer/exporter related variable.
User avatar
vejmarie
Posts: 713
Joined: Mon Jan 04, 2016 4:52 pm
Location: Somewhere between France, USA and Taiwan
Contact:

Re: Part module preference option not activated at startup ?

Post by vejmarie »

sgrogan wrote: Wed Jul 12, 2017 9:07 pm
vejmarie wrote: Wed Jul 12, 2017 8:50 pm perhaps not at module startup at least for the file format at Importer/Exporter level.
Have you seen this thread? https://forum.freecadweb.org/viewtopic.php?f=8&t=14211
I think having all the import/export stuff available at start-up would be very convenient.
I was not aware of the thread, and it does correspond exactly to what I face as an issue. I really think we shall find a way to expose import/export stuff at startup as you mention, because it is quite disturbing to the end user to activate Part module which is a design module to import or use FreeCAD as a pure viewer. I will try to see if I can find a way to make it happens.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Part module preference option not activated at startup ?

Post by easyw-fc »

triplus wrote: Wed Jul 12, 2017 9:44 pm ...
Variable/parameter gets set in Preferences and after it is stored as parameter. You can therefore always check for the value set at FreeCAD start. Regardless of the fact if STEP importer/exporter preferences page was already loaded or not ...
Hi @triplus
is there a way to create a var that can be changed at running time i.e. for "UseVBO" and not that would need a FC restart as per "WriteSurfaceCurveMode"?
It is enough to expose the var to Gui?

reference discussion here
https://forum.freecadweb.org/viewtopic. ... 10#p142185

Thx
Maurice
User avatar
vejmarie
Posts: 713
Joined: Mon Jan 04, 2016 4:52 pm
Location: Somewhere between France, USA and Taiwan
Contact:

Re: Part module preference option not activated at startup ?

Post by vejmarie »

triplus wrote: Wed Jul 12, 2017 9:44 pm Hi vejmarie.

As for the more general issue. Workbench name and icon is available when FreeCAD starts. No resource files are involved and nothing needs to be loaded. Therefore Preferences sidebar could be turned into a workbench switcher. That is all workbenches would be listed and when user clicks on an icon corresponding workbench gets loaded. Things like workbench specific preferences page therefore gets loaded. That would resolve the confusion for new users as now you have to first load the workbench to see the corresponding workbench icon/name in Preferences. I never tackled this as it would involve C++ and i somehow settled for Python for now.

As for your problem. I have a feeling it's a different one. Variable/parameter gets set in Preferences and after it is stored as parameter. You can therefore always check for the value set at FreeCAD start. Regardless of the fact if STEP importer/exporter preferences page was already loaded or not. Look under Tools -> Edit parameters ... All sorts of stored settings are located there. And the same can be done for your (user set) STEP importer/exporter related variable.
I am in a mix of all of that, as I need to keep the parameter between FreeCAD restart, but I also need to expose an easy way to the end user to change the value ;)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Part module preference option not activated at startup ?

Post by triplus »

vejmarie wrote: Thu Jul 13, 2017 7:47 am I am in a mix of all of that, as I need to keep the parameter between FreeCAD restart, but I also need to expose an easy way to the end user to change the value ;)
In FreeCAD terms that comes down to:
  • User: Load Part workbench and by doing that STEP preferences will be made available in Preferences. A way to set a value is therefore added there.
  • Developer: User made setting is stored as parameter. And therefore you check for that (on STEP import/export) and don't care about availability of Preferences at all.
Example:

https://www.freecadweb.org/tracker/view.php?id=2744

Yorik bypassed this and made some of the preferences always available. By adding them on FreeCAD start and not when Draft/Arch workbench gets loaded.

https://github.com/yorikvanhavre/FreeCA ... 810e546517

That is why they are there on FreeCAD start. Before you needed to load corresponding workbench to get them. Now i won't judge on what should or shouldn't be done. I only described the situation. ;) Current guidelines suggests it is not OK to load workbench specific functionality on FreeCAD start by default. Import/Export related settings could likely be treated as corner case scenarios. As they are scattered among different workbenches and centralized in Preferences. Some available by default and others not.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Part module preference option not activated at startup ?

Post by easyw-fc »

triplus wrote: Thu Jul 13, 2017 1:49 pm In FreeCAD ...
thx for clarifying :D
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Part module preference option not activated at startup ?

Post by wmayer »

is there a way to create a var that can be changed at running time i.e. for "UseVBO" and not that would need a FC restart as per "WriteSurfaceCurveMode"?
It is enough to expose the var to Gui?
The class ParameterGrp is derived from the class Base::Subject and thus it's possible to register observers to a group that get notified for each changed parameter inside the group.

The observer class must derive from ParameterGrp::ObserverType and re-implement the method OnChange. As a reference have a look at the class AbstractSplitView

To listen to the changes of a group the method Attach of the group must be called.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Part module preference option not activated at startup ?

Post by easyw-fc »

wmayer wrote: Thu Jul 13, 2017 2:36 pm The class ParameterGrp is derived from ...
thx for supporting :)
Post Reply