Skip to content

Commit

Permalink
Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneGit committed May 2, 2024
1 parent b36ed9a commit 42cd80b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ def _connect_signals(self):
self.view.move_button.clicked.connect(self.move_model)
self.view.place_button.clicked.connect(self.place_model)
self.view.cancel_action.clicked.connect(
partial(self.view.cancel_movement, True)
partial(self.view.shift_state, True)
)
self.view.return_action.clicked.connect(
partial(self.view.cancel_movement, False)
partial(self.view.shift_state, False)
)
self.view.load_model_button.clicked.connect(self.open_file)
self.view.slice3a_button.clicked.connect(partial(self.slice_stl, "3axes"))
Expand Down
27 changes: 14 additions & 13 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ def keyPressProcessing(self, event):

if self.move_button.isChecked():
if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_Z:
self.cancel_movement()
self.shift_state()
return True
elif event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_Y:
self.cancel_movement(False)
self.shift_state(False)
return True

return False
Expand Down Expand Up @@ -784,7 +784,9 @@ def save_current_movement(self):
self.stlActor.movements_array = movements
self.stlActor.current_movement_index = len(movements) - 1

def cancel_movement(self, cancel=True):
# We move on to the nearest state of movement of the model.
# If cancel=True, go back. If cancel=False, move forward.
def shift_state(self, cancel=True):
current_index = self.stlActor.current_movement_index
movements = self.stlActor.movements_array

Expand All @@ -793,20 +795,19 @@ def cancel_movement(self, cancel=True):
else:
current_index += 1

if 0 <= current_index < len(movements):
transform = movements[current_index][1]
if (current_index > len(movements) - 1) or (current_index < 0):
return False

self.stlActor.SetUserTransform(transform)
if not self.boxWidget is None:
self.boxWidget.SetTransform(transform)
transform = movements[current_index][1]

self.updateTransform()
self.reload_scene()
self.stlActor.SetUserTransform(transform)
if not self.boxWidget is None:
self.boxWidget.SetTransform(transform)

self.stlActor.current_movement_index = current_index
self.updateTransform()
self.reload_scene()

else:
return False
self.stlActor.current_movement_index = current_index

def updateTransform(self):
tf = self.stlActor.GetUserTransform()
Expand Down

0 comments on commit 42cd80b

Please sign in to comment.