COPASI API  4.16.103
CPlotItem.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/plot/CPlotItem.cpp,v $
3 // $Revision: 1.26 $
4 // $Name: $
5 // $Author: ssahle $
6 // $Date: 2012/05/02 23:41:49 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #include "CPlotItem.h"
24 #include "report/CKeyFactory.h"
25 #include "utilities/utility.h"
26 
27 const std::string CPlotItem::TypeName[] =
28 {
29  "Unset",
30  "2D Curve",
31  "Histogram",
32  "Banded Graph",
33  "Surface",
34 
35  "2D Plot",
36  "SimWiz",
37  ""
38 };
39 
40 const char* CPlotItem::XMLType[] =
41 {
42  "Unset",
43  "Curve2D",
44  "Histogram1DItem",
45  "BandedGraph",
46  "Surface",
47 
48  "Plot2D",
49  "SimWiz",
50  NULL
51 };
52 
53 const std::string CPlotItem::RecordingActivityName[] =
54 {
55  "",
56  "Before",
57  "During",
58  "",
59  "After"
60 };
61 
62 const char* CPlotItem::XMLRecordingActivity[] =
63 {
64  "NotSet",
65  "before",
66  "during",
67  "before&during",
68  "after",
69  "before&after",
70  "during&after",
71  "before&during&after",
72  NULL
73 };
74 
75 CPlotItem::CPlotItem(const std::string & name,
76  const CCopasiContainer * pParent,
77  const CPlotItem::Type & type):
78  CCopasiParameterGroup(TypeName[type], pParent, "PlotItem"),
79  mType(unset),
80  mActivity(),
81  mpXMLActivity(NULL)
82 {
83  //setObjectName(TypeName[mType]); //TODO
84  setObjectName(name);
85  setType(type); //to create the parameters
86 }
87 
89  const CCopasiContainer * pParent):
90  CCopasiParameterGroup(src, pParent),
91  mType(unset),
92  mActivity(),
93  mpXMLActivity(NULL),
94  channels(src.getChannels())
95 {
96  setType(src.mType);
97 }
98 
100 {
101  if (type == mType) return;
102 
103  if (mType != unset) clear();
104 
105  mType = type;
106 
107  //create parameters
108  if (type == curve2d || type == bandedGraph)
109  {
110  assertParameter("Line type", CCopasiParameter::UINT, (unsigned C_INT32) 0);
111  assertParameter("Line subtype", CCopasiParameter::UINT, (unsigned C_INT32) 0);
113  assertParameter("Symbol subtype", CCopasiParameter::UINT, (unsigned C_INT32) 0);
114  }
115 
116  if (type == histoItem1d)
117  {
119  }
120 
121  if (type == curve2d || type == histoItem1d || type == bandedGraph || type == surface)
122  {
123  assertParameter("Color", CCopasiParameter::STRING, std::string("auto"));
124 
125  mpXMLActivity =
126  assertParameter("Recording Activity", CCopasiParameter::STRING, std::string("during"))->getValue().pSTRING;
127 
129 
132  {
135  }
136  }
137 
138  if (type == plot2d)
139  {
140  assertParameter("log X", CCopasiParameter::BOOL, false);
141  assertParameter("log Y", CCopasiParameter::BOOL, false);
142  mpXMLActivity = NULL;
144  }
145 }
146 
148 {}
149 
151 {
152  //TODO: parametergroup cleanup
153 }
154 
156 {}
157 
159 {return mType;}
160 
162 {
163  switch (mType)
164  {
165  case curve2d:
166  case bandedGraph:
167  case histoItem1d:
168  case surface:
169  mActivity = activity;
171  break;
172 
173  default:
175  break;
176  }
177 }
178 
180 {
182 
183  switch (mType)
184  {
185  case curve2d:
186  case bandedGraph:
187  case histoItem1d:
188  case surface:
189 
190  if (!mpXMLActivity)
191  const_cast<CPlotItem *>(this)->mpXMLActivity =
192  getParameter("Recording Activity")->getValue().pSTRING;
193 
195 
196  if (Activity < COutputInterface::BEFORE ||
198  {
199  Activity = COutputInterface::DURING;
200  * mpXMLActivity = XMLRecordingActivity[Activity];
201  }
202 
203  const_cast<CPlotItem *>(this)->mActivity = Activity;
204 
205  break;
206 
207  default:
208  break;
209  }
210 
211  return mActivity;
212 }
213 
214 std::vector<CPlotDataChannelSpec> & CPlotItem::getChannels()
215 {return channels;}
216 
217 const std::vector<CPlotDataChannelSpec> & CPlotItem::getChannels() const
218 {return channels;}
219 
221 {return channels.size();}
222 
224 {
225  channels.push_back(channel);
226 }
227 
228 const std::string & CPlotItem::getTitle() const
229 {
230  return getObjectName();
231 }
232 
233 void CPlotItem::setTitle(const std::string & title)
234 {
235  setObjectName(title);
236 }
CPlotItem(const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const Type &type=curve2d)
Definition: CPlotItem.cpp:75
std::string * mpXMLActivity
Definition: CPlotItem.h:133
const std::string & getObjectName() const
std::vector< CPlotDataChannelSpec > channels
Definition: CPlotItem.h:135
virtual ~CPlotItem()
Definition: CPlotItem.cpp:147
void addChannel(const CPlotDataChannelSpec &channel)
Definition: CPlotItem.cpp:223
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
size_t getNumChannels() const
Definition: CPlotItem.cpp:220
void setActivity(const COutputInterface::Activity &activity)
Definition: CPlotItem.cpp:161
#define C_INT32
Definition: copasi.h:90
void initObjects()
Definition: CPlotItem.cpp:155
Type mType
Definition: CPlotItem.h:123
static const char * XMLType[]
Definition: CPlotItem.h:104
void setType(CPlotItem::Type type)
Definition: CPlotItem.cpp:99
COutputInterface::Activity mActivity
Definition: CPlotItem.h:128
static const std::string RecordingActivityName[]
Definition: CPlotItem.h:110
const Value & getValue() const
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
CCopasiParameter * getParameter(const std::string &name)
const COutputInterface::Activity & getActivity() const
Definition: CPlotItem.cpp:179
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
void cleanup()
Definition: CPlotItem.cpp:150
#define C_FLOAT64
Definition: copasi.h:92
static const char * XMLRecordingActivity[]
Definition: CPlotItem.h:115
CCopasiParameter * assertParameter(const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
bool setObjectName(const std::string &name)
void setTitle(const std::string &title)
Definition: CPlotItem.cpp:233
static const std::string TypeName[]
Definition: CPlotItem.h:99