Browse Source

Add point weight to saving and loading.

pull/1/head
Taylor Bockman 5 years ago
parent
commit
79145ba819
  1. 5
      clusterview2/point_manager.py
  2. 8
      clusterview2/points.py
  3. 2
      main_window.py

5
clusterview2/point_manager.py

@ -32,7 +32,7 @@ class PointManager():
# We will need to cast the string representation of color
# back into a Color enum.
PointManager.point_set.add_point(point['x'], point['y'],
Color(point['color']))
Color(point['color'], point['weight']))
@staticmethod
def save(location):
@ -52,7 +52,8 @@ class PointManager():
data['points'].append({
'x': p.x,
'y': p.y,
'color': p.color
'color': p.color,
'weight': p.weight
})
with open(location, 'w') as out_file:

8
clusterview2/points.py

@ -316,7 +316,7 @@ class PointSet:
for p in self._points:
p.unselect()
def add_point(self, x, y, color, attrs=[]):
def add_point(self, x, y, color, weight=1.0, attrs=[]):
"""
Adds a point in screen coordinates and an optional attribute to
the list.
@ -324,6 +324,7 @@ class PointSet:
@param x The x-coordinate.
@param y The y-coordinate.
@param color The color of the point.
@param weight The point weight.
@param attr An optional attribute.
@raises ExceededWindowBoundsError If the point could not be constructed
because it would be outside the
@ -337,8 +338,11 @@ class PointSet:
if not isinstance(color, Color):
raise ValueError("Point color must be a Color enum.")
if not isinstance(weight, float):
raise ValueError("Point weight must be a float.")
point = Point(x, y, color, self._point_size,
self._viewport_width, self._viewport_height)
self._viewport_width, self._viewport_height, weight)
for attr in attrs:
point.add_attribute(attr)

2
main_window.py

@ -176,7 +176,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
clear_selection()
self._mode = Mode.CLUSTERING
self.opengl_widget.setCursor(QCursor(Qt.CursorShape.ArrowCursor))
self.status_bar.showMessage('UNWEIGHTED CLUSTERING')
self.status_bar.showMessage('CLUSTERING')
self.opengl_widget.update()
def _reset(self):

Loading…
Cancel
Save