Graphisoft

Programming GDL Web Control


Table of Contents


Naming Conventions

  • GDL Web Control
      Internet Explorer on Windows; ActiveX technology
  • GDL Web Plug-in
      All other supported browsers; Netscape plug-in technology

    This document uses 'plug-in' in both cases, when discussing GDL programming in general.

Platforms and Browsers Supported

    MacOS X
    (PowerPC version)
    MacOS X
    (Intel version)
    Windows 2000, XP, Vista

    Internet Explorer

    -

    -

    supported

    Firefox

    supported*

    supported

    supported

    Safari

    supported*

    supported

    -

    * From GDL Web Control 13 the PowerPC version of MacOS X does not supported.

Operation

    When a GDL object is displayed on an HMTL page, the browser loads the plug-in and passes the attributes set for the plug-in and the GDL object.

    In order to display the object correctly, 3 files have to be available on the server. The files, in order of download, are: the GDL object, gdllist.txt and master.gdl.

    • GDL object file: can be standalone or assembly (macros used).
    • gdllist.txt: The catalog file. This lists all the files needed to display the object. This file is created by GDL Publisher.
    • master.gdl: this contains default material and texture definitions. If not found, the file installed on the client machine is used. The path to this file can be set via the Preferences dialog box.

    After loading these files, the plug-in starts interpreting the object. At this stage, further files might be needed from the server.

    It is important to note that only those files needed to display the object using the current parameter values are downloaded.

Embedding into HTML

    As shown earlier, two kinds of technology are used to display GDL objects in web browsers. Both types require somewhat different HTML code for embedding.

    • GDL Web Control
      <object CLASSID="CLSID:64D9B72C-E42A-490e-9181-221E1E035A14"
              codebase="..."
              id="GDL_Control"
              WIDTH="128" HEIGHT="128">
            	<param NAME="..." VALUE="...">
            	<param NAME="..." VALUE="...">
      </object>
    • GDL Web Plug-in
      <EMBED type="model/vnd.gs-gdl"
             name="GDL_CONTROL"
             src="..."
             WIDTH="128" HEIGHT="128">
      </EMBED>

