References QGpCoreTools::endl(), help(), Simulator::init(), MSG_ID, QGpGuiTools::CoordinateFile::points(), QGpGuiTools::CoordinateFile::read(), QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), QGpCoreTools::tr(), w, QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().
{
Application a(argc, argv, help);
QString stationFile;
int i, j=1;
for(i=1; i<argc; i++) {
QByteArray arg=argv[i];
if(arg[0]=='-') {
if(arg=="-s") {
CoreApplication::checkOptionArg(i, argc, argv);
stationFile=argv[i];
} else {
App::stream() << tr("gpfksimulator: bad option %1, see -help").arg(argv[i]) << endl;
return 2;
}
} else {
argv[j++]=argv[i];
}
}
if(j < argc) {
argv[j]=0;
argc=j;
}
QVector<Point2D> stations;
CoordinateFile cf;
if(cf.read()) {
QList<NamedPoint> points=cf.points();
for(QList<NamedPoint>::iterator it=points.begin(); it!=points.end();it++) {
stations.append(Point2D(*it));
}
}
if(stations.count()<2) {
Message::critical(MSG_ID, tr("Loading coordinates"), tr("Less than 2 stations in your array"));
return 2;
}
Point2D center;
for(QVector<Point2D>::iterator it=stations.begin();it!=stations.end();it++) {
center+=*it;
}
center.setX(center.x()/stations.count());
center.setY(center.y()/stations.count());
for(QVector<Point2D>::iterator it=stations.begin();it!=stations.end();it++) {
(*it)-=center;
}
SciFigsGlobal s;
Simulator * w=new Simulator;
w->init(stations);
w->show();
int appReturn=a.exec();
return appReturn;
}