|
|
@ -1,5 +1,6 @@ |
|
|
|
import os |
|
|
|
|
|
|
|
from enum import Enum |
|
|
|
from enum import Enum |
|
|
|
|
|
|
|
from functools import partial |
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
from PyQt5.QtCore import Qt |
|
|
|
from PyQt5.QtCore import Qt |
|
|
|
from PyQt5.QtGui import QCursor |
|
|
|
from PyQt5.QtGui import QCursor |
|
|
@ -7,8 +8,9 @@ from PyQt5 import QtWidgets, uic |
|
|
|
|
|
|
|
|
|
|
|
from clusterview.exceptions import handle_exceptions, InvalidModeError |
|
|
|
from clusterview.exceptions import handle_exceptions, InvalidModeError |
|
|
|
from clusterview.mode import Mode |
|
|
|
from clusterview.mode import Mode |
|
|
|
from clusterview.mode_handlers import MODE_HANDLER_MAP |
|
|
|
from clusterview.mode_handlers import MODE_HANDLER_MAP, ogl_keypress_handler |
|
|
|
from clusterview.opengl_widget import (initialize_gl, paint_gl, resize_gl, |
|
|
|
from clusterview.opengl_widget import (clear_selection, initialize_gl, |
|
|
|
|
|
|
|
paint_gl, resize_gl, |
|
|
|
set_drawing_mode, set_drawing_context) |
|
|
|
set_drawing_mode, set_drawing_context) |
|
|
|
from clusterview_ui import Ui_MainWindow |
|
|
|
from clusterview_ui import Ui_MainWindow |
|
|
|
|
|
|
|
|
|
|
@ -36,6 +38,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
# tracked and fired properly. |
|
|
|
# tracked and fired properly. |
|
|
|
self.opengl_widget.setMouseTracking(True) |
|
|
|
self.opengl_widget.setMouseTracking(True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Enables us to handle key press events (used for checking |
|
|
|
|
|
|
|
# for and handling terminating selections with ESC). |
|
|
|
|
|
|
|
# Here we partially apply the key press handler with self to |
|
|
|
|
|
|
|
# create a new function that only expects the event `keyPressEvent` |
|
|
|
|
|
|
|
# expects. In this way, we've snuck the state of the opengl_widget |
|
|
|
|
|
|
|
# into the function so that we can modify it as we please. |
|
|
|
|
|
|
|
self.opengl_widget.keyPressEvent = partial(ogl_keypress_handler, self) |
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------- |
|
|
|
#----------------------------------------------- |
|
|
|
# OpenGL Graphics Handlers are set |
|
|
|
# OpenGL Graphics Handlers are set |
|
|
|
# here and defined in clusterview.opengl_widget. |
|
|
|
# here and defined in clusterview.opengl_widget. |
|
|
@ -68,24 +78,32 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.CrossCursor)) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.CrossCursor)) |
|
|
|
self.status_bar.showMessage("ADD MODE") |
|
|
|
self.status_bar.showMessage("ADD MODE") |
|
|
|
|
|
|
|
clear_selection() |
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
def __edit_points(self): |
|
|
|
def __edit_points(self): |
|
|
|
self.__mode = Mode.EDIT |
|
|
|
self.__mode = Mode.EDIT |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.CrossCursor)) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.CrossCursor)) |
|
|
|
self.status_bar.showMessage("EDIT MODE") |
|
|
|
self.status_bar.showMessage("EDIT MODE") |
|
|
|
|
|
|
|
clear_selection() |
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
def __delete_points(self): |
|
|
|
def __delete_points(self): |
|
|
|
self.__mode = Mode.DELETE |
|
|
|
self.__mode = Mode.DELETE |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) |
|
|
|
self.status_bar.showMessage("DELETE MODE") |
|
|
|
self.status_bar.showMessage("DELETE MODE") |
|
|
|
|
|
|
|
clear_selection() |
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
def __move_points(self): |
|
|
|
def __move_points(self): |
|
|
|
self.__mode = Mode.MOVE |
|
|
|
self.__mode = Mode.MOVE |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
set_drawing_mode(self.__mode) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.SizeAllCursor)) |
|
|
|
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.SizeAllCursor)) |
|
|
|
self.status_bar.showMessage("MOVE MODE") |
|
|
|
self.status_bar.showMessage("MOVE MODE") |
|
|
|
|
|
|
|
clear_selection() |
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
@handle_exceptions |
|
|
|
@handle_exceptions |
|
|
|
def __solve_launcher(self): |
|
|
|
def __solve_launcher(self): |
|
|
|