Implement fit to window for nodes.
This commit is contained in:
parent
00daf22067
commit
6177c3c169
@ -242,9 +242,10 @@ OV.Navigator = class
|
||||
console.log ('sh');
|
||||
},
|
||||
onFitToWindow : (selectedNodeId) => {
|
||||
console.log ('fit');
|
||||
navigator.FitNodeToWindow (selectedNodeId);
|
||||
}
|
||||
});
|
||||
navigator.navigatorItems.AddNodeItem (nodeId, nodeItem);
|
||||
parentItem.AddChild (nodeItem);
|
||||
nodeItem.ShowChildren (true, null);
|
||||
AddModelNodeToTree (navigator, model, childNode, nodeItem);
|
||||
@ -381,6 +382,16 @@ OV.Navigator = class
|
||||
this.callbacks.updateMeshesSelection ();
|
||||
}
|
||||
|
||||
FitNodeToWindow (nodeId)
|
||||
{
|
||||
let meshInstanceIdSet = new Set ();
|
||||
let nodeItem = this.navigatorItems.GetNodeItem (nodeId);
|
||||
nodeItem.EnumerateMeshItems ((meshItem) => {
|
||||
meshInstanceIdSet.add (meshItem.GetMeshInstanceId ());
|
||||
});
|
||||
this.callbacks.fitMeshesToWindow (meshInstanceIdSet);
|
||||
}
|
||||
|
||||
FitMeshToWindow (meshInstanceId)
|
||||
{
|
||||
this.callbacks.fitMeshToWindow (meshInstanceId);
|
||||
|
||||
@ -74,14 +74,26 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
});
|
||||
this.AddButton (this.showHideButton);
|
||||
}
|
||||
|
||||
EnumerateMeshItems (processor)
|
||||
{
|
||||
for (let child of this.children) {
|
||||
if (child instanceof OV.NodeItem) {
|
||||
child.EnumerateMeshItems (processor);
|
||||
} else if (child instanceof OV.MeshItem) {
|
||||
processor (child);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OV.NavigatorItems = class
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
this.materialIndexToItem = {};
|
||||
this.meshInstanceIdToItem = {};
|
||||
this.materialIndexToItem = new Map ();
|
||||
this.nodeIdToItem = new Map ();
|
||||
this.meshInstanceIdToItem = new Map ();
|
||||
}
|
||||
|
||||
MaterialItemCount ()
|
||||
@ -91,12 +103,12 @@ OV.NavigatorItems = class
|
||||
|
||||
GetMaterialItem (materialIndex)
|
||||
{
|
||||
return this.materialIndexToItem[materialIndex];
|
||||
return this.materialIndexToItem.get (materialIndex);
|
||||
}
|
||||
|
||||
AddMaterialItem (materialIndex, materialItem)
|
||||
{
|
||||
this.materialIndexToItem[materialIndex] = materialItem;
|
||||
this.materialIndexToItem.set (materialIndex, materialItem);
|
||||
}
|
||||
|
||||
MeshItemCount ()
|
||||
@ -104,14 +116,24 @@ OV.NavigatorItems = class
|
||||
return Object.keys (this.meshInstanceIdToItem).length;
|
||||
}
|
||||
|
||||
GetNodeItem (nodeId)
|
||||
{
|
||||
return this.nodeIdToItem.get (nodeId);
|
||||
}
|
||||
|
||||
AddNodeItem (nodeId, meshItem)
|
||||
{
|
||||
this.nodeIdToItem.set (nodeId, meshItem);
|
||||
}
|
||||
|
||||
GetMeshItem (meshInstanceId)
|
||||
{
|
||||
return this.meshInstanceIdToItem[meshInstanceId.GetKey ()];
|
||||
return this.meshInstanceIdToItem.get (meshInstanceId.GetKey ());
|
||||
}
|
||||
|
||||
AddMeshItem (meshInstanceId, meshItem)
|
||||
{
|
||||
this.meshInstanceIdToItem[meshInstanceId.GetKey ()] = meshItem;
|
||||
this.meshInstanceIdToItem.set (meshInstanceId.GetKey (), meshItem);
|
||||
}
|
||||
|
||||
EnumerateMeshItems (processor)
|
||||
@ -125,7 +147,8 @@ OV.NavigatorItems = class
|
||||
|
||||
Clear ()
|
||||
{
|
||||
this.materialIndexToItem = {};
|
||||
this.meshInstanceIdToItem = {};
|
||||
this.materialIndexToItem = new Map ();
|
||||
this.nodeIdToItem = new Map ();
|
||||
this.meshInstanceIdToItem = new Map ();
|
||||
}
|
||||
};
|
||||
|
||||
@ -52,6 +52,11 @@ OV.TreeViewItem = class
|
||||
this.mainElement.click (onClick);
|
||||
}
|
||||
|
||||
IsGroup ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetParent (parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
@ -108,6 +113,7 @@ OV.TreeViewGroupItem = class extends OV.TreeViewItem
|
||||
constructor (name, iconPath)
|
||||
{
|
||||
super (name);
|
||||
this.children = [];
|
||||
this.showChildren = false;
|
||||
|
||||
this.childrenDiv = null;
|
||||
@ -120,6 +126,19 @@ OV.TreeViewGroupItem = class extends OV.TreeViewItem
|
||||
}
|
||||
}
|
||||
|
||||
IsGroup ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AddChild (child)
|
||||
{
|
||||
this.CreateChildrenDiv ();
|
||||
this.children.push (child);
|
||||
child.SetParent (this);
|
||||
child.AddDomElements (this.childrenDiv);
|
||||
}
|
||||
|
||||
ShowChildren (show, onComplete)
|
||||
{
|
||||
this.showChildren = show;
|
||||
@ -147,13 +166,6 @@ OV.TreeViewGroupItem = class extends OV.TreeViewItem
|
||||
}
|
||||
return this.childrenDiv;
|
||||
}
|
||||
|
||||
AddChild (child)
|
||||
{
|
||||
this.CreateChildrenDiv ();
|
||||
child.SetParent (this);
|
||||
child.AddDomElements (this.childrenDiv);
|
||||
}
|
||||
};
|
||||
|
||||
OV.TreeViewGroupButtonItem = class extends OV.TreeViewGroupItem
|
||||
|
||||
@ -257,6 +257,18 @@ OV.Website = class
|
||||
this.viewer.FitSphereToWindow (boundingSphere, true);
|
||||
}
|
||||
|
||||
FitMeshesToWindow (meshInstanceIdSet)
|
||||
{
|
||||
let meshInstanceIdKeys = new Set ();
|
||||
for (let meshInstanceId of meshInstanceIdSet) {
|
||||
meshInstanceIdKeys.add (meshInstanceId.GetKey ());
|
||||
}
|
||||
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
|
||||
return meshInstanceIdKeys.has (meshUserData.originalMeshId.GetKey ());
|
||||
});
|
||||
this.viewer.FitSphereToWindow (boundingSphere, true);
|
||||
}
|
||||
|
||||
UpdateMeshesVisibility ()
|
||||
{
|
||||
this.viewer.SetMeshesVisibility ((meshUserData) => {
|
||||
@ -699,6 +711,9 @@ OV.Website = class
|
||||
fitMeshToWindow : (meshInstanceId) => {
|
||||
this.FitMeshToWindow (meshInstanceId);
|
||||
},
|
||||
fitMeshesToWindow : (meshInstanceIdSet) => {
|
||||
this.FitMeshesToWindow (meshInstanceIdSet);
|
||||
},
|
||||
getMeshesForMaterial : (materialIndex) => {
|
||||
return GetMeshesForMaterial (this.viewer, this.model, materialIndex);
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user