Functions
gpfksimulator/main.cpp File Reference
#include <SciFigs.h>
#include "Simulator.h"
#include "gpfksimulatorVersion.h"
#include "gpfksimulatorInstallPath.h"

Functions

ApplicationHelphelp ()
int main (int argc, char **argv)
 PACKAGE_INFO (gpfksimulator, GPFKSIMULATOR)

Function Documentation

int main ( int  argc,
char **  argv 
)

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);

  // Options
  QString stationFile;
  // Check arguments
  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;
  }

  // Load station coordinates
  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;
  }
  // Find gravity center of the array
  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());
  // Center the array around 0,0
  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;
}
PACKAGE_INFO ( gpfksimulator  ,
GPFKSIMULATOR   
)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines