diff --git a/clusterview.ui b/clusterview.ui
index 16914ae..e7968b4 100644
--- a/clusterview.ui
+++ b/clusterview.ui
@@ -95,6 +95,74 @@
-
+
+
+ Solver
+
+
+
-
+
+
+ Centroids
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 50
+ 26
+
+
+
+
+ 50
+ 16777215
+
+
+
+
+ -
+
+
+ true
+
+
+ Choose Centroids
+
+
+
+ -
+
+
+ false
+
+
+ Solve
+
+
+
+ -
+
+
+ false
+
+
+ Group
+
+
+
+
+
+
+ -
Qt::Vertical
@@ -116,29 +184,6 @@
Canvas Information
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
- Mouse Position:
-
-
-
-
@@ -166,7 +211,30 @@
20
- 40
+ 20
+
+
+
+
+ -
+
+
+ Mouse Position:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 20
+ 20
@@ -226,7 +294,6 @@
-
diff --git a/clusterview/colors.py b/clusterview/colors.py
index d8adb9c..32f14c8 100644
--- a/clusterview/colors.py
+++ b/clusterview/colors.py
@@ -9,6 +9,10 @@ class Color(str, Enum):
ORANGE = 'ORANGE'
PURPLE = 'PURPLE'
+ @classmethod
+ def count(cls):
+ return len(cls.__members__)
+
# A simple map from Color -> RGBA 4-Tuple
# Note: The color values in the tuple are not RGB, but
diff --git a/clusterview_ui.py b/clusterview_ui.py
index e37b328..b3b4276 100644
--- a/clusterview_ui.py
+++ b/clusterview_ui.py
@@ -57,17 +57,42 @@ class Ui_MainWindow(object):
self.point_list_widget.setObjectName("point_list_widget")
self.gridLayout.addWidget(self.point_list_widget, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.groupBox)
+ self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget)
+ self.groupBox_3.setObjectName("groupBox_3")
+ self.formLayout = QtWidgets.QFormLayout(self.groupBox_3)
+ self.formLayout.setObjectName("formLayout")
+ self.label_2 = QtWidgets.QLabel(self.groupBox_3)
+ self.label_2.setObjectName("label_2")
+ self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_2)
+ self.number_of_centroids = QtWidgets.QSpinBox(self.groupBox_3)
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.number_of_centroids.sizePolicy().hasHeightForWidth())
+ self.number_of_centroids.setSizePolicy(sizePolicy)
+ self.number_of_centroids.setMinimumSize(QtCore.QSize(50, 26))
+ self.number_of_centroids.setMaximumSize(QtCore.QSize(50, 16777215))
+ self.number_of_centroids.setObjectName("number_of_centroids")
+ self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.number_of_centroids)
+ self.choose_centroids_button = QtWidgets.QPushButton(self.groupBox_3)
+ self.choose_centroids_button.setEnabled(True)
+ self.choose_centroids_button.setObjectName("choose_centroids_button")
+ self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.choose_centroids_button)
+ self.solve_button = QtWidgets.QPushButton(self.groupBox_3)
+ self.solve_button.setEnabled(False)
+ self.solve_button.setObjectName("solve_button")
+ self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.solve_button)
+ self.group_button = QtWidgets.QPushButton(self.groupBox_3)
+ self.group_button.setEnabled(False)
+ self.group_button.setObjectName("group_button")
+ self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.group_button)
+ self.verticalLayout.addWidget(self.groupBox_3)
spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.verticalLayout.addItem(spacerItem)
self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_2.setObjectName("groupBox_2")
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2)
self.gridLayout_2.setObjectName("gridLayout_2")
- spacerItem1 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
- self.gridLayout_2.addItem(spacerItem1, 0, 2, 1, 1)
- self.label = QtWidgets.QLabel(self.groupBox_2)
- self.label.setObjectName("label")
- self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.mouse_position_label = QtWidgets.QLabel(self.groupBox_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@@ -78,8 +103,13 @@ class Ui_MainWindow(object):
self.mouse_position_label.setText("")
self.mouse_position_label.setObjectName("mouse_position_label")
self.gridLayout_2.addWidget(self.mouse_position_label, 0, 3, 1, 1)
- spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
- self.gridLayout_2.addItem(spacerItem2, 1, 0, 1, 1)
+ spacerItem1 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
+ self.gridLayout_2.addItem(spacerItem1, 1, 0, 1, 1)
+ self.label = QtWidgets.QLabel(self.groupBox_2)
+ self.label.setObjectName("label")
+ self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
+ spacerItem2 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
+ self.gridLayout_2.addItem(spacerItem2, 0, 2, 1, 1)
self.verticalLayout.addWidget(self.groupBox_2)
self.horizontalLayout.addLayout(self.verticalLayout)
MainWindow.setCentralWidget(self.centralwidget)
@@ -128,7 +158,6 @@ class Ui_MainWindow(object):
self.tool_bar.addAction(self.action_move_points)
self.tool_bar.addAction(self.action_edit_points)
self.tool_bar.addAction(self.action_delete_points)
- self.tool_bar.addAction(self.action_solve)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
@@ -137,6 +166,11 @@ class Ui_MainWindow(object):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "ClusterView"))
self.groupBox.setTitle(_translate("MainWindow", "Point List"))
+ self.groupBox_3.setTitle(_translate("MainWindow", "Solver"))
+ self.label_2.setText(_translate("MainWindow", "Centroids"))
+ self.choose_centroids_button.setText(_translate("MainWindow", "Choose Centroids"))
+ self.solve_button.setText(_translate("MainWindow", "Solve"))
+ self.group_button.setText(_translate("MainWindow", "Group"))
self.groupBox_2.setTitle(_translate("MainWindow", "Canvas Information"))
self.label.setText(_translate("MainWindow", "Mouse Position:"))
self.menu_file.setTitle(_translate("MainWindow", "File"))
diff --git a/main_window.py b/main_window.py
index 7b920d5..6eee515 100644
--- a/main_window.py
+++ b/main_window.py
@@ -1,13 +1,11 @@
-from enum import Enum
from functools import partial
-import os
-from PyQt5 import uic
-from PyQt5.QtCore import QEvent, Qt
+from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import QFileDialog, QMainWindow
-from clusterview.exceptions import handle_exceptions, InvalidModeError
+from clusterview.exceptions import handle_exceptions
+from clusterview.colors import Color
from clusterview.mode import Mode
from clusterview.mode_handlers import (MODE_HANDLER_MAP, ogl_keypress_handler,
refresh_point_list)
@@ -34,6 +32,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
+ # 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
+ # (Color.GREY).
+ self.number_of_centroids.setMinimum(0)
+ self.number_of_centroids.setMaximum(Color.count() - 2)
+
# We only need to set the context in our OpenGL state machine
# wrapper once here since the window is fixed size.
# If we allow resizing of the window, the context must be updated
@@ -44,7 +49,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# Enables mouse tracking on the viewport so mouseMoveEvents are
# tracked and fired properly.
self.opengl_widget.setMouseTracking(True)
-
+
# Enable keyboard input capture on the OpenGL Widget
self.opengl_widget.setFocusPolicy(Qt.StrongFocus)