Skip to content

Commit

Permalink
Point Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kubasaw committed Oct 18, 2019
1 parent 0a855ac commit cd10b6c
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 245 deletions.
3 changes: 2 additions & 1 deletion car/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .motion import motion, track
from .util import *
from .util import *
from .guiConnector import *
69 changes: 69 additions & 0 deletions car/guiConnector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from PyQt5 import QtCore


class tableGuiConnector(QtCore.QAbstractTableModel):
def __init__(self, myTab):
self.__internalTable = myTab
super().__init__()

def rowCount(self, parent):
return len(self.__internalTable)

def columnCount(self, parent):
return int(2)

def data(self, index, role):
if role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()

return self.__internalTable[index.row()][index.column()]

def headerData(self, section, orientation, role):
if role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()

if orientation == QtCore.Qt.Horizontal:
if section == 0:
return "Position"
else:
return "Height"
if orientation == QtCore.Qt.Vertical:
return section

def flags(self,index):
return QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEditable

def setData(self,index,value,role):
if role!=QtCore.Qt.EditRole:
return False
try:
self.__internalTable[index.row()][index.column()]=float(value)
except:
return False
return True

def insertRows(self, row, count=1, parent=QtCore.QModelIndex()):
self.beginInsertRows(parent,row,row+count-1)

for i in range(0,count):
self.__internalTable.insert(row,[0]*2)

self.endInsertRows()

return True

def removeRows(self, row, count=1, parent=QtCore.QModelIndex()):
self.beginRemoveRows(parent,row,row+count-1)

for i in range(row,row+count):
self.__internalTable.pop(i)

self.endRemoveRows()

return True






