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

#include <CLTransformation.h>

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

Public Member Functions

 CLTransformation ()
 
 CLTransformation (const double matrix[12])
 
std::string get3DTransformationString () const
 
virtual const double * getMatrix () const
 
bool is2DTransformation () const
 
bool isIdentityMatrix () const
 
bool isSetMatrix () const
 
virtual void parseTransformation (const std::string &transformationString)
 
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 * getIdentityMatrix ()
 

Static Public Attributes

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 Attributes

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

Detailed Description

Definition at line 23 of file CLTransformation.h.

Constructor & Destructor Documentation

CLTransformation::CLTransformation ( )

Default constructor. All matrix elements are set to NaN

Definition at line 28 of file CLTransformation.cpp.

References mMatrix.

28  : CLBase()
29 {
30  unsigned int i;
31 
32  for (i = 0; i < 12; ++i)
33  {
34  mMatrix[i] = std::numeric_limits<double>::quiet_NaN();
35  }
36 }
CLBase()
Definition: CLBase.h:36
CLTransformation::CLTransformation ( const double  matrix[12])

Constructor with values for the matrix.

Constructor with id and values for the matrix.

Definition at line 41 of file CLTransformation.cpp.

References mMatrix.

41  : CLBase()
42 {
43  unsigned int i;
44 
45  for (i = 0; i < 12; ++i)
46  {
47  mMatrix[i] = matrix[i];
48  }
49 }
CLBase()
Definition: CLBase.h:36

Member Function Documentation

std::string CLTransformation::get3DTransformationString ( ) const

Returns a string to represent the 3D transformation.

Definition at line 125 of file CLTransformation.cpp.

References mMatrix.

Referenced by CCopasiXML::saveTransformationAttributes().

126 {
127  // transform the matrix to a string
128  std::ostringstream os;
129  unsigned int i;
130  os << mMatrix[0];
131 
132  for (i = 1; i < 12; ++i)
133  {
134  os << "," << mMatrix[i];
135  }
136 
137  return os.str();
138 }
const double * CLTransformation::getIdentityMatrix ( )
static

Returns the 3D identity matrix. The matrix contains 12 values.

Definition at line 77 of file CLTransformation.cpp.

References IDENTITY3D.

Referenced by CLGroupAttributes::CLGroupAttributes(), and CLLayoutRenderer::draw_curve().

78 {
79  return IDENTITY3D;
80 }
static const double IDENTITY3D[12]
const double * CLTransformation::getMatrix ( ) const
virtual

Returns the matrix.

Returns the matrix. The matrix contains 12 values.

Definition at line 68 of file CLTransformation.cpp.

References mMatrix.

Referenced by CLLayoutRenderer::extract_transformation_attributes().

69 {
70  return mMatrix;
71 }
bool CLTransformation::is2DTransformation ( ) const

Checks if the transformation is a 2D transformation, i.e. we have to check some of the values.

Definition at line 112 of file CLTransformation.cpp.

References mMatrix.

Referenced by CCopasiXML::saveTransformationAttributes().

113 {
114  return mMatrix[2] == 0.0 &&
115  mMatrix[5] == 0.0 &&
116  mMatrix[6] == 0.0 &&
117  mMatrix[7] == 0.0 &&
118  mMatrix[8] == 1.0 &&
119  mMatrix[11] == 0.0;
120 }
bool CLTransformation::isIdentityMatrix ( ) const

Returns true if the matrix is the identity matrix.

Definition at line 103 of file CLTransformation.cpp.

References IDENTITY3D, and mMatrix.

Referenced by CCopasiXML::saveTransformationAttributes().

104 {
105  return !memcmp(mMatrix, CLTransformation::IDENTITY3D, sizeof(double)*12);
106 }
static const double IDENTITY3D[12]
bool CLTransformation::isSetMatrix ( ) const

Returns true if the matrix has been set or false otherwise.

Definition at line 87 of file CLTransformation.cpp.

References mMatrix.

Referenced by CLLayoutRenderer::extract_transformation_attributes(), CCopasiXML::saveTransformationAttributes(), and transform().

88 {
89  bool result = true;
90  unsigned int i;
91 
92  for (i = 0; result && i < 12; ++i)
93  {
94  result = (mMatrix[i] == mMatrix[i]);
95  }
96 
97  return result;
98 }
void CLTransformation::parseTransformation ( const std::string &  transformationString)
virtual

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

Reimplemented in CLTransformation2D.

Definition at line 145 of file CLTransformation.cpp.

References IDENTITY3D, mMatrix, and setMatrix().

Referenced by CLTransformation2D::parseTransformation().

146 {
147  // the string should contain a list of 6 komma seperated numbers
148  // if it doesn't, we try to set the 3D matrix
149  bool result = true;
150  std::string delimiter = ",";
151  std::size_t lastPos = transformationString.find_first_not_of(delimiter);
152  std::size_t pos;
153  unsigned int index = 0;
154 
155  while (lastPos != std::string::npos)
156  {
157  if (index > 11)
158  {
159  result = false;
160  break;
161  }
162 
163  pos = transformationString.find_first_of(delimiter, lastPos);
164  double value = strtod(transformationString.substr(lastPos, pos - lastPos).c_str(), NULL);
165  mMatrix[index] = value;
166  index++;
167  lastPos = transformationString.find_first_not_of(delimiter, pos);
168  }
169 
170  if (!result || index != 12)
171  {
173  }
174 }
void setMatrix(const double m[12])
static const double IDENTITY3D[12]
void CLTransformation::setMatrix ( const double  m[12])

Sets the matrix.

Definition at line 54 of file CLTransformation.cpp.

References mMatrix.

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

55 {
56  unsigned int i;
57 
58  for (i = 0; i < 12; ++i)
59  {
60  mMatrix[i] = m[i];
61  }
62 }

Member Data Documentation

const double CLTransformation::IDENTITY3D = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}
static
double CLTransformation::mMatrix[12]
protected

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