Display alias in spreadsheet

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Shalmeneser
Veteran
Posts: 9558
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: Display alias in spreadsheet

Post by Shalmeneser »

value == alias
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Display alias in spreadsheet

Post by adrianinsaval »

adrianinsaval wrote: Fri Feb 04, 2022 7:53 pmmaybe it's better if your keywords are for example %a and %v
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 reference
Attachments
Screenshot 2022-02-04 191542.png
Screenshot 2022-02-04 191542.png (17.3 KiB) Viewed 1077 times
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

adrianinsaval wrote: Fri Feb 04, 2022 7:53 pm
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 ?
agreed 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.

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.
Yes, that would make a printf-format like, which is broadly understood :)
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

adrianinsaval wrote: Fri Feb 04, 2022 10:16 pm
adrianinsaval wrote: Fri Feb 04, 2022 7:53 pmmaybe it's better if your keywords are for example %a and %v
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 reference
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.
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

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
Screenshot_2022-02-07_14-45-37.png
Screenshot_2022-02-07_14-45-37.png (15.59 KiB) Viewed 947 times
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 :)
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Display alias in spreadsheet

Post by TheMarkster »

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".
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

@TheMarkster

Yes, I didn't tried initially to move stuff around, but now it's done ! A separate "Display Settings" group :)
Screenshot_2022-02-08_11-30-15.png
Screenshot_2022-02-08_11-30-15.png (26.1 KiB) Viewed 865 times
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.
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

@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 :

Code: Select all

radius	3
diameter	6
	28.2743
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 ?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Display alias in spreadsheet

Post by openBrain »

dpoen wrote: Tue Feb 08, 2022 10:44 am 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.
The rule for quality is not to bet but to test. ;)
BTW : is there a test in the CI that check the export of an given sheet ?
Humm I think so but better to check. Even maybe @chennes finished adding a test for copy/paste.
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: Display alias in spreadsheet

Post by adrianinsaval »

dpoen wrote: Tue Feb 08, 2022 10:33 am Screenshot_2022-02-08_11-30-15.png
Note that don't know which size the spacing, highlighted in red, should have.
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.
Post Reply