Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to hide tree edges #7296

Merged
merged 17 commits into from
Sep 18, 2023
Merged

Add option to hide tree edges #7296

merged 17 commits into from
Sep 18, 2023

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Aug 24, 2023

This PR makes it possible for users to hide the edges of tree and also persist this setting.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Open a tracing
  • Create two trees
  • Enable/Disable the edge visibility of the trees using the context menu in the skeleton tab
  • The nodes should always be visible (unless the whole tree is turned invisible)

TODOs:

  • Adapt Tracing Store to changes. I need your help here @fm3 or maybe @frcroth
  • [ ] Maybe also adapt wklibs client (as the trees have a new property) decided to defer that
  • [ ] Adapt NML reading & writing decided to defer that

Issues:


(Please delete unneeded items, merge only when none are left open)

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Aug 24, 2023

@fm3 (or @frcroth) I am struggling with the tracing store as the newly added skeleton update action updateTreeEdgesVisibility still needs to be added. The same goes for the new property each tree now has (if it does not yet exist the frontend sets a default for skeletons retrieved by the server).

The tracingstore currently throws the following error:
image

Could you please help me out here and add the necessary changes?

And maybe you know whether wklibs needs to be adjusted to comply with the newly added property.

@fm3
Copy link
Member

fm3 commented Aug 24, 2023

Sure, we can add that. Just to make sure I’m understanding this correctly: There is a new update action that sets for a specific tree the hideEdges boolean? So I would adapt the skeleton proto definition to reflect that, and add the update action in the backend?

I’m wondering if the boolean’s naming is ideal. Since trees also have isVisible, maybe edgesAreVisible = true? That would also match the name “updateTreeEdgesVisibility”. But I don’t have a strong opinion here.

Related: Should we also adapt the NML format? In this case, we could indeed also adapt the python libs to get/set this boolean. But I’d say adapting the libs not super important/urgent.

@MichaelBuessemeyer
Copy link
Contributor Author

Sure, we can add that. Just to make sure I’m understanding this correctly: There is a new update action that sets for a specific tree the hideEdges boolean? So I would adapt the skeleton proto definition to reflect that, and add the update action in the backend?

I hope so, yes 😅. But we can talk about my changes a little before you start so you only make the necessary changes. You text me when you want to start :)

I’m wondering if the boolean’s naming is ideal. Since trees also have isVisible, maybe edgesAreVisible = true? That would also match the name “updateTreeEdgesVisibility”. But I don’t have a strong opinion here.

I noticed the same thing in the middle of coding these changes. Thus I simply applied your suggestion and renamed the property to edgesAreVisible.

Related: Should we also adapt the NML format? In this case, we could indeed also adapt the python libs to get/set this boolean. But I’d say adapting the libs not super important/urgent.

Oh yeah, that's right. I think I already adjusted the reading nml in the frontend. But the writer still needs to be adjusted 👍. I added the point to the ToDos.

@fm3
Copy link
Member

fm3 commented Aug 28, 2023

@MichaelBuessemeyer I added the backend changes, please see if they work for you as intended :)

Note that we decided against adapting NML (and thus the python libs) for the moment, compare https://scm.slack.com/archives/C5AKLAV0B/p1693224632337739?thread_ts=1684748763.542109&cid=C5AKLAV0B

Looks like the snapshot tests fail, possibly because the proto is now slightly different with the new property? Let me know if I need to change anything for that

@MichaelBuessemeyer MichaelBuessemeyer marked this pull request as ready for review September 1, 2023 07:32
Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me overall 👍 why didn't you need to adapt the edge_shader, though? don't the edges support alpha and 0.5 is then interpreted as 0, anyway? I think, you will need to change this, since the #7136 PR added alpha support for edges (because these can get half-transparent when going from one t value to another).

And another note: We have a generic update-tree-action which could have been used for updating the edgesAreVisible parameter. However, now that we have the dedicated update action, it's also fine :)

@@ -721,6 +722,7 @@ export function parseNml(nmlString: string): Promise<{
isVisible: _parseFloat(attr, "color.a") !== 0,
groupId: groupId >= 0 ? groupId : DEFAULT_GROUP_ID,
type: _parseTreeType(attr, "type", TreeTypeEnum.DEFAULT),
edgesAreVisible: _parseBool(attr, "edgesAreVisible", true),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for parsing right? what about serialization? can be invoked via the trees-tab ("save selected trees as nml" or sth like that)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I did not take care of serialization. Internally we agreed to postpone the support of the new edgesAreVisible field in nmls. Thus I did not implement any NML support besides what is needed for typescript. This line is needed because the created object currentTree in line 712, because the field edgesAreVisible is required by this object. Alternatively, I could set the value to always be true, if you prefer this variation over already trying to parse a value that is not yet serialized, I would also be fine with that :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, makes sense :)

@philippotto
Copy link
Member

philippotto commented Sep 5, 2023

image

The icon doesn't look good with the dark mode 🙈

@MichaelBuessemeyer
Copy link
Contributor Author

why didn't you need to adapt the edge_shader, though? don't the edges support alpha and 0.5 is then interpreted as 0, anyway?

Exactly 👍

I think, you will need to change this, since the #7136 PR added alpha support for edges (because these can get half-transparent when going from one t value to another).

Ok, I'll find a way 👍

And another note: We have a generic update-tree-action which could have been used for updating the edgesAreVisible parameter. However, now that we have the dedicated update action, it's also fine :)

🤔 I was following the way the visibility of the whole tree is updated. This has its own action. But this is potentially due to multiple of these update actions later being combined into a single action.
I can still undo these changes and use the regular tree update action, if you think, that's cleaner. This shouldn't take up much time, right?

@fm3
Copy link
Member

fm3 commented Sep 7, 2023

I think there is no harm in the dedicated update action.

I’m not certain anymore, but I think the update action for the tree visibility was introduced because of backwards compatibility. There are old update actions stored in fossildb, as they are applied lazily in the backend. When applying those, we would have to interpret the missing field, and consider whether it should mean the visibility is not changed, or is set to true. While introducing that logic would be fine by me as well, the dedicated action is fine for me as well. The only downside might be a busier history. Philipp, if you think it would be better to unify this into the update tree action, we can certainly do it as well.

@MichaelBuessemeyer
Copy link
Contributor Author

I think, you will need to change this, since the #7136 PR added alpha support for edges (because these can get half-transparent when going from one t value to another).

This pr works perfectly together with the changes of the nd dataset pr. There were no changes needed from my side and it still works 💯

The icon doesn't look good with the dark mode 🙈

I also fixed the icon in dark mode and increased the size of the rectangles a little.
image
image

@philippotto
Copy link
Member

I think there is no harm in the dedicated update action.

Yes, I agree.

I think, you will need to change this, since the #7136 PR added alpha support for edges (because these can get half-transparent when going from one t value to another).

This pr works perfectly together with the changes of the nd dataset pr. There were no changes needed from my side and it still works 💯

The icon doesn't look good with the dark mode 🙈

I also fixed the icon in dark mode and increased the size of the rectangles a little. image image

Awesome 👍 Will test now.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, works great for me :)

@philippotto philippotto merged commit 1f07395 into master Sep 18, 2023
@philippotto philippotto deleted the hide-tree-edges branch September 18, 2023 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to make edges of a tree invisible
3 participants