copasi API  0.1
copasi/UI/copasiui3window.h
Go to the documentation of this file.
00001 // Begin CVS Header
00002 //   $Source: /fs/turing/cvs/copasi_dev/copasi/UI/copasiui3window.h,v $
00003 //   $Revision: 1.95.2.1 $
00004 //   $Name: Build-33 $
00005 //   $Author: aekamal $
00006 //   $Date: 2010/09/27 13:44:55 $
00007 // End CVS Header
00008 
00009 // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual
00010 // Properties, Inc., University of Heidelberg, and The University
00011 // of Manchester.
00012 // All rights reserved.
00013 
00014 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
00015 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
00016 // and The University of Manchester.
00017 // All rights reserved.
00018 
00019 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
00020 // Properties, Inc. and EML Research, gGmbH.
00021 // All rights reserved.
00022 
00023 #include <string>
00024 
00025 #include <QMainWindow>
00026 #include <QModelIndex>
00027 #include <QMap>
00028 
00029 #ifdef COPASI_SBW_INTEGRATION
00030 #include <QApplication>
00031 #include <QEvent>
00032 
00033 #define WIN32_LEAN_AND_MEAN
00034 #include <SBW/SBW.h>
00035 #undef DELETE
00036 #undef ERROR
00037 #undef TRUE
00038 #undef FALSE
00039 using namespace SystemsBiologyWorkbench;
00040 #else
00041 class SBWListener;
00042 #endif  // COPASI_SBW_INTEGRATION
00043 
00044 #include "../MIRIAM/CMIRIAMResource.h"
00045 
00046 //class QToolButton;
00047 class Q3ListViewItem;
00048 class ListViews;
00049 class DataModelGUI;
00050 class SliderDialog;
00051 class QAction;
00052 class ObjectBrowserDialog;
00053 class QComboBox;
00054 class CMIRIAMResources;
00055 class CMIRIAMResourceObject;
00056 class QEvent;
00057 class QActionGroup;
00058 class QThread;
00059 
00060 class CopasiUI3Window : public QMainWindow
00061 #ifdef COPASI_SBW_INTEGRATION
00062     // A SBW listener can catch messages from SBW ... used here to allow COPASI to be shut down
00063     , public SBWListener
00064 #endif // COPASI_SBW_INTEGRATION
00065 
00066 {
00067   Q_OBJECT
00068 
00069 public:
00070   static CopasiUI3Window * create();
00071   ~CopasiUI3Window();
00072 
00073   DataModelGUI* getDataModel();
00074 
00075   ListViews* getMainWidget();
00076 
00077   void checkPendingMessages();
00078   void suspendAutoSave(const bool & suspend);
00079 
00085   void importSBMLFromString(const std::string & sbmlDocumentText);
00086 
00087   std::string exportSBMLToString();
00088 
00089   QThread * getMainThread() const;
00090 
00091 protected:
00092   virtual void closeEvent(QCloseEvent* e);
00093 
00094   /*
00095    * This is used for doing drag-and-drop action (16.04.10)
00096    */
00097   void dragEnterEvent(QDragEnterEvent *event);
00098   void dropEvent(QDropEvent *event);
00099 
00100 public slots:
00101   void slotShowSliders(bool flag);
00102 
00107   void slotObjectBrowserDialogWasClosed();
00108 
00109   void autoSave();
00110 
00111 protected slots:
00112   void slotFileOpen(QString file = QString::null);
00113   void slotFileExamplesCopasiFiles(QString file = QString::null);
00114   void slotFileExamplesSBMLFiles(QString file = QString::null);
00115   bool slotFileSave();
00116   bool slotFileSaveAs(QString str = QString::null);
00117   void newDoc();
00118   void slotFilePrint();
00119   void slotImportSBML(QString file = QString::null);
00120   void slotExportSBML();
00121   void slotExportMathModel();
00122   void slotTutorialWizard();
00123   void about();
00124   void license();
00125   void aboutQt();
00126   void slotQuit();
00127   void slotPreferences();
00128   void slotConvertToIrreversible();
00129   void listViewsFolderChanged(const QModelIndex & index);
00130   void slotOpenRecentFile(QAction * pAction);
00131   void slotOpenRecentSBMLFile(QAction * pAction);
00132   bool slotRegistration();
00133   void slotCheckModel();
00134   void slotApplyInitialState();
00135   void slotUpdateInitialState();
00136   void slotFrameworkChanged(int index);
00137   void slotCapture();
00138   void slotUpdateMIRIAM();
00139   void slotExpandModel();
00140   void slotFontSelection();
00141 
00142 #ifdef WITH_MERGEMODEL
00143   void slotAddFileOpen(QString file = QString::null);
00144   void slotAddModel();
00145   void slotMergeModels();
00146 #endif
00147 
00148   // SBW: handle the custom events
00149   void customEvent(QEvent *);
00150 
00155   void slotShowObjectBrowserDialog(bool flag);
00156 
00157 private:
00158   CopasiUI3Window();
00159 
00160   void createActions();
00161   void createToolBar();
00162   void createMenuBar();
00163 
00164   void CleanUp();
00165 
00166   void updateTitle();
00167 
00168   void setApplicationFont();
00169 
00170   DataModelGUI* mpDataModelGUI; // to keep track of the data model..
00171   ListViews *mpListView;
00172   QComboBox * mpBoxSelectFramework;
00173 
00174   int newFlag;
00175   QString FixedTitle;
00176 
00177   QAction* mpaNew;
00178   QAction* mpaOpen;
00179   QAction* mpaOpenCopasiFiles;
00180   QAction* mpaOpenSBMLFiles;
00181   QAction* mpaSave;
00182   QAction* mpaSaveAs;
00183   QAction* mpaImportSBML;
00184   QAction* mpaExportSBML;
00185   QAction* mpaExportODE;
00186   QAction* mpaQuit;
00187   QAction* mpaObjectBrowser;
00188   QAction* mpaSliders;
00189   QAction* mpaCheckModel;
00190   QAction* mpaApplyInitialState;
00191   QAction* mpaUpdateInitialState;
00192   QAction* mpaCapture;
00193   QAction* mpaUpdateMIRIAM;
00194   QAction* mpaExpandModel;
00195   QAction* mpaFontSelectionDialog;
00196 
00197 #ifdef WITH_MERGEMODEL
00198   QAction* mpaAddModel;
00199   QAction* mpaMergeModels;
00200 #endif
00201   SliderDialog* mpSliders;
00202   ObjectBrowserDialog * mpObjectBrowser;
00203 
00204   bool mSaveAsRequired;
00205   QTimer *mpAutoSaveTimer;
00206   bool mSuspendAutoSave;
00207 
00208   //menus
00209   QMenu * mpMenuExamples;
00210   QMenu * mpMenuRecentFiles;
00211   QMap< QAction *, int > mRecentFilesActionMap;
00212   QActionGroup * mpRecentFilesActionGroup;
00213   void refreshRecentFileMenu();
00214 
00215   QMenu * mpMenuRecentSBMLFiles;
00216   QMap< QAction *, int > mRecentSBMLFilesActionMap;
00217   QActionGroup * mpRecentSBMLFilesActionGroup;
00218   void refreshRecentSBMLFileMenu();
00219 
00220   QMenu * mpTools;
00221 
00222   CMIRIAMResources * mpMIRIAMResources;
00223 
00224   QThread * mpMainThread;
00225 
00226 #ifdef COPASI_SBW_INTEGRATION
00227 public:
00231   class QSBWSBMLEvent : public QEvent
00232   {
00233   public:
00238     QSBWSBMLEvent(const std::string & SBMLModel);
00239 
00244     const std::string & getSBMLModel() const;
00245 
00246   private:
00250     std::string mSBML;
00251   };
00252 
00256   class QSBWShutdownEvent: public QEvent
00257   {
00258   public:
00259     QSBWShutdownEvent();
00260 
00261   };
00262 
00263   // We expose 2 methods to SBW, one to load an SBML file
00264   SystemsBiologyWorkbench::DataBlockWriter sbwAnalysis(SystemsBiologyWorkbench::Module from,
00265       SystemsBiologyWorkbench::DataBlockReader reader);
00266 
00267   // and another to return the SBML file COAPSI is currently working with
00268   SystemsBiologyWorkbench::DataBlockWriter sbwGetSBML(SystemsBiologyWorkbench::Module from,
00269       SystemsBiologyWorkbench::DataBlockReader reader);
00270 
00271   // This method must not be renamed as SBW calls it by name
00272   void registerMethods(SystemsBiologyWorkbench::MethodTable<CopasiUI3Window> & table);
00273 
00274   // as part of the SBWListener we tell SBW here, that we want to react on the shutdown event
00275   virtual void onShutdown();
00276 
00277 private:
00281   void sbwConnect();
00282 
00286   void sbwDisconnect();
00287 
00291   void sbwRegister();
00292 
00297   void sbwUnregister(const std::string & moduleName) const;
00298 
00302   void sbwRefreshMenu();
00303 
00310   std::vector< SystemsBiologyWorkbench::DataBlockReader > sbwFindServices(const std::string & category,
00311       const bool & recursive);
00312 
00313 protected slots:
00314   void sbwSlotMenuTriggered(QAction * pAction);
00315 
00316 private:
00320   SystemsBiologyWorkbench::ModuleImpl * mpSBWModule;
00321 
00325   QStringList mSBWAnalyzerModules;
00326 
00330   QStringList mSBWAnalyzerServices;
00331 
00335   QMap< QAction *, int > mSBWActionMap;
00336 
00340   QActionGroup * mpSBWActionGroup;
00341 
00345   QMenu * mpSBWMenu;
00346 
00350   QAction * mpSBWAction;
00351 
00355   bool mSBWIgnoreShutdownEvent;
00356 
00357 #endif // COPASI_SBW_INTEGRATION
00358 
00359 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines