mirror of
https://github.com/Team4388/autoPlanner2025.git
synced 2026-06-09 00:38:05 -06:00
Butttttooonns
Nutton editor shows the path now I need to fix it but Im taking a break
This commit is contained in:
+45
-4
@@ -11,7 +11,6 @@ class ButtonEditor(QMainWindow):
|
||||
self.setWindowTitle("Button Editor")
|
||||
self.path_planner = path_planner
|
||||
|
||||
#Set background image to the field
|
||||
self.image_label = QLabel(self)
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -23,7 +22,6 @@ class ButtonEditor(QMainWindow):
|
||||
else:
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
|
||||
#Layout stuff
|
||||
self.path_planner_button = QPushButton("Main Window")
|
||||
self.path_planner_button.clicked.connect(self.show_path_planner)
|
||||
self.button_editor_button = QPushButton("Button Editor")
|
||||
@@ -33,7 +31,6 @@ class ButtonEditor(QMainWindow):
|
||||
button_layout.addWidget(self.path_planner_button)
|
||||
button_layout.addWidget(self.button_editor_button)
|
||||
|
||||
#Layout of the auto planner
|
||||
layout = QVBoxLayout()
|
||||
layout.addLayout(button_layout)
|
||||
layout.addWidget(self.image_label)
|
||||
@@ -50,4 +47,48 @@ class ButtonEditor(QMainWindow):
|
||||
|
||||
def show_path_planner(self):
|
||||
self.hide()
|
||||
self.path_planner.show()
|
||||
self.path_planner.show()
|
||||
|
||||
def update_scene(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)
|
||||
|
||||
# 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 i < len(self.path_planner.control_points):
|
||||
control_pair = self.path_planner.control_points[i]
|
||||
|
||||
pen = QPen(Qt.yellow)
|
||||
pen.setWidth(2)
|
||||
painter.setPen(pen)
|
||||
|
||||
path = QPainterPath()
|
||||
path.moveTo(start)
|
||||
path.cubicTo(control_pair[0], control_pair[1], end)
|
||||
painter.drawPath(path)
|
||||
|
||||
# Draw the nodes
|
||||
painter.setPen(Qt.white)
|
||||
font = painter.font()
|
||||
font.setPointSize(25)
|
||||
painter.setFont(font)
|
||||
|
||||
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 // 2, y - self.path_planner.node_size // 2,
|
||||
self.path_planner.node_size, self.path_planner.node_size)
|
||||
painter.drawEllipse(node_rect)
|
||||
painter.drawText(node_rect, Qt.AlignCenter, str(i + 1))
|
||||
|
||||
painter.end()
|
||||
self.image_label.setPixmap(self.pixmap)
|
||||
|
||||
Reference in New Issue
Block a user