Explorar o código

-add doxygen documentation for ImageLabeler and ImageHolder classes

gapchich %!s(int64=13) %!d(string=hai) anos
pai
achega
fd518e3b1e
Modificáronse 9 ficheiros con 620 adicións e 218 borrados
  1. 114 39
      ImageHolder.cpp
  2. 62 9
      ImageHolder.h
  3. 198 134
      ImageLabeler.cpp
  4. 217 16
      ImageLabeler.h
  5. 8 4
      Makefile
  6. 4 2
      Makefile.Debug
  7. 6 4
      Makefile.Release
  8. 8 7
      OptionsForm.cpp
  9. 3 3
      OptionsForm.h

+ 114 - 39
ImageHolder.cpp

@@ -15,6 +15,7 @@
 #include <qmath.h>
 #include <QDebug>
 
+//! A constructor initializing some variables
 ImageHolder::ImageHolder(QWidget *aParent)
 	: QLabel(aParent)
 {
@@ -41,13 +42,19 @@ ImageHolder::ImageHolder(QWidget *aParent)
 	setScaledContents(true);
 	setMouseTracking(true);
 }
-
+//! An empty destructor
 ImageHolder::~ImageHolder()
 {
-	//list_bounding_box_->clear();
-	//delete list_bounding_box_;
+
 }
 
+//! An event which being automatically called after any change of the widget
+/*!
+ * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
+ * \see drawPolygons(QPainter *aPainter, QPen *aPen)
+ *
+ * It contains drawing of the confirmed and not confirmed selections either.
+ */
 void
 ImageHolder::paintEvent(QPaintEvent *anEvent)
 {
@@ -95,13 +102,17 @@ ImageHolder::paintEvent(QPaintEvent *anEvent)
 	drawPolygons(&painter, &pen);
 }
 
