UNPKG

awv3

Version:
44 lines (39 loc) 1.32 kB
import Ccbaseref from './ccbaseref'; import { Member } from './command/lowlevel'; import { getClass } from './geomutils'; // Like a Ccref, but an object is not yet created, // we have a command (AST expression) that evaluates to it and geomParams let idCounter = 0; export default class Ccfuturef extends Ccbaseref { constructor(command, geomParams, parent = undefined, pointType = undefined) { super(); this.command = command; this.geomParams = geomParams; this.parent = parent || this; this.pointType = pointType ? pointType.replace('Point', '') : undefined; this.id = --idCounter; } get class() { return getClass(this.geomParams); } get children() { switch (this.class) { case 'CC_Point': return []; case 'CC_Line': return [this.startPoint, this.endPoint]; case 'CC_Arc': return [this.startPoint, this.endPoint, this.center]; case 'CC_Circle': return [this.center]; } } getNamedChild(childName) { return new Ccfuturef( Member(this.command, childName), { start: this.geomParams[childName.replace('Point', '')] }, this, childName, ); } }