Remember visibility status when changing between flat list and tree view.

This commit is contained in:
kovacsv 2021-11-15 07:47:50 +01:00
parent 2ccc67fe1a
commit ef83c0bfd3
3 changed files with 25 additions and 7 deletions

View File

@ -116,7 +116,6 @@ OV.Navigator = class
},
onViewTypeChanged : () => {
this.SetSelection (null);
this.ShowAllMeshes (true);
}
});

View File

@ -66,7 +66,8 @@ OV.MeshItem = class extends OV.TreeViewButtonItem
}
if (recurse === OV.NavigatorItemRecurse.Parents) {
if (this.parent instanceof OV.NodeItem) {
this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
let parentIsVisible = this.parent.CalculateIsVisible ();
this.parent.SetVisible (parentIsVisible, OV.NavigatorItemRecurse.Parents);
}
}
}
@ -107,11 +108,14 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
CalculateIsVisible ()
{
let isVisible = false;
this.EnumerateMeshItems ((meshItem) => {
if (meshItem.IsVisible ()) {
isVisible = true;
for (let child of this.children) {
if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
if (child.IsVisible ()) {
isVisible = true;
break;
}
}
});
}
return isVisible;
}
@ -138,7 +142,8 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
}
if (recurse === OV.NavigatorItemRecurse.Parents || recurse === OV.NavigatorItemRecurse.All) {
if (this.parent instanceof OV.NodeItem) {
this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
let parentIsVisible = this.parent.CalculateIsVisible ();
this.parent.SetVisible (parentIsVisible, OV.NavigatorItemRecurse.Parents);
}
}
}

View File

@ -443,8 +443,22 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
function UpdateView (panel, importResult, isHierarchical)
{
let hiddenMeshInstanceIds = [];
panel.EnumerateMeshItems ((meshItem) => {
if (!meshItem.IsVisible ()) {
hiddenMeshInstanceIds.push (meshItem.GetMeshInstanceId ());
}
return true;
});
panel.ClearMeshTree ();
panel.FillMeshTree (importResult.model);
for (let meshInstanceId of hiddenMeshInstanceIds) {
let meshItem = panel.GetMeshItem (meshInstanceId);
meshItem.SetVisible (false, OV.NavigatorItemRecurse.Parents);
}
UpdateButtonsStatus (panel.buttons, panel.showTree, isHierarchical);
panel.callbacks.onViewTypeChanged ();
}