Add polygon drawing and click-to-fill tools
Introduce two new drawing modes alongside the existing brush: - Polygon mode: left-click to place vertices connected by lines; right-click removes the last vertex; clicking near the first vertex (red dot) when >= 3 points are placed closes the shape (bold cyan outline). Multiple shapes can coexist as canvas overlays. Cancel Current Poly discards the in-progress polygon; Del Shape removes the last completed shape. - Fill mode: left-click inside any closed polygon to rasterise it onto the mask. Selects the innermost shape containing the click (smallest area via cv2.contourArea). Polygons whose centroid lies inside the target are punched out as holes. Each fill is a single undoable step in the mask history. Also renames the Alpha slider label to Mask Alpha and removes the stale Reload Saved reference from the README. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,16 @@ class Annotator(QMainWindow):
|
||||
for b in [self.btn_prev, btn_next, btn_skip, btn_load_prev_mask]:
|
||||
row1.addWidget(b)
|
||||
|
||||
row_tools = QHBoxLayout()
|
||||
for b in [
|
||||
self.mc.btn_brush,
|
||||
self.mc.btn_polygon,
|
||||
self.mc.btn_fill,
|
||||
self.mc.btn_del_shape,
|
||||
self.mc.btn_cancel_poly,
|
||||
]:
|
||||
row_tools.addWidget(b)
|
||||
|
||||
row2 = QHBoxLayout()
|
||||
for b in [
|
||||
btn_clear,
|
||||
@@ -136,7 +146,7 @@ class Annotator(QMainWindow):
|
||||
row3.addWidget(self.mc.brush_reset)
|
||||
|
||||
row4 = QHBoxLayout()
|
||||
row4.addWidget(QLabel("Alpha"))
|
||||
row4.addWidget(QLabel("Mask Alpha"))
|
||||
row4.addWidget(self.mc.alpha_slider)
|
||||
row4.addWidget(self.mc.alpha_reset)
|
||||
|
||||
@@ -162,6 +172,7 @@ class Annotator(QMainWindow):
|
||||
left = QVBoxLayout()
|
||||
left.addLayout(canvas_row)
|
||||
left.addLayout(row1)
|
||||
left.addLayout(row_tools)
|
||||
left.addLayout(row2)
|
||||
left.addLayout(row3)
|
||||
left.addLayout(row4)
|
||||
|
||||
Reference in New Issue
Block a user