COPASI API  4.16.103
Public Member Functions | Protected Slots | Protected Attributes | List of all members
BandedGraphWidget Class Reference

#include <BandedGraphWidget.h>

Inheritance diagram for BandedGraphWidget:
Inheritance graph
[legend]
Collaboration diagram for BandedGraphWidget:
Collaboration graph
[legend]

Public Member Functions

 BandedGraphWidget (QWidget *parent=0, const char *name=0, Qt::WindowFlags fl=0)
 
virtual bool LoadFromCurveSpec (const CPlotItem *curve)
 
virtual bool SaveToCurveSpec (CPlotItem *curve, const CPlotItem *original=NULL) const
 
virtual void setMultipleEditMode (bool mode)
 
 ~BandedGraphWidget ()
 
- Public Member Functions inherited from CQPlotEditWidget
 CQPlotEditWidget (QWidget *parent=NULL, Qt::WindowFlags fl=0)
 
virtual void setModel (const CModel *model)
 
virtual ~CQPlotEditWidget ()
 

Protected Slots

virtual void buttonPressedX ()
 
virtual void buttonPressedY ()
 
void buttonPressedYone ()
 
void buttonPressedYtwo ()
 

Protected Attributes

const CCopasiObjectmpObjectX
 
const CCopasiObjectmpObjectYone
 
const CCopasiObjectmpObjectYtwo
 
- Protected Attributes inherited from CQPlotEditWidget
const CModelmpModel
 

Detailed Description

Definition at line 18 of file BandedGraphWidget.h.

Constructor & Destructor Documentation

BandedGraphWidget::BandedGraphWidget ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WindowFlags  fl = 0 
)

Definition at line 36 of file BandedGraphWidget.cpp.

References CQIconResource::copasi, and CQIconResource::icon().

36  :
37  CQPlotEditWidget(parent, fl),
38  mpObjectYone(NULL),
39  mpObjectYtwo(NULL),
40  mpObjectX(NULL)
41 {
42  setupUi(this);
43 
45  mpBtnYone->setIcon(CQIconResource::icon(CQIconResource::copasi));
46  mpBtnYtwo->setIcon(CQIconResource::icon(CQIconResource::copasi));
47 }
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
static const QIcon & icon(const IconID &id)
const CCopasiObject * mpObjectX
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CQPlotEditWidget(QWidget *parent=NULL, Qt::WindowFlags fl=0)
BandedGraphWidget::~BandedGraphWidget ( )

Definition at line 52 of file BandedGraphWidget.cpp.

53 {
54  // no need to delete child widgets, Qt does it all for us
55 }

Member Function Documentation

void BandedGraphWidget::buttonPressedX ( )
protectedvirtualslot

Definition at line 189 of file BandedGraphWidget.cpp.

References FROM_UTF8, CCopasiObject::getObjectDisplayName(), CCopasiSelectionDialog::getObjectSingle(), CQPlotEditWidget::mpModel, mpObjectX, mpObjectYone, mpObjectYtwo, and CQSimpleSelectionTree::NumericValues.

190 {
191  if (!mpModel) return;
192 
195  mpObjectX);
196 
197  if (mpObjectX)
198  {
199  mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
200 
201  if (mpObjectYone)
203  mpEditTitle->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()
204  + "/"
206  + "|"
208  else
209  mpEditTitle->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()
210  + "|"
212 
213  //TODO update tab title
214  }
215  else
216  mpEditX->setText("");
217 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
const CCopasiObject * mpObjectX
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
virtual void BandedGraphWidget::buttonPressedY ( )
inlineprotectedvirtualslot

Definition at line 42 of file BandedGraphWidget.h.

References buttonPressedYone().

void BandedGraphWidget::buttonPressedYone ( )
protectedslot

Definition at line 220 of file BandedGraphWidget.cpp.

References FROM_UTF8, CCopasiObject::getObjectDisplayName(), CCopasiSelectionDialog::getObjectSingle(), CQPlotEditWidget::mpModel, mpObjectX, mpObjectYone, mpObjectYtwo, and CQSimpleSelectionTree::NumericValues.

Referenced by buttonPressedY().

