Add custom toolbar for Autodesk Viewer

Source: Internet
Author: User

If you have participated in our recent activities, you will frequently hear the Autodesk viewer big Model Browser we are currently working on. This is a browser based on webgl technology that does not need to download any plug-ins, supports dozens of data formats. In addition, the viewer also provides APIs. You can embed the viewer into your own web program. We have also written a lot of samples and released them to GitHub. These examples require consumerkey. You need to apply to Autodesk. Currently, this product has not been officially released, we only invited some customers to do the test and will release it soon. You need to wait patiently.

Custom interface APIs have been added to the latest code push. You can use these APIs to create custom toolbar in the same style as the built-in toolbar of viewer. First, you need to create a container on the page, which is generally a div tag. Use CSS to control its position. The following JavaScript code will generate a custom toolbar:

(Screen-shot)

 

function addToolBar(container) {
    //create a toolbar
    var toolbar = new Autodesk.Viewing.UI.ToolBar(container);

    //create a subToolbar
    var subToolbar = toolbar.addSubToolbar(‘sub1‘);

    //add some  buttons to it
    var button1 = Autodesk.Viewing.UI.ToolBar.createMenuButton("Button1",
        "Tooltip for Button1",
        function (e) {
            alert("Button1 is clicked.");
        });

    //add icon for the button
    button1.className = ‘glyphicon glyphicon-euro‘;

    var button2 = Autodesk.Viewing.UI.ToolBar.createMenuButton("Button2",
        "Tool tip for Button2",
        function (e) {
            alert("Button2 is clicked");
        });
    //Add buttons to subtoolbar
    toolbar.addToSubToolbar("sub1", button1);
    toolbar.addToSubToolbar("sub1", button2);


    //create a radio sub toolbar
    var radioSubToolbar = toolbar.addSubToolbar(‘radioSub2‘, true); //id, isRadio
   
    // add some buttons to it
    var button3 = Autodesk.Viewing.UI.ToolBar.createMenuButton("Button3",
        "Tool tip for Button3",
        function (e) {
            alert("Button2 is clicked");
        });
    var button4 = Autodesk.Viewing.UI.ToolBar.createMenuButton("Button4",
        "Tool tip for Button4",
        function (e) {
            alert("Button4 is clicked");
        });

    //add buttons to radioSubToolbar
    toolbar.addToSubToolbar("radioSub2", button3);
    toolbar.addToSubToolbar("radioSub2", button4);


}

Next, we will introduce a method that is easier to organize and maintain to create custom toolbar.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.