Refactor object reload to handle 3mf files #16610
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
3mf Files can have multiple models in them, and they can be named individually, but Cura was renaming all these models with its filename, not really an issue by itself but having the original names is better when there are many models in the file.
Also, when the file has multiple models, and user reloads them (right click -> Reload All Models), all objects from that file where being replaced by the first model in the file.
Another minor issue was that when reloading, Cura would read the same file multiple times, one for each model.
! Important: This should be accompanied by Ultimaker/Uranium#898, so that both model reload methods have the same behaviour
Type of change
How Has This Been Tested?
Confirmed other filetypes where not affected by the refactor:
Opened a OBJ file and reloaded.
Opened STL file and reloaded.
Opened gcode file, and reloaded.
Loaded a 3MF file into Cura, verified the name of the models in the app are the model name in the file.
Right click the window and selected "Reload All Models", verified each model get replaced as expected.
Updated the 3MF file removing one of the models, ignored the "File has been modified" message{1}, right click->"Reload All Models". Confirmed it works as before and keep the mesh in the scene.
Updated the 3MF file, adding a new mesh into it, ignored the "File has been modified" message{1} and reloaded the models via right click. Confirmed it works as before and the new mesh is NOT loaded in the scene{2}.
{1}: The message about the file being modified and asking to reload is handles by Uranium, and not in Cura. Improvements to that process will be committed to Uranium.
{2}: This should be an improvement, as the newly added model should be loaded when we reload a file. This however should be accompanied with an update to the process described in {1} so that both have the same behaviour.
Test Configuration:
Checklist: