COPASI API  4.16.103
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
CLColorDefinition Class Reference

#include <CLColorDefinition.h>

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

Public Member Functions

 CLColorDefinition (CCopasiContainer *pParent=NULL)
 
 CLColorDefinition (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255, CCopasiContainer *pParent=NULL)
 
 CLColorDefinition (const CLColorDefinition &source, CCopasiContainer *pParent=NULL)
 
 CLColorDefinition (const ColorDefinition &source, CCopasiContainer *pParent=NULL)
 
std::string createValueString () const
 
unsigned char getAlpha () const
 
unsigned char getBlue () const
 
unsigned char getGreen () const
 
const std::string & getId () const
 
const std::string & getKey () const
 
unsigned char getRed () const
 
void setAlpha (unsigned char c)
 
void setBlue (unsigned char c)
 
bool setColorValue (const std::string &valueString)
 
void setGreen (unsigned char c)
 
void setId (const std::string &id)
 
void setRed (unsigned char c)
 
void setRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
 
ColorDefinition * toSBML (unsigned int level, unsigned int version) const
 
virtual ~CLColorDefinition ()
 
- Public Member Functions inherited from CLBase
 CLBase ()
 
 CLBase (const CLBase &b)
 
 CLBase (const SBase &)
 
const std::string & getTag () const
 
bool hasTag () const
 
virtual void moveBy (const CLPoint &)
 
void setTag (const std::string &tag)
 
virtual ~CLBase ()
 
- 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
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) 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
 
virtual std::string getUnits () const
 
UpdateMethodgetUpdateMethod () const
 
virtual const CCopasiObjectgetValueObject () 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 ()
 

Protected Attributes

unsigned char mAlpha
 
unsigned char mBlue
 
unsigned char mGreen
 
std::string mId
 
std::string mKey
 
unsigned char mRed
 
- Protected Attributes inherited from CLBase
std::string mTag
 

Private Member Functions

CLColorDefinitionoperator= (const CLColorDefinition &source)
 

Additional Inherited Members

- 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
 
- 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 CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 25 of file CLColorDefinition.h.

Constructor & Destructor Documentation

CLColorDefinition::CLColorDefinition ( CCopasiContainer pParent = NULL)

Contructor which sets the ColorDefinition to completely opaque black.

Contructor which sets the CLColorDefinition to completely opaque black.

Definition at line 33 of file CLColorDefinition.cpp.

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

34  : CLBase(),
35  CCopasiObject("ColorDefinition", pParent),
36  mRed(0),
37  mGreen(0),
38  mBlue(0),
39  mAlpha(255),
40  mKey(""),
41  mId("")
42 {
43  this->mKey = CCopasiRootContainer::getKeyFactory()->add("ColorDefinition", this);
44 }
CLBase()
Definition: CLBase.h:36
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
std::string add(const std::string &prefix, CCopasiObject *pObject)
static CKeyFactory * getKeyFactory()
CLColorDefinition::CLColorDefinition ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255,
CCopasiContainer pParent = NULL 
)

Constructor which sets the ColorDefinition to the given RGBA values.

Constructor which sets the CLColorDefinition to the given RGBA values.

Definition at line 49 of file CLColorDefinition.cpp.

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

50  : CLBase(),
51  CCopasiObject("ColorDefinition", pParent),
52  mRed(r),
53  mGreen(g),
54  mBlue(b),
55  mAlpha(a),
56  mKey(""),
57  mId("")
58 {
59  this->mKey = CCopasiRootContainer::getKeyFactory()->add("ColorDefinition", this);
60 }
CLBase()
Definition: CLBase.h:36
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
std::string add(const std::string &prefix, CCopasiObject *pObject)
static CKeyFactory * getKeyFactory()
CLColorDefinition::CLColorDefinition ( const CLColorDefinition source,
CCopasiContainer pParent = NULL 
)

Copy Contructor

Definition at line 65 of file CLColorDefinition.cpp.

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

65  :
66  CLBase(source),
67  CCopasiObject(source, pParent),
68  mRed(source.mRed),
69  mGreen(source.mGreen),
70  mBlue(source.mBlue),
71  mAlpha(source.mAlpha),
72  mKey(""),
73  mId(source.mId)
74 {
75  this->mKey = CCopasiRootContainer::getKeyFactory()->add("ColorDefinition", this);
76 }
CLBase()
Definition: CLBase.h:36
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
std::string add(const std::string &prefix, CCopasiObject *pObject)
static CKeyFactory * getKeyFactory()
CLColorDefinition::CLColorDefinition ( const ColorDefinition &  source,
CCopasiContainer pParent = NULL 
)

