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

#include <CopasiSlider.h>

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

Public Slots

void closeButtonClicked ()
 
void editButtonClicked ()
 
void qSliderPressed ()
 
void qSliderReleased ()
 
void sliderValueChanged (int value)
 

Signals

void closeClicked (CopasiSlider *slider)
 
void editClicked (CopasiSlider *slider)
 
void sliderPressed ()
 
void sliderReleased ()
 
void valueChanged (double)
 

Public Member Functions

 CopasiSlider (CSlider *pSlider, DataModelGUI *pDM, QWidget *parent=0)
 
void focusSlider ()
 
CSlidergetCSlider () const
 
bool isValid () const
 
C_FLOAT64 maxValue () const
 
unsigned C_INT32 minorMajorFactor () const
 
C_FLOAT64 minorTickInterval () const
 
C_FLOAT64 minValue () const
 
unsigned C_INT32 numMinorTicks () const
 
CCopasiObjectobject () const
 
C_FLOAT64 originalValue () const
 
void resetValue ()
 
void setMaxValue (C_FLOAT64 value)
 
void setMinorMajorFactor (unsigned C_INT32 factor)
 
void setMinValue (C_FLOAT64 value)
 
void setNumMinorTicks (unsigned C_INT32 numMinorTicks)
 
void setObject (CCopasiObject *object)
 
void setOriginalValue (C_FLOAT64 value)
 
void setType (CSlider::Type type)
 
void setValue (C_FLOAT64 value)
 
CSlider::Type type () const
 
void updateLabel ()
 
void updateSliderData ()
 
void updateValue (bool modifyRange, bool updateDependencies)
 
C_FLOAT64 value () const
 
virtual ~CopasiSlider ()
 

Protected Member Functions

int calculatePositionFromValue (C_FLOAT64 value)
 
C_FLOAT64 calculateValueFromPosition (int position)
 

Protected Attributes

QToolButton * mpCloseButton
 
CSlidermpCSlider
 
DataModelGUImpDM
 
QToolButton * mpEditButton
 
QLabel * mpLabel
 
QSlider * mpQSlider
 
bool mValueOutOfRange
 

Detailed Description

Definition at line 34 of file CopasiSlider.h.

Constructor & Destructor Documentation

CopasiSlider::CopasiSlider ( CSlider pSlider,
DataModelGUI pDM,
QWidget *  parent = 0 
)

Definition at line 34 of file CopasiSlider.cpp.

References closeButtonClicked(), CSlider::compile(), CQIconResource::edit, editButtonClicked(), CQIconResource::editDelete, CQIconResource::icon(), mpCloseButton, mpCSlider, mpEditButton, mpLabel, mpQSlider, qSliderPressed(), qSliderReleased(), sliderPressed(), sliderReleased(), sliderValueChanged(), updateSliderData(), and valueChanged().

