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

#include <HistoWidget.h>

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

Public Member Functions

 HistoWidget (QWidget *parent=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)
 
 ~HistoWidget ()
 
- 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 ()
 

Protected Attributes

const CCopasiObjectmpObjectX
 
- Protected Attributes inherited from CQPlotEditWidget
const CModelmpModel
 

Detailed Description

Definition at line 18 of file HistoWidget.h.

Constructor & Destructor Documentation

HistoWidget::HistoWidget ( QWidget *  parent = 0,
Qt::WindowFlags  fl = 0 
)

Definition at line 20 of file HistoWidget.cpp.

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

20  :
21  CQPlotEditWidget(parent, fl),
22  mpObjectX(NULL)
23 {
24  setupUi(this);
25 
26  mpBtnVariable->setIcon(CQIconResource::icon(CQIconResource::copasi));
27 }
const CCopasiObject * mpObjectX
Definition: HistoWidget.h:35
static const QIcon & icon(const IconID &id)
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CQPlotEditWidget(QWidget *parent=NULL, Qt::WindowFlags fl=0)
HistoWidget::~HistoWidget ( )

Definition at line 29 of file HistoWidget.cpp.

30 {
31  // no need to delete child widgets, Qt does it all for us
32 }

Member Function Documentation

void HistoWidget::buttonPressedX ( )
protectedvirtualslot

Definition at line 34 of file HistoWidget.cpp.

References CQPlotSubwidget::createHistograms(), FROM_UTF8, CCopasiObject::getObjectDisplayName(), CCopasiSelectionDialog::getObjectVector(), CQPlotEditWidget::mpModel, mpObjectX, and CQSimpleSelectionTree::NumericValues.

35 {
36  if (!mpModel) return;
37 
38  // mpObjectX = CCopasiSelectionDialog::getObjectSingle(this, CQSimpleSelectionTree::NUMERIC, mpObjectX);
39  //mpObjectX = CCopasiSelectionDialog::getObjectSingle(this, CQSimpleSelectionTree::PLOT_OBJECT, mpObjectX);
40 
41  std::vector< const CCopasiObject * > oldSelection;
42 
43  if (mpObjectX)
44  oldSelection.push_back(mpObjectX);
45 
46  std::vector< const CCopasiObject * > objects =
49  &oldSelection);
50 
51  if (objects.size() && objects[0])
52  {
53  mpObjectX = objects[0];
54  mpEditVariable->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
55  mpEditTitle->setText("Histogram: " + FROM_UTF8(mpObjectX->getObjectDisplayName()));
56  }
57  else
58  {
59  mpObjectX = NULL;
60  mpEditVariable->setText("");
61  mpEditTitle->setText("Histogram");
62  }
63 
64  //check if more than one object was selected...
65  if (objects.size() > 1)
66  {
67  CQPlotSubwidget * pParent;
68  QObject* tmp = this;
69 
70  while (!(pParent = dynamic_cast< CQPlotSubwidget * >(tmp)) && this)
71  tmp = tmp->parent();
72 
73  if (pParent) //tell the parent to create the remaining histogram descriptions.
74  pParent->createHistograms(objects, mpEditIncrement->text().toDouble());
75  }
76 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static std::vector< const CCopasiObject * > getObjectVector(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const std::vector< const CCopasiObject * > *pCurrentSelection=NULL)
const CCopasiObject * mpObjectX
Definition: HistoWidget.h:35
void createHistograms(std::vector< const CCopasiObject * >objects, const C_FLOAT64 &incr)
bool HistoWidget::LoadFromCurveSpec ( const CPlotItem curve)
virtual

Implements CQPlotEditWidget.

Definition at line 78 of file HistoWidget.cpp.

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

