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

Segment group batch actions #7164

Merged
merged 51 commits into from Jul 20, 2023
Merged

Segment group batch actions #7164

merged 51 commits into from Jul 20, 2023

Conversation

dieknolle3333
Copy link
Contributor

@dieknolle3333 dieknolle3333 commented Jun 20, 2023

Steps to test:

  • Go to the segments tab in any annotation
  • Make sure you see some segments in the list, e.g. by clicking segments
  • Either create a new group and drop segments or test the following on the root group:
    -- Right-click a group and set the color
    -- Revert setting the color
    -- Load meshes either ad-hoc or precomputed with a meshfile. If there is no meshfile, there should only be the option to load the meshes ad-hoc
    -- Hide/show meshes. The text of the option should be adjusted to the current visibility
    -- Download all meshes of the group. You should receive a zip with the according stl files.

Issues:


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

@dieknolle3333 dieknolle3333 marked this pull request as draft June 20, 2023 19:21
@dieknolle3333 dieknolle3333 self-assigned this Jun 27, 2023
@dieknolle3333 dieknolle3333 marked this pull request as ready for review June 27, 2023 16:34
@dieknolle3333 dieknolle3333 marked this pull request as draft June 27, 2023 16:37
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.

very cool stuff 👍 I left a couple of notes but overall it looks pretty good. other than the refactoring of the per-segment-call code about which we already talked, there is one thing I'm a bit hesitant about: areSegmentsInGroupVisible. this is state you are maintaining in your component, but it can be affected from the outside. for example, if I rightclick into the data viewport and render a mesh, the segment list won't take note of that right now. similarily, if I use the checkbox next to a mesh to hide it, the list component will also run into an outdated state.

instead, you should probably derive this information from the IsosurfaceInformation objects in this.props.isosurfaces[segment.id] (it has a isVisible prop). you might want to use getDerivedStateFromProps for that so that you can build your areSegmentsInGroupVisible state everytime the isosurfaces change.

@dieknolle3333
Copy link
Contributor Author

@philippotto thank you for the review!

I'll just quickly respond to the topic on areSegmentsInGroupVisible:
In my view it was okay if the visibility of some meshes changed without the field noticing, because it was meant as a map for each group, to remember whether the last interaction made all meshes in a group visible or invisible. But you are totally right of course, that the state of the meshes matters if it was manipulated from another place. One example would be groups with only one mesh.

I thought about extracting the visibility from the meshes but I wasn't sure what a good metric in a mixed-visibility group is. If I use the actual isosurface data, is it fine to derive a field called areAnySegmentsInGroupVisible? So if any mesh in the group is visible, clicking the action hides all meshes. Or is it better the other way around? (If any mesh in the group is invisible, clicking the action makes everything visible?) I think intuitively I would prefer the second option.

@philippotto
Copy link
Member

I thought about extracting the visibility from the meshes but I wasn't sure what a good metric in a mixed-visibility group is. If I use the actual isosurface data, is it fine to derive a field called areAnySegmentsInGroupVisible? So if any mesh in the group is visible, clicking the action hides all meshes. Or is it better the other way around? (If any mesh in the group is invisible, clicking the action makes everything visible?) I think intuitively I would prefer the second option.

Yes, i think it's fine to deal with mixed visibilities like you suggested. I don't have a strong opinion whether hide or show are "preferred". If you find the one variant more intuitive, let's go with that :)

@dieknolle3333 dieknolle3333 marked this pull request as ready for review July 10, 2023 16:47
Copy link
Member

@hotzenklotz hotzenklotz left a comment

Choose a reason for hiding this comment

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

Great stuff. Please see my comments on naming variables, functions etc and consistency. Otherwise this is works very well.

frontend/javascripts/oxalis/model/sagas/isosurface_saga.ts Outdated Show resolved Hide resolved
frontend/javascripts/oxalis/model/sagas/isosurface_saga.ts Outdated Show resolved Hide resolved
const { segmentMeshController } = getSceneController();
const zipWriter = new Zip.ZipWriter(new Zip.BlobWriter("application/zip"));
try {
const promises = cells.map((element) => {
Copy link
Member

Choose a reason for hiding this comment

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

Can we call this something more specific / less generic? What do these promise hold? Maybe zipWriterPromises? Or zippedFilesPromises`? Idk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is a promise for each file that's added to the zipWriter. (for reference: https://gildas-lormeau.github.io/zip.js/api/index.html) so I think addFileToZipWriterPromises is long but correct.

frontend/javascripts/oxalis/model/sagas/isosurface_saga.ts Outdated Show resolved Hide resolved
groupTree: generatedGroupTree,
searchableTreeItemList,
prevProps: nextProps,
};
} else {
}
if (prevState.prevProps?.isosurfaces !== isosurfaces) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure I understand the reason for this code. Can you elaborate please. How can I test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code makes sure that changing the visibility of a mesh (e.g. by clicking the checkbox) gets noticed by the segments_view as the visibility is part of the isosurface.
This is needed because I toggle the "Hide/Show meshes" option based on the mesh visibility in the group.
You can test it by loading all meshes in a group. Now, the context menu should say "Hide...". If you deselect any mesh's visibility checkbox, the context menu notices and will then read "Show all meshes".
Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also see philipps comment for this: #7164 (review)

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.

great stuff :) I left some suggestions for simplifying some things further 🤞

@@ -0,0 +1,14 @@
class TransFormStream {}

let mockedWindow = false;
Copy link
Member

Choose a reason for hiding this comment

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

whats the purpose of this variable? if it's needed for some reason, you can add a comment to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omitting it doesn't seem to break anything, so I left it out.
Just for clarification. Technically this could have been used somewhere else because the scope of the variable is global, right? (https://www.w3schools.com/js/js_scope.asp)

Copy link
Member

Choose a reason for hiding this comment

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

Technically this could have been used somewhere else because the scope of the variable is global, right? (https://www.w3schools.com/js/js_scope.asp)

The linked article is a bit confusing (generally, w3schools ist not the best resource; I recommend MDN instead). However, the specific MDN article is also not perfect (it mentions module scope, but doesn't really explain when it comes into play).
To answer your question: no, it could not have been used somewhere else because the variable is module-scoped. That scoping is achieved during the compilation/bundling of all the module files. To get a truly global variable, one has to extend window (in a browser context) or global (in a node context).

const entries = await reader.getEntries();
await reader.close();
const wkwFile = entries.find((entry: Entry) =>
const wkwFile = entries.find((entry: any) =>
Copy link
Member

Choose a reason for hiding this comment

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

I just pushed a commit (I hope the CI passes), which improves the typing a bit.

};
this.setState({
areSegmentsInGroupVisible: newSegmentsInGroupVisible,
});
};

getSegmentsWithMissingLocation = (groupId: number): number[] => {
Copy link
Member

Choose a reason for hiding this comment

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

I'd replace Location with Position here to keep it consistent with the somePosition attribute.

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.

Great :) Code looks good to me and it works great, too 👍

@hotzenklotz hotzenklotz mentioned this pull request Jun 27, 2023
8 tasks
@dieknolle3333 dieknolle3333 merged commit 9cecaab into master Jul 20, 2023
2 checks passed
@dieknolle3333 dieknolle3333 deleted the segment-group-batch-actions branch July 20, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segments Groups
3 participants