瀏覽代碼

Set background label list color to shape color

Experimental, not sure it is such a good idea.
Michael Pitidis 13 年之前
父節點
當前提交
0aa5efd756
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      labelme.py

+ 4 - 5
labelme.py

@@ -33,11 +33,8 @@ __appname__ = 'labelme'
 
 # TODO:
 # - [medium] Zoom should keep the image centered.
-# - [high] Save per-shape colors in label file.
 # - [high] Add recently opened files list in File menu.
 # - [high] Escape should cancel editing mode if no point in canvas.
-# - [medium] Maybe have separate colors for different shapes, and
-#   color the background in the label list accordingly (kostas).
 # - [medium] Add undo button for vertex addition.
 # - [medium,maybe] Support vertex moving.
 # - [low,maybe] Open images with drag & drop.
@@ -346,12 +343,13 @@ class MainWindow(QMainWindow, WindowMixin):
             shape = Shape(label=label)
             for x, y in points:
                 shape.addPoint(QPointF(x, y))
+            s.append(shape)
+            self.addLabel(shape)
             if line_color:
                 shape.line_color = QColor(*line_color)
+                self.items[shape].setBackgroundColor(shape.line_color)
             if fill_color:
                 shape.fill_color = QColor(*fill_color)
-            s.append(shape)
-            self.addLabel(shape)
         self.canvas.loadShapes(s)
 
     def saveLabels(self, filename):
@@ -631,6 +629,7 @@ class MainWindow(QMainWindow, WindowMixin):
                 default=DEFAULT_LINE_COLOR)
         if color:
             self.canvas.selectedShape.line_color = color
+            self.items[self.canvas.selectedShape].setBackgroundColor(color)
             self.canvas.update()
             self.setDirty()