COPASI API  4.16.103
COutputHandlerPlot.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 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) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <QtCore/QThread>
16 
17 #include "UI/copasiui3window.h"
18 
19 #include "copasi.h"
20 
21 #include "COutputHandlerPlot.h"
23 #include "plotwindow.h"
24 #include "copasi/UI/qtUtilities.h"
26 
29  mpDefinitionVector(NULL)
30 {}
31 
33  COutputHandler(src),
34  mpDefinitionVector(src.mpDefinitionVector)
35 {}
36 
38 {}
39 
40 bool COutputHandlerPlot::compile(std::vector< CCopasiContainer * > listOfContainer,
41  const CCopasiDataModel* pDataModel)
42 {
43  if (!mpDefinitionVector) return false;
44 
45  // This must only be executed in the main thread.
47  {
48  mInterfaces.clear();
49 
50  //step through the vector of specifications and create the plot windows
51  std::string key;
52 
53  size_t i, imax = mpDefinitionVector->size();
54 
55  for (i = 0; i < imax; i++)
56  {
57  CPlotSpecification * pSpecification = (*mpDefinitionVector)[i];
58 
59  if (pSpecification->isActive())
60  {
61  key = pSpecification->CCopasiParameter::getKey();
62 
63  if (!mPlotMap.count(key))
64  mPlotMap[key] = new PlotWindow(this, pSpecification, CopasiUI3Window::getMainWindow());
65  else if ("COPASI Plot: " + pSpecification->getTitle() !=
66  TO_UTF8(mPlotMap[key]->windowTitle()))
67  mPlotMap[key] = new PlotWindow(this, pSpecification, CopasiUI3Window::getMainWindow());
68  else
69  mPlotMap[key]->initFromSpec(pSpecification);
70 
71  mPlotMap[key]->show();
72 
73  mInterfaces.insert(mPlotMap[key]);
74  }
75  }
76  }
77 
78  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
79  return COutputHandler::compile(listOfContainer, pDataModel);
80 }
81 
83 {
84  std::map<std::string, PlotWindow*>::iterator it = mPlotMap.begin();
85  std::map<std::string, PlotWindow*>::iterator end = mPlotMap.end();
86 
87  for (; it != end; ++it)
88  if (it->second == pInterface)
89  {
90  mPlotMap.erase(it);
91  return;
92  }
93 
95  return;
96 }
97 
99 {mpDefinitionVector = pDefinitionVector;}
virtual void removeInterface(COutputInterface *pInterface)
virtual size_t size() const
static bool isMainThread()
const bool & isActive() const
static CopasiUI3Window * getMainWindow()
COutputDefinitionVector * mpDefinitionVector
std::map< std::string, PlotWindow * > mPlotMap
void setOutputDefinitionVector(COutputDefinitionVector *pDefinitionVector)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
std::set< COutputInterface * > mInterfaces
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
virtual void removeInterface(COutputInterface *pInterface)