微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Autodesk Forge中创建新面板

如何解决在Autodesk Forge中创建新面板

我创建了自己的按钮,没有任何onClick事件。我还扩展了属性面板。单击先前创建的按钮后,如何创建自己的面板并显示它?

解决方法

function ShowDocker(viewer) {

SimplePanel = function(parentContainer,id,title,content,x,y) {
    this.content = content;
    Autodesk.Viewing.UI.DockingPanel.call(this,parentContainer,'');
    // Auto-fit to the content and don't allow resize.  Position at the coordinates 
    //given.
    this.container.style.height = "auto";
    this.container.style.width = "auto";
    this.container.style.resize = "auto";
    this.container.style.left = x + "%";
    this.container.style.top = y + "%";
};

SimplePanel.prototype = Object.create(Autodesk.Viewing.UI.DockingPanel.prototype);
SimplePanel.prototype.constructor = SimplePanel;
SimplePanel.prototype.initialize = function() {
    // Override DockingPanel initialize() to:
    // - create a standard title bar
    // - click anywhere on the panel to move
    // - create a close element at the bottom right
    //
    this.title = this.createTitleBar(this.titleLabel || this.container.id);
    this.container.appendChild(this.title);
    this.closer = this.createCloseButton(); 
    this.container.appendChild(this.title);
   this.title.appendChild(this.closer);
   this.container.appendChild(this.content);

this.initializeMoveHandlers(this.title);
this.initializeCloseHandler(this.closer);
};
var tag = document.createElement('testdiv');
var text = document.createTextNode("Here goes your html");
tag.appendChild(text);
var docpanel = new SimplePanel(this.viewer.container,'AllPropertiesPanels','All 
Properties',tag,50,80);
docpanel.setVisible(true);

}

尝试使用上面的代码,通过为面板分配可见性,可以使面板在单击按钮时显示和消失

docpanel.setVisible(true/false)
,

或者,如果您对显示自定义键值数据的更专业的面板感兴趣,则可以参考其中的Learn Forge tutorials来解释如何完成此操作:

// Subclassing a "property panel" class
class ModelSummaryPanel extends Autodesk.Viewing.UI.PropertyPanel {
    constructor(viewer,container,options) {
        super(container,options);
        this.viewer = viewer;
    }
}

let panel = new ModelSummaryPanel(viewer,viewer.container,'my-panel','My Panel');
panel.setVisible(true);
panel.addProperty('Key 1','Value 1','Category 1');
panel.addProperty('Key 2','Value 2','Category 1');
panel.addProperty('Key 3','Value 3','Category 1');
panel.addProperty('Key A','Value A','Category 2');

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。