I am currently working on drag-and-drop floor plans based on canvas templates.
But when updating a dataset with templates during scaling, a number of unpleasant things happen (delay, flash, re-initialization of templates).
Is there a way to change the coordinates and sizes of templates inside the canvas without editing the base dataset for them? Something like tranform(), setLocation() et…
If not, is there any other way to dynamically add templates to a container other than a canvas / repeater?
Ignition 8.0.14
How are you changing the template canvas’ dataset? If you’re just changing the position/size, then the canvas is supposed to just reposition the existing instances - not recreate them (as of 8.0.6).
I have a custom property of dataset type. It is bound to the corresponding canvas property.
On event (mouse wheel) I change the dataset. The edits only apply to columns with position and sizes.
As a result, all templates are reinitialized:
- the init script for every template is triggered (by change the “componentRunning” property)
- big image templates are blinking.
- with a large number of templates (> 1000), a delay occurs that lasts much longer than I expect. It is the same as for the initial initialization of templates.
And you’re not adding any new instances? This the check for equality that determines whether items will be moved, or the canvas has to recreate everything.
boolean canRepositionTo(LoadSpec that) {
return this.row == that.row
&& Objects.equal(this.zIndex, that.zIndex)
&& Objects.equal(this.name, that.name)
&& Objects.equal(this.templateId, that.templateId)
&& Objects.equal(this.params, that.params);
}
I am not adding new instances
Reinitialization happens even if I just overwrite the dataset by itself
What’s the version of your Vision module? Are any of the properties in that code snippet above changing from one dataset to the next?
Version of Vision module is 10.0.15 (b2020072213)
I noticed a remarkable thing
If the table with templates is sorted by the zIndex column (ascending), then reinitialization does not occur
If the zIndex in some line is strictly lower than in the previous line, then rewriting the table (without edits at all) leads to its reinitialization
Apparently my problem should be solved by manually sorting the template table by the zIndex column. But this is not an obvious thing and I doubt that it was intended.