79 {
80  if (!curve)
81  {
82  // We need to reset the widget to defaults
83  mpEditTitle->setText("");
84 
85  mpObjectX = NULL;
86  mpEditVariable->setText("");
87 
88  mpEditIncrement->setText("");
89 
90  mpCheckBefore->setChecked(false);
91  mpCheckDuring->setChecked(true);
92  mpCheckAfter->setChecked(false);
93 
94  return true;
95  }
96 
97  if (curve->getType() != CPlotItem::histoItem1d) return false;
98 
99  if (curve->getChannels().size() != 1) return false;
100 
101  //title
102  mpEditTitle->setText(FROM_UTF8(curve->getTitle()));
103 
104  //variable
105  mpObjectX = NULL;
106  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
108  assert(pDataModel != NULL);
109 
110  if (curve->getChannels().size() >= 1)
111  mpObjectX = pDataModel->getDataObject(curve->getChannels()[0]);
112 
113  if (mpObjectX == pDataModel)
114  {
115  mpObjectX = NULL;
116  }
117 
118  if (mpObjectX != NULL)
119  mpEditVariable->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
120  else
121  mpEditVariable->setText("");
122 
123  //other parameters:
124  const void* tmp;
125 
126  if (!(tmp = curve->getValue("increment").pVOID)) return false;
127 
128  mpEditIncrement->setText(QString::number(*(const C_FLOAT64*)tmp));
129 
130  mpCheckBefore->setChecked(curve->getActivity() & COutputInterface::BEFORE);
131  mpCheckDuring->setChecked(curve->getActivity() & COutputInterface::DURING);
132  mpCheckAfter->setChecked(curve->getActivity() & COutputInterface::AFTER);
133 
134  return true; //TODO
135 }
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 * mpObjectX
Definition: HistoWidget.h:35
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
const COutputInterface::Activity & getActivity() const
Definition: CPlotItem.cpp:179
#define C_FLOAT64
Definition: copasi.h:92
const CCopasiParameter::Value & getValue(const std::string &name) const
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
bool HistoWidget::SaveToCurveSpec ( CPlotItem curve,
const CPlotItem original = NULL 
) const
virtual

Implements CQPlotEditWidget.

Definition at line 137 of file HistoWidget.cpp.

References COutputInterface::AFTER, COutputInterface::BEFORE, C_FLOAT64, C_INT32, COutputInterface::DURING, CPlotItem::getActivity(), CPlotItem::getChannels(), CCopasiObject::getCN(), CPlotItem::getTitle(), CPlotItem::getType(), CCopasiParameterGroup::getValue(), CPlotItem::histoItem1d, mpObjectX, CCopasiParameter::Value::pDOUBLE, CPlotItem::setActivity(), CPlotItem::setTitle(), CCopasiParameterGroup::setValue(), and TO_UTF8.

138 {
139 
140  C_INT32 Activity = 0;
141 
142  if (mpCheckBefore->isChecked()) Activity += COutputInterface::BEFORE;
143 
144  if (mpCheckDuring->isChecked()) Activity += COutputInterface::DURING;
145 
146  if (mpCheckAfter->isChecked()) Activity += COutputInterface::AFTER;
147 
148  std::string title = TO_UTF8(mpEditTitle->text());
150  C_FLOAT64 increment = mpEditIncrement->text().toDouble();
151 
152  bool thingsChanged = false;
153 
154  if (original != NULL)
155  {
156  if (original->getType() != CPlotItem::histoItem1d)
157  thingsChanged = true;
158 
159  if (thingsChanged || original->getTitle() != title)
160  thingsChanged = true;
161 
162  if (thingsChanged || *original->getValue("increment").pDOUBLE != increment)
163  thingsChanged = true;
164 
165  if (thingsChanged || original->getActivity() != Activity)
166  thingsChanged = true;
167 
168  if (thingsChanged || original->getChannels().size() != 1)
169  thingsChanged = true;
170 
171  if (thingsChanged || original->getChannels()[0] != name)
172  thingsChanged = true;
173  }
174  else thingsChanged = true;
175 
176  if (!thingsChanged)
177  return false;
178 
179  //title
180  curve->setTitle(title);
181 
182  //channels
183  curve->getChannels().clear();
184  curve->getChannels().push_back(CPlotDataChannelSpec(name));
185 
186  //other parameters: TODO
187  curve->setValue("increment", increment);
188 
189  curve->setActivity((COutputInterface::Activity) Activity);
190 
191  return true;
192 }
virtual CCopasiObjectName getCN() const
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
void setActivity(const COutputInterface::Activity &activity)
Definition: CPlotItem.cpp:161
const CCopasiObject * mpObjectX
Definition: HistoWidget.h:35
#define C_INT32
Definition: copasi.h:90
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
bool setValue(const std::string &name, const CType &value)
const COutputInterface::Activity & getActivity() const
Definition: CPlotItem.cpp:179
#define C_FLOAT64
Definition: copasi.h:92
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
const CCopasiParameter::Value & getValue(const std::string &name) const
const std::string & getTitle() const
Definition: CPlotItem.cpp:228
void setTitle(const std::string &title)
Definition: CPlotItem.cpp:233
void HistoWidget::setMultipleEditMode ( bool  mode)
virtual

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

Implements CQPlotEditWidget.

Definition at line 197 of file HistoWidget.cpp.

198 {
199  mpEditTitle->setEnabled(!mode);
200  mpEditVariable->setEnabled(!mode);
201  mpBtnVariable->setEnabled(!mode);
202 }

Member Data Documentation

const CCopasiObject* HistoWidget::mpObjectX
protected

Definition at line 35 of file HistoWidget.h.

Referenced by buttonPressedX(), LoadFromCurveSpec(), and SaveToCurveSpec().


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