Skip to content

Commit

Permalink
fixing issue with cursor for window resizing (#545) and reducing the …
Browse files Browse the repository at this point in the history
…vertical height of the gui
  • Loading branch information
carsen-stringer committed Aug 16, 2022
1 parent d9c9f28 commit 91dd7ab
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 46 deletions.
74 changes: 34 additions & 40 deletions cellpose/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,10 @@ def make_buttons(self):
label.setFont(self.smallfont)
self.l0.addWidget(label, 1,0,1,4)

label = QLabel('[pageup/down]')
label.setStyleSheet(label_style)
label.setFont(self.smallfont)
self.l0.addWidget(label, 1,5,1,5)


b=2
self.view = 0 # 0=image, 1=flowsXY, 2=flowsZ, 3=cellprob
self.color = 0 # 0=RGB, 1=gray, 2=R, 3=G, 4=B
self.RGBChoose = guiparts.RGBRadioButtons(self, b,5)
self.RGBDropDown = QComboBox()
self.RGBDropDown.addItems(["RGB","red=R","green=G","blue=B","gray","spectral"])
self.RGBDropDown.setFont(self.medfont)
Expand All @@ -318,7 +313,14 @@ def make_buttons(self):
label = QLabel('[press R / G / B to \n toggle RGB and color ]')
label.setStyleSheet(label_style)
label.setFont(self.smallfont)
self.l0.addWidget(label, b+1,0,1,4)
self.l0.addWidget(label, b,4,1,4)

label = QLabel('[pageup/down]')
label.setStyleSheet(label_style)
label.setFont(self.smallfont)
self.l0.addWidget(label, b+1,0,1,5)
self.RGBChoose = guiparts.RGBRadioButtons(self, b+2,0)


b+=3

Expand Down Expand Up @@ -387,6 +389,14 @@ def make_buttons(self):
label.setStyleSheet(self.headings)
label.setFont(self.boldfont)
self.l0.addWidget(label, b,0,1,9)

# use GPU
self.useGPU = QCheckBox('use GPU')
self.useGPU.setStyleSheet(self.checkstyle)
self.useGPU.setFont(self.medfont)
self.useGPU.setToolTip('if you have specially installed the <i>cuda</i> version of torch, then you can activate this')
self.check_gpu()
self.l0.addWidget(self.useGPU, b,5,1,4)

b+=1
self.diameter = 30
Expand All @@ -412,26 +422,6 @@ def make_buttons(self):
self.SizeButton.setStyleSheet(self.styleInactive)
self.SizeButton.setFont(self.boldfont)

# scale toggle
b+=1
self.scale_on = True
self.ScaleOn = QCheckBox('scale disk on')
self.ScaleOn.setFont(self.medfont)
self.ScaleOn.setStyleSheet('color: rgb(150,50,150);')
self.ScaleOn.setChecked(True)
self.ScaleOn.setToolTip('see current diameter as red disk at bottom')
self.ScaleOn.toggled.connect(self.toggle_scale)
self.l0.addWidget(self.ScaleOn, b,0,1,5)

# use GPU
#b+=1
self.useGPU = QCheckBox('use GPU')
self.useGPU.setStyleSheet(self.checkstyle)
self.useGPU.setFont(self.medfont)
self.useGPU.setToolTip('if you have specially installed the <i>cuda</i> version of torch, then you can activate this')
self.check_gpu()
self.l0.addWidget(self.useGPU, b,5,1,4)

### fast mode
#self.NetAvg = QComboBox()
#self.NetAvg.addItems(['average 4 nets', 'run 1 net', '+ turn off resample (fast)'])
Expand Down Expand Up @@ -501,7 +491,6 @@ def make_buttons(self):
self.stitch_threshold.setFixedWidth(70)
self.l0.addWidget(self.stitch_threshold, b,5,1,4)


b+=1
self.GB = QGroupBox('model zoo')
self.GB.setStyleSheet("QGroupBox { border: 1px solid white; color:white; padding: 10px 0px;}")
Expand Down Expand Up @@ -571,7 +560,7 @@ def make_buttons(self):

self.CBg.addWidget(self.ModelChoose, 0,0,1,7)

# recompute segmentation
# compute segmentation w/ custom model
self.ModelButton = QPushButton(u'run model')
self.ModelButton.clicked.connect(self.compute_model)
self.CBg.addWidget(self.ModelButton, 0,7,2,2)
Expand All @@ -583,14 +572,13 @@ def make_buttons(self):
b+=1
self.progress = QProgressBar(self)
self.progress.setStyleSheet('color: gray;')
self.l0.addWidget(self.progress, b,0,1,9)
self.l0.addWidget(self.progress, b,0,1,5)

b+=1
self.roi_count = QLabel('0 ROIs')
self.roi_count.setStyleSheet('color: white;')
self.roi_count.setFont(self.boldfont)
self.roi_count.setAlignment(QtCore.Qt.AlignRight)
self.l0.addWidget(self.roi_count, b,0,1,9)
self.l0.addWidget(self.roi_count, b,5,1,3)

b+=1
line = QHLine()
Expand Down Expand Up @@ -686,6 +674,16 @@ def make_buttons(self):
self.zpos.returnPressed.connect(self.update_ztext)
self.zpos.setFixedWidth(60)
self.l0.addWidget(self.zpos, b, 6,1,3)

# scale toggle
self.scale_on = True
self.ScaleOn = QCheckBox('scale disk on')
self.ScaleOn.setFont(self.medfont)
self.ScaleOn.setStyleSheet('color: rgb(150,50,150);')
self.ScaleOn.setChecked(True)
self.ScaleOn.setToolTip('see current diameter as red disk at bottom')
self.ScaleOn.toggled.connect(self.toggle_scale)
self.l0.addWidget(self.ScaleOn, b,0,1,4)

# add scrollbar underneath
self.scroll = QScrollBar(QtCore.Qt.Horizontal)
Expand Down Expand Up @@ -941,6 +939,7 @@ def make_viewbox(self):
border=[100, 100, 100],
invertY=True
)
self.p0.setCursor(QtCore.Qt.CrossCursor)
self.brush_size=3
self.win.addItem(self.p0, 0, 0, rowspan=1, colspan=1)
self.p0.setMenuEnabled(False)
Expand Down Expand Up @@ -1274,14 +1273,9 @@ def plot_clicked(self, event):
def mouse_moved(self, pos):
items = self.win.scene().items(pos)
#for x in items:
# if x==self.p0:
# mousePoint = self.p0.mapSceneToView(pos)
# if self.orthobtn.isChecked():
# self.vLine.setPos(mousePoint.x())
# self.hLine.setPos(mousePoint.y())
#else:
# QtWidgets.QApplication.restoreOverrideCursor()
#QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.DefaultCursor)
# if not x==self.p0:
# QtWidgets.QApplication.restoreOverrideCursor()
# QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.DefaultCursor)


