소스 검색

fix 修复BUG

zhanghaijun 3 년 전
부모
커밋
5121e79d02

+ 24 - 0
.editorconfig

@@ -0,0 +1,24 @@
+# EditorConfig 用于在 IDE 中检查代码的基本 Code Style
+# @see: https://editorconfig.org/
+
+[*]
+end_of_line = lf
+indent_size = 2
+indent_style = space
+max_line_length = 320
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+max_line_length = off
+trim_trailing_whitespace = false
+
+[*.{js,jsx,ts,tsx,vue}]
+end_of_line = lf
+
+[*.{java, gradle, groovy, kt, sh}]
+indent_size = 4
+
+[*.{bat, cmd}]
+end_of_line = crlf

+ 1 - 0
.gitignore

@@ -8,6 +8,7 @@ plugins/script/qtscript_widgets.pdb
 release/plugins/script/qtscript_widgets.pdb
 scripts/Common/csv2pm.exe
 scripts/Common/csv2zdm.exe
+scripts/Common/ProgressBar.exe
 scripts/Data/InitialDataImport/CSVImport/PMCsvImport/csv2pm.exe
 scripts/Data/InitialDataImport/CSVImport/ZDMCsvImport/csv2zdm.exe
 scripts/Data/InitialDataImport/DialogInput/PMDialogInput/csv2pm.exe

+ 1 - 1
README.md

@@ -4,7 +4,7 @@
 ## 代码拉取
 1. 拉取代码
 2. 下载ZIP并在根目录下解压到当前目录
