Display alias in spreadsheet
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
- Shalmeneser
- Veteran
- Posts: 9558
- Joined: Wed Dec 23, 2020 12:04 am
- Location: Fr
Re: Display alias in spreadsheet
value == alias
- adrianinsaval
- Veteran
- Posts: 5551
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Display alias in spreadsheet
also now taht I remember, there's already a similar feature in sketcher that allows you to format the label of dimensional constrains and it uses %N and %V keywords, we should keep consistency with it here and use %V and %A. And I guess you could try to look up the code for that to use as a referenceadrianinsaval wrote: ↑Fri Feb 04, 2022 7:53 pmmaybe it's better if your keywords are for example %a and %v
- Attachments
-
- Screenshot 2022-02-04 191542.png (17.3 KiB) Viewed 1077 times
Re: Display alias in spreadsheet
Yes, that would make a printf-format like, which is broadly understoodadrianinsaval wrote: ↑Fri Feb 04, 2022 7:53 pmagreed but maybe it's better if your keywords are for example %a and %v or something like that, just so "alias" and "value" are still available in the rare case someone wants something lik "%v (alias: %a)" of course this is not critical but just something that came to mind.dpoen wrote: ↑Fri Feb 04, 2022 9:29 am 4) Yes, that why making it customisable should be nice.
I'm thinking about a text field in the preference panel, where we could enter "alias = value", "alias : value", "value alias" and so on, and then at print time I just replace 'alias' with the actual alias name, and 'value' with the actual value for each cell with an alias. Than would give great flexibility, isn't it ?
And I do agree that a better default would be to have the value first and the alias second, to ensure the value is always displayed.
Re: Display alias in spreadsheet
Yes, that what I'm looking for ! I've been reading through this https://forum.freecadweb.org/viewtopic.php?f=10&t=61153 , so I'll use all of this to make something similar.adrianinsaval wrote: ↑Fri Feb 04, 2022 10:16 pmalso now taht I remember, there's already a similar feature in sketcher that allows you to format the label of dimensional constrains and it uses %N and %V keywords, we should keep consistency with it here and use %V and %A. And I guess you could try to look up the code for that to use as a referenceadrianinsaval wrote: ↑Fri Feb 04, 2022 7:53 pmmaybe it's better if your keywords are for example %a and %v
Re: Display alias in spreadsheet
Here it come, I've wrote a first draft, if would be happy to get feedback on it !
What have been done :
Format using a dedicated function to avoid code duplication.
Add a toggle in preference to activate or not this feature.
Add a custom field to format using %A / %V
To be done still :
Fix a bug where the format on the spreadsheet is not updated when we hit the "Apply" button, but only when you hit "OK".
Add a toggle on the Spreadsheet view to show/hide aliases.
I'm new to Qt programming, and in particular with UI design, so I would enjoy get feedback / correction on it, if need be.
FYI, I've based my work on 3cb9f522a7819ad31fcdfaa764eac9a7f5c4b7e1
Please checkout https://github.com/FreeCAD/FreeCAD/pull/5489
What have been done :
Format using a dedicated function to avoid code duplication.
Add a toggle in preference to activate or not this feature.
Add a custom field to format using %A / %V
To be done still :
Fix a bug where the format on the spreadsheet is not updated when we hit the "Apply" button, but only when you hit "OK".
Add a toggle on the Spreadsheet view to show/hide aliases.
I'm new to Qt programming, and in particular with UI design, so I would enjoy get feedback / correction on it, if need be.
FYI, I've based my work on 3cb9f522a7819ad31fcdfaa764eac9a7f5c4b7e1
Please checkout https://github.com/FreeCAD/FreeCAD/pull/5489
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Display alias in spreadsheet
It looks like the new checkbox is related to importing and exporting. There should be a new group for it. I don't know a good name, maybe "Display Format"? "Display Style"? In the future there might be added things like defaults for the background color, font style, alignment, etc.
When a new users sees this on the screen:
some_alias = 3
for a cell with a value of 3 and the alias is "some_alias"
This might infer to the new user that an alias can be created in the same manner. For example, to create a cell with this alias and this value, enter into the cell:
some_alias = 3
That could be a useful feature to have, but probably is much more complex since it is parsing user input. I think it would be good if the display format and the alias creation syntax were the same, but I guess alias creation could always be some_alias = 3 no matter the display format setting. Just thinking "out loud".
When a new users sees this on the screen:
some_alias = 3
for a cell with a value of 3 and the alias is "some_alias"
This might infer to the new user that an alias can be created in the same manner. For example, to create a cell with this alias and this value, enter into the cell:
some_alias = 3
That could be a useful feature to have, but probably is much more complex since it is parsing user input. I think it would be good if the display format and the alias creation syntax were the same, but I guess alias creation could always be some_alias = 3 no matter the display format setting. Just thinking "out loud".
Re: Display alias in spreadsheet
@TheMarkster
Yes, I didn't tried initially to move stuff around, but now it's done ! A separate "Display Settings" group Note that don't know which size the spacing, highlighted in red, should have.
Regarding your proposal, I don't feel we need it, nor I could do do it, I would involve a lot of work, I feel. What I've done here is just transform the 'look and feel" of the cell, at the last stage of render, in order to reduce impact on the rest (in particular processing). Adding an option to edit alias on the fly would be another work, imho...
Moreover, the "display alias" option should be deactivated by default, so that new user would not have to learn that additionally. Only when needed they could activate it, and a this point they should be aware enough to figure out how to deal this that.
Yes, I didn't tried initially to move stuff around, but now it's done ! A separate "Display Settings" group Note that don't know which size the spacing, highlighted in red, should have.
Regarding your proposal, I don't feel we need it, nor I could do do it, I would involve a lot of work, I feel. What I've done here is just transform the 'look and feel" of the cell, at the last stage of render, in order to reduce impact on the rest (in particular processing). Adding an option to edit alias on the fly would be another work, imho...
Moreover, the "display alias" option should be deactivated by default, so that new user would not have to learn that additionally. Only when needed they could activate it, and a this point they should be aware enough to figure out how to deal this that.
Re: Display alias in spreadsheet
@0penBrain
Been testing the case you mention in the PR :
"It should be thoroughly tested with cases like copy/pasting cell, using cell in a an expression, and exporting."
Copy/paste: Work as intended, ie copy the value of the cell, or the expression, if there is one, as if no alias where involved.
Using in expression: My spreadsheet example show that the expression "diameter = 2 / radius" work fine.
Exporting: Alias are not shown in the outputted data. Exporting my example produce :
which should be the previous behaviour.
I want to emphasis the fact that I'm only modifying the display output of the cells, not the actual value, hence I'm not surprised that everything work nicely. Indeed if for instance the exported were using the same display method, that could cause trouble, so checking doesn't hurt !
BTW : is there a test in the CI that check the export of an given sheet ?
Been testing the case you mention in the PR :
"It should be thoroughly tested with cases like copy/pasting cell, using cell in a an expression, and exporting."
Copy/paste: Work as intended, ie copy the value of the cell, or the expression, if there is one, as if no alias where involved.
Using in expression: My spreadsheet example show that the expression "diameter = 2 / radius" work fine.
Exporting: Alias are not shown in the outputted data. Exporting my example produce :
Code: Select all
radius 3
diameter 6
28.2743
I want to emphasis the fact that I'm only modifying the display output of the cells, not the actual value, hence I'm not surprised that everything work nicely. Indeed if for instance the exported were using the same display method, that could cause trouble, so checking doesn't hurt !
BTW : is there a test in the CI that check the export of an given sheet ?
Re: Display alias in spreadsheet
The rule for quality is not to bet but to test.
Humm I think so but better to check. Even maybe @chennes finished adding a test for copy/paste.BTW : is there a test in the CI that check the export of an given sheet ?
- adrianinsaval
- Veteran
- Posts: 5551
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Display alias in spreadsheet
AFAIK this is not something that should be set to fixed value, the widgets should be in a horizontal layout I think, and either be expanding themselves or have a expanding spacer.