Skip to content

Commit

Permalink
fix: do not allow move of bed plane (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjonok authored May 1, 2024
1 parent c36fdcb commit 582ab7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Locale:
WarningPathNotClosed = "When cutting the model, not closed areas were found! Check that the shapes are positioned correctly"

RemoveFirstPlaneError = "First figure cannot be removed"
CannotDropHere = "Figure cannot be dropped here"

def __init__(self, **entries):
self.__dict__.update(entries)
Expand Down Expand Up @@ -295,6 +296,7 @@ def __init__(self, **entries):
M10CutDistance="Дистанция отреза филамента, мм:",
RemoveFirstPlaneError="Первая фигура не может быть убрана",
WarningPathNotClosed="При разрезании модели были обнаружены незамкнутые участки! Проверьте корректность расположения фигур",
CannotDropHere="Фигура не может быть перенесена сюда",
),
}

Expand Down
22 changes: 20 additions & 2 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from src import locales, gui_utils, interactor_style
from src.InteractorAroundActivePlane import InteractionAroundActivePlane
from src.gui_utils import plane_tf, Plane, Cone
from src.gui_utils import plane_tf, Plane, Cone, showErrorDialog
from src.settings import (
sett,
get_color,
Expand Down Expand Up @@ -70,10 +70,28 @@ def __init__(self, parent=None):
self.setDropIndicatorShown(True)
self.setAcceptDrops(True)

def dragMoveEvent(self, event):
def dragEnterEvent(self, e: QtGui.QDragEnterEvent) -> None:
# we cannot start dragging the first row
item = self.selectedItems()[0]
idx = self.indexFromItem(item)
if idx.row() == 0:
e.ignore()
return

return super().dragEnterEvent(e)

def dragMoveEvent(self, event: QtGui.QDragMoveEvent) -> None:
self.itemIsMoving = True
super().dragMoveEvent(event)

def dropEvent(self, event):
# we cannot drop on the first row
if self.indexAt(event.pos()).row() == 0:
showErrorDialog(locales.getLocale().CannotDropHere)
return

super().dropEvent(event)


class MainWindow(QMainWindow):
from src.figure_editor import FigureEditor
Expand Down

0 comments on commit 582ab7e

Please sign in to comment.