123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import Konva from "konva";
- import { ActionManager } from "../models/application/actions/action-manager";
- export class Layer {
- constructor(id, konvaLayer) {
- this.id = id;
- this.name = "New Construction " + this.id;
- this.konvaLayer = konvaLayer;
- this.aggregators = [];
- this.selectedAggregators = [];
- this.konvaGroup = new Konva.Group({
- draggable: false,
- resizeEnabled: false
- });
- this.konvaLayer.add(this.konvaGroup);
- this.actionManager = new ActionManager();
- }
- getKonvaGroup() {
- return this.konvaGroup;
- }
- getKonvaLayer() {
- return this.konvaLayer;
- }
- addAggregator(aggregator) {
- this.aggregators.push(aggregator);
- }
- getAggregators() {
- return this.aggregators;
- }
- getSelectedAggregators() {
- return this.selectedAggregators;
- }
- setSelectedAggregator(aggregator) {
- if (!this.selectedAggregators.includes(aggregator)) {
- this.selectedAggregators.push(aggregator);
- }
- }
- removeSelectedAggregator(aggregator) {
- if (this.selectedAggregators.includes(aggregator)) {
- let index = this.selectedAggregators.indexOf(aggregator);
- this.selectedAggregators.splice(index, 1);
- }
- }
- removeAggregator(aggregator) {
- let index = this.aggregators.indexOf(aggregator);
-
- //console.log('indexOf(aggregator): ', index) Debug
- this.aggregators.splice(index, 1);
-
- /*if (this.selectedAggregators.includes(aggregator)) {
- let index = this.selectedAggregators.indexOf(aggregator);
- this.selectedAggregators.splice(index, 1);
- } TODO = trecho estava causando conflitos, checar propósito*/
- this.actionManager.remove(aggregator.genericObject);
- aggregator.konvaObject.destroy();
- }
- }
|