COPASI API  4.16.103
DefaultplotDialog.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/DefaultplotDialog.cpp,v $
3 // $Revision: 1.12 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/11/29 13:55:53 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #include "DefaultplotDialog.h"
15 
16 #include "qtUtilities.h"
17 
18 #include "utilities/CCopasiTask.h"
21 
22 /*
23  * Constructs a DefaultPlotDialog as a child of 'parent', with the
24  * name 'name' and widget flags set to 'f'.
25  *
26  * The dialog will by default be modeless, unless you set 'modal' to
27  * true to construct a modal dialog.
28  */
29 DefaultPlotDialog::DefaultPlotDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
30  : QDialog(parent, fl)
31 {
32  setObjectName(QString::fromUtf8(name));
33  setModal(modal);
34  setupUi(this);
35 }
36 
37 /*
38  * Destroys the object and frees any allocated resources
39  */
41 {
42  // no need to delete child widgets, Qt does it all for us
43 }
44 
46 {
47  if (!mpTask) return;
48 
49  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
51  assert(pDataModel != NULL);
52 
54  this->accept();
55  else
56  this->reject();
57 }
58 
60 {
61  mpTask = t;
62 
63  fillList();
64 }
65 
67 {
68  if (mpCheckAll->isChecked())
69  mList = COutputAssistant::getListOfDefaultOutputDescriptions(NULL); //this gets the complete list
70  else
71  mList = COutputAssistant::getListOfDefaultOutputDescriptions(mpTask); //only the items fitting the task
72 
73  listBox->clear();
74 
75  std::vector<C_INT32>::const_iterator it, itEnd = mList.end();
76 
77  QStringList Items;
78 
79  for (it = mList.begin(); it != itEnd; ++it)
80  {
81  QString Name = FROM_UTF8(COutputAssistant::getItemName(*it));
82 
83  if (!Name.startsWith("--")) Name = " " + Name;
84 
85  Items.append(Name);
86  }
87 
88  listBox->insertItems(0, Items);
89 
90  listBox->item(0)->setSelected(true);
91 }
92 
94 {
95  if (!mpTask) return;
96 
97  int i = listBox->currentRow();
98 
99  if (i >= 0)
100  {
101  mIndex = mList[i];
102  lineEditTitle->setText(FROM_UTF8(COutputAssistant::getItemName(mIndex)));
103  textEdit->setText(FROM_UTF8(COutputAssistant::getItem(mIndex).description));
104 
105  createButton->setEnabled(!lineEditTitle->text().startsWith("-- "));
106  }
107  else //Listbox is emtpy, so there is no current row (-1)
108  {
109  mIndex = 0;
110  lineEditTitle->setText("");
111  textEdit->setText("");
112 
113  createButton->setEnabled(false);
114  }
115 }
116 
117 //virtual
119 {
120  fillList();
121 }
122 
CCopasiTask * mpTask
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual void setTask(CCopasiTask *t)
static const std::string & getItemName(C_INT32 id)
static CCopasiObject * createDefaultOutput(C_INT32 id, CCopasiTask *task, CCopasiDataModel *pDataModel, bool activate=true)
DefaultPlotDialog(QWidget *parent=0, const char *name=0, bool modal=false, Qt::WindowFlags fl=0)
static std::vector< C_INT32 > getListOfDefaultOutputDescriptions(const CCopasiTask *task=NULL)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
virtual void slotCreate()
connected to create button
std::vector< C_INT32 > mList
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
static const CDefaultOutputDescription & getItem(C_INT32 id)
virtual void slotSelect()
called when selection in listbox is changed
virtual void slotToggleAll(bool flag)
connected to check box