Browse Source

fixed:loading of ImageInfo with empty 'segmented' definition.

Johannes Ruehle 13 years ago
parent
commit
10794745a9
1 changed files with 15 additions and 9 deletions
  1. 15 9
      ImageLabeler.cpp

+ 15 - 9
ImageLabeler.cpp

@@ -2081,6 +2081,7 @@ ImageLabeler::loadInfo(QString filename)
 		if(!element.isNull()) {
 			/* path to the image */
 			if (element.tagName() == "image") {
+				//qDebug() << "image";
 				string = element.text();
 				if (string.isEmpty()) {
 					showWarning(
@@ -2108,30 +2109,34 @@ ImageLabeler::loadInfo(QString filename)
 			}
 			/* path to the segmented image */
 			if (element.tagName() == "segmented") {
+				//qDebug() << "segmented";
 				string = element.text();
-				if (string.isEmpty()) {
-					continue;
+				if ( !string.isEmpty()) {
+				  segmented_image_ = string;
+				  action_view_segmented_->setEnabled(true);
 				}
-				segmented_image_ = string;
-				action_view_segmented_->setEnabled(true);
 			}
 			/* image description */
 			else if (element.tagName() == "description" &&
-				!element.text().isEmpty()) {
+			      !element.text().isEmpty()) {
+				//qDebug() << "description";	
 				image_description_ = element.text();
 			}
 			/* tags */
 			else if (element.tagName() == "tags" &&
 				!element.text().isEmpty()) {
+			  	//qDebug() << "tags";
 				tags_ = element.text();
 			}
 			/* legend */
 			else if (element.tagName() == "legend") {
+				qDebug() << "legend";
 				list_label_->clear();
 				loadLegendFromNode(&element);
 			}
 			/* objects */
 			else if (element.tagName() == "objects") {
+				//qDebug() << "objects";
 				QDomNode subNode = element.firstChild();
 				QDomElement subElement;
 
@@ -2183,7 +2188,7 @@ ImageLabeler::loadInfo(QString filename)
 		}
 		rootNode = rootNode.nextSibling();
 	}
-
+	qDebug() << "image info loaded for "<<filename;
 	unsaved_data_ = 0;
 	return true;
 }
@@ -2601,7 +2606,7 @@ ImageLabeler::loadImage()
 	QFileDialog fileDialog(0, tr("Load image"));
 	fileDialog.setFileMode(QFileDialog::ExistingFile);
 	QStringList filters;
-	filters << "Image files (*.jpeg *.jpg *.gif *.png *.bmp *.tiff)"
+	filters << "Image files (*.jpeg *.jpg *.gif *.png *.bmp *.tiff *.pgm)"
 			<< "Any files (*)";
 
 	fileDialog.setNameFilters(filters);
@@ -2884,8 +2889,9 @@ ImageLabeler::loadLegendFromNode(QDomElement *anElement)
 
 			/* color attribute */
 			string = subElement.attribute("color");
+			
 			color = string.toUInt(&ok, 16);
-
+			
 			if (!ok) {
 				qDebug() <<
 					"loadLegendFromNode: "
@@ -3891,7 +3897,7 @@ ImageLabeler::setLabelColor(int anID, QColor aColor)
 	if (list_label_colors_.count() < list_label_->count()) {
 		generateColors();
 	}
-
+	
 	QListWidgetItem *item = list_label_->item(anID);
 	list_label_colors_.takeAt(anID);
 	list_label_colors_.insert(anID, aColor.rgb());