/** * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved. * * This file is part of the QCAD project. * * QCAD is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * QCAD is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with QCAD. */ include("scripts/EAction.js"); include("scripts/simple.js"); include("scripts/Layer/Layer.js"); include("scripts/Common/CsvToPmConvert.js") include("scripts/Common/DrawPM.js") function PMOptimize(guiAction) { EAction.call(this, guiAction); this.pmsel = false; this.selectLineDialog = undefined; } PMOptimize.prototype = new EAction(); PMOptimize.includeBasePath = includeBasePath; PMOptimize.prototype.beginEvent = function () { EAction.prototype.beginEvent.call(this); try { var appWin = EAction.getMainWindow(); this.selectLineDialog = this.createWidget(PMOptimize.includeBasePath + "/SelectLineDialog.ui", appWin); var pmWidget = this.selectLineDialog.findChild("pmWidget"); var opBtn = this.selectLineDialog.findChild("opBtn"); var exitBtn = this.selectLineDialog.findChild("exitBtn"); opBtn.clicked.connect(this, this.opBtnClicked); exitBtn.clicked.connect(this, this.exitBtnClicked); this.btngrp = new QButtonGroup(pmWidget); var allPMFile = RSettings.getStringValue("OpenDisplayFile/PMFile", ""); EAction.handleUserMessage("allPMFile: " + allPMFile.toString()); var pmList = allPMFile.split(','); this.pms = new Array(); for (var i = 0; i < pmList.length; i++) { if (pmList[i] == "" || this.pms.indexOf(pmList[i]) !== -1) { continue; } this.pms.push(pmList[i]); } if (this.pms.length == 0) { opBtn.setEnabled(false); } for (var i = 0; i < this.pms.length; i++) { var pmFile = new QRadioButton(this.pms[i], pmWidget); pmFile.setGeometry(50, 25 + 40 * i, 1200, 40); this.btngrp.addButton(pmFile, i); pmFile.clicked.connect(this, this.pmClicked); } if (!this.selectLineDialog.exec()) { EAction.handleUserMessage("clicked~"); destr(this.selectLineDialog); EAction.activateMainWindow(); return undefined; } } catch (error) { EAction.handleUserMessage("PMOptimize.js, ERROR: " + error.toString()); } }; PMOptimize.prototype.opBtnClicked = function () { if (!this.pmsel) { var appWin = EAction.getMainWindow(); QMessageBox.information(appWin, qsTr("提示"), qsTr("请选择优化的的文件")); return; } // 点击后的事件 // if(this.pmsel){ // var pmd = new PM(); // pmd.interface(this.pms[this.pmid]); // } try { 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]); convert.convert(); // 绘制PM var filePM = new DrawPM(convert.getPmFileName(), this.ratio, 0); filePM.applyDrawing(); } // 关闭弹框 this.exitBtnClicked(); } catch (error) { EAction.handleUserMessage("PMOptimize.js, ERROR: " + error.toString()); } }; PMOptimize.prototype.exitBtnClicked = function () { if (this.selectLineDialog) { destr(this.selectLineDialog); } }; PMOptimize.prototype.pmClicked = function () { this.pmsel = true; this.pmid = this.btngrp.checkedId(); EAction.handleUserMessage(this.pms[this.pmid]); };