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

#include <CQMoietiesTaskResult.h>

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

Public Member Functions

void clear ()
 
 CQMoietiesTaskResult (QWidget *parent=0, const char *name=0)
 
virtual bool leave ()
 
void load ()
 
virtual void setFramework (int framework)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
 ~CQMoietiesTaskResult ()
 
- Public Member Functions inherited from CopasiWidget
 CopasiWidget (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
 
bool enter (const std::string &key)
 
CCopasiDataModelgetDataModel ()
 
bool getIgnoreUpdates ()
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Protected Attributes

CMoietiesTaskmpMoietiesTask
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Private Slots

void slotCreateGlobalQuantity (const QModelIndex &index)
 
void slotSave (void)
 

Private Member Functions

void init ()
 

Additional Inherited Members

- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 

Detailed Description

Definition at line 21 of file CQMoietiesTaskResult.h.

Constructor & Destructor Documentation

CQMoietiesTaskResult::CQMoietiesTaskResult ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 39 of file CQMoietiesTaskResult.cpp.

References init().

40  : CopasiWidget(parent, name)
41 {
42  setupUi(this);
43 
44  init();
45 }
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
CQMoietiesTaskResult::~CQMoietiesTaskResult ( )

Definition at line 50 of file CQMoietiesTaskResult.cpp.

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

Member Function Documentation

void CQMoietiesTaskResult::clear ( )

Definition at line 121 of file CQMoietiesTaskResult.cpp.

Referenced by update().

122 {
123  mpMoieties->setRowCount(0);
124  mpStoichiometry->setArrayAnnotation(NULL);
125  mpLinkMatrix->setArrayAnnotation(NULL);
126  mpReducedStoichiometry->setArrayAnnotation(NULL);
127 }
bool CQMoietiesTaskResult::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 132 of file CQMoietiesTaskResult.cpp.

References load(), mpMoietiesTask, and CopasiWidget::mpObject.

133 {
134  mpMoietiesTask = dynamic_cast< CMoietiesTask * >(mpObject);
135 
136  load();
137 
138  return true;
139 }
CCopasiObject * mpObject
Definition: copasiWidget.h:64
CMoietiesTask * mpMoietiesTask
void CQMoietiesTaskResult::init ( )
private

Definition at line 55 of file CQMoietiesTaskResult.cpp.

References COL_AMOUNT, COL_BTN, COL_EQUATION, COL_NUMBER, COL_SPECIES, CQIconResource::icon(), mpMoietiesTask, slotCreateGlobalQuantity(), CQIconResource::tool, and CQPushButtonDelegate::ToolButton.

Referenced by CQMoietiesTaskResult().

56 {
57  mpMoietiesTask = NULL;
58 
59  QImage ToolBtn;
60 
61  // Initialize the moieties tab
62  mpMoieties->setColumnCount(5);
63 
64  QTableWidgetItem * pItem = new QTableWidgetItem("Dependent Species");
65  mpMoieties->setHorizontalHeaderItem(COL_SPECIES, pItem);
66  pItem = new QTableWidgetItem("Total Particle Number");
67  mpMoieties->setHorizontalHeaderItem(COL_NUMBER, pItem);
68  pItem = new QTableWidgetItem("Total Amount");
69  mpMoieties->setHorizontalHeaderItem(COL_AMOUNT, pItem);
70  pItem = new QTableWidgetItem("");
71  mpMoieties->setHorizontalHeaderItem(COL_BTN, pItem);
72  pItem = new QTableWidgetItem("Expression");
73  mpMoieties->setHorizontalHeaderItem(COL_EQUATION, pItem);
74 
76  mpMoieties->setItemDelegateForColumn(COL_BTN, pDelegate);
77 
78  connect(pDelegate, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotCreateGlobalQuantity(const QModelIndex &)));
79 
80  // Initialize the stoichiometry tab
81  mpStoichiometry->setLegendEnabled(true);
82 
83  // Initialize the stoichiometry tab
84  mpLinkMatrix->setLegendEnabled(true);
85 
86  // Initialize the stoichiometry tab
87  mpReducedStoichiometry->setLegendEnabled(true);
88 }
#define COL_EQUATION
#define COL_NUMBER
static const QIcon & icon(const IconID &id)
#define COL_AMOUNT
CMoietiesTask * mpMoietiesTask
#define COL_SPECIES
#define COL_BTN
void slotCreateGlobalQuantity(const QModelIndex &index)
bool CQMoietiesTaskResult::leave ( )
virtual

Reimplemented from CopasiWidget.

Definition at line 129 of file CQMoietiesTaskResult.cpp.

130 {return true;}
void CQMoietiesTaskResult::load ( )

Definition at line 141 of file CQMoietiesTaskResult.cpp.