Constructor to generate object from the corresponding SBML object.

Definition at line 81 of file CLColorDefinition.cpp.

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

81  :
82  CLBase(),
83  CCopasiObject("ColorDefinition", pParent),
84  mRed(source.getRed()),
85  mGreen(source.getGreen()),
86  mBlue(source.getBlue()),
87  mAlpha(source.getAlpha()),
88  mKey(""),
89  mId(source.getId())
90 {
91  this->mKey = CCopasiRootContainer::getKeyFactory()->add("ColorDefinition", this);
92 }
CLBase()
Definition: CLBase.h:36
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
std::string add(const std::string &prefix, CCopasiObject *pObject)
static CKeyFactory * getKeyFactory()
CLColorDefinition::~CLColorDefinition ( )
virtual

Dtor.

Definition at line 97 of file CLColorDefinition.cpp.

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

98 {
100 }
bool remove(const std::string &key)
static CKeyFactory * getKeyFactory()

Member Function Documentation

std::string CLColorDefinition::createValueString ( ) const

Creates a string the represents the current color value.

Definition at line 233 of file CLColorDefinition.cpp.

References mAlpha, mBlue, mGreen, and mRed.

Referenced by CCopasiXML::saveColorDefinition().

234 {
235  std::ostringstream os;
236  os << "#" << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)mRed << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)mGreen << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)mBlue;
237 
238  if (mAlpha != 255)
239  {
240  os << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)mAlpha;
241  }
242 
243  return os.str();
244 }
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
unsigned char CLColorDefinition::getAlpha ( ) const

Returns the alpha color component.

Definition at line 129 of file CLColorDefinition.cpp.

References mAlpha.

Referenced by CLLayoutRenderer::draw_layout(), getColor(), and CLLayoutRenderer::resolve_color().

130 {
131  return mAlpha;
132 }
unsigned char mAlpha
unsigned char CLColorDefinition::getBlue ( ) const

Returns the blue color component.

Definition at line 121 of file CLColorDefinition.cpp.

References mBlue.

Referenced by CLLayoutRenderer::draw_layout(), getColor(), and CLLayoutRenderer::resolve_color().

122 {
123  return mBlue;
124 }
unsigned char mBlue
unsigned char CLColorDefinition::getGreen ( ) const

Returns the green color component.

Definition at line 113 of file CLColorDefinition.cpp.

References mGreen.

Referenced by CLLayoutRenderer::draw_layout(), getColor(), and CLLayoutRenderer::resolve_color().

114 {
115  return mGreen;
116 }
unsigned char mGreen
const std::string & CLColorDefinition::getId ( ) const

Returns the id of the object.

Definition at line 268 of file CLColorDefinition.cpp.

References mId.

Referenced by CLRenderResolver::fill_base_maps(), CLRenderFlattener::flatten(), and CCopasiXML::saveColorDefinition().

269 {
270  return this->mId;
271 }
const std::string & CLColorDefinition::getKey ( ) const
virtual

Returns the key of the color definition.

Reimplemented from CCopasiObject.

Definition at line 249 of file CLColorDefinition.cpp.

References mKey.

250 {
251  return this->mKey;
252 }
unsigned char CLColorDefinition::getRed ( ) const

Returns the red color component.

Definition at line 105 of file CLColorDefinition.cpp.

References mRed.

Referenced by CLLayoutRenderer::draw_layout(), getColor(), and CLLayoutRenderer::resolve_color().

106 {
107  return mRed;
108 }
unsigned char mRed
CLColorDefinition& CLColorDefinition::operator= ( const CLColorDefinition source)
private
void CLColorDefinition::setAlpha ( unsigned char  c)

Sets alpha red color component.

Definition at line 161 of file CLColorDefinition.cpp.

References mAlpha.

162 {
163  this->mAlpha = c;
164 }
unsigned char mAlpha
void CLColorDefinition::setBlue ( unsigned char  c)

Sets the blue color component.

Definition at line 153 of file CLColorDefinition.cpp.

References mBlue.

154 {
155  this->mBlue = c;
156 }
unsigned char mBlue
bool CLColorDefinition::setColorValue ( const std::string &  valueString)

Sets the color value from a given string. If the string is not a valid value string, the color value is set to black and false is returned.

Definition at line 183 of file CLColorDefinition.cpp.

References mAlpha, mBlue, mGreen, and mRed.

Referenced by getColor(), CLLayoutRenderer::resolve_color(), CLRenderResolver::setBackgroundColor(), and CCopasiXMLParser::ColorDefinitionElement::start().

