1 #include <boost/filesystem/operations.hpp>
2 using namespace boost::filesystem;
5 #include "py/python.hpp"
6 extern "C" void initmussa();
7 //extern "C" void initmussaqui();
10 #include "qui/MussaWindow.hpp"
11 #include "qui/threading/ThreadManager.hpp"
12 #include "qui/threading/InterpreterThread.hpp"
13 #include "alg/parse_options.hpp"
14 #include "mussa_exceptions.hpp"
18 #include <QApplication>
21 #include <CoreFoundation/CoreFoundation.h>
24 std::string get_doc_dir()
27 CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
28 CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,
29 kCFURLPOSIXPathStyle);
30 const char *pathPtr = CFStringGetCStringPtr(macPath,
31 CFStringGetSystemEncoding());
32 std::string doc_dir(pathPtr);
33 qDebug("Path = %s", pathPtr);
37 return std::string(".");
41 int main(int argc, char **argv)
45 // if we're under unix and don't have a display, see if we can still run
47 opts.useGUI = getenv("DISPLAY") != 0;
48 if (opts.useGUI == false) {
49 std::clog << "DISPLAY not set, running in console mode only" << std::endl;
52 //opts.doc_dir = get_doc_dir();
53 QApplication app(argc, argv, opts.useGUI);
55 initialize_mussa(opts, argc, argv);
56 if (opts.analysis == 0) {
62 if (opts.runAsPythonInterpeter) {
63 ThreadManager &thread = ThreadManagerFactory();
64 // allow the user to keep the interpreter open even after
65 // closing all the windows
66 app.setQuitOnLastWindowClosed(false);
67 InterpreterThread *interp = thread.create_interpreter();
69 std::cerr << "Unable to initialize interpeter thread" << std::endl;
72 MussaPython *py = interp->get_py_ptr();
74 std::cerr << "Unable to initialize python interpreter" << std::endl;
77 py->add_module("mussa", &initmussa);
78 //py->add_module("mussaqui", &initmussaqui);
79 // quit when the interpreter exits
80 QObject::connect(interp, SIGNAL(finished()),
85 #endif /* USE_PYTHON */
87 MussaWindow *win = new MussaWindow(opts.analysis);
92 } catch (mussa_error e) {
94 } catch (boost::filesystem::filesystem_error e) {
98 catch( boost::python::error_already_set ) {
102 catch (std::runtime_error e) {
105 qFatal("unrecognized exception");