Setting Default Parameter Values at Loading

  • Required Parameters
    <object CLASSID="CLSID:64D9B72C-E42A-490e-9181-221E1E035A14"
            codebase="http://www.gdlcentral.com/bin/files/GDLCtl.cab"
            id="GDL_Control"
            WIDTH="128" HEIGHT="128">
      <param NAME="Src" VALUE="plugintest.gsm">
      <param NAME="GdlListTxt" VALUE="GDLList.txt">
      <param NAME="MasterGdl" VALUE="Master.gdl">
    </object>
    • classid: Used by the system to identify GDL ActiveX Control.
    • codebase: To use automatic installation and update.
    • id: To make the object instance available to Javascript.
    <embed type="model/vnd.gs-gdl"
           name="GDL_Control"
           WIDTH="128" HEIGHT="128"
           SRC="plugintest.gsm"
           GDLListTxt="GDLList.txt"
           MasterGdl="Master.gdl">
    </embed>
    • type: This is used by the browser to identify GDL objects.
    • name: To make the object instance available to Javascript.
    • width, height: To set the size of the view rectangle.
    • src: The path to the GDL object on the server.
        (Set relative to the path of the HTML page displayed.)
    • gdllisttxt: The path to the GDL catalog file, gdllist.txt on the server.
        (Set relative to the embedded GDL object .)
    • mastergdl: The path to master.gdl file on the server.
        (Set relative to the embedded GDL object.)

  • Optional Parameters

    To find the complete list of optional parameters, go to the Web Plug-in Reference page.

      - disablemenus: When the user right-clicks or ctrl-clicks (Mac) over the plug-in area on the HTML page, a pop-up menu appears. It is possible to ban the use of the menu items listed. The parameter is a four digit hexadecimal number. When the ith bit of the parameter is set to 1, this means the ith menu item is disabled in the list; e.g.: disablemenus=#2000 value will disable the 14th menu item. (When counting the menu items, take into account that the separators are also considered as menu items.)

      - lengthunitformat:
      Value Description
      1 mm
      2 cm
      3 m
      4 km
      5 decimal feet
      6 feet & decimal inches
      7 decimal inches
      8 feet & fractional inches
      9 fractional inches

      - projectioncode:
      Value Description
      0 Front view
      1 Back view
      2 Over view
      3 Top view
      4 Left view
      5 Right view
      6 Frontal axonometry
      7 Isometric axonometry
      8 Monometric axonometry
      9 Dimetric axonometry
      10 Perspective projection
      11 Bottom axonometry
      12 Frontal bottom axonometry
      13 Isometric bottom axonometry
      14 Monometric bottom axonometry
      15 Dimetric bottom axonometry

      - setplugincode: To enable CAD connectivity on the web server, i.e. the ability to save GDL objects in different CAD formats, a code file is needed. This code file contains the formats licensed and can be requested from GDL Technology at sales@gdltechnology.com. The license is tied to the web server's IP address.

      - showtype:
      Value Description
      WIREFRAME Draws the object in wireframe, shows all lines
      HIDDENLINE wireframe + invisible lines hidden
      SHADING hiddenline + color
      PHOTORENDERING Photorealistic view of the object
      DRAWING2D Draws the object in 2D
      PREVIEW Draws the preview picture of the object

      - similar: When this parameter is set to YES, the plug-in will search for other instances of itself that are showing the same object inside the page. Then it will use the same parameter values for each instance. When the user changes any values, all instances will be updated automatically.

  • GDL Object Parameters

    It is possible to set the GDL parameters of objects to override their default values, i.e. the ones with which the objects were saved in the authoring tool.
    <object CLASSID="CLSID:64D9B72C-E42A-490e-9181-221E1E035A14"
            codebase="http://www.gdlcentral.com/bin/files/GDLCtl.cab"
            id="GDL_Control"
            WIDTH="128" HEIGHT="128">
      <param NAME="Src" VALUE="plugintest.gsm">
      <param NAME="GdlListTxt" VALUE="GDLList.txt">
      <param NAME="MasterGdl" VALUE="Master.gdl">
      <param NAME="GDLParams" VALUE="smyParam=1">
    </object>
    
    <embed type="model/vnd.gs-gdl"
           name="GDL_Control"
           WIDTH="128" HEIGHT="128"
           SRC="plugintest.gsm"
           GDLListTxt="GDLList.txt"
           MasterGdl="Master.gdl"
           smyParam=1>
    </embed>
    Parameters can be either strings or numbers in the world of GDL. When setting a string type parameter, start with the prefix 's'. When setting number type parameters, start with 'r' followed by the name of the parameter.

  • Example I - Embedding

    This example embeds a GDL object into an HTML page.
    <object CLASSID="CLSID:64D9B72C-E42A-490e-9181-221E1E035A14"
            codebase="http://www.gdlcentral.com/bin/files/GDLCtl.cab"
            id="GDL_Control"
            WIDTH="128" HEIGHT="128">
      <param NAME="Src" VALUE="plugintest.gsm">
      <param NAME="GdlListTxt" VALUE="GDLList.txt">
      <param NAME="MasterGdl" VALUE="Master.gdl">
      <param NAME="GDLParams" VALUE="smyParam=1">
      <embed type="model/vnd.gs-gdl"
             name="GDL_Control"
             WIDTH="128" HEIGHT="128"
             SRC="plugintest.gsm"
             GDLListTxt="GDLList.txt"
             MasterGdl="Master.gdl"
             smyParam=1>
      </embed>
    </object>
    View Example I