184 {
185  bool result = true;
186  size_t first_letter = valueString.find_first_not_of(std::string(" \t\r\n"));
187 
188  if (first_letter == std::string::npos)
189  {
190  result = false;
191  }
192  else
193  {
194  std::string trimmed = valueString.substr(first_letter, valueString.find_last_not_of(" \t\r\n") - first_letter + 1);
195 
196  if (trimmed[0] == '#' && (trimmed.size() == 7 || trimmed.size() == 9) && trimmed.find_first_not_of("0123456789ABCDEFabcdef", 1) == std::string::npos)
197  {
198  this->mRed = (unsigned char)strtol(trimmed.substr(1, 2).c_str(), NULL, 16);
199  this->mGreen = (unsigned char)strtol(trimmed.substr(3, 2).c_str(), NULL, 16);
200  this->mBlue = (unsigned char)strtol(trimmed.substr(5, 2).c_str(), NULL, 16);
201 
202  if (trimmed.size() == 9)
203  {
204  // set the alpha value
205  this->mAlpha = (unsigned char)strtol(trimmed.substr(7, 2).c_str(), NULL, 16);
206  }
207  else
208  {
209  // if no alpha is given, the color is completely opaque
210  this->mAlpha = 255;
211  }
212  }
213  else
214  {
215  result = false;
216  }
217  }
218 
219  if (result == false)
220  {
221  this->mRed = 0;
222  this->mGreen = 0;
223  this->mBlue = 0;
224  this->mAlpha = 255;
225  }
226 
227  return result;
228 }
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
void CLColorDefinition::setGreen ( unsigned char  c)

Sets the green color component.

Definition at line 145 of file CLColorDefinition.cpp.

References mGreen.

146 {
147  this->mGreen = c;
148 }
unsigned char mGreen
void CLColorDefinition::setId ( const std::string &  id)

Sets the id of the object.

Definition at line 276 of file CLColorDefinition.cpp.

References mId.

Referenced by test000097::addGlobalRenderInformation(), test000097::addLocalRenderInformation(), and CCopasiXMLParser::ColorDefinitionElement::start().

277 {
278  this->mId = id;
279 }
void CLColorDefinition::setRed ( unsigned char  c)

Sets the red color component.

Definition at line 137 of file CLColorDefinition.cpp.

References mRed.

138 {
139  this->mRed = c;
140 }
unsigned char mRed
void CLColorDefinition::setRGBA ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255 
)

Sets the red green, blue and alpha color component. The alpha value is optional and defaults to 255 if not given.

Definition at line 170 of file CLColorDefinition.cpp.

References mAlpha, mBlue, mGreen, and mRed.

Referenced by test000097::addGlobalRenderInformation(), and test000097::addLocalRenderInformation().

171 {
172  this->mRed = r;
173  this->mGreen = g;
174  this->mBlue = b;
175  this->mAlpha = a;
176 }
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue
ColorDefinition * CLColorDefinition::toSBML ( unsigned int  level,
unsigned int  version 
) const

Converts this object to the corresponding SBML object.

Definition at line 257 of file CLColorDefinition.cpp.

References mAlpha, mBlue, mGreen, mId, and mRed.

Referenced by CLRenderInformationBase::addSBMLAttributes().

258 {
259  ColorDefinition* pCD = new ColorDefinition(level, version);
260  pCD->setId(this->mId);
261  pCD->setRGBA(this->mRed, this->mGreen, this->mBlue, this->mAlpha);
262  return pCD;
263 }
unsigned char mAlpha
unsigned char mRed
unsigned char mGreen
unsigned char mBlue

Member Data Documentation

unsigned char CLColorDefinition::mAlpha
protected
unsigned char CLColorDefinition::mBlue
protected

Definition at line 35 of file CLColorDefinition.h.

Referenced by createValueString(), getBlue(), setBlue(), setColorValue(), setRGBA(), and toSBML().

unsigned char CLColorDefinition::mGreen
protected
std::string CLColorDefinition::mId
protected

The color definition needs an id in addition to the key. The id corresponds to the id in the SBML render extension and it does not have to be globally unique. As a matter of fact, it is sometimes needed that color definitions of different render information have the same id.

Definition at line 49 of file CLColorDefinition.h.

Referenced by getId(), setId(), and toSBML().

std::string CLColorDefinition::mKey
protected

The color definition needs a key.

Definition at line 41 of file CLColorDefinition.h.

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

unsigned char CLColorDefinition::mRed
protected

Definition at line 33 of file CLColorDefinition.h.

Referenced by createValueString(), getRed(), setColorValue(), setRed(), setRGBA(), and toSBML().


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