Browse Source

Enable resetting of the cluster solver

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
21f706baea
  1. 7
      clusterview.ui
  2. 12
      clusterview/mode_handlers.py
  3. 4
      clusterview_ui.py
  4. 16
      main_window.py

7
clusterview.ui

@ -159,6 +159,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<widget class="QPushButton" name="reset_button">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

12
clusterview/mode_handlers.py

@ -371,6 +371,18 @@ def group(ctx):
ctx.opengl_widget.update() ctx.opengl_widget.update()
def reset_centroid_count_and_colors():
global __centroid_count
global __remaining_colors
__centroid_count = 0
__remaining_colors = [c for c in Color if
c not in [Color.BLUE, Color.GREY]]
for point in PointManager.point_set.points:
point.color = Color.GREY
# Simple dispatcher to make it easy to dispatch the right mode # Simple dispatcher to make it easy to dispatch the right mode
# function when the OpenGL window is acted on. # function when the OpenGL window is acted on.
MODE_HANDLER_MAP = { MODE_HANDLER_MAP = {

4
clusterview_ui.py

@ -86,6 +86,9 @@ class Ui_MainWindow(object):
self.group_button.setEnabled(False) self.group_button.setEnabled(False)
self.group_button.setObjectName("group_button") self.group_button.setObjectName("group_button")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.group_button) self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.group_button)
self.reset_button = QtWidgets.QPushButton(self.groupBox_3)
self.reset_button.setObjectName("reset_button")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.reset_button)
self.verticalLayout.addWidget(self.groupBox_3) self.verticalLayout.addWidget(self.groupBox_3)
spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.verticalLayout.addItem(spacerItem) self.verticalLayout.addItem(spacerItem)
@ -171,6 +174,7 @@ class Ui_MainWindow(object):
self.choose_centroids_button.setText(_translate("MainWindow", "Choose Centroids")) self.choose_centroids_button.setText(_translate("MainWindow", "Choose Centroids"))
self.solve_button.setText(_translate("MainWindow", "Solve")) self.solve_button.setText(_translate("MainWindow", "Solve"))
self.group_button.setText(_translate("MainWindow", "Group")) self.group_button.setText(_translate("MainWindow", "Group"))
self.reset_button.setText(_translate("MainWindow", "Reset"))
self.groupBox_2.setTitle(_translate("MainWindow", "Canvas Information")) self.groupBox_2.setTitle(_translate("MainWindow", "Canvas Information"))
self.label.setText(_translate("MainWindow", "Mouse Position:")) self.label.setText(_translate("MainWindow", "Mouse Position:"))
self.menu_file.setTitle(_translate("MainWindow", "File")) self.menu_file.setTitle(_translate("MainWindow", "File"))

16
main_window.py

@ -9,7 +9,8 @@ from clusterview.colors import Color
from clusterview.mode import Mode from clusterview.mode import Mode
from clusterview.mode_handlers import (group, MODE_HANDLER_MAP, from clusterview.mode_handlers import (group, MODE_HANDLER_MAP,
ogl_keypress_handler, ogl_keypress_handler,
refresh_point_list) refresh_point_list,
reset_centroid_count_and_colors)
from clusterview.opengl_widget import (clear_selection, initialize_gl, from clusterview.opengl_widget import (clear_selection, initialize_gl,
mouse_leave, paint_gl, resize_gl, mouse_leave, paint_gl, resize_gl,
set_drawing_context) set_drawing_context)
@ -67,8 +68,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self)) self))
self.choose_centroids_button.clicked.connect(self.__choose_centroids) self.choose_centroids_button.clicked.connect(self.__choose_centroids)
self.group_button.clicked.connect(self.__group) self.group_button.clicked.connect(self.__group)
self.reset_button.clicked.connect(self.__reset_grouping)
# ----------------------------------------------- # -----------------------------------------------
# OpenGL Graphics Handlers are set # OpenGL Graphics Handlers are set
# here and defined in clusterview.opengl_widget. # here and defined in clusterview.opengl_widget.
@ -159,6 +163,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.__off_mode() self.__off_mode()
self.opengl_widget.update() self.opengl_widget.update()
def __reset_grouping(self):
self.__off_mode()
self.number_of_centroids.setEnabled(True)
self.number_of_centroids.setValue(0)
self.choose_centroids_button.setEnabled(True)
self.solve_button.setEnabled(False)
self.group_button.setEnabled(False)
PointManager.centroids = []
reset_centroid_count_and_colors()
@property @property
def mode(self): def mode(self):
""" """

Loading…
Cancel
Save