Explorar el Código

Merge branch 'master' of linode:hci1

Michael Pitidis hace 13 años
padre
commit
c652ec996d
Se han modificado 3 ficheros con 14 adiciones y 4 borrados
  1. 11 1
      canvas.py
  2. 1 1
      labelme.py
  3. 2 2
      shape.py

+ 11 - 1
canvas.py

@@ -358,7 +358,17 @@ class Canvas(QWidget):
         self.shapes = list(shapes)
         self.current = None
         self.repaint()
-
+        
+    def copySelectedShape(self):
+        if self.selectedShape:
+            newShape=self.selectedShape.copy()
+            self.shapes.append(newShape)
+            self.deSelectShape()
+            self.shapes[-1].selected=True
+            self.selectedShape=self.shapes[-1]
+            self.repaint()
+            return self.selectedShape
+    
     def setShapeVisible(self, shape, value):
         self.visible[shape] = value
         self.repaint()

+ 1 - 1
labelme.py

@@ -229,7 +229,7 @@ class MainWindow(QMainWindow, WindowMixin):
         lf.save(filename, shapes, unicode(self.filename), self.imageData)
 
     def copySelectedShape(self):
-        self.addLabel(self.copySelectedShape())
+        self.addLabel(self.canvas.copySelectedShape())
 
     def highlightLabel(self, item):
         if self.highlighted:

+ 2 - 2
shape.py

@@ -89,9 +89,9 @@ class Shape(object):
         self.points = [p + offset for p in self.points]
 
     def copy(self):
-        shape = Shape()
+        shape = Shape("Copy of %s" % self.label )
         shape.points= [p for p in self.points]
-        shape.label = "Copy of %s" % self.label
+        #shape.label = 
         shape.fill = self.fill
         shape.selected = self.selected
         return shape