Skip to content

Commit 86041d1

Browse files
committed
LabelImages: don't select any annotation after deleting annotation, but keep the old selected label. only select the annotation if the mouse click is very close to the object box, or within it.
1 parent 5dd301f commit 86041d1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

SerialPrograms/Source/ML/Programs/ML_LabelImages.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ void LabelImages::delete_selected_annotation(){
426426
return;
427427
}
428428

429+
std::string old_label = m_annotations[m_selected_obj_idx].label;
429430
m_annotations.erase(m_annotations.begin() + m_selected_obj_idx);
430431

431432
if (m_annotations.size() == 0){ // no more annotations
@@ -434,14 +435,15 @@ void LabelImages::delete_selected_annotation(){
434435
return;
435436
}
436437

437-
if (m_selected_obj_idx >= m_annotations.size()){
438-
m_selected_obj_idx = m_annotations.size() - 1;
439-
} else{
440-
// no change to the currently selected index
441-
}
438+
// if (m_selected_obj_idx >= m_annotations.size()){
439+
// m_selected_obj_idx = m_annotations.size() - 1;
440+
// } else{
441+
// // no change to the currently selected index
442+
// }
442443

443-
std::string cur_label = m_annotations[m_selected_obj_idx].label;
444-
set_selected_label(cur_label);
444+
445+
m_selected_obj_idx = m_annotations.size(); // don't select anything after deleting an object, but keep the old selected label
446+
set_selected_label(old_label);
445447
update_rendered_objects();
446448
}
447449

@@ -466,7 +468,10 @@ void LabelImages::change_annotation_selection_by_mouse(double x, double y){
466468
}
467469
if (d2 < closest_distance){
468470
closest_distance = d2;
469-
m_selected_obj_idx = i;
471+
if (d2 < 500){
472+
m_selected_obj_idx = i; // only select the object if the mouse click is very close to the object box, or within it.
473+
}
474+
470475
}
471476
}
472477

0 commit comments

Comments
 (0)