55 #include <sbml/SBMLDocument.h>
56 #include <sbml/packages/render/sbml/RenderPoint.h>
57 #include <sbml/packages/render/sbml/Text.h>
58 #include <sbml/packages/layout/sbml/LineSegment.h>
66 #if LIBSBML_VERSION >= 50400
67 #include <sbml/packages/layout/extension/LayoutModelPlugin.h>
71 #include <QNetworkAccessManager>
72 #include <QNetworkRequest>
73 #include <QNetworkReply>
91 mpSBMLExportString(NULL),
96 mSBMLExportIncomplete(true),
97 mSBMLExportCOPASIMIRIAM(true),
101 , mSEDMLImportString()
102 , mpSEDMLExportString(NULL)
105 , mSEDMLExportIncomplete(true)
106 , mSEDMLExportCOPASIMIRIAM(true)
127 assert(pDataModel != NULL);
129 std::set< ListViews * >::iterator it =
mListViews.begin();
130 std::set< ListViews * >::iterator end =
mListViews.end();
132 for (; it != end; ++it)
134 (*it)->setDataModel(
this);
143 #ifdef WITH_MERGEMODEL
145 void DataModelGUI::addModel(
const std::string & fileName)
157 void DataModelGUI::addModelRun()
176 if (
mSuccess && pModel && pMergeModel)
183 void DataModelGUI::addModelFinished()
339 if (pFunctionDB == NULL)
return;
341 pFunctionDB->
save(fileName);
348 if (pFunctionDB == NULL)
return;
350 if (pFunctionDB->
load(fileName))
446 void DataModelGUI::exportSBML(
const std::string & fileName,
bool overwriteFile,
int sbmlLevel,
int sbmlVersion,
bool exportIncomplete,
bool exportCOPASIMIRIAM)
530 if (reply != NULL && reply->error() == QNetworkReply::NoError)
532 std::string filename;
534 filename +=
"/miriam.xml";
536 QFile *miriamFile =
new QFile(filename.c_str());
538 if (miriamFile->open(QFile::WriteOnly))
540 miriamFile->write(reply->readAll());
553 reply->deleteLater();
574 QNetworkReply *reply =
dynamic_cast<QNetworkReply*
>(sender());
576 if (reply != NULL) reply->abort();
591 QNetworkAccessManager *manager =
new QNetworkAccessManager(
this);
593 connect(manager, SIGNAL(
finished(QNetworkReply*)),
596 QNetworkReply* reply = manager->get(QNetworkRequest(QUrl(
"http://www.ebi.ac.uk/miriam/main/export/xml/")));
597 connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
646 std::set< const CCopasiObject * > Objects;
655 for (; ppEntity != ppEntityEnd; ++ppEntity)
658 if ((*ppEntity)->getInitialExpression() !=
"" ||
664 (pMetab = dynamic_cast< CMetab * >(*ppEntity)) != NULL)
683 for (; itReaction != endReaction; ++itReaction)
687 for (i = 0, imax = Group.
size(); i < imax; i++)
716 QString
Message =
"Error while updating the initial values!\n\n";
720 QMessageBox::Ok, QMessageBox::Ok);
732 std::vector< Refresh * >::iterator it =
mUpdateVector.begin();
733 std::vector< Refresh * >::iterator end =
mUpdateVector.end();
735 for (; it != end; ++it)
748 std::set< ListViews * >::iterator it =
mListViews.begin();
749 std::set< ListViews * >::iterator end =
mListViews.end();
751 for (; it != end; ++it)
759 std::set< ListViews * >::iterator it =
mListViews.begin();
760 std::set< ListViews * >::iterator end =
mListViews.end();
762 for (; it != end; ++it)
764 (*it)->updateMIRIAMResourceContents();
770 std::set< ListViews * >::iterator it =
mListViews.begin();
771 std::set< ListViews * >::iterator end =
mListViews.end();
773 for (; it != end; ++it)
787 assert(pDataModel != NULL);
789 if (pDataModel != NULL)
793 if (pSBMLDocument != NULL &&
794 pSBMLDocument->getModel() != NULL &&
795 pSBMLDocument->getModel()->getAnnotation() != NULL)
800 if (foundNamespace.first ==
true)
812 CCopasiMessage(
CCopasiMessage::RAW,
"CellDesigner annotation was found in the file, but the version is not supported.\nPlease open the file in the latest version of CellDesigner and save it again.");
816 bool importCD =
false;
817 #if LIBSBML_VERSION >= 50400
819 LayoutModelPlugin* mplugin = (LayoutModelPlugin*)pSBMLDocument->getModel()->getPlugin(
"layout");
821 if (mplugin == NULL || (mplugin != NULL && mplugin->getNumLayouts() == 0))
827 if (importCD ||
CQMessageBox::question(NULL,
"CellDesigner import",
"A CellDesigner diagram was found in this file.\nDo you want to import the diagram?" , QMessageBox::Yes | QMessageBox::No , QMessageBox::No) == QMessageBox::Yes)
841 std::map<std::string, std::string> modelmap;
842 std::map<CCopasiObject*, SBase*>::const_iterator it;
843 std::map<CCopasiObject*, SBase*>::const_iterator itEnd = pDataModel->
getCopasi2SBMLMap().end();
851 s2 = it->first->getKey();
858 if ((s1 !=
"") && (s2 !=
""))
865 std::map<std::string, std::string> layoutmap;
866 std::map<std::string, std::string> idToKeyMap;
876 std::map<std::string, std::string> tmp;
889 CCopasiMessage(
CCopasiMessage::RAW,
"CellDesigner annotation was found in the file, but the version is not supported.\nPlease open the file in the latest version of CellDesigner and save it again.");
898 void DataModelGUI::importSEDMLFromString(
const std::string & sedmlDocumentText)
903 mSEDMLImportString = sedmlDocumentText;
906 connect(
mpThread, SIGNAL(
finished()),
this, SLOT(importSEDMLFromStringFinished()));
910 void DataModelGUI::importSEDMLFromStringRun()
924 void DataModelGUI::importSEDMLFromStringFinished()
926 mSEDMLImportString =
"";
934 disconnect(
mpThread, SIGNAL(
finished()),
this, SLOT(importSEDMLFromStringFinished()));
938 void DataModelGUI::importSEDML(
const std::string & fileName)
949 void DataModelGUI::importSEDMLRun()
963 void DataModelGUI::importSEDMLFinished()
973 disconnect(
mpThread, SIGNAL(
finished()),
this, SLOT(importSEDMLFinished()));
978 void DataModelGUI::exportSEDML(
const std::string & fileName,
bool overwriteFile,
int sedmlLevel,
int sedmlVersion,
bool exportIncomplete,
bool exportCOPASIMIRIAM)
985 mSEDMLLevel = sedmlLevel;
986 mSEDMLVersion = sedmlVersion;
987 mSEDMLExportIncomplete = exportIncomplete;
988 mSEDMLExportCOPASIMIRIAM = exportCOPASIMIRIAM;
995 void DataModelGUI::exportSEDMLFinished()
1000 disconnect(
mpThread, SIGNAL(
finished()),
this, SLOT(exportSEDMLFinished()));
1005 void DataModelGUI::exportSEDMLToString(std::string & sedmlDocumentText)
1010 mpSEDMLExportString = & sedmlDocumentText;
1013 connect(
mpThread, SIGNAL(
finished()),
this, SLOT(exportSEDMLToStringFinished()));
1017 void DataModelGUI::exportSEDMLToStringRun()
1031 void DataModelGUI::exportSEDMLToStringFinished()
1033 disconnect(
mpThread, SIGNAL(
finished()),
this, SLOT(exportSEDMLToStringFinished()));
1038 void DataModelGUI::exportSEDMLRun()
1051 #endif //COPASI_SEDML
void importSBMLFromStringRun()
const Layout * getLayout() const
COutputHandlerPlot mOutputHandlerPlot
SBMLDocument * getCurrentSBMLDocument()
CMIRIAMResources * mpMiriamResources
void buildChangedObjects()
Header file of class CModelEntity and CModelValue.
void exportSBMLToStringFinished()
void importSBML(const std::string &fileName)
bool updateMIRIAM(CMIRIAMResources &miriamResources)
void loadFunctionDB(const std::string &fileName)
bool notify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
void exportSBMLToStringRun()
static const XMLNode * findCellDesignerAnnotation(SBMLDocument *pDocument, const XMLNode *pAnnotation)
void exportMathModelRun()
void setDataModel(DataModelGUI *pDM)
void loadModel(const std::string &fileName)
static CProgressBar * create(QWidget *parent=0, const char *name=0, Qt::WindowModality windowModality=Qt::WindowModal)
CCopasiObject * getInitialValueReference() const
bool mSBMLExportIncomplete
COutputDefinitionVector & getPlotDefinitionList()
std::vector< Refresh * > mUpdateVector
void exportSBML(const std::string &fileName, bool overwriteFile, int sbmlLevel, int sbmlVersion, bool exportIncomplete, bool exportCOPASIMIRIAM=true)
void importSBMLFromStringFinished()
virtual bool progressItem(const size_t &handle)
CRecentFiles & getRecentFiles()
std::string mExportFormat
std::string mSBMLImportString
void miriamDownloadProgress(qint64 received, qint64 total)
bool updateMIRIAMResourcesFromFile(CProcessReport *pProcessReport, const std::string &filename)
static CLayout * createLayout(const Layout &sbmlLayout, const std::map< std::string, std::string > &modelmap, std::map< std::string, std::string > &layoutmap, const std::map< std::string, std::string > &globalIdToKeyMap, const CCopasiContainer *pParent=NULL)
std::set< ListViews * > mListViews
void importSBMLFinished()
static std::pair< bool, std::string > findCellDesignerNamespace(const SBMLDocument *pDocument)
void miriamDownloadFinished(QNetworkReply *)
void exportSBMLFinished()
static CConfigurationFile * getConfiguration()
std::vector< CType * >::const_iterator const_iterator
unsigned int mDownloadedBytes
void exportMathModelFinished()
CModelEntity ** endFixed()
void finished(bool success)
void saveFunctionDB(const std::string &fileName)
std::string * mpSBMLExportString
virtual bool setName(const std::string &name)
void refreshActiveParameterSet()
void addFile(const std::string &file)
void setOutputDefinitionVector(COutputDefinitionVector *pDefinitionVector)
void notifyView(ListViews::ObjectType objectType, ListViews::Action action, std::string key="")
void appendElementReferences(std::set< const CCopasiObject * > &objects) const
void setFramework(int framework)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
bool loadModel(std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
void refreshInitialValues()
CRecentFiles & getRecentSBMLFiles()
CListOfLayouts * getListOfLayouts()
CCopasiParameter * getParameter(const std::string &name)
CRecentFiles & getRecentSEDMLFiles()
CProgressBar * mpProgressBar
void deregisterListView(ListViews *pListView)
static CFunctionDB * getFunctionList()
static void getValue(const std::string &name, CType &value)
bool save(const std::string &fileName)
void addLayout(CLayout *layout, const std::map< std::string, std::string > &m)
static CCopasiDataModel * addDatamodel()
void saveModel(const std::string &fileName, bool overwriteFile=false)
DataModelGUI(QObject *parent)
unsigned int mDownloadedTotalBytes
static std::string getIdFromSBase(const SBase *s)
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void exportSBMLToString(std::string &sbmlDocumentText)
bool compileIfNecessary(CProcessReport *pProcessReport)
const CStateTemplate & getStateTemplate() const
static CCopasiMessage getLastMessage()
void registerListView(ListViews *pListView)
void linkDataModelToGUI()
CCopasiVectorNS< CReaction > & getReactions()
static double determineVersion(const XMLNode *pNode)
std::set< const CCopasiObject * > mChangedObjects
void importSBMLFromString(const std::string &sbmlDocumentText)
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
void exportMathModel(const std::string &fileName, const std::string &filter, bool overwriteFile=false)
void importCellDesigner()
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
void updateMIRIAMResourceContents()
std::map< CCopasiObject *, SBase * > & getCopasi2SBMLMap()
CModelEntity ** getEntities()
bool mSBMLExportCOPASIMIRIAM
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)