Browse Source

Add point clearing

master
Taylor Bockman 5 years ago
parent
commit
39f778f32d
  1. 7
      clusterview2.ui
  2. 3
      clusterview2/points.py
  3. 5
      clusterview2_ui.py
  4. 8
      main_window.py

7
clusterview2.ui

@ -314,6 +314,8 @@
<addaction name="action_move_points"/> <addaction name="action_move_points"/>
<addaction name="action_edit_points"/> <addaction name="action_edit_points"/>
<addaction name="action_delete_points"/> <addaction name="action_delete_points"/>
<addaction name="separator"/>
<addaction name="action_clear_canvas"/>
</widget> </widget>
<action name="action_add_points"> <action name="action_add_points">
<property name="text"> <property name="text">
@ -387,6 +389,11 @@
<string>Generate Random Points</string> <string>Generate Random Points</string>
</property> </property>
</action> </action>
<action name="action_clear_canvas">
<property name="text">
<string>Clear Canvas</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

3
clusterview2/points.py

@ -287,6 +287,9 @@ class PointSet:
for point in self._points: for point in self._points:
yield point yield point
def clear_points(self):
self._points = []
@property @property
def point_size(self): def point_size(self):
return self._point_size return self._point_size

5
clusterview2_ui.py

@ -152,6 +152,8 @@ class Ui_MainWindow(object):
self.action_exit.setObjectName("action_exit") self.action_exit.setObjectName("action_exit")
self.action_generate_random_points = QtWidgets.QAction(MainWindow) self.action_generate_random_points = QtWidgets.QAction(MainWindow)
self.action_generate_random_points.setObjectName("action_generate_random_points") self.action_generate_random_points.setObjectName("action_generate_random_points")
self.action_clear_canvas = QtWidgets.QAction(MainWindow)
self.action_clear_canvas.setObjectName("action_clear_canvas")
self.menu_file.addAction(self.action_load_point_configuration) self.menu_file.addAction(self.action_load_point_configuration)
self.menu_file.addAction(self.action_save_point_configuration) self.menu_file.addAction(self.action_save_point_configuration)
self.menu_file.addSeparator() self.menu_file.addSeparator()
@ -163,6 +165,8 @@ class Ui_MainWindow(object):
self.tool_bar.addAction(self.action_move_points) self.tool_bar.addAction(self.action_move_points)
self.tool_bar.addAction(self.action_edit_points) self.tool_bar.addAction(self.action_edit_points)
self.tool_bar.addAction(self.action_delete_points) self.tool_bar.addAction(self.action_delete_points)
self.tool_bar.addSeparator()
self.tool_bar.addAction(self.action_clear_canvas)
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
@ -199,3 +203,4 @@ class Ui_MainWindow(object):
self.action_load_point_configuration.setText(_translate("MainWindow", "Load Point Configuration")) self.action_load_point_configuration.setText(_translate("MainWindow", "Load Point Configuration"))
self.action_exit.setText(_translate("MainWindow", "Exit")) self.action_exit.setText(_translate("MainWindow", "Exit"))
self.action_generate_random_points.setText(_translate("MainWindow", "Generate Random Points")) self.action_generate_random_points.setText(_translate("MainWindow", "Generate Random Points"))
self.action_clear_canvas.setText(_translate("MainWindow", "Clear Canvas"))

8
main_window.py

@ -105,6 +105,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_edit_points.triggered.connect(self._edit_points) self.action_edit_points.triggered.connect(self._edit_points)
self.action_delete_points.triggered.connect(self._delete_points) self.action_delete_points.triggered.connect(self._delete_points)
self.action_move_points.triggered.connect(self._move_points) self.action_move_points.triggered.connect(self._move_points)
self.action_clear_canvas.triggered.connect(self._clear_canvas)
(self.action_generate_random_points (self.action_generate_random_points
.triggered.connect(self._generate_random_points)) .triggered.connect(self._generate_random_points))
@ -167,6 +168,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
clear_selection() clear_selection()
self.opengl_widget.update() self.opengl_widget.update()
def _clear_canvas(self):
PointManager.point_set.clear_points()
refresh_point_list(self)
self.opengl_widget.update()
def _clustering(self): def _clustering(self):
if len(list(PointManager.point_set.points)) == 0: if len(list(PointManager.point_set.points)) == 0:
error_dialog = QErrorMessage() error_dialog = QErrorMessage()
@ -183,7 +189,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def _reset(self): def _reset(self):
self._off_mode() self._off_mode()
self.number_of_clusters.setEnabled(True) self.number_of_clusters.setEnabled(True)
self.number_of_clusters.setValue(0) self.number_of_clusters.setValue(4)
self.clustering_button.setEnabled(False) self.clustering_button.setEnabled(False)
self.clustering_solved = False self.clustering_solved = False
PointManager.clusters = [] PointManager.clusters = []

Loading…
Cancel
Save