(sv) Temporal Symbols (Icons)
Since 3.2.0
Introduction
This functionality is part of HDC.EmbeddedAPI controller and allows an external application to place selected icons based on object ID.
For available system icons, please review this guide: (sv) Ikoner
Sample icons with a context menu placed in individual rooms:
Configuration
Both internal and external IDs are supported. Icons are created based on configuration object with the following structure:
var symbols = {
//general call options
options: {
//applicable if IDs given are from external domain
domain: "12",
//external object class (only used with domain ID
objectClass: "HDV_H1_SPACE",
//common icon ID for all objects (check icon ID in system configuration)
//can be used per object
iconId: "123",
//If the real icon size is not adequate, it can be altered by changing this parameter
// accepted values are between 1 and 100
// it will be applied evenly to width and height to maintain proper aspect ratio
//can be used per icon
sizePercentage: 50,
//optional icon alignment parameter, can be used per object
alignTo:"C"
},
//context menu for symbols, common for all objects
menu: [{
//name of the menu item
name: 'My Menu Item',
//callback function that should be called when menu item is selected
callback: this.myFunction,
//context that should be set for callback
context: this,
// icon class to be used, choose from any FontAwsome 5 icons (only free icons are supported)
iconCls: 'far fa-address-card',
}],
//array of objects where icons should be placed (center of bounding box)
"objects": [{
// internal or external domain ID (see domain config above)
id: "5105701/10/1",
//optional object label for the context menu
label: 'Room 01'
//optional icon ID, if individual icon should be used
iconId: "123",
//optional position
position: {
x: 12.32,
y: 14.56
}
}, {
id: "5105701/10/107",
label: 'Room 02'
}, {
id: "5105701/10/106",
label: "Room 03"
}, {
id: "5105701/10/7",
label: "Room 03"
}]
};
Icon Allign
Available options for optional alignTo parameter
C - Center
LT - Left Top
RT - Right Top
LB - Left Bottom
RB - Right Bottom
L - Left
R - Right
T - Top
B - Bottom
Menu - Callback Function
A function given as callback in configuration must be set before the configuration object is created and passed to HD.EmbeddedAPI
A test function can look like this:
var myFunction = function(params){console.log(params)};
The function will be called with a proper context as set in configuration and with "parameters" argument containing the following information:
classId:"108"
iconId:"1843"
label:"Room 02"
objectId:"76933"
position:{x: 1.6299999505281448, y: 7.682500123977661}
sizePercentage:10
tslSvgId:"ENT-195768"
height:90
width:90
Events
Symbols are a special case of Spots, and support the following events:
'*.*.user.spot.select'
'*.*.spot.update'
Samples:
with payload:
Change Icon Location
A preset Icon position can be passed for each object in a configuration:
A position of an Icon can be changed by the user. Later on, the position can be recorded as a reaction to event or by using getSymbols() function.
Functions
Function | Description | Arguments |
---|---|---|
HD.EmbededApi.clearSymbols() | Clear all symbols on the current drawing | N/A |
HD.EmbededApi.setSymbols(symbols); | Set symbols according to passed configuration | Symbols definition object as described in this manual. |
HD.EmbededApi.getSymbols() | Get current state of symbols, including their position | N/A |
Performance
If a high frequency refresh rate is needed for the same objects, it is advised to perform object conversion from external to internal domain once, and then use internal object class and ID to set symbols.
Otherwise, when objects are passed with external domain, conversion and server round-trip will be performed for every call. HD.EmbededApi.convertEid2hdid function can be used for this conversion.