COPASI API  4.16.103
CCopasiPlotSelectionDialog.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <QtGui/QLayout>
16 #include <QtGui/QWidget>
17 #include <QtGui/QPushButton>
18 #include <QtGui/QCheckBox>
19 #include <QtGui/QLabel>
20 #include <QtGui/QSplitter>
21 #include <QtGui/QHBoxLayout>
22 #include <QtGui/QVBoxLayout>
23 #include <QtGui/QDialogButtonBox>
24 
25 #include "copasi.h"
26 
28 #include "CCopasiSelectionWidget.h"
29 #include "qtUtilities.h"
30 #include "CQMessageBox.h"
31 #include "model/CModel.h"
32 #include "report/CCopasiObject.h"
33 
34 CCopasiPlotSelectionDialog::CCopasiPlotSelectionDialog(QWidget* parent, const char* name, bool modal, Qt::WFlags f):
35  QDialog(parent, f)
36  , mpExpertCheckBox(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 {
49  setObjectName(QString::fromUtf8(name));
50  setModal(modal);
51  mpMainLayout = new QVBoxLayout(this);
52 
53  mpSplitter = new QSplitter(this);
54  mpSplitter->setOrientation(Qt::Horizontal);
55  mpMainLayout->addWidget(mpSplitter);
56 
57  mpButtonBox = new QHBoxLayout(this);
58  mpMainLayout->addLayout(mpButtonBox);
59 
60  QDialogButtonBox* box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
61  mpButtonBox->addWidget(box);
62 
63  mpExpertCheckBox = new QCheckBox(this);
64  mpExpertCheckBox->setText("Expert Mode");
65  mpExpertCheckBox->setChecked(false);
66  mpButtonBox->addWidget(mpExpertCheckBox);
67 
68  mpXAxisSelectionBox = new QWidget(mpSplitter);
69  QVBoxLayout *vBox1 = new QVBoxLayout(mpXAxisSelectionBox);
70  mpXAxisSelectionBox->setLayout(vBox1);
71  mpXAxisSelectionBox->layout()->setContentsMargins(5, 5, 5, 5);
72 
73  mpYAxisSelectionBox = new QWidget(mpSplitter);
74  QVBoxLayout *vBox2 = new QVBoxLayout(mpYAxisSelectionBox);
75  mpYAxisSelectionBox->setLayout(vBox2);
76  mpYAxisSelectionBox->layout()->setContentsMargins(5, 5, 5, 5);
77 
78  mpXAxisLabel = new QLabel("X-Axis:", mpXAxisSelectionBox);
79  mpXAxisLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
80  mpXAxisSelectionBox->layout()->addWidget(mpXAxisLabel);
81 
82  mpYAxisLabel = new QLabel("Y-Axis:", mpYAxisSelectionBox);
83  mpYAxisLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
84  mpYAxisSelectionBox->layout()->addWidget(mpYAxisLabel);
85 
89  mpXAxisSelectionBox->layout()->addWidget(mpXAxisSelectionWidget);
90 
94  mpYAxisSelectionBox->layout()->addWidget(mpYAxisSelectionWidget);
95 
96  connect(box, SIGNAL(accepted()), this, SLOT(slotOKButtonClicked()));
97  connect(box, SIGNAL(rejected()), this, SLOT(slotCancelButtonClicked()));
98  connect(mpExpertCheckBox, SIGNAL(toggled(bool)), this, SLOT(slotExpertCheckBoxToggled(bool)));
99 
100  setTabOrder();
101 }
102 
104 {}
105 
107 {
108  QWidget::setTabOrder(this->mpExpertCheckBox, this->mpXAxisSelectionWidget);
109  QWidget::setTabOrder(this->mpXAxisSelectionWidget, this->mpYAxisSelectionWidget);
110  this->mpXAxisSelectionWidget->setFocus();
111 }
112 
114 {
115  // fill the selection vectors
118  std::string message = "";
119  bool showWarning = false;
120 
121  if (this->mpXAxisOutputVector->empty())
122  {
123  message += "X Axis";
124  showWarning = true;
125  }
126 
127  if (this->mpYAxisOutputVector->empty())
128  {
129  if (showWarning)
130  {
131  message += " and ";
132  }
133 
134  showWarning = true;
135  message += "Y Axis";
136  }
137 
138  if (showWarning)
139  {
140  message = "You did not select anything for the " + message + "!\nDo you want to proceed anyway?";
141 
142  if (CQMessageBox::question(this, "Empty Selection", FROM_UTF8(message), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No)
143  {
144  return;
145  }
146  }
147 
148  QDialog::done(QDialog::Accepted);
149 }
150 
152 {
153  QDialog::done(QDialog::Rejected);
154 }
155 
157 {
158  this->mpXAxisSelectionWidget->setExpertMode(checked);
159  this->mpYAxisSelectionWidget->setExpertMode(checked);
160 }
161 
162 void CCopasiPlotSelectionDialog::setOutputVectors(std::vector< const CCopasiObject * > * outputVector1,
163  std::vector< const CCopasiObject * > * outputVector2)
164 {
165  this->mpXAxisOutputVector = outputVector1;
167  this->mpYAxisOutputVector = outputVector2;
169 }
170 
172  const CQSimpleSelectionTree::ObjectClasses & classes)
173 {
174  this->mpXAxisSelectionWidget->populateTree(pModel, classes);
175  this->mpYAxisSelectionWidget->populateTree(pModel, classes);
176 }
void setExpertMode(bool expertMode)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
std::vector< const CCopasiObject * > * mpYAxisOutputVector
void setSingleSelection(bool singleSelection)
void setModel(CModel *model, const CQSimpleSelectionTree::ObjectClasses &classes)
void populateTree(const CModel *model, const CQSimpleSelectionTree::ObjectClasses &classes)
CCopasiSelectionWidget * mpYAxisSelectionWidget
void setOutputVector(std::vector< const CCopasiObject * > *outputVector)
CCopasiSelectionWidget * mpXAxisSelectionWidget
std::vector< const CCopasiObject * > * mpXAxisOutputVector
Definition: CModel.h:50
void setOutputVectors(std::vector< const CCopasiObject * > *outputVector1, std::vector< const CCopasiObject * > *outputVector2)
CCopasiPlotSelectionDialog(QWidget *parent=0, const char *name=0, bool modal=false, Qt::WFlags f=0)
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)