Skip to content
Snippets Groups Projects
Commit 27ba1525 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Start enabling moving operations to inbetween other operations in y-direction

parent 0db47102
No related branches found
No related tags found
1 merge request!220Start enabling moving operations to inbetween other operations in y-direction
Pipeline #90108 passed
...@@ -6,7 +6,7 @@ B-ASIC Scheduler-GUI Graphics Scheduler Event Module. ...@@ -6,7 +6,7 @@ B-ASIC Scheduler-GUI Graphics Scheduler Event Module.
Contains the scheduler_ui SchedulerEvent class containing event filters and Contains the scheduler_ui SchedulerEvent class containing event filters and
handlers for SchedulerItem objects. handlers for SchedulerItem objects.
""" """
import math
from typing import List, Optional, overload from typing import List, Optional, overload
# QGraphics and QPainter imports # QGraphics and QPainter imports
...@@ -195,8 +195,8 @@ class SchedulerEvent: # PyQt5 ...@@ -195,8 +195,8 @@ class SchedulerEvent: # PyQt5
def update_pos(operation_item, dx, dy): def update_pos(operation_item, dx, dy):
pos_x = operation_item.x() + dx pos_x = operation_item.x() + dx
pos_y = operation_item.y() + dy * (OPERATION_GAP + OPERATION_HEIGHT)
if self.is_component_valid_pos(operation_item, pos_x): if self.is_component_valid_pos(operation_item, pos_x):
pos_y = operation_item.y() + dy * (OPERATION_GAP + OPERATION_HEIGHT)
operation_item.setX(pos_x) operation_item.setX(pos_x)
operation_item.setY(pos_y) operation_item.setY(pos_y)
self._current_pos.setX(self._current_pos.x() + dx) self._current_pos.setX(self._current_pos.x() + dx)
...@@ -208,7 +208,7 @@ class SchedulerEvent: # PyQt5 ...@@ -208,7 +208,7 @@ class SchedulerEvent: # PyQt5
delta_x = (item.mapToParent(event.pos()) - self._current_pos).x() delta_x = (item.mapToParent(event.pos()) - self._current_pos).x()
delta_y = (item.mapToParent(event.pos()) - self._current_pos).y() delta_y = (item.mapToParent(event.pos()) - self._current_pos).y()
delta_y_steps = round(delta_y / (OPERATION_GAP + OPERATION_HEIGHT)) delta_y_steps = round(2 * delta_y / (OPERATION_GAP + OPERATION_HEIGHT)) / 2
if delta_x > 0.505: if delta_x > 0.505:
update_pos(item, 1, delta_y_steps) update_pos(item, 1, delta_y_steps)
elif delta_x < -0.505: elif delta_x < -0.505:
...@@ -224,6 +224,7 @@ class SchedulerEvent: # PyQt5 ...@@ -224,6 +224,7 @@ class SchedulerEvent: # PyQt5
allows the item to receive future move, release and double-click events. allows the item to receive future move, release and double-click events.
""" """
item: OperationItem = self.scene().mouseGrabberItem() item: OperationItem = self.scene().mouseGrabberItem()
self._old_op_position = self._schedule._y_locations[item.operation.graph_id]
self._signals.component_selected.emit(item.graph_id) self._signals.component_selected.emit(item.graph_id)
self._current_pos = item.mapToParent(event.pos()) self._current_pos = item.mapToParent(event.pos())
self.set_item_active(item) self.set_item_active(item)
...@@ -242,6 +243,14 @@ class SchedulerEvent: # PyQt5 ...@@ -242,6 +243,14 @@ class SchedulerEvent: # PyQt5
if pos_x > self._schedule.schedule_time: if pos_x > self._schedule.schedule_time:
pos_x = pos_x % self._schedule.schedule_time pos_x = pos_x % self._schedule.schedule_time
redraw = True redraw = True
if self._schedule._y_locations[item.operation.graph_id] % 1:
# TODO: move other operations
self._schedule._y_locations[item.operation.graph_id] = math.ceil(
self._schedule._y_locations[item.operation.graph_id]
)
pos_y = item.y() + (OPERATION_GAP + OPERATION_HEIGHT) / 2
item.setY(pos_y)
redraw = True
if redraw: if redraw:
item.setX(pos_x) item.setX(pos_x)
self._redraw_lines(item) self._redraw_lines(item)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment