| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- include("scripts/Common/DrawingUtils.js");
- include("scripts/Common/FileCTR.js");
- include("scripts/Common/FileDMX.js");
- include("scripts/Common/FileZDM.js");
- // 纵断面,地面线CTR
- // 有纵断面,画竖曲线半径和坡度
- // 有地面线才画设计高程,地面高程,里程桩号
- // 有CTR,才画桥梁,隧道
- function DrawZdmAll(ratio) {
- // 比例尺
- this.ratio = ratio || 10.0;
- }
- DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile, isCertCsv) {
- // 图层
- var layername = layer || getLayername("ZDM", zdmFile);
- addLayerToView(layername, "white", "CONTINUOUS", RLineweight.Weight025, 0);
- setCurrentLayer(layername);
- // qsTr("地面线文件") + " (*.dmx);"
- var fileDMX = new FileDMX(dmxFile, this.ratio);
- fileDMX.applyOperation();
- var dmxData = fileDMX.getArrayData();
- // qsTr("纵断面文件") + " (*.zdm);"
- var drawZdm = new FileZDM(zdmFile, this.ratio);
- // 线绘图在生成CSV文件
- drawZdm.applyOperation();
- if (isCertCsv) {
- drawZdm.saveCsvFile();
- }
- var zdmData = drawZdm.getZDMArray();
- // qsTr("桥梁 隧道") + " (*.ctr);"
- var fileCTR = new FileCTR(ctrFile, this.ratio);
- fileCTR.applyBridge(zdmData, dmxData, new RColor(31, 57, 197));
- fileCTR.applyTunnel(zdmData, new RColor(255, 255, 0));
- // 以下开始绘画表格数据
- var extreme_dmx = this.getExtremePosition(zdmData.length > 0 ? zdmData : dmxData);
- addPolylinetoView([extreme_dmx[0], extreme_dmx[2]], false, false, 0, new RColor(255, 255, 0));
- addPolylinetoView([extreme_dmx[1], extreme_dmx[3]], false, false, 0, new RColor(255, 255, 0));
- var startPoint = extreme_dmx[2];
- var endPoint = extreme_dmx[3];
- var text_width = 260;
- addPolylinetoView([[startPoint[0] - text_width, startPoint[1]], endPoint], false, false, 0, new RColor(255, 255, 0));
- var array = new Array();
- array.push({ name: "R", "space": 60, text: "竖曲线半径 (m)" });
- array.push({ name: "SJGC", "space": 100, text: "设计高程 (m)" });
- array.push({ name: "DMGC", "space": 100, text: "地面高程 (m)" });
- array.push({ name: "PDPC", "space": 100, text: "坡度 (%) 坡长 (m)" });
- array.push({ name: "BLZH", "space": 120, text: "百里桩号 (m)" });
- for (var i = 0; i < array.length; i++) {
- var item = array[i];
- var space = (item.space || 100);
- var text = (item.text || "").toString();
- addPolylinetoView([[startPoint[0] - text_width, startPoint[1] - space * (i + 1)], [endPoint[0], endPoint[1] - space * (i + 1)]], false, false, 0, new RColor(255, 255, 0));
- addSimpleTextToView(text, [startPoint[0] - text_width + 50, startPoint[1] - space * (i + 1) + 50], 15, 0, "宋体", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- switch (item.name) {
- case "R":
- drawZdm.applyRadius([startPoint[0], startPoint[1] - space * i], space);
- break;
- case "SJGC":
- this.applyHeightMileage(dmxData, [startPoint[0], startPoint[1] - space * i], space);
- break;
- case "DMGC":
- this.applyHeightMileage(zdmData, [startPoint[0], startPoint[1] - space * i], space);
- break;
- case "PDPC":
- drawZdm.applySlope([startPoint[0], startPoint[1] - space * i], space);
- break;
- case "BLZH":
- this.applyMileage(zdmData, [startPoint[0], startPoint[1] - space * i], space);
- break;
- }
- if (i == array.length - 1) {
- addPolylinetoView([startPoint, [startPoint[0], startPoint[1] - space * (i + 1)]], false, false, 0, new RColor(255, 255, 0));
- addPolylinetoView([endPoint, [endPoint[0], endPoint[1] - space * (i + 1)]], false, false, 0, new RColor(255, 255, 0));
- }
- }
- // 居中显示
- var di = getAssignDocumentInterface(0);
- if (!isNull(di)) {
- di.autoZoom();
- }
- return true;
- }
- DrawZdmAll.prototype.applyHeightMileage = function (arrayData, startPoint, spacetext) {
- var space = 50;
- var spaceDistance = 0;
- for (var i = 0; i < arrayData.length; i++) {
- if (i != 0) {
- spaceDistance = spaceDistance + (arrayData[i][0] - arrayData[i - 1][0]);
- }
- if (i != 0 && spaceDistance < space) {
- // 不足最小间距
- continue;
- }
- spaceDistance = 0;
- var text = (round((arrayData[i][1]) * 100) / 100).toString();
- addSimpleTextToView(text, [arrayData[i][0], startPoint[1] - spacetext + 30], 15, 90, "宋体", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- }
- }
- DrawZdmAll.prototype.applyMileage = function (arrayData, startPoint, space) {
- spaceDistance = 0;
- var bailiDistance = 0;
- var tenBailiDistance = 0;
- for (var i = 0; i < arrayData.length; i++) {
- if (i != 0) {
- spaceDistance = spaceDistance + (arrayData[i][0] - arrayData[i - 1][0]);
- bailiDistance = bailiDistance + (arrayData[i][0] - arrayData[i - 1][0]);
- tenBailiDistance = tenBailiDistance + (arrayData[i][0] - arrayData[i - 1][0]);
- }
- if (i == 0 || spaceDistance >= 50) {
- // 绘制桩号 必须满足最小间距
- spaceDistance = 0;
- var text = (round((arrayData[i][0] % 1000) * 1000) / 1000).toString();
- addSimpleTextToView(text, [arrayData[i][0], startPoint[1] - 50], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- }
- if (i == 0) {
- var x = arrayData[i][0];
- addSimpleTextToView("K" + (Math.floor(arrayData[i][0] / 1000) * 1000).toString(), [x, startPoint[1] - space + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- addPolylinetoView([[x, startPoint[1] - space], [x, startPoint[1] - space + 5]], false, false, 0, new RColor(255, 255, 0));
- } else if (tenBailiDistance > 1000) {
- // 千里标 K
- tenBailiDistance = tenBailiDistance % 1000;
- bailiDistance = bailiDistance % 100;
- var x = Math.floor(arrayData[i][0] / 1000) * 1000;
- addSimpleTextToView("K" + Math.floor(arrayData[i][0] / 1000).toString(), [x, startPoint[1] - space + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- addPolylinetoView([[x, startPoint[1] - space], [x, startPoint[1] - space - 5]], false, false, 0, new RColor(255, 255, 0));
- } else if (bailiDistance > 100) {
- // 百里标
- bailiDistance = bailiDistance % 100;
- var x = Math.floor(arrayData[i][0] / 100) * 100;
- addSimpleTextToView(Math.floor(arrayData[i][0] / 100).toString(), [x, startPoint[1] - space + 10], 15, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
- addPolylinetoView([[x, startPoint[1] - space], [x, startPoint[1] - space + 5]], false, false, 0, new RColor(255, 255, 0));
- }
- }
- }
- DrawZdmAll.prototype.getExtremePosition = function (array) {
- var len = array.length;
- if (len == 0) {
- EAction.handleUserMessage("extreme data is empty...");
- return [[0, 0], [0, 0], [0, 0], [0, 0]];
- }
- var y_min = array[0][1];
- var y_max = array[0][1];
- for (var i = 0; i < len; i++) {
- y_min = Math.min(array[i][1], y_min);
- y_max = Math.max(array[i][1], y_max);
- }
- var padding = 0;
- var verPadding = 40
- return [
- // 左上
- [array[0][0] - padding, y_max + verPadding],
- // 右上
- [array[len - 1][0] + padding, y_max + verPadding],
- // 左下
- [array[0][0] - padding, y_min - verPadding],
- // 右下
- [array[len - 1][0] + padding, y_min - verPadding],
- ];
- };
|