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

#include <curve2dwidget.h>

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

Public Member Functions

 Curve2DWidget (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)
 
 ~Curve2DWidget ()
 
- 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 ()
 
virtual void typeChanged (int linetype)
 

Protected Attributes

const CCopasiObjectmpObjectX
 
const CCopasiObjectmpObjectY
 
- Protected Attributes inherited from CQPlotEditWidget
const CModelmpModel
 

Detailed Description

Definition at line 16 of file curve2dwidget.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file curve2dwidget.cpp.

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

24  :
25  CQPlotEditWidget(parent, fl),
26  mpObjectY(NULL),
27  mpObjectX(NULL)
28 {
29  setupUi(this);
30 
33 }
const CCopasiObject * mpObjectY
Definition: curve2dwidget.h:33
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)
const CCopasiObject * mpObjectX
Definition: curve2dwidget.h:34
Curve2DWidget::~Curve2DWidget ( )

Definition at line 38 of file curve2dwidget.cpp.

39 {
40  // no need to delete child widgets, Qt does it all for us
41 }

Member Function Documentation

void Curve2DWidget::buttonPressedX ( )
protectedvirtualslot

Definition at line 277 of file curve2dwidget.cpp.

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

278 {
279  if (!mpModel) return;
280 
283  mpObjectX);
284 
285  if (mpObjectX)
286  {
287  mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
288 
289  if (mpObjectY)
290  mpEditTitle->setText(FROM_UTF8(mpObjectY->getObjectDisplayName()
291  + "|"
293 
294  //TODO update tab title
295  }
296  else
297  mpEditX->setText("");
298 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const CCopasiObject * mpObjectY
Definition: curve2dwidget.h:33
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
const CCopasiObject * mpObjectX
Definition: curve2dwidget.h:34
void Curve2DWidget::buttonPressedY ( )
protectedvirtualslot

Definition at line 300 of file curve2dwidget.cpp.

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

301 {
302  if (!mpModel) return;
303 
306  mpObjectY);
307 
308  if (mpObjectY)
309  {
310  mpEditY->setText(FROM_UTF8(mpObjectY->getObjectDisplayName()));
311 
312  if (mpObjectX)
313  mpEditTitle->setText(FROM_UTF8(mpObjectY->getObjectDisplayName()
314  + "|"
316 
317  //TODO update tab title
318  }
319  else
320  mpEditY->setText("");
321 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CModel * mpModel
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const CCopasiObject * mpObjectY
Definition: curve2dwidget.h:33
static const CCopasiObject * getObjectSingle(QWidget *pParent, const CQSimpleSelectionTree::ObjectClasses &classes, const CCopasiObject *pCurrentObject=NULL)
const CCopasiObject * mpObjectX
Definition: curve2dwidget.h:34
bool Curve2DWidget::LoadFromCurveSpec ( const CPlotItem curve)
virtual

Implements CQPlotEditWidget.

Definition at line 43 of file curve2dwidget.cpp.

References COutputInterface::AFTER, COutputInterface::BEFORE, C_FLOAT64, C_INT32, CPlotItem::curve2d, COutputInterface::DURING, FROM_UTF8, CPlotItem::getActivity(), CPlotItem::getChannels(), CQPlotColors::getColor(), CPlotColors::getCopasiColorStr(), CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getDataObject(), CPlotColors::getNumCopasiColors(), CCopasiObject::getObjectDisplayName(), CPlotItem::getTitle(), CPlotItem::getType(), CCopasiParameterGroup::getValue(), mpObjectX, mpObjectY, CCopasiParameter::Value::pVOID, and typeChanged().

44 {
45  if (!curve)
46  {
47  // We need to reset the widget to defaults
48  mpEditTitle->setText("");
49 
50  mpObjectX = NULL;
51  mpEditX->setText("");
52 
53  mpObjectY = NULL;
54  mpEditY->setText("");
55 
56  mpBoxType->setCurrentIndex(0);
57  mpBoxLineSubType->setCurrentIndex(0);
58  mpBoxColor->clear();
59 
60  mpCheckBefore->setChecked(false);
61  mpCheckDuring->setChecked(true);
62  mpCheckAfter->setChecked(false);
63 
64  return true;
65  }
66 
67  if (curve->getType() != CPlotItem::curve2d) return false;
68 
69  //if (curve->getChannels().getSize != 2) return false;
70 
71  mpEditTitle->setText(FROM_UTF8(curve->getTitle()));
72 
73  //TODO: check if objects exist....
74  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
76  assert(pDataModel != NULL);
77  mpObjectX = mpObjectY = NULL;
78 
79  if (curve->getChannels().size() >= 1)
80  mpObjectX = pDataModel->getDataObject(curve->getChannels()[0]);
81 
82  if (curve->getChannels().size() >= 2)
83  mpObjectY = pDataModel->getDataObject(curve->getChannels()[1]);
84 
85  if (mpObjectX)
86  mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
87 
88  if (mpObjectY)
89  mpEditY->setText(FROM_UTF8(mpObjectY->getObjectDisplayName()));
90 
91  const void* tmp;
92 
93  //Type
94  if (!(tmp = curve->getValue("Line type").pVOID)) return false;
95 
96  unsigned C_INT32 linetype = *(unsigned C_INT32*)tmp;
97  mpBoxType->setCurrentIndex(linetype);
98 
99  typeChanged(linetype);
100 
101  //line subtype & width
102  if (linetype == 0 || linetype == 3)
103  {
104  if (!(tmp = curve->getValue("Line subtype").pVOID)) return false;
105 
106  mpBoxLineSubType->setCurrentIndex(*(unsigned C_INT32*)tmp);
107 
108  //mpBoxWidth
109  if (!(tmp = curve->getValue("Line width").pVOID)) return false;
110 
111  mpSpinBoxWidth->setValue(*(C_FLOAT64*)tmp);
112  }
113 
114  // points
115  if (linetype == 1)
116  {
117  if (!(tmp = curve->getValue("Line width").pVOID)) return false;
118 
119  mpSpinBoxWidth->setValue(*(C_FLOAT64*)tmp);
120  }
121 
122  //symbol type
123  if (linetype == 2 || linetype == 3)
124  {
125  if (!(tmp = curve->getValue("Symbol subtype").pVOID)) return false;
126 
127  mpBoxSymbolSubType->setCurrentIndex(*(unsigned C_INT32*)tmp);
128  }
129 
130  //color TODO
131  mpBoxColor->clear();
132  mpBoxColor->addItem("auto");
133  size_t i;
134 
135  for (i = 0; i < CQPlotColors::getNumCopasiColors(); ++i)
136  {
137  QColor color = CQPlotColors::getColor("auto", i);
138  QPixmap pix(12, 12);
139  QPainter painter(&pix);
140 
141  if (color.isValid())
142  {
143  painter.setPen(Qt::gray);
144  painter.setBrush(QBrush(color));
145  painter.drawRect(0, 0, 12, 12);
146  }
147 
148  QIcon icon;
149  icon.addPixmap(pix);
150 
151  mpBoxColor->addItem(icon, CQPlotColors::getCopasiColorStr(i).c_str());
152  }
153 
154  if (!(tmp = curve->getValue("Color").pVOID)) return false;
155 
156  std::string colorstr = *(std::string*)tmp;
157  int tmpindex;
158 
159  if ((tmpindex = mpBoxColor->findText(colorstr.c_str())) != -1)
160  mpBoxColor->setCurrentIndex(tmpindex);
161  else
162  {
163  QColor color = QColor(colorstr.c_str());
164  QPixmap pix(12, 12);
165  QPainter painter(&pix);
166 
167  if (color.isValid())
168  {
169  painter.setPen(Qt::gray);
170  painter.setBrush(QBrush(color));
171  painter.drawRect(0, 0, 12, 12);
172  }
173 
174  QIcon icon;
175  icon.addPixmap(pix);
176 
177  mpBoxColor->addItem(icon, colorstr.c_str());
178  mpBoxColor->setCurrentIndex(mpBoxColor->count() - 1);
179  }
180 
181  //channel
182  mpCheckBefore->setChecked(curve->getActivity() & COutputInterface::BEFORE);
183  mpCheckDuring->setChecked(curve->getActivity() & COutputInterface::DURING);
184  mpCheckAfter->setChecked(curve->getActivity() & COutputInterface::AFTER);
185 
186  return true; //TODO
187 }
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
static size_t getNumCopasiColors()
Definition: CPlotColors.cpp:36
static QColor getColor(std::string colorstr, size_t colorindex)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static std::string getCopasiColorStr(size_t index)
Definition: CPlotColors.cpp:17
virtual void typeChanged(int linetype)
std::vector< CPlotDataChannelSpec > & getChannels()
Definition: CPlotItem.cpp:214
#define C_INT32
Definition: copasi.h:90
const CCopasiObject * mpObjectY
Definition: curve2dwidget.h:33
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
const CCopasiObject * mpObjectX
Definition: curve2dwidget.h:34
bool Curve2DWidget::SaveToCurveSpec ( CPlotItem curve,
const CPlotItem original = NULL 
) const
virtual

Implements CQPlotEditWidget.

Definition at line 189 of file curve2dwidget.cpp.

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

190 {
191  //if (!(mpObjectX && mpObjectY)) return false;
192 
193  //curve->setType(CPlotItem::curve2d);
194 
195  std::string title = TO_UTF8(mpEditTitle->text());
196  unsigned C_INT32 lineType = (unsigned C_INT32)mpBoxType->currentIndex();
197  unsigned C_INT32 lineSubType = (unsigned C_INT32)mpBoxLineSubType->currentIndex();
198  unsigned C_INT32 symbolSubType = (unsigned C_INT32)mpBoxSymbolSubType->currentIndex();
199  C_FLOAT64 lineWidth = (C_FLOAT64)mpSpinBoxWidth->value();
200  std::string color = TO_UTF8(mpBoxColor->currentText());
201 
202  C_INT32 Activity = 0;
203 
204  if (mpCheckBefore->isChecked()) Activity += COutputInterface::BEFORE;
205 
206  if (mpCheckDuring->isChecked()) Activity += COutputInterface::DURING;
207 
208  if (mpCheckAfter->isChecked()) Activity += COutputInterface::AFTER;
209 
212 
213  bool thingsChanged = false;
214 
215  if (original != NULL)
216  {
217  // compare whether things changed
218  if (original->getTitle() != title)
219  thingsChanged = true;
220 
221  if (thingsChanged || original->getType() != CPlotItem::curve2d)
222  thingsChanged = true;
223 
224  if (thingsChanged || *original->getValue("Line type").pUINT != lineType)
225  thingsChanged = true;
226 
227  if (thingsChanged || *original->getValue("Line subtype").pUINT != lineSubType)
228  thingsChanged = true;
229 
230  if (thingsChanged || *original->getValue("Symbol subtype").pUINT != symbolSubType)
231  thingsChanged = true;
232 
233  if (thingsChanged || *original->getValue("Line width").pDOUBLE != lineWidth)
234  thingsChanged = true;
235 
236  if (thingsChanged || *original->getValue("Color").pSTRING != color)
237  thingsChanged = true;
238 
239  if (thingsChanged || original->getActivity() != Activity)
240  thingsChanged = true;
241 
242  if (thingsChanged || original->getChannels().size() != 2)
243  thingsChanged = true;
244 
245  if (thingsChanged || original->getChannels()[0] != xName)
246  thingsChanged = true;
247 
248  if (thingsChanged || original->getChannels()[1] != yName)
249  thingsChanged = true;
250  }
251  else thingsChanged = true;
252 
253  if (!thingsChanged)
254  return false;
255 
256  //title
257  curve->setTitle(title);
258 
259  //channels
260  curve->getChannels().clear();
261  curve->getChannels().push_back(CPlotDataChannelSpec(xName));
262  curve->getChannels().push_back(CPlotDataChannelSpec(yName));
263 
264  curve->setValue("Line type", lineType);
265  curve->setValue("Line subtype", lineSubType);
266  curve->setValue("Symbol subtype", symbolSubType);
267  curve->setValue("Line width", lineWidth);
268 
269  //color
270  curve->setValue("Color", color);
271 
272  curve->setActivity((COutputInterface::Activity) Activity);
273 
274  return true;
275 }
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 * mpObjectY
Definition: curve2dwidget.h:33
const CPlotItem::Type & getType() const
Definition: CPlotItem.cpp:158
bool setValue(const std::string &name, const CType &value)
unsigned C_INT32 * pUINT
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
const CCopasiObject * mpObjectX
Definition: curve2dwidget.h:34
void Curve2DWidget::setMultipleEditMode ( bool  mode)
virtual

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

Implements CQPlotEditWidget.

Definition at line 350 of file curve2dwidget.cpp.

351 {
352  mpEditTitle->setEnabled(!mode);
353  mpEditX->setEnabled(!mode);
354  mpEditY->setEnabled(!mode);
355  mpBtnX->setEnabled(!mode);
356  mpBtnY->setEnabled(!mode);
357 }
void Curve2DWidget::typeChanged ( int  linetype)
protectedvirtualslot

Definition at line 323 of file curve2dwidget.cpp.

Referenced by LoadFromCurveSpec().

324 {
325  if (linetype == 0 || linetype == 3 || linetype == 1)
326  {
327  mpBoxLineSubType->setEnabled(linetype != 1);
328  mpSpinBoxWidth->setEnabled(true);
329  }
330  else
331  {
332  mpBoxLineSubType->setEnabled(linetype == 1);
333  mpSpinBoxWidth->setEnabled(false);
334  }
335 
336  //symbol type
337  if (linetype == 2 || linetype == 3)
338  {
339  mpBoxSymbolSubType->setEnabled(true);
340  }
341  else
342  {
343  mpBoxSymbolSubType->setEnabled(false);
344  }
345 }

Member Data Documentation

const CCopasiObject* Curve2DWidget::mpObjectX
protected

Definition at line 34 of file curve2dwidget.h.

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

const CCopasiObject* Curve2DWidget::mpObjectY
protected

Definition at line 33 of file curve2dwidget.h.

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


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