def color_choose(self):
Expand Down
12 changes: 6 additions & 6 deletions cellpose/gui/guiparts.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def __init__(self, parent=None, row=0, col=0):
button.setChecked(True)
self.addButton(button, b)
button.toggled.connect(lambda: self.btnpress(parent))
self.parent.l0.addWidget(button, row+b,col,1,3)
self.parent.l0.addWidget(button, row,col+2*b,1,2)
self.setExclusive(True)
#self.buttons.

Expand Down Expand Up @@ -581,7 +581,7 @@ def mouseDragEvent(self, ev):
return

def hoverEvent(self, ev):
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.CrossCursor)
#QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.CrossCursor)
if self.parent.in_stroke:
if self.parent.in_stroke:
# continue stroke if not at start
Expand Down Expand Up @@ -726,12 +726,12 @@ def __init__(self, parent=None, *args):
self.setStyleSheet(\
"QSlider::handle:horizontal {\
background-color: white;\
border: 1px solid #5c5c5c;\
border-radius: 0px;\
border-color: black;\
border: 1px solid white;\
border-radius: 2px;\
border-color: white;\
height: 8px;\
width: 6px;\
margin: -8px 2; \
margin: 0px 2; \
}")


Expand Down

0 comments on commit 91dd7ab

Please sign in to comment.