-3. 下载地址 [https://pan.baidu.com/s/1xl93BvVAMLLaCzQwrVeGBA?pwd=kdke](https://pan.baidu.com/s/1xl93BvVAMLLaCzQwrVeGBA?pwd=kdke)
+3. 下载地址 [https://pan.baidu.com/s/1JYiTJORp5A3Dm5S-zsMUIg?pwd=puin](https://pan.baidu.com/s/1JYiTJORp5A3Dm5S-zsMUIg?pwd=puin)
 
 ## 项目提交
 ### 查找超过20MB的文件

+ 3 - 3
issue/20231003.txt

@@ -1,10 +1,10 @@
 1、PM文件导入,图层问题,导入到了0图层。(偶发的)  待测试
 2、(修改完成)PM优化,弹框,未选择线路,不能点击优化按钮。
-3、PM优化,添加10s加载动画。 10s前可以手动关闭优化过程。 
+3、(修改完成)PM优化,添加10s加载动画。 10s前可以手动关闭优化过程。 
 4、(修改完成)ZDM坡度 预期 *100。
 5、(修改完成)ZDM 坡长应为两个变坡点间的距离,而不是两边变坡点间直线的长度。
-6、ZDM比例调整 10.0 => 1.0
-7、ZDM添加坡度坡长。
+6、(修改完成)ZDM比例调整 10.0 => 1.0
+7、(修改完成)ZDM添加坡度坡长。
 8、(修改完成)para.ini文件,打开工程和新建工程 复制一份para.ini保证项目中的使用。
 
 10、dxf导入时毫无反应,地形不能导入;之前20M以内的等一会还能导入,现在导入直接没反应

+ 0 - 4
scripts/.gitignore

@@ -1,4 +0,0 @@
-Pro
-Cam
-tmp
-**/*.exe

+ 9 - 8
scripts/Common/DrawZdmAll.js

@@ -9,7 +9,8 @@ include("scripts/Common/FileZDM.js");
 // 有地面线才画设计高程,地面高程,里程桩号
 // 有CTR,才画桥梁,隧道
 function DrawZdmAll(ratio) {
-  this.ratio = ratio || 10.0;
+  // 比例尺
+  this.ratio = 1.0; //ratio || 10.0;
 }
 
 DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile, isCertCsv) {
@@ -22,13 +23,13 @@ DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile,
   fileDMX.applyOperation();
   var dmxData = fileDMX.getArrayData();
   // qsTr("纵断面文件") + " (*.zdm);"
-  var DrawZdmAll = new FileZDM(zdmFile, this.ratio);
+  var drawZdm = new FileZDM(zdmFile, this.ratio);
   // 线绘图在生成CSV文件
-  DrawZdmAll.applyOperation();
+  drawZdm.applyOperation();
   if (isCertCsv) {
-    DrawZdmAll.saveCsvFile();
+    drawZdm.saveCsvFile();
   }
-  var zdmData = DrawZdmAll.getZDMArray();
+  var zdmData = drawZdm.getZDMArray();
   // qsTr("桥梁 隧道") + " (*.ctr);"
   var fileCTR = new FileCTR(ctrFile, this.ratio);
   fileCTR.applyBridge(zdmData, dmxData, new RColor(31, 57, 197));
@@ -46,7 +47,7 @@ DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile,
   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: "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];
@@ -56,7 +57,7 @@ DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile,
     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":
-        DrawZdmAll.applyRadius([startPoint[0], startPoint[1] - space * i], space);
+        drawZdm.applyRadius([startPoint[0], startPoint[1] - space * i], space);
         break;
       case "SJGC":
         this.applyHeightMileage(dmxData, [startPoint[0], startPoint[1] - space * i], space);
@@ -65,7 +66,7 @@ DrawZdmAll.prototype.applyPainting = function (layer, dmxFile, zdmFile, ctrFile,
         this.applyHeightMileage(zdmData, [startPoint[0], startPoint[1] - space * i], space);
         break;
       case "PDPC":
-        DrawZdmAll.applySlope([startPoint[0], startPoint[1] - space * i], space);
+        drawZdm.applySlope([startPoint[0], startPoint[1] - space * i], space);
         break;
       case "BLZH":
         this.applyMileage(zdmData, [startPoint[0], startPoint[1] - space * i], space);

+ 43 - 12
scripts/Common/FileZDM.js

@@ -46,11 +46,12 @@ FileZDM.prototype.applyOperation = function () {
     if (this.newEntityData[i][2] == 1) {
       addPolylinetoView(TempLineData, false, false, 0, PDColor);
       // 计算斜率
-      var pdAngle = (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) / (this.newEntityData[i + 1][0] - this.newEntityData[i][0]);
+      // var pdAngle = (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) / (this.newEntityData[i + 1][0] - this.newEntityData[i][0]);
+      var pdAngle = (this.csvCoor[c + 1][1] - this.csvCoor[c][1]) / (this.csvCoor[c + 1][0] - this.csvCoor[c][0]);
       // 计算长度
-      var pdLen = sqrt((this.newEntityData[i + 1][1] - this.newEntityData[i][1]) * (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) + (this.newEntityData[i + 1][0] - this.newEntityData[i][0]) * (this.newEntityData[i + 1][0] - this.newEntityData[i][0]));
+      // var pdLen = sqrt((this.newEntityData[i + 1][1] - this.newEntityData[i][1]) * (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) + (this.newEntityData[i + 1][0] - this.newEntityData[i][0]) * (this.newEntityData[i + 1][0] - this.newEntityData[i][0]));
       addSimpleTextToView((round(pdAngle * 100 * 1000) / 1000).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 + 9], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
-      addSimpleTextToView((round(this.csvCoor[c+1][0]-this.csvCoor[c][0])).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addSimpleTextToView((round(this.csvCoor[c + 1][0] - this.csvCoor[c][0])).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
       c++;
       // addSimpleTextToView((round(pdLen * 1000) / 1000).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
     } else if (this.newEntityData[i][2] == 2) {
@@ -258,16 +259,46 @@ FileZDM.prototype.applyRadius = function (startPoint, space) {
   }
 }
 FileZDM.prototype.applySlope = function (startPoint, space) {
+  // 节点的数组
+  var array = this.csvCoor;
+  // 上一个节点的坐标
   var lastPoint = undefined;
-  for (var i = 0; i < this.newFZEntityData.length; i += 3) {
-    if (i + 1 < this.newFZEntityData.length && this.newFZEntityData[i + 1][2] == 2) {
-      addLineToView([lastPoint[0], lastPoint[1]], [startPoint[0], startPoint[1]], 0);
-      if (lastPoint && this.newFZEntityData[i + 1][1] > lastPoint[1]) {
-        addLineToView([lastPoint[0], startPoint[1] - space], [this.newFZEntityData[i + 1][0], startPoint[1]], 0);
-      } else if (lastPoint) {
-        addLineToView([lastPoint[0], startPoint[1]], [this.newFZEntityData[i + 1][0], startPoint[1] - space], 0);
-      }
-      lastPoint = this.newFZEntityData[i + 1];
+  var yMax = startPoint[1];
+  var yMin = startPoint[1] - space;
+  for (var i = 0; i < array.length; i++) {
+    var item = array[i];
+    if (i == 0) {
+      // 第一次进来
+      lastPoint = item;
+      continue;
+    }
+    var textAngle = undefined;
+    var revers = 1;
+    if (lastPoint && item[1] > lastPoint[1]) {
+      addLineToView([lastPoint[0] / this.ratio, yMin], [item[0] / this.ratio, yMax], 0);
+      textAngle = Math.atan((yMax - yMin) / ((item[0] - lastPoint[0]) / this.ratio));
+      revers = 1;
+    } else if (lastPoint && item[1] <= lastPoint[1]) {
+      addLineToView([lastPoint[0] / this.ratio, yMax], [item[0] / this.ratio, yMin], 0);
+      textAngle = Math.atan((yMin - yMax) / ((item[0] - lastPoint[0]) / this.ratio));
+      revers = -1;
+    }
+    // 计算斜率
+    var angle = (item[1] - lastPoint[1]) / (item[0] - lastPoint[0]);
+    var x = (lastPoint[0] + (item[0] - lastPoint[0]) * 1 / 2) / this.ratio;
+    var y = yMax - space * 1 / 2;
+
+    if (revers == 1) {
+      addSimpleTextToView((round(angle * 100 * 1000) / 1000).toString(), [x - 2, y + 8], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addSimpleTextToView((round((item[0] - lastPoint[0]) * 1000) / 1000).toString(), [x - 2, y - 4], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+    } else {
+      addSimpleTextToView((round(angle * 1000) / 1000).toString(), [x + 2, y + 8], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+      addSimpleTextToView((round((item[0] - lastPoint[0]) * 1000) / 1000).toString(), [x - 2, y - 4], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
     }
+    // 绘画竖线
+    addLineToView([item[0] / this.ratio, yMax], [item[0] / this.ratio, yMin], 0);
+    addSimpleTextToView("+" + (round((item[0]) * 1000) / 1000).toString(), [item[0] / this.ratio - 10, y - 25], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+    addSimpleTextToView((round((item[1] - lastPoint[1]) * 1000) / 1000).toString(), [item[0] / this.ratio + 6, y - 25], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
+    lastPoint = item;
   }
 }

+ 21 - 0
scripts/Common/OptimizeConvert.js

@@ -0,0 +1,21 @@
+include("scripts/EAction.js");
+include("scripts/simple.js");
+
+function OptimizeConvert(name) {
+  this.name = name || "平面"
+}
+OptimizeConvert.includeBasePath = includeBasePath;
+OptimizeConvert.prototype.exec = function () {
+  var path = OptimizeConvert.includeBasePath;
+  EAction.handleUserMessage(path + "/ProgressBar.exe");
+  // 优化操作
+  var process = new QProcess;
+  process.setProgram(path + "/ProgressBar.exe");
+  var args = [];
+  args.push(path);
+  args.push(this.name);
+  process.setArguments(args);
+  process.start();
+  process.waitForStarted(); //等待程序启动
+  process.waitForFinished(-1);//等待程序关闭
+}

BIN
scripts/Common/loading.gif


+ 3 - 3
scripts/Data/InitialDataImport/CSVImport/ZDMCsvImport/ZDMCsvImport.js

@@ -62,7 +62,7 @@ ZDMCsvImport.prototype.convert = function (csvFile) {
     // CSV => ZDM
     var convert = new CsvToZdmConvert(csvFile);
     convert.convert();
-    var filename = convert.getZdmFileName();
+    var zdmFile = convert.getZdmFileName();
     // 图层
     var layername = getLayername("CSV>ZDM", csvFile);
     // 绘制ZDM
@@ -70,10 +70,10 @@ ZDMCsvImport.prototype.convert = function (csvFile) {
     var path = RSettings.getStringValue("OpenProject/Current", "");
     var dmxFile = path + "/诸城南-五莲北.DMX";
     var ctrFile = dmxFile.replace(/.\w+$/i, ".CTR");
-    drawZdmAll.applyPainting(layername, dmxFile, filename, ctrFile, false);
+    drawZdmAll.applyPainting(layername, dmxFile, zdmFile, ctrFile, false);
     if (true) {
       var tmp = RSettings.getStringValue("OpenDisplayFile/ZDMFile", "");
-      RSettings.setValue("OpenDisplayFile/ZDMFile", tmp + "," + dmxFile);
+      RSettings.setValue("OpenDisplayFile/ZDMFile", tmp + "," + zdmFile);
     }
   } catch (error) {
     EAction.handleUserMessage("ZDMCsvImport.js, ERROR: " + error.toString());

+ 4 - 0
scripts/Data/InitialDataImport/LatitudeFileImport/ExZDMImport/ExZDMImport.js

@@ -66,6 +66,10 @@ ExZDMImport.prototype.applyPainting = function (file) {
   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) {
 //   // 图层

+ 5 - 2
scripts/Optimize/PMOptimize/PMOptimize.js

@@ -21,6 +21,7 @@ include("scripts/EAction.js");
 include("scripts/simple.js");
 include("scripts/Layer/Layer.js");
 include("scripts/Common/CsvToPmConvert.js")
+include("scripts/Common/OptimizeConvert.js")
 include("scripts/Common/DrawPM.js")
 
 function PMOptimize(guiAction) {
@@ -73,7 +74,6 @@ PMOptimize.prototype.beginEvent = function () {
   }
 };
 
-
 PMOptimize.prototype.opBtnClicked = function () {
   if (!this.pmsel) {
     var appWin = EAction.getMainWindow();
@@ -86,12 +86,15 @@ PMOptimize.prototype.opBtnClicked = function () {
   //   pmd.interface(this.pms[this.pmid]);
   // }  
   try {
+    // 模拟优化过程
+    var optimize = new OptimizeConvert("平面");
+    optimize.exec();
+    // 优化完毕,开始绘画PM
     var pjPath = RSettings.getStringValue("OpenProject/Current", "");
     var array = new Array();
     array.push(pjPath + "/Output_data/平面参数-NDVI最优解.csv");
     array.push(pjPath + "/Output_data/平面参数-平衡解.csv");
     array.push(pjPath + "/Output_data/平面参数-造价最优解.csv");
-
     for (var i = 0; i < array.length; i++) {
       // CSV -> PM
       var convert = new CsvToPmConvert(array[i]);

+ 5 - 1
scripts/Optimize/ZDMOptimize/ZDMOptimize.js

@@ -2,6 +2,7 @@ include("scripts/EAction.js");
 include("scripts/simple.js");
 include("scripts/Common/DrawingUtils.js");
 include("scripts/Common/CsvToZdmConvert.js")
+include("scripts/Common/OptimizeConvert.js")
 include("scripts/Common/FileZDM.js")
 include("scripts/Common/DrawZdmAll.js");
 
@@ -69,9 +70,12 @@ ZDMOptimize.prototype.opBtnClicked = function () {
       QMessageBox.information(appWin, qsTr("提示"), qsTr("请选择优化的的文件"));
       return;
     }
+    // 模拟优化过程
+    var optimize = new OptimizeConvert("纵断面");
+    optimize.exec();
     // 图层
     var layername = "ZDM-OPTIMIZE" + Math.floor(Math.random() * 100); // getLayername("ZDM-OPTIMIZE", "");
-    // 
+    // 开始绘画
     var path = RSettings.getStringValue("OpenProject/Current", "");
     var convert = new CsvToZdmConvert(path + "/Output_data/最优纵断面参数.csv");
     convert.convert();