Communicating with the Plug-in

  • Checking Load Status
    It is very important to check the status of the embedded objects, before starting any communication with the plug-in.
    <script language=javascript>
      function DoMyStuff ()
      {
      }
    
      function CheckLoaded ()
      {
        document.GDL_Control.CallPlugin ("GetPluginStatus", "");
        if (document.GDL_Control.sResult == "BUSY") {
          intervalID = setTimeout('CheckLoaded()', 100);
        }
        else {
          clearTimeout (intervalId);
          DoMyStuff ();
        }
      }
    </script>
    This code snippet uses the page's onload event to call the check function. Once the plug-in has finished displaying the object, it can accept commands or handle queries.

  • Sending Commands
    Commands are tasks which the plug-in can execute and there is no return value: e.g. setting view modes.

    To send commands: GDL_Control.CallPlugin ("Command", "Parameter")

  • Query/Response
    If return values are expected from the plug-in:

      1. Send the query to the object's instance:
        GDL_Control.CallPlugin ("Command", "Parameter")

      2. Request the result from the instance:
        myVariable = GDL_Control.sResult

  • Setting Parameter Values
    GDL_Control.CallPlugin ("SetParameter", "sMyParam=1&rMyParam2=2.000")

    To set more than one parameter at a time, join the commands with the '&' sign.

  • Getting Parameter Values
    GDL objects can have 1024 parameters. To get a parameter value, you should know its index in the parameter list of the object in question. The index starts with 1.

    GDL_Control.CallPlugin ("GetParameter", i)

    A loop can be used to get all the parameters at a time:
    <script language=javascript>
      function GetParamVals (param)
      {
        var parameterString = "", aParameterString, myParamStr = "";
      
        for (i = 1; i <= 128; i++) {
          document.GDL_Control.CallPlugin ("GetParameter", String (i));
          aParameterString = document.GDL_Control.sResult;
          if (aParameterString != "") {
            stringsOfParameters = aParameterString.split (";");
            myParamStr += stringsOfParameters + "
    "
            if (stringsOfParameters.length < 4)
              continue;
            if (stringsOfParameters[2].indexOf (param) != -1) {
              parameterString = stringsOfParameters[1];
              break;
            }
          }
        }				
        return parameterString;
      }
    </script>
  • Define plugin callback function
    From version 13 the plugin can call back a user defined JavaScript function. If a user defines a callback function, the plugin calls it every time when it's state has changed. With this function developers can keep the consistency of the JavaScript user interface.

    This example sets the function which the plugin can call:
    <script language=javascript>
      function PluginCallBack (message)
      {
        // plugin calls this with various messages
      }
      
      window.onload = function SetNotificationScript ()
      {
        if (document.GDL_Control) {
          document.GDL_Control.CallPlugin ("SETNOTIFICATIONSCRIPT", "PluginCallBack");
        }
      }
    </script>
    The message can be one of the followings:

    Message Event
    Drawing2D The showtype switched to Drawing2D.
    Wireframe The showtype switched to Wireframe.
    HiddenLine The showtype switched to HiddenLine.
    Shading The showtype switched to Shading.
    PhotoRendering The showtype switched to PhotoRendering.
    ParameterChanged Some of the parameters changed.
    GraphicalEditing The user switched on or off graphical editing mode.
    InternalEngine The rendering engine switched to Internal Engine.
    OpenGL The rendering engine switched to Internal Engine.

    View CallBack Example

  • Example II - Communication
    This example embeds a GDL object into the page by changing parameter 'myParam' from its default value 0 to 1.

    It also changes the parameter 'Radius' to 45 degrees and sets the axonometry angle to 180 degrees at load time.

    To change this parameter, click on the 'Set Parameter' button included on the example page.

    View Example II

  • Example III - Plug-in Interface Functions
    • Accessing the interface: CallPlugin ("MenuCommand", "Parameter")

        Parameter:
        • Preferences, ParameterSettings, SaveObject, ...
        • Preview, Drawing2D, Shading, Photorendering, ...
    • Setting Interface Modes: CallPlugin ("UI_MODE", "Parameter")

        Parameter:
        • Pan_Mode,
          Zoom_In_Mode, Zoom_Out_Mode,
          Fit_In_Mode,
          Reset_Mode
    • Setting zoom: CallPlugin ("SETZOOM", "scaleX, scaleY, origoX, origoY")
    • Getting zoom: CallPlugin ("GETZOOM", "")

        Get the result by checking .sResult = scaleX, scaleY, origoX, origoY.

    View Example III

GRAPHISOFT is part of the Nemetschek Group