COPASI API  4.16.103
Public Member Functions | Private Types | List of all members
CCopasiXMLParser::LinearGradientElement Class Reference
Inheritance diagram for CCopasiXMLParser::LinearGradientElement:
Inheritance graph
[legend]
Collaboration diagram for CCopasiXMLParser::LinearGradientElement:
Collaboration graph
[legend]

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 LinearGradientElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~LinearGradientElement ()
 
- Public Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
 CXMLElementHandler (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void end (const XML_Char *C_UNUSED(pszName))
 
virtual void reset ()
 
virtual void start (const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
 
virtual ~CXMLElementHandler ()
 

Private Types

enum  Element { LinearGradient = 0, GradientStop }
 

Additional Inherited Members

- Protected Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
void addFix (const std::string &key, CCopasiObject *pObject)
 
void deleteCurrentHandler ()
 
- Protected Attributes inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
SCopasiXMLParserCommonmCommon
 
C_INT32 mCurrentElement
 
C_INT32 mLastKnownElement
 
CCopasiXMLParsermParser
 
CXMLElementHandlermpCurrentHandler
 

Detailed Description

Definition at line 3789 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enumerator
LinearGradient 
GradientStop 

Definition at line 3796 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

CCopasiXMLParser::LinearGradientElement::LinearGradientElement ( CCopasiXMLParser parser,
SCopasiXMLParserCommon common 
)
CCopasiXMLParser::LinearGradientElement::~LinearGradientElement ( )
virtual

Destructor

Definition at line 11347 of file CCopasiXMLParser.cpp.

References pdelete.

11348 {
11350 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

void CCopasiXMLParser::LinearGradientElement::end ( const XML_Char *  pszName)
virtual

End element handler

Parameters
constXML_Char *pszName

Definition at line 11448 of file CCopasiXMLParser.cpp.

References CLRenderInformationBase::addGradientDefinition(), CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pGradient, SCopasiXMLParserCommon::pRenderInformation, START_ELEMENT, and UNKNOWN_ELEMENT.

11449 {
11450  switch (mCurrentElement)
11451  {
11452  case LinearGradient:
11453 
11454  if (strcmp(pszName, "LinearGradient"))
11456  pszName, "LinearGradient", mParser.getCurrentLineNumber());
11457 
11460  // delete the gradient since the add method made a copy
11461  delete mCommon.pGradient;
11462  mCommon.pGradient = NULL;
11463 
11464  //reset handler
11466  //call parent handler
11467  mParser.onEndElement(pszName);
11468  break;
11469 
11470  case GradientStop:
11471 
11472  if (strcmp(pszName, "Stop"))
11474  pszName, "Stop", mParser.getCurrentLineNumber());
11475 
11476  //tell the handler where to continue
11478 
11479  //no need to delete Handler (since it is the only one the destructor
11480  //will handle it)
11481  break;
11482 
11483  case UNKNOWN_ELEMENT:
11484  mCurrentElement = mLastKnownElement;
11485  break;
11486 
11487  default:
11489  pszName, "???", mParser.getCurrentLineNumber());
11490  break;
11491  }
11492 
11493  return;
11494 }
#define START_ELEMENT
#define MCXML
CLGradientBase * pGradient
void addGradientDefinition(const CLGradientBase *gradient)
CLRenderInformationBase * pRenderInformation
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::LinearGradientElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 11352 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, CLGradientBase::PAD, SCopasiXMLParserCommon::pGradient, CLGradientBase::REFLECT, CLGradientBase::REPEAT, CLGradientBase::setId(), CLLinearGradient::setPoint1(), CLLinearGradient::setPoint2(), CLGradientBase::setSpreadMethod(), and UNKNOWN_ELEMENT.

