1 // This file is part of the Mussa source distribution.
2 // http://mussa.caltech.edu/
3 // Contact author: Tristan De Buysscher, tristan@caltech.edu
5 // This program and all associated source code files are Copyright (C) 2005
6 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
7 // under the GNU Public License; please see the included LICENSE.txt
8 // file for more information, or contact Tristan directly.
11 #include "mussa_gui_conn_window.hh"
15 parse_args(int argc, char **argv, string *a_file_path, int *window,
16 int *threshold, char *ana_mode, float *ent_thres);
19 int main(int argc, char **argv)
24 int window, threshold;
26 char run_mode, ana_mode;
34 // yeah, its horrible to be passing these by reference, but I just don't see
35 // any other way without making parse_args part of MussaClass, which just
36 // seems wrong (args are after all, an io type thing, and the gui only mode
37 // will have it own way as well...
38 run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
39 &ana_mode, &ent_thres);
41 cout << "mussa: run mode = " << run_mode;
42 cout << "\tfile_path = "<< a_file_path << endl;
43 cout << "mussa: ent_thres = " << ent_thres << endl;
45 // if no error from parse args (run_mode = 'e', ie error), run in proper mode
48 if ((run_mode == 'f') || (run_mode == 'n'))
50 err_msg = an_analysis.load_mupa_file(a_file_path);
51 err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
52 //an_overlord.do_analysis();
56 err_msg = an_analysis.load(a_file_path);
57 //an_overlord.get_analysis();
59 // no longer needed, but still semi-useful reality check...
62 cout << "GTV - All Gui, All the Time\n";
67 if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
69 //an_overlord.spawnConnView(1000,500);
70 ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
72 // we have an analysis already if in these 2 modes
73 if ((run_mode == 'f') || (run_mode == 'v'))
74 a_conn_win->add_ana(&an_analysis);
80 cout << err_msg << endl;
85 // minimal arg reading function, not very robust to errors
87 parse_args(int argc, char **argv, string *a_file_path, int *window,
88 int *threshold, char *ana_mode, float *ent_thres)
94 // initialize these to 0 as flag if they are not changed
98 run_mode = 'e'; //error default if no run mode set implicitly or explicitly
99 *ana_mode = 't'; // default to transitivie analyses mode
103 // no args means gui only mode
106 // 1 arg means its a mupa file and run in full mode
121 // see what alternate mode the user wants to run in
126 if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
127 run_mode = an_arg[0];
130 cout << "Error: \'" << an_arg;
131 cout << "\' is not a valid analysis mode for -a argument" << endl;
134 *a_file_path = * ++argv;
137 // alternate analyses modes
138 else if (an_arg == "-a")
142 // t = transitive, r = radial, e = entropy
143 if ( (an_arg == "t") || (an_arg == "r") || (an_arg == "e") )
144 *ana_mode = an_arg[0];
147 cout << "Error: \'" << an_arg;
148 cout << "\' is not a valid run mode for -m argument" << endl;
153 else if (an_arg == "-w") // alternate window size arg
155 *window = atoi(* ++argv);
158 else if (an_arg == "-t") // alternate threshold arg
160 *threshold = atoi(* ++argv);
163 else if (an_arg == "-et") // alternate entropy threshold arg
165 *ent_thres = atof(* ++argv);
172 *a_file_path = an_arg;
178 //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
179 cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;