没有GUI的ZoomWindow扩展会中断吗? [英] ZoomWindow extension breaks without GUI?

查看:74
本文介绍了没有GUI的ZoomWindow扩展会中断吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用查看器的v2.13,ZoomWindow扩展依赖于启用默认GUI.有没有解决的办法?加载方法为:

Using v2.13 of the viewer, the ZoomWindow extension relies on having the default GUI enabled. Is there a way around this? The load method is:

proto.load = function() {
    var viewer = this.viewer;
    var toolbar = viewer.getToolbar(true);
    //var toolbar = viewer.getToolbar ? viewer.getToolbar(true) : undefined;

    // Init & Register tool
    this.tool = new namespace.ZoomWindowTool(viewer);
    viewer.toolController.registerTool(this.tool);

    // Add the ui to the viewer.
    this.createUI(toolbar);
    return true;
};

失败,因为未定义getToolbar.

which fails because getToolbar is undefined.

从注释行看,这似乎已经被考虑了,但尚未实现.

It seems from the commented out line that this has been considered, but not implemented.

实现替代方案的最佳方法是什么-我应该用新名称复制整个扩展名,还是可以在运行时替换load方法?

What is the best way to implement a work around - should I copy the entire extension with a new name, or can I replace the load method at runtime?

本来希望使用无头查看器,但似乎最简单的方法是用CSS隐藏UI.

was looking to use the headless viewer, but it seems easiest just to hide the UI with css.

推荐答案

对于我来说尚不清楚,如果您使用的是GuiViewer3D或要使用Viewer3D(没有Autodesk自定义UI的查看器).如果您使用GuiViewer3D,则可以在加载ZoomWindow扩展之前简单地等待工具栏加载,这需要创建工具栏控件才能向其添加按钮.

It's not clear to me if you are using the GuiViewer3D or want to use the Viewer3D, the viewer without Autodesk custom UI. If you use GuiViewer3D, you can simply wait for the toolbar to be loaded before loading the ZoomWindow extension, which requires the toolbar controls to be created in order to add a button to it.

viewer.addEventListener(Autodesk.Viewing.TOOLBAR_CREATED_EVENT, function () {

   viewer.loadExtension('Autodesk.Viewing.ZoomWindow')
})

这是我不久前写的一篇关于在查看器中使用事件的博客文章.它不是最新版本,但仍然有效: http://adndevblog.typepad. com/cloud_and_mobile/2015/10/event-watcher-extension-for-view-data.html

Here is a blogpost I wrote a while ago about using events in the viewer. It is not up-to-date with the current version but remains valid: http://adndevblog.typepad.com/cloud_and_mobile/2015/10/event-watcher-extension-for-view-data.html

现在,正如Zhong所提到的,如果您想使用没有UI的无头查看器并且仍然使用扩展名,则可能必须按照建议的方式对其进行复制和自定义.但是更简单的解决方法是使用GuiViewer3D并仅使用CSS隐藏现有工具栏,因此js代码仍然有效.例如,在div id ="guiviewer3d-toolbar"或adsk-control类上设置display:none.

Now as Zhong mentioned, if you want to use the headless viewer with no UI and still use the extension, you may have to copy and customize it as you suggested. But an easier workaround could be to use GuiViewer3D and simply hide the existing toolbar with css, so the the js code remains valid. Set display:none on div id="guiviewer3d-toolbar", for example, or on the adsk-control class.

希望有帮助

这篇关于没有GUI的ZoomWindow扩展会中断吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