|
@@ -1243,13 +1243,10 @@ ImageLabeler::nextImage(int iImageStep)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- list_bounding_box_.clear();
|
|
|
- list_polygon_.clear();
|
|
|
- list_areas_->clear();
|
|
|
- image_holder_->clearAll();
|
|
|
- segmented_image_.clear();
|
|
|
- //clearLabelColorList();
|
|
|
-
|
|
|
+ if (!askForKeepingAnnotations()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (list_images_widget_->count() - iImageStep == image_ID_) {
|
|
|
image_ID_ = 0;
|
|
|
}
|
|
@@ -1297,14 +1294,10 @@ ImageLabeler::prevImage(int iImageStep)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- list_bounding_box_.clear();
|
|
|
- list_polygon_.clear();
|
|
|
- list_areas_->clear();
|
|
|
- image_holder_->clearAll();
|
|
|
- segmented_image_.clear();
|
|
|
- //clearLabelColorList();
|
|
|
+ if (!askForKeepingAnnotations()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
if (image_ID_ < iImageStep) {
|
|
|
image_ID_ = list_images_widget_->count() - 1;
|
|
|
}
|
|
@@ -3129,12 +3122,37 @@ ImageLabeler::askForUnsavedData()
|
|
|
|
|
|
if (QMessageBox::Save == ret)
|
|
|
saveAllInfo();
|
|
|
+ else if (QMessageBox::Discard == ret)
|
|
|
+ return true;
|
|
|
else if (QMessageBox::Cancel == ret)
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+bool
|
|
|
+ImageLabeler::askForKeepingAnnotations()
|
|
|
+{
|
|
|
+ if ((!list_bounding_box_.isEmpty() ||
|
|
|
+ !list_polygon_.isEmpty()) )
|
|
|
+ {
|
|
|
+ QMessageBox msgBox;
|
|
|
+ msgBox.setText(tr("There are some annotations"));
|
|
|
+ msgBox.setInformativeText(tr("Do you want to keep them?"));
|
|
|
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
+ msgBox.setDefaultButton(QMessageBox::Yes);
|
|
|
+ msgBox.setIcon(QMessageBox::Question);
|
|
|
+ int ret = msgBox.exec();
|
|
|
+
|
|
|
+ if (QMessageBox::Yes == ret)
|
|
|
+ return true;
|
|
|
+ else if (QMessageBox::No == ret)
|
|
|
+ clearAllTool();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
//! A slot member setting bbox tool active
|
|
|
/*!
|
|
|
* \param[in] aButtonPressed is a bool flag which is needed for toggled buttons
|
|
@@ -3631,13 +3649,19 @@ ImageLabeler::selectImage(QListWidgetItem *anItem)
|
|
|
return;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
|
- clearAllTool();
|
|
|
- //clearLabelList();
|
|
|
- //clearLabelColorList();
|
|
|
|
|
|
- image_ID_ = list_images_widget_->row(anItem);
|
|
|
+ if (!askForUnsavedData()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!askForKeepingAnnotations()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ image_ID_ = list_images_widget_->row(anItem);
|
|
|
+
|
|
|
+ selectImage(image_ID_);
|
|
|
|
|
|
- selectImage(image_ID_);
|
|
|
}
|
|
|
|
|
|
//! A protected member loading image from list_images_
|