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

Public Member Functions

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

Member Enumeration Documentation

Enumerator
RenderCurve 
ListOfElements 

Definition at line 4243 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 12142 of file CCopasiXMLParser.cpp.

References pdelete.

12143 {
12145 }
#define pdelete(p)
Definition: copasi.h:215

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 12244 of file CCopasiXMLParser.cpp.

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

12245 {
12246  switch (mCurrentElement)
12247  {
12248  case RenderCurve:
12249 
12250  if (strcmp(pszName, "Curve"))
12252  pszName, "Curve", mParser.getCurrentLineNumber());
12253 
12256 
12257  //reset handler
12259  //call parent handler
12260  mParser.onEndElement(pszName);
12261  break;
12262 
12263  case ListOfElements:
12264 
12265  if (strcmp(pszName, "ListOfElements"))
12267  pszName, "ListOfElements", mParser.getCurrentLineNumber());
12268 
12269  //tell the handler where to continue
12271 
12272  //no need to delete Handler (since it is the only one the destructor
12273  //will handle it)
12274  break;
12275 
12276  case UNKNOWN_ELEMENT:
12277  mCurrentElement = mLastKnownElement;
12278  break;
12279 
12280  default:
12282  pszName, "???", mParser.getCurrentLineNumber());
12283  break;
12284  }
12285 
12286  return;
12287 }
#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::RenderCurveElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 12147 of file CCopasiXMLParser.cpp.

References CLGroup::addChildElement(), CCopasiMessage::EXCEPTION, CLGroup::getElement(), CLRenderCurve::getListOfCurveElements(), CLGroup::getNumElements(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, CLGraphicalPrimitive1D::parseDashArray(), CLTransformation2D::parseTransformation(), SCopasiXMLParserCommon::pGroup, SCopasiXMLParserCommon::pListOfCurveElements, CLRenderCurve::setEndHead(), CLRenderCurve::setStartHead(), CLGraphicalPrimitive1D::setStroke(), CLGraphicalPrimitive1D::setStrokeWidth(), strToDouble(), and UNKNOWN_ELEMENT.

12149 {
12150  mCurrentElement++; /* We should always be on the next element */
12151 
12152  const char * Transform;
12153  const char * Stroke;
12154  const char * StrokeWidth;
12155  const char * StrokeDashArray;
12156  const char * StartHead;
12157  const char * EndHead;
12158  CLRenderCurve* pRenderCurve = NULL;
12159 
12160  switch (mCurrentElement)
12161  {
12162  case RenderCurve:
12163 
12164  if (strcmp(pszName, "Curve"))
12166  pszName, "Curve", mParser.getCurrentLineNumber());
12167 
12168  Transform = mParser.getAttributeValue("transform", papszAttrs, false);
12169  Stroke = mParser.getAttributeValue("stroke", papszAttrs, false);
12170  StrokeWidth = mParser.getAttributeValue("stroke-width", papszAttrs, false);
12171  StrokeDashArray = mParser.getAttributeValue("stroke-dasharray", papszAttrs, false);
12172  StartHead = mParser.getAttributeValue("startHead", papszAttrs, false);
12173  EndHead = mParser.getAttributeValue("endHead", papszAttrs, false);
12174  pRenderCurve = new CLRenderCurve();
12175 
12176  if (Transform != NULL)
12177  {
12178  pRenderCurve->parseTransformation(Transform);
12179  }
12180 
12181  if (Stroke != NULL)
12182  {
12183  pRenderCurve->setStroke(Stroke);
12184  }
12185 
12186  if (StrokeWidth != NULL)
12187  {
12188  double width = strToDouble(StrokeWidth, NULL);
12189  pRenderCurve->setStrokeWidth(width);
12190  }
12191 
12192  if (StrokeDashArray != NULL)
12193  {
12194  pRenderCurve->parseDashArray(StrokeDashArray);
12195  }
12196 
12197  if (StartHead != NULL)
12198  {
12199  pRenderCurve->setStartHead(StartHead);
12200  }
12201 
12202  if (EndHead != NULL)
12203  {
12204  pRenderCurve->setEndHead(EndHead);
12205  }
12206 
12207  assert(mCommon.pGroup != NULL);
12208  mCommon.pGroup->addChildElement(pRenderCurve);
12209  // delete the polygon again since the addElement method made a copy
12210  delete pRenderCurve;
12211  pRenderCurve = dynamic_cast<CLRenderCurve*>(mCommon.pGroup->getElement(mCommon.pGroup->getNumElements() - 1));
12212  assert(pRenderCurve != NULL);
12214  break;
12215 
12216  case ListOfElements:
12217 
12218  //only one type of tags may occur here, so we can throw an exception.
12219  //No need to silently ignore unknown tags here.
12220  if (strcmp(pszName, "ListOfElements"))
12222  pszName, "ListOfElements", mParser.getCurrentLineNumber());
12223 
12224  //only one type of tags may occur here, so if the handler exists
12225  //it must be the correct one
12226  if (!mpCurrentHandler)
12227  mpCurrentHandler = new ListOfCurveElementsElement(mParser, mCommon);
12228 
12230  mpCurrentHandler->start(pszName, papszAttrs);
12231  break;
12232 
12233  default:
12237  mParser.onStartElement(pszName, papszAttrs);
12238  break;
12239  }
12240 
12241  return;
12242 }
UnknownElement mUnknownElement
void setStartHead(const std::string &startHead)
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)
void setEndHead(const std::string &endHead)
#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)
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 * > * pListOfCurveElements
int getCurrentLineNumber() const
Definition: CExpat.h:470
const std::vector< CLRenderPoint * > * getListOfCurveElements() const
void setStrokeWidth(double width)
size_t getNumElements() const
Definition: CLGroup.cpp:384
void addChildElement(const CLTransformation2D *pChild)
Definition: CLGroup.cpp:517
virtual void parseTransformation(const std::string &transformationString)

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