+//! draws only confirmed bounding boxes
+/*!
+ * parameters of bboxes may vary depending on whether bbox is selected or not or
+ * whether it's label is main or not.
+ */
 void
 ImageHolder::drawBoundingBoxes(
 	QPainter *aPainter,
 	QPen *aPen
 )
 {
-	/* FIXME: hardcoded colors */
 	if (0 == list_bounding_box_)
 	{
 		return;
@@ -109,23 +120,27 @@ ImageHolder::drawBoundingBoxes(
 	}
 
 	Qt::PenStyle penStyle;
+	/* default width is hardcoded */
 	int width = 2;
-	/* confirmed boxes */
+	/* drawing all the bboxes */
 	for (int i = 0; i < list_bounding_box_->size(); i++) {
 		penStyle = Qt::SolidLine;
 		int labelID = list_bounding_box_->at(i)->label_ID_;
 
+		/* setting color for the label of current bbox */
 		if (labelID < list_label_color_->count())
 			aPen->setColor(QColor(list_label_color_->at(labelID)));
+		/* in case there is no color for such label */
 		else
 			aPen->setColor(QColor(Qt::white));
 
-		/* checking whether labeled area is of main object or not */
+		/* checking whether labeled area is of main label or not */
 		if (labelID == *main_label_)
 			width = 3;
 		else
 			width = 2;
 
+		/* changing the line style and width if current area is selected(focused) */
 		if (RectFigure == focused_selection_type_ &&
 			focused_selection_ == i) {
 			penStyle = Qt::DotLine;
@@ -149,6 +164,7 @@ ImageHolder::drawBoundingBoxes(
 			aPainter->setPen(circPen);
 			for (int j = 0; j < 4; j++) {
 				QPoint point;
+				/* getting the number of point mouse pointer hovered on */
 				if (!j) {
 					point = rect.topLeft();
 				}
@@ -164,6 +180,7 @@ ImageHolder::drawBoundingBoxes(
 				{
 					point = rect.bottomLeft();
 				}
+				/* if current point is hovered then fill it */
 				if (i == hovered_point_.figureID &&
 					j == hovered_point_.pointID &&
 					RectFigure == hovered_point_.figure) {
@@ -182,11 +199,11 @@ ImageHolder::drawBoundingBoxes(
 		aPainter->setPen(*aPen);
 
 		aPainter->drawRect(rect);
+
 		/* drawing label ids of these boxes */
 		QString labelIDText =
 			QString("%1").arg(labelID);
 
-
 		aPainter->drawText(
 			rect.left() + 5,
 			rect.top() + 5,
@@ -199,13 +216,17 @@ ImageHolder::drawBoundingBoxes(
 
 }
 
+//! draws only confirmed polygons
+/*!
+ * parameters of polygons may vary depending on whether poly is selected or not or
+ * whether it's label is main or not.
+ */
 void
 ImageHolder::drawPolygons(
 	QPainter *aPainter,
 	QPen *aPen
 )
 {
-	/* FIXME: hardcoded colors */
 	if (0 == list_polygon_)
 	{
 		return;
@@ -213,14 +234,17 @@ ImageHolder::drawPolygons(
 	}
 
 	Qt::PenStyle penStyle = Qt::SolidLine;
+	/* default width is hardcoded */
 	int width = 2;
-	/* confirmed polygons */
+	/* drawing all the polygons */
 	for (int i = 0; i < list_polygon_->size(); i++) {
 		penStyle = Qt::SolidLine;
 		int labelID = list_polygon_->at(i)->label_ID_;
 
+		/* setting color for the label of current bbox */
 		if (labelID < list_label_color_->count())
 			aPen->setColor(QColor(list_label_color_->at(labelID)));
+		/* in case there is no color for such label */
 		else
 			aPen->setColor(QColor(Qt::white));
 
@@ -230,6 +254,7 @@ ImageHolder::drawPolygons(
 		else
 			width = 2;
 
+		/* changing the line style and width if current area is selected(focused) */
 		if (PolyFigure == focused_selection_type_ &&
 			focused_selection_ == i) {
 			penStyle = Qt::DotLine;
@@ -241,10 +266,12 @@ ImageHolder::drawPolygons(
 		for (int j = 0; j < poly.size(); j++) {
 			point.setX(poly.at(j).x());
 			point.setY(poly.at(j).y());
+			/* scaling */
 			point *= scale_;
 			poly.remove(j);
 			poly.insert(j, point);
 
+			/* in case if it's focused */
 			if (focused_selection_ == i &&
 				focused_selection_type_ == PolyFigure) {
 				QPen circPen;
@@ -252,6 +279,7 @@ ImageHolder::drawPolygons(
 				circPen.setStyle(Qt::SolidLine);
 				circPen.setColor(aPen->color());
 				aPainter->setPen(circPen);
+				/* filling the point if it is hovered */
 				if (j == hovered_point_.pointID &&
 					i == hovered_point_.figureID &&
 					PolyFigure == hovered_point_.figure) {
@@ -270,7 +298,7 @@ ImageHolder::drawPolygons(
 		aPainter->setPen(*aPen);
 
 		aPainter->drawPolygon(poly);
-		/* drawing label ids of these polys */
+		/* drawing label IDs of these polygons */
 		QString labelIDText =
 			QString("%1").arg(labelID);
 		QRect rect = poly.boundingRect();
@@ -289,6 +317,14 @@ ImageHolder::drawPolygons(
 
 }
 
+//! Changes current state and setting new coordinates for the bbox
+/*!
+ * \see mouseMoveEvent(QMouseEvent *anEvent)
+ * \param[in] aNewPos a second point for the bbox(rect)
+ * \param[in] anOldPos a first point for the bbox
+ * \param[in,out] aNewRect a pointer to the rectangle
+ *  which is being currently changed
+ */
 void
 ImageHolder::triggerBoundBox(
 	const QPoint &aNewPos,
@@ -307,6 +343,14 @@ ImageHolder::triggerBoundBox(
 	repaint_needed_ = 1;
 }
 
+//! \brief Changes current state and adding a new point to the
+//! current not confirmed polygon
+/*!
+ * \see mouseMoveEvent(QMouseEvent *anEvent)
+ * \param[in] aPoint a point going to be added to the polygon
+ * \param[in,out] aNewPoly a pointer to the polygon
+ *  which is being currently changed
+ */
 void
 ImageHolder::triggerPolygon(
 	const QPoint &aPoint,
@@ -318,6 +362,16 @@ ImageHolder::triggerPolygon(
 	repaint_needed_ = 1;
 }
 
+//! \brief Puts focus on some of the selections(selected areas)
+/*!
+ * \param[in] anItem should be a pointer to the item of list_areas_ which
+ * has a string with certain format
+ * \see ImageLabeler::addPoly(Polygon *poly)
+ * \see ImageLabeler::list_areas_
+ * \see focused_selection_
+ * \see focused_selection_type_
+ * Parses the string from anItem and gets the selected object out of it
+ */
 void
 ImageHolder::focusOnArea(QListWidgetItem *anItem)
 {
@@ -357,13 +411,17 @@ ImageHolder::focusOnArea(QListWidgetItem *anItem)
 	update();
 }
 
+//! Changes scale_ variable depending on zoom direction and scale factor
+/*!
+ * \param[in] aDirection an enum indicating the zoom direction
+ * \param[in] scaleFactor a speed of zooming
+ */
 void
 ImageHolder::scaleImage(
 	ZoomDirection aDirection,
 	double scaleFactor
 )
 {
-	//QSize size = pixmap()->size();
 	QSize size = this->size();
 
 	/* zoomin */
@@ -376,24 +434,13 @@ ImageHolder::scaleImage(
 		size /= scaleFactor;
 		scale_ /= scaleFactor;
 	}
-
-//	setScaledContents(true);
 	this->resize(size);
-//	setPixmap(
-//		image_->scaled(
-//			size,
-//			Qt::IgnoreAspectRatio,
-//			Qt::SmoothTransformation
-//			)
-//		);
-//	setScaledContents(false);
-
-
-
-	//resize(scaleFactor * pixmap()->size());
-	//emit imageScaled();
 }
 
+//! Removes the focus on an object
+/*!
+ * \see paintEvent(QPaintEvent *)
+ */
 void
 ImageHolder::clearFocusOnArea()
 {
@@ -401,14 +448,16 @@ ImageHolder::clearFocusOnArea()
 	focused_selection_type_ = NoFigure;
 }
 
+//! Clears the data of hovered_point_
 void
-ImageHolder::clearEdition()
+ImageHolder::clearHoveredPoint()
 {
 	hovered_point_.figure = NoFigure;
 	hovered_point_.figureID = -1;
 	hovered_point_.pointID = -1;
 }
 
+//! Sets current tool
 void
 ImageHolder::setTool(Tool aTool)
 {
@@ -419,15 +468,13 @@ ImageHolder::setTool(Tool aTool)
 	case PolygonTool:
 		tool_ = PolygonTool;
 		break;
-	case TaggingTool:
-		tool_ = TaggingTool;
-		break;
 	default:
 		tool_ = NoTool;
 		break;
 	}
 }
 
+//! Sets a pointer on the ImageLabeler::list_bounding_box_
 void
 ImageHolder::setBoundingBoxList(QList< BoundingBox * > *aBBoxList)
 {
@@ -439,6 +486,7 @@ ImageHolder::setBoundingBoxList(QList< BoundingBox * > *aBBoxList)
 	list_bounding_box_ = aBBoxList;
 }
 
+//! Sets a pointer on the ImageLabeler::list_polygon_
 void
 ImageHolder::setPolygonList(QList< Polygon * > *aPolygonList)
 {
@@ -450,6 +498,7 @@ ImageHolder::setPolygonList(QList< Polygon * > *aPolygonList)
 	list_polygon_ = aPolygonList;
 }
 
+//! Sets a pointer on the ImageLabeler::list_label_color
 void
 ImageHolder::setLabelColorList(QList< uint > *aLabelColorList)
 {
@@ -461,6 +510,7 @@ ImageHolder::setLabelColorList(QList< uint > *aLabelColorList)
 	list_label_color_ = aLabelColorList;
 }
 
+//! Sets a pointer on the ImageLabeler::main_label_
 void
 ImageHolder::setMainLabelNum(int *aNum)
 {
@@ -472,6 +522,7 @@ ImageHolder::setMainLabelNum(int *aNum)
 	main_label_ = aNum;
 }
 
+//! Sets a pointer on the ImageLabeler::image_
 void
 ImageHolder::setImage(QPixmap *anImage)
 {
@@ -483,6 +534,7 @@ ImageHolder::setImage(QPixmap *anImage)
 	image_ = anImage;
 }
 
+//! Clears scale, state, bounding_box_ and polygon_
 void
 ImageHolder::clearAll()
 {
@@ -497,6 +549,7 @@ ImageHolder::clearAll()
 	update();
 }
 
+//! Clears las selection(selected area)
 void
 ImageHolder::clearLast()
 {
@@ -507,8 +560,6 @@ ImageHolder::clearLast()
 	case PolygonTool:
 		polygon_.poly.clear();
 		break;
-	case TaggingTool:
-		break;
 	default:
 		break;
 	}
@@ -518,6 +569,10 @@ ImageHolder::clearLast()
 	update();
 }
 
+//! Moves bounding_box_ or polygon_ to the corresponding list
+/*!
+ * \see ImageLabeler::confirmSelection()
+ */
 void
 ImageHolder::confirmSelection()
 {
@@ -546,29 +601,35 @@ ImageHolder::confirmSelection()
 	update();
 }
 
+//! returns state
 ImageHolder::State
 ImageHolder::state()
 {
 	return state_;
 }
 
+//! returns tool
 ImageHolder::Tool
 ImageHolder::tool()
 {
 	return tool_;
 }
 
+//! returns focused_selection_
 int
 ImageHolder::focusedSelection()
 {
 	return focused_selection_;
 }
+
+//! returns focused_selection_type_
 Figure
 ImageHolder::focusedSelectionType()
 {
 	return focused_selection_type_;
 }
 
+//! removes last added point form the polygon_
 void
 ImageHolder::undo()
 {
@@ -587,6 +648,7 @@ ImageHolder::undo()
 	}
 }
 
+//! Brings back the last removed by undo() point
 void
 ImageHolder::redo()
 {
@@ -605,6 +667,15 @@ ImageHolder::redo()
 	}
 }
 
+//! Checks whether mouse pointer is on some point of any object or not
+/*!
+ * \see hovered_point_
+ * \see drawBoundingBoxes(QPainter *aPainter, QPen *aPen)
+ * \see drawPolygons(QPainter *aPainter, QPen *aPen)
+ *
+ * It simply checks all the points of all objects if mouse
+ * pointer is hovered above any of them
+ */
 void
 ImageHolder::checkForPoints(QPoint *aPos)
 {
@@ -685,15 +756,12 @@ void
 ImageHolder::keyPressEvent(QKeyEvent *anEvent)
 {
 	QLabel::keyPressEvent(anEvent);
-
-	//keyboard_modifier_ = anEvent->modifiers();
-
-	if (repaint_needed_) {
-		update();
-		repaint_needed_ = 0;
-	}
 }
 
+//! Event is automatically called on every mouse move
+/*!
+ * With the help of this event all the mouse movements are being tracked.
+ */
 void
 ImageHolder::mouseMoveEvent(QMouseEvent *anEvent)
 {
@@ -771,6 +839,12 @@ ImageHolder::mouseMoveEvent(QMouseEvent *anEvent)
 	}
 }
 
+//! Event is automatically called on every mouse click
+/*!
+ * Every time mouse was clicked it's position is stored in the prev_cursor_pos_
+ * Depending on current state and selected tool it creates new points or
+ * starts new rects
+ */
 void
 ImageHolder::mousePressEvent(QMouseEvent *anEvent)
 {
@@ -817,6 +891,7 @@ ImageHolder::mousePressEvent(QMouseEvent *anEvent)
 	}
 }
 
+//! Event is automatically called on every mouse release
 void
 ImageHolder::mouseReleaseEvent(QMouseEvent *anEvent)
 {

+ 62 - 9
ImageHolder.h

@@ -1,5 +1,5 @@
-/*
- * ImageHolder.h
+/*!
+ * \file ImageHolder.h
  *
  *  Created on: Oct 5, 2011
  *      Author: Gapchich Vladislav
@@ -10,28 +10,33 @@
 
 #include <QLabel>
 
+//! enum indicating the figure of selection
 enum Figure {
 	NoFigure,
 	RectFigure,
 	PolyFigure
 };
 
+//! structure containing rectangle and it's label ID
 struct BoundingBox {
 	QRect rect;
 	int label_ID_;
 };
 
+//! structure containing list of the polygon points and it's label ID
 struct Polygon {
 	QPolygon poly;
 	int label_ID_;
 };
 
+//! structure indicates hovered point and the object which belongs to this hovered point
 struct HoveredPoint {
-	Figure figure;
-	int figureID;
-	int pointID;
+	Figure figure; /*!< figure of the object which belongs to the hovered point */
+	int figureID; /*!< ID of the object in list_bounding_box_ or list_polygon_ depend on figure */
+	int pointID; /*!< number of the point in an object(rect or poly) */
 };
 
+//! enum indicating the direction of zooming
 enum ZoomDirection {
 	NoZoom,
 	ZoomIn,
@@ -41,6 +46,11 @@ enum ZoomDirection {
 class QListWidgetItem;
 class QPixmap;
 
+//! \brief Widget containing loaded image.
+//! It makes drawing rectangles and polygons on the image possible.
+/* \see paintEvent(QPaintEvent *)
+ * \see ImageLabeler
+ */
 class ImageHolder : public QLabel
 {
 	Q_OBJECT
@@ -74,8 +84,7 @@ public:
 	enum Tool {
 		NoTool,
 		BoundingBoxTool,
-		PolygonTool,
-		TaggingTool
+		PolygonTool
 	};
 
 	enum State {
@@ -105,38 +114,82 @@ public slots:
 	void confirmSelection();
 	void focusOnArea(QListWidgetItem *anItem);
 	void clearFocusOnArea();
-	void clearEdition();
+	void clearHoveredPoint();
 	void undo();
 	void redo();
 
 signals:
 	void selectionStarted();
-	void imageScaled();
 	void areaEdited();
 
 private:
+	//! flag for the internal use
 	bool repaint_needed_;
 
+	//! \brief pointer to the list of ImageLabeler
+	//! \see ImageLabeler::list_bounding_box_
 	QList< BoundingBox * > *list_bounding_box_;
+
+	//! \brief pointer to the list of ImageLabeler
+	//! \see ImageLabeler::list_polygon_
 	QList< Polygon * > *list_polygon_;
+
+	//! \brief pointer to the list of ImageLabeler
+	//! \see ImageLabeler::list_label_color_
 	QList< uint > *list_label_color_;
+
+	//! \brief list of points for the undo\redo methods
+	//! \see undo()
+	//! \see redo()
 	QList< QPoint > list_poly_history_;
+
+	//! \brief pointer to the object of ImageLabeler
+	//! \see ImageLabeler::image_
 	QPixmap *image_;
+
+	//! \brief pointer to the variable of ImageLabeler
+	//! \see ImageLabeler::main_label_
 	int *main_label_;
+
+	//! \brief a structure that keeps not confirmed rectangle selection
+	//! \see paintEvent(QPaintEvent *)
+	//! \see ImageLabeler::confirmSelection()
 	BoundingBox bounding_box_;
+
+	//! \brief a structure that keeps not confirmed polygon selection
+	//! \see paintEvent(QPaintEvent *)
+	//! \see ImageLabeler::confirmSelection()
 	Polygon polygon_;
+
+	//! keeps current keyboard modifier(like ctrl, shift, alt etc)
 	int keyboard_modifier_;
+
+	//! \brief keeps an information about current hovered point
+	//! \see checkForPoints(QPoint *aPos)
 	HoveredPoint hovered_point_;
 
+	//! \brief keeps the position of a mouse when it was clicked
 	QPoint prev_cursor_pos_;
 
+	//! enum indicating tool user applying currently
 	Tool tool_;
+
+	//! enum indicating the current state of image_holder_
 	State state_;
 
+	//! indicates which selection(selected area) is focused at the moment
 	int focused_selection_;
+
+	//! indicates the type of currently selected figure
 	Figure focused_selection_type_;
 
+	//! \brief indicates current scale
+	//! \see scaleImage(ZoomDirection aDirection,double scaleFactor)
 	double scale_;
+
+	//! \brief declares the radius of the selecltable point
+	//! \see drawBoundingBoxes(QPainter *aPainter,QPen *aPen)
+	//! \see drawPolygons(QPainter *aPainter,QPen *aPen)
 	int point_radius_;
 };
 

+ 198 - 134
ImageLabeler.cpp

@@ -1,8 +1,8 @@
-/*
+/*!
  * \file ImageLabeler.cpp
  * \brief implementation of the ImageLabeler class
  *
- * ImageLabeler class is the main widget which contains all GUI elements
+ * Main widget which contains all GUI elements
  * and connect them with each other.
  *
  *  Created on: Oct 4, 2011
@@ -634,24 +634,12 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
 		this,
 		SLOT(setDataFromForm(QString))
 		);
-	connect(
-		image_holder_,
-		SIGNAL(imageScaled()),
-		this,
-		SLOT(onImageScaled())
-		);
 	connect(
 		image_holder_,
 		SIGNAL(areaEdited()),
 		this,
 		SLOT(onAreaEdit())
 		);
-	connect(
-		&options_form_,
-		SIGNAL(optionsSet()),
-		this,
-		SLOT(onOptionsSet())
-		);
 
 	QString settingsPath = aSettingsPath;
 	if (settingsPath.isEmpty())
@@ -670,6 +658,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
 
 	/* the same for options_form_ */
 	options_form_.setPASCALpath(&PASCALpath_);
+	options_form_.setAutoColorGeneration(&auto_color_generation_);
 }
 
 //! A destructor of the ImageLabeler class
@@ -775,6 +764,7 @@ ImageLabeler::~ImageLabeler()
 
 //! A member which reads the settings from file to RAM
 /*!
+ *  \see writeSettings(QSettings *aSettings)
  *	\param[in] aSettings a pointer to the QSettings object
  *	which should be previously created and set to the right
  *	file with settings.
@@ -785,7 +775,7 @@ ImageLabeler::readSettings(QSettings *aSettings)
 	aSettings->beginGroup("/global");
 	auto_color_generation_ =
 		aSettings->value("/auto_label_color_generation", 0).toBool();
-	options_form_.setAutoColorGeneration(auto_color_generation_);
+	options_form_.setAutoColorGeneration(&auto_color_generation_);
 	PASCALpath_ = aSettings->value("/PASCAL_root_path", "").toString();
 	aSettings->endGroup();
 
@@ -804,6 +794,7 @@ ImageLabeler::readSettings()
 
 //! A member which writes settings from RAM to file
 /*!
+ *  \see readSettings(QSettings *aSettings)
  *	\param[in] aSettings a pointer to the QSettings object
  *	which should be previously created and set to the right
  *	file with settings
@@ -829,7 +820,7 @@ ImageLabeler::writeSettings()
 	writeSettings(settings_);
 }
 
-//! A member taking a pointer to the Image struct and adding it to all necessary
+//! \brief A member taking a pointer to the Image struct and adding it to all necessary
 //! containers and widgets
 /*!
  * \param[in] anImage a pointer to the Image struct which should contain path to
@@ -1039,7 +1030,7 @@ ImageLabeler::removeLabel(int aLabelID)
 	unsaved_data_ = 1;
 }
 
-//! a slot Member setting label_ID_ variable according to the selected row
+//! \brief a slot Member setting label_ID_ variable according to the selected row
 //! in the list_label_ widget
 /*!
  *	\param[in] anItem a pointer to the QListWidgetItem object which can be
@@ -1170,9 +1161,11 @@ ImageLabeler::editArea()
 	list_areas_->blockSignals(oldState);
 }
 
-//! A slot member parsing a text of the changed item and tries to edit
+//! \brief A slot member parsing a text of the changed item and tries to edit
 //! the corresponding area
 /*!
+ *  \see polyFromListItemText(QString *aString,int *oldID)
+ *  \see BBoxFromListItemText(QString *aString,int *oldID)
  *	\param[in] anItem a pointer to the QListWidgetItem object which contains
  *	area's changed data
  *
@@ -1187,7 +1180,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
 	int oldID = -1;
 	if (-1 != areaString.indexOf("Poly")) {
 		Polygon *poly = new Polygon;
-		*poly = polyFromString(&areaString, &oldID);
+		*poly = polyFromListItemText(&areaString, &oldID);
 
 		if (-1 < poly->label_ID_ && !poly->poly.isEmpty() &&
 			-1 < oldID) {
@@ -1199,7 +1192,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
 	}
 	else if (-1 != areaString.indexOf("BBox")) {
 		BoundingBox *bbox = new BoundingBox;
-		*bbox = BBoxFromString(&areaString, &oldID);
+		*bbox = BBoxFromListItemText(&areaString, &oldID);
 
 		if (-1 < bbox->label_ID_ && -1 < oldID) {
 			list_bounding_box_.takeAt(oldID);
@@ -1220,7 +1213,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
 	unsaved_data_ = 1;
 }
 
-//! A slot member changing the item in the list_areas_ to meet the changes
+//! \brief A slot member changing the item in the list_areas_ to meet the changes
 //! being made during area editing(where editing means moving the points of
 //! an area)
 /*!
@@ -1266,7 +1259,7 @@ ImageLabeler::onAreaEdit()
 	unsaved_data_ = 1;
 }
 
-//! A slot member deleting selected area in the list_areas_ widget
+//! \brief A slot member deleting selected area in the list_areas_ widget
 //! and all other corresponding containers
 /*!
  * \see deleteArea(QListWidgetItem *anItem)
@@ -1360,7 +1353,7 @@ ImageLabeler::deleteArea(QListWidgetItem *anItem)
 /*!
  * \see toggleLabelPriority(QListWidgetItem *anItem)
  * Slot not just only toggles current label priority but also checks other labels
- * if any of the are also main. If so it just makes them common(not main)
+ * if any of them are also main. If so it just makes them common(not main)
  */
 void
 ImageLabeler::toggleLabelPriority()
@@ -1499,7 +1492,7 @@ ImageLabeler::getImagesFromDir(const QDir &dir)
 	}
 }
 
-//! A slot member changing current image to the next one
+//! \brief A slot member changing current image to the next one
 //! and clearing all the data(except legend)
 /*!
  * Asks about unsaved data if there is any. If current picture was the
@@ -1555,7 +1548,7 @@ ImageLabeler::nextImage()
 	//clearLabelColorList();
 }
 
-//! A slot member changing current image to the previous one
+//! \brief A slot member changing current image to the previous one
 //! and clearing all the data(except legend)
 /*!
  * Asks about unsaved data if there is any. If current picture was the
@@ -2901,7 +2894,6 @@ ImageLabeler::generateColors()
 	}
 
 	int coeff = (0xff / labelCount) * 3;
-	//QList< uint > colors;
 	list_label_colors_.clear();
 	list_label_colors_.append(0);
 	uchar red = 0xff;
@@ -2960,6 +2952,9 @@ ImageLabeler::generateColors()
 //! A protected member creating new boundary box from text data
 /*!
  * \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
+ * \see BBoxFromData(QString *aBBoxData)
+ *
+ * It creates bbox both in the container and in the list widget
  */
 void
 ImageLabeler::addBBoxFromData(
@@ -2979,9 +2974,11 @@ ImageLabeler::addBBoxFromData(
 	addBBoxArea(list_bounding_box_.count() - 1, *bbox);
 }
 
-//!
+//! A protected member parsing string data and returning a BoundingBox from it
 /*!
+ * \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
  *
+ * format is x;y;w;h where w - width and h - height
  */
 BoundingBox
 ImageLabeler::BBoxFromData(
@@ -3039,12 +3036,14 @@ ImageLabeler::BBoxFromData(
 	return bbox;
 }
 
-//!
+//! A protected member getting a BoundaryBox from text of the list_areas_ item
 /*!
+ * \see BBoxFromData(QString *aBBoxData)
  *
+ * Slot gets label ID an points from the string data. BBox ID can not be changed.
  */
 BoundingBox
-ImageLabeler::BBoxFromString(
+ImageLabeler::BBoxFromListItemText(
 	QString *aString,
 	int *oldID
 )
@@ -3068,7 +3067,7 @@ ImageLabeler::BBoxFromString(
 	int bboxID = getNumFromString(aString, "BBox #", ";", &ok);
 	if (!ok || bboxID <= -1) {
 		qDebug() <<
-			"BBoxFromString: bboxID is corrupted";
+			"BBoxFromListItemText: bboxID is corrupted";
 		return bbox;
 		/* NOTREACHED */
 	}
@@ -3102,8 +3101,11 @@ ImageLabeler::BBoxFromString(
 	return bbox;
 }
 
-//!
+//! A protected member adding poly to the list widget and to the list container
 /*!
+ * \see addBBox(BoundingBox *bbox)
+ * \param[in] poly a pointer to the Polygon structure
+ *  containing new poly information
  *
  */
 void
@@ -3119,6 +3121,14 @@ ImageLabeler::addPoly(Polygon *poly)
 
 }
 
+//! A protected member adding bounding box to the list widget
+//! and to the list container
+/*!
+ * \see addPoly(Polygon *poly)
+ * \param[in] bbox a pointer to the BoundingBox structure
+ *  containing new bounding box information
+ *
+ */
 void
 ImageLabeler::addBBox(BoundingBox *bbox)
 {
@@ -3129,12 +3139,14 @@ ImageLabeler::addBBox(BoundingBox *bbox)
 
 	list_bounding_box_.append(bbox);
 	addBBoxArea(list_bounding_box_.count() - 1, *bbox);
-
 }
 
-//!
+//! A protected member creating new polygon from text data
 /*!
+ * \see addPolyArea(int anID, Polygon aPoly, int itemID)
+ * \see polyFromData(QString *aPolyData)
  *
+ * It creates polygon both in the container and in the list widget
  */
 void
 ImageLabeler::addPolyFromData(
@@ -3155,9 +3167,11 @@ ImageLabeler::addPolyFromData(
 	addPolyArea(list_polygon_.count() - 1, *poly);
 }
 
-//!
+//! A protected member parsing string data and returning a Polygon from it
 /*!
+ * \see addPolyArea(int anID, Polygon aPoly, int itemID)
  *
+ * format is x0;y0;x1;y1;...
  */
 Polygon
 ImageLabeler::polyFromData(
@@ -3170,9 +3184,11 @@ ImageLabeler::polyFromData(
 	QString buffer;
 	int startPos = 0;
 	bool ok = 1;
+	/* indicates whether coordinate x or y */
 	bool evenFlag = 0;
 
 	for (int i = 0; i < aPolyData->size(); i++) {
+		/* ";" is a separator */
 		if (';' != aPolyData->at(i))
 			continue;
 
@@ -3198,12 +3214,14 @@ ImageLabeler::polyFromData(
 		startPos = i + 1;
 	}
 
+	/* last coordinate was Xi what means an error */
 	if (evenFlag) {
 		qDebug() <<
 			"polyFromData: "
 			"poly format is corrupted";
 		poly.poly.clear();
 	}
+	/* last converting from string was not successful */
 	else if (!ok) {
 		poly.poly.clear();
 	}
@@ -3211,12 +3229,14 @@ ImageLabeler::polyFromData(
 	return poly;
 }
 
-//!
+//! A protected member getting a Polygon from text of the list_areas_ item
 /*!
+ * \see polyFromData(QString *aPolyData)
  *
+ * Slot gets label ID an points from the string data. Poly ID can not be changed.
  */
 Polygon
-ImageLabeler::polyFromString(
+ImageLabeler::polyFromListItemText(
 	QString *aString,
 	int *oldID
 )
@@ -3240,7 +3260,7 @@ ImageLabeler::polyFromString(
 	int polyID = getNumFromString(aString, "Poly #", ";", &ok);
 	if (!ok || polyID <= -1) {
 		qDebug() <<
-			"polyFromString: poly ID is corrupted";
+			"polyFromListItemText: poly ID is corrupted";
 		return poly;
 		/* NOTREACHED */
 	}
@@ -3274,13 +3294,14 @@ ImageLabeler::polyFromString(
 	return poly;
 }
 
-//!
+//! A protected member only for internal use. Showing a message box with warning
 /*!
- *
+ * \param[in] text a QString object containing message you want
+ *  to deliver to the user
  */
 void
 ImageLabeler::showWarning(
-		const QString text
+		const QString &text
 )
 {
 	if (text.isEmpty()) {
@@ -3294,9 +3315,11 @@ ImageLabeler::showWarning(
 	msgBox.exec();
 }
 
-//!
+//! A protected member only for internal use.
+//! Shows a message box asking about unsaved progress
 /*!
- *
+ * It depends on object containers(list_bounding_box_ and list_polygon_)
+ * and on unsaved_data_ flag which must be true to make this dialog appear
  */
 bool
 ImageLabeler::askForUnsavedData()
@@ -3319,12 +3342,12 @@ ImageLabeler::askForUnsavedData()
 		else if (QMessageBox::Cancel == ret)
 			return true;
 	}
-	return false;
+	return true;
 }
 
-//!
+//! A slot member setting bbox tool active
 /*!
- *
+ * \param[in] aButtonPressed is a bool flag which is needed for toggled buttons
  */
 void
 ImageLabeler::setBoundingBoxTool(bool aButtonPressed)
@@ -3337,9 +3360,9 @@ ImageLabeler::setBoundingBoxTool(bool aButtonPressed)
 	}
 }
 
-//!
+//! A slot member setting polygon tool active
 /*!
- *
+ * \param[in] aButtonPressed is a bool flag which is needed for toggled buttons
  */
 void
 ImageLabeler::setPolygonTool(bool aButtonPressed)
@@ -3354,30 +3377,22 @@ ImageLabeler::setPolygonTool(bool aButtonPressed)
 	}
 }
 
-//!
-/*!
- *
- */
+//! A slot member enables button_confirm_selection_ button
 void
 ImageLabeler::onSelectionStarted()
 {
 	button_confirm_selection_->setEnabled(true);
 }
 
-//!
-/*!
- *
- */
-void
-ImageLabeler::onImageScaled()
-{
-
-}
-
-
-//!
+//! A slot member adding information about new selected area
 /*!
+ * \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
+ * \see addPolyArea(int aPolyID, Polygon aPoly, int itemID)
  *
+ * After user has created a new selection area it should be confirmed or else it
+ * wouldn't be added to the item list and containers. This slot takes all data from
+ * unconfirmed selection and places it into list widget and corresponding container
+ * (list_bounding_box_ or list_polygon_)
  */
 void
 ImageLabeler::confirmSelection()
@@ -3417,9 +3432,12 @@ ImageLabeler::confirmSelection()
 	unsaved_data_ = 1;
 }
 
-//!
+//! \brief A slot member clears all widgets and containers
+//! (not recommended to use without necessity)
 /*!
- *
+ * \see clearAllTool()
+ * \see clearLabelList()
+ * \see clearLabelColorList()
  */
 void
 ImageLabeler::clearAll()
@@ -3437,9 +3455,11 @@ ImageLabeler::clearAll()
 	action_view_segmented_->setEnabled(false);
 }
 
-//!
+//! A slot member clears only selections made by user
 /*!
- *
+ * \see clearAll()
+ * \see clearLabelList()
+ * \see clearLabelColorList()
  */
 void
 ImageLabeler::clearAllTool()
@@ -3451,9 +3471,14 @@ ImageLabeler::clearAllTool()
 	image_holder_->clearAll();
 }
 
-//!
+//! A slot member clears label list
 /*!
+ * \see clearAll()
+ * \see clearAllTool()
+ * \see clearLabelColorList()
  *
+ * As far as BACKGROUND label should always be present slot adds
+ * it after clearing all the label list
  */
 void ImageLabeler::clearLabelList()
 {
@@ -3465,9 +3490,14 @@ void ImageLabeler::clearLabelList()
 		);
 }
 
-//!
+//! A slot member clears the list of label colors
 /*!
+ * \see clearAll()
+ * \see clearAllTool()
+ * \see clearLabelList()
  *
+ * As far as BACKGROUND label should always be present slot adds
+ * it's color(black by default) after clearing all the label color list
  */
 void ImageLabeler::clearLabelColorList()
 {
@@ -3475,9 +3505,13 @@ void ImageLabeler::clearLabelColorList()
 	list_label_colors_.append(0x0);
 }
 
-//!
+//! A slot member enabling all the tools
 /*!
+ * \see disableTools()
  *
+ * By default the initial state of all tools is disabled
+ * so this slot is recommended to use when at least one image
+ * has been loaded
  */
 void
 ImageLabeler::enableTools()
@@ -3502,9 +3536,9 @@ ImageLabeler::enableTools()
 	button_delete_all_labels_->setEnabled(true);
 }
 
-//!
+//! A slot member disabling all the tools
 /*!
- *
+ * \see enableTools()
  */
 void
 ImageLabeler::disableTools()
@@ -3529,9 +3563,11 @@ ImageLabeler::disableTools()
 	button_delete_all_labels_->setEnabled(false);
 }
 
-//!
+//! \brief A slot member triggering popup_area_list_ menu with the coordinates
+//! of the mouse pointer
 /*!
- *
+ * \see deleteArea()
+ * \see editArea()
  */
 void
 ImageLabeler::areaListPopupMenu(const QPoint &aPos)
@@ -3549,9 +3585,12 @@ ImageLabeler::areaListPopupMenu(const QPoint &aPos)
 	popup_area_list_->exec(globalPos);
 }
 
-//!
+//! \brief A slot member triggering popup_label_list_ menu width the coordinates
+//! of the mouse pointer
 /*!
- *
+ * \see setLabelColor()
+ * \see toggleLabelPriority()
+ * \see removeLabel()
  */
 void
 ImageLabeler::labelListPopupMenu(const QPoint &aPos)
@@ -3569,6 +3608,32 @@ ImageLabeler::labelListPopupMenu(const QPoint &aPos)
 	popup_label_list_->exec(globalPos);
 }
 
+//! \brief A slot member triggering popup_images_list_ menu width the coordinates
+//! of the mouse pointer
+/*!
+ * \see removeImage()
+ */
+void
+ImageLabeler::imageListPopupMenu(const QPoint &aPos)
+{
+	QPoint globalPos = list_images_widget_->mapToGlobal(aPos);
+	QModelIndex index = list_images_widget_->indexAt(aPos);
+
+	if (-1 == index.row()) {
+		return;
+		/* NOTREACHED */
+	}
+
+	list_images_widget_->item(index.row())->setSelected(true);
+
+	popup_images_list_->exec(globalPos);
+}
+
+//! \brief A slot member gets image description or tags from line_edit_form_
+//! depends on line_edit_form_.purpose()
+/*!
+ * \see LineEditForm
+ */
 void
 ImageLabeler::setDataFromForm(QString aData)
 {
@@ -3581,9 +3646,11 @@ ImageLabeler::setDataFromForm(QString aData)
 	}
 }
 
-//!
+//! A slot member creating 2-dimensional array for the segmented image
 /*!
- *
+ * Array size is equal to a size of the current image loaded
+ * and each pixel has the label id which corresponds to the objects in
+ * list_bounding_box_ and list_polygon_.
  */
 void
 ImageLabeler::setPureData()
@@ -3594,12 +3661,14 @@ ImageLabeler::setPureData()
 		delete pure_data_;
 	}
 
+	/* getting image size */
 	QSize imageSize = image_->size();
 	pure_data_ = new int *[imageSize.height()];
 	if (!pure_data_) {
 		return;
 		/* NOTREACHED */
 	}
+	/* allocating memory */
 	for (int i = 0; i < imageSize.height(); i++) {
 		pure_data_[i] = new int[imageSize.width()];
 		if (!pure_data_[i]) {
@@ -3608,8 +3677,10 @@ ImageLabeler::setPureData()
 		}
 	}
 
+	/* getting the number of all selections */
 	int bboxCnt = list_bounding_box_.count();
 	int polyCnt = list_polygon_.count();
+	/* checking if each coordinate(pixel) belongs to any object */
 	for (int i = 0; i < imageSize.height(); i++)
 		for (int j = 0; j < imageSize.width(); j++) {
 			pure_data_[i][j] = 0;
@@ -3628,13 +3699,12 @@ ImageLabeler::setPureData()
 				}
 			}
 		}
-
-
 }
 
-//!
+//! \brief A slot member setting new color for
+//! the current label from QColorDialog
 /*!
- *
+ * \see setLabelColor(int anID, QColor aColor)
  */
 void
 ImageLabeler::setLabelColor()
@@ -3643,6 +3713,7 @@ ImageLabeler::setLabelColor()
 		generateColors();
 	}
 
+	/* getting current item */
 	QListWidgetItem *current = list_label_->currentItem();
 
 	int labelID = list_label_->row(current);
@@ -3669,14 +3740,15 @@ ImageLabeler::setLabelColor()
 	image_holder_->update();
 }
 
-//!
+//! A protected member setting color aColor for the label number anID
 /*!
- *
+ * \param[in] anID an integer indicating label number in the list_label_ widget
+ * \param[in] aColor a QColor object contains color you want to set for the label
  */
 void
 ImageLabeler::setLabelColor(int anID, QColor aColor)
 {
-	if (anID < 0) {
+	if (anID < 0 || list_label_->count() < anID) {
 		return;
 		/* NOTREACHED */
 	}
@@ -3698,19 +3770,9 @@ ImageLabeler::setLabelColor(int anID, QColor aColor)
 	image_holder_->update();
 }
 
-//!
+//! A slot member loading normal image which path is in the current_image_
 /*!
- *
- */
-void
-ImageLabeler::onOptionsSet()
-{
-	auto_color_generation_ = options_form_.autoColorGeneration();
-}
-
-//!
-/*!
- *
+ * \see viewSegmented()
  */
 void
 ImageLabeler::viewNormal()
@@ -3727,9 +3789,9 @@ ImageLabeler::viewNormal()
 	action_view_normal_->setEnabled(false);
 }
 
-//!
+//! A slot member loading segmented image which path is in the segmented_image_
 /*!
- *
+ * \see viewNormal()
  */
 void
 ImageLabeler::viewSegmented()
@@ -3746,9 +3808,11 @@ ImageLabeler::viewSegmented()
 	action_view_normal_->setEnabled(true);
 }
 
-//!
+//! \brief A slot member setting interrupt_search_ to true for interrupting
+//! the recursive search
 /*!
- *
+ * \see loadImages()
+ * \see getImagesFromDir(const QDir &dir)
  */
 void
 ImageLabeler::interruptSearch()
@@ -3756,9 +3820,12 @@ ImageLabeler::interruptSearch()
 	interrupt_search_ = 1;
 }
 
-//!
+//! \brief A slot member selecting image corresponding to the item
+//! in the list_images_widget_
 /*!
- *
+ * \see selectImage(int anImageID)
+ * \param[in] anItem a pointer to the QListWidgetItem object which indicates
+ * certain image in the image_list_
  */
 void
 ImageLabeler::selectImage(QListWidgetItem *anItem)
@@ -3778,9 +3845,14 @@ ImageLabeler::selectImage(QListWidgetItem *anItem)
 	selectImage(image_ID_);
 }
 
-//!
+//! A protected member loading image from list_images_
 /*!
+ * \see loadInfo(QString filename)
+ * \param[in] anImageID an integer indicates certain
+ * image in the image_list_
  *
+ * if that image was labeled before, selectImage(int anImageID)
+ * will try to load all info
  */
 bool
 ImageLabeler::selectImage(int anImageID)
@@ -3792,6 +3864,7 @@ ImageLabeler::selectImage(int anImageID)
 		/* NOTREACHED */
 	}
 
+	/* checking if it was labeled before */
 	if (list_images_->at(anImageID).labeled_ &&
 		!list_images_->at(anImageID).pas_)
 	{
@@ -3801,12 +3874,14 @@ ImageLabeler::selectImage(int anImageID)
 		labeled.append(".dat");
 		loadInfo(labeled);
 	}
+	/* if it was loaded from PASCAL file then we're in trouble */
 	else if (list_images_->at(anImageID).labeled_ &&
 		list_images_->at(anImageID).pas_)
 	{
 		/* TODO: do the pascal file selecting */
 		showWarning("this function doesn't work at the moment, sorry.");
 	}
+	/* loading clean unlabeled image */
 	else {
 		current_image_ = list_images_->at(anImageID).image_;
 		image_->load(current_image_);
@@ -3817,29 +3892,13 @@ ImageLabeler::selectImage(int anImageID)
 	return true;
 }
 
-//!
-/*!
- *
- */
-void
-ImageLabeler::imageListPopupMenu(const QPoint &aPos)
-{
-	QPoint globalPos = list_images_widget_->mapToGlobal(aPos);
-	QModelIndex index = list_images_widget_->indexAt(aPos);
-
-	if (-1 == index.row()) {
-		return;
-		/* NOTREACHED */
-	}
-
-	list_images_widget_->item(index.row())->setSelected(true);
-
-	popup_images_list_->exec(globalPos);
-}
-
-//!
+//! \brief A slot member removing selected image from list
+//! (image will still be loaded in the image_holder_)
 /*!
- *
+ * Image will be removed from list so it will not be possible to load
+ * it again without using loadImage() or other slots for image loading.
+ * if you want to remove image from image_holder_ just call
+ * image_holder_->clear()
  */
 void
 ImageLabeler::removeImage()
@@ -3855,7 +3914,7 @@ ImageLabeler::removeImage()
 	}
 }
 
-//!
+//! A protected member which is being automatically called on every image resize
 /*!
  *
  */
@@ -3865,7 +3924,7 @@ ImageLabeler::resizeEvent (QResizeEvent *anEvent)
 	QWidget::resizeEvent(anEvent);
 }
 
-//!
+//! A protected member which is being automatically called on every mouse press
 /*!
  *
  */
@@ -3875,9 +3934,14 @@ ImageLabeler::mousePressEvent(QMouseEvent *anEvent)
 	QWidget::mousePressEvent(anEvent);
 }
 
