Browse Source

Config for shape colors (line_color, fill_color, etc)

Kentaro Wada 4 years ago
parent
commit
bac03f075d
4 changed files with 32 additions and 10 deletions
  1. 16 2
      labelme/app.py
  2. 12 2
      labelme/config/default_config.yaml
  3. 4 5
      labelme/shape.py
  4. 0 1
      labelme/widgets/canvas.py

+ 16 - 2
labelme/app.py

@@ -73,6 +73,22 @@ class MainWindow(QtWidgets.QMainWindow):
             config = get_config()
         self._config = config
 
+        # set default shape colors
+        Shape.line_color = QtGui.QColor(*self._config["shape"]["line_color"])
+        Shape.fill_color = QtGui.QColor(*self._config["shape"]["fill_color"])
+        Shape.select_line_color = QtGui.QColor(
+            *self._config["shape"]["select_line_color"]
+        )
+        Shape.select_fill_color = QtGui.QColor(
+            *self._config["shape"]["select_fill_color"]
+        )
+        Shape.vertex_fill_color = QtGui.QColor(
+            *self._config["shape"]["vertex_fill_color"]
+        )
+        Shape.hvertex_fill_color = QtGui.QColor(
+            *self._config["shape"]["hvertex_fill_color"]
+        )
+
         super(MainWindow, self).__init__()
         self.setWindowTitle(__appname__)
 
@@ -1099,8 +1115,6 @@ class MainWindow(QtWidgets.QMainWindow):
             action.setEnabled(True)
 
         rgb = self._get_rgb_by_label(shape.label)
-        if rgb is None:
-            return
 
         r, g, b = rgb
         label_list_item.setText(

+ 12 - 2
labelme/config/default_config.yaml

@@ -14,11 +14,21 @@ file_search: null
 sort_labels: true
 validate_label: null
 
-default_shape_color: null
-shape_color: auto   # null, 'auto', 'manual'
+default_shape_color: [0, 255, 0]
+shape_color: auto  # null, 'auto', 'manual'
 shift_auto_shape_color: 0
 label_colors: null
 
+shape:
+  # drawing
+  line_color: [0, 255, 0, 128]
+  fill_color: [0, 255, 0, 64]
+  vertex_fill_color: [0, 255, 0, 255]
+  # selecting / hovering
+  select_line_color: [255, 255, 255, 255]
+  select_fill_color: [0, 255, 0, 155]
+  hvertex_fill_color: [255, 255, 255, 255]
+
 # main
 flag_dock:
   show: true

+ 4 - 5
labelme/shape.py

@@ -11,12 +11,11 @@ import labelme.utils
 # - [opt] Store paths instead of creating new ones at each paint.
 
 
-R, G, B = SHAPE_COLOR = 0, 255, 0  # green
-DEFAULT_LINE_COLOR = QtGui.QColor(R, G, B, 128)  # bf hovering
-DEFAULT_FILL_COLOR = QtGui.QColor(R, G, B, 128)  # hovering
+DEFAULT_LINE_COLOR = QtGui.QColor(0, 255, 0, 128)  # bf hovering
+DEFAULT_FILL_COLOR = QtGui.QColor(0, 255, 0, 128)  # hovering
 DEFAULT_SELECT_LINE_COLOR = QtGui.QColor(255, 255, 255)  # selected
-DEFAULT_SELECT_FILL_COLOR = QtGui.QColor(R, G, B, 155)  # selected
-DEFAULT_VERTEX_FILL_COLOR = QtGui.QColor(R, G, B, 255)  # hovering
+DEFAULT_SELECT_FILL_COLOR = QtGui.QColor(0, 255, 0, 155)  # selected
+DEFAULT_VERTEX_FILL_COLOR = QtGui.QColor(0, 255, 0, 255)  # hovering
 DEFAULT_HVERTEX_FILL_COLOR = QtGui.QColor(255, 255, 255, 255)  # hovering
 
 

+ 0 - 1
labelme/widgets/canvas.py

@@ -565,7 +565,6 @@ class Canvas(QtWidgets.QWidget):
             drawing_shape = self.current.copy()
             drawing_shape.addPoint(self.line[1])
             drawing_shape.fill = True
-            drawing_shape.fill_color.setAlpha(64)
             drawing_shape.paint(p)
 
         p.end()