This repository was archived by the owner on Nov 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsDialog.py
78 lines (50 loc) · 2.51 KB
/
settingsDialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from PyQt5.QtWidgets import (QComboBox, QDialog, QDialogButtonBox, QFormLayout, QGroupBox, QHBoxLayout,
QSpinBox, QVBoxLayout)
import window
class Dialog(QDialog):
def __init__(self,mainWindow):
super(Dialog, self).__init__()
self.mainWindow = mainWindow
self.algorithmSettings = QGroupBox("Algorithm Settings")
self.dimensionSettings = QGroupBox("Map Dimension Settings")
self.resolutionSettings = QGroupBox("Resolution Settings")
self.topLayout = QFormLayout()
self.algorithmType = QComboBox()
self.algorithmType.addItem('A*')
self.algorithmType.addItem('Dijkstra')
self.algorithmType.setCurrentIndex(self.mainWindow.algorithmType)
self.heuristicType = QComboBox()
self.heuristicType.addItem('Euclidean')
self.heuristicType.addItem('Manhattan')
self.heuristicType.setCurrentIndex(self.mainWindow.mapa.heuristicType)
self.topLayout.addRow("Algorith Type:", self.algorithmType)
self.topLayout.addRow("Heuristic Type:", self.heuristicType)
optionsLayout = QHBoxLayout()
self.widthSpin = QSpinBox()
self.widthSpin.setRange(10,100)
self.widthSpin.setValue(self.mainWindow.mapWidth)
# self.heightSpin = QSpinBox()
# self.heightSpin.setRange(10,100)
# self.heightSpin.setValue(self.mainWindow.mapHeight)
optionsLayout.addWidget(self.widthSpin)
#optionsLayout.addWidget(self.heightSpin)
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
buttonBox.accepted.connect(self.accept)
buttonBox.rejected.connect(self.reject)
self.algorithmSettings.setLayout(self.topLayout)
self.dimensionSettings.setLayout(optionsLayout)
actualLayout = QVBoxLayout()
actualLayout.addWidget(self.algorithmSettings)
actualLayout.addWidget(self.dimensionSettings)
actualLayout.addWidget(buttonBox)
self.setLayout(actualLayout)
self.setWindowTitle("Settings")
def accept(self) -> None:
self.mainWindow.algorithmType = self.algorithmType.currentIndex()
self.mainWindow.mapa.heuristicType = self.heuristicType.currentIndex()
self.mainWindow.mapa.resetH()
if (self.widthSpin.value() != self.mainWindow.mapWidth):
self.mainWindow.mapWidth = self.widthSpin.value()
self.mainWindow.mapHeight = self.widthSpin.value()
self.mainWindow.handleReset()
self.close()