COPASI API  4.16.103
Macros | Functions
ViewCurrentUI/main.cpp File Reference
#include <stdexcept>
#include <QtGui/QApplication>
#include <QtCore/QString>
#include "copasi.h"
#include "UI/CQCopasiApplication.h"
#include "UI/copasiui3window.h"
#include "UI/DataModelGUI.h"
#include "UI/CQMessageBox.h"
#include "CopasiDataModel/CCopasiDataModel.h"
#include "report/CCopasiRootContainer.h"
#include "function/CFunctionDB.h"
#include "function/CFunction.h"
#include "commandline/COptionParser.h"
#include "commandline/COptions.h"
#include <worker.h>
#include <arguments.h>
Include dependency graph for ViewCurrentUI/main.cpp:

Go to the source code of this file.

Macros

#define COPASI_MAIN
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

#define COPASI_MAIN

Definition at line 11 of file ViewCurrentUI/main.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 41 of file ViewCurrentUI/main.cpp.

References CCopasiRootContainer::addDatamodel(), COptions::compareValue(), CopasiUI3Window::create(), CQMessageBox::critical(), CCopasiRootContainer::destroy(), FROM_UTF8, COptions::getValue(), Arguments::handleCommandLine(), CCopasiRootContainer::init(), Arguments::isValid(), Arguments::prepareModel(), and CQCopasiApplication::setMainWindow().

42 {
43  CQCopasiApplication a(argc, argv);
44 
45  // parse args
46  Arguments args(argc, argv);
47 
48  if (args.handleCommandLine())
49  {
50  return 0;
51  }
52 
53  a.setAttribute(Qt::AA_DontShowIconsInMenus, false);
54 
55  Q_INIT_RESOURCE(copasi);
56 
57  // Parse the commandline options
58  try
59  {
60  // Create the root container but don't pass in any args past the executable name
61  CCopasiRootContainer::init(1, argv, true);
62  }
63  catch (copasi::option_error & msg)
64  {
65  CQMessageBox::critical(NULL, "Initialization Error",
66  msg.what(),
67  QMessageBox::Ok , QMessageBox::Ok);
68 
69  return 1;
70  }
71 
72 #ifdef Darwin
73  std::string PluginDir;
74 
75  COptions::getValue("CopasiDir", PluginDir);
76  PluginDir += "/Contents/plugins";
77 
78  QApplication::setLibraryPaths(QStringList(FROM_UTF8(PluginDir)));
79 #endif // Darwin
80 
81  // Create the global data model.
83 
84  // instantiate model and apply all changes
85  args.prepareModel();
86 
87  // Create the main application window.
89  Worker* pWorker = NULL;
90 #ifdef COPASI_SBW_INTEGRATION
91 
92  if (COptions::compareValue("SBWRegister", true))
93  goto finish;
94 
95 #endif // COPASI_SBW_INTEGRATION
96 
97  if (pWindow != NULL)
98  {
99  a.setMainWindow(pWindow);
100 
101  // pass control to the worker
102  if (args.isValid())
103  pWorker = new Worker(pWindow, &args);
104 
105  a.exec();
106  }
107 
108 finish:
109 
110  try // To suppress any access violations during destruction works only under Windows
111  {
112  if (pWorker != NULL)
113  {
114  delete pWorker;
115  pWorker = NULL;
116  }
117 
119  }
120  catch (...)
121  {}
122 
123  return 0;
124 }
Definition: worker.h:18
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
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)
static void init(int argc, char *argv[], const bool &withGui=false)