COPASI API  4.16.103
CPlotSelectionDialog.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CPlotSelectionDialog.cpp,v $
3  $Revision: 1.2 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2006/04/27 01:27:40 $
7  End CVS Header */
8 
9 // Copyright 2005 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc. and EML Research, gGmbH.
11 // All rights reserved.
12 
13 #include "CPlotSelectionDialog.h"
14 #include "qwidget.h"
15 #include "qpushbutton.h"
16 #include "qcheckbox.h"
17 #include "qlabel.h"
18 #include "qsplitter.h"
19 #include "SimpleSelectionWidget.h"
20 #include "ObjectBrowserWidget.h"
21 #include "qhbox.h"
22 #include "qvbox.h"
23 #include "model/CModel.h"
24 #include "report/CCopasiObject.h"
25 #include "copasi.h"
26 #include "qlayout.h"
27 
28 CPlotSelectionDialog::CPlotSelectionDialog(QWidget* parent, const char* name, bool modal, WFlags f):
29  QDialog(parent, name, modal, f)
30  , mpOKButton(NULL)
31  , mpCancelButton(NULL)
32  , mpExpertCheckBox(NULL)
33  , mpXAxisSimpleSelectionWidget(NULL)
34  , mpYAxisSimpleSelectionWidget(NULL)
35  , mpXAxisObjectBrowserWidget(NULL)
36  , mpYAxisObjectBrowserWidget(NULL)
37  , mpXAxisSelectionWidget(NULL)
38  , mpYAxisSelectionWidget(NULL)
39  , mpSplitter(NULL)
40  , mpButtonBox(NULL)
41  , mpMainLayout(NULL)
42  , mpXAxisLabel(NULL)
43  , mpYAxisLabel(NULL)
44  , mpXAxisSelectionBox(NULL)
45  , mpYAxisSelectionBox(NULL)
46  , mpXAxisOutputVector(NULL)
47  , mpYAxisOutputVector(NULL)
48  , mpXAxisTmpVector(new std::vector<CCopasiObject*>())
49  , mpYAxisTmpVector(new std::vector<CCopasiObject*>())
50 {
51  this->mpMainLayout = new QVBoxLayout(this);
52  this->mpMainLayout->setAutoAdd(true);
53 
54  this->mpSplitter = new QSplitter(this);
55  this->mpSplitter->setOrientation(Qt::Horizontal);
56 
57  this->mpButtonBox = new QHBox(this);
58  this->mpButtonBox->layout()->setAutoAdd(false);
59 
60  ((QHBoxLayout*)this->mpButtonBox->layout())->addStretch();
61 
62  this->mpOKButton = new QPushButton(this->mpButtonBox);
63  this->mpOKButton->setText("OK");
64  this->mpOKButton->setDefault(true);
65  this->mpButtonBox->layout()->add(this->mpOKButton);
66 
67  this->mpCancelButton = new QPushButton(this->mpButtonBox);
68  this->mpCancelButton->setText("Cancel");
69  this->mpButtonBox->layout()->add(this->mpCancelButton);
70 
71  this->mpExpertCheckBox = new QCheckBox(this->mpButtonBox);
72  this->mpExpertCheckBox->setText("Expert Mode");
73  this->mpExpertCheckBox->setChecked(false);
74  this->mpButtonBox->layout()->add(this->mpExpertCheckBox);
75 
76  ((QHBoxLayout*)this->mpButtonBox->layout())->addStretch();
77 
78  this->mpXAxisSelectionBox = new QVBox(this->mpSplitter);
79  this->mpXAxisSelectionBox->layout()->setMargin(5);
80  this->mpXAxisSelectionBox->layout()->setAutoAdd(false);
81 
82  this->mpYAxisSelectionBox = new QVBox(this->mpSplitter);
83  this->mpYAxisSelectionBox->layout()->setMargin(5);
84  this->mpYAxisSelectionBox->layout()->setAutoAdd(false);
85 
86  this->mpXAxisLabel = new QLabel("X-Axis:", this->mpXAxisSelectionBox);
87  this->mpXAxisLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
88  this->mpXAxisSelectionBox->layout()->add(this->mpXAxisLabel);
89 
90  this->mpYAxisLabel = new QLabel("Y-Axis:", this->mpYAxisSelectionBox);
91  this->mpYAxisLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
92  this->mpYAxisSelectionBox->layout()->add(this->mpYAxisLabel);
93 
94  this->mpXAxisSimpleSelectionWidget = new SimpleSelectionWidget(this->mpXAxisSelectionBox);
96  this->mpXAxisSimpleSelectionWidget->setSingleSelection(true);
97  this->mpXAxisSimpleSelectionWidget->setOutputVector(this->mpXAxisTmpVector);
98  this->mpXAxisSelectionBox->layout()->add(this->mpXAxisSelectionWidget);
99 
100  this->mpYAxisSimpleSelectionWidget = new SimpleSelectionWidget(this->mpYAxisSelectionBox);
102  this->mpYAxisSimpleSelectionWidget->setOutputVector(this->mpYAxisTmpVector);
103  this->mpYAxisSelectionBox->layout()->add(this->mpYAxisSelectionWidget);
104 
105  connect(this->mpOKButton, SIGNAL(clicked()), this, SLOT(slotOKButtonClicked()));
106  connect(this->mpCancelButton, SIGNAL(clicked()), this, SLOT(slotCancelButtonClicked()));
107  connect(this->mpExpertCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotExpertCheckBoxToggled(bool)));
108 
109  this->setTabOrder();
110 }
111 
113 {
114  pdelete(this->mpOKButton);
115  pdelete(this->mpCancelButton);
116  pdelete(this->mpExpertCheckBox);
117  pdelete(this->mpXAxisLabel);
118  pdelete(this->mpYAxisLabel);
125  pdelete(this->mpSplitter);
126  pdelete(this->mpButtonBox);
127  pdelete(this->mpMainLayout);
128  pdelete(this->mpXAxisTmpVector);
129  pdelete(this->mpYAxisTmpVector);
130 }
131 
133 {
134  QWidget::setTabOrder(this->mpOKButton, this->mpCancelButton);
135  QWidget::setTabOrder(this->mpCancelButton, this->mpExpertCheckBox);
136  QWidget::setTabOrder(this->mpExpertCheckBox, this->mpXAxisSelectionWidget);
137  QWidget::setTabOrder(this->mpXAxisSelectionWidget, this->mpYAxisSelectionWidget);
138  this->mpXAxisSelectionWidget->setFocus();
139 }
140 
142 {
143  // fill the selection vectors
144  if (this->mpXAxisOutputVector)
145  {
146  if (this->mpExpertCheckBox->isChecked())
147  {
148  this->mpXAxisTmpVector->clear();
150  }
151  else
152  {
153  if (this->mpXAxisSimpleSelectionWidget->isSingleSelection())
154  {
155  this->mpXAxisTmpVector->clear();
156  this->mpXAxisSimpleSelectionWidget->addButtonClicked();
157  }
158  }
159  unsigned int counter;
160  unsigned int maxCount = this->mpXAxisTmpVector->size();
161  this->mpXAxisOutputVector->clear();
162  for (counter = 0; counter < maxCount;++counter)
163  {
164  this->mpXAxisOutputVector->push_back(this->mpXAxisTmpVector->at(counter));
165  }
166  }
167  if (this->mpYAxisOutputVector)
168  {
169  if (this->mpExpertCheckBox->isChecked())
170  {
171  this->mpYAxisTmpVector->clear();
173  }
174  else
175  {
176  if (this->mpYAxisSimpleSelectionWidget->isSingleSelection())
177  {
178  this->mpYAxisTmpVector->clear();
179  this->mpYAxisSimpleSelectionWidget->addButtonClicked();
180  }
181  }
182  unsigned int counter;
183  unsigned int maxCount = this->mpYAxisTmpVector->size();
184  this->mpYAxisOutputVector->clear();
185  for (counter = 0; counter < maxCount;++counter)
186  {
187  this->mpYAxisOutputVector->push_back(this->mpYAxisTmpVector->at(counter));
188  }
189  }
190  QDialog::done(QDialog::Accepted);
191 }
192 
194 {
195  QDialog::done(QDialog::Rejected);
196 }
197 
199 {
200  this->mpXAxisSelectionWidget->hide();
201  this->mpYAxisSelectionWidget->hide();
202  this->mpXAxisSelectionBox->layout()->remove(this->mpXAxisSelectionWidget);
203  this->mpYAxisSelectionBox->layout()->remove(this->mpYAxisSelectionWidget);
204  if (checked)
205  {
206  if (!this->mpXAxisObjectBrowserWidget)
207  {
208  // create ObjectBrowserWidget objects
211  }
214  }
215 
216  else
217  {
220  }
221  this->mpXAxisSelectionBox->layout()->add(this->mpXAxisSelectionWidget);
222  this->mpYAxisSelectionBox->layout()->add(this->mpYAxisSelectionWidget);
223  this->mpXAxisSelectionWidget->show();
224  this->mpYAxisSelectionWidget->show();
225  this->setTabOrder();
226 }
227 
228 void CPlotSelectionDialog::setOutputVectors(std::vector<CCopasiObject*>* outputVector1, std::vector<CCopasiObject*>* outputVector2)
229 {
230  this->mpXAxisOutputVector = outputVector1;
231  this->mpYAxisOutputVector = outputVector2;
232 }
233 
235 {
236  this->mpXAxisSimpleSelectionWidget->populateTree(model);
237  this->mpYAxisSimpleSelectionWidget->populateTree(model);
238 }
SimpleSelectionWidget * mpYAxisSimpleSelectionWidget
#define pdelete(p)
Definition: copasi.h:215
void slotExpertCheckBoxToggled(bool checked)
std::vector< CCopasiObject * > * mpXAxisTmpVector
ObjectBrowserWidget * mpXAxisObjectBrowserWidget
std::vector< CCopasiObject * > * mpYAxisTmpVector
void setModel(CModel *model)
std::vector< CCopasiObject * > * mpXAxisOutputVector
ObjectBrowserWidget * mpYAxisObjectBrowserWidget
SimpleSelectionWidget * mpXAxisSimpleSelectionWidget
void setOutputVectors(std::vector< CCopasiObject * > *outputVector1, std::vector< CCopasiObject * > *outputVector2)
CPlotSelectionDialog(QWidget *parent=0, const char *name=0, bool modal=false, WFlags f=0)
Definition: CModel.h:50
std::vector< CCopasiObject * > * mpYAxisOutputVector