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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 PolygonElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~PolygonElement ()
 
- 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 { Polygon = 0, ListOfElements }
 

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 4277 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enumerator
Polygon 
ListOfElements 

Definition at line 4284 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 11976 of file CCopasiXMLParser.cpp.

References pdelete.

11977 {
11979 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 12090 of file CCopasiXMLParser.cpp.

References CCopasiMessage::EXCEPTION, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pListOfCurveElements, START_ELEMENT, and UNKNOWN_ELEMENT.

12091 {
12092  switch (mCurrentElement)
12093  {
12094  case Polygon:
12095 
12096  if (strcmp(pszName, "Polygon"))
12098  pszName, "Polygon", mParser.getCurrentLineNumber());
12099 
12102 
12103  //reset handler
12105  //call parent handler
12106  mParser.onEndElement(pszName);
12107  break;
12108 
12109  case ListOfElements:
12110 
12111  if (strcmp(pszName, "ListOfElements"))
12113  pszName, "ListOfElements", mParser.getCurrentLineNumber());
12114 
12115  //tell the handler where to continue
12117 
12118  //no need to delete Handler (since it is the only one the destructor
12119  //will handle it)
12120  break;
12121 
12122  case UNKNOWN_ELEMENT:
12123  mCurrentElement = mLastKnownElement;
12124  break;
12125 
12126  default:
12128  pszName, "???", mParser.getCurrentLineNumber());
12129  break;
12130  }
12131 
12132  return;
12133 }
#define START_ELEMENT
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
std::vector< CLRenderPoint * > * pListOfCurveElements
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::PolygonElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 11981 of file CCopasiXMLParser.cpp.

References CLGroup::addChildElement(), CLGraphicalPrimitive2D::EVENODD, CCopasiMessage::EXCEPTION, CLGroup::getElement(), CLPolygon::getListOfElements(), CLGroup::getNumElements(), CLGraphicalPrimitive2D::INHERIT, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, CLGraphicalPrimitive2D::NONZERO, CLGraphicalPrimitive1D::parseDashArray(), CLTransformation2D::parseTransformation(), SCopasiXMLParserCommon::pGroup, SCopasiXMLParserCommon::pListOfCurveElements, CLGraphicalPrimitive2D::setFillColor(), CLGraphicalPrimitive2D::setFillRule(), CLGraphicalPrimitive1D::setStroke(), CLGraphicalPrimitive1D::setStrokeWidth(), strToDouble(), and UNKNOWN_ELEMENT.

11983 {
11984  mCurrentElement++; /* We should always be on the next element */
11985 
11986  const char * Transform;
11987  const char * Stroke;
11988  const char * StrokeWidth;
11989  const char * StrokeDashArray;
11990  const char * Fill;
11991  const char * FillRule;
11992  CLPolygon* pPolygon = NULL;
11993 
11994  switch (mCurrentElement)
11995  {
11996  case Polygon:
11997 
11998  if (strcmp(pszName, "Polygon"))
12000  pszName, "Polygon", mParser.getCurrentLineNumber());
12001 
12002  Transform = mParser.getAttributeValue("transform", papszAttrs, false);
12003  Stroke = mParser.getAttributeValue("stroke", papszAttrs, false);
12004  StrokeWidth = mParser.getAttributeValue("stroke-width", papszAttrs, false);
12005  StrokeDashArray = mParser.getAttributeValue("stroke-dasharray", papszAttrs, false);
12006  Fill = mParser.getAttributeValue("fill", papszAttrs, false);
12007  FillRule = mParser.getAttributeValue("fill-rule", papszAttrs, false);
12008  pPolygon = new CLPolygon();
12009 
12010  if (Transform != NULL)
12011  {
12012  pPolygon->parseTransformation(Transform);
12013  }
12014 
12015  if (Stroke != NULL)
12016  {
12017  pPolygon->setStroke(Stroke);
12018  }
12019 
12020  if (StrokeWidth != NULL)
12021  {
12022  double width = strToDouble(StrokeWidth, NULL);
12023  pPolygon->setStrokeWidth(width);
12024  }
12025 
12026  if (StrokeDashArray != NULL)
12027  {
12028  pPolygon->parseDashArray(StrokeDashArray);
12029  }
12030 
12031  if (Fill != NULL)
12032  {
12033  pPolygon->setFillColor(Fill);
12034  }
12035 
12036  if (FillRule != NULL)
12037  {
12038  std::string f(FillRule);
12039 
12040  if (f == "nonzero")
12041  {
12043  }
12044  else if (f == "evenodd")
12045  {
12047  }
12048  else
12049  {
12051  }
12052  }
12053 
12054  mCommon.pGroup->addChildElement(pPolygon);
12055  // delete the polygon again since the addElement method made a copy
12056  delete pPolygon;
12057  pPolygon = dynamic_cast<CLPolygon*>(mCommon.pGroup->getElement(mCommon.pGroup->getNumElements() - 1));
12058  assert(pPolygon != NULL);
12060  break;
12061 
12062  case ListOfElements:
12063 
12064  //only one type of tags may occur here, so we can throw an exception.
12065  //No need to silently ignore unknown tags here.
12066  if (strcmp(pszName, "ListOfElements"))
12068  pszName, "ListOfElements", mParser.getCurrentLineNumber());
12069 
12070  //only one type of tags may occur here, so if the handler exists
12071  //it must be the correct one
12072  if (!mpCurrentHandler)
12073  mpCurrentHandler = new ListOfCurveElementsElement(mParser, mCommon);
12074 
12076  mpCurrentHandler->start(pszName, papszAttrs);
12077  break;
12078 
12079  default:
12083  mParser.onStartElement(pszName, papszAttrs);
12084  break;
12085  }
12086 
12087  return;
12088 }
UnknownElement mUnknownElement
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
void parseDashArray(const std::string &s)
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CCopasiObject * getElement(size_t n)
Definition: CLGroup.cpp:409
void setStroke(const std::string &key)
void setFillColor(const std::string &color)
virtual void start(const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
Definition: CXMLHandler.h:87
double strToDouble(const char *str, char const **pTail)
Definition: utility.cpp:325
std::vector< CLRenderPoint * > * getListOfElements()
Definition: CLPolygon.cpp:108
std::vector< CLRenderPoint * > * pListOfCurveElements
int getCurrentLineNumber() const
Definition: CExpat.h:470
void setStrokeWidth(double width)
size_t getNumElements() const
Definition: CLGroup.cpp:384
void addChildElement(const CLTransformation2D *pChild)
Definition: CLGroup.cpp:517
void setFillRule(FILL_RULE rule)
virtual void parseTransformation(const std::string &transformationString)

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