COPASI API  4.16.103
CQProgressItemBar.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQProgressItemBar.cpp,v $
3 // $Revision: 1.10 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/05/17 13:10:18 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 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 #include "CQProgressItemBar.h"
20 #include "CQProgressItem.h"
21 #include "qtUtilities.h"
22 
23 /*
24  * Constructs a CQProgressItemBar which is a child of 'parent', with the
25  * name 'name'.'
26  */
27 CQProgressItemBar::CQProgressItemBar(QWidget* parent, const char* name)
28  : CQProgressItem(parent, name)
29 {
30  Ui::CQProgressItemBar::setupUi(this);
31 
32  init();
33 }
34 
35 /*
36  * Destroys the object and frees any allocated resources
37  */
39 {
40  destroy();
41  // no need to delete child widgets, Qt does it all for us
42 }
43 
44 
46 {
47  mpItem = pItem;
48  mValue = mpItem->getValue();
49  mEnd = mpItem->getEndValue();
50 
51  mItemName->setText(FROM_UTF8(mpItem->getObjectName()));
52  mProgressBar->setMinimum(0);
53  mProgressBar->setMaximum(100);
54 
55  mLastSet = -1; // indicates was never set;
56 
57  // needed so that reset() does allocation
58  if (mStart.pVOID != NULL) destroy();
59 
60  return reset();
61 }
62 
64 {
65  (this->*mpSetValue)();
66 
67  if (mCurrentValue != mLastSet)
68  {
69  mProgressBar->setValue(mCurrentValue);
71  }
72 
73  return true;
74 }
75 
77 {
78  switch (mpItem->getType())
79  {
82 
83  if (!mStart.pDOUBLE)
84  mStart.pDOUBLE = new C_FLOAT64;
85 
87  mFactor = 100.0 / (* mEnd.pDOUBLE - * mStart.pDOUBLE);
89  break;
90 
92 
93  if (!mStart.pINT)
94  mStart.pINT = new C_INT32;
95 
96  * mStart.pINT = * mValue.pINT;
97  mFactor = 100.0 / ((C_FLOAT64)(* mEnd.pINT - * mStart.pINT));
99  break;
100 
102 
103  if (!mStart.pUINT)
104  mStart.pUINT = new unsigned C_INT32;
105 
106  * mStart.pUINT = * mValue.pUINT;
107  mFactor = 100.0 / ((C_FLOAT64)(* mEnd.pUINT - * mStart.pUINT));
109  break;
110 
111  default:
112  break;
113  }
114 
115  return process();
116 }
117 
120 
123 
126 
128 {
129  if (mpItem == NULL) return;
130 
131  switch (mpItem->getType())
132  {
136  break;
137 
140  break;
141 
144  break;
145 
146  default:
147  break;
148  }
149 }
150 
152 {
153  mpItem = NULL;
154  mStart.pVOID = NULL;
155 }
CCopasiParameter::Value mValue
#define pdelete(p)
Definition: copasi.h:215
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
virtual bool initFromProcessReportItem(CProcessReportItem *pItem)
virtual bool process()
#define C_INT32
Definition: copasi.h:90
virtual bool reset()
void(CQProgressItemBar::* mpSetValue)()
const CCopasiParameter::Type & getType() const
const Value & getValue() const
const CCopasiParameter::Value & getEndValue() const
CProcessReportItem * mpItem
unsigned C_INT32 * pUINT
virtual void setValueFromDOUBLE()
virtual void setValueFromUINT()
#define C_FLOAT64
Definition: copasi.h:92
virtual void setValueFromINT()
CQProgressItemBar(QWidget *parent=0, const char *name=0)
CCopasiParameter::Value mStart
CCopasiParameter::Value mEnd