130 changes: 65 additions & 65 deletions car/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,71 +28,71 @@ class track:
"""

def __init__(self):
self.__verticalProfile = [(0, 9.529),
(50, 9.870),
(100, 10.04),
(150, 10.22),
(155, 10.182),
(200, 9.471),
(250, 8.576),
(255, 8.476),
(280, 7.885),
(300, 7.392),
(315, 7.118),
(345, 6.675),
(350, 6.650),
(375, 6.300),
(400, 6.070),
(415, 5.878),
(450, 5.707),
(455, 5.722),
(500, 5.670),
(540, 5.572),
(550, 5.570),
(590, 5.627),
(600, 5.626),
(625, 5.651),
(650, 5.658),
(655, 5.603),
(680, 5.953),
(700, 6.130),
(750, 6.070),
(785, 6.026),
(800, 5.818),
(813, 5.755),
(836, 5.577),
(850, 5.509),
(870, 5.494),
(900, 5.282),
(930, 5.235),
(950, 5.030),
(975, 4.883),
(1000, 4.786),
(1025, 4.647),
(1050, 4.482),
(1100, 4.276),
(1150, 4.038),
(1165, 3.946),
(1200, 3.697),
(1220, 3.539),
(1250, 3.369),
(1270, 3.761),
(1300, 4.975),
(1335, 6.691),
(1350, 7.451),
(1395, 9.695),
(1400, 9.945),
(1450, 12.069),
(1455, 12.17),
(1500, 11.903),
(1505, 11.739),
(1550, 9.721),
(1553, 9.621),
(1580, 9.515),
(1600, 9.508),
(1630, 9.438),
(1650, 9.466),
(1659, 9.529)]
self.__verticalProfile = [[0, 9.529],
[50, 9.870],
[100, 10.04],
[150, 10.22],
[155, 10.182],
[200, 9.471],
[250, 8.576],
[255, 8.476],
[280, 7.885],
[300, 7.392],
[315, 7.118],
[345, 6.675],
[350, 6.650],
[375, 6.300],
[400, 6.070],
[415, 5.878],
[450, 5.707],
[455, 5.722],
[500, 5.670],
[540, 5.572],
[550, 5.570],
[590, 5.627],
[600, 5.626],
[625, 5.651],
[650, 5.658],
[655, 5.603],
[680, 5.953],
[700, 6.130],
[750, 6.070],
[785, 6.026],
[800, 5.818],
[813, 5.755],
[836, 5.577],
[850, 5.509],
[870, 5.494],
[900, 5.282],
[930, 5.235],
[950, 5.030],
[975, 4.883],
[1000, 4.786],
[1025, 4.647],
[1050, 4.482],
[1100, 4.276],
[1150, 4.038],
[1165, 3.946],
[1200, 3.697],
[1220, 3.539],
[1250, 3.369],
[1270, 3.761],
[1300, 4.975],
[1335, 6.691],
[1350, 7.451],
[1395, 9.695],
[1400, 9.945],
[1450, 12.069],
[1455, 12.17],
[1500, 11.903],
[1505, 11.739],
[1550, 9.721],
[1553, 9.621],
[1580, 9.515],
[1600, 9.508],
[1630, 9.438],
[1650, 9.466],
[1659, 9.529]]
self.__trackLength = max(pos[0] for pos in self.__verticalProfile)
self.__interpolantFunction = interp1d([pos[0] for pos in self.__verticalProfile], [
pos[1] for pos in self.__verticalProfile], kind='cubic', bounds_error=True, copy=False, assume_sorted=True)
Expand Down
121 changes: 0 additions & 121 deletions gui/about.ui

This file was deleted.

34 changes: 16 additions & 18 deletions gui/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ def setupUi(self, MainWindow):
self.tabWidget.addTab(self.Car, "")
self.Track = QtWidgets.QWidget()
self.Track.setObjectName("Track")
self.trackVerticalProfileField = QtWidgets.QPlainTextEdit(self.Track)
self.trackVerticalProfileField.setGeometry(QtCore.QRect(10, 30, 261, 281))
self.trackVerticalProfileField.setObjectName("trackVerticalProfileField")
self.trackVerticalProfileLabel = QtWidgets.QLabel(self.Track)
self.trackVerticalProfileLabel.setGeometry(QtCore.QRect(10, 10, 251, 16))
self.trackVerticalProfileLabel.setGeometry(QtCore.QRect(10, 10, 121, 16))
self.trackVerticalProfileLabel.setObjectName("trackVerticalProfileLabel")
self.trackVerticalProfileTab = QtWidgets.QTableWidget(self.Track)
self.trackVerticalProfileTab.setGeometry(QtCore.QRect(280, 30, 371, 281))
self.trackVerticalProfileTab = QtWidgets.QTableView(self.Track)
self.trackVerticalProfileTab.setGeometry(QtCore.QRect(10, 30, 231, 281))
self.trackVerticalProfileTab.setFocusPolicy(QtCore.Qt.WheelFocus)
self.trackVerticalProfileTab.setAlternatingRowColors(True)
self.trackVerticalProfileTab.setSortingEnabled(True)
self.trackVerticalProfileTab.setObjectName("trackVerticalProfileTab")
self.trackVerticalProfileTab.setColumnCount(2)
self.trackVerticalProfileTab.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.trackVerticalProfileTab.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.trackVerticalProfileTab.setHorizontalHeaderItem(1, item)
self.rowInsertButton = QtWidgets.QPushButton(self.Track)
self.rowInsertButton.setGeometry(QtCore.QRect(250, 30, 75, 23))
self.rowInsertButton.setObjectName("rowInsertButton")
self.rowDeleteButton = QtWidgets.QPushButton(self.Track)
self.rowDeleteButton.setGeometry(QtCore.QRect(250, 60, 75, 23))
self.rowDeleteButton.setObjectName("rowDeleteButton")
self.tabWidget.addTab(self.Track, "")
MainWindow.setCentralWidget(self.centralwidget)
self.menuBar = QtWidgets.QMenuBar(MainWindow)
Expand Down Expand Up @@ -123,7 +123,7 @@ def setupUi(self, MainWindow):
self.menuBar.addAction(self.menuAbout.menuAction())

self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
self.tabWidget.setCurrentIndex(2)
self.actionClose.triggered.connect(MainWindow.close)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

Expand All @@ -138,11 +138,9 @@ def retranslateUi(self, MainWindow):
self.engineLabel.setText(_translate("MainWindow", "Engine"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Simulation), _translate("MainWindow", "Simulation"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Car), _translate("MainWindow", "Car"))
self.trackVerticalProfileLabel.setText(_translate("MainWindow", "Track Profile (Python format)+table view"))
item = self.trackVerticalProfileTab.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Position [m]"))
item = self.trackVerticalProfileTab.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Height [m a.s.l.]"))
self.trackVerticalProfileLabel.setText(_translate("MainWindow", "Track Profile (table view)"))
self.rowInsertButton.setText(_translate("MainWindow", "Add point"))
self.rowDeleteButton.setText(_translate("MainWindow", "Remove point"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Track), _translate("MainWindow", "Track"))
self.menuMain.setTitle(_translate("MainWindow", "Main"))
self.menuAbout.setTitle(_translate("MainWindow", "About"))
Expand Down
Loading

0 comments on commit cd10b6c

Please sign in to comment.