221 {
222  if (!mpModel) return;
223 
226  mpObjectYone);
227 
228  if (mpObjectYone)
229  {
230  mpEditYone->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()));
231 
232  if (mpObjectX)
234  mpEditTitle->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()
235  + "/"
237  + "|"
239  else
240  mpEditTitle->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()
241  + "|"
243 
244  //TODO update tab title
245  }
246  else
247  mpEditYone->setText("");
248 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
const CCopasiObject * mpObjectX
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
void BandedGraphWidget::buttonPressedYtwo ( )
protectedslot

Definition at line 251 of file BandedGraphWidget.cpp.

References FROM_UTF8, CCopasiObject::getObjectDisplayName(), CCopasiSelectionDialog::getObjectSingle(), CQPlotEditWidget::mpModel, mpObjectX, mpObjectYone, mpObjectYtwo, and CQSimpleSelectionTree::NumericValues.

252 {
253  if (!mpModel) return;
254 
257  mpObjectYtwo);
258 
259  if (mpObjectYtwo)
260  {
261  mpEditYtwo->setText(FROM_UTF8(mpObjectYtwo->getObjectDisplayName()));
262 
263  if (mpObjectX)
265  mpEditTitle->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()
266  + "/"
268  + "|"
270  else
271  mpEditTitle->setText(FROM_UTF8(mpObjectYtwo->getObjectDisplayName()
272  + "|"
274 
275  //TODO update tab title
276  }
277  else
278  mpEditYtwo->setText("");
279 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
const CCopasiObject * mpObjectX
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
bool BandedGraphWidget::LoadFromCurveSpec ( const CPlotItem curve)
virtual

Implements CQPlotEditWidget.

Definition at line 58 of file BandedGraphWidget.cpp.

References COutputInterface::AFTER, CPlotItem::bandedGraph, COutputInterface::BEFORE, COutputInterface::DURING, FROM_UTF8, CPlotItem::getActivity(), CPlotItem::getChannels(), CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getDataObject(), CCopasiObject::getObjectDisplayName(), CPlotItem::getTitle(), CPlotItem::getType(), CCopasiParameterGroup::getValue(), mpObjectX, mpObjectYone, mpObjectYtwo, and CCopasiParameter::Value::pVOID.

59 {
60  if (!curve)
61  {
62  // We need to reset the widget to defaults
63  mpEditTitle->setText("");
64 
66 
67  mpEditX->setText("");
68  mpEditYone->setText("");
69  mpEditYtwo->setText("");
70 
71  mpCheckBefore->setChecked(false);
72  mpCheckDuring->setChecked(true);
73  mpCheckAfter->setChecked(false);
74 
75  return true;
76  }
77 
78  if (curve->getType() != CPlotItem::bandedGraph) return false;
79 
80  //if (curve->getChannels().getSize != 3) return false;
81 
82  mpEditTitle->setText(FROM_UTF8(curve->getTitle()));
83 
84  //TODO: check if objects exist....
87  assert(pDataModel != NULL);
89 
90  if (curve->getChannels().size() >= 1)
91  mpObjectX = pDataModel->getDataObject(curve->getChannels()[0]);
92 
93  if (curve->getChannels().size() >= 2)
94  mpObjectYone = pDataModel->getDataObject(curve->getChannels()[1]);
95 
96  if (curve->getChannels().size() >= 3)
97  {
98  mpObjectYtwo = pDataModel->getDataObject(curve->getChannels()[2]);
99 
100  if ((mpObjectYtwo->getObjectDisplayName() == "(CN)Root") && mpObjectYone)
101  mpObjectYtwo = mpObjectYone; // as long as we haven't a second Y-axis chooser, this has to suffice.
102  }
103 
104  if (mpObjectX)
105  mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
106 
107  if (mpObjectYone)
108  mpEditYone->setText(FROM_UTF8(mpObjectYone->getObjectDisplayName()));
109 
110  if (mpObjectYtwo)
111  mpEditYtwo->setText(FROM_UTF8(mpObjectYtwo->getObjectDisplayName()));
112 
113  const void* tmp;
114 
115  if (!(tmp = curve->getValue("Line type").pVOID)) return false;
116 
117  mpCheckBefore->setChecked(curve->getActivity() & COutputInterface::BEFORE);
118  mpCheckDuring->setChecked(curve->getActivity() & COutputInterface::DURING);
119  mpCheckAfter->setChecked(curve->getActivity() & COutputInterface::AFTER);
120 
121  return true;
122 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const COutputInterface::Activity & getActivity() const
Definition: CPlotItem.cpp:179
const CCopasiObject * mpObjectX
const CCopasiParameter::Value & getValue(const std::string &name) const
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
bool BandedGraphWidget::SaveToCurveSpec ( CPlotItem curve,
const CPlotItem original = NULL 
) const
virtual

Implements CQPlotEditWidget.

Definition at line 125 of file BandedGraphWidget.cpp.

References COutputInterface::AFTER, CPlotItem::bandedGraph, COutputInterface::BEFORE, C_INT32, COutputInterface::DURING, CPlotItem::getActivity(), CPlotItem::getChannels(), CCopasiObject::getCN(), CPlotItem::getTitle(), CPlotItem::getType(), mpObjectX, mpObjectYone, mpObjectYtwo, CPlotItem::setActivity(), CPlotItem::setTitle(), and TO_UTF8.

126 {
127  //curve->setType(CPlotItem::bandedGraph);
128 
129  std::string title = TO_UTF8(mpEditTitle->text());
130 
134 
135  C_INT32 Activity = 0;
136 
137  if (mpCheckBefore->isChecked()) Activity += COutputInterface::BEFORE;
138 
139  if (mpCheckDuring->isChecked()) Activity += COutputInterface::DURING;
140 
141  if (mpCheckAfter->isChecked()) Activity += COutputInterface::AFTER;
142 
143  bool thingsChanged = false;
144 
145  if (original != NULL)
146  {
147  // compare whether things changed
148  if (original->getTitle() != title)
149  thingsChanged = true;
150 
151  if (thingsChanged || original->getType() != CPlotItem::bandedGraph)
152  thingsChanged = true;
153 
154  if (thingsChanged || original->getActivity() != Activity)
155  thingsChanged = true;
156 
157  if (thingsChanged || original->getChannels().size() != 3)
158  thingsChanged = true;
159 
160  if (thingsChanged || original->getChannels()[0] != xName)
161  thingsChanged = true;
162 
163  if (thingsChanged || original->getChannels()[1] != yName1)
164  thingsChanged = true;
165 
166  if (thingsChanged || original->getChannels()[2] != yName2)
167  thingsChanged = true;
168  }
169  else thingsChanged = true;
170 
171  if (!thingsChanged)
172  return false;
173 
174  //title
175  curve->setTitle(title);
176 
177  //channels
178  curve->getChannels().clear();
179  curve->getChannels().push_back(CPlotDataChannelSpec(xName));
180  curve->getChannels().push_back(CPlotDataChannelSpec(yName1));
181  curve->getChannels().push_back(CPlotDataChannelSpec(yName2));
182 
183  curve->setActivity((COutputInterface::Activity) Activity);
184 
185  return true;
186 }
virtual CCopasiObjectName getCN() const
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
void setActivity(const COutputInterface::Activity &activity)
Definition: CPlotItem.cpp:161
#define C_INT32
Definition: copasi.h:90
const CCopasiObject * mpObjectYone
const CCopasiObject * mpObjectYtwo
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
const COutputInterface::Activity & getActivity() const
Definition: CPlotItem.cpp:179
const CCopasiObject * mpObjectX
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
void setTitle(const std::string &title)
Definition: CPlotItem.cpp:233
void BandedGraphWidget::setMultipleEditMode ( bool  mode)
virtual

In multiple edit mode, we don't want to edit name & channels

Implements CQPlotEditWidget.

Definition at line 21 of file BandedGraphWidget.cpp.

22 {
23  mpEditTitle->setEnabled(!mode);
24  mpEditX->setEnabled(!mode);
25  mpEditYone->setEnabled(!mode);
26  mpEditYtwo->setEnabled(!mode);
27  mpBtnX->setEnabled(!mode);
28  mpBtnYone->setEnabled(!mode);
29  mpBtnYtwo->setEnabled(!mode);
30 }

Member Data Documentation

const CCopasiObject* BandedGraphWidget::mpObjectX
protected
const CCopasiObject* BandedGraphWidget::mpObjectYone
protected
const CCopasiObject* BandedGraphWidget::mpObjectYtwo
protected

The documentation for this class was generated from the following files: