COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CLTransformation2D Class Reference

#include <CLTransformation2D.h>

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

Public Member Functions

 CLTransformation2D ()
 
 CLTransformation2D (const double m[6])
 
 CLTransformation2D (const Transformation2D &source)
 
std::string get2DTransformationString () const
 
const double * getMatrix2D () const
 
virtual void parseTransformation (const std::string &transformationString)
 
void setMatrix (const double m[12])
 
void setMatrix2D (const double m[6])
 
- Public Member Functions inherited from CLTransformation
 CLTransformation ()
 
 CLTransformation (const double matrix[12])
 
std::string get3DTransformationString () const
 
virtual const double * getMatrix () const
 
bool is2DTransformation () const
 
bool isIdentityMatrix () const
 
bool isSetMatrix () const
 
void setMatrix (const double m[12])
 
- 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 ()
 

Static Public Member Functions

static const double * getIdentityMatrix2D ()
 
- Static Public Member Functions inherited from CLTransformation
static const double * getIdentityMatrix ()
 

Static Public Attributes

static const double IDENTITY2D [6] = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}
 
- Static Public Attributes inherited from CLTransformation
static const double IDENTITY3D [12] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}
 

Protected Member Functions

virtual void addSBMLAttributes (Transformation2D *pTransformation) const
 
void updateMatrix2D ()
 
void updateMatrix3D ()
 

Protected Attributes

double mMatrix2D [6]
 
- Protected Attributes inherited from CLTransformation
double mMatrix [12]
 
- Protected Attributes inherited from CLBase
std::string mTag
 

Detailed Description

Definition at line 21 of file CLTransformation2D.h.

Constructor & Destructor Documentation

CLTransformation2D::CLTransformation2D ( )

Constructor.

Definition at line 25 of file CLTransformation2D.cpp.

References CLTransformation::IDENTITY3D, CLTransformation::mMatrix, and updateMatrix2D().

26 {
27  unsigned int i;
28 
29  for (i = 0; i < 12; ++i)
30  {
31  mMatrix[i] = IDENTITY3D[i];
32  }
33 
34  this->updateMatrix2D();
35 }
static const double IDENTITY3D[12]
CLTransformation2D::CLTransformation2D ( const double  matrix[6])

Constructor with a matrix.

Constructor with values for the matrix.

Definition at line 40 of file CLTransformation2D.cpp.

References setMatrix2D().

41 {
42  this->setMatrix2D(matrix);
43 }
void setMatrix2D(const double m[6])
CLTransformation2D::CLTransformation2D ( const Transformation2D &  source)

Constructor to generate object from the corresponding SBML object.

Definition at line 48 of file CLTransformation2D.cpp.

References setMatrix2D(), and updateMatrix2D().

48  :
50 {
51  if (source.isSetMatrix())
52  {
53  this->setMatrix2D(source.getMatrix2D());
54  }
55  else
56  {
57  this->updateMatrix2D();
58  }
59 }
void setMatrix2D(const double m[6])

Member Function Documentation

void CLTransformation2D::addSBMLAttributes ( Transformation2D *  pTransformation) const
protectedvirtual

Adds the attributes for a 2d transformation object to the passed in. object.

Definition at line 189 of file CLTransformation2D.cpp.

References mMatrix2D.

Referenced by CLGraphicalPrimitive1D::addSBMLAttributes(), and CLImage::toSBML().

190 {
191  pTransformation->setMatrix2D(this->mMatrix2D);
192 }
std::string CLTransformation2D::get2DTransformationString ( ) const

Returns a string to represent the 2D transformation.

Definition at line 96 of file CLTransformation2D.cpp.

References mMatrix2D.

Referenced by CCopasiXML::saveTransformationAttributes().

97 {
98  // transform the matrix to a string
99  std::ostringstream os;
100  unsigned int i;
101  os << mMatrix2D[0];
102 
103  for (i = 1; i < 6; ++i)
104  {
105  os << "," << mMatrix2D[i];
106  }
107 
108  return os.str();
109 }
const double * CLTransformation2D::getIdentityMatrix2D ( )
static

Returns a 2D identity matrix. The matrix contains 6 values.

Definition at line 89 of file CLTransformation2D.cpp.

References IDENTITY2D.

90 {
91  return IDENTITY2D;
92 }
static const double IDENTITY2D[6]
const double * CLTransformation2D::getMatrix2D ( ) const

Returns the matrix. The matrix contains 6 values.

Definition at line 80 of file CLTransformation2D.cpp.

References mMatrix2D.

Referenced by transform().

