+bool RouteDialog::readRouteFromFile( QString &filename)
+{
+/* 2d */
+ Vector temp;
+ int i;
+ QString rivi;
+ QFile file;
+ //file.setFileName("route.txt");
+ file.setFileName( filename);
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ QMessageBox::about(0, "Error", "File not found");
+ return false;
+ }
+
+ vertexList.clear();
+ i = 0;
+ //while( file.canReadLine())
+ while(!file.atEnd())
+ {
+ QString str1, str2, str3;
+ rivi = file.readLine();
+
+ str1 = rivi.section(" ", 0, 0);
+ if (str1.compare("Start:") == 0 || str1.compare("Stop:") == 0)
+ {
+
+ }
+ else
+ {
+ //QMessageBox::about(0, "LUKEE", file.readLine());
+ str1 = rivi.section(" ", 2, 2); // latitude y-value
+ str2 = rivi.section(" ", 4, 4); // longitude x-value
+ str3 = rivi.section(" ", 6, 6); // altitude z-value
+ QString str = QString("la: %1 lo: %2 al: %3").arg(str1).arg(str2).arg(str3);
+ //QMessageBox::about(0, "LUKEE", str);
+
+ double x, y, z;
+ x = str2.toDouble();
+ y = str1.toDouble();
+ z = str3.toDouble();
+ temp.setX( x); // Longitude
+ temp.setY( y);// Latitude
+ temp.setZ( z);// altitude
+
+ vertexList.append(temp);
+ }
+ i++;
+ }
+
+ // la: lo: al:
+ file.close();
+
+ /* */
+ /* for 3D test */
+ /*vertexList.append(Vector(0.0, 0.0, 0.0));
+ vertexList.append(Vector(1.0, 1.0, 1.0));
+ vertexList.append(Vector(1.0, 1.0, 0.0));
+
+ vertexList.append(Vector(1.0, 0.0, 0.0));
+ vertexList.append(Vector(1.0, 0.0, 1.0));
+ vertexList.append(Vector(0.0, 1.0, 1.0));
+
+ vertexList.append(Vector(0.0, 1.0, 0.0));
+ vertexList.append(Vector(0.0, 0.0, 0.0));
+ vertexList.append(Vector(0.0, 0.0, 1.0));
+*/
+ /* For 3d */
+ //int i;
+ for(i= 0; i<35; i++)
+ {
+ connection[i] = i;
+ }
+ /* connection[0] = 0;
+ connection[1] = 1; connection[2] = 5; connection[3] = 8; connection[4] = -4;
+ connection[5] = 5; connection[6] = 6; connection[7] = 7; connection[8] = -8;
+ connection[9] = 6; connection[10] = 2; connection[11] = 3; connection[12] = -7;
+ connection[13] = 1; connection[14] = 4; connection[15] = 3; connection[16] = -2;
+ connection[17] = 8; connection[18] = 7; connection[19] = 3; connection[20] = -4;
+ connection[21] = 6; connection[22] = 5; connection[23] = 1; connection[24] = -2;*/
+
+ /******** in 3d use only */
+ a = 400/2.;
+ b = 1 - a*(-1);
+ c = -300/2.;
+ d = 300 - c*(-1);
+ //angle = toradians(60);
+
+ view3d.setUp( 0.0, 0.0, 1.0);
+ view3d.setAngle(toradians(60));
+ setAtPoint( &view3d);
+ xmin = objxmin; xmax = objxmax; ymin = objymin; ymax = objymax;
+ setFromPoint( &view3d);
+ view3d.setEye();
+ /****** end of 3d *****/
+ return true;
+}
+
+/*
+ * Find out data range for x-, y- and z-coordinates
+ */