Browse Source

-fixed few bugs and made several cosmetic changes

gapchich 13 years ago
parent
commit
ac62ee6068
6 changed files with 408 additions and 159 deletions
  1. 2 1
      ImageHolder.cpp
  2. 362 139
      ImageLabeler.cpp
  3. 22 16
      ImageLabeler.h
  4. 20 3
      OptionsForm.cpp
  5. 1 0
      OptionsForm.h
  6. 1 0
      main.cpp

+ 2 - 1
ImageHolder.cpp

@@ -738,7 +738,8 @@ ImageHolder::mouseMoveEvent(QMouseEvent *anEvent)
 	if (-1 != hovered_point_.figureID &&
 		!list_polygon_->isEmpty() &&
 		PolyFigure == hovered_point_.figure &&
-		(anEvent->buttons() & Qt::LeftButton))
+		(anEvent->buttons() & Qt::LeftButton) &&
+		hovered_point_.figureID == focused_selection_)
 	{
 		Polygon *poly = list_polygon_->at(hovered_point_.figureID);
 		poly->poly.setPoint(hovered_point_.pointID, pos);

File diff suppressed because it is too large
+ 362 - 139
ImageLabeler.cpp


+ 22 - 16
ImageLabeler.h

@@ -82,6 +82,18 @@ protected:
 		QString *aString,
 		int *oldID
 		);
+	void addBBoxArea(
+		int anID,
+		BoundingBox aBBox,
+		int itemID = -1
+		);
+	void addPolyArea(
+		int aPolyID,
+		Polygon aPoly,
+		int itemID = -1
+		);
+	bool deleteArea(QListWidgetItem *anItem);
+	bool toggleLabelPriority(QListWidgetItem *anItem);
 	void enableTools();
 	void disableTools();
 	void legendToXml(QDomDocument *aDoc, QDomElement *aRoot);
@@ -103,24 +115,15 @@ public slots:
 		bool isMain,
 		QString aLabel
 	);
+	void editLabel(QListWidgetItem *anItem);
 	void removeLabel();
+	void removeLabel(int aLabelID);
 	void setLabelID(QListWidgetItem *anItem);
-	void addBBoxArea(
-		int anID,
-		BoundingBox aBBox,
-		int itemID = -1
-		);
-	void addPolyArea(
-		int aPolyID,
-		Polygon aPoly,
-		int itemID = -1
-		);
-	void deleteArea();
-	void editArea();
 	void toggleLabelPriority();
-	void nextImage();
-	void prevImage();
-	void editLabel(QListWidgetItem *anItem);
+
+	void editArea();
+	void deleteArea();
+
 	void saveAllInfo();
 	void saveSegmentedPicture();
 	void saveLegend();
@@ -130,6 +133,8 @@ public slots:
 	void loadPascalFile();
 	void loadPascalPolys();
 	void loadLegendFromFile();
+	void nextImage();
+	void prevImage();
 	void setBoundingBoxTool(bool aButtonPressed);
 	void setPolygonTool(bool aButtonPressed);
 	void generateColors();
@@ -156,6 +161,7 @@ public slots:
 	void removeImage();
 	void imageListPopupMenu(const QPoint &);
 	void writeSettings();
+	void readSettings();
 
 private:
 	/* menu */
@@ -170,7 +176,7 @@ private:
 	QAction *action_open_image_;
 	QAction *action_open_labeled_image_;
 	QAction *action_load_legend_;
-	QAction *action_save_labels_;
+	QAction *action_save_all_;
 	QAction *action_save_segmented_;
 	QAction *action_save_legend_;
 	QAction *action_quit_;

+ 20 - 3
OptionsForm.cpp

@@ -34,6 +34,7 @@ OptionsForm::OptionsForm(QWidget *aParent)
 	button_set_PASCAL_root_ = new QPushButton(this);
 	button_set_PASCAL_root_->setText(tr("set PASCAL root path"));
 	edit_PASCAL_root_ = new QLineEdit("", this);
+	edit_PASCAL_root_->setMinimumWidth(180);
 	button_ok_ = new QPushButton(this);
 	button_ok_->setText(tr("OK"));
 	button_cancel_ = new QPushButton(this);
@@ -67,8 +68,13 @@ OptionsForm::OptionsForm(QWidget *aParent)
 		this,
 		SLOT(hide())
 		);
+	connect(
+		edit_PASCAL_root_,
+		SIGNAL(editingFinished()),
+		this,
+		SLOT(onPathEditing())
+		);
 
-	adjustSize();
 	move(QApplication::desktop()->screen()->rect().center() - rect().center());
 }
 
@@ -148,15 +154,26 @@ OptionsForm::showOptions()
 	else
 		edit_PASCAL_root_->setText(*PASCALpath_);
 
-	adjustSize();
 	show();
 }
 
+void
+OptionsForm::onPathEditing()
+{
+	QString text = edit_PASCAL_root_->text();
+	QDir dir(text);
+	if (dir.exists())
+		*PASCALpath_ = text;
+	else
+		edit_PASCAL_root_->setText(*PASCALpath_);
+}
+
 void
 OptionsForm::keyPressEvent(QKeyEvent *anEvent)
 {
 	if ((Qt::Key_Enter == anEvent->key() ||
-		Qt::Key_Return == anEvent->key())) {
+		Qt::Key_Return == anEvent->key()) &&
+		!edit_PASCAL_root_->hasFocus()) {
 		setOptions();
 	}
 }

+ 1 - 0
OptionsForm.h

@@ -34,6 +34,7 @@ public slots:
 	void showOptions();
 	void newPascalPath();
 	void setAutoColorGeneration(bool flag);
+	void onPathEditing();
 
 signals:
 	void optionsSet();

+ 1 - 0
main.cpp

@@ -5,6 +5,7 @@
 
 #include "ImageLabeler.h"
 
+/* TODO: make list_areas_ and list_areas_widget_ separately */
 int main(int argc, char *argv[])
 {
 	QApplication app(argc, argv);

Some files were not shown because too many files changed in this diff