import {ComponentNode} from '@int/geotoolkit/schematics/scene/ComponentNode';
import {Rectangle} from '@int/geotoolkit/scene/shapes/Rectangle';
import {Rect} from '@int/geotoolkit/util/Rect';
import {obfuscate} from '@int/geotoolkit/lib';

class NodeCementBW extends ComponentNode {
    constructor (data) {
        super();

        this._rectanglePos = new Rectangle({'fillstyle': 'lightgrey'});
        this._rectangleNeg = new Rectangle({'fillstyle': 'lightgrey'});
        if (data) {
            this.setDescription(data['description']);
            this.setGeometryData(data['geometry']);
        }

        this.addChild(this._rectanglePos);
        this.addChild(this._rectangleNeg);
    }

    setGeometryData (geometry) {
        if (!geometry) {
            return;
        }
        super.setGeometryData(geometry);

        const radOuter = geometry['diameter']['outer'] / 2;
        const radInner = geometry['diameter']['inner'] / 2;
        const depthFr = geometry['depth']['from'];
        const depthTo = geometry['depth']['to'];

        this._rectanglePos.setRect(radInner, depthFr, radOuter, depthTo);
        this._rectangleNeg.setRect(-radInner, depthFr, -radOuter, depthTo);
        this._geometryBounds = new Rect(-radOuter, depthFr, radOuter, depthTo);
        this.setModelLimits(new Rect(this._geometryBounds));
    }

    getGeometryBounds () {
        return this._geometryBounds;
    }
}
obfuscate(NodeCementBW);
export {NodeCementBW};
