forked from SeAIPalette/SeAIPalette
ADD file via upload
This commit is contained in:
parent
82e80a5b3b
commit
4747b58d70
|
@ -0,0 +1,127 @@
|
|||
import sys, os
|
||||
from MainWindow_map import Ui_MainWindow
|
||||
from PyQt5 import QtWidgets, QtCore, QtSql, QtGui
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtGui import QPixmap
|
||||
|
||||
import threading, time, subprocess
|
||||
|
||||
class mywindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
def __init__(self):
|
||||
super(mywindow, self).__init__()
|
||||
self.setupUi(self)
|
||||
|
||||
self.comboBox_map.addItems(['地图0', '地图1', '地图2'])
|
||||
|
||||
self.comboBox_algo.addItems(['野火法+牛耕法', '野火法+内螺旋法', '野火法+贪心法'])
|
||||
|
||||
self.comboBox_axis.addItems(['x', 'y'])
|
||||
|
||||
self.comboBox_render.addItems(['是', '否'])
|
||||
|
||||
self.comboBox_around.addItems(['不考虑', '考虑'])
|
||||
|
||||
self.comboBox_bettery.addItems(['否', '是'])
|
||||
|
||||
if self.comboBox_bettery.currentText() == '否':
|
||||
self.lineEdit_bettery.setEnabled(False)
|
||||
|
||||
def slot_bettery(self):
|
||||
if self.comboBox_bettery.currentText() == '否':
|
||||
self.lineEdit_bettery.setEnabled(False)
|
||||
if self.comboBox_bettery.currentText() == '是':
|
||||
self.lineEdit_bettery.setEnabled(True)
|
||||
|
||||
def thread_run(self):
|
||||
if self.comboBox_bettery.currentText() == '否':
|
||||
if self.ships_num == '1':
|
||||
if self.comboBox_algo.currentText() == '野火法+牛耕法':
|
||||
cmd = 'python -u -m Palette.examples.wildfire_boustrophedon -c '+self.map+self.render+'--cover-ratio '+self.cover_ratio
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True,stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(),encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+内螺旋法':
|
||||
cmd = 'python -u -m Palette.examples.wildfire_spiral -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+贪心法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_greedy -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio + ' -n 1'
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
elif self.ships_num != '1':
|
||||
if self.comboBox_algo.currentText() == '野火法+牛耕法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_boustrophedon -c '+self.map+self.render+'--cover-ratio '+self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True,stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(),encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+内螺旋法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_spiral -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+贪心法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_greedy -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
|
||||
elif self.comboBox_bettery.currentText() == '是':
|
||||
if self.ships_num != '1':
|
||||
if self.comboBox_algo.currentText() == '野火法+牛耕法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_boustrophedon -c '+self.map+self.render+'--cover-ratio '+self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis+' -b '+self.lineEdit_bettery.text()
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True,stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(),encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+内螺旋法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_spiral -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis+' -b '+self.lineEdit_bettery.text()
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
elif self.comboBox_algo.currentText() == '野火法+贪心法':
|
||||
cmd = 'python -u -m Palette.examples.charge_multi_split_wildfire_greedy -c ' + self.map + self.render + '--cover-ratio ' + self.cover_ratio+' -n '+str(self.ships_num)+' -a '+self.axis+' -b '+self.lineEdit_bettery.text()
|
||||
result = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||
self.label_show.setText(str(result.read(), encoding="utf-8"))
|
||||
|
||||
elif self.ships_num == '1':
|
||||
self.label_show.setText('请设置多移动节点')
|
||||
|
||||
|
||||
def run(self):
|
||||
self.cover_ratio = str(float(self.lineEdit_coverr.text()) / 100.0)
|
||||
self.ships_num = self.lineEdit_shipn.text()
|
||||
self.axis = self.comboBox_axis.currentText()
|
||||
if self.comboBox_map.currentText() == '地图0':
|
||||
self.map = 'map0'
|
||||
elif self.comboBox_map.currentText() == '地图1':
|
||||
self.map = 'map1'
|
||||
elif self.comboBox_map.currentText() == '地图2':
|
||||
self.map = 'map2'
|
||||
elif self.comboBox_map.currentText() == '自定义地图':
|
||||
if self.comboBox_around.currentText() == '不考虑':
|
||||
self.map = 'map_actual_show'
|
||||
elif self.comboBox_around.currentText() == '考虑':
|
||||
self.map = 'map_actual_with_around_show'
|
||||
|
||||
if self.comboBox_render.currentText() == '是':
|
||||
self.render = ' --render '
|
||||
elif self.comboBox_render.currentText() == '否':
|
||||
self.render = ' '
|
||||
|
||||
threading.Thread(target=self.thread_run).start()
|
||||
self.label_show.setText('程序正在运行,请稍后!')
|
||||
|
||||
def stop(self):
|
||||
print('2')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
window = mywindow()
|
||||
# window.showMaximized()
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
Loading…
Reference in New Issue