Skip to content

Commit 658e372

Browse files
committed
revise ASSIGN tool
1 parent f5cc5e2 commit 658e372

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

source/QtImageViewerPlus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def setTool(self, tool):
811811
#calls the toolMessage method to show the tool message window
812812
self.tools.toolMessage()
813813

814-
if tool in ["FREEHAND", "RULER", "FOURCLICKS", "PLACEANNPOINT"] or (tool in ["CUT", "EDITBORDER", "RITM"] and len(self.selected_blobs) > 1):
814+
if tool in ["FREEHAND", "RULER", "FOURCLICKS", "PLACEANNPOINT", "ASSIGN"] or (tool in ["CUT", "EDITBORDER", "RITM"] and len(self.selected_blobs) > 1):
815815
self.resetSelection()
816816

817817
if tool == "RITM" or tool == "SAMINTERACTIVE" or tool == "WATERSHED":
@@ -978,7 +978,7 @@ def mousePressEvent(self, event):
978978
self.leftMouseButtonPressed.emit(x, y)
979979

980980
if mods & Qt.ShiftModifier and (self.tools.tool == "WATERSHED" or self.tools.tool == "FREEHAND" or self.tools.tool == "EDITBORDER"\
981-
or self.tools.tool == "CUT" or self.tools.tool == "RULER" or self.tools.tool == "SAM" or self.tools.tool == "SAMINTERACTIVE"):
981+
or self.tools.tool == "CUT" or self.tools.tool == "ASSIGN" or self.tools.tool == "RULER" or self.tools.tool == "SAM" or self.tools.tool == "SAMINTERACTIVE"):
982982
self.tools.leftPressed(x, y, mods)
983983

984984
elif self.tools.tool == "SELECTAREA":

source/tools/Assign.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ def __init__(self, viewerplus):
66
self.active_label = None
77

88
message = "<p><i>Assign a class to a region</i></p>"
9-
message += "<p>Choose the class from the Labels panel</p>"
10-
message += "<p>- LMB on a region to assign the class</p>"
9+
message += "<p>Make sure to have chosen a class from the Labels panel</p>"
10+
message += "<p>- SHIFT + LMB on a region to assign the class</p>"
11+
message += ("<p>To assign a class to multiple regions, active the PAN/ZOOM tool, make a<br>"
12+
"selection, and then double-click on a class in the Labels panel.</p>")
1113
self.tool_message = f'<div style="text-align: left;">{message}</div>'
1214

1315

@@ -22,39 +24,29 @@ def leftPressed(self, x, y, mods):
2224
return #do nothing, no label is set
2325

2426
# handle points
25-
26-
select_point = self.viewerplus.annotations.clickedPoint(x, y)
27-
if select_point is not None:
28-
self.viewerplus.addToSelectedPointList(select_point)
29-
for point in self.viewerplus.selected_annpoints:
30-
self.viewerplus.setAnnPointClass(point, self.active_label)
31-
27+
selected_point = self.viewerplus.annotations.clickedPoint(x, y)
28+
if selected_point is not None:
29+
self.viewerplus.setAnnPointClass(selected_point, self.active_label)
3230
return
3331

3432
# handle areas
35-
3633
selected_blob = self.viewerplus.annotations.clickedBlob(x, y)
37-
if selected_blob is None:
38-
return
39-
40-
self.viewerplus.addToSelectedList(selected_blob)
41-
42-
genets = set()
43-
for blob in self.viewerplus.selected_blobs:
44-
if blob.genet is not None \
45-
and blob.genet >= 0:
46-
genets.add(blob.genet)
47-
else:
48-
self.viewerplus.setBlobClass(blob, self.active_label)
49-
50-
project = self.viewerplus.project
51-
for image in project.images:
52-
blobs = [blob for blob in image.annotations.seg_blobs if blob.genet in genets]
53-
for blob in blobs:
54-
self.viewerplus.setBlobClass(blob, self.active_label)
55-
56-
# if image == self.viewerplus2.image //we need to update also the other viewer!!!!
57-
# 2) l'undo ha lo stesso problema, posso aggiungere i blob ma devono essere fatti per ogni immagine.
34+
if selected_blob is not None:
35+
self.viewerplus.setBlobClass(selected_blob, self.active_label)
36+
37+
# genets = set()
38+
# for blob in self.viewerplus.selected_blobs:
39+
# if blob.genet is not None \
40+
# and blob.genet >= 0:
41+
# genets.add(blob.genet)
42+
# else:
43+
# self.viewerplus.setBlobClass(blob, self.active_label)
44+
#
45+
# project = self.viewerplus.project
46+
# for image in project.images:
47+
# blobs = [blob for blob in image.annotations.seg_blobs if blob.genet in genets]
48+
# for blob in blobs:
49+
# self.viewerplus.setBlobClass(blob, self.active_label)
5850

5951
message ="[TOOL][ASSIGN] Blob(s) assigned ({:d}) (CLASS={:s}).".format(len(self.viewerplus.selected_blobs), self.active_label)
6052
self.viewerplus.logfile.info(message)

0 commit comments

Comments
 (0)