import { __awaiter, __generator } from "tslib";
// declare const Cesium: typeof import("cesium");
import { Cartesian3 } from '@taotieh/cesium_extend';
import ClipWithBox from './Mods/ClipWithBox';
import ClipWithPlane from './Mods/ClipWithPlane';
import ClipWithCamera from './Mods/ClipWithCamera';
import ClipWithHorizon from './Mods/ClipWithHorizon';
import ClipWithVertical from './Mods/ClipWithVertical';
import ClipWithPath from './Mods/ClipWithPath';
import ClipWithParmas from './Mods/ClipWithParmas';
/** ********************************************************
 *  刨切模块功能说明
 *  为了实现多种剖切模式, 需要将剖切动作拆分出几个最小单元.
 * 1. 最基础的通过参数驱动的自定义平面剖切功能, ClipWithPlane. 这个
 *    类需要实现通过传入参数, 构建平面, 同时捕获鼠标动作实现剖切平面的
 *    [位置]和[方向]更新. (同时跟新实际剖切面和可是几何面).
 *    这个类不由用户自主激活.
 * 2. 水平剖面, ClipWithHorizon. 继承自 ClipWithPlane, 在其基础
 *    上简化构造面的过程. 不需要通过接口传入面的参数, 而是根据鼠标行为,
 *    自动捕获击中点, 创建相应的水平面, 过任一点的水平面只有一个.
 * 3. 竖直剖面 ClipWithVertical. 继承自 ClipWithPlane,
 *    和 ClipWithHorizon 类似, 根据用户鼠标行为创建面. 但考虑到过任
 *    意一点有无数个竖直面, 这个类里需要设计一个方案生成符合操作者直觉
 *    [方向]的竖直面.
 * 4. 使用相机裁剪面方向构建剖面. ClipWithCamera 继承自 ClipWithPlane,
 *    和水平/竖直类似, 也是有用户触发, 根据用户鼠标击中点快速构建剖面.
 *    该剖面使用相机的朝向作为剖面的发现方向. 并可选跟随相机移动而更新.
 * 5. 盒剖切. ClipBox 这个看起来最复杂, 实际应该是最简单的. 继承自 Clip.
 *    在实现了 ClipWithPlane 的基础上, ClipBox 实际是对 6 个 ClipWithPlane
 *    进行协同管理, 仅此而已.
 ***********************************************************/
var ClipControl = /** @class */ (function () {
    function ClipControl(viewer, instance) {
        this._entities = [];
        this._measureType = '';
        this._positions = [];
        this._distance = '';
        this._installed = false;
        this._viewer = viewer;
        this._instance = instance;
        this._modClipWithHorizon = new ClipWithHorizon(viewer, instance);
        this._modClipWithVertical = new ClipWithVertical(viewer, instance);
        this._modClipWithPath = new ClipWithPath(viewer, instance);
        this._modClipWithBox = new ClipWithBox(viewer, instance);
        this._modClipWithCamera = new ClipWithCamera(viewer, instance);
        this._modClipWithPlane = new ClipWithPlane(viewer, instance, Cartesian3.ZERO.clone(), Cartesian3.ZERO.clone());
        this._modClipWithParams = new ClipWithParmas(viewer, instance);
    }
    ClipControl.prototype.switchClipTool = function (tool, option) {
        if (tool === void 0) { tool = ''; }
        return __awaiter(this, void 0, void 0, function () {
            var _a, cwh, cwv, cwb, cwp, cwc, cwpa, cwpm;
            return __generator(this, function (_b) {
                _a = this, cwh = _a._modClipWithHorizon, cwv = _a._modClipWithVertical, cwb = _a._modClipWithBox, cwp = _a._modClipWithPlane, cwc = _a._modClipWithCamera, cwpa = _a._modClipWithPath, cwpm = _a._modClipWithParams;
                // this._activeMod && await this._activeMod.stop();
                switch (tool) {
                    case 'clip_with_horizon':
                        this._activeMod = cwh;
                        break;
                    case 'clip_with_vertical':
                        option._isVertical = true;
                        this._activeMod = cwpm;
                        break;
                    case 'clip_with_camera':
                        this._activeMod = cwc;
                        break;
                    case 'clip_with_plane':
                        this._activeMod = cwp;
                        break;
                    case 'clip_with_box':
                        this._activeMod = cwb;
                        break;
                    case 'clip_with_path':
                        cwpa.option = option;
                        this._activeMod = cwpa;
                        break;
                    case 'clip_with_parmas':
                        this._activeMod = cwpm;
                        break;
                    default:
                        this._activeMod = undefined;
                }
                this._activeMod && this._activeMod.start(option);
                return [2 /*return*/];
            });
        });
    };
    return ClipControl;
}());
export default ClipControl;
