var Glodon$1 = window.Glodon || {};
window.Glodon = Glodon$1;
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
// 事件处理基类
var EventManager = /** @class */ (function () {
function EventManager() {
this._eventContainer = {};
}
// 添加监听事件
EventManager.prototype.addEvent = function (type, fn) {
this._eventContainer[type] = this._eventContainer[type] || [];
this._eventContainer[type].push(fn);
return this;
};
// 删除监听事件
EventManager.prototype.removeEvent = function (type, fn) {
if (this._eventContainer[type]) {
var index = this._eventContainer[type].indexOf(fn);
index >= 0 && this._eventContainer[type].splice(index, 1);
}
return this;
};
// 触发监听事件
EventManager.prototype.fireEvent = function (type) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (type && this._eventContainer[type]) {
__spreadArrays(this._eventContainer[type]).forEach(function (fn) {
fn.apply(null, args);
});
}
return this;
};
// reset
EventManager.prototype.reset = function () {
this._eventContainer = {};
};
return EventManager;
}());
// 事件处理类
var EventEmmiter = /** @class */ (function (_super) {
__extends(EventEmmiter, _super);
function EventEmmiter() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._onceEvents = {};
_this._pausedEvents = {};
return _this;
}
// 增加监听事件
EventEmmiter.prototype.on = function (type, fn) {
return this.addEvent(type, fn);
};
// 删除监听事件
EventEmmiter.prototype.off = function (type, fn) {
var index;
if (this._onceEvents[type]) { // once列表中查找并删除此事件
(index = this._onceEvents[type].indexOf(fn)) >= 0 && this._onceEvents[type].splice(index, 1);
this._onceEvents[type].length === 0 && delete this._onceEvents[type];
}
if (this._pausedEvents[type]) { // pause列表中查找并删除此事件
(index = this._pausedEvents[type].indexOf(fn)) >= 0 && this._pausedEvents[type].splice(index, 1);
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
}
return this.removeEvent(type, fn);
};
// 触发一类监听事件
EventEmmiter.prototype.trigger = function (type) {
var _this = this;
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (!this._eventContainer[type])
return this;
var originEvents = __spreadArrays(this._eventContainer[type]);
if (this._pausedEvents[type]) { // 此类监听事件中存在pause项时,另外记录完整的事件数组,并在现有的数组中删除pause项
this._pausedEvents[type].forEach(function (fn) {
_this.removeEvent(type, fn);
});
}
this.fireEvent.apply(this, __spreadArrays([type], args));
this._eventContainer[type] = originEvents; // 恢复完整的事件数组
if (this._onceEvents[type]) { // 单次执行的事件,执行后从数组中删除
this._onceEvents[type].forEach(function (fn) {
(!_this._pausedEvents[type] || _this._pausedEvents[type].indexOf(fn) < 0) && _this.off(type, fn); // 排除once事件pause状态
});
}
return this;
};
// 增加单次执行的事件
EventEmmiter.prototype.once = function (type, fn) {
this.on(type, fn);
this._onceEvents[type] = this._onceEvents[type] || [];
this._onceEvents[type].indexOf(fn) < 0 && this._onceEvents[type].push(fn);
return this;
};
// 暂停事件
EventEmmiter.prototype.pause = function (type, fn) {
this._pausedEvents[type] = this._pausedEvents[type] || [];
this._pausedEvents[type].indexOf(fn) < 0 && this._pausedEvents[type].push(fn);
return this;
};
// 恢复事件
EventEmmiter.prototype.resume = function (type, fn) {
if (!this._pausedEvents[type])
return this;
var index = this._pausedEvents[type].indexOf(fn);
index >= 0 && this._pausedEvents[type].splice(index, 1);
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
return this;
};
EventEmmiter.prototype.reset = function () {
this._onceEvents = {};
this._pausedEvents = {};
_super.prototype.reset.call(this);
};
return EventEmmiter;
}(EventManager));
var InteractionEvent;
(function (InteractionEvent) {
InteractionEvent["TransformStarted"] = "TransformStarted";
InteractionEvent["TransformChanged"] = "TransformChanged";
InteractionEvent["TransformFinished"] = "TransformFinished";
InteractionEvent["TransformModeChanged"] = "TransformModeChanged";
InteractionEvent["DrawFinished"] = "DrawFinished";
InteractionEvent["Exit"] = "Exit";
InteractionEvent["ExitEdit"] = "ExitEdit";
InteractionEvent["EditCompleted"] = "EditCompleted";
InteractionEvent["WarningHint"] = "WarningHint";
})(InteractionEvent || (InteractionEvent = {}));
var InteractionEvent$1 = InteractionEvent;
// 此对象用于简化处理各类数据,包括判断数据类型、判断属性、及数据的各类其他操作等,待丰富
var DataUtil = {
// 用于判断数据类型
assertType: function (param, typeName) {
var assert = function (fullTypeName) { return Object.prototype.toString.call(param) === "[object " + fullTypeName + "]"; };
switch (typeName) {
case 'obj':
case 'Obj':
case 'object':
case 'Object':
return assert('Object');
case 'arr':
case 'Arr':
case 'array':
case 'Array':
return assert('Array');
case 'num':
case 'Num':
case 'number':
case 'Number':
return assert('Number');
case 'func':
case 'Func':
case 'function':
case 'Function':
return assert('Function');
case 'str':
case 'Str':
case 'string':
case 'String':
return assert('String');
default:
return assert(typeName);
}
},
// 判断多个参数是否都是某个数据类型(参数平铺传入,最后一个参数是类型名)
assertParamsType: function () {
var _this = this;
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
if (params.length > 1) {
var typeName_1 = params.splice(params.length - 1, 1)[0];
var result_1 = true;
params.every(function (param) {
result_1 = _this.assertType(param, typeName_1);
return result_1;
});
return result_1;
}
},
// 判断对象是否包含某属性
hasProperty: function (param, propertyName) {
if (this.assertType(param, 'obj')) {
return param[propertyName] !== undefined;
}
},
// 颜色转换 hex to rgb
hexToRgb: function (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
red: parseInt(result[1], 16),
green: parseInt(result[2], 16),
blue: parseInt(result[3], 16)
} : null;
},
componentToHex: function (c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
},
// 颜色转换 rgb to hex
rgbToHex: function (r, g, b) {
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
}
};
var _a, _b, _c, _d;
var SDM = (_d = (_c = (_b = (_a = window.Glodon) === null || _a === void 0 ? void 0 : _a.Bimface) === null || _b === void 0 ? void 0 : _b.Data) === null || _c === void 0 ? void 0 : _c.StatisticsDataManager) === null || _d === void 0 ? void 0 : _d.getInstance();
/*
* @namespace Glodon.Bimface.Module.Scene.EditorEvent
* @classdesc 常量:Editor的事件
*/
var EditorEvent;
(function (EditorEvent) {
EditorEvent["Loaded"] = "Loaded";
EditorEvent["ViewChanged"] = "ViewChanged";
EditorEvent["ModelAdded"] = "ModelAdded";
EditorEvent["ModelRemoved"] = "ModelRemoved";
EditorEvent["LayerTreeNodeClicked"] = "LayerTreeNodeClicked";
EditorEvent["SceneAdded"] = "SceneAdded";
EditorEvent["PropertiesShow"] = "PropertiesShow";
EditorEvent["PropertiesHide"] = "PropertiesHide";
EditorEvent["HideEffectsPanels"] = "HideEffectsPanels";
EditorEvent["EffectsShow"] = "EffectsShow";
EditorEvent["EffectsHide"] = "EffectsHide";
EditorEvent["EffectFolderShow"] = "EffectFolderShow";
EditorEvent["EffectFolderHide"] = "EffectFolderHide";
EditorEvent["EffectCrossHairShow"] = "EffectCrossHairShow";
EditorEvent["EffectCrossHairHide"] = "EffectCrossHairHide";
EditorEvent["EffectPanelShow"] = "EffectPanelShow";
EditorEvent["EffectPanelHide"] = "EffectPanelHide";
EditorEvent["EffectShow"] = "EffectShow";
EditorEvent["EffectHide"] = "EffectHide";
EditorEvent["SaveEffect"] = "SaveEffect";
EditorEvent["AnchorPointUpdate"] = "AnchorPointUpdate";
EditorEvent["AnchorPointDestroy"] = "AnchorPointDestroy";
EditorEvent["TempAnchorDestroy"] = "TempAnchorDestroy";
EditorEvent["AnchorEffectShow"] = "AnchorEffectShow";
EditorEvent["AnchorEffectHide"] = "AnchorEffectHide";
EditorEvent["AnchorSizeUpdate"] = "AnchorSizeUpdate";
EditorEvent["SaveAnchorEffect"] = "SaveAnchorEffect";
EditorEvent["FireEffectShow"] = "FireEffectShow";
EditorEvent["FireEffectHide"] = "FireEffectHide";
EditorEvent["FireEffectDrawExit"] = "FireEffectDrawExit";
EditorEvent["FireEffectDestroy"] = "FireEffectDestroy";
EditorEvent["SaveFireEffect"] = "SaveFireEffect";
EditorEvent["CurveHide"] = "CurveHide";
EditorEvent["CurveInit"] = "CurveInit";
EditorEvent["CurveAnimationDestroy"] = "CurveAnimationDestroy";
EditorEvent["TempCurveDestroy"] = "TempCurveDestroy";
EditorEvent["CurveEffectShow"] = "CurveEffectShow";
EditorEvent["CurveEffectHide"] = "CurveEffectHide";
EditorEvent["SaveCurveEffect"] = "SaveCurveEffect";
EditorEvent["FanScanDrawExit"] = "FanScanDrawExit";
EditorEvent["FanScanDestroy"] = "FanScanDestroy";
EditorEvent["FanScanShow"] = "FanScanShow";
EditorEvent["FanScanHide"] = "FanScanHide";
EditorEvent["SaveFanScan"] = "SaveFanScan";
EditorEvent["RingScanDrawExit"] = "RingScanDrawExit";
EditorEvent["RingScanDestroy"] = "RingScanDestroy";
EditorEvent["RingScanShow"] = "RingScanShow";
EditorEvent["RingScanHide"] = "RingScanHide";
EditorEvent["SaveRingScan"] = "SaveRingScan";
EditorEvent["WaterEffectDrawExit"] = "WaterEffectDrawExit";
EditorEvent["WaterEffectDestroy"] = "WaterEffectDestroy";
EditorEvent["WaterEffectShow"] = "WaterEffectShow";
EditorEvent["WaterEffectHide"] = "WaterEffectHide";
EditorEvent["SaveWaterEffect"] = "SaveWaterEffect";
EditorEvent["MapEffectDestroy"] = "MapEffectDestroy";
EditorEvent["MapEffectShow"] = "MapEffectShow";
EditorEvent["MapEffectHide"] = "MapEffectHide";
EditorEvent["SaveMapEffect"] = "SaveMapEffect";
EditorEvent["SkyBoxShow"] = "SkyBoxShow";
EditorEvent["SkyBoxHide"] = "SkyBoxHide";
EditorEvent["SaveSkyBox"] = "SaveSkyBox";
EditorEvent["RainEffectShow"] = "RainEffectShow";
EditorEvent["RainEffectHide"] = "RainEffectHide";
EditorEvent["SaveRainEffect"] = "SaveRainEffect";
EditorEvent["RainEffectDestroy"] = "RainEffectDestroy";
EditorEvent["handleStartDrawOrEditEvent"] = "handleStartDrawOrEditEvent";
EditorEvent["handleExitDrawOrEditEvent"] = "handleExitDrawOrEditEvent";
EditorEvent["LayerTreeNodeSelectionChanged"] = "LayerTreeNodeSelectionChanged";
EditorEvent["EffectTreeNodeSelectionChanged"] = "EffectTreeNodeSelectionChanged";
EditorEvent["AddResourceByViewToken"] = "AddResourceByViewToken";
EditorEvent["AddResourcePanelShow"] = "AddResourcePanelShow";
EditorEvent["UpdateResourcePanelShow"] = "UpdateResourcePanelShow";
EditorEvent["LayerNameChanged"] = "LayerNameChanged";
EditorEvent["EffectNameChanged"] = "EffectNameChanged";
EditorEvent["EffectNamePanelChanged"] = "EffectNamePanelChanged";
EditorEvent["LayerAdjustmentShow"] = "LayerAdjustmentShow";
EditorEvent["LayerAdjustmentHide"] = "LayerAdjustmentHide";
EditorEvent["TileLayerSourceChanged"] = "TileLayerSourceChanged";
EditorEvent["ModelLayerTransformed"] = "ModelLayerTransformed";
EditorEvent["ClearInvalidLayers"] = "ClearInvalidLayers";
EditorEvent["PropertiesShowPanel"] = "PropertiesShowPanel";
EditorEvent["LayerTreeNodeVisibleChanged"] = "LayerTreeNodeVisibleChanged";
EditorEvent["layerEditNotificationShow"] = "layerEditNotificationShow";
EditorEvent["layerEditNotificationHide"] = "layerEditNotificationHide";
EditorEvent["LayerEditInit"] = "LayerEditInit";
EditorEvent["ExitLayerEffectDrawOrEdit"] = "ExitLayerEffectDrawOrEdit";
EditorEvent["LayerEditTreeUnselect"] = "LayerEditTreeUnselect";
EditorEvent["DrawFlatEffect"] = "DrawFlatEffect";
EditorEvent["DrawFlatEffectExit"] = "DrawFlatEffectExit";
EditorEvent["EditFlatEffectExit"] = "EditFlatEffectExit";
EditorEvent["initFlatEffect"] = "initFlatEffect";
EditorEvent["DrawClippingEffect"] = "DrawClippingEffect";
EditorEvent["DrawClippingEffectExit"] = "DrawClippingEffectExit";
EditorEvent["EditClippingEffectExit"] = "EditClippingEffectExit";
EditorEvent["initClippingEffect"] = "initClippingEffect";
EditorEvent["LayerEditHideLayer"] = "LayerEditHideLayer";
EditorEvent["RestoreLayerVisible"] = "RestoreLayerVisible";
EditorEvent["SetDirectoryTreeState"] = "SetDirectoryTreeState";
EditorEvent["ExitEditTool"] = "ExitEditTool";
EditorEvent["ReinitEditFan"] = "ReinitEditFan";
EditorEvent["ReinitEditLine"] = "ReinitEditLine";
EditorEvent["ReinitEditRing"] = "ReinitEditRing";
EditorEvent["ReinitEditWater"] = "ReinitEditWater";
EditorEvent["ReinitEditFlapSurface"] = "ReinitEditFlapSurface";
EditorEvent["ReinitEditFlapSurfaceForWall"] = "ReinitEditFlapSurfaceForWall";
EditorEvent["ExitEditFlatEffect"] = "ExitEditFlatEffect";
EditorEvent["ExitEditWallEffect"] = "ExitEditWallEffect";
EditorEvent["ReinitEditClippingSurface"] = "ReinitEditClippingSurface";
EditorEvent["ExitEditClippingEffect"] = "ExitEditClippingEffect";
})(EditorEvent || (EditorEvent = {}));
var eventBus = new EventEmmiter();
// DomElement操作工具类
var Dom = /** @class */ (function () {
function Dom(element) {
this.eventMap = {};
this.element = element;
}
// 创建DomElement对象(使用空的Dom对象初始化时调用)
Dom.prototype.createElement = function (param) {
var element = document.createElement(param.elementType);
var className = param.className;
if (className) {
DataUtil.assertType(className, 'arr') && (className = className.join(' '));
element.className = className;
}
param.id && (element.id = param.id);
var domObject = new Dom(element);
if (param.parent) {
var parent_1 = param.parent instanceof Dom ? param.parent : new Dom(param.parent);
parent_1.append(domObject);
}
domObject.visible = true;
return domObject; // 返回一个新的以DomElement为参数创建的Dom对象以进行后续的链式操作
};
// 获取HTTPElement对象
Dom.prototype.getElement = function () {
return this.element;
};
// 获取父元素HTTPElement对象
Dom.prototype.getParent = function () {
return this.element.parentElement;
};
// 末尾附加一个子元素
Dom.prototype.append = function (childElement) {
this.element.appendChild(childElement.element);
return this;
};
// 附加一个子元素到指定位置
Dom.prototype.insert = function (childElement, index) {
if (index !== undefined && this.element.childNodes.length > index) {
this.element.insertBefore(childElement.element, this.element.childNodes[index]);
}
else {
this.append(childElement);
}
return this;
};
// 删除一个子元素
Dom.prototype.remove = function (childElement) {
this.element.removeChild(childElement.element);
return this;
};
// 删除所有子元素
Dom.prototype.clear = function () {
while (this.element.childNodes.length > 0) {
this.element.removeChild(this.element.childNodes[0]);
}
return this;
};
// 替换元素
Dom.prototype.replace = function (newElement, oldElement) {
this.element.replaceChild(newElement.getElement(), oldElement.getElement());
return this;
};
// 显示对象
Dom.prototype.show = function () {
if (this.visible)
return this;
this.element.style.display = this.displayType;
this.visible = true;
return this;
};
// 隐藏对象
Dom.prototype.hide = function () {
if (!this.visible)
return this;
if (this.element) {
this.displayType = this.element.style.display;
this.displayType === 'none' && (this.displayType = undefined);
this.element.style.display = 'none';
this.visible = false;
}
return this;
};
// 获取可见性
Dom.prototype.isVisible = function () {
return this.visible;
};
// 添加dom事件监听
Dom.prototype.on = function (eventType, fn, option) {
if (option === void 0) { option = null; }
this.element.addEventListener(eventType, fn, option);
this.eventMap[eventType] = this.eventMap[eventType] || [];
this.eventMap[eventType].push(fn);
return this;
};
// 删除dom事件监听
Dom.prototype.off = function (eventType, fn) {
this.element.removeEventListener(eventType, fn);
if (this.eventMap[eventType]) {
var index = this.eventMap[eventType].indexOf(fn);
index >= 0 && this.eventMap[eventType].splice(index, 1);
}
return this;
};
// 销毁对象
Dom.prototype.destroy = function () {
var _this = this;
var _loop_1 = function (eventType) {
this_1.eventMap[eventType].forEach(function (fn) {
_this.off(eventType, fn);
});
};
var this_1 = this;
for (var eventType in this.eventMap) {
_loop_1(eventType);
}
this.element.parentElement && this.element.parentElement.removeChild(this.element);
this.eventMap = undefined;
this.displayType = undefined;
this.themeType = undefined;
this.element = undefined;
};
Dom.prototype.getClass = function () {
return this.getElement().getAttribute('class');
};
Dom.prototype.hasClass = function (className) {
var currentClassName = this.getClass();
if (!currentClassName)
return false;
var arr = currentClassName && currentClassName.split(' ');
if (arr.indexOf(className) > -1) {
return true;
}
else {
return false;
}
};
// 添加一个或多个css class
Dom.prototype.addClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this.element.classList).add.apply(_a, classes);
return this;
};
// 删除一个或多个css class
Dom.prototype.removeClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this.element.classList).remove.apply(_a, classes);
return this;
};
Dom.prototype.toggleClass = function (className, enable) {
this.getClass(); var hasClassName = this.hasClass(className);
if (enable != undefined) {
if (enable && !hasClassName) {
this.addClass(className);
}
if (!enable) {
this.removeClass(className);
}
}
else {
if (hasClassName) {
this.removeClass(className);
}
else {
this.addClass(className);
}
}
return !hasClassName;
};
// toggle一个css class
Dom.prototype.toggle = function (classname) {
this.element.classList.toggle(classname);
return this;
};
// 获取元素当前在页面中的位置
Dom.prototype.getPosition = function () {
var _a = this.element.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
return { top: top, left: left, right: right, bottom: bottom };
};
// 获取元素的尺寸信息
Dom.prototype.getDimensions = function () {
var _a = this.element.getBoundingClientRect(), width = _a.width, height = _a.height;
return { width: width, height: height };
};
// 获取元素宽度
Dom.prototype.getWidth = function () {
var width = this.element.getBoundingClientRect().width;
return width;
};
// 获取元素高度
Dom.prototype.getHeight = function () {
var height = this.element.getBoundingClientRect().height;
return height;
};
// 获取或设置元素的内容
Dom.prototype.html = function (htmlContent) {
if (htmlContent != undefined) {
this.element.innerHTML = htmlContent;
return this;
}
else {
return this.element.innerHTML;
}
};
// 获取单个css属性或设置单个/多个css属性
Dom.prototype.css = function (key, value) {
if (DataUtil.assertType(key, 'str')) {
if (value) {
this.element.style[key] = value;
return this;
}
else {
return this.element.style[key];
}
}
else if (DataUtil.assertType(key, 'obj')) {
var cssOptions = key;
for (var cssKey in cssOptions) {
this.element.style[cssKey] = cssOptions[cssKey];
}
return this;
}
};
// 获取单个attribute属性或设置单个/多个attribute属性
Dom.prototype.attribute = function (key, value) {
if (DataUtil.assertType(key, 'str')) {
if (value != undefined) {
this.element[key] = value;
return this;
}
else {
return this.element[key];
}
}
else if (DataUtil.assertType(key, 'obj')) {
var attrOptions = key;
for (var attrKey in attrOptions) {
this.element[attrKey] = attrOptions[attrKey];
}
return this;
}
};
// 获取或设置元素的主题
Dom.prototype.theme = function (themeType) {
if (themeType) {
this.themeType && this.removeClass(this.themeType);
this.themeType = themeType;
this.addClass(themeType);
return this;
}
else {
return this.themeType;
}
};
// 点击组件
Dom.prototype.click = function () {
this.element.click();
return this;
};
return Dom;
}());
var UIEvents;
(function (UIEvents) {
UIEvents["ValueChanged"] = "ValueChanged";
UIEvents["Clicked"] = "Clicked";
UIEvents["RightClicked"] = "RightClicked";
UIEvents["MouseOver"] = "MouseOver";
UIEvents["MouseOut"] = "MouseOut";
UIEvents["CheckedChanged"] = "CheckedChanged";
UIEvents["SelectionChanged"] = "SelectionChanged";
UIEvents["ExpendChanged"] = "ExpendChanged";
UIEvents["IsolateChanged"] = "IsolateChanged"; // 是否隔离
})(UIEvents || (UIEvents = {}));
var UIEvents$1 = UIEvents;
/**
* @namespace Glodon.Bimface.Tiles.UI.ControlAnchor
* @classdesc 常量:UI锚点(用以进行控件定位)
* @description Glodon.Bimface.Tiles.UI.ControlAnchor
* @property {String} TopLeft 视图左上角
* @property {String} TopCenter 视图中上侧
* @property {String} TopRight 视图右上角
* @property {String} MiddleLeft 视图左中侧
* @property {String} MiddleRight 视图右中侧
* @property {String} BottomLeft 视图左下角
* @property {String} BottomCenter 视图中下侧
* @property {String} BottomRight 视图右下角
* @property {String} MiddleCenter 视图中心
*/
var ControlAnchor;
(function (ControlAnchor) {
ControlAnchor["TopLeft"] = "TopLeft";
ControlAnchor["TopCenter"] = "TopCenter";
ControlAnchor["TopRight"] = "TopRight";
ControlAnchor["MiddleLeft"] = "MiddleLeft";
ControlAnchor["MiddleRight"] = "MiddleRight";
ControlAnchor["BottomLeft"] = "BottomLeft";
ControlAnchor["BottomCenter"] = "BottomCenter";
ControlAnchor["BottomRight"] = "BottomRight";
ControlAnchor["MiddleCenter"] = "MiddleCenter";
})(ControlAnchor || (ControlAnchor = {}));
var ControlAnchor$1 = ControlAnchor;
// UI组件基类
var Control = /** @class */ (function (_super) {
__extends(Control, _super);
function Control(param) {
var _this = _super.call(this) || this;
_this._domElement = param.element || new Dom().createElement(param.elementParam);
if (param.parent) {
var parentElement = param.parent instanceof Control ? param.parent._domElement
: param.parent instanceof Dom ? param.parent : new Dom(param.parent);
parentElement.append(_this._domElement);
param.parent instanceof Control && (_this._parent = param.parent);
}
_this.id = param.id; // || uuid
_this.type = param.type;
_this.position = { anchor: 'TopLeft', offset: { x: 0, y: 0 } };
return _this;
}
//
Control.prototype.getParent = function () {
return this._parent;
};
// 设置本对象的父级Control对象
Control.prototype.setParent = function (control) {
this._parent = control;
};
// 获取DomElement对象
Control.prototype.getDomElement = function () {
return this._domElement;
};
// 设置点击事件
Control.prototype.onClick = function (fn) {
var _this = this;
this._domElement.on('click', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.Clicked, _this);
});
return this;
};
// 设置鼠标移入事件
Control.prototype.onMouseOver = function (fn) {
var _this = this;
this._domElement.on('mouseover', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.MouseOver, _this);
});
return this;
};
// 设置鼠标移出事件
Control.prototype.onMouseOut = function (fn) {
var _this = this;
this._domElement.on('mouseout', function (eventData) {
fn(eventData);
_this.trigger(UIEvents$1.MouseOut, _this);
});
return this;
};
/**
* 显示
* @function Glodon.Bimface.Tiles.UI.Control.prototype.show
*/
Control.prototype.show = function () {
this._domElement.show();
return this;
};
/**
* 隐藏
* @function Glodon.Bimface.Tiles.UI.Control.prototype.hide
*/
Control.prototype.hide = function () {
this._domElement.hide();
return this;
};
/**
* 获取可见性状态
* @function Glodon.Bimface.Tiles.UI.Control.prototype.isVisible
* @returns {Boolean} 可见性状态
*/
Control.prototype.isVisible = function () {
return this._domElement.isVisible();
};
// 销毁
Control.prototype.destroy = function () {
this._domElement.destroy();
};
/**
* 对组件增加CSS样式
* @function Glodon.Bimface.Tiles.UI.Control.prototype.addClass
* @param {String} class CSS类名
*/
Control.prototype.addClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this._domElement).addClass.apply(_a, classes);
return this;
};
/**
* 对组件移除CSS样式
* @function Glodon.Bimface.Tiles.UI.Control.prototype.removeClass
* @param {String} class CSS类名
*/
Control.prototype.removeClass = function () {
var _a;
var classes = [];
for (var _i = 0; _i < arguments.length; _i++) {
classes[_i] = arguments[_i];
}
(_a = this._domElement).removeClass.apply(_a, classes);
return this;
};
// 删除一个或多个css class
Control.prototype.toggleClass = function (className) {
this._domElement.toggleClass(className);
return this;
};
/**
* 设置组件的位置信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.setPosition
* @param {Object} position 组件的位置信息
* @param {Glodon.Bimface.Tiles.UI.ControlAnchor} position.anchor 定位组件位置的锚点
* @param {Object} position.offset 基于锚点的偏移值
* @param {Number} position.offset.x X方向偏移值,单位为px
* @param {Number} position.offset.y Y方向偏移值,单位为px
*/
Control.prototype.setPosition = function (position) {
if (position.anchor && ControlAnchor$1.hasOwnProperty(position.anchor)) {
for (var key in ControlAnchor$1) {
this.removeClass("bfui-anchor-" + key.toLowerCase());
}
var anchor = position.anchor.toLowerCase();
this.addClass("bfui-anchor-" + anchor);
this.position.anchor = position.anchor;
}
this.setOffset(position.offset);
return this;
};
Control.prototype.setOffset = function (offset) {
if (offset) {
var offsetX = offset.x || 0;
var offsetY = offset.y || 0;
var anchor = this.position.anchor.toLowerCase();
this.setStyle(anchor.indexOf('right') >= 0 ? { marginRight: -offsetX + "px" } : { marginLeft: offsetX + "px" })
.setStyle(anchor.indexOf('bottom') >= 0 ? { marginBottom: -offsetY + "px" } : { marginTop: offsetY + "px" });
this.position.offset.x = offsetX;
this.position.offset.y = offsetY;
}
return this;
};
Control.prototype.getPositionParam = function () {
return this.position;
};
/**
* 获取ID
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getId
* @returns {String} ID
*/
Control.prototype.getId = function () {
return this.id;
};
// 获取Control类型
Control.prototype.getType = function () {
return this.type;
};
/**
* 获取组件的位置信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getPosition
* @returns {Object} 组件的位置信息
*/
Control.prototype.getPosition = function () {
return this._domElement.getPosition();
};
/**
* 获取组件的尺寸信息
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getDimensions
* @returns {Object} 组件的尺寸信息
*/
Control.prototype.getDimensions = function () {
return this._domElement.getDimensions();
};
// 获取元素宽度
Control.prototype.getWidth = function () {
return this._domElement.getWidth();
};
// 获取元素高度
Control.prototype.getHeight = function () {
return this._domElement.getHeight();
};
// 设置css style(传入多个键值对组成的对象参数)
Control.prototype.setStyle = function (style) {
this._domElement.css(style);
return this;
};
Control.prototype.getTooltip = function () {
return this.tooltip;
};
Control.prototype.setTooltip = function (tooltip) {
this.tooltip = tooltip;
this.getDomElement().attribute('title', tooltip);
return this;
};
/**
* 通过HTML字符串初始化Control内容,支持在字符串中插入Control对象标记,配合controlMap实现html与Control混合结构的整体初始化
* @param {string} html Control的内容html字符串。如需插入Control对象,则在插入的位置写入