COPASI API  4.16.103
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
CSlider Class Reference

#include <CSlider.h>

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

Public Types

enum  Scale { linear = 0, logarithmic, undefinedScale }
 
enum  Type {
  Float = 0, UnsignedFloat, Integer, UnsignedInteger,
  Undefined
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 

Public Member Functions

bool compile (const std::vector< CCopasiContainer * > &listOfContainer=CCopasiContainer::EmptyList)
 
Scale convertScaleNameToScale (const char *scaleName)
 
const char * convertScaleToScaleName (Scale scale)
 
 CSlider (const std::string &name="Slider", const CCopasiContainer *pParent=NULL)
 
 CSlider (const CSlider &src, const CCopasiContainer *pParent=NULL)
 
const std::string & getAssociatedEntityKey () const
 
const std::string & getKey () const
 
const C_FLOAT64getMaxValue () const
 
const C_FLOAT64getMinValue () const
 
const C_FLOAT64getOriginalValue () const
 
Scale getScaling () const
 
CCopasiObjectgetSliderObject ()
 
const std::string & getSliderObjectCN () const
 
CSlider::Type getSliderType () const
 
const C_FLOAT64getSliderValue () const
 
bool getSynced () const
 
unsigned C_INT32 getTickFactor () const
 
unsigned C_INT32 getTickNumber () const
 
bool isValid () const
 
void resetRange ()
 
void resetValue ()
 
bool setAssociatedEntityKey (const std::string &associatedEntityKey)
 
bool setMaxValue (const C_FLOAT64 maxValue)
 
bool setMinValue (const C_FLOAT64 minValue)
 
bool setOriginalValue (const C_FLOAT64 value)
 
bool setScaling (Scale scaling)
 
bool setSliderObject (CCopasiObject *pObject)
 
bool setSliderObject (const CCopasiObjectName &objectCN)
 
bool setSliderType (const CSlider::Type type)
 
bool setSliderValue (const C_FLOAT64 value, const bool &writeToObject=true)
 
void setSynced (bool synced)
 
bool setTickFactor (const unsigned C_INT32 tickFactor)
 
bool setTickNumber (const unsigned C_INT32 tickNumber)
 
void sync ()
 
void writeToObject ()
 
