COPASI API  4.16.103
CQSpringLayoutParameterWindow.cpp
Go to the documentation of this file.
1 // Copyright (C) 2013 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
7 
8 #include <qwt_slider.h>
9 #include <qwt_scale_engine.h>
10 #include <QtGui/QWidget>
11 #include <QtGui/QVBoxLayout>
12 #include <QtGui/QLabel>
13 
14 CQSpringLayoutParameterWindow::CQSpringLayoutParameterWindow(const QString &title, QWidget *parent , Qt::WindowFlags flags)
15  : QDockWidget(title, parent, flags)
16 {
17  QWidget* pParaWidget = new QWidget(this);
18  QVBoxLayout* pLayout = new QVBoxLayout;
19  pParaWidget->setLayout(pLayout);
20  size_t i;
21 
22  for (i = 0; i < mLayoutParameters.values.size(); ++i)
23  {
24  QLabel* label = new QLabel(mLayoutParameters.names[i].c_str());
25  pLayout->addWidget(label);
26  QwtSlider* slider = new QwtSlider(pParaWidget, Qt::Horizontal, QwtSlider::BottomScale);
27 
28  if (mLayoutParameters.isLog[i])
29  {
30  slider->setScaleEngine(new QwtLog10ScaleEngine);
31  slider->setRange(log10(mLayoutParameters.min[i]), log10(mLayoutParameters.max[i]));
32  slider->setScale(mLayoutParameters.min[i], mLayoutParameters.max[i]);
33  slider->setValue(log10(mLayoutParameters.values[i]));
34  }
35  else
36  {
37  slider->setRange(mLayoutParameters.min[i], mLayoutParameters.max[i]);
38  slider->setValue(mLayoutParameters.values[i]);
39  }
40 
41  pLayout->addWidget(slider);
42  mLayoutSliders.push_back(slider);
43 
44  connect(slider, SIGNAL(valueChanged(double)), this, SLOT(slotLayoutSliderChanged()));
45  }
46 
47  setWidget(pParaWidget);
48  setVisible(false);
49 }
50 
52 {
53 }
54 
56 {
57  return mLayoutParameters;
58 }
59 
61 {
62  //std::cout << "slider..." << std::endl;
63  size_t i;
64 
65  for (i = 0; i < mLayoutSliders.size(); ++i)
66  {
67  if (mLayoutParameters.isLog[i])
68  mLayoutParameters.values[i] = pow(10, mLayoutSliders[i]->value());
69  else
70  mLayoutParameters.values[i] = mLayoutSliders[i]->value();
71  }
72 }
std::vector< QwtSlider * > mLayoutSliders
CCopasiSpringLayout::Parameters & getLayoutParameters()
CCopasiSpringLayout::Parameters mLayoutParameters
CQSpringLayoutParameterWindow(const QString &title, QWidget *parent=0, Qt::WindowFlags flags=0)
std::vector< std::string > names