mirror of
https://github.com/Team4388/autoPlanner2025.git
synced 2026-06-09 00:38:05 -06:00
camelCase
This commit is contained in:
+53
-38
@@ -6,34 +6,34 @@ from PySide6.QtGui import QPixmap, QMouseEvent, QPainter, QPen, QColor, QPainter
|
||||
from PySide6.QtCore import Qt, QPoint, QRect
|
||||
|
||||
class ButtonEditor(QMainWindow):
|
||||
def __init__(self, path_planner):
|
||||
def __init__(self, pathPlanner):
|
||||
super().__init__()
|
||||
self.setWindowTitle("Button Editor")
|
||||
self.path_planner = path_planner
|
||||
self.pathPlanner = pathPlanner
|
||||
|
||||
self.image_label = QLabel(self)
|
||||
self.imageLabel = QLabel(self)
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
image_path = os.path.join(script_dir, "images", "Field.png")
|
||||
self.pixmap = QPixmap(image_path)
|
||||
scriptDir = os.path.dirname(os.path.abspath(__file__))
|
||||
imagePath = os.path.join(scriptDir, "images", "Field.png")
|
||||
self.pixmap = QPixmap(imagePath)
|
||||
|
||||
if self.pixmap.isNull():
|
||||
self.image_label.setText(f"Image not found at: {image_path}")
|
||||
self.imageLabel.setText(f"Image not found at: {imagePath}")
|
||||
else:
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
self.imageLabel.setPixmap(self.pixmap)
|
||||
|
||||
self.path_planner_button = QPushButton("Main Window")
|
||||
self.path_planner_button.clicked.connect(self.show_path_planner)
|
||||
self.button_editor_button = QPushButton("Button Editor")
|
||||
self.button_editor_button.clicked.connect(self.show_button_editor)
|
||||
self.pathPlannerButton = QPushButton("Main Window")
|
||||
self.pathPlannerButton.clicked.connect(self.showPathPlanner)
|
||||
self.buttonEditorButton = QPushButton("Button Editor")
|
||||
self.buttonEditorButton.clicked.connect(self.showButtonEditor)
|
||||
|
||||
button_layout = QHBoxLayout()
|
||||
button_layout.addWidget(self.path_planner_button)
|
||||
button_layout.addWidget(self.button_editor_button)
|
||||
buttonLayout = QHBoxLayout()
|
||||
buttonLayout.addWidget(self.pathPlannerButton)
|
||||
buttonLayout.addWidget(self.buttonEditorButton)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addLayout(button_layout)
|
||||
layout.addWidget(self.image_label)
|
||||
layout.addLayout(buttonLayout)
|
||||
layout.addWidget(self.imageLabel)
|
||||
|
||||
container = QWidget()
|
||||
container.setLayout(layout)
|
||||
@@ -41,30 +41,45 @@ class ButtonEditor(QMainWindow):
|
||||
|
||||
self.resize(self.pixmap.width(), self.pixmap.height() + 60)
|
||||
|
||||
def show_button_editor(self):
|
||||
# Variables
|
||||
self.matchLength = 15
|
||||
self.TPS = 50
|
||||
self.matchTicks = self.matchLength * self.TPS
|
||||
self.displayTickResolution = 4
|
||||
self.displayTicks = round(self.matchTicks / self.displayTickResolution)
|
||||
|
||||
self.keyFrames = []
|
||||
|
||||
def addKeyFrames(self):
|
||||
currentFrame = 0
|
||||
|
||||
for i in range(0, self.displayTicks):
|
||||
self.keyFrames.append(currentFrame)
|
||||
|
||||
def showButtonEditor(self):
|
||||
self.show()
|
||||
self.path_planner.hide()
|
||||
self.pathPlanner.hide()
|
||||
|
||||
def show_path_planner(self):
|
||||
def showPathPlanner(self):
|
||||
self.hide()
|
||||
self.path_planner.show()
|
||||
self.pathPlanner.show()
|
||||
|
||||
def update_scene(self):
|
||||
def updateScene(self):
|
||||
self.pixmap = QPixmap(os.path.join(os.path.dirname(os.path.abspath(__file__)), "images", "Field.png"))
|
||||
painter = QPainter(self.pixmap)
|
||||
|
||||
grey_pen = QPen(QColor(127, 127, 127))
|
||||
grey_pen.setWidth(2)
|
||||
painter.setPen(grey_pen)
|
||||
greyPen = QPen(QColor(127, 127, 127))
|
||||
greyPen.setWidth(2)
|
||||
painter.setPen(greyPen)
|
||||
|
||||
# Draw the Bezier curve segments
|
||||
if self.path_planner.coordinates.size > 0:
|
||||
for i in range(len(self.path_planner.coordinates) - 1):
|
||||
start = QPoint(self.path_planner.coordinates[i][0], self.path_planner.coordinates[i][1])
|
||||
end = QPoint(self.path_planner.coordinates[i + 1][0], self.path_planner.coordinates[i + 1][1])
|
||||
if self.pathPlanner.coordinates.size > 0:
|
||||
for i in range(len(self.pathPlanner.coordinates) - 1):
|
||||
start = QPoint(self.pathPlanner.coordinates[i][0], self.pathPlanner.coordinates[i][1])
|
||||
end = QPoint(self.pathPlanner.coordinates[i + 1][0], self.pathPlanner.coordinates[i + 1][1])
|
||||
|
||||
if i < len(self.path_planner.control_points):
|
||||
control_pair = self.path_planner.control_points[i]
|
||||
if i < len(self.pathPlanner.controlPoints):
|
||||
controlPair = self.pathPlanner.controlPoints[i]
|
||||
|
||||
pen = QPen(Qt.yellow)
|
||||
pen.setWidth(2)
|
||||
@@ -72,7 +87,7 @@ class ButtonEditor(QMainWindow):
|
||||
|
||||
path = QPainterPath()
|
||||
path.moveTo(start)
|
||||
path.cubicTo(control_pair[0], control_pair[1], end)
|
||||
path.cubicTo(controlPair[0], controlPair[1], end)
|
||||
painter.drawPath(path)
|
||||
|
||||
# Draw the nodes
|
||||
@@ -84,11 +99,11 @@ class ButtonEditor(QMainWindow):
|
||||
painter.setPen(Qt.NoPen)
|
||||
painter.setBrush(Qt.white)
|
||||
|
||||
for i, (x, y) in enumerate(self.path_planner.coordinates):
|
||||
node_rect = QRect(x - self.path_planner.node_size // 6, y - self.path_planner.node_size // 6,
|
||||
self.path_planner.node_size // 3, self.path_planner.node_size // 3)
|
||||
painter.drawEllipse(node_rect)
|
||||
painter.drawText(node_rect, Qt.AlignCenter, str(i + 1))
|
||||
for i, (x, y) in enumerate(self.pathPlanner.coordinates):
|
||||
nodeRect = QRect(x - self.pathPlanner.nodeSize // 6, y - self.pathPlanner.nodeSize // 6,
|
||||
self.pathPlanner.nodeSize // 3, self.pathPlanner.nodeSize // 3)
|
||||
painter.drawEllipse(nodeRect)
|
||||
painter.drawText(nodeRect, Qt.AlignCenter, str(i + 1))
|
||||
|
||||
painter.end()
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
self.imageLabel.setPixmap(self.pixmap)
|
||||
|
||||
Reference in New Issue
Block a user