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);
54 Q_INIT_RESOURCE(icons);
55 const QIcon mussa_icon(":/icons/mussa.png");
56 app.setWindowIcon(mussa_icon);
58 initialize_mussa(opts, argc, argv);
59 if (opts.analysis == 0) {
63 ThreadManager &thread = ThreadManagerFactory();
66 if (opts.runAsPythonInterpeter) {
67 // allow the user to keep the interpreter open even after
68 // closing all the windows
69 app.setQuitOnLastWindowClosed(false);
70 InterpreterThread *interp = thread.create_interpreter();
72 std::cerr << "Unable to initialize interpeter thread" << std::endl;
75 MussaPython *py = interp->get_py();
77 std::cerr << "Unable to initialize python interpreter" << std::endl;
80 py->add_module("mussa", &initmussa);
81 py->add_module("mussaqui", &initmussaqui);
82 // quit when the interpreter exits
83 QObject::connect(interp, SIGNAL(finished()),
88 #endif /* USE_PYTHON */
90 MussaWindow win(opts.analysis);
95 } catch (mussa_error e) {
97 } catch (boost::filesystem::filesystem_error e) {
101 catch( boost::python::error_already_set ) {
105 catch (std::runtime_error e) {
108 qFatal("unrecognized exception");