material editor

A forum to discuss the implementation of a good Materials system in FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: material editor

Post by bernd »

material attributes are no longer hard coded in material editor ui file ... see git commit c3e64d28 I wonder if some where in the FreeCAD code the material properties are dedined? As far as I know they are not. Just the units are defined in unit system.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: material editor

Post by Jee-Bee »

bernd wrote: Sat Jun 09, 2018 11:22 am git commit c3e64d28
Thanks
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: material editor

Post by bernd »

@damian:

do you still do some dev for material editor? What I would like to see is a nice Gui::Input field to change the material attributes, like we have in FEM

Screenshot_20180610_060454.png
Screenshot_20180610_060454.png (3.71 KiB) Viewed 15704 times

Do you do development in this regard? With such an input field in material editor, I would totally switch to the material editor for material editing in FEM.

Bernd
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: material editor

Post by damian »

good morning @bernd !

A busy week. A lot of work plus painting my parent's house.

Of course, I've followed you and the last night compiled your improvements. Two issues:

1º) Migration to QTreeView with QStyledItemDelegate
2º) Use of PySide version of the InputField ("Gui::InputField")
bernd wrote: Sun Jun 10, 2018 4:07 am What I would like to see is a nice Gui::Input field to change the material attributes, like we have in FEM
bernd wrote: Sun Jun 10, 2018 4:07 am Do you do development in this regard?
No. I commented that I didn't find any example of this make directly from the py file, always the property and its kind (for instance length) defined in the ui file. And now you removed the property's classification from the ui file (I like this solution).
bernd wrote: Sun Jun 10, 2018 4:07 am I would totally switch to the material editor for material editing in FEM
I know. I could not offer a solution before two or three weeks.
If you prefer to apply the Gui::Input and switch, later on, I could finish the migration to QTreeView, following the yorik's example. This last doesn't change the material editor and open the door for later dev.

Thank you for your improvements.

OS: Ubuntu 16.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.13938 (Git)
Build type: Unknown
Branch: mat
Hash: c4fd48fb322a8e8c0927e7c5cac08797f2b0995a
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: material editor

Post by damian »

Okey, I see one example of "Gui::InputField"

Code: Select all

self.Length = ui.createWidget("Gui::InputField")
self.Length.setText("0.00 mm")
https://github.com/FreeCAD/FreeCAD/blob ... rchWall.py
so complicated!
https://het.as.utexas.edu/HET/Software/ ... lview.html
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: material editor

Post by yorik »

Yeah the model view thing in Qt is not simple...

But look at how it is used it here, it's not that hard as it seems in the doc :) : https://github.com/yorikvanhavre/BIM_Wo ... ts.py#L214

Basically inside all the different functions ( createEditor, setEditorData, etc..) you will need to find which property we are editing (the index contains the exact position of the field in the tree, so you can retrieve for example the text in the first column), and depending on that, display either a QLineEdit, or an InputWidget or something else (QSpinBox, color chooser, etc..)

That is easy for the "fixed" properties (we know their type), but when the user adds custom properties, I'm not sure. Ideally there should be a way to specify the property type. Maybe we need one more column that says the type?
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: material editor

Post by damian »

yorik wrote: Mon Jun 11, 2018 3:36 pm Basically inside all the different functions ( createEditor, setEditorData, etc..)
I was enterteined with the update() and append rows to the model, and ...
Now I'm arriving at editor!
It is possible for a custom delegate to provide editors without the use of an editor item factory. In this case, the following virtual functions must be reimplemented:

PySide.QtGui.QStyledItemDelegate.createEditor() returns the widget used to change data from the model and can be reimplemented to customize editing behavior.
PySide.QtGui.QStyledItemDelegate.setEditorData() provides the widget with data to manipulate.
PySide.QtGui.QStyledItemDelegate.updateEditorGeometry() ensures that the editor is displayed correctly with respect to the item view.
PySide.QtGui.QStyledItemDelegate.setModelData() returns updated data to the model.
https://srinikom.github.io/pyside-docs/ ... egate.html
yorik wrote: Mon Jun 11, 2018 3:36 pm but when the user adds custom properties
Yes. A few experiments to taste different solutions.

The next weekend might be migrated to model view and code to review.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: material editor

Post by bernd »

mhh I'm curious how you solve the different input widgets inside the tree. I would have gone the easy way and make an edit button and made the editing in a different widget or at least outside the tree widget. I will wait and not do any more changes on the editor.

BTW: I did move the material attribute structure another one. Now the material editor and the FCMat writer use the same material attribute structure. See git commit 1051f10498b5f

@Yorik and others:
I wonder if these material attribute structure is somewhere else defined in the code?

BTW:
Damian, If you have made any changes on the editor, you should rebase your work. I did do some code formating according pep8 style guide on material module for better readability and to have standard code formating.
damian
Posts: 583
Joined: Sun May 31, 2015 6:16 pm

Re: material editor

Post by damian »

bernd wrote: Mon Jun 11, 2018 4:29 pm pep8 style guide
Yes, I have got the module PEP8 enabled in my IDE (spyder)
I make all my code in parallel to the existing one, without mess up.
The last step is to activate model/view and remove classical widgets, and it will require refactoring especially some variable names.
This last step will be posterior to your review.
Thank you
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: material editor

Post by yorik »

bernd wrote: Mon Jun 11, 2018 4:29 pm I wonder if these material attribute structure is somewhere else defined in the code?
Not in the code, but on the wiki there is this:

https://www.freecadweb.org/wiki/Material
https://www.freecadweb.org/wiki/Material_data_model
Post Reply