-//!
+//! A protected member which is being automatically called on every key press
 /*!
- *
+ * current list of available commands:
+ * - key left\right - prevImage() \ nextImage()
+ * - enter\return - confirmSelection()
+ * - esc - clear current selection
+ * - ctrl+z - image_holder_->undo()
+ * - ctrl+y - iamge_holder_->redo()
  */
 void
 ImageLabeler::keyPressEvent(QKeyEvent *anEvent)
@@ -3906,14 +3970,14 @@ ImageLabeler::keyPressEvent(QKeyEvent *anEvent)
 	//	Qt::NoModifier == anEvent->modifiers() &&
 		-1 != image_holder_->focusedSelection()) {
 		image_holder_->clearFocusOnArea();
-		image_holder_->clearEdition();
+		image_holder_->clearHoveredPoint();
 		image_holder_->update();
 	}
 
 	if (Qt::Key_Escape == anEvent->key()) {
 		image_holder_->clearLast();
 		image_holder_->clearFocusOnArea();
-		image_holder_->clearEdition();
+		image_holder_->clearHoveredPoint();
 		image_holder_->update();
 	}
 
@@ -3940,9 +4004,9 @@ ImageLabeler::keyReleaseEvent(QKeyEvent *anEvent)
 	keyboard_modifier_ = anEvent->modifiers();
 }
 
