1 #include <boost/filesystem/operations.hpp>
2 using namespace boost::filesystem;
5 #include "py/python.hpp"
8 #include "qui/MussaWindow.hpp"
9 #include "qui/threading/ThreadManager.hpp"
10 #include "qui/threading/InterpreterThread.hpp"
11 #include "alg/parse_options.hpp"
12 #include "mussa_exceptions.hpp"
16 #include <QApplication>
19 #include <CoreFoundation/CoreFoundation.h>
22 std::string get_doc_dir()
25 CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
26 CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,
27 kCFURLPOSIXPathStyle);
28 const char *pathPtr = CFStringGetCStringPtr(macPath,
29 CFStringGetSystemEncoding());
30 std::string doc_dir(pathPtr);
31 qDebug("Path = %s", pathPtr);
35 return std::string(".");
39 int main(int argc, char **argv)
43 // if we're under unix and don't have a display, see if we can still run
45 opts.useGUI = getenv("DISPLAY") != 0;
46 if (opts.useGUI == false) {
47 std::clog << "DISPLAY not set, running in console mode only" << std::endl;
50 //opts.doc_dir = get_doc_dir();
51 QApplication app(argc, argv, opts.useGUI);
52 Q_INIT_RESOURCE(icons);
53 const QIcon mussa_icon(":/icons/mussa.png");
54 app.setWindowIcon(mussa_icon);
56 initialize_mussa(opts, argc, argv);
57 if (opts.analysis == 0) {
61 ThreadManager &thread = ThreadManagerFactory();
64 if (opts.runAsPythonInterpeter) {
65 // allow the user to keep the interpreter open even after
66 // closing all the windows
67 app.setQuitOnLastWindowClosed(false);
68 const InterpreterThread *interp = thread.create_interpreter();
69 // quit when the interpreter exits
70 QObject::connect(interp, SIGNAL(finished()),
74 #endif /* USE_PYTHON */
76 MussaWindow win(opts.analysis);
81 } catch (mussa_error e) {
83 } catch (boost::filesystem::filesystem_error e) {
87 catch( boost::python::error_already_set ) {
91 catch (std::runtime_error e) {
94 qFatal("unrecognized exception");