| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- include("scripts/EAction.js");
- include("scripts/simple.js");
- include("scripts/Common/DrawingUtils.js");
- include("scripts/Common/DrawZdmAll.js");
- function ExZDMImport(guiAction) {
- EAction.call(this, guiAction);
- this.ratio = 10.0;
- }
- ExZDMImport.prototype = new EAction();
- ExZDMImport.includeBasePath = includeBasePath;
- ExZDMImport.prototype.beginEvent = function () {
- EAction.prototype.beginEvent.call(this);
- var appWin = EAction.getMainWindow();
- if (RSettings.getStringValue("OpenProject/Current", "") == "") {
- QMessageBox.critical(appWin, qsTr("提示"), qsTr("请先选择工程路径"));
- return;
- }
- var lastOpenFileDir = RSettings.getStringValue("OpenProject/Current", RSettings.getDocumentsLocation());
- var filterAll = qsTr("纵断面文件") + " (*.zdm);";
- var fileDialog = new QFileDialog(appWin, qsTr("请选择纵断面文件"), lastOpenFileDir, "");
- fileDialog.setNameFilters([filterAll]);
- fileDialog.selectNameFilter(filterAll);
- fileDialog.setOption(QFileDialog.DontUseNativeDialog, getDontUseNativeDialog());
- fileDialog.fileMode = QFileDialog.ExistingFiles;
- if (!fileDialog.exec()) {
- destr(fileDialog);
- EAction.activateMainWindow();
- this.terminate();
- return;
- }
- var files = fileDialog.selectedFiles();
- if (files.length === 0) {
- destr(fileDialog);
- EAction.activateMainWindow();
- this.terminate();
- return;
- }
- destr(fileDialog);
- EAction.activateMainWindow();
- try {
- this.fileName = files[0];
- var ok = this.applyPainting(this.fileName);
- if (ok) {
- var tmp = RSettings.getStringValue("OpenDisplayFile/ZDMFile", "");
- RSettings.setValue("OpenDisplayFile/ZDMFile", tmp + "," + this.fileName);
- // EAction.handleUserMessage("sucessful load!");
- }
- // RSettings.setValue("ImportZdmFile/Path", this.fileName);
- } catch (error) {
- EAction.handleUserMessage("fail load, error: " + error.toString());
- }
- };
- ExZDMImport.prototype.slotRatioButtonclicked = function (v) {
- qDebug(v);
- this.ratio = v;
- this.applyOperation();
- };
- ExZDMImport.prototype.applyPainting = function (file) {
- var drawZdmAll = new DrawZdmAll(this.ratio);
- var layername = getLayername("ZDM", file);
- var dmxFile = file.replace(/.\w+$/i, ".DMX");
- var zdmFile = file.replace(/.\w+$/i, ".ZDM");
- var ctrFile = file.replace(/.\w+$/i, ".CTR");
- drawZdmAll.applyPainting(layername, dmxFile, zdmFile, ctrFile, true);
- if (true) {
- var tmp = RSettings.getStringValue("OpenDisplayFile/ZDMFile", "");
- RSettings.setValue("OpenDisplayFile/ZDMFile", tmp + "," + zdmFile);
- }
- }
- // ExZDMImport.prototype.applyPainting = function (file) {
- // // 图层
- // var layername = getLayername("ZDM", file);
- // addLayerToView(layername, "white", "CONTINUOUS", RLineweight.Weight025, 0);
- // setCurrentLayer(layername);
- // // qsTr("地面线文件") + " (*.dmx);"
- // var fileDMX = new FileDMX(file.replace(/.\w+$/i, ".DMX"), this.ratio);
- // fileDMX.applyOperation();
- // var dmxData = fileDMX.getArrayData();
- // // qsTr("纵断面文件") + " (*.zdm);"
- // var exZDMImport = new FileZDM(file.replace(/.\w+$/i, ".ZDM"), this.ratio);
- // // 线绘图在生成CSV文件
- // exZDMImport.applyOperation();
- // exZDMImport.saveCsvFile();
- // var zdmData = exZDMImport.getZDMArray();
- // // qsTr("桥梁 隧道") + " (*.ctr);"
- // var fileCTR = new FileCTR(file.replace(/.\w+$/i, ".CTR"), this.ratio);
- // fileCTR.applyBridge(zdmData, dmxData, new RColor(31, 57, 197));
- // fileCTR.applyTunnel(zdmData, new RColor(255, 255, 0));
- // // 以下开始绘画表格数据
- // var extreme_dmx = this.getExtremePosition(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":
- // exZDMImport.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":
- // exZDMImport.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;
- // };
- // ExZDMImport.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);
- // }
- // }
- // ExZDMImport.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));
- // }
- // }
- // }
- // ExZDMImport.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 = 20
- // 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],
- // ];
- // };
|