function MxVueComandLine() { // 命令行 let msCmdText = ""; let msCmdDisplay = ""; let msCmdTip = ""; let mUpDisplayFun = undefined; // 命令行更新 this.mountUpDisplayFun = function (fun) { mUpDisplayFun = fun; } this.upDisplay = function () { if (mUpDisplayFun == undefined) { return; } mUpDisplayFun(); } this.setCmdText = function (str) { msCmdText = str; } this.getCmdText = function () { return msCmdText; } this.getCmdDisplay = function () { return msCmdDisplay; } this.setCmdDisplay = function (str) { msCmdDisplay = str; } this.addCmdDisplay = function (str) { if (msCmdDisplay.length > 1024) { msCmdDisplay = msCmdDisplay.substring(msCmdDisplay.length - 1024, msCmdDisplay.length); msCmdDisplay = msCmdDisplay + str; } else { msCmdDisplay = msCmdDisplay + str; } } this.setCmdTip = function (str) { msCmdTip = str; } this.getCmdTip = function () { return msCmdTip; } } const MxInputType = { kNoInput : 0, kXYCoordInput : 1, kDistanceInput : 2, kDynTip : 3 }; const MxInputPostionType = { kRelative : 0, // 相对mPos计算。并排放。 kAbsolutely : 1 // 绝对位置,指定位置。 }; function MxDynamicInput() { let mType = MxInputType.kNoInput; let mPos=[0,0]; let mTip = ""; let mValue1 = ""; let mValue1Pos = [0,0]; let mValue2 = ""; let mValue2Pos = [0,0]; let misShow = false; let mOnKeydownEvent = undefined; let mFocusValue = ""; this.setFocusValue = function(value){ mFocusValue = value; } this.getFocusValue = function(){ return mFocusValue; } this.mountKeydownEvent = function (fun) { mOnKeydownEvent = fun; } this.onKeydown = function (keyCode) { if (mOnKeydownEvent == undefined) { return; } mOnKeydownEvent(keyCode); } this.setType = function(type){ mType = type; } this.getType = function(){ return mType; } this.isShow = function(){ return misShow; } this.setPos = function(pos){ mPos = pos; } this.setTip = function(tip){ mTip = tip; } this.setValue1 = function(val){ mValue1 = val; } this.getValue1 = function(){ return mValue1; } this.setValue1Pos = function(pos){ mValue1Pos = pos; } this.setValue2 = function(val){ mValue2 = val; } this.getValue2 = function(){ return mValue2; } this.setValue2Pos = function(pos){ mValue2Pos = pos; } this.setShow = function(isShow){ misShow = isShow; } this.getData = function(){ if(!misShow){ return undefined; } let ret = {list:[{value:"",readonly:true},{value:"",readonly:false},{value:"",readonly:false}],pos:mPos,postype:MxInputPostionType.kRelative}; if(mType == MxInputType.kNoInput){ return undefined; } else if(mType == MxInputType.kXYCoordInput){ ret.list[0].show = true; ret.list[0].value = mTip; ret.list[0].readonly = true; ret.list[1].show = true; ret.list[1].value = mValue1; ret.list[1].readonly = false; ret.list[2].show = true; ret.list[2].value = mValue2; ret.list[2].readonly = false; } else if(mType == MxInputType.kDistanceInput) { ret.list[0].show = true; ret.list[0].value = mTip; ret.list[0].readonly = true; ret.list[1].show = true; ret.list[1].value = mValue1; ret.list[1].readonly = false; ret.list[1].pos = mValue1Pos; ret.list[2].show = true; ret.list[2].value = mValue2; ret.list[2].readonly = true; ret.list[2].pos = mValue2Pos; ret.postype = MxInputPostionType.kAbsolutely; } else if(mType == MxInputType.kDynTip) { ret.list[0].show = true; ret.list[0].value = mTip; ret.list[0].readonly = true; ret.list[1].show = false; ret.list[2].show = false; } else { ret = undefined; } return ret; } } function MxVueInterface() { // 标题 const mTitle = { // 是否显示 isShow: true, // 标题 title: '标题' }; // 顶部按钮栏数据 const mTopButtonBarData = { isShow: true, buttonBarData: [{ icon: "iconwenjian", prompt: "提示1" }, { icon: "iconwenjian", prompt: "提示2" }, { icon: "iconwenjian", prompt: "提示3" }] } // 标题按钮栏数据 const mTitleButtonBarData = [{ icon: "iconxinjiantuceng", prompt: "提示" }, { icon: "iconwenjian", prompt: "提示" }, { icon: "iconic_save", prompt: "提示" }, { icon: "iconhoutui-shi", prompt: "提示" }, { icon: "iconqianjin-shi", prompt: "提示" }, { icon: "iconxiajiantou", prompt: "提示" }, ]; // 菜单栏数据 const mMenuBarData = [ { title: "文件(F)", list: [ { tab: "新建(N)", icon: "iconxinjiantuceng" }, { tab: "新建(O)", icon: "icondakaiwenjian" }, { tab: "打开DWG文件(M)", icon: "icondakaidwg" }, { tab: "输入(R)" }, { tab: "保存(S)", icon: "iconic_save" }, { tab: "另存为(A)", icon: "iconlingcunwei" }, { tab: "另存为DWG(F)", icon: "iconDWG1" }, { tab: "输出(E)" }, { tab: "打印(P)", icon: "iconccgl-dayinliebiao-3" }, { tab: "退出(X)" } ] }, { title: "功能(A)", list: [ { tab: "会员登录(L)" }, { tab: "云图(C)" }, { tab: "测量(L)" }, { tab: "批准(P)" }, { tab: "审图批注(P)" }, { tab: "高级工具(O)" }, { tab: "绘图(D)" }, { tab: "编辑(E)" } ] }, { title: "编辑(E)", list: [ { tab: "放弃(R)", icon: "iconhuitui" }, { tab: "回退(U)", icon: "iconhuitui1" }, { tab: "剪切(T)", icon: "iconjianqie" }, { tab: "复制(C)", icon: "iconcopy" }, { tab: "粘贴(P)", icon: "iconniantie" }, { tab: "清除(A)", icon: "iconqingchu" }, { tab: "测距(D)", icon: "iconceju" }, { tab: "前置(F)", icon: "iconqianzhi" }, { tab: "后置(B)", icon: "iconhouzhi" }, { tab: "置于对象之上(S)", icon: "iconr_shangzhi" }, { tab: "置于对象之下(X)", icon: "iconr_xiazhi" } ] }, { title: "视图(V)", list: [ { tab: "重画(R)", icon: "iconicon_zhonghua" }, { tab: "实时缩放(Z)", icon: "iconsuofang1" }, { tab: "上一步", icon: "iconsuofang-zhongzhi" }, { tab: "窗口缩放(W)", icon: "iconzoomtoallitem" }, { tab: "范围缩放(E)", icon: "iconsuofang2" }, { tab: "视区平移(P)", icon: "iconqingchu" }, { tab: "测距(D)", icon: "iconceju" }, { tab: "前置(F)", icon: "iconqianzhi" }, { tab: "后置(B)", icon: "iconhouzhi" }, { tab: "置于对象之上(S)", icon: "iconqianzhisvg" }, { tab: "置于对象之下(X)", icon: "iconhouzhi1" } ] }, { title: "格式(O)", list: [ { tab: "图层...(L)", icon: "iconlayer" }, { tab: "打开所有图层(A)", icon: "iconlight" }, { tab: "选择关闭图层(S)", icon: "iconsuofang-zhongzhi" }, { tab: "颜色(C)" }, { tab: "线型(N)", icon: "iconedit" }, { tab: "线宽(W)" }, { tab: "文字样式(S)", icon: "iconl_wenzi" }, { tab: "标注样式(D)", icon: "iconxianxingbiaozhu" }, { tab: "点样式(P)", icon: "iconl_duoduan" } ] }, { title: "绘图(D)", list: [ { tab: "直线(L)", icon: "iconl_zhixian" }, { tab: "多线段(P)", icon: "iconl_duoduan" }, { tab: "正多边形(Y)", icon: "iconl_duobian" }, { tab: "矩形(G)", icon: "iconl_juxing" }, { tab: "圆弧(A)" }, { tab: "圆(C)", icon: "iconl_yuan" }, { tab: "椭圆(E)", icon: "iconl_tuoyuan" }, { tab: "椭圆弧(O)", icon: "iconl_tuoyuanhu" }, { tab: "样条线(S)", icon: "iconl_quxian" }, { tab: "点(N)", icon: "iconxianxingbiaozhu" }, { tab: "插入块(L...)", icon: "iconcharu1" }, { tab: "文字(T)", icon: "iconziti" }, { tab: "多行文字(M)", icon: "iconduohangwenzi" }, { tab: "填充(H)", icon: "icontianchong" }, { tab: "图片(E)", icon: "iconcharutupian" }, { tab: "线型标注(B)", icon: "iconxianxingbiaozhu" }, { tab: "对齐标注(D)", icon: "iconduiqibiaozhu" }, { tab: "半径标注(F)", icon: "iconbanjingbiaozhu_" }, { tab: "直径标注(G)", icon: "iconzhijing" }, { tab: "倾斜标注(J)", icon: "iconlujingqingxie" }, { tab: "块(K)" }, { tab: "云线(Y)", icon: "iconyunxian" }, { tab: "批注(Z)", icon: "iconpizhu15beifen4" } ], }, { title:"修改(M)", list:[ { tab:"对象特性(O)", icon:"iconduixiang" }, { tab:"快速选择(Q)", icon:"iconxuanze" }, { tab:"特性匹配(F)", icon:"iconpipei" }, { tab:"删除(E)", icon:"iconshanchu" }, { tab:"复制(Y)", icon:"iconcopy" }, { tab:"镜像(I)", icon:"iconjingxiang" }, { tab:"偏移(S)", icon:"iconpianyi" }, { tab:"移动(V)", icon:"iconyidong" }, { tab:"旋转(R)", icon:"iconxuanzhuan" }, { tab:"缩放(L)", icon:"iconsuofang" }, { tab:"修剪(T)", icon:"iconxiujian" }, { tab:"延伸(D)", icon:"iconyanshen" }, { tab:"导角(C)", icon:"icondaojiaoshubiaoyangshi_" }, { tab:"圆角(F)", icon:"iconyuanjiao" }, { tab:"离散(M)", icon:"iconlisanshuju-01" }, { tab:"分解(X)", icon:"iconfenjie" } ] }, { title:"帮助(H)", list:[ { tab:"设置(S)" }, { tab:"热键快捷命令(Q)" }, { tab:"关于(A)" } ] } ]; // 右侧按钮栏 const mRighButtonBarData = { isShow: true, buttonBarData: [{ icon: "iconziti", id: 1, prompt: "字体", }, { icon: "icondashujukeshihuaico-", id: 2, prompt: "表格", }, { icon: "iconl_zhixian", id: 3, prompt: "直线", }, { icon: "iconl_tuoyuanhu", id: 4, prompt: "椭圆弧", }, { icon: "iconl_duoduan", id: 4, prompt: "多端", }, { icon: "iconl_quxian", id: 6, prompt: "曲线", }, { icon: "iconl_xuanding", id: 7, prompt: "选定", }, { icon: "iconr_xiujian", id: 8, prompt: "修剪", }, { icon: "iconl_tuoyuan", id: 9, prompt: "椭圆", }, { icon: "iconr_hebing", id: 10, prompt: "核定", }, { icon: "iconr_quxian", id: 11, prompt: "曲线", }, ] }; // 左侧按钮栏 const mLeftButtonBarData = { isShow: true, buttonBarData: [ { icon: "iconl_zhixian", prompt: "直线", cmd: "Mx_Line" }, { icon: "iconl_tuoyuanhu", prompt: "圆", cmd: "Mx_Circle" }, { icon: "iconl_tuoyuanhu", id: 15, prompt: "椭圆弧", }, { icon: "iconl_duoduan", id: 16, prompt: "多端", }, { icon: "iconl_quxian", id: 17, prompt: "曲线", }, { icon: "iconl_xuanding", id: 18, prompt: "选定", }, { icon: "iconr_xiujian", id: 19, prompt: "修剪", }, { icon: "iconl_tuoyuan", id: 20, prompt: "椭圆", }, { icon: "iconr_hebing", id: 21, prompt: "核定", }, { icon: "iconr_quxian", id: 22, prompt: "曲线", }, ] }; // 层Com盒数据 const mLayerComboxData = { isShow: true, selectionBarData: [ { state: { isLock: true, isEyes: true, isSun: true, isColor: "#FFFFFF", index: 1 }, text: "O" }, { state: { isLock: true, isEyes: true, isSun: true, isColor: "#FFFFFF", index: 2 }, text: "O" }, { state: { isLock: true, isEyes: true, isSun: true, isColor: "#FFFFFF", index: 3 }, text: "OP" }, { state: { isLock: true, isEyes: true, isSun: true, isColor: "#FFFFFF", index: 4 }, text: "A" } ] } // 颜色盒子数据 const mColorComboxData = { isShow: true, selectionBarData: [{ state: { isColor: "#FFFFFF", index: 1 }, text: "白" }, { state: { isColor: "#000000", index: 2 }, text: "黑" } ] } // 线型盒子数据 const mLinetypeComboxData = { isShow: true, selectionBarData: [{ state: { previewImg: "../../assets/xainjihe.png", index: 1 }, text: "ByLay2er", }, { state: { previewImg: "../../assets/xainjihe.png", index: 2 }, text: "ByLa1yer", }, { state: { previewImg: "../../assets/xainjihe.png", index: 3 }, text: "ByLa3yer", }, { state: { previewImg: "../../assets/xainjihe.png", index: 4 }, text: "ByLay4er", } ] } // 底部数据 const mFooterData = { isShow: true, bottomBarData: {} }; const CursorType = { kNormal: "cursor3", kRect: "cursor1", kCross: "cursor2" } const mQuickCommand = [ ["Mx_Line", "l", "line", "li", "_line"], ["Mx_Circle", "circle", "c", "cir", "_circle"] ]; let mSetCoordFun = undefined; let mUpdateCursorFun = undefined; let mOnLayerComboxSelectEvent = undefined; let mOnKeydownEvent = undefined; let mCursorType = CursorType.kNormal; let mComandLine = new MxVueComandLine(); let mdynamicInput = new MxDynamicInput(); let mMxEvents = {}; this.mountSetCoordFun = function (fun) { mSetCoordFun = fun; } this.mountUpdateCursorFun = function (fun) { mUpdateCursorFun = fun; } this.mountLayerComboxSelectEvnet = function (fun) { mOnLayerComboxSelectEvent = fun; } this.mountKeydownEvent = function (fun) { mOnKeydownEvent = fun; } // vue界面上,图层被选择了,的通知消息。 this.onLayerComboxSelect = function (str) { if (mOnLayerComboxSelectEvent == undefined) { return; } mOnLayerComboxSelectEvent(str); } this.onKeydown = function (keyCode) { if (mOnKeydownEvent == undefined) { return; } mOnKeydownEvent(keyCode); } this.setTipCoord = function (str) { if (mSetCoordFun == undefined) { return; } mSetCoordFun(str); } this.getCursorType = function () { return mCursorType; } this.setCursorType = function (curtype) { if (typeof (curtype) == "number") { switch (curtype) { case 0: { mCursorType = CursorType.kNormal; break; } case 1: { mCursorType = CursorType.kRect; break; } case 2: { mCursorType = CursorType.kCross; break; } } } else { mCursorType = curtype; } if (mUpdateCursorFun == undefined) { return; } mUpdateCursorFun(); } this.getTitle = function () { return mTitle; } this.getTopButtonBarData = function () { return mTopButtonBarData; } this.getMenuBarData = function () { return mMenuBarData; } this.getRighButtonBarData = function () { return mRighButtonBarData; } this.getLeftButtonBarData = function () { return mLeftButtonBarData; } this.getTitleButtonBarData = function () { return mTitleButtonBarData; } this.getLayerComboxData = function () { return mLayerComboxData; } this.getColorComboxData = function () { return mColorComboxData; } this.getLinetypeComboxData = function () { return mLinetypeComboxData; } this.getFooterData = function () { return mFooterData; } this.sendStringToExecute = function (sCmd) { MxFun.sendStringToExecute(sCmd) } this.getCmdLine = function () { return mComandLine; } this.getDynamicInput = function(){ return mdynamicInput; } this.init = function () { MxFun.initQuickCommand(mQuickCommand); } this.OnMxEvent = function(event){ let eventName = event["name"]; if(eventName == undefined){ return; } let call = mMxEvents[eventName]; if(call == undefined){ return; } call(event["param"]); } this.mountMxEvent = function(name,call){ mMxEvents[name] = call; } } var mxvue = new MxVueInterface()