References CCopasiVector< T >::begin(), COL_AMOUNT, COL_BTN, COL_EQUATION, COL_NUMBER, COL_SPECIES, CCopasiVector< T >::end(), FROM_UTF8, CCopasiRootContainer::getDatamodelList(), CCopasiDataModel::getModel(), CModel::getMoieties(), CCopasiContainer::getObject(), and CModel::getQuantityUnitsDisplayString().

Referenced by enterProtected().

142 {
143  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
145  assert(pDataModel != NULL);
146  CModel * pModel = pDataModel->getModel();
147 
148  if (pModel == NULL) return;
149 
150  // Set the units for the amount column
151  QString AmountUnits = FROM_UTF8(pModel->getQuantityUnitsDisplayString());
152 
153  if (!AmountUnits.isEmpty())
154  AmountUnits = "\n(" + AmountUnits + ")";
155 
156  mpMoieties->horizontalHeaderItem(COL_AMOUNT)->setText("Total Amount" + AmountUnits);
157 
158  // Fill the moieties table
161  mpMoieties->setRowCount(end - it);
162 
163  QTableWidgetItem * pItem;
164  int i = 0;
165 
166  for (; it != end; ++it, i++)
167  {
168  pItem = new QTableWidgetItem(FROM_UTF8((*it)->getObjectName()));
169  mpMoieties->setItem(i, COL_SPECIES, pItem);;
170 
171  pItem = new QTableWidgetItem(QString::number((*it)->getNumber()));
172  mpMoieties->setItem(i, COL_NUMBER, pItem);
173 
174  (*it)->refreshAmount();
175  pItem = new QTableWidgetItem(QString::number((*it)->getAmount()));
176  mpMoieties->setItem(i, COL_AMOUNT, pItem);
177 
178  pItem = new QTableWidgetItem("");
179  mpMoieties->setItem(i, COL_BTN, pItem);
180 
181  // Show the Button
182  pItem = mpMoieties->item(i, COL_BTN);
183  pItem->setFlags(pItem->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled);
184  mpMoieties->openPersistentEditor(pItem);
185 
186  pItem = new QTableWidgetItem(FROM_UTF8((*it)->getDescription(pModel)));
187  mpMoieties->setItem(i, COL_EQUATION, pItem);
188  }
189 
190  mpTabWidget->setTabText(mpTabWidget->indexOf(mpMoieties), "Moieties (" + QString::number(i) + ")");
191 
192  mpMoieties->resizeColumnsToContents();
193  mpMoieties->resizeRowsToContents();
194 
195  // Fill the stoichiometry matrix
196  CColorScaleBiLog * tcs = NULL;
197  const CArrayAnnotation * pAnnotation =
198  static_cast< const CArrayAnnotation * >(pModel->getObject(CCopasiObjectName("Array=Stoichiometry(ann)")));
199  tcs = new CColorScaleBiLog();
200  mpStoichiometry->setColorCoding(tcs);
201  mpStoichiometry->setColorScalingAutomatic(true);
202  mpStoichiometry->setArrayAnnotation(pAnnotation);
203 
204  // Fill the link matrix
205  pAnnotation =
206  static_cast< const CArrayAnnotation * >(pModel->getObject(CCopasiObjectName("Array=Link matrix(ann)")));
207  tcs = new CColorScaleBiLog();
208  mpLinkMatrix->setColorCoding(tcs);
209  mpLinkMatrix->setColorScalingAutomatic(true);
210  mpLinkMatrix->setArrayAnnotation(pAnnotation);
211 
212  // Fill the reduced stoichiometry matrix
213  pAnnotation =
214  static_cast< const CArrayAnnotation * >(pModel->getObject(CCopasiObjectName("Array=Reduced stoichiometry(ann)")));
215  tcs = new CColorScaleBiLog();
216  mpReducedStoichiometry->setColorCoding(tcs);
217  mpReducedStoichiometry->setColorScalingAutomatic(true);
218  mpReducedStoichiometry->setArrayAnnotation(pAnnotation);
219 
220  return;
221 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
iterator begin()
#define COL_EQUATION
const CCopasiVector< CMoiety > & getMoieties() const
Definition: CModel.cpp:1163
iterator end()
#define COL_NUMBER
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
std::string getQuantityUnitsDisplayString() const
Definition: CModel.cpp:4647
#define COL_AMOUNT
#define COL_SPECIES
Definition: CModel.h:50
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
#define COL_BTN
void CQMoietiesTaskResult::setFramework ( int  framework)
virtual

Reimplemented from CopasiWidget.

Definition at line 280 of file CQMoietiesTaskResult.cpp.

References COL_AMOUNT, COL_NUMBER, CopasiWidget::mFramework, and CopasiWidget::setFramework().

281 {
282  CopasiWidget::setFramework(framework);
283 
284  switch (mFramework)
285  {
286  case 0: // Concentration
287  mpMoieties->showColumn(COL_AMOUNT);
288  mpMoieties->hideColumn(COL_NUMBER);
289  break;
290 
291  case 1: // Particle Number
292  mpMoieties->hideColumn(COL_AMOUNT);
293  mpMoieties->showColumn(COL_NUMBER);
294  break;
295  }
296 }
#define COL_NUMBER
#define COL_AMOUNT
virtual void setFramework(int framework)
void CQMoietiesTaskResult::slotCreateGlobalQuantity ( const QModelIndex &  index)
privateslot

Definition at line 253 of file CQMoietiesTaskResult.cpp.

References ListViews::ADD, C_INT32, CModel::createModelValue(), CCopasiRootContainer::getDatamodelList(), CMoiety::getExpression(), CModel::getMoieties(), CCopasiObject::getObjectName(), ListViews::MODELVALUE, CopasiWidget::protectedNotify(), CModelEntity::setInitialExpression(), CCopasiVector< T >::size(), and TO_UTF8.

Referenced by init().

254 {
255  int row = index.row();
256 
257  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
258  CModel * pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel();
259 
260  if (pModel == NULL) return;
261 
262  CCopasiVector< CMoiety > Moieties = pModel->getMoieties();
263 
264  if (row >= (C_INT32) Moieties.size()) return;
265 
266  const CMoiety * pMoiety = Moieties[row];
267 
268  CModelValue * pMV = pModel->createModelValue("Moiety[" + pMoiety->getObjectName() + "].TotalAmount");
269 
270  int i = 0;
271 
272  while (pMV == NULL)
273  pMV = pModel->createModelValue("Moiety[" + pMoiety->getObjectName() + "].TotalAmount_" + TO_UTF8(QString::number(++i)));
274 
275  pMV->setInitialExpression(pMoiety->getExpression());
277 }
const std::string & getObjectName() const
virtual size_t size() const
bool setInitialExpression(const std::string &expression)
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
#define C_INT32
Definition: copasi.h:90
const CCopasiVector< CMoiety > & getMoieties() const
Definition: CModel.cpp:1163
std::string getExpression() const
Definition: CMoiety.cpp:228
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual bool protectedNotify(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
Definition: CModel.h:50
void CQMoietiesTaskResult::slotSave ( void  )
privateslot

Definition at line 223 of file CQMoietiesTaskResult.cpp.

References C_INT32, checkSelection(), CLocaleString::fromUtf8(), CCopasiTask::getResult(), CopasiFileDialog::getSaveFileName(), mpMoietiesTask, and TO_UTF8.

224 {
225  C_INT32 Answer = QMessageBox::No;
226  QString fileName;
227 
228  while (Answer == QMessageBox::No)
229  {
230  fileName =
231  CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
232  "untitled.txt", "TEXT Files (*.txt)", "Save to");
233 
234  if (fileName.isEmpty()) return;
235 
236  // Checks whether the file exists
237  Answer = checkSelection(fileName);
238 
239  if (Answer == QMessageBox::Cancel) return;
240  }
241 
242  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());
243 
244  if (file.fail())
245  return;
246 
247  if (mpMoietiesTask != NULL)
248  file << mpMoietiesTask->getResult();
249 
250  return;
251 }
#define C_INT32
Definition: copasi.h:90
C_INT32 checkSelection(const QString &file)
const CResult & getResult() const
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
CMoietiesTask * mpMoietiesTask
static CLocaleString fromUtf8(const std::string &utf8)
static QString getSaveFileName(QWidget *parent=0, const char *name=0, const QString &startWith=QString::null, const QString &filter=QString::null, const QString &caption=QString::null, QString *pSelectedFilter=NULL, QFileDialog::Options options=0)
bool CQMoietiesTaskResult::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 90 of file CQMoietiesTaskResult.cpp.

References ListViews::ADD, ListViews::CHANGE, clear(), and ListViews::MODEL.

93 {
94  // :TODO:
95  switch (objectType)
96  {
97  case ListViews::MODEL:
98 
99  switch (action)
100  {
101  case ListViews::ADD:
102  clear();
103  break;
104 
105  case ListViews::CHANGE:
106  break;
107 
108  default:
109  break;
110  }
111 
112  break;
113 
114  default:
115  break;
116  }
117 
118  return true;
119 }
objectType

Member Data Documentation

CMoietiesTask* CQMoietiesTaskResult::mpMoietiesTask
protected

Definition at line 38 of file CQMoietiesTaskResult.h.

Referenced by enterProtected(), init(), and slotSave().


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