|
|
|
@ -2,7 +2,7 @@ from functools import partial
|
|
|
|
|
|
|
|
|
|
from PyQt5.QtCore import Qt |
|
|
|
|
from PyQt5.QtGui import QCursor |
|
|
|
|
from PyQt5.QtWidgets import QFileDialog, QMainWindow |
|
|
|
|
from PyQt5.QtWidgets import QFileDialog, QInputDialog, QMainWindow |
|
|
|
|
|
|
|
|
|
from clusterview.exceptions import handle_exceptions |
|
|
|
|
from clusterview.colors import Color |
|
|
|
@ -10,10 +10,12 @@ from clusterview.mode import Mode
|
|
|
|
|
from clusterview.mode_handlers import (group, MODE_HANDLER_MAP, |
|
|
|
|
ogl_keypress_handler, |
|
|
|
|
refresh_point_list, |
|
|
|
|
reset_centroid_count_and_colors) |
|
|
|
|
reset_centroid_count_and_colors, |
|
|
|
|
generate_random_points) |
|
|
|
|
from clusterview.opengl_widget import (clear_selection, initialize_gl, |
|
|
|
|
mouse_leave, paint_gl, resize_gl, |
|
|
|
|
set_drawing_context) |
|
|
|
|
from clusterview.points import PointSet |
|
|
|
|
from clusterview.point_manager import PointManager |
|
|
|
|
from clusterview.point_list_widget import item_click_handler |
|
|
|
|
from clusterview_ui import Ui_MainWindow |
|
|
|
@ -34,6 +36,20 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
super(MainWindow, self).__init__(parent) |
|
|
|
|
self.setupUi(self) |
|
|
|
|
|
|
|
|
|
# Size of point for drawing |
|
|
|
|
self.__point_size = 8 |
|
|
|
|
|
|
|
|
|
# TODO: THESE ARE HARD CODED TO THE CURRENT QT WIDGET SIZES |
|
|
|
|
# FIX THIS PROPERLY WITH A RESIZE EVENT DETECT. |
|
|
|
|
# PointManager is a class that is filled with static methods |
|
|
|
|
# designed for managing state. |
|
|
|
|
self.__viewport_width = 833 |
|
|
|
|
self.__viewport_height = 656 |
|
|
|
|
|
|
|
|
|
PointManager.point_set = PointSet(self.__point_size, |
|
|
|
|
self.__viewport_width, |
|
|
|
|
self.__viewport_height) |
|
|
|
|
|
|
|
|
|
# Spin box should only allow the number of centroids to be no |
|
|
|
|
# greater than the number of supported colors minus 2 to exclude |
|
|
|
|
# the color for selection (Color.BLUE) and the default color for points |
|
|
|
@ -90,6 +106,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
self.action_delete_points.triggered.connect(self.__delete_points) |
|
|
|
|
self.action_move_points.triggered.connect(self.__move_points) |
|
|
|
|
|
|
|
|
|
(self.action_generate_random_points |
|
|
|
|
.triggered.connect(self.__generate_random_points)) |
|
|
|
|
|
|
|
|
|
self.action_save_point_configuration.triggered.connect( |
|
|
|
|
self.__save_points_file) |
|
|
|
|
|
|
|
|
@ -173,6 +192,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
PointManager.centroids = [] |
|
|
|
|
reset_centroid_count_and_colors() |
|
|
|
|
|
|
|
|
|
def __generate_random_points(self): |
|
|
|
|
value, ok = QInputDialog.getInt(self, "Number of Points", |
|
|
|
|
"Number of Points:", 30, 30, 3000, 1) |
|
|
|
|
|
|
|
|
|
if ok: |
|
|
|
|
self.__mode = Mode.ADD |
|
|
|
|
generate_random_points(value, |
|
|
|
|
(self.__viewport_width - self.__point_size), |
|
|
|
|
(self.__viewport_height - self.__point_size) |
|
|
|
|
) |
|
|
|
|
self.__mode = Mode.OFF |
|
|
|
|
|
|
|
|
|
self.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
refresh_point_list(self) |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def mode(self): |
|
|
|
|
""" |
|
|
|
|