Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changing access place model button #153

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/InteractorAroundActivePlane.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def leftBtnPress(self, obj, event, view=None):
normal = actor.GetTriangleNormal(triangle_id)
actor.RotateByVector(-normal)
view.model_centering()
view.save_current_movement()

def middleBtnPress(self, obj, event):
if event == "MouseWheelForwardEvent":
Expand Down
41 changes: 21 additions & 20 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,12 @@ def keyPressProcessing(self, event):
self.save_project_action.trigger()
return True

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

return False

Expand Down Expand Up @@ -782,7 +781,7 @@ def save_current_movement(self):

movements = [movement for movement in movements if movement[0] <= current_index]

movement = self.stlActor.GetUserTransform()
movement = self.copyTransform(self.stlActor.GetUserTransform())
movements.append((current_index + 1, movement))

max_movements = 100
Expand Down Expand Up @@ -817,6 +816,11 @@ def shift_state(self, cancel=True):

self.stlActor.current_movement_index = current_index

def copyTransform(self, transform):
new_transform = vtk.vtkTransform()
new_transform.SetMatrix(transform.GetMatrix())
return new_transform

def updateTransform(self):
tf = self.stlActor.GetUserTransform()
x, y, z = tf.GetPosition()
Expand Down Expand Up @@ -849,7 +853,9 @@ def load_stl(self, stl_actor):
self.clear_scene()
self.boxWidget = None
self.stlActor = stl_actor
self.stlActor.movements_array = [(0, self.stlActor.GetUserTransform())]
self.stlActor.movements_array = [
(0, self.copyTransform(self.stlActor.GetUserTransform()))
]
self.stlActor.current_movement_index = 0
self.stlActor.addUserTransformUpdateCallback(self.stl_move_panel.update)
# self.actor_interactor_style.setStlActor(self.stlActor)
Expand Down Expand Up @@ -1060,7 +1066,6 @@ def state_nothing(self):
self.hide_checkbox.setChecked(False)
self.bottom_panel.setEnabled(False)
self.stl_move_panel.setEnabled(False)
self.place_button.setEnabled(False)
self.cancel_action.setEnabled(False)
self.return_action.setEnabled(False)
self.state = NothingState
Expand All @@ -1086,7 +1091,6 @@ def state_gcode(self, layers_count):
self.hide_checkbox.setChecked(True)
self.bottom_panel.setEnabled(False)
self.stl_move_panel.setEnabled(False)
self.place_button.setEnabled(False)
self.cancel_action.setEnabled(False)
self.return_action.setEnabled(False)
self.state = GCodeState
Expand All @@ -1111,9 +1115,8 @@ def state_stl(self):
self.hide_checkbox.setChecked(False)
self.bottom_panel.setEnabled(True)
self.stl_move_panel.setEnabled(False)
self.place_button.setEnabled(False)
self.cancel_action.setEnabled(False)
self.return_action.setEnabled(False)
self.cancel_action.setEnabled(True)
self.return_action.setEnabled(True)
self.state = StlState

def state_moving(self):
Expand All @@ -1127,7 +1130,7 @@ def state_moving(self):
self.picture_slider.setEnabled(False)
self.picture_slider.setSliderPosition(0)
self.move_button.setEnabled(True)
self.place_button.setEnabled(True)
self.place_button.setEnabled(False)
self.load_model_button.setEnabled(False)
self.slice3a_button.setEnabled(False)
self.color_model_button.setEnabled(False)
Expand All @@ -1136,7 +1139,6 @@ def state_moving(self):
# self.hide_checkbox.setChecked(False)
self.bottom_panel.setEnabled(False)
self.stl_move_panel.setEnabled(True)
self.place_button.setEnabled(True)
self.cancel_action.setEnabled(True)
self.return_action.setEnabled(True)
self.state = MovingState
Expand All @@ -1153,7 +1155,7 @@ def state_both(self, layers_count):
self.picture_slider.setMaximum(layers_count)
self.picture_slider.setSliderPosition(layers_count)
self.move_button.setEnabled(True)
self.place_button.setEnabled(True)
self.place_button.setEnabled(False)
self.load_model_button.setEnabled(True)
self.slice3a_button.setEnabled(True)
self.color_model_button.setEnabled(True)
Expand All @@ -1162,9 +1164,8 @@ def state_both(self, layers_count):
self.hide_checkbox.setChecked(True)
self.bottom_panel.setEnabled(True)
self.stl_move_panel.setEnabled(False)
self.place_button.setEnabled(False)
self.cancel_action.setEnabled(False)
self.return_action.setEnabled(False)
self.cancel_action.setEnabled(True)
self.return_action.setEnabled(True)
self.state = BothState

def reset_colorize(self):
Expand Down
Loading