Преглед на файлове

imageinfo polygon loading and plotting

Johannes R преди 13 години
родител
ревизия
9dd8f0e7e1
променени са 1 файла, в които са добавени 29 реда и са изтрити 7 реда
  1. 29 7
      ImageLabeler.cpp

+ 29 - 7
ImageLabeler.cpp

@@ -2100,14 +2100,13 @@ ImageLabeler::loadInfo(QString filename)
 					return false;
 					/* NOTREACHED */
 				}
-
+                QString sImageStr = string;
                 if( QFileInfo(string).isRelative() )
                 {
-                    string = QFileInfo(filename).path() + "/" + string;
-                    string = QFileInfo(string).absoluteFilePath();
+                    sImageStr = QFileInfo(filename).path() + "/" + string;
                 }
 
-                if (!image_->load( string )) {
+                if (!image_->load( sImageStr )) {
 					return false;
 					/* NOTREACHED */
 				}
@@ -3338,8 +3337,30 @@ ImageLabeler::polyFromData(
 	/* indicates whether coordinate x or y */
 	bool evenFlag = 0;
 
+
+    ///jojo
+    QStringList coordsList = aPolyData->split(";", QString::SkipEmptyParts);
+    Polygon newPoly;
+    try
+    {
+        if( coordsList.size() % 2 == 0)
+        {
+            for( int i = 0; i < coordsList.size(); i += 2)
+            {
+                newPoly.poly.append( QPoint( QVariant(coordsList[i]).toInt(),
+                                             QVariant(coordsList[i+1]).toInt() ) );
+            }
+        }
+    }
+    catch(std::exception &e)
+    {
+        newPoly.poly.clear();
+    }
+    return newPoly;
+    ///#jojo
+/*
 	for (int i = 0; i < aPolyData->size(); i++) {
-		/* ";" is a separator */
+        // ";" is a separator
 		if (';' != aPolyData->at(i))
 			continue;
 
@@ -3365,19 +3386,20 @@ ImageLabeler::polyFromData(
 		startPos = i + 1;
 	}
 
-	/* last coordinate was Xi what means an error */
+    // 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 */
+    // last converting from string was not successful
 	else if (!ok) {
 		poly.poly.clear();
 	}
 
 	return poly;
+    */
 }
 
 //! A protected member getting a Polygon from text of the list_areas_ item