11354 {
11355  mCurrentElement++; /* We should always be on the next element */
11356 
11357  const char * X1;
11358  const char * Y1;
11359  const char * Z1;
11360  const char * X2;
11361  const char * Y2;
11362  const char * Z2;
11363  const char * ID;
11364  const char * SPREADMETHOD;
11365  CLLinearGradient* pLinearGradient = NULL;
11366 
11367  switch (mCurrentElement)
11368  {
11369  case LinearGradient:
11370 
11371  if (strcmp(pszName, "LinearGradient"))
11373  pszName, "LinearGradient", mParser.getCurrentLineNumber());
11374 
11375  X1 = mParser.getAttributeValue("x1", papszAttrs);
11376  Y1 = mParser.getAttributeValue("y1", papszAttrs);
11377  Z1 = mParser.getAttributeValue("z1", papszAttrs, false);
11378  X2 = mParser.getAttributeValue("x2", papszAttrs);
11379  Y2 = mParser.getAttributeValue("y2", papszAttrs);
11380  Z2 = mParser.getAttributeValue("z2", papszAttrs, false);
11381  ID = mParser.getAttributeValue("id", papszAttrs);
11382  SPREADMETHOD = mParser.getAttributeValue("spreadMethod", papszAttrs, "pad");
11383  pLinearGradient = new CLLinearGradient();
11384  pLinearGradient->setId(ID);
11385 
11386  if (Z1 == NULL)
11387  {
11388  pLinearGradient->setPoint1(CLRelAbsVector(X1), CLRelAbsVector(Y1));
11389  }
11390  else
11391  {
11392  pLinearGradient->setPoint1(CLRelAbsVector(X1), CLRelAbsVector(Y1), CLRelAbsVector(Z1));
11393  }
11394 
11395  if (Z2 == NULL)
11396  {
11397  pLinearGradient->setPoint2(CLRelAbsVector(X2), CLRelAbsVector(Y2));
11398  }
11399  else
11400  {
11401  pLinearGradient->setPoint2(CLRelAbsVector(X2), CLRelAbsVector(Y2), CLRelAbsVector(Z2));
11402  }
11403 
11404  if (!strcmp(SPREADMETHOD, "reflect"))
11405  {
11406  pLinearGradient->setSpreadMethod(CLGradientBase::REFLECT);
11407  }
11408  else if (!strcmp(SPREADMETHOD, "repeat"))
11409  {
11410  pLinearGradient->setSpreadMethod(CLGradientBase::REPEAT);
11411  }
11412  else
11413  {
11414  pLinearGradient->setSpreadMethod(CLGradientBase::PAD);
11415  }
11416 
11417  mCommon.pGradient = pLinearGradient;
11418  break;
11419 
11420  case GradientStop:
11421 
11422  //only one type of tags may occur here, so we can throw an exception.
11423  //No need to silently ignore unknown tags here.
11424  if (strcmp(pszName, "Stop"))
11426  pszName, "Stop", mParser.getCurrentLineNumber());
11427 
11428  //only one type of tags may occur here, so if the handler exists
11429  //it must be the correct one
11430  if (!mpCurrentHandler)
11431  mpCurrentHandler = new GradientStopElement(mParser, mCommon);
11432 
11434  mpCurrentHandler->start(pszName, papszAttrs);
11435  break;
11436 
11437  default:
11441  mParser.onStartElement(pszName, papszAttrs);
11442  break;
11443  }
11444 
11445  return;
11446 }
UnknownElement mUnknownElement
void setSpreadMethod(SPREADMETHOD method)
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
CLGradientBase * pGradient
void setPoint1(const CLRelAbsVector &x1, const CLRelAbsVector &y1, const CLRelAbsVector &z1=CLRelAbsVector(0.0, 0.0))
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
void setPoint2(const CLRelAbsVector &x1, const CLRelAbsVector &y1, const CLRelAbsVector &z1=CLRelAbsVector(0.0, 0.0))
virtual void start(const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
Definition: CXMLHandler.h:87
int getCurrentLineNumber() const
Definition: CExpat.h:470
void setId(const std::string &id)

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