Autodesk.Viewing.UI.ModelStructurePanel
Extends DockingPanel
new ModelStructurePanel(parentContainer,id,title,options)
Model structure panel.
Sets the model structure panel for displaying the loaded model.
Parameters
parentContainer* HTMLElement | The container for this panel. |
id* string | The id for this panel. |
title* string | The initial title for this panel. |
options object | An optional dictionary of options. |
startCollapsed boolean | When true, collapses all of the nodes under the root. |
Methods
addClass(id,className)
Given a node’s id, adds the given CSS class to this node.
Parameters
id* string | The id of a node in an Autodesk.Viewing.Model |
className* string | The CSS class to add |
Returns
Type | Description |
---|---|
boolean |
|
addEventListener(target,eventId,callback)
Inherits addEventListener
Adds an event listener to a given target that has an addEventListener(event, callback) API. These event listeners are tracked by the DockingPanel and are automatically removed on uninitialize.
Parameters
target* object | The target that will fire the event. |
eventId* string | The event to be listened to. |
callback* function | The callback to execute when the event is fired. |
addVisibilityListener(callback)
Inherits addVisibilityListener
Adds a callback to call when this DockingPanel changes visibility.
Parameters
callback* function | A function that takes in a single boolean parameter indicating the current visibility state. |
createScrollContainer(options)
Inherits createScrollContainer
Creates a scroll container element to add to this DockingPanel. Call this method during initialize() if a scroll container is needed. The function will create the scroll container and make it available via the “scrollContainer” property of the DockingPanel.
Parameters
options object | An optional dictionary of options. |
left boolean | When true, the scrollbar appears on the left. |
heightAdjustment number | The scroll container height is 100% of the panel minus the height adjustment. Provide a value to account for other elements in the panel like a title bar. |
marginTop number | The marginTop setting for the scroll container’s CSS style, in pixels. |
createTitleBar(title)
Inherits createTitleBar
Creates a title bar element to add to this DockingPanel. Call this method during initialize() if a standard title bar is desired, and then add it to an existing container.
Parameters
title* string | The text to use in the title bar. |
Returns
Type | Description |
---|---|
HTMLElement | The created title bar. |
getContainerBoundingRect()
Inherits getContainerBoundingRect
Returns the parent’s container bounding rectangle.
Returns
Type | Description |
---|---|
ClientRect | Bounding rectangle of the parent. |
getContentSize()
Returns the width and height to be used when resizing the panel to the content.
Returns
Type | Description |
---|---|
Object |
getNodeClass(node)
Override this to specify the CSS classes of a node. This way, in CSS, the designer can specify custom styling per type. By default, an empty string is returned.
Parameters
node* Object | A node in an Autodesk.Viewing.Model |
Returns
Type | Description |
---|---|
string | CSS classes for the node |
getNodeLabel(node)
Override this method to specify the label for a node. By default, this is the node’s name, or ‘Object ‘ + object id if the name is blank.
Parameters
node* Object | A node in an Autodesk.Viewing.Model |
Returns
Type | Description |
---|---|
string | Label of the tree node |
initialize()
Inherits initialize
Creates the sub-elements of this DockingPanel. Override this in derived classes. The default implementation is to create a title bar with the title or id provided in the constructor. The title bar also acts as the move handler for the DockingPanel. Finally, a close button is added to the top right corner.
initializeCloseHandler(closer)
Inherits initializeCloseHandler
Initializes the given HTMLDomElement as the close handle for this DockingPanel. When this element is clicked, this DockingPanel is hidden.
Parameters
closer* HTMLElement | The DOM element that will act as the close handle. |
initializeMoveHandlers(mover)
Inherits initializeMoveHandlers
Initializes the given HTMLDomElement as the move handle for this DockingPanel. When this element is clicked and dragged, this DockingPanel is moved.
Parameters
mover* HTMLElement | The DOM element that will act as the move handle. |
isGroupCollapsed(node)
Returns true if the group is collapsed.
Parameters
node* Object | The node in the tree. |
Returns
Type | Description |
---|---|
Boolean |
|
isGroupNode(node)
Override this method to specify whether or not a node is a group node. By default, a node is considered a group if it has a ‘children’ property containing an array with at least one element.
Parameters
node* Object | A node in an Autodesk.Viewing.Model |
Returns
Type | Description |
---|---|
boolean | true if this node is a group node, false otherwise |
isVisible()
Inherits isVisible
Gets the new visibility state of this DockingPanel.
Returns
Type | Description |
---|---|
boolean | Whether or not the panel is visible. |
onClick(node,event)
Override this method to do something when the user clicks on a tree node
Parameters
node* Object | A node in an Model |
event* Event |
onDoubleClick(node,event)
Override this to do something when the user double-clicks on a tree node
Parameters
node* Object | A node in an Model |
event* Event |
onEndMove(event,endX,endY)
Inherits onEndMove
Override this event to be notified when this panel ends a move operation.
Parameters
event* MouseEvent | The mouseup event. |
endX* number | The ending x position of the panel in pixels. |
endY* number | The ending y position of the panel in pixels. |
onHover(node,event)
Override this to do something when the user hovers on a tree node
Parameters
node* Object | A node in an Model |
event* Event |
onIconClick(node,event)
Override this to do something when the user clicks on a tree node’s icon. By default, groups will be expanded/collapsed.
Parameters
node* Object | A node in an Model |
event* Event |
onMove(event,currentX,currentY)
Inherits onMove
Override this to be notified when this panel is moved. Note, do not forget to call this base class method in the overriding method.
Parameters
event* MouseEvent | The mousemove event. |
currentX* number | The current x position of the panel in pixels. |
currentY* number | The current y position of the panel in pixels. |
onRightClick(node,event)
Override this to do something when the user right-clicks on a tree node
Parameters
node* Object | A node in an Autodesk.Viewing.Model |
event* Event |
onStartMove(event,startX,startY)
Inherits onStartMove
Override this event to be notified when this panel begins a move operation.
Parameters
event* MouseEvent | The mousedown event. |
startX* number | The starting x position of the panel in pixels. |
startY* number | The starting y position of the panel in pixels. |
onTitleClick(event)
Inherits onTitleClick
Override this method to be notified when the user clicks on the title.
Parameters
event* Event |
onTitleDoubleClick(event)
Inherits onTitleDoubleClick
Override this method to be notified when the user double-clicks on the title.
Parameters
event* Event |
removeClass(id,className)
Given a node’s id, removes the given CSS class from this node.
Parameters
id* string | The id of a node in an Autodesk.Viewing.Model |
className* string | The CSS class to remove |
Returns
Type | Description |
---|---|
boolean |
|
removeEventListener(target,eventId,callback)
Inherits removeEventListener
Removes an existing event listener added using DockingPanel.addEventListener.
Parameters
target* object | The target with the event listener. |
eventId* string | The id of the event being listened to. |
callback* function | The callback executed when the event is fired. |
Returns
Type | Description |
---|---|
boolean | True if the listener was removed successfully; false otherwise. |
resizeToContent(options)
Inherits resizeToContent
Resizes the panel to the current content. Currently this only works on height.
Parameters
options object | An optional dictionary of options. |
maxHeight number | The maximum height to resize this panel. |
setGroupCollapsed(node,collapsed)
Collapse/expand a group node.
Parameters
node* Object | A node to collapse/expand in the tree. |
collapsed* Boolean | True to collapse the group, false to expand it. |
setModel(instanceTree,modelTitle)
Sets the model for this panel to display.
Parameters
instanceTree* InstanceTree | The object tree returned by Autodesk.Viewing.Model.getObjectTree( function(instanceTree) ); |
modelTitle string | An optional title to display for this model. |
setSelection(nodes)
Displays the given nodes as selected in this panel.
Parameters
nodes* Array | An array of Autodesk.Viewing.Model nodes to display as selected |
setTitle(text,options)
Inherits setTitle
Sets the title for this panel.
Parameters
text* string | The title for this panel. |
options Object | An optional dictionary of options. |
localizeTitle boolean | When true, localization is attempted for the given text. |
setVisible(show)
Inherits setVisible
Sets the new visibility state of this DockingPanel.
Parameters
show* boolean | The desired visibility state. |
shouldInclude(node)
Override this method to specify if a tree node should be created for this node. By default, every node will be displayed.
Parameters
node* Object | A node in an Model |
Returns
Type | Description |
---|---|
boolean | true if a node should be created, false otherwise |
uninitialize()
Inherits uninitialize
Performs any clean up necessary. This can include disconnecting UI elements, unregistering event callbacks, etc.
visibilityChanged()
Inherits visibilityChanged
Notification that visibility has been changed by external sources.