-//!
+//! A protected member which is being automatically called on every mouse wheel turn
 /*!
- *
+ * implements zooming in and out on ctrl+wheel
  */
 void
 ImageLabeler::wheelEvent(QWheelEvent *anEvent)

+ 217 - 16
ImageLabeler.h

@@ -1,5 +1,5 @@
 /*
- * ImageLabeler.h
+ * \file ImageLabeler.h
  *
  *  Created on: Oct 4, 2011
  *      Author: Gapchich Vladislav
@@ -34,12 +34,26 @@ class QDomDocument;
 class QDomElement;
 class QSettings;
 
+//! Keeps flags for the image
+/*
+ * \see loadInfo(QString filename)
+ * \see loadPascalFile(QString aFilename, QString aPath)
+ *
+ * Image could be labeled before so you can load all the info about it
+ * using loadInfo(QString filename)
+ * pas_ means it was loaded from the file with PASCAL format
+ */
 struct Image {
 	QString image_;
 	bool labeled_;
 	bool pas_;
 };
 
+//! \brief Main widget which contains all GUI elements
+//! and connect them with each other.
+/*
+ * \\see ImageHolder
+ */
 class ImageLabeler : public QMainWindow
 {
 	Q_OBJECT
@@ -55,9 +69,14 @@ protected:
 	bool readSettings(QSettings *aSettings);
 	bool writeSettings(QSettings *aSettings);
 	void getImagesFromDir(const QDir &dir);
-	void showWarning(const QString text);
+	void showWarning(const QString &text);
 	bool askForUnsavedData();
 	void loadLegendFromNode(QDomElement *anElement);
+	void addLabel(
+		int aLabelID,
+		bool isMain,
+		QString aLabel
+		);
 	void addPoly(Polygon *poly);
 	void addBBox(BoundingBox *bbox);
 	void addPolyFromData(
@@ -71,14 +90,14 @@ protected:
 	Polygon polyFromData(
 		QString *aPolyData
 		);
-	Polygon	polyFromString(
+	Polygon	polyFromListItemText(
 		QString *aString,
 		int *oldID
 		);
 	BoundingBox BBoxFromData(
 		QString *aBBoxData
 		);
-	BoundingBox	BBoxFromString(
+	BoundingBox	BBoxFromListItemText(
 		QString *aString,
 		int *oldID
 		);
@@ -103,6 +122,7 @@ protected:
 	bool loadPascalFile(QString aFilename, QString aPath = QString());
 	bool loadPascalPolys(QString aFilename);
 	bool selectImage(int anImageID);
+	void setLabelColor(int anID, QColor aColor);
 
 public:
 	ImageLabeler(QWidget *aParent = 0, QString aSettingsPath = QString());
@@ -110,11 +130,6 @@ public:
 
 public slots:
 	void addLabel();
-	void addLabel(
-		int aLabelID,
-		bool isMain,
-		QString aLabel
-	);
 	void editLabel(QListWidgetItem *anItem);
 	void removeLabel();
 	void removeLabel(int aLabelID);
@@ -145,73 +160,150 @@ public slots:
 	void clearLabelColorList();
 	void areaListPopupMenu(const QPoint &aPos);
 	void labelListPopupMenu(const QPoint &aPos);
+	void imageListPopupMenu(const QPoint &);
 	void setDataFromForm(QString aData);
-	void onImageScaled();
-	void onOptionsSet();
 	void onSelectionStarted();
 	void onAreaItemChange(QListWidgetItem *);
 	void onAreaEdit();
 	void setPureData();
 	void setLabelColor();
-	void setLabelColor(int anID, QColor aColor);
 	void viewNormal();
 	void viewSegmented();
 	void interruptSearch();
 	void selectImage(QListWidgetItem *);
 	void removeImage();
-	void imageListPopupMenu(const QPoint &);
 	void writeSettings();
 	void readSettings();
 
 private:
 	/* menu */
+	//! main menu bar contains all other menus
 	QMenuBar *menu_bar_;
+
+	//! \brief contains all actions connected with file loading and saving files.
+	//! also contains menu_pascal_
 	QMenu *menu_file_;
+
+	//! contains actions for loading PASCAL xml file and PASCAL polygon
 	QMenu *menu_pascal_;
+
+	//! \brief contains action_view_normal_ and action_view_segmented_
+	//! \see action_view_normal_ \see action_view_segmented_
 	QMenu *menu_view_;
+
+	/*! \brief contains tools, undo, redo, description adding and options
+	 * \see action_undo_
+	 * \see action_redo_
+	 * \see action_bound_box_tool_
+	 * \see action_polygon_tool_
+	 * \see action_tagging_tool_
+	 * \see action_add_description_
+	 * \see action_options_
+	 */
 	QMenu *menu_edit_;
+
+	//! empty yet
 	QMenu *menu_help_;
+
 	/* menu file */
+	//! \see loadImages()
 	QAction *action_open_images_;
+
+	//! \see loadImage()
 	QAction *action_open_image_;
+
+	//! \see loadInfo()
 	QAction *action_open_labeled_image_;
+
+	//! \see loadLegendFromFile()
 	QAction *action_load_legend_;
+
+	//! \see saveAllInfo()
 	QAction *action_save_all_;
+
+	//! \see saveSegmentedPicture()
 	QAction *action_save_segmented_;
+
+	//! \see saveLegend()
 	QAction *action_save_legend_;
+
+	//! closes the application
 	QAction *action_quit_;
+
 	/* menu pascal */
+	//! \see loadPascalFile();
 	QAction *action_load_pascal_file_;
+
+	//! \see loadPascalPolys();
 	QAction *action_load_pascal_poly_;
+
 	/* menu view */
+	//! loads an image from current_image_ \see viewNormal()
 	QAction *action_view_normal_;
+
+	//! loads an image from segmented_image_ \see viewSegmented()
 	QAction *action_view_segmented_;
+
 	/* menu edit */
+	//! \see ImageHolder::undo()
 	QAction *action_undo_;
+
+	//! \see ImageHolder::redo()
 	QAction *action_redo_;
+
+	//! \see setBoundingBoxTool(bool aButtonPressed)
 	QAction *action_bound_box_tool_;
+
+	//! \see setPolygonTool(bool aButtonPressed)
 	QAction *action_polygon_tool_;
+
+	//! \see setTags()
 	QAction *action_tagging_tool_;
+
+	/*! \see setDataFromForm(QString aData)
+	 *  \see image_description_
+	 */
 	QAction *action_add_description_;
+
+	//! \see OptionsForm
 	QAction *action_options_;
 
+	//! empty yet
 	QAction *action_about_;
+
+	//! empty yet
 	QAction *action_help_content_;
 
+
 	/* popup menu */
+	//! \brief popup menu for area_list_
+	//! \see list_areas_
 	QMenu *popup_area_list_;
 
+	//! \see deleteArea()
 	QAction *action_delete_area_;
+
+	//! \see editArea()
 	QAction *action_edit_area_;
 
+	//! \brief popup menu for list_label_
+	//! \see list_label_
 	QMenu *popup_label_list_;
 
+	//! \see toggleLabelPriority()
 	QAction *action_toggle_priority_;
+
+	//! \see setLabelColor(int anID, QColor aColor)
 	QAction *action_set_color_;
+
+	//! \see removeLabel()
 	QAction *action_delete_label_;
 
+	//! \brief popup menu for list_images_
+	//! \see list_images
 	QMenu *popup_images_list_;
 
+	//! \see removeImage()
 	QAction *action_remove_image_;
 
 	/* layouts */
@@ -227,64 +319,173 @@ private:
 	QHBoxLayout *layout_labelbox_buttons_;
 
 	/* widgets */
+	//!	parent for all widgets
 	QWidget *central_widget_;
-	//QFrame *frame_image_;
+
+	//! \brief container(parent) of the image_holder_
+	//! \see iamge_holder_
 	QScrollArea *frame_image_;
+
+	//! frame containing all the widgets in the center
 	QFrame *frame_center_;
+
+	//! frame containing all the left part
 	QFrame *frame_toolbox_;
+
+	//! frame containing all the right part
 	QFrame *frame_labelbox_;
+
+	//! \brief object containing current loaded image
+	//! \see image_holder_
 	QPixmap *image_;
+
+	//! widget containing the image_(inherited from QLabel)
 	ImageHolder *image_holder_;
+
+	//! just an information label
 	QLabel *label_toolbox_;
+
+	//! just an information label
 	QLabel *label_list_areas_;
+
+	//! just an information label
 	QLabel *label_list_images_;
+
+	//! list widget containing labels
 	QListWidget *list_label_;
+
+	//! list widget containing selected areas data
 	QListWidget *list_areas_;
+
+	//! \brief list widget containing loaded images names
+	//! \see list_images_
 	QListWidget *list_images_widget_;
+
+	//! \brief widget for editing tags and image description
+	//! \see tags_
+	//! \see image_description_
 	LineEditForm line_edit_form_;
+
+	//! widget containing possible options
 	OptionsForm options_form_;
 
+	//! \brief button switching to the bounding box tool
+	//! \see BoundingBox
+	//! \see setBoundingBoxTool(bool aButtonPressed)
 	QPushButton *button_bound_box_tool_;
+
+	//! \brief button switching to the bounding box tool
+	//! \see Polygon
+	//! \see setPolygonTool(bool aButtonPressed)
 	QPushButton *button_polygon_tool_;
+
+	//! \brief button calling LineEditForm to edit tags
+	//! \see tags_
+	//! \see LineEditForm
 	QPushButton *button_tagging_tool_;
+
+	//! \brief button clearing all selection
+	//! \see clearAllTool()
 	QPushButton *button_clear_selection_tool_;
+
+	//! \brief button deleting all labels(except BACKGROUND)
+	//! \see clearLabelList()
 	QPushButton *button_delete_all_labels_;
+
+	//! \brief button generating colors for all labels(except BACKGROUND)
+	//! \see generateColors()
 	QPushButton *button_generate_colors_;
+
+	//! \brief button adding new label
+	//! \see addLabel()
 	QPushButton *button_add_label_;
+
+	//! \brief button removing current label
+	//! \see removeLabel()
 	QPushButton *button_remove_label_;
+
+	//! \brief button switching to the next image
+	//! \see nextImage()
 	QPushButton *button_prev_image_;
+
+	//! \brief button switching to the previous image
+	//! \see prevImage()
 	QPushButton *button_next_image_;
+
+	//! \brief button confirming current selection(selected area)
+	//! \see configrmSelection()
 	QPushButton *button_confirm_selection_;
 
+	//! abstract group manages tool buttons state
 	QButtonGroup *group_tools_;
 
 	/* variables */
+	//! keeps current keyboard modifier(like ctrl, shift, alt etc)
 	Qt::KeyboardModifiers keyboard_modifier_;
+
+	//! number of the main label
 	int main_label_;
+
+	//! \brief 2d array for the segmented image
+	//! \see setPureData()
 	int **pure_data_;
+
+	//! \brief number of selected label in the list_label_
+	//! \see list_label_
 	int label_ID_;
+
+	//! \brief number of current image in the list_images_
+	//! \see list_images_
 	int image_ID_;
 
+	//! contains current image description
 	QString image_description_;
+
+	//! contains tags for the current image
 	QString tags_;
+
+	//! "root" path to the directory where all the PASCAL data is located
 	QString PASCALpath_;
-	QList< Image > *list_images_;
-	//QStringList::iterator current_image_;
+
+	//! path to the currenlty loaded image
 	QString current_image_;
+
+	//! path to the segmented image
 	QString segmented_image_;
+
+	//! \brief list of all selected and confirmed rectangular areas
+	//! \see addBBox(BoundingBox *bbox)
 	QList< BoundingBox * > list_bounding_box_;
+
+	//! \brief list of all selected and confirmed polygon areas
+	//! \see addPoly(Polygon *poly)
 	QList< Polygon * > list_polygon_;
+
+	//! contains the paths for all loaded images
+	QList< Image > *list_images_;
+
+	//! list of label colors
 	QList< uint > list_label_colors_;
 
+	//! \brief buffer for manual list_areas_ items editing
+	//! \see onAreaItemChange(QListWidgetItem *anItem)
 	QString old_area_string_;
 
 	/* options */
+	//! enables\disables automatic color generation before image segmenting
 	bool auto_color_generation_;
 
 	/* flags */
+	//! \brief flag used to interrupt recursive search of the images
+	//! \see interruptSearch()
+	//! \see loadImages()
+	//! \see getImagesFromDir(const QDir &dir)
 	bool interrupt_search_;
+
+	//! flag indicating whether there is an unsaved data or not
 	bool unsaved_data_;
 
+	//! pointer to object used to read and write application settings
 	QSettings *settings_;
 };
 

+ 8 - 4
Makefile

@@ -1,9 +1,9 @@
 #############################################################################
 # Makefile for building: ImageLabeler
-# Generated by qmake (2.01a) (Qt 4.6.3) on: Di. Okt 18 13:47:35 2011
+# Generated by qmake (2.01a) (Qt 4.7.1) on: Thu Oct 20 15:46:56 2011
 # Project:  ImageLabeler.pro
 # Template: app
-# Command: /usr/bin/qmake -unix CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
+# Command: /usr/bin/qmake CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
 #############################################################################
 
 first: release
@@ -67,6 +67,8 @@ Makefile: ImageLabeler.pro  /usr/share/qt4/mkspecs/default/qmake.conf /usr/share
 		/usr/share/qt4/mkspecs/common/unix.conf \
 		/usr/share/qt4/mkspecs/common/linux.conf \
 		/usr/share/qt4/mkspecs/qconfig.pri \
+		/usr/share/qt4/mkspecs/modules/qt_phonon.pri \
+		/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
 		/usr/share/qt4/mkspecs/features/qt_functions.prf \
 		/usr/share/qt4/mkspecs/features/qt_config.prf \
 		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
@@ -86,11 +88,13 @@ Makefile: ImageLabeler.pro  /usr/share/qt4/mkspecs/default/qmake.conf /usr/share
 		/usr/lib64/libQtXml.prl \
 		/usr/lib64/libQtCore.prl \
 		/usr/lib64/libQtGui.prl
-	$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
+	$(QMAKE) CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
 /usr/share/qt4/mkspecs/common/g++.conf:
 /usr/share/qt4/mkspecs/common/unix.conf:
 /usr/share/qt4/mkspecs/common/linux.conf:
 /usr/share/qt4/mkspecs/qconfig.pri:
+/usr/share/qt4/mkspecs/modules/qt_phonon.pri:
+/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri:
 /usr/share/qt4/mkspecs/features/qt_functions.prf:
 /usr/share/qt4/mkspecs/features/qt_config.prf:
 /usr/share/qt4/mkspecs/features/exclusive_builds.prf:
@@ -111,7 +115,7 @@ Makefile: ImageLabeler.pro  /usr/share/qt4/mkspecs/default/qmake.conf /usr/share
 /usr/lib64/libQtCore.prl:
 /usr/lib64/libQtGui.prl:
 qmake: qmake_all FORCE
-	@$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
+	@$(QMAKE) CONFIG+=debug_and_release -o Makefile ImageLabeler.pro
 
 qmake_all: FORCE
 

+ 4 - 2
Makefile.Debug

@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: ImageLabeler
-# Generated by qmake (2.01a) (Qt 4.6.3) on: Di. Okt 18 13:47:35 2011
+# Generated by qmake (2.01a) (Qt 4.7.1) on: Thu Oct 20 15:46:55 2011
 # Project:  ImageLabeler.pro
 # Template: app
 #############################################################################
@@ -65,6 +65,8 @@ DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
 		/usr/share/qt4/mkspecs/common/unix.conf \
 		/usr/share/qt4/mkspecs/common/linux.conf \
 		/usr/share/qt4/mkspecs/qconfig.pri \
+		/usr/share/qt4/mkspecs/modules/qt_phonon.pri \
+		/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
 		/usr/share/qt4/mkspecs/features/qt_functions.prf \
 		/usr/share/qt4/mkspecs/features/qt_config.prf \
 		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
@@ -115,7 +117,7 @@ $(TARGET):  $(OBJECTS)
 	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
 
 qmake:  FORCE
-	@$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile.Debug ImageLabeler.pro
+	@$(QMAKE) CONFIG+=debug_and_release -o Makefile.Debug ImageLabeler.pro
 
 dist: 
 	@$(CHK_DIR_EXISTS) debug/ImageLabeler1.0.0 || $(MKDIR) debug/ImageLabeler1.0.0 

+ 6 - 4
Makefile.Release

@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: ImageLabeler
-# Generated by qmake (2.01a) (Qt 4.6.3) on: Di. Okt 18 13:47:35 2011
+# Generated by qmake (2.01a) (Qt 4.7.1) on: Thu Oct 20 15:46:55 2011
 # Project:  ImageLabeler.pro
 # Template: app
 #############################################################################
@@ -10,8 +10,8 @@
 CC            = gcc
 CXX           = g++
 DEFINES       = -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS        = -m64 -pipe -O2 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS      = -m64 -pipe -O2 -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -W -D_REENTRANT $(DEFINES)
+CFLAGS        = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS      = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
 INCPATH       = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtXml -I/usr/include -Irelease
 LINK          = g++
 LFLAGS        = -m64 -Wl,-O1
@@ -65,6 +65,8 @@ DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
 		/usr/share/qt4/mkspecs/common/unix.conf \
 		/usr/share/qt4/mkspecs/common/linux.conf \
 		/usr/share/qt4/mkspecs/qconfig.pri \
+		/usr/share/qt4/mkspecs/modules/qt_phonon.pri \
+		/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
 		/usr/share/qt4/mkspecs/features/qt_functions.prf \
 		/usr/share/qt4/mkspecs/features/qt_config.prf \
 		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
@@ -115,7 +117,7 @@ $(TARGET):  $(OBJECTS)
 	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
 
 qmake:  FORCE
-	@$(QMAKE) -unix CONFIG+=debug_and_release -o Makefile.Release ImageLabeler.pro
+	@$(QMAKE) CONFIG+=debug_and_release -o Makefile.Release ImageLabeler.pro
 
 dist: 
 	@$(CHK_DIR_EXISTS) release/ImageLabeler1.0.0 || $(MKDIR) release/ImageLabeler1.0.0 

+ 8 - 7
OptionsForm.cpp

@@ -29,8 +29,8 @@ OptionsForm::OptionsForm(QWidget *aParent)
 	layout_PASCAL_root_ = new QHBoxLayout;
 	layout_h_ = new QHBoxLayout;
 
-	auto_color_generation_ = new QCheckBox(this);
-	auto_color_generation_->setText(tr("Automatic label color generation"));
+	auto_color_generation_box_ = new QCheckBox(this);
+	auto_color_generation_box_->setText(tr("Automatic label color generation"));
 	button_set_PASCAL_root_ = new QPushButton(this);
 	button_set_PASCAL_root_->setText(tr("set PASCAL root path"));
 	edit_PASCAL_root_ = new QLineEdit("", this);
@@ -40,7 +40,7 @@ OptionsForm::OptionsForm(QWidget *aParent)
 	button_cancel_ = new QPushButton(this);
 	button_cancel_->setText(tr("Cancel"));
 
-	layout_v_->addWidget(auto_color_generation_);
+	layout_v_->addWidget(auto_color_generation_box_);
 	layout_v_->addLayout(layout_PASCAL_root_);
 	layout_v_->addLayout(layout_h_);
 
@@ -92,7 +92,7 @@ OptionsForm::~OptionsForm()
 void
 OptionsForm::setOptions()
 {
-	emit optionsSet();
+	*auto_color_generation_ = auto_color_generation_box_->isChecked();
 	hide();
 }
 
@@ -132,13 +132,14 @@ OptionsForm::newPascalPath()
 bool
 OptionsForm::autoColorGeneration()
 {
-	return auto_color_generation_->isChecked();
+	return auto_color_generation_box_->isChecked();
 }
 
 void
-OptionsForm::setAutoColorGeneration(bool flag)
+OptionsForm::setAutoColorGeneration(bool *flag)
 {
-	auto_color_generation_->setChecked(flag);
+	auto_color_generation_box_->setChecked(*flag);
+	auto_color_generation_ = flag;
 }
 
 void

+ 3 - 3
OptionsForm.h

@@ -33,14 +33,13 @@ public slots:
 	void setOptions();
 	void showOptions();
 	void newPascalPath();
-	void setAutoColorGeneration(bool flag);
+	void setAutoColorGeneration(bool *flag);
 	void onPathEditing();
 
 signals:
-	void optionsSet();
 
 private:
-	QCheckBox *auto_color_generation_;
+	QCheckBox *auto_color_generation_box_;
 	QPushButton *button_set_PASCAL_root_;
 	QLineEdit *edit_PASCAL_root_;
 	QPushButton *button_ok_;
@@ -52,6 +51,7 @@ private:
 
 	/* pointers to variables */
 	QString *PASCALpath_;
+	bool *auto_color_generation_;
 };
 
 #endif /* __OPTIONSFORM_H__ */