Przeglądaj źródła

added:keyboard short cut for fast image traversion (Ctrl+KeyUp, Ctrl+KeyDown)

Johannes Ruehle 13 lat temu
rodzic
commit
c41e54a92e
2 zmienionych plików z 38 dodań i 11 usunięć
  1. 18 9
      ImageLabeler.cpp
  2. 20 2
      ImageLabeler.h

+ 18 - 9
ImageLabeler.cpp

@@ -99,7 +99,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
 	action_open_image_ = new QAction(this);
 	action_open_image_->setText(tr("&Load image"));
 	action_open_images_ = new QAction(this);
-	action_open_images_->setText(tr("&Load images(recursively)"));
+	action_open_images_->setText(tr("&Load images (recursively)"));
 	action_open_labeled_image_ = new QAction(this);
 	action_open_labeled_image_->setText(tr("&Load labeled image"));
 	action_load_legend_ = new QAction(this);
@@ -339,7 +339,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
 	button_next_image_ = new QPushButton(central_widget_);
 	button_next_image_->setText("→");
 	button_next_image_->setAutoRepeat(true);
-
+	
 	/*
 	 * layouts part begins
 	 */
@@ -1610,7 +1610,7 @@ ImageLabeler::getImagesFromDir(const QDir &dir)
  * Adds to filename of the current image to the window title
  */
 void
-ImageLabeler::nextImage()
+ImageLabeler::nextImage(int iImageStep)
 {
 	if (list_images_->isEmpty()) {
 		return;
@@ -1629,11 +1629,11 @@ ImageLabeler::nextImage()
 	segmented_image_.clear();
 	//clearLabelColorList();
 	
-	if (list_images_widget_->count() - 1 == image_ID_) {
+	if (list_images_widget_->count() - iImageStep == image_ID_) {
 		image_ID_ = 0;
 	}
 	else {
-		image_ID_ ++;
+		image_ID_ += iImageStep;
 	}
 
 	if (!selectImage(image_ID_)) {
@@ -1668,7 +1668,7 @@ ImageLabeler::nextImage()
  * Adds to filename of the current image to the window title
  */
 void
-ImageLabeler::prevImage()
+ImageLabeler::prevImage(int iImageStep)
 {
 	if (!list_images_widget_->count()) {
 		return;
@@ -1688,11 +1688,11 @@ ImageLabeler::prevImage()
 	//clearLabelColorList();
 
 	
-	if (!image_ID_) {
+	if (image_ID_ < iImageStep) {
 		image_ID_ = list_images_widget_->count() - 1;
 	}
 	else {
-		image_ID_--;
+		image_ID_ -= iImageStep;
 	}
 
 	list_images_widget_->setCurrentRow(image_ID_);
@@ -2138,7 +2138,7 @@ ImageLabeler::loadInfo(QString filename)
 			}
 			/* legend */
 			else if (element.tagName() == "legend") {
-				qDebug() << "legend";
+				//qDebug() << "legend";
 				list_label_->clear();
 				loadLegendFromNode(&element);
 			}
@@ -4116,11 +4116,20 @@ ImageLabeler::keyPressEvent(QKeyEvent *anEvent)
 		Qt::ControlModifier == keyboard_modifier_) {
 		prevImage();
 	}
+	if (Qt::Key_Down == anEvent->key() &&
+		Qt::ControlModifier == keyboard_modifier_) {
+		prevImage(5);
+	}
 
 	if (Qt::Key_Right == anEvent->key() &&
 		Qt::ControlModifier == keyboard_modifier_) {
 		nextImage();
 	}
+	
+	if (Qt::Key_Up == anEvent->key() &&
+		Qt::ControlModifier == keyboard_modifier_) {
+		nextImage(5);
+	}
 
 	if ((Qt::Key_Enter == anEvent->key() ||
 		Qt::Key_Return == anEvent->key()) &&

+ 20 - 2
ImageLabeler.h

@@ -149,8 +149,26 @@ public slots:
 	void loadPascalFile();
 	void loadPascalPolys();
 	void loadLegendFromFile();
-	void nextImage();
-	void prevImage();
+	/*! \brief Presents the next image of the list of images.
+	 * 
+	 * Depending on the step the next image (default) or an arbituary next image is shown. 
+	 * Example: using keyboard short cut Ctrl + LeftKey presents the next (+1) image,
+	 * and keyboard short cut Ctrl + UpKey presents the fifth next (+5) image.
+	 * 
+	 * \param iImageStep incremental step for the next image to show (default is 1)
+	 * 
+	 */
+	void nextImage(int iImageStep = 1);
+	/*! \brief Presents the previous image of the list of images.
+	 * 
+	 * Depending on the step the previous image (default) or an arbituary previous image is shown.
+	 * Example: using keyboard short cut Ctrl + RightKey presents the previous (-1) image,
+	 * and keyboard short cut Ctrl + DownKey presents the fifth previous (-5) image.
+	 * 
+	 * \param iImageStep incremental step for the previous image to show (default is 1)
+	 * 
+	 */
+	void prevImage(int iImageStep = 1);
 	void setBoundingBoxTool(bool aButtonPressed);
 	void setPolygonTool(bool aButtonPressed);
 	void generateColors();