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

Display alias in spreadsheet

Post by dpoen »

Hello everyone !

To introduce myself, as requested, I'm a developer working with FreeCAD on robotic topic, and use it to format CAD data before using it into some simulation. Also at home I'm planning to make some model for myself, and interested in making them parametric using the Spreadsheet.

Please note that I've no way to log in the bug tracker (can't get the validation mail :/) So I'm just posting my idea here, hope someone could drive me to the right place, if need be, thank :D
Moreover i don't want to fork FreeCAD just to propose a small change like that, and I would like to share that with you beforehand !

I've been playing around with the Spreadsheet, and as stated here : https://forum.freecadweb.org/viewtopic.php?t=17352 We need to duplicate data between the "alias" and a cell near to display the actual value of the alias to help keep track of it. And I agree that it's not very nice...
The change I'm proposing display in the cell something like "alias = value", instead of "value", but **without disturbing** the actual value of the cell, which could be used as usual in formula, with unit etc.
I'm only modifying the final string that is used to display the cell content.

I'm linking a patch that contain my change to achieve it, but it's really straightforward ! Apply it on the master branch.
freecad.patch.txt
The patch for the change, to be applied on the paster branch.
The .txt extension is just to be able to link on the post :)
(2.58 KiB) Downloaded 31 times
It's just a PoC right now, and if it's okay, maybe we should add a tick box to display them at the Sheet level, to allows the user to toggle it on/off ? Just an idea.
Moreover, my code is a big copy/paste and add code duplication, which I don't like, but what do you think about it ? This part of the code has already a fair amount of code duplication :/

Thank for reading that, and if the idea is fine, to help me out to go through the whole PR process :)

Cheers
chrisb
Veteran
Posts: 53921
Joined: Tue Mar 17, 2015 9:14 am

Re: Display alias in spreadsheet

Post by chrisb »

I don't quite understand what you want, but it was definitely right to post here first, before entering anything in the tracker.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Display alias in spreadsheet

Post by openBrain »

The best to do would be to push a PR so it's testable.
Before that, the behavior should be made optional and ideally the formatting should be settable by the user.
Did you check what happens when you copy/paste a cell ?
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

I've opened a PR to explain better what I means, (the fork process it was actually way easier than I thought !)
It's here : https://github.com/FreeCAD/FreeCAD/pull/5489
I've not made yet the behaviour optional or anything like that, just because I want some "green light" from you that is a acceptable feature. Given the fact that implementing the "optionality" part might take a fair amount of learning to make in work (I've never work on these large GUI setup ;) )
But it's obviously a nice touch, and I would be happy to work on that !
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

On the PR, we started a discussion, and the two messages was :

@adrianinsaval
Application wide preference sounds like a good idea to me, a command to toggle on/off in spreadsheet workbench can make it more easy to access. Formatting could be left as a parameter only, an advance feature for powerusers. A different color for the extra text would be good if possible. Also there's code duplication in your PR, perhaps it's worth creating a function and just using that?

And my reply :
I agree that application wide could be nice, that would allows any user to get the formatting they like even on document they exchange with others people.
I've no idea how to format the text, but that would be very pleasing to the eyes. I will try to understand how to do, if you got any reference/tips I would take that :)
Yes code duplication is one of my concern... But to be fair, this whole part of the code seems to me like having already duplication :/ So For the PoC I've simply followed the previous pattern to get thing working quickly and keep the change smalls. But I would be glad to try to refactor a bit this code, if you feels that it's necessary and a good idea !
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Display alias in spreadsheet

Post by openBrain »

Moved to "open discussion" so it's more visible by the FC user community. ;)
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

Just as a note at least for myself, I could take example on what have been done here https://forum.freecadweb.org/viewtopic.php?f=10&t=61153 to get a somewhat coherent design in term of formatting, option etc...
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Display alias in spreadsheet

Post by TheMarkster »

Just a few notes:

1) Already you get the alias name as a tooltip when hovering the mouse over a cell.

2) It should be user-configurable because if the alias name is long you won't be able to see the value without widening the cell width.
Snip macro screenshot-5e758c.png
Snip macro screenshot-5e758c.png (27.14 KiB) Viewed 1895 times
And, personally, I will have the alias in the cell to the left, so I don't really need this functionality.

3) There is a preferences page in edit menu -> preferences for the spreadsheet workbench. Such a setting could go there. But it would also be good to have a button or checkbox to enable directly from within the spreadsheet view, alternatively or maybe both, in the context menu. A user could quickly toggle this on to see the aliases, then back off after finding the cell he wants to edit. I would not prefer this button in the spreadsheet workbench, but rather in the view. That way it is not necessary to switch to SS WB to toggle this setting.

4) The alias could go after the value so that if the cell isn't wide enough the user can still see the value, which is more important than seeing the alias if one cannot see both.

Something like this for a cell with a value of 3 and alias = some_really_long_alias_name:

3 [some_really_long_alias_name]



It is good to see someone taking the initiative to add a feature he deems worthy of being added.
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Display alias in spreadsheet

Post by dpoen »

@TheMarkster

1) Did notice that, very useful indeed !

2) Yes, I do agree.
"And, personally, I will have the alias in the cell to the left, so I don't really need this functionality. " Yes, that the thing I want to avoid :) But that why making it optional should be mandatory, to avoid messing up previous spreadsheet built that way. And also not be a pain to user that prefer duplicate the alias name in an adjacent cell !
btw, I fully understand what you mean, however, even if you don't want to enlarge the B column, you are forced to enlarge the A column. At the end of the day, long alias will take a lot of space anyway.

3) Yes, edit menu -> preferences for the spreadsheet workbench is where is should belong
"then back off after finding the cell he wants to edit." Didn't thought about that use case, but is actually clever !
I agree on your statements.

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 ?
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Display alias in spreadsheet

Post by adrianinsaval »

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.
Post Reply