Untitled

 avatar
unknown
plain_text
a year ago
2.7 kB
9
Indexable
public set() {
        if (!this.cad.preview.on) {
            // this.object.clear(); // when user select an object means to empty list of highlighted objects. It is impossible to have any highlighted object at this moment.
            if (!this.cad.KEY_CTRL) {
                for (let i: number = this.oList.length - 1; i >= 0; i--) {
                    this.oList[i].select(false);
                }
            }
            this.filterSelection(this.cad.intersected()).forEach(intersected => {
                const i: number = this.find(intersected); // find if currently intercepted object is found in a list of selected objects
                if (i === -1) {
                    if (intersected.selectable() && this.isAllowed(intersected)) {
                        if ((intersected instanceof XNS_Equipment && !this.cad.KEY_SHIFT) || !(intersected instanceof XNS_Equipment)) {  // equipment is only selected without SHIFT key, otherwise it switches rescaling mode for equipment
                            intersected.select(true); // select it
                        }
                    }
                }
                else {
                    if (intersected.selected()) {
                        if ((intersected instanceof XNS_Equipment && !this.cad.KEY_SHIFT) || !(intersected instanceof XNS_Equipment)) { // equipment is only unselected without SHIFT key, otherwise it turns rescaling mode off for equipment
                            intersected.select(false); // unselect it because it is already selected.
                        }
                    }

                }
            });
            if (!this.cad.KEY_CTRL && !this.cad.KEY_SHIFT && this.oList.length > 0) {
                const objects: Array<XNS_Object> = this.cad.select.filterByType([XNS_Connection, XNS_Location, XNS_Equipment]); // Filter connections, locations and equipments only
                if (objects.length === 1) { // Only one object is allowed for selection
                    if (objects[0] instanceof XNS_Equipment) { // Single equipment can be selected (it should not affect locations)
                        this.cad.onTabControl(TabID.EQUIPMENTS, ToolID.PROPERTIES, objects[0].name);
                        objects[0].select(false);
                        return;
                    }
                }
                if (this.cad.onSelect)
                    this.cad.onSelect(this.getObjectData(true, this.oList[this.oList.length - 1]));
                return;
            }
            if (this.cad.onSelect)
                this.cad.onSelect(this.getObjectData(false));
        }
    }
Editor is loading...
Leave a Comment