/*******************************************/
/*                                         */
/*           viewer application            */
/*             beta test v 1.0             */
/*                                         */
/*******************************************/

#include "window.h"

using namespace morpheo::tools::viewer::parser;
using namespace morpheo::tools::viewer::bdd;
using namespace morpheo::tools::viewer::graphics;

using namespace std;

int main (int argc, char* argv[])
{
  /*if to many arguments*/
  if(argc>2){
    cout << "error : argument must be a file name or nothing" << endl;
    cout << "usage : Viewer [file]" << endl;
    return 0;
  }

  /*construct the base*/
  Parse *par = new Parse();
  
  /*create the window application*/
  QApplication *a=new QApplication (argc,argv);  
   
   if(argc == 2){
     if(par->open_file(argv[1],0)==-1){
	cout << "file doesn't exist or is not a valid format" << endl;  
	exit(1);
     }
     Window *win = new Window(QString(argv[1]));
     win->_setParse(par);
     win->_init_file();
     win->show();
   }

   else{
     
     Window *win = new Window(NULL);
     win->_setParse(par);
     win->show();
   }
    

  a->setStyle(new QPlastiqueStyle);
  
  return a->exec();
  
}
