File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,20 +175,22 @@ void ImageCanvas::mouseReleaseEvent(QMouseEvent * e) {
175175 }
176176
177177 if (e->button () == Qt::RightButton) { // selection of label
178- QColor color = _mask.id .pixel (_mouse_pos / _scale);
179- const LabelInfo * label = _ui->id_labels [color.red ()];
180-
181- if (!_watershed.id .isNull () && _ui->checkbox_watershed_mask ->isChecked ()) {
182- QColor color = QColor (_watershed.id .pixel (_mouse_pos / _scale));
183- QMap<int , const LabelInfo*>::const_iterator it = _ui->id_labels .find (color.red ());
184- if (it != _ui->id_labels .end ()) {
185- label = it.value ();
178+ QColor maskColor = _mask.id .pixel (_mouse_pos / _scale);
179+ QColor watershedColor = _watershed.id .pixel (_mouse_pos / _scale);
180+ const LabelInfo * label = _ui->id_labels [maskColor.red ()] != NULL ? _ui->id_labels [maskColor.red ()] : _ui->id_labels [watershedColor.red ()];
181+ if (label != NULL )
182+ {
183+ if (!_watershed.id .isNull () && _ui->checkbox_watershed_mask ->isChecked ()) {
184+ QColor color = QColor (_watershed.id .pixel (_mouse_pos / _scale));
185+ QMap<int , const LabelInfo*>::const_iterator it = _ui->id_labels .find (color.red ());
186+ if (it != _ui->id_labels .end ()) {
187+ label = it.value ();
188+ }
186189 }
190+ if (label->item != NULL )
191+ emit (_ui->list_label ->currentItemChanged (label->item , NULL ));
192+ refresh ();
187193 }
188- if (label->item != NULL )
189- emit (_ui->list_label ->currentItemChanged (label->item , NULL ));
190-
191- refresh ();
192194 }
193195
194196 if (e->button () == Qt::MiddleButton)
You can’t perform that action at this time.
0 commit comments