|
|
@ -2,20 +2,23 @@ from enum import Enum |
|
|
|
from functools import partial |
|
|
|
from functools import partial |
|
|
|
import os |
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from PyQt5 import uic |
|
|
|
from PyQt5.QtCore import Qt |
|
|
|
from PyQt5.QtCore import Qt |
|
|
|
from PyQt5.QtGui import QCursor |
|
|
|
from PyQt5.QtGui import QCursor |
|
|
|
from PyQt5 import QtWidgets, uic |
|
|
|
from PyQt5.QtWidgets import QFileDialog, QMainWindow |
|
|
|
|
|
|
|
|
|
|
|
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, ogl_keypress_handler |
|
|
|
from clusterview.mode_handlers import (MODE_HANDLER_MAP, ogl_keypress_handler, |
|
|
|
|
|
|
|
refresh_point_list) |
|
|
|
from clusterview.opengl_widget import (clear_selection, initialize_gl, |
|
|
|
from clusterview.opengl_widget import (clear_selection, initialize_gl, |
|
|
|
paint_gl, resize_gl, |
|
|
|
paint_gl, resize_gl, |
|
|
|
set_drawing_mode, set_drawing_context) |
|
|
|
set_drawing_mode, set_drawing_context) |
|
|
|
|
|
|
|
from clusterview.point_manager import PointManager |
|
|
|
from clusterview.point_list_widget import item_click_handler |
|
|
|
from clusterview.point_list_widget import item_click_handler |
|
|
|
from clusterview_ui import Ui_MainWindow |
|
|
|
from clusterview_ui import Ui_MainWindow |
|
|
|
|
|
|
|
|
|
|
|
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
class MainWindow(QMainWindow, Ui_MainWindow): |
|
|
|
""" |
|
|
|
""" |
|
|
|
A wrapper class for handling creating a window based |
|
|
|
A wrapper class for handling creating a window based |
|
|
|
on the `clusterview_ui.py` code generated from |
|
|
|
on the `clusterview_ui.py` code generated from |
|
|
@ -68,6 +71,12 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
self.action_move_points.triggered.connect(self.__move_points) |
|
|
|
self.action_move_points.triggered.connect(self.__move_points) |
|
|
|
self.action_solve.triggered.connect(self.__solve_launcher) |
|
|
|
self.action_solve.triggered.connect(self.__solve_launcher) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.action_save_point_configuration.triggered.connect( |
|
|
|
|
|
|
|
self.__save_points_file) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.action_load_point_configuration.triggered.connect( |
|
|
|
|
|
|
|
self.__open_points_file) |
|
|
|
|
|
|
|
|
|
|
|
# Override handler for mouse press so we can draw points based on |
|
|
|
# Override handler for mouse press so we can draw points based on |
|
|
|
# the OpenGL coordinate system inside of the OpenGL Widget. |
|
|
|
# the OpenGL coordinate system inside of the OpenGL Widget. |
|
|
|
self.opengl_widget.mousePressEvent = self.__ogl_click_dispatcher |
|
|
|
self.opengl_widget.mousePressEvent = self.__ogl_click_dispatcher |
|
|
@ -128,7 +137,30 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
@mode.setter |
|
|
|
@mode.setter |
|
|
|
def mode(self, mode): |
|
|
|
def mode(self, mode): |
|
|
|
self.__mode = mode |
|
|
|
self.__mode = mode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __open_points_file(self): |
|
|
|
|
|
|
|
ofile, _ = QFileDialog.getOpenFileName(self, |
|
|
|
|
|
|
|
"Open Point Configuration", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"JSON files (*.json)") |
|
|
|
|
|
|
|
if ofile: |
|
|
|
|
|
|
|
set_drawing_mode(Mode.LOADED) |
|
|
|
|
|
|
|
self.__mode = Mode.LOADED |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PointManager.load(ofile) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refresh_point_list(self) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __save_points_file(self): |
|
|
|
|
|
|
|
file_name, _ = QFileDialog.getSaveFileName(self, |
|
|
|
|
|
|
|
"Save Point Configuration", |
|
|
|
|
|
|
|
"", |
|
|
|
|
|
|
|
"JSON Files (*.json)") |
|
|
|
|
|
|
|
if file_name: |
|
|
|
|
|
|
|
PointManager.save(file_name) |
|
|
|
|
|
|
|
|
|
|
|
@handle_exceptions |
|
|
|
@handle_exceptions |
|
|
|
def __solve_launcher(self): |
|
|
|
def __solve_launcher(self): |
|
|
|
""" |
|
|
|
""" |
|
|
@ -147,7 +179,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): |
|
|
|
Mode dispatcher for click actions on the OpenGL widget. |
|
|
|
Mode dispatcher for click actions on the OpenGL widget. |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
if self.__mode is not Mode.OFF: |
|
|
|
if self.__mode not in [Mode.OFF, Mode.LOADED]: |
|
|
|
# Map from Mode -> function |
|
|
|
# Map from Mode -> function |
|
|
|
# where the function is a handler for the |
|
|
|
# where the function is a handler for the |
|
|
|
# OpenGL event. The context passed to these functions allows |
|
|
|
# OpenGL event. The context passed to these functions allows |
|
|
|