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 "gui/ConnWindow.hh"
12 #include "alg/mussa_class.hh"
13 #include "mussa_exceptions.hh"
18 parse_args(int argc, char **argv, string *a_file_path, int *window,
19 int *threshold, enum Mussa::analysis_modes *ana_mode, float *ent_thres);
22 int main(int argc, char **argv)
27 int window, threshold;
30 enum Mussa::analysis_modes ana_mode;
38 // yeah, its horrible to be passing these by reference, but I just don't see
39 // any other way without making parse_args part of MussaClass, which just
40 // seems wrong (args are after all, an io type thing, and the gui only mode
41 // will have it own way as well...
42 run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
43 &ana_mode, &ent_thres);
45 cout << "mussa: run mode = " << run_mode;
46 cout << "\tfile_path = "<< a_file_path << endl;
47 cout << "mussa: ent_thres = " << ent_thres << endl;
49 // if no error from parse args (run_mode = 'e', ie error), run in proper mode
52 if ((run_mode == 'f') || (run_mode == 'n'))
54 err_msg = an_analysis.load_mupa_file(a_file_path);
55 an_analysis.analyze(window, threshold, ana_mode, ent_thres);
56 //an_overlord.do_analysis();
60 err_msg = an_analysis.load(a_file_path);
61 //an_overlord.get_analysis();
63 // no longer needed, but still semi-useful reality check...
66 cout << "GTV - All Gui, All the Time\n";
71 if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
73 //an_overlord.spawnConnView(1000,500);
74 ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
76 // we have an analysis already if in these 2 modes
77 if ((run_mode == 'f') || (run_mode == 'v'))
78 a_conn_win->add_ana(&an_analysis);
84 cout << err_msg << endl;
89 // minimal arg reading function, not very robust to errors
91 parse_args(int argc, char **argv, string *a_file_path, int *window,
92 int *threshold, enum Mussa::analysis_modes *ana_mode, float *ent_thres)
98 // initialize these to 0 as flag if they are not changed
102 run_mode = 'e'; //error default if no run mode set implicitly or explicitly
103 *ana_mode = Mussa::TransitiveNway; // default to transitivie analyses mode
105 // no args means gui only mode
117 // see what alternate mode the user wants to run in
122 if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
123 run_mode = an_arg[0];
126 cout << "Error: \'" << an_arg;
127 cout << "\' is not a valid analysis mode for -a argument" << endl;
128 throw cmdline_error("not valid -a argument");
130 *a_file_path = * ++argv;
133 // alternate analyses modes
134 else if (an_arg == "-a")
138 // t = transitive, r = radial, e = entropy
139 if (an_arg == "t") *ana_mode = Mussa::TransitiveNway;
140 else if (an_arg == "r") *ana_mode = Mussa::RadialNway;
141 else if (an_arg == "e") *ana_mode = Mussa::EntropyNway;
144 cout << "Error: \'" << an_arg;
145 cout << "\' is not a valid run mode for -m argument" << endl;
146 throw cmdline_error("bad argument -m");
149 else if (an_arg == "-w") // alternate window size arg
151 *window = atoi(* ++argv);
154 else if (an_arg == "-t") // alternate threshold arg
156 *threshold = atoi(* ++argv);
159 else if (an_arg == "-et") // alternate entropy threshold arg
161 *ent_thres = atof(* ++argv);
168 *a_file_path = an_arg;
174 //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
175 cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;