COPASI API  4.16.103
CopasiUI/main.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <stdexcept>
16 #include <locale.h>
17 
18 #include <QtGui/QApplication>
19 
20 #define COPASI_MAIN
21 
22 #include "copasi.h"
23 
24 #include "UI/CQCopasiApplication.h"
25 #include "UI/copasiui3window.h"
26 #include "UI/DataModelGUI.h"
27 #include "UI/CQMessageBox.h"
28 
31 #include "function/CFunctionDB.h"
32 #include "function/CFunction.h"
34 #include "commandline/COptions.h"
35 
36 #ifdef COPASI_SBW_INTEGRATION
37 // SBW includes
38 #include "SBW/SBW.h"
39 #include <sstream>
40 #endif // COPASI_SBW_INTEGRATION
41 
42 #ifdef Darwin
43 # include <QtCore/QDir>
44 # include "UI/qtUtilities.h"
45 #endif // Darwin
46 
47 int main(int argc, char *argv[])
48 {
49  // Fix for Issue 1377, if locale is not set to the default one, some
50  // numbers will be displayed in the systems default locale:
51  setlocale(LC_ALL, "C");
52 
53  // Fix of Issue with Text centering on OSX Mavericks
54 #ifdef Q_OS_MACX
55 
56  if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8)
57  {
58  // fix Mac OS X 10.9 (mavericks) font issue
59  // https://bugreports.qt-project.org/browse/QTBUG-32789
60  QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
61  }
62 
63 #endif
64 
65  CQCopasiApplication a(argc, argv);
66 
67  a.setAttribute(Qt::AA_DontShowIconsInMenus, false);
68 
69  Q_INIT_RESOURCE(copasi);
70 
71  // Parse the commandline options
72  try
73  {
74  // Create the root container.
75  CCopasiRootContainer::init(argc, argv, true);
76  }
77  catch (copasi::option_error & msg)
78  {
79  CQMessageBox::critical(NULL, "Initialization Error",
80  msg.what(),
81  QMessageBox::Ok , QMessageBox::Ok);
82 
83  return 1;
84  }
85 
86 #ifdef Darwin
87  std::string PluginDir;
88 
89  COptions::getValue("CopasiDir", PluginDir);
90  PluginDir += "/Contents/plugins";
91 
92  QApplication::setLibraryPaths(QStringList(FROM_UTF8(PluginDir)));
93 #endif // Darwin
94 
95  // Create the global data model.
97 
98  // Create the main application window.
100 
101 #ifdef COPASI_SBW_INTEGRATION
102 
103  if (COptions::compareValue("SBWRegister", true))
104  goto finish;
105 
106 #endif // COPASI_SBW_INTEGRATION
107 
108  if (pWindow != NULL)
109  {
110  a.setMainWindow(pWindow);
111  a.exec();
112  }
113 
114 finish:
115 
116  try // To suppress any access violations during destruction works only under Windows
117  {
118  pdelete(pWindow);
120  }
121  catch (...)
122  {}
123 
124  return 0;
125 }
#define pdelete(p)
Definition: copasi.h:215
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void setMainWindow(CopasiUI3Window *pMainWindow)
static bool compareValue(const std::string &name, const CType &value)
Definition: COptions.h:128
static CopasiUI3Window * create()
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
static CCopasiDataModel * addDatamodel()
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
int main(int argc, char *argv[])
static void init(int argc, char *argv[], const bool &withGui=false)