81 {
82  return mMatrix2D;
83 }
void CLTransformation2D::parseTransformation ( const std::string &  transformationString)
virtual

Sets the transformation matrix from the given string. The string has to contain either 6 or 12 numerical values seperated by ",". Otherwise the matrix is set to the identity matrix.

Reimplemented from CLTransformation.

Definition at line 149 of file CLTransformation2D.cpp.

References mMatrix2D, CLTransformation::parseTransformation(), updateMatrix2D(), and updateMatrix3D().

Referenced by CCopasiXMLParser::ImageElement::start(), CCopasiXMLParser::RectangleElement::start(), CCopasiXMLParser::EllipseElement::start(), CCopasiXMLParser::TextElement::start(), CCopasiXMLParser::RenderCurveElement::start(), CCopasiXMLParser::PolygonElement::start(), and CCopasiXMLParser::GroupElement::start().

150 {
151  // the string should contain a list of 6 komma seperated numbers
152  // if it doesn't, we try to set the 3D matrix
153  bool result = true;
154  std::string delimiter = ",";
155  std::size_t lastPos = transformationString.find_first_not_of(delimiter);
156  std::size_t pos;
157  unsigned int index = 0;
158 
159  while (lastPos != std::string::npos)
160  {
161  if (index > 5)
162  {
163  result = false;
164  break;
165  }
166 
167  pos = transformationString.find_first_of(delimiter, lastPos);
168  double value = strtod(transformationString.substr(lastPos, pos - lastPos).c_str(), NULL);
169  mMatrix2D[index] = value;
170  index++;
171  lastPos = transformationString.find_first_not_of(delimiter, pos);
172  }
173 
174  if (!result || index != 6)
175  {
176  this->CLTransformation::parseTransformation(transformationString);
177  this->updateMatrix2D();
178  }
179  else
180  {
181  this->updateMatrix3D();
182  }
183 }
virtual void parseTransformation(const std::string &transformationString)
void CLTransformation2D::setMatrix ( const double  m[12])

Sets the 3D matrix. The 2D matrix is updated accordingly.

Definition at line 143 of file CLTransformation2D.cpp.

References CLTransformation::setMatrix(), and updateMatrix2D().

144 {
146  this->updateMatrix2D();
147 }
void setMatrix(const double m[12])
void CLTransformation2D::setMatrix2D ( const double  m[6])

Sets the 2D matrix. The 3D matrix is updated accordingly.

Sets the matrix.

Definition at line 64 of file CLTransformation2D.cpp.

References mMatrix2D, and updateMatrix3D().

Referenced by CLTransformation2D().

65 {
66  unsigned int i;
67 
68  for (i = 0; i < 6; ++i)
69  {
70  mMatrix2D[i] = m[i];
71  }
72 
73  this->updateMatrix3D();
74 }
void CLTransformation2D::updateMatrix2D ( )
protected

Fills the 2D matrix with data from the 3D matrix.

Definition at line 133 of file CLTransformation2D.cpp.

References CLTransformation::mMatrix, and mMatrix2D.

Referenced by CLTransformation2D(), parseTransformation(), and setMatrix().

134 {
135  mMatrix2D[0] = mMatrix[0];
136  mMatrix2D[1] = mMatrix[1];
137  mMatrix2D[2] = mMatrix[3];
138  mMatrix2D[3] = mMatrix[4];
139  mMatrix2D[4] = mMatrix[9];
140  mMatrix2D[5] = mMatrix[10];
141 }
void CLTransformation2D::updateMatrix3D ( )
protected

Sets the 3D matrix from the 2D matrix.

Definition at line 114 of file CLTransformation2D.cpp.

References CLTransformation::mMatrix, and mMatrix2D.

Referenced by parseTransformation(), and setMatrix2D().

115 {
116  mMatrix[0] = mMatrix2D[0];
117  mMatrix[1] = mMatrix2D[1];
118  mMatrix[2] = 0.0;
119  mMatrix[3] = mMatrix2D[2];
120  mMatrix[4] = mMatrix2D[3];
121  mMatrix[5] = 0.0;
122  mMatrix[6] = 0.0;
123  mMatrix[7] = 0.0;
124  mMatrix[8] = 1.0;
125  mMatrix[9] = mMatrix2D[4];
126  mMatrix[10] = mMatrix2D[5];
127  mMatrix[11] = 0.0;
128 }

Member Data Documentation

const double CLTransformation2D::IDENTITY2D = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}
static

Definition at line 24 of file CLTransformation2D.h.

Referenced by getIdentityMatrix2D().

double CLTransformation2D::mMatrix2D[6]
protected

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