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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 RadialGradientElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~RadialGradientElement ()
 
- 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 { RadialGradient = 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 3830 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enumerator
RadialGradient 
GradientStop 

Definition at line 3837 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 11503 of file CCopasiXMLParser.cpp.

References pdelete.

11504 {
11506 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 11629 of file CCopasiXMLParser.cpp.

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

11630 {
11631  switch (mCurrentElement)
11632  {
11633  case RadialGradient:
11634 
11635  if (strcmp(pszName, "RadialGradient"))
11637  pszName, "RadialGradient", mParser.getCurrentLineNumber());
11638 
11641  // delete the gradient since the add method made a copy
11642  delete mCommon.pGradient;
11643  mCommon.pGradient = NULL;
11644 
11645  //reset handler
11647  //call parent handler
11648  mParser.onEndElement(pszName);
11649  break;
11650 
11651  case GradientStop:
11652 
11653  if (strcmp(pszName, "Stop"))
11655  pszName, "Stop", mParser.getCurrentLineNumber());
11656 
11657  //tell the handler where to continue
11659 
11660  //no need to delete Handler (since it is the only one the destructor
11661  //will handle it)
11662  break;
11663 
11664  case UNKNOWN_ELEMENT:
11665  mCurrentElement = mLastKnownElement;
11666  break;
11667 
11668  default:
11670  pszName, "???", mParser.getCurrentLineNumber());
11671  break;
11672  }
11673 
11674  return;
11675 }
#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::RadialGradientElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 11508 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, CLGradientBase::PAD, SCopasiXMLParserCommon::pGradient, CLGradientBase::REFLECT, CLGradientBase::REPEAT, CLRadialGradient::setCenter(), CLRadialGradient::setFocalPoint(), CLGradientBase::setId(), CLRadialGradient::setRadius(), CLGradientBase::setSpreadMethod(), and UNKNOWN_ELEMENT.

11510 {
11511  mCurrentElement++; /* We should always be on the next element */
11512 
11513  const char * CX;
11514  const char * CY;
11515  const char * CZ;
11516  const char * R;
11517  const char * FX;
11518  const char * FY;
11519  const char * FZ;
11520  const char * ID;
11521  const char * SPREADMETHOD;
11522  CLRadialGradient* pRadialGradient = NULL;
11523 
11524  switch (mCurrentElement)
11525  {
11526  case RadialGradient:
11527 
11528  if (strcmp(pszName, "RadialGradient"))
11530  pszName, "RadialGradient", mParser.getCurrentLineNumber());
11531 
11532  CX = mParser.getAttributeValue("cx", papszAttrs, false);
11533  CY = mParser.getAttributeValue("cy", papszAttrs, false);
11534  CZ = mParser.getAttributeValue("cz", papszAttrs, false);
11535  FX = mParser.getAttributeValue("fx", papszAttrs, false);
11536  FY = mParser.getAttributeValue("fy", papszAttrs, false);
11537  FZ = mParser.getAttributeValue("fz", papszAttrs, false);
11538  R = mParser.getAttributeValue("r", papszAttrs);
11539  ID = mParser.getAttributeValue("id", papszAttrs);
11540  SPREADMETHOD = mParser.getAttributeValue("spreadMethod", papszAttrs, "pad");
11541  pRadialGradient = new CLRadialGradient();
11542  pRadialGradient->setId(ID);
11543 
11544  if (CX == NULL)
11545  {
11546  CX = "50%";
11547  }
11548 
11549  if (CY == NULL)
11550  {
11551  CY = "50%";
11552  }
11553 
11554  if (CZ == NULL)
11555  {
11556  CZ = "50%";
11557  }
11558 
11559  pRadialGradient->setCenter(CLRelAbsVector(CX), CLRelAbsVector(CY), CLRelAbsVector(CZ));
11560 
11561  if (R == NULL)
11562  {
11563  R = "50%";
11564  }
11565 
11566  pRadialGradient->setRadius(CLRelAbsVector(R));
11567 
11568  if (FX == NULL)
11569  {
11570  FX = CX;
11571  }
11572 
11573  if (FY == NULL)
11574  {
11575  FY = CY;
11576  }
11577 
11578  if (FZ == NULL)
11579  {
11580  FZ = CZ;
11581  }
11582 
11583  pRadialGradient->setFocalPoint(CLRelAbsVector(FX), CLRelAbsVector(FY), CLRelAbsVector(FZ));
11584 
11585  if (!strcmp(SPREADMETHOD, "reflect"))
11586  {
11587  pRadialGradient->setSpreadMethod(CLGradientBase::REFLECT);
11588  }
11589  else if (!strcmp(SPREADMETHOD, "repeat"))
11590  {
11591  pRadialGradient->setSpreadMethod(CLGradientBase::REPEAT);
11592  }
11593  else
11594  {
11595  pRadialGradient->setSpreadMethod(CLGradientBase::PAD);
11596  }
11597 
11598  mCommon.pGradient = pRadialGradient;
11599  break;
11600 
11601  case GradientStop:
11602 
11603  //only one type of tags may occur here, so we can throw an exception.
11604  //No need to silently ignore unknown tags here.
11605  if (strcmp(pszName, "Stop"))
11607  pszName, "Stop", mParser.getCurrentLineNumber());
11608 
11609  //only one type of tags may occur here, so if the handler exists
11610  //it must be the correct one
11611  if (!mpCurrentHandler)
11612  mpCurrentHandler = new GradientStopElement(mParser, mCommon);
11613 
11615  mpCurrentHandler->start(pszName, papszAttrs);
11616  break;
11617 
11618  default:
11622  mParser.onStartElement(pszName, papszAttrs);
11623  break;
11624  }
11625 
11626  return;
11627 }
void setRadius(const CLRelAbsVector &r)
void setCenter(const CLRelAbsVector &x, const CLRelAbsVector &y, const CLRelAbsVector &z=CLRelAbsVector(0.0, 0.0))
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
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
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 setFocalPoint(const CLRelAbsVector &x, const CLRelAbsVector &y, const CLRelAbsVector &z=CLRelAbsVector(0.0, 0.0))
void setId(const std::string &id)

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