Browse Source

Some UI changes, color count, etc

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
b5cec56229
  1. 117
      clusterview.ui
  2. 4
      clusterview/colors.py
  3. 50
      clusterview_ui.py
  4. 17
      main_window.py

117
clusterview.ui

@ -95,6 +95,74 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Solver</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Centroids</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="number_of_centroids">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>26</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="choose_centroids_button">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Choose Centroids</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="solve_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Solve</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="group_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -116,29 +184,6 @@
<string>Canvas Information</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Mouse Position:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="mouse_position_label">
<property name="sizePolicy">
@ -166,7 +211,30 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Mouse Position:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
@ -226,7 +294,6 @@
<addaction name="action_move_points"/>
<addaction name="action_edit_points"/>
<addaction name="action_delete_points"/>
<addaction name="action_solve"/>
</widget>
<action name="action_add_points">
<property name="text">

4
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

50
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"))

17
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)

Loading…
Cancel
Save