34  :
35  QFrame(parent),
36  mpCSlider(pSlider),
37  mpQSlider(NULL),
38  mpLabel(NULL),
39  mpCloseButton(NULL),
40  mpEditButton(NULL),
41  mValueOutOfRange(false),
42  mpDM(pDM)
43 {
44  this->setLayout(new QHBoxLayout);
45  this->setFrameShape(QFrame::Box);
46  this->layout()->setContentsMargins(2, 2, 2, 2);
47  //this->layout()->setSpacing(0);
48  //this->layout()->setMargin(0);
49  QFrame* pFrame = new QFrame(NULL);
50  pFrame->setLayout(new QVBoxLayout);
51  pFrame->layout()->setContentsMargins(2, 2, 2, 2);
52  this->mpLabel = new QLabel(NULL);
53  this->mpLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
54  pFrame->layout()->addWidget(this->mpLabel);
55  this->mpQSlider = new QSlider(Qt::Horizontal);
56  mpQSlider->setFocusPolicy(Qt::WheelFocus);
57  this->mpQSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
58 #ifdef WIN32
59  this->mpQSlider->setMinimumHeight(10);
60 #endif
61  pFrame->layout()->addWidget(this->mpQSlider);
62  this->layout()->addWidget(pFrame);
63 
64  pFrame = new QFrame(NULL);
65  pFrame->setLayout(new QVBoxLayout);
66  pFrame->layout()->setContentsMargins(2, 2, 2, 2);
67 
68  this->mpCloseButton = new QToolButton(NULL);
70  pFrame->layout()->addWidget(this->mpCloseButton);
71 
72  this->mpEditButton = new QToolButton(NULL);
74  pFrame->layout()->addWidget(this->mpEditButton);
75 
76  this->layout()->addWidget(pFrame);
77 
78  if (!this->mpCSlider->compile())
79  {
80  this->mpQSlider->setEnabled(false);
81  }
82 
83  this->updateSliderData();
84  this->mpCloseButton->setToolTip(tr("Remove Slider"));
85  this->mpEditButton->setToolTip(tr("Edit Slider"));
86 
87  connect(this->mpQSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
88  connect(this->mpQSlider, SIGNAL(sliderReleased()), this, SLOT(qSliderReleased()));
89  connect(this->mpQSlider, SIGNAL(sliderPressed()), this, SLOT(qSliderPressed()));
90  connect(this->mpCloseButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
91  connect(this->mpEditButton, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
92 
93  setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
94 
95  // We need to assure that the slider is compiled
96  if (mpCSlider) mpCSlider->compile();
97 }
bool compile(const std::vector< CCopasiContainer * > &listOfContainer=CCopasiContainer::EmptyList)
Definition: CSlider.cpp:69
void qSliderPressed()
void sliderPressed()
void valueChanged(double)
void updateSliderData()
bool mValueOutOfRange
Definition: CopasiSlider.h:92
QLabel * mpLabel
Definition: CopasiSlider.h:89
void sliderReleased()
static const QIcon & icon(const IconID &id)
void editButtonClicked()
DataModelGUI * mpDM
Definition: CopasiSlider.h:93
void closeButtonClicked()
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void qSliderReleased()
QToolButton * mpCloseButton
Definition: CopasiSlider.h:90
QToolButton * mpEditButton
Definition: CopasiSlider.h:91
void sliderValueChanged(int value)
QSlider * mpQSlider
Definition: CopasiSlider.h:88
CopasiSlider::~CopasiSlider ( )
virtual

Definition at line 99 of file CopasiSlider.cpp.

100 {}

Member Function Documentation

int CopasiSlider::calculatePositionFromValue ( C_FLOAT64  value)
protected

Definition at line 381 of file CopasiSlider.cpp.

References CSlider::getMaxValue(), CSlider::getMinValue(), CSlider::getScaling(), CSlider::getTickNumber(), CSlider::linear, CSlider::logarithmic, minorTickInterval(), and mpCSlider.

Referenced by setMaxValue(), setMinValue(), setNumMinorTicks(), setValue(), and updateSliderData().

382 {
383  int position;
384 
385  switch (this->mpCSlider->getScaling())
386  {
387  case CSlider::linear:
388  position = (int)floor(((value - this->mpCSlider->getMinValue()) / this->minorTickInterval()) + 0.5);
389  break;
390 
392  position = (int)floor((this->mpCSlider->getTickNumber() * (log10(value / this->mpCSlider->getMinValue()) / log10(this->mpCSlider->getMaxValue() / this->mpCSlider->getMinValue()))) + 0.5);
393  break;
394 
395  default:
396  position = 0;
397  }
398 
399  return position;
400 }
C_FLOAT64 minorTickInterval() const
C_FLOAT64 value() const
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
Scale getScaling() const
Definition: CSlider.cpp:369
C_FLOAT64 CopasiSlider::calculateValueFromPosition ( int  position)
protected

Definition at line 357 of file CopasiSlider.cpp.

References CSlider::getMaxValue(), CSlider::getMinValue(), CSlider::getScaling(), CSlider::getTickNumber(), CSlider::linear, CSlider::logarithmic, minorTickInterval(), mpCSlider, and value().

Referenced by sliderValueChanged().

358 {
359  double value;
360  double exponent;
361 
362  switch (this->mpCSlider->getScaling())
363  {
364  case CSlider::linear:
365  value = this->mpCSlider->getMinValue() + position * this->minorTickInterval();
366  break;
367 
369  exponent = (((double)position) * log10(this->mpCSlider->getMaxValue() / this->mpCSlider->getMinValue())) / this->mpCSlider->getTickNumber();
370  value = this->mpCSlider->getMinValue() * pow(10.0, exponent);
371  break;
372 
373  default:
374  value = 0.0;
375  break;
376  }
377 
378  return value;
379 }
C_FLOAT64 minorTickInterval() const
C_FLOAT64 value() const
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
Scale getScaling() const
Definition: CSlider.cpp:369
void CopasiSlider::closeButtonClicked ( )
slot

Definition at line 342 of file CopasiSlider.cpp.

References closeClicked().

Referenced by CopasiSlider().

343 {
344  emit closeClicked(this);
345 }
void closeClicked(CopasiSlider *slider)
void CopasiSlider::closeClicked ( CopasiSlider slider)
signal

Referenced by closeButtonClicked().

void CopasiSlider::editButtonClicked ( )
slot

Definition at line 347 of file CopasiSlider.cpp.

References editClicked().

Referenced by CopasiSlider().

348 {
349  emit editClicked(this);
350 }
void editClicked(CopasiSlider *slider)
void CopasiSlider::editClicked ( CopasiSlider slider)
signal

Referenced by editButtonClicked().

void CopasiSlider::focusSlider ( )

Definition at line 102 of file CopasiSlider.cpp.

References mpQSlider.

Referenced by SliderDialog::changeEvent(), and SliderDialog::setCurrentSlider().

103 {
104  if (mpQSlider == NULL) return;
105 
106  mpQSlider->setFocus(Qt::OtherFocusReason);
107 }
QSlider * mpQSlider
Definition: CopasiSlider.h:88
CSlider * CopasiSlider::getCSlider ( ) const
bool CopasiSlider::isValid ( ) const

Checks whether the slider is actually valid. This is mainly done by calling isValid on the underlying CSlider object.

Definition at line 420 of file CopasiSlider.cpp.

References CSlider::isValid(), and mpCSlider.

Referenced by SliderDialog::deleteInvalidSliders().

421 {
422  return (this->mpCSlider != NULL && this->mpCSlider->isValid());
423 }
bool isValid() const
Definition: CSlider.cpp:408
CSlider * mpCSlider
Definition: CopasiSlider.h:87
C_FLOAT64 CopasiSlider::maxValue ( ) const

Definition at line 208 of file CopasiSlider.cpp.

References CSlider::getMaxValue(), and mpCSlider.

Referenced by SliderDialog::setCorrectSliderObject(), updateLabel(), and updateValue().

209 {
210  return this->mpCSlider->getMaxValue();
211 }
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 CopasiSlider::minorMajorFactor ( ) const

Definition at line 174 of file CopasiSlider.cpp.

References CSlider::getTickFactor(), and mpCSlider.

175 {
176  return this->mpCSlider->getTickFactor();
177 }
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 getTickFactor() const
Definition: CSlider.cpp:366
C_FLOAT64 CopasiSlider::minorTickInterval ( ) const

Definition at line 185 of file CopasiSlider.cpp.

References C_FLOAT64, CSlider::getMaxValue(), CSlider::getMinValue(), CSlider::getTickNumber(), and mpCSlider.

Referenced by calculatePositionFromValue(), and calculateValueFromPosition().

186 {
187  return (C_FLOAT64)(this->mpCSlider->getMaxValue() - this->mpCSlider->getMinValue()) / ((C_FLOAT64)this->mpCSlider->getTickNumber());
188 }
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
CSlider * mpCSlider
Definition: CopasiSlider.h:87
#define C_FLOAT64
Definition: copasi.h:92
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
C_FLOAT64 CopasiSlider::minValue ( ) const

Definition at line 203 of file CopasiSlider.cpp.

References CSlider::getMinValue(), and mpCSlider.

Referenced by SliderDialog::setCorrectSliderObject(), updateLabel(), and updateValue().

204 {
205  return this->mpCSlider->getMinValue();
206 }
CSlider * mpCSlider
Definition: CopasiSlider.h:87
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
unsigned C_INT32 CopasiSlider::numMinorTicks ( ) const

Definition at line 198 of file CopasiSlider.cpp.

References CSlider::getTickNumber(), and mpCSlider.

199 {
200  return this->mpCSlider->getTickNumber();
201 }
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
CCopasiObject * CopasiSlider::object ( ) const

Definition at line 213 of file CopasiSlider.cpp.

References CSlider::getSliderObject(), and mpCSlider.

Referenced by SliderDialog::fillSliderBox(), SliderDialog::setCorrectSliderObject(), SliderDialog::setFramework(), setValue(), and updateValue().

214 {
215  return this->mpCSlider->getSliderObject();
216 }
CSlider * mpCSlider
Definition: CopasiSlider.h:87
CCopasiObject * getSliderObject()
Definition: CSlider.cpp:176
C_FLOAT64 CopasiSlider::originalValue ( ) const

Definition at line 407 of file CopasiSlider.cpp.

References CSlider::getOriginalValue(), and mpCSlider.

Referenced by resetValue().

408 {
409  return this->mpCSlider->getOriginalValue();
410 }
const C_FLOAT64 & getOriginalValue() const
Definition: CSlider.cpp:285
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::qSliderPressed ( )
slot

Definition at line 289 of file CopasiSlider.cpp.

References sliderPressed().

Referenced by CopasiSlider().

290 {
291  emit sliderPressed();
292 }
void sliderPressed()
void CopasiSlider::qSliderReleased ( )
slot

Definition at line 284 of file CopasiSlider.cpp.

References sliderReleased().

Referenced by CopasiSlider().

285 {
286  emit sliderReleased();
287 }
void sliderReleased()
void CopasiSlider::resetValue ( )

Definition at line 402 of file CopasiSlider.cpp.

References originalValue(), and setValue().

Referenced by SliderDialog::resetValue().

403 {
404  this->setValue(this->originalValue());
405 }
void setValue(C_FLOAT64 value)
C_FLOAT64 originalValue() const
void CopasiSlider::setMaxValue ( C_FLOAT64  value)

Definition at line 224 of file CopasiSlider.cpp.

References calculatePositionFromValue(), CSlider::getSliderValue(), mpCSlider, mpQSlider, CSlider::setMaxValue(), and updateLabel().

Referenced by SliderDialog::setCorrectSliderObject().

225 {
226  this->mpCSlider->setMaxValue(value);
227 
228  this->mpQSlider->setValue(this->calculatePositionFromValue(this->mpCSlider->getSliderValue()));
229 
230  this->updateLabel();
231 }
void updateLabel()
bool setMaxValue(const C_FLOAT64 maxValue)
Definition: CSlider.cpp:323
int calculatePositionFromValue(C_FLOAT64 value)
C_FLOAT64 value() const
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
CSlider * mpCSlider
Definition: CopasiSlider.h:87
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::setMinorMajorFactor ( unsigned C_INT32  factor)

Definition at line 179 of file CopasiSlider.cpp.

References mpCSlider, mpQSlider, and CSlider::setTickFactor().

180 {
181  this->mpCSlider->setTickFactor(factor);
182  this->mpQSlider->setPageStep(this->mpQSlider->singleStep()*factor);
183 }
bool setTickFactor(const unsigned C_INT32 tickFactor)
Definition: CSlider.cpp:360
CSlider * mpCSlider
Definition: CopasiSlider.h:87
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::setMinValue ( C_FLOAT64  value)

Definition at line 233 of file CopasiSlider.cpp.

References calculatePositionFromValue(), CSlider::getSliderValue(), mpCSlider, mpQSlider, CSlider::setMinValue(), and updateLabel().

Referenced by SliderDialog::setCorrectSliderObject().

234 {
235  this->mpCSlider->setMinValue(value);
236 
237  this->mpQSlider->setValue(this->calculatePositionFromValue(this->mpCSlider->getSliderValue()));
238 
239  this->updateLabel();
240 }
void updateLabel()
int calculatePositionFromValue(C_FLOAT64 value)
C_FLOAT64 value() const
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
CSlider * mpCSlider
Definition: CopasiSlider.h:87
bool setMinValue(const C_FLOAT64 minValue)
Definition: CSlider.cpp:295
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::setNumMinorTicks ( unsigned C_INT32  numMinorTicks)

Definition at line 190 of file CopasiSlider.cpp.

References calculatePositionFromValue(), CSlider::getSliderValue(), mpCSlider, mpQSlider, and CSlider::setTickNumber().

191 {
193  // set maxValue and value of slider
194  this->mpQSlider->setMaximum(numMinorTicks);
195  this->mpQSlider->setValue(this->calculatePositionFromValue(this->mpCSlider->getSliderValue()));
196 }
int calculatePositionFromValue(C_FLOAT64 value)
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
bool setTickNumber(const unsigned C_INT32 tickNumber)
Definition: CSlider.cpp:351
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 numMinorTicks() const
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::setObject ( CCopasiObject object)

Definition at line 218 of file CopasiSlider.cpp.

References mpCSlider, CSlider::setSliderObject(), and updateSliderData().

Referenced by SliderDialog::setCorrectSliderObject().

219 {
220  this->mpCSlider->setSliderObject(object);
221  this->updateSliderData();
222 }
bool setSliderObject(CCopasiObject *pObject)
Definition: CSlider.cpp:104
void updateSliderData()
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::setOriginalValue ( C_FLOAT64  value)

Definition at line 412 of file CopasiSlider.cpp.

References mpCSlider, and CSlider::setOriginalValue().

Referenced by SliderDialog::setDefault().

413 {
415 }
bool setOriginalValue(const C_FLOAT64 value)
Definition: CSlider.cpp:191
C_FLOAT64 value() const
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::setType ( CSlider::Type  type)

Definition at line 299 of file CopasiSlider.cpp.

References mpCSlider, and CSlider::setSliderType().

300 {
301  this->mpCSlider->setSliderType(type);
302 }
CSlider::Type type() const
bool setSliderType(const CSlider::Type type)
Definition: CSlider.cpp:182
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::setValue ( C_FLOAT64  value)

Definition at line 141 of file CopasiSlider.cpp.

References C_INT32, calculatePositionFromValue(), CSlider::getSliderValue(), CCopasiObject::isValueBool(), CCopasiObject::isValueDbl(), CCopasiObject::isValueInt(), mpCSlider, mpDM, mpQSlider, object(), DataModelGUI::refreshInitialValues(), CCopasiObject::setObjectValue(), CSlider::setSliderValue(), and updateLabel().

Referenced by resetValue().

142 {
143 
144  // we set the value ourselves so that listviews can do the
145  // update of the dependent values as well as taking the framework into
146  // consideration
147 
148  // first we set the slider value without actually writing to the underlying object
149  this->mpCSlider->setSliderValue(value, false);
150  /* reget value in case it was outside range and got set to minValue or
151  * maxValue */
152  value = this->mpCSlider->getSliderValue();
153 
154  // now we handle writing to the object ourselves
155  CCopasiObject* pObject = this->object();
156 
157  if (pObject == NULL) return;
158 
159  if (pObject->isValueDbl())
160  pObject->setObjectValue(value);
161  else if (pObject->isValueInt())
162  pObject->setObjectValue((C_INT32) floor(value + 0.5));
163  else if (pObject->isValueBool())
164  pObject->setObjectValue(value != 0.0);
165 
166  // recalculate all other dependent values
168 
169  this->mpQSlider->setValue(this->calculatePositionFromValue(value));
170 
171  this->updateLabel();
172 }
bool isValueInt() const
void updateLabel()
void setObjectValue(const C_FLOAT64 &value)
CCopasiObject * object() const
#define C_INT32
Definition: copasi.h:90
int calculatePositionFromValue(C_FLOAT64 value)
C_FLOAT64 value() const
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
void refreshInitialValues()
DataModelGUI * mpDM
Definition: CopasiSlider.h:93
CSlider * mpCSlider
Definition: CopasiSlider.h:87
bool isValueBool() const
bool isValueDbl() const
bool setSliderValue(const C_FLOAT64 value, const bool &writeToObject=true)
Definition: CSlider.cpp:215
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::sliderPressed ( )
signal

Referenced by CopasiSlider(), and qSliderPressed().

void CopasiSlider::sliderReleased ( )
signal

Referenced by CopasiSlider(), and qSliderReleased().

void CopasiSlider::sliderValueChanged ( int  value)
slot

Definition at line 275 of file CopasiSlider.cpp.

References calculateValueFromPosition(), CSlider::getSliderValue(), mpCSlider, CSlider::setSliderValue(), updateLabel(), and valueChanged().

Referenced by CopasiSlider(), and updateSliderData().

276 {
278 
279  this->updateLabel();
280 
281  emit valueChanged(this->mpCSlider->getSliderValue());
282 }
void updateLabel()
void valueChanged(double)
C_FLOAT64 value() const
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
C_FLOAT64 calculateValueFromPosition(int position)
CSlider * mpCSlider
Definition: CopasiSlider.h:87
bool setSliderValue(const C_FLOAT64 value, const bool &writeToObject=true)
Definition: CSlider.cpp:215
CSlider::Type CopasiSlider::type ( ) const

Definition at line 294 of file CopasiSlider.cpp.

References CSlider::getSliderType(), and mpCSlider.

295 {
296  return this->mpCSlider->getSliderType();
297 }
CSlider::Type getSliderType() const
Definition: CSlider.cpp:188
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::updateLabel ( )

Definition at line 242 of file CopasiSlider.cpp.

References FROM_UTF8, CSlider::getMaxValue(), CSlider::getMinValue(), CCopasiObject::getObjectDisplayName(), CSlider::getSliderObject(), CSlider::getSliderValue(), maxValue(), minValue(), mpCSlider, mpLabel, and mValueOutOfRange.

Referenced by setMaxValue(), setMinValue(), setValue(), sliderValueChanged(), and updateSliderData().

243 {
244  double minValue, maxValue, currValue;
245  minValue = this->mpCSlider->getMinValue();
246  maxValue = this->mpCSlider->getMaxValue();
247  currValue = this->mpCSlider->getSliderValue();
248  CCopasiObject* object = this->mpCSlider->getSliderObject();
249  QString labelString = "";
250 
251  if (object)
252  {
253  labelString += FROM_UTF8(object->getObjectDisplayName(true, true));
254  labelString += " : [";
255  labelString += QString::number(minValue);
256  labelString += "-";
257  labelString += QString::number(maxValue);
258  labelString += "] {";
259  labelString += QString::number(currValue);
260  labelString += "}";
261 
262  if (this->mValueOutOfRange)
263  {
264  labelString += " (Value out of range!)";
265  }
266  }
267  else
268  {
269  labelString += "Object not available!";
270  }
271 
272  this->mpLabel->setText(labelString);
273 }
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
bool mValueOutOfRange
Definition: CopasiSlider.h:92
QLabel * mpLabel
Definition: CopasiSlider.h:89
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
C_FLOAT64 minValue() const
CSlider * mpCSlider
Definition: CopasiSlider.h:87
C_FLOAT64 maxValue() const
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
CCopasiObject * getSliderObject()
Definition: CSlider.cpp:176
void CopasiSlider::updateSliderData ( )

Definition at line 109 of file CopasiSlider.cpp.

References calculatePositionFromValue(), CSlider::getSliderObject(), CSlider::getSliderValue(), CSlider::getTickFactor(), CSlider::getTickNumber(), mpCSlider, mpQSlider, sliderValueChanged(), updateLabel(), and valueChanged().

Referenced by SliderDialog::addSlider(), CopasiSlider(), SliderDialog::createNewSlider(), SliderDialog::editSlider(), SliderDialog::fillSliderBox(), setObject(), and SliderDialog::updateAllSliders().

110 {
111  if (this->mpCSlider)
112  {
113  //mpCSlider->compile();
114  this->mpQSlider->setMinimum(0);
115  this->mpQSlider->setMaximum(this->mpCSlider->getTickNumber());
116  this->mpQSlider->setTickInterval(1);
117  this->mpQSlider->setSingleStep(1);
118  this->mpQSlider->setPageStep(this->mpCSlider->getTickFactor());
119  disconnect(this->mpQSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
120  this->mpQSlider->setValue(this->calculatePositionFromValue(this->mpCSlider->getSliderValue()));
121  connect(this->mpQSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
122  this->updateLabel();
123 
124  if (this->mpQSlider->isEnabled() == false)
125  {
126  if (this->mpCSlider->getSliderObject() != NULL)
127  {
128  this->mpQSlider->setEnabled(true);
129  }
130  }
131 
132  this->update();
133  }
134 }
void updateLabel()
void valueChanged(double)
int calculatePositionFromValue(C_FLOAT64 value)
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
CSlider * mpCSlider
Definition: CopasiSlider.h:87
unsigned C_INT32 getTickNumber() const
Definition: CSlider.cpp:357
unsigned C_INT32 getTickFactor() const
Definition: CSlider.cpp:366
void sliderValueChanged(int value)
CCopasiObject * getSliderObject()
Definition: CSlider.cpp:176
QSlider * mpQSlider
Definition: CopasiSlider.h:88
void CopasiSlider::updateValue ( bool  modifyRange,
bool  updateDependencies 
)

Definition at line 304 of file CopasiSlider.cpp.

References C_INT32, CSlider::getMaxValue(), CSlider::getMinValue(), CSlider::getSliderValue(), CCopasiObject::isValueBool(), CCopasiObject::isValueDbl(), CCopasiObject::isValueInt(), maxValue(), minValue(), mpCSlider, mpDM, mValueOutOfRange, object(), DataModelGUI::refreshInitialValues(), CSlider::resetRange(), CCopasiObject::setObjectValue(), and value().

Referenced by SliderDialog::updateAllSliders().

305 {
306  double value = this->mpCSlider->getSliderValue();
307  double maxValue = this->mpCSlider->getMaxValue();
308  double minValue = this->mpCSlider->getMinValue();
309 
310  if ((value > maxValue) || (value < minValue))
311  {
312  if (!modifyRange)
313  {
314  this->mValueOutOfRange = true;
315  }
316  else
317  {
318  this->mValueOutOfRange = false;
319  this->mpCSlider->resetRange();
320  }
321  }
322 
323  // now we handle writing to the object ourselves
324  CCopasiObject* pObject = this->object();
325 
326  if (pObject == NULL) return;
327 
328  if (pObject->isValueDbl())
329  pObject->setObjectValue(value);
330  else if (pObject->isValueInt())
331  pObject->setObjectValue((C_INT32) floor(value + 0.5));
332  else if (pObject->isValueBool())
333  pObject->setObjectValue(value != 0.0);
334 
335  // recalculate all other dependent values
336  if (updateDependencies)
337  {
339  }
340 }
bool isValueInt() const
void setObjectValue(const C_FLOAT64 &value)
CCopasiObject * object() const
#define C_INT32
Definition: copasi.h:90
bool mValueOutOfRange
Definition: CopasiSlider.h:92
C_FLOAT64 value() const
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
void refreshInitialValues()
DataModelGUI * mpDM
Definition: CopasiSlider.h:93
const C_FLOAT64 & getMaxValue() const
Definition: CSlider.cpp:348
C_FLOAT64 minValue() const
CSlider * mpCSlider
Definition: CopasiSlider.h:87
bool isValueBool() const
C_FLOAT64 maxValue() const
bool isValueDbl() const
const C_FLOAT64 & getMinValue() const
Definition: CSlider.cpp:320
void resetRange()
Definition: CSlider.cpp:159
C_FLOAT64 CopasiSlider::value ( ) const

Definition at line 136 of file CopasiSlider.cpp.

References CSlider::getSliderValue(), and mpCSlider.

Referenced by calculateValueFromPosition(), SliderDialog::setCorrectSliderObject(), SliderDialog::setDefault(), and updateValue().

137 {
138  return this->mpCSlider->getSliderValue();
139 }
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
CSlider * mpCSlider
Definition: CopasiSlider.h:87
void CopasiSlider::valueChanged ( double  )
signal

Member Data Documentation

QToolButton* CopasiSlider::mpCloseButton
protected

Definition at line 90 of file CopasiSlider.h.

Referenced by CopasiSlider().

CSlider* CopasiSlider::mpCSlider
protected
DataModelGUI* CopasiSlider::mpDM
protected

Definition at line 93 of file CopasiSlider.h.

Referenced by setValue(), and updateValue().

QToolButton* CopasiSlider::mpEditButton
protected

Definition at line 91 of file CopasiSlider.h.

Referenced by CopasiSlider().

QLabel* CopasiSlider::mpLabel
protected

Definition at line 89 of file CopasiSlider.h.

Referenced by CopasiSlider(), and updateLabel().

QSlider* CopasiSlider::mpQSlider
protected
bool CopasiSlider::mValueOutOfRange
protected

Definition at line 92 of file CopasiSlider.h.

Referenced by updateLabel(), and updateValue().


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