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 mesh actions to 3d viewport context menu #6813

Merged
merged 17 commits into from
Feb 9, 2023

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Feb 3, 2023

This pr adds some mesh-related items to the context menu in the 3d viewport.
Note that finding/opening the mesh/segment of the mesh in the segments tab is not included, as this requires #5792 to be implemented. IMO this pr shouldn't wait for these changes as the current items are already valuable enough to be merged :shipit:.

Note, that this pr is affected by bug #6814. (The context menu needs to be opened twice under certain circumstances)

URL of deployed dev instance (used for testing):

Steps to test:

  • Open a tracing with meshes. E.g. open a new hybrid tracing with an existing segmentation layer. Compute an ad-hoc mesh using the context menu in the e.g. xy viewport.
  • Hover the mesh in the 3d viewport and open the context menu (likely needed twice).
  • Play around with the new options (hide, remove, jump, and listing the name / segment id)
  • In case the name of the segment of the mesh is very long, the name will be abbreviated and fully available via a tooltip.

Issues:


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

@MichaelBuessemeyer MichaelBuessemeyer self-assigned this Feb 3, 2023
infoRows.push(
<InfoMenuItem key="copy-cell">
<div className="cell-context-icon" />
Segment Name: {segmentName}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure how to indicate that this menu field displays the segment's name. First, I wrote Segment Name: as a prefix. But this seems to be too long IMO. Therefore I replayed it with a name tag icon. Does this make sense? Do you have a better suggestion?

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Feb 6, 2023

I'll do the docs update and the changelog entry on Thursday (I think).

But it should be ready for the 1st code review :)

@MichaelBuessemeyer MichaelBuessemeyer marked this pull request as ready for review February 6, 2023 11:54
@MichaelBuessemeyer
Copy link
Contributor Author

@philippotto If you think daniel has more time / is better suited for the review, please just assign him 🙏

@MichaelBuessemeyer MichaelBuessemeyer changed the title [WIP] Add mesh actions to 3d viewport context menu Add mesh actions to 3d viewport context menu Feb 6, 2023
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.

Code looks already quite good 👍 When the CI is green, I can test it on a dev instance :)

frontend/javascripts/libs/utils.ts Show resolved Hide resolved
frontend/javascripts/oxalis/view/context_menu.tsx Outdated Show resolved Hide resolved
@@ -1090,15 +1188,29 @@ function ContextMenuInner(propsWithInputRef: Props) {
);
}

if (segmentIdAtPosition > 0) {
if (segmentIdAtPosition > 0 || maybeClickedMeshId != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Could it be that both are defined? Or is one case only for the data viewports and the second case only for the 3D viewport? If both were possible, the user wouldn't know which ID is shown, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not possible that both are defined. The segmentId is calculated based upon the calculated global position of where the context menu is opened. The function used for that is _calculateMaybeGlobalPos. Thus in case of the 3d viewport, the segmentId will never be defined.
And the maybeClickedMeshI can only be defined when the context menu is opened in the 3d viewport. Thus if on variable is defined / > 0 the other cannot. They exclude each other 🎉 .

I am personally not perfectly happy with my solution here, but other alternatives would me more code duplication. Thus I added a comment shortly explaining that only one of them can be defined.

Copy link
Member

Choose a reason for hiding this comment

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

It is not possible that both are defined. The segmentId is calculated based upon the calculated global position of where the context menu is opened. The function used for that is _calculateMaybeGlobalPos. Thus in case of the 3d viewport, the segmentId will never be defined.
And the maybeClickedMeshI can only be defined when the context menu is opened in the 3d viewport. Thus if on variable is defined / > 0 the other cannot. They exclude each other tada .

Great 👍 Thanks for the explanation!

I am personally not perfectly happy with my solution here, but other alternatives would me more code duplication. Thus I added a comment shortly explaining that only one of them can be defined.

Yeah, I think, it's a good trade-off.

@philippotto
Copy link
Member

philippotto commented Feb 9, 2023

Just gave it a whirl and it worked quite well 👍 Great work!

Not, that this pr is affected by bug #6814. (The context menu needs to be opened twice under certain circumstances)

Do you know these circumstances? For me, it always worked on the first try 🤔

I am unsure how to indicate that this menu field displays the segment's name. First, I wrote Segment Name: as a prefix. But this seems to be too long IMO. Therefore I replayed it with a name tag icon. Does this make sense? Do you have a better suggestion?

Two ideas:

  • I like the name tag icon, but I'd give it a tooltip (only the icon) which says "Segment Name"
  • I'd only display the name if it really is defined. Otherwise, it's redundant (see screenshot).
    image

One thing which caught my eye is this:

  • If I rightclick somewhere in the 3d viewport where no mesh or skeleton is, I get the following context menu:
    image
    At first, I thought: cool, now I can even load a mesh for a segment which is rendered onto one of the planes in the 3d viewports. However, a) this doesn't work (would be complicated to support probably) and b) these context options also show up when rightclicking a white area. So, I assume this case is just not handled properly somehow? I think, it should simply show "No actions available" or something like this (I think, this string already exists in the context menu module somewhere).

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Feb 9, 2023

Do you know these circumstances? For me, it always worked on the first try 🤔

Yeah, it is actually hard to reproduce. For me, it always worked when I created an ad-hoc mesh in the zy viewport and then immediately hovered over a mesh in the 3d viewport without clicking anywhere and then opening the context menu. Then it says "no data" 🤷‍♂️.
The same bug already exists on the master (wk-demo):

  • create a tracing
  • create some nodes in the yz viewport
  • open the context menu in the yz viewport and close it by also clicking somewhere in the yz viewport
  • hover a skeleton node in the 3d viewport and right-click. The menu is empty although it shouldn't be. Then reponing the context menu shows options.

One thing which caught my eye is this:

This definitely shouldn't be the case. I'll investigate this :)

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Feb 9, 2023

And also: Please note, that I added the change of words in the upload view where "uploaded" changed to "imported".
Bildschirmfoto 2023-02-09 um 11 59 20

@MichaelBuessemeyer
Copy link
Contributor Author

I fixed the bug and mentioned the new mesh-related context menu items in the docs

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 👍

@philippotto philippotto merged commit 38a942a into master Feb 9, 2023
@philippotto philippotto deleted the add-mesh-actions-to-3d-context-menu branch February 9, 2023 16:31
hotzenklotz added a commit that referenced this pull request Feb 10, 2023
…tarea

* 'master' of github.com:scalableminds/webknossos:
  Add mesh actions to 3d viewport context menu (#6813)
hotzenklotz added a commit that referenced this pull request Feb 10, 2023
* textarea:
  Add mesh actions to 3d viewport context menu (#6813)
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.

Context-menu for 3D viewport
2 participants