HTML Drawing Control

Incorporate server-side services

Highlighting and labeling services

Code below incorporates server-side services that handle highlighting and labeling:

DrawingSvgService.highlightSvgDrawing(pKeyValues, planType, highlightParameters, { async: false, callback: function(svg) { //display returned svg with asset highlighting and labeling }, errorHandler: function(m, e){ Ab.view.View.showException(e); } )};

pKeyValues: Object to pass site_id, bl_id, fl_id,  dwg_name, filename;like {bl_id: 'HQ', fl_id: '18', dwg_name: 'hq18', filename: 'hq18-room-trial1.svg'}

  • If filename value (any arbitrary file name not existing in database afm_dwgs.dwg_name) is passed, others are optional. The core loads the specified file from enterpriseGraphicsFolder defined in afm-projects.xml. In this case, applications have to pass  hs_rest parameter  value as the restriction of highlight and label datasources.
  • If dwg_name value (a valid database afm_dwgs.dwg_name value) is passed, others are optional. The core will load specfied file from enterpriseGraphicsFolder defined in afm-projects.xml.  By default, the core will apply the specified dwg_name value as the restriction of highlight and label datasources.
  • If dwg_name value is not passed, site_id is required for a campus drawing; bl_id and fl_id are required for a floor plan drawing.

planType : String to pass the primary key value ( active_plantypes.plan_type in database)

  • If planType value is passed, the core will retrieve highlight and label configurable info from its corresponding active_plantypes record. Please check database table active_plantypes for details.

highlightParameters : Array of Objects to pass highlight parameters like [highlightParameter, borderHighlightParameter]. Each highlightParameter applies its own highlighting to the target floor plan.

Pass the following values:

  • view_file : String, axvw view file name. highlight and label dataSources are defined in the view.

Required if plantype value is not passed;

  • hs_ds : String, highlight dataSource Id;

Required if plantype value is not passed;

  • assetToHighlight : String, the asset such as rm is highlighted.

Optional if highlighted asset is same as highlight dataSource's main table;

  • hs_rest : Ab.view.Restriction, pass runtime restriction to highlight dataSource. And convert the restriction into JSON by toJSON(restriction).

Optional;

  • hs_param : Object. pass runtime values to highlight dataSource parameters. And convert the parameter object into JSON by toJSON(parameterObj).

Optional if there is no applicable dataSource parameters;

  • borderHighlight : true/false. Indicates if the highlight is bordering.

Optional if the highlight is not bordering;

  • borderSize : Integer. If the highlight is bordering, it'll overwrite the default highlight border size.

Optional if default size 20 is fine;

  • label_ds , String, label dataSource Id.

Required if the highlight is with labeling;

  • label_ht : Number, label highlight in em unit.

Optional;

  • label_clr : label color.

Optional;

  • label_view_file : String. label dataSources defined axvw file name.

Optional if label dataSource is defined in the same view as highlight dataSource.

  • selection_ds : String. The datasource Id for asset selectability.

Optional;

Notes :

  • This API is used by HTML and mobile drawing controls. In most cases, application developers don't need to call it directly, but you could pass supported parameters in your applications through drawing control APIs.
  • One example of a typical highlight parameter object : {view_file: 'ab-sp-hl-rm-by-dp-per-fl.axvw', hs_ds:'ds_ab-sp-hl-rm-by-dp-per-fl_drawing_rmHighlight', label_ds: 'ds_ab-sp-hl-rm-by-dp-per-fl_drawing_rmLabel', label_clr: '#B9C2CA'}

Legend data service

DrawingSvgService.getLegends(drawingNames, highlightParameter, { callback: function(legendData) { //legendData is Object like {'ELECTRONIC SYS.-Engineering': {name: 'BRASS', color: 'rgb(250,250, 250)', value: '14 1 171 16744319 0.0000 120.0000 BRASS'},...} //display legendData }, errorHandler: function(m, e){ Ab.view.View.showException(e); } }); ////////////////////example to use DrawingSvgService.getLegends and display legends in panel in datasource-selector.js /////////////////////////////////////////////////////////////// /** * Refreshes legend panel with retrieved legend data from server-side. * * @param legendPanel legend panel object. * @param isBorder true/false. */ refreshLegendPanel: function(legendPanel, isBorder){ legendPanel.clear(); legendPanel.clearGridRows(); Ab.grid.Grid.prototype.displayHatchField = function(bitmapName){ var index = bitmapName.indexOf('-'); bitmapName = bitmapName.substring(index + 1); return "<img src="+Ab.view.View.contextPath+"/schema/ab-core/graphics/hpatterns/" + bitmapName.toUpperCase() + ".png hspace='0' border='0' style='width:100%;height:16px;'/>"; }; var drawingNames = []; for(var drawingName in this.drawingController.control.drawings){ drawingNames.push(drawingName); } var highlightParameter = {}; if(isBorder){ highlightParameter = this.highlightParameters[1]; }else{ highlightParameter = this.highlightParameters[0]; } var legends; //gets legend data from server DrawingSvgService.getLegends(drawingNames, highlightParameter, { async: false, callback: function(result) { legends = result; }, errorHandler: function(m, e){ Ab.view.View.showException(e); } }); var record, legendObj; for(var key in legends){ legendObj = legends[key]; record = new Ab.data.Record({ 'legend.color': legendObj.value, 'legend.value': key }); legendPanel.addGridRow(record); } legendPanel.update(); },

drawingNames : Array of drawing names like ['HQ17', 'SRL03', 'XC02']

highlightParameter : Object, same as highlight parameter object specified above.