[project @ 8]
[mussa.git] / mussa.cc
1 #include "mussa_gui_conn_window.hh"
2
3 char
4 parse_args(int argc, char **argv, string *a_file_path, int *window, 
5            int *threshold)
6 {
7   int i;
8   string an_arg;
9   char run_mode;
10
11   *window = 0;
12   *threshold = 0;
13
14   // minimal arg reading structure, not very robust to errors
15
16
17   run_mode = 'g';
18   i = 1;
19   while (i < argc)
20   {
21     an_arg = * ++argv;
22     i++;
23
24     if (an_arg == "-v")
25     {
26       *a_file_path = * ++argv;
27       i++;
28       run_mode = 'v';
29     }
30     else if (an_arg == "-n")
31     {
32       *a_file_path = * ++argv;
33       i++;
34       run_mode = 'n';
35     }
36     else if (an_arg == "-w")
37     {
38       *window = atoi(* ++argv);
39       i++;
40     }
41     else if (an_arg == "-t")
42     {
43       *threshold = atoi(* ++argv);
44       i++;
45     }
46     else
47     {
48       *a_file_path = an_arg;
49       run_mode = 'f';
50     }
51   }
52   return run_mode;
53 }
54
55
56 int main(int argc, char **argv) 
57 {
58   Mussa an_analysis;
59   string a_file_path;
60   char * picked_file;
61   int window, threshold;
62   char run_mode;
63   int x_max=1000;
64   int y_max=500;
65   string err_msg;
66
67   err_msg = "";
68
69   // yeah, its horrible to be passing these by reference, but I just don't see
70   // any other way without making parse_args part of MussaClass, which just
71   // seems wrong (args are after all, an io type thing, and the gui only mode
72   // will have it own way as well...
73   run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold);
74
75   if ((run_mode == 'f') || (run_mode == 'n'))
76     err_msg = an_analysis.analyze(a_file_path, window, threshold);
77     //an_overlord.do_analysis();
78
79   if  (run_mode == 'v')
80     err_msg = an_analysis.load(a_file_path);
81       //an_overlord.get_analysis();
82
83   // no longer needed, but still semi-useful reality check...
84   if (run_mode == 'g')
85   {
86     cout << "GTV - All Gui, All the Time\n";
87   }
88
89   if (err_msg == "")
90   {
91     if  ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
92     {
93       //an_overlord.spawnConnView(1000,500);
94       ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
95
96       // we have an analysis already if in these 2 modes
97       if  ((run_mode == 'f') || (run_mode == 'v'))
98         a_conn_win->add_ana(&an_analysis);
99
100       Fl::run();
101     }
102   }
103   else
104     cout << err_msg << endl;
105 }
106
107 /*
108       cout << "fee\n";
109       cout << "fie\n";
110       cout << "foe\n";
111       cout << "fum\n";
112 */