 ~CSlider ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual CCopasiObjectName getCN () const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
virtual voidgetValuePointer () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
virtual void print (std::ostream *ostream) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Static Public Attributes

static const char * ScaleName []
 
static const char * TypeName []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 

Private Attributes

std::string mAssociatedEntityKey
 
CRegisteredObjectName mCN
 
std::vector< Refresh * > mInitialRefreshes
 
std::string mKey
 
C_FLOAT64 mMaxValue
 
C_FLOAT64 mMinValue
 
C_FLOAT64 mOriginalValue
 
CCopasiObjectmpSliderObject
 
Scale mScaling
 
Type mSliderType
 
bool mSync
 
unsigned C_INT32 mTickFactor
 
unsigned C_INT32 mTickNumber
 
C_FLOAT64 mValue
 

Additional Inherited Members

- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 29 of file CSlider.h.

Member Enumeration Documentation

Enum of valid scales

Enumerator
linear 
logarithmic 
undefinedScale 

Definition at line 40 of file CSlider.h.

Enum of valid quantitye units

Enumerator
Float 
UnsignedFloat 
Integer 
UnsignedInteger 
Undefined 

Definition at line 35 of file CSlider.h.

Constructor & Destructor Documentation

CSlider::CSlider ( const std::string &  name = "Slider",
const CCopasiContainer pParent = NULL 
)

Default constructor

Parameters
conststd::string & name (default: "NoName")
constCCopasiContainer * pParent (default: NULL)

Definition at line 30 of file CSlider.cpp.

31  :
32  CCopasiContainer(name, pParent, "Slider"),
33  mKey(CCopasiRootContainer::getKeyFactory()->add("Slider", this)),
35  mpSliderObject(NULL),
37  mValue(0.0),
38  mMinValue(0),
39  mMaxValue(0),
40  mTickNumber(1000),
41  mTickFactor(100),
42  mSync(true),
44  mCN(),
46 {}
C_FLOAT64 mValue
Definition: CSlider.h:311
unsigned C_INT32 mTickNumber
Definition: CSlider.h:331
Type mSliderType
Definition: CSlider.h:306
bool mSync
Definition: CSlider.h:341
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
std::string mAssociatedEntityKey
Definition: CSlider.h:296
std::vector< Refresh * > mInitialRefreshes
Definition: CSlider.h:357
static CKeyFactory * getKeyFactory()
C_FLOAT64 mMinValue
Definition: CSlider.h:321
std::string mKey
Definition: CSlider.h:291
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
unsigned C_INT32 mTickFactor
Definition: CSlider.h:336
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
CRegisteredObjectName mCN
Definition: CSlider.h:351
Scale mScaling
Definition: CSlider.h:346
CSlider::CSlider ( const CSlider src,
const CCopasiContainer pParent = NULL 
)

Copy constructor

Parameters
constCSlider & src
constCCopasiContainer * pParent (default: NULL)

Definition at line 48 of file CSlider.cpp.

49  :
50  CCopasiContainer(src, pParent),
51  mKey(CCopasiRootContainer::getKeyFactory()->add("Slider", this)),
55  mValue(src.mValue),
56  mMinValue(src.mMinValue),
57  mMaxValue(src.mMaxValue),
60  mSync(src.mSync),
61  mScaling(src.mScaling),
62  mCN(src.mCN),
64 {}
C_FLOAT64 mValue
Definition: CSlider.h:311
unsigned C_INT32 mTickNumber
Definition: CSlider.h:331
Type mSliderType
Definition: CSlider.h:306
bool mSync
Definition: CSlider.h:341
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
std::string mAssociatedEntityKey
Definition: CSlider.h:296
std::vector< Refresh * > mInitialRefreshes
Definition: CSlider.h:357
static CKeyFactory * getKeyFactory()
C_FLOAT64 mMinValue
Definition: CSlider.h:321
std::string mKey
Definition: CSlider.h:291
virtual bool add(CCopasiObject *pObject, const bool &adopt=true)
unsigned C_INT32 mTickFactor
Definition: CSlider.h:336
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
CRegisteredObjectName mCN
Definition: CSlider.h:351
Scale mScaling
Definition: CSlider.h:346
CSlider::~CSlider ( )

Destructor.

Definition at line 66 of file CSlider.cpp.

References CCopasiRootContainer::getKeyFactory(), mKey, and CKeyFactory::remove().

bool remove(const std::string &key)
static CKeyFactory * getKeyFactory()
std::string mKey
Definition: CSlider.h:291

Member Function Documentation

bool CSlider::compile ( const std::vector< CCopasiContainer * > &  listOfContainer = CCopasiContainer::EmptyList)

Compile, i.e., find the objects pointed to by the CN.

Parameters
conststd::vector< CCopasiContainer * > & listOfContainer (default: CCopasiContainer::EmptyList)
Returns
bool success

Definition at line 69 of file CSlider.cpp.

References CCopasiObject::getObjectDataModel(), mCN, mpSliderObject, mSync, setSliderObject(), and sync().

Referenced by SliderDialog::addSlider(), CopasiSlider::CopasiSlider(), SliderDialog::createNewSlider(), SliderDialog::getCSlidersForObject(), and SliderDialog::sliderObjectChanged().

70 {
71  if (getObjectDataModel() == NULL) return false;
72 
73  //setSliderObject(CCopasiContainer::ObjectFromName(listOfContainer, getObjectName()));
74  setSliderObject(getObjectDataModel()->ObjectFromName(listOfContainer, mCN));
75 
76  if (this->mSync) this->sync();
77 
78  return (mpSliderObject != NULL);
79 }
CCopasiDataModel * getObjectDataModel()
bool setSliderObject(CCopasiObject *pObject)
Definition: CSlider.cpp:104
bool mSync
Definition: CSlider.h:341
void sync()
Definition: CSlider.cpp:245
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
CRegisteredObjectName mCN
Definition: CSlider.h:351
CSlider::Scale CSlider::convertScaleNameToScale ( const char *  scaleName)

Converts the scaling name to the corresponding enum.

Returns
CSlider::Scale

Definition at line 380 of file CSlider.cpp.

References linear, logarithmic, and undefinedScale.

Referenced by CCopasiXMLParser::SliderElement::start().

381 {
382  if (!strncmp("linear", scaleName, 7))
383  {
384  return CSlider::linear;
385  }
386  else if (!strncmp("logarithmic", scaleName, 12))
387  {
388  return CSlider::logarithmic;
389  }
390  else
391  {
393  }
394 }
const char * CSlider::convertScaleToScaleName ( Scale  scale)

Converts the scaling name to the corresponding enum.

Returns
const char* scaleName

Definition at line 396 of file CSlider.cpp.

References ScaleName, and undefinedScale.

Referenced by CCopasiXML::saveGUI().

397 {
398  if (scale < 0 || scale > CSlider::undefinedScale) return ScaleName[undefinedScale];
399 
400  return ScaleName[scale];
401 }
static const char * ScaleName[]
Definition: CSlider.h:50
const std::string & CSlider::getAssociatedEntityKey ( ) const

Retrieve the key of the associated entity.

Returns
const std::string & associatedEntityKey

Definition at line 101 of file CSlider.cpp.

References mAssociatedEntityKey.

Referenced by SliderDialog::equivalentSliderExists(), SliderDialog::getCSlidersForObject(), and CCopasiXML::saveGUI().

102 {return mAssociatedEntityKey;}
std::string mAssociatedEntityKey
Definition: CSlider.h:296
const std::string & CSlider::getKey ( ) const
virtual

Retrieve the key

Returns
const std::string & key

Reimplemented from CCopasiObject.

Definition at line 91 of file CSlider.cpp.

References mKey.

Referenced by CCopasiXML::saveGUI().

92 {return mKey;}
std::string mKey
Definition: CSlider.h:291
const C_FLOAT64 & CSlider::getMaxValue ( ) const
const C_FLOAT64 & CSlider::getMinValue ( ) const
const C_FLOAT64 & CSlider::getOriginalValue ( ) const

Retrieve the original slider Value.

Returns
const C_FLOAT64 Value

Definition at line 285 of file CSlider.cpp.

References mOriginalValue.

Referenced by CopasiSlider::originalValue(), and SliderSettingsDialog::updateInputFieldsValues().

286 {
287  return this->mOriginalValue;
288 }
C_FLOAT64 mOriginalValue
Definition: CSlider.h:316
CSlider::Scale CSlider::getScaling ( ) const

Retrieve the scaling of the slider.

Returns
Scale scaling

Definition at line 369 of file CSlider.cpp.

References mScaling.

Referenced by CopasiSlider::calculatePositionFromValue(), CopasiSlider::calculateValueFromPosition(), CCopasiXML::saveGUI(), and SliderSettingsDialog::updateInputFieldsValues().

370 {
371  return this->mScaling;
372 }
Scale mScaling
Definition: CSlider.h:346
CCopasiObject * CSlider::getSliderObject ( )
const std::string & CSlider::getSliderObjectCN ( ) const

Retrieve the slider object CN.

Returns
const std::string & sliderObjectCN

Definition at line 179 of file CSlider.cpp.

References mCN.

Referenced by CCopasiXML::saveGUI().

180 {return mCN; /*getObjectName();*/}
CRegisteredObjectName mCN
Definition: CSlider.h:351
CSlider::Type CSlider::getSliderType ( ) const

Retrieve the slider type.

Returns
const CSlider::Type type

Definition at line 188 of file CSlider.cpp.

References mSliderType.

Referenced by CCopasiXML::saveGUI(), and CopasiSlider::type().

189 {return mSliderType;}
Type mSliderType
Definition: CSlider.h:306
const C_FLOAT64 & CSlider::getSliderValue ( ) const
bool CSlider::getSynced ( ) const

Returns wether the value is to be kept in sync the the objects value.

Returns
bool isSynced.

Definition at line 86 of file CSlider.cpp.

References mSync.

87 {
88  return this->mSync;
89 }
bool mSync
Definition: CSlider.h:341
unsigned C_INT32 CSlider::getTickFactor ( ) const

Retrieve the tick factor.

Returns
const unsigned C_INT32 & tickFactor

Definition at line 366 of file CSlider.cpp.

References mTickFactor.

Referenced by CopasiSlider::minorMajorFactor(), CCopasiXML::saveGUI(), SliderSettingsDialog::updateInputFieldsValues(), and CopasiSlider::updateSliderData().

367 {return mTickFactor;}
unsigned C_INT32 mTickFactor
Definition: CSlider.h:336
unsigned C_INT32 CSlider::getTickNumber ( ) const
bool CSlider::isValid ( ) const

Checks whether the object the slider points to actually exists. Returns true if it does.

Definition at line 408 of file CSlider.cpp.

References CCopasiDataModel::getModel(), CCopasiObject::getObjectDataModel(), mCN, mpSliderObject, and CCopasiDataModel::ObjectFromName().

Referenced by CopasiSlider::isValid().

409 {
410  bool result = false;
411  // check which object if any belongs to the CN and if it is the same as
412  // the pointer currently stored in the slider
413  assert(getObjectDataModel() != NULL);
414  const CModel* pModel = getObjectDataModel()->getModel();
415  assert(pModel != NULL);
416  std::vector<CCopasiContainer*> listOfContainers;
417  listOfContainers.push_back(const_cast<CModel*>(pModel));
418  const CCopasiObject* pObject = getObjectDataModel()->ObjectFromName(listOfContainers, this->mCN);
419  result = (pObject != NULL && pObject == this->mpSliderObject);
420  return result;
421 }
CCopasiDataModel * getObjectDataModel()
Definition: CModel.h:50
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CRegisteredObjectName mCN
Definition: CSlider.h:351
void CSlider::resetRange ( )

Reset the minimum and maximum value to defaults. For the minimum this is half the current value. For the maximum this is twice the current value.

Definition at line 159 of file CSlider.cpp.

References C_FLOAT64, getSliderValue(), mMaxValue, mMinValue, mSliderType, and Undefined.

Referenced by SliderSettingsDialog::browseButtonPressed(), SliderDialog::createNewSlider(), and CopasiSlider::updateValue().

160 {
161  if (this->mSliderType != Undefined)
162  {
163  C_FLOAT64 value = this->getSliderValue();
164  this->mMinValue = value / 2.0;
165  this->mMaxValue = value == 0 ? 1.0 : value * 2.0;
166  }
167 }
Type mSliderType
Definition: CSlider.h:306
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mMinValue
Definition: CSlider.h:321
void CSlider::resetValue ( )

Sets the value of the slider back to it's original value.

Definition at line 154 of file CSlider.cpp.

References mOriginalValue, and setSliderValue().

155 {
156  this->setSliderValue(this->mOriginalValue);
157 }
C_FLOAT64 mOriginalValue
Definition: CSlider.h:316
bool setSliderValue(const C_FLOAT64 value, const bool &writeToObject=true)
Definition: CSlider.cpp:215
bool CSlider::setAssociatedEntityKey ( const std::string &  associatedEntityKey)

Set the key of the associated entity

Parameters
conststd::string & associatedEntityKey
Returns
bool succes

Definition at line 94 of file CSlider.cpp.

References CCopasiRootContainer::getKeyFactory(), and mAssociatedEntityKey.

Referenced by SliderSettingsDialog::browseButtonPressed(), SliderDialog::createNewSlider(), and CCopasiXMLParser::SliderElement::start().

95 {
96  mAssociatedEntityKey = associatedEntityKey;
97 
98  return (CCopasiRootContainer::getKeyFactory()->get(associatedEntityKey) != NULL);
99 }
std::string mAssociatedEntityKey
Definition: CSlider.h:296
static CKeyFactory * getKeyFactory()
bool CSlider::setMaxValue ( const C_FLOAT64  maxValue)

Set the slider maximum value.

Parameters
constC_FLOAT64 maxValue
Returns
bool succes

Definition at line 323 of file CSlider.cpp.

References getSliderValue(), mMaxValue, mMinValue, mpSliderObject, mSliderType, mValue, Undefined, and writeToObject().

Referenced by CopasiSlider::setMaxValue(), CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

324 {
325  if (mSliderType != Undefined)
326  {
327  mMaxValue = maxValue;
328 
329  if (mMaxValue < mMinValue)
330  {
332  }
333 
335  {
336  this->mValue = this->mMaxValue;
337  this->writeToObject();
338  }
339 
340  return true;
341  }
342  else
343  {
344  return false;
345  }
346 }
C_FLOAT64 mValue
Definition: CSlider.h:311
Type mSliderType
Definition: CSlider.h:306
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
void writeToObject()
Definition: CSlider.cpp:265
C_FLOAT64 mMinValue
Definition: CSlider.h:321
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
bool CSlider::setMinValue ( const C_FLOAT64  minValue)

Set the slider minimum value.

Parameters
constC_FLOAT64 minValue
Returns
bool succes

Definition at line 295 of file CSlider.cpp.

References getSliderValue(), mMaxValue, mMinValue, mpSliderObject, mSliderType, mValue, Undefined, and writeToObject().

Referenced by CopasiSlider::setMinValue(), CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

296 {
297  if (mSliderType != Undefined)
298  {
299  mMinValue = minValue;
300 
301  if (mMaxValue < mMinValue)
302  {
304  }
305 
307  {
308  this->mValue = this->mMinValue;
309  this->writeToObject();
310  }
311 
312  return true;
313  }
314  else
315  {
316  return false;
317  }
318 }
C_FLOAT64 mValue
Definition: CSlider.h:311
Type mSliderType
Definition: CSlider.h:306
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
void writeToObject()
Definition: CSlider.cpp:265
C_FLOAT64 mMinValue
Definition: CSlider.h:321
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
bool CSlider::setOriginalValue ( const C_FLOAT64  value)

Set the sliders original value.

Parameters
constC_FLOAT64 Value
constbool & writeToObject (Default: true)
Returns
bool succes

Definition at line 191 of file CSlider.cpp.

References mMaxValue, mMinValue, mOriginalValue, mSliderType, and Undefined.

Referenced by CopasiSlider::setOriginalValue(), and SliderSettingsDialog::updateSlider().

192 {
193  if (mSliderType != Undefined)
194  {
195  mOriginalValue = value;
196 
197  if (mOriginalValue < this->mMinValue)
198  {
199  mOriginalValue = this->mMinValue;
200  }
201 
202  if (mOriginalValue > this->mMaxValue)
203  {
204  mOriginalValue = this->mMaxValue;
205  }
206 
207  return true;
208  }
209  else
210  {
211  return false;
212  }
213 }
C_FLOAT64 mOriginalValue
Definition: CSlider.h:316
Type mSliderType
Definition: CSlider.h:306
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
C_FLOAT64 mMinValue
Definition: CSlider.h:321
bool CSlider::setScaling ( CSlider::Scale  scaling)

Set the scaling for the CSlider.

Definition at line 374 of file CSlider.cpp.

References mScaling.

Referenced by CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

375 {
376  this->mScaling = scaling;
377  return true;
378 }
Scale mScaling
Definition: CSlider.h:346
bool CSlider::setSliderObject ( CCopasiObject pObject)

Set the slider object.

Parameters
CCopasiObject* pObject
Returns
bool succes

Definition at line 104 of file CSlider.cpp.

References CModel::buildInitialRefreshSequence(), C_FLOAT64, Float, CCopasiObject::getCN(), CCopasiDataModel::getModel(), CCopasiObject::getObjectDataModel(), getSliderValue(), Integer, CCopasiObject::isValueDbl(), CCopasiObject::isValueInt(), mCN, mInitialRefreshes, mMaxValue, mMinValue, mOriginalValue, mpSliderObject, mSync, setSliderType(), sync(), and Undefined.

Referenced by SliderSettingsDialog::browseButtonPressed(), compile(), SliderDialog::createNewSlider(), CopasiSlider::setObject(), and CCopasiXMLParser::SliderElement::start().

105 {
106  mpSliderObject = pObject;
107 
108  if (!pObject)
109  {
110  mInitialRefreshes.clear();
111  return false;
112  }
113 
114  mCN = pObject->getCN();
115 
116  std::set< const CCopasiObject * > ChangedObjects;
117  ChangedObjects.insert(pObject);
118 
119  CCopasiDataModel* pDataModel = getObjectDataModel();
120  assert(pDataModel != NULL);
121  mInitialRefreshes = pDataModel->getModel()->buildInitialRefreshSequence(ChangedObjects);
122 
123  if (mpSliderObject->isValueInt())
124  {
125  this->setSliderType(Integer);
126  }
127  else if (mpSliderObject->isValueDbl())
128  {
129  this->setSliderType(Float);
130  }
131  else
132  {
133  this->setSliderType(Undefined);
134  }
135 
136  if (this->mSync) this->sync();
137 
138  C_FLOAT64 value = this->getSliderValue();
139  this->mOriginalValue = value;
140 
141  if (this->mMinValue > value)
142  {
143  this->mMinValue = value;
144  }
145 
146  if (this->mMaxValue < value)
147  {
148  this->mMaxValue = value;
149  }
150 
151  return true;
152 }
CCopasiDataModel * getObjectDataModel()
bool isValueInt() const
virtual CCopasiObjectName getCN() const
C_FLOAT64 mOriginalValue
Definition: CSlider.h:316
bool mSync
Definition: CSlider.h:341
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
bool setSliderType(const CSlider::Type type)
Definition: CSlider.cpp:182
const C_FLOAT64 & getSliderValue() const
Definition: CSlider.cpp:290
std::vector< Refresh * > mInitialRefreshes
Definition: CSlider.h:357
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mMinValue
Definition: CSlider.h:321
void sync()
Definition: CSlider.cpp:245
bool isValueDbl() const
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
CRegisteredObjectName mCN
Definition: CSlider.h:351
bool CSlider::setSliderObject ( const CCopasiObjectName objectCN)

Set the slider object.

Parameters
constCCopasiObjectName & objectCN
Returns
bool succes

Definition at line 169 of file CSlider.cpp.

References mCN.

170 {
171  //return setObjectName(objectCN);
172  mCN = objectCN;
173  return true;
174 }
CRegisteredObjectName mCN
Definition: CSlider.h:351
bool CSlider::setSliderType ( const CSlider::Type  type)

Set the slider type.

Parameters
constCSlider::Type type
Returns
bool succes

Definition at line 182 of file CSlider.cpp.

References mSliderType.

Referenced by setSliderObject(), CopasiSlider::setType(), and CCopasiXMLParser::SliderElement::start().

183 {
184  mSliderType = type;
185  return true;
186 }
Type mSliderType
Definition: CSlider.h:306
bool CSlider::setSliderValue ( const C_FLOAT64  value,
const bool &  writeToObject = true 
)

Set the slider value.

Parameters
constC_FLOAT64 Value
constbool & writeToObject (Default: true)
Returns
bool succes

Definition at line 215 of file CSlider.cpp.

References mMaxValue, mMinValue, mSliderType, mSync, mValue, Undefined, and writeToObject().

Referenced by resetValue(), CopasiSlider::setValue(), CopasiSlider::sliderValueChanged(), CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

217 {
218  if (mSliderType != Undefined)
219  {
220  mValue = value;
221 
222  if (mValue < this->mMinValue)
223  {
224  mValue = this->mMinValue;
225  }
226 
227  if (mValue > this->mMaxValue)
228  {
229  mValue = this->mMaxValue;
230  }
231 
232  if (this->mSync && writeToObject)
233  {
234  this->writeToObject();
235  }
236 
237  return true;
238  }
239  else
240  {
241  return false;
242  }
243 }
C_FLOAT64 mValue
Definition: CSlider.h:311
Type mSliderType
Definition: CSlider.h:306
bool mSync
Definition: CSlider.h:341
C_FLOAT64 mMaxValue
Definition: CSlider.h:326
void writeToObject()
Definition: CSlider.cpp:265
C_FLOAT64 mMinValue
Definition: CSlider.h:321
void CSlider::setSynced ( bool  synced)

Sets wether the value is to be kept in sync the the objects value.

Definition at line 81 of file CSlider.cpp.

References mSync.

82 {
83  this->mSync = synced;
84 }
bool mSync
Definition: CSlider.h:341
bool CSlider::setTickFactor ( const unsigned C_INT32  tickFactor)

Set the tick factor.

Parameters
constunsigned C_INT32 & tickFactor
Returns
bool succes

Definition at line 360 of file CSlider.cpp.

References mTickFactor.

Referenced by CopasiSlider::setMinorMajorFactor(), CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

361 {
362  mTickFactor = tickFactor;
363  return true;
364 }
unsigned C_INT32 mTickFactor
Definition: CSlider.h:336
bool CSlider::setTickNumber ( const unsigned C_INT32  tickNumber)

Set the tick number.

Parameters
constunsigned C_INT32 & tickNumber
Returns
bool succes

Definition at line 351 of file CSlider.cpp.

References mTickNumber.

Referenced by CopasiSlider::setNumMinorTicks(), CCopasiXMLParser::SliderElement::start(), and SliderSettingsDialog::updateSlider().

352 {
353  mTickNumber = tickNumber;
354  return true;
355 }
unsigned C_INT32 mTickNumber
Definition: CSlider.h:331
void CSlider::sync ( )

Set the CSliders value to the value of the underlying object.

Definition at line 245 of file CSlider.cpp.

References C_FLOAT64, C_INT32, Float, CCopasiObject::getValuePointer(), Integer, mpSliderObject, mSliderType, mValue, UnsignedFloat, and UnsignedInteger.

Referenced by compile(), and setSliderObject().

246 {
247  if (!this->mpSliderObject) return;
248 
250  {
251  C_INT32* reference =
252  (C_INT32*)(((CCopasiObjectReference<C_INT32>*)mpSliderObject)->getValuePointer());
253 
254  mValue = *reference;
255  }
257  {
258  C_FLOAT64* reference =
260 
261  mValue = *reference;
262  }
263 }
C_FLOAT64 mValue
Definition: CSlider.h:311
#define C_INT32
Definition: copasi.h:90
Type mSliderType
Definition: CSlider.h:306
#define C_FLOAT64
Definition: copasi.h:92
virtual void * getValuePointer() const
CCopasiObject * mpSliderObject
Definition: CSlider.h:301
void CSlider::writeToObject ( )

Set the objects value to the value stored in CSlider.

Definition at line 265 of file CSlider.cpp.

References C_INT32, CCopasiObject::isValueBool(), CCopasiObject::isValueDbl(), CCopasiObject::isValueInt(), mInitialRefreshes, mpSliderObject, mValue, and CCopasiObject::setObjectValue().

Referenced by setMaxValue(), setMinValue(), and setSliderValue().

266 {
267  if (!mpSliderObject) return;
268 
269  if (mpSliderObject->isValueDbl())
271  else if (mpSliderObject->isValueInt())
272  mpSliderObject->setObjectValue((C_INT32) floor(mValue + 0.5));
273  else if (mpSliderObject->isValueBool())
275 
276  std::vector< Refresh * >::iterator it = mInitialRefreshes.begin();
277  std::vector< Refresh * >::iterator end = mInitialRefreshes.end();
278 
279  for (; it != end; ++it)
280  (**it)();
281 
282  return;
283 }
bool isValueInt() const
C_FLOAT64 mValue
Definition: CSlider.h:311
void setObjectValue(const C_FLOAT64 &value)
#define C_INT32
Definition: copasi.h:90
std::vector< Refresh * > mInitialRefreshes
Definition: CSlider.h:357
bool isValueBool() const
bool isValueDbl() const
CCopasiObject * mpSliderObject
Definition: CSlider.h:301

Member Data Documentation

std::string CSlider::mAssociatedEntityKey
private

The key of the associated entity of the slider's object.

Definition at line 296 of file CSlider.h.

Referenced by getAssociatedEntityKey(), and setAssociatedEntityKey().

CRegisteredObjectName CSlider::mCN
private

The CN of the object that the slider modifies.

Definition at line 351 of file CSlider.h.

Referenced by compile(), getSliderObjectCN(), isValid(), and setSliderObject().

std::vector< Refresh * > CSlider::mInitialRefreshes
private

The sequnece of methods to update initial values depending on this sliders object.

Definition at line 357 of file CSlider.h.

Referenced by setSliderObject(), and writeToObject().

std::string CSlider::mKey
private

The key of the slider.

Definition at line 291 of file CSlider.h.

Referenced by getKey(), and ~CSlider().

C_FLOAT64 CSlider::mMaxValue
private

The maximum value of the slider

Definition at line 326 of file CSlider.h.

Referenced by getMaxValue(), resetRange(), setMaxValue(), setMinValue(), setOriginalValue(), setSliderObject(), and setSliderValue().

C_FLOAT64 CSlider::mMinValue
private

The minimun value of the slider

Definition at line 321 of file CSlider.h.

Referenced by getMinValue(), resetRange(), setMaxValue(), setMinValue(), setOriginalValue(), setSliderObject(), and setSliderValue().

C_FLOAT64 CSlider::mOriginalValue
private

The original value of the slider-

Definition at line 316 of file CSlider.h.

Referenced by getOriginalValue(), resetValue(), setOriginalValue(), and setSliderObject().

CCopasiObject* CSlider::mpSliderObject
private

The slider object pointing to the slider's object afteer compile.

Definition at line 301 of file CSlider.h.

Referenced by compile(), getSliderObject(), isValid(), setMaxValue(), setMinValue(), setSliderObject(), sync(), and writeToObject().

Scale CSlider::mScaling
private

The scaling of the slider.

Definition at line 346 of file CSlider.h.

Referenced by getScaling(), and setScaling().

Type CSlider::mSliderType
private

The value type of the slider's object.

Definition at line 306 of file CSlider.h.

Referenced by getSliderType(), resetRange(), setMaxValue(), setMinValue(), setOriginalValue(), setSliderType(), setSliderValue(), and sync().

bool CSlider::mSync
private

Wether the CSlider's value is always in sync with its object's value.

Definition at line 341 of file CSlider.h.

Referenced by compile(), getSynced(), setSliderObject(), setSliderValue(), and setSynced().

unsigned C_INT32 CSlider::mTickFactor
private

The factor between minor and major ticks.

Definition at line 336 of file CSlider.h.

Referenced by getTickFactor(), and setTickFactor().

unsigned C_INT32 CSlider::mTickNumber
private

The number of ticks the slider is divided into.

Definition at line 331 of file CSlider.h.

Referenced by getTickNumber(), and setTickNumber().

C_FLOAT64 CSlider::mValue
private

The value of the slider-

Definition at line 311 of file CSlider.h.

Referenced by getSliderValue(), setMaxValue(), setMinValue(), setSliderValue(), sync(), and writeToObject().

const char * CSlider::ScaleName
static
Initial value:
=
{"linear", "logarithmic", "undefined", NULL}

String representation of valid scalings

Definition at line 50 of file CSlider.h.

Referenced by convertScaleToScaleName().

const char * CSlider::TypeName
static
Initial value:
=
{"float", "unsignedFloat", "integer", "unsignedInteger", "Undefined", NULL}

String representation of valid quantity units

Definition at line 45 of file CSlider.h.

Referenced by CCopasiXML::saveGUI(), and CCopasiXMLParser::SliderElement::start().


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