1 /**
2 * @file GraphicalPrimitive1D.cpp
3 * @brief abstract base class for graphical 1D objects
4 * @author Ralph Gauges
5 * @author Frank T. Bergmann
6 *
7 * <!--------------------------------------------------------------------------
8 * This file is part of libSBML. Please visit http://sbml.org for more
9 * information about SBML, and the latest version of libSBML.
10 *
11 * Copyright (C) 2020 jointly by the following organizations:
12 * 1. California Institute of Technology, Pasadena, CA, USA
13 * 2. University of Heidelberg, Heidelberg, Germany
14 * 3. University College London, London, UK
15 *
16 * Copyright (C) 2019 jointly by the following organizations:
17 * 1. California Institute of Technology, Pasadena, CA, USA
18 * 2. University of Heidelberg, Heidelberg, Germany
19 *
20 * Copyright (C) 2013-2018 jointly by the following organizations:
21 * 1. California Institute of Technology, Pasadena, CA, USA
22 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
23 * 3. University of Heidelberg, Heidelberg, Germany
24 *
25 * Copyright (C) 2011-2013 jointly by the following organizations:
26 * 1. California Institute of Technology, Pasadena, CA, USA
27 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
28 *
29 * Copyright 2010 Ralph Gauges
30 * Group for the modeling of biological processes
31 * University of Heidelberg
32 * Im Neuenheimer Feld 267
33 * 69120 Heidelberg
34 * Germany
35 *
36 * This library is free software; you can redistribute it and/or modify it
37 * under the terms of the GNU Lesser General Public License as published by
38 * the Free Software Foundation. A copy of the license agreement is provided
39 * in the file named "LICENSE.txt" included with this software distribution
40 * and also available online as http://sbml.org/software/libsbml/license.html
41 * ---------------------------------------------------------------------- -->*/
42
43 #include <sbml/packages/render/sbml/GraphicalPrimitive1D.h>
44 #include <sbml/packages/render/validator/RenderSBMLError.h>
45
46 #include <sbml/packages/render/sbml/Ellipse.h>
47 #include <sbml/packages/render/sbml/Rectangle.h>
48 #include <sbml/packages/render/sbml/Polygon.h>
49 #include <sbml/packages/render/sbml/RenderGroup.h>
50 #include <sbml/packages/render/sbml/ListOfDrawables.h>
51 #include <sbml/packages/render/sbml/LineEnding.h>
52 #include <sbml/packages/render/sbml/ListOfLineEndings.h>
53 #include <sbml/packages/render/sbml/Text.h>
54 #include <sbml/packages/render/sbml/RenderCurve.h>
55
56
57 using namespace std;
58
59 #include <limits>
60 #include <sstream>
61 #include <string.h>
62 #ifndef OMIT_DEPRECATED
63 #ifdef DEPRECATION_WARNINGS
64 #include <iostream>
65 #endif // DEPRECATION_WARNINGS
66 #endif // OMIT_DEPRECATED
67
68 LIBSBML_CPP_NAMESPACE_BEGIN
69
70
71
72
73 #ifdef __cplusplus
74
75
76 /*
77 * Creates a new GraphicalPrimitive1D using the given SBML Level, Version and
78 * “render” package version.
79 */
GraphicalPrimitive1D(unsigned int level,unsigned int version,unsigned int pkgVersion)80 GraphicalPrimitive1D::GraphicalPrimitive1D(unsigned int level,
81 unsigned int version,
82 unsigned int pkgVersion)
83 : Transformation2D(level, version, pkgVersion)
84 ,mStroke("")
85 ,mStrokeWidth(std::numeric_limits<double>::quiet_NaN())
86 , mIsSetStrokeWidth (false)
87 {
88 setSBMLNamespacesAndOwn(new RenderPkgNamespaces(level, version, pkgVersion));
89 }
90
91
92 /*
93 * Creates a new GraphicalPrimitive1D using the given RenderPkgNamespaces
94 * object.
95 */
GraphicalPrimitive1D(RenderPkgNamespaces * renderns)96 GraphicalPrimitive1D::GraphicalPrimitive1D(RenderPkgNamespaces *renderns)
97 : Transformation2D(renderns)
98 , mStroke ("")
99 ,mStrokeWidth(std::numeric_limits<double>::quiet_NaN())
100 , mIsSetStrokeWidth (false)
101 {
102 // set the element namespace of this object
103 setElementNamespace(renderns->getURI());
104
105 // connect child elements to this element.
106 connectToChild();
107
108 // load package extensions bound with this object (if any)
109 loadPlugins(renderns);
110 }
111
112
113 /*
114 * Creates a new GraphicalPrimitive1D object from the given XMLNode object.
115 * The XMLNode object has to contain a valid XML representation of a
116 * GraphicalPrimitive1D object as defined in the render extension specification.
117 * This method is normally called when render information is read from a file and
118 * should normally not have to be called explicitly.
119 *
120 * @param node the XMLNode object reference that describes the GraphicalPrimitive1D
121 * object to be instantiated.
122 */
GraphicalPrimitive1D(const XMLNode & node,unsigned int l2version)123 GraphicalPrimitive1D::GraphicalPrimitive1D(const XMLNode& node, unsigned int l2version)
124 :Transformation2D(node, l2version)
125 {
126 const XMLAttributes& attributes=node.getAttributes();
127 const XMLNode* child;
128
129 ExpectedAttributes ea;
130 addExpectedAttributes(ea);
131 this->readAttributes(attributes,ea);
132 unsigned int n=0,nMax = node.getNumChildren();
133 while(n<nMax)
134 {
135 child=&node.getChild(n);
136 const std::string& childName=child->getName();
137 if(childName=="annotation")
138 {
139 this->mAnnotation=new XMLNode(*child);
140 }
141 else if(childName=="notes")
142 {
143 this->mNotes=new XMLNode(*child);
144 }
145 ++n;
146 }
147
148
149 setSBMLNamespacesAndOwn(new RenderPkgNamespaces(2,l2version));
150
151 connectToChild();
152 }
153
154
155 #ifndef OMIT_DEPRECATED
156 /** @cond doxygenLibsbmlInternal */
157 /*
158 * Constructor which creates a GraphicalPrimitive1D.
159 * The transformation properties are not set, neither is the stroke or the stroke width.
160 * The id is set to the given string.
161 *
162 * @param id The id for the GraphicalPrimitive1D object
163 *
164 * This constructor is deprecated. The new libsbml API only has
165 * constructors which take the SBML level and version or one that takes
166 * an SBMLNamespaces object.
167 */
GraphicalPrimitive1D(RenderPkgNamespaces * renderns,const std::string & id)168 GraphicalPrimitive1D::GraphicalPrimitive1D(RenderPkgNamespaces* renderns, const std::string& id):
169 Transformation2D(renderns)
170 // ,mId(id)
171 ,mStroke("")
172 ,mStrokeWidth(std::numeric_limits<double>::quiet_NaN())
173 {
174 #ifdef DEPRECATION_WARNINGS
175 std::cerr << "Warning. GraphicalPrimitive1D::GraphicalPrimitive1D(const std::string& id) is deprecated." << std::endl;
176 #endif // DEPRECATION_WARNINGS
177 setId(id);
178
179 // set the element namespace of this object
180 setElementNamespace(renderns->getURI());
181
182 // connect child elements to this element.
183 connectToChild();
184
185 // load package extensions bound with this object (if any)
186 loadPlugins(renderns);
187 }
188 /** @endcond */
189 #endif // OMIT_DEPRECATED
190
191
192 /*
193 * Copy constructor for GraphicalPrimitive1D.
194 */
GraphicalPrimitive1D(const GraphicalPrimitive1D & orig)195 GraphicalPrimitive1D::GraphicalPrimitive1D(const GraphicalPrimitive1D& orig)
196 : Transformation2D( orig )
197 , mStroke ( orig.mStroke )
198 , mStrokeWidth ( orig.mStrokeWidth )
199 , mIsSetStrokeWidth ( orig.mIsSetStrokeWidth )
200 , mStrokeDashArray (orig.mStrokeDashArray)
201 {
202 }
203
204
205 /*
206 * Assignment operator for GraphicalPrimitive1D.
207 */
208 GraphicalPrimitive1D&
operator =(const GraphicalPrimitive1D & rhs)209 GraphicalPrimitive1D::operator=(const GraphicalPrimitive1D& rhs)
210 {
211 if (&rhs != this)
212 {
213 Transformation2D::operator=(rhs);
214 mStroke = rhs.mStroke;
215 mStrokeWidth = rhs.mStrokeWidth;
216 mIsSetStrokeWidth = rhs.mIsSetStrokeWidth;
217 mStrokeDashArray = rhs.mStrokeDashArray;
218 }
219
220 return *this;
221 }
222
223
224 /*
225 * Creates and returns a deep copy of this GraphicalPrimitive1D object.
226 */
227 GraphicalPrimitive1D*
clone() const228 GraphicalPrimitive1D::clone() const
229 {
230 return (GraphicalPrimitive1D*)(Transformation::clone());
231 }
232
233
234 /*
235 * Destructor for GraphicalPrimitive1D.
236 */
~GraphicalPrimitive1D()237 GraphicalPrimitive1D::~GraphicalPrimitive1D()
238 {
239 }
240
241
242 /*
243 * Returns the value of the "id" attribute of this GraphicalPrimitive1D.
244 */
245 const std::string&
getId() const246 GraphicalPrimitive1D::getId() const
247 {
248 return mId;
249 }
250
251
252 /*
253 * Returns the value of the "stroke" attribute of this GraphicalPrimitive1D.
254 */
255 const std::string&
getStroke() const256 GraphicalPrimitive1D::getStroke() const
257 {
258 return mStroke;
259 }
260
261
262 /*
263 * Returns the value of the "stroke-width" attribute of this
264 * GraphicalPrimitive1D.
265 */
266 double
getStrokeWidth() const267 GraphicalPrimitive1D::getStrokeWidth() const
268 {
269 return mStrokeWidth;
270 }
271
272
273 /*
274 * Returns the value of the "stroke-dasharray" attribute of this
275 * GraphicalPrimitive1D.
276 */
277 const std::vector<unsigned int>&
getStrokeDashArray() const278 GraphicalPrimitive1D::getStrokeDashArray() const
279 {
280 return this->mStrokeDashArray;
281 }
282
283
284 /** @cond doxygenLibsbmlInternal */
285 /*
286 * Returns a const reference to the stroke dasharray.
287 *
288 * @return const reference to stroke dash array
289 */
getDashArray() const290 const std::vector<unsigned int>& GraphicalPrimitive1D::getDashArray() const
291 {
292 return this->mStrokeDashArray;
293 }
294 /** @endcond */
295
296 /** @cond doxygenLibsbmlInternal */
297 /*
298 * Returns a reference to the stroke dasharray.
299 *
300 * @return reference to stroke dash array
301 */
getDashArray()302 std::vector<unsigned int>& GraphicalPrimitive1D::getDashArray()
303 {
304 return this->mStrokeDashArray;
305 }
306 /** @endcond */
307
308 /*
309 * Predicate returning @c true if this GraphicalPrimitive1D's "id" attribute is
310 * set.
311 */
312 bool
isSetId() const313 GraphicalPrimitive1D::isSetId() const
314 {
315 return (mId.empty() == false);
316 }
317
318
319 /*
320 * Predicate returning @c true if this GraphicalPrimitive1D's "stroke"
321 * attribute is set.
322 */
323 bool
isSetStroke() const324 GraphicalPrimitive1D::isSetStroke() const
325 {
326 return (!this->mStroke.empty()) && (this->mStroke != "none");
327 }
328
329
330 /*
331 * Predicate returning @c true if this GraphicalPrimitive1D's "stroke-width"
332 * attribute is set.
333 */
334 bool
isSetStrokeWidth() const335 GraphicalPrimitive1D::isSetStrokeWidth() const
336 {
337 return mIsSetStrokeWidth;
338 }
339
340
341 /*
342 * Predicate returning @c true if this GraphicalPrimitive1D's
343 * "stroke-dasharray" attribute is set.
344 */
345 bool
isSetStrokeDashArray() const346 GraphicalPrimitive1D::isSetStrokeDashArray() const
347 {
348 bool result=true;
349 if(mStrokeDashArray.empty() || mStrokeDashArray[0]!=mStrokeDashArray[0])
350 {
351 result=false;
352 }
353 return result;
354 }
355
356 /*
357 * Returns true if the dash array has been set or false otherwise.
358 * The array is considered set if it is not empty and if the first entry is
359 * not NaN.
360 *
361 * @true if the dasharray is set.
362 */
isSetDashArray() const363 bool GraphicalPrimitive1D::isSetDashArray() const
364 {
365 bool result=true;
366 if(mStrokeDashArray.empty() || mStrokeDashArray[0]!=mStrokeDashArray[0])
367 {
368 result=false;
369 }
370 return result;
371 }
372
373
374 /*
375 * Sets the value of the "id" attribute of this GraphicalPrimitive1D.
376 */
377 int
setId(const std::string & id)378 GraphicalPrimitive1D::setId(const std::string& id)
379 {
380 return SyntaxChecker::checkAndSetSId(id, mId);
381 }
382
383
384 /*
385 * Sets the value of the "stroke" attribute of this GraphicalPrimitive1D.
386 */
387 int
setStroke(const std::string & stroke)388 GraphicalPrimitive1D::setStroke(const std::string& stroke)
389 {
390 mStroke = stroke;
391 return LIBSBML_OPERATION_SUCCESS;
392 }
393
394
395 /*
396 * Sets the value of the "stroke-width" attribute of this GraphicalPrimitive1D.
397 */
398 int
setStrokeWidth(double strokeWidth)399 GraphicalPrimitive1D::setStrokeWidth(double strokeWidth)
400 {
401 mStrokeWidth = strokeWidth;
402 mIsSetStrokeWidth = true;
403 return LIBSBML_OPERATION_SUCCESS;
404 }
405
406
407 /*
408 * Sets the value of the "stroke-dasharray" attribute of this
409 * GraphicalPrimitive1D.
410 */
411 int
setStrokeDashArray(const std::vector<unsigned int> & array)412 GraphicalPrimitive1D::setStrokeDashArray(const std::vector<unsigned int>& array)
413 {
414 this->mStrokeDashArray = array;
415
416 return LIBSBML_OPERATION_SUCCESS;
417 }
418
419
420 /*
421 * Sets the dasharray to the values in the given array.
422 *
423 * @param array Array of alternating stroke and gap length values.
424 */
setDashArray(const std::vector<unsigned int> & array)425 void GraphicalPrimitive1D::setDashArray(const std::vector<unsigned int>& array)
426 {
427 this->mStrokeDashArray=array;
428 }
429
430
431 /*
432 * Sets the dasharray from the given string.
433 * If the string is not a valid dasharray string, false
434 * is returned and the dasharray remains in the state is was
435 * before the call.
436 *
437 * The individual numerical values in the string have to be separated by kommas.
438 *
439 * @param arrayString a string with number representing a dash array.
440 *
441 * @return @c true if setting the dasharray from the string succeed or @c false otherwise.
442 */
setDashArray(const std::string & arrayString)443 bool GraphicalPrimitive1D::setDashArray(const std::string& arrayString)
444 {
445 std::vector<unsigned int> array;
446 bool result=false;
447 if(this->parseDashArray(arrayString,array)==true)
448 {
449 this->mStrokeDashArray=array;
450 result=true;
451 }
452 return result;
453 }
454
455
456 /*
457 * Returns the number of defined dashes.
458 */
459 unsigned int
getNumDashes() const460 GraphicalPrimitive1D::getNumDashes() const
461 {
462 return (unsigned int)mStrokeDashArray.size();
463 }
464
465 /*
466 * Returns the dash at the given index.
467 */
468 unsigned int
getDashByIndex(unsigned int index) const469 GraphicalPrimitive1D::getDashByIndex(unsigned int index) const
470 {
471 if (index >= getNumDashes())
472 return -1;
473 return mStrokeDashArray[index];
474 }
475
476 /*
477 * Adds a new length of a dash to the 'stroke-dasharray' attribute.
478 */
479 void
addDash(unsigned int dash)480 GraphicalPrimitive1D::addDash(unsigned int dash)
481 {
482 mStrokeDashArray.push_back(dash);
483 }
484
485 /*
486 * Unsets the 'stroke-dasharray' attribute.
487 */
488 void
clearDashes()489 GraphicalPrimitive1D::clearDashes()
490 {
491 mStrokeDashArray.clear();
492 }
493
494 /*
495 * Sets the dash at the given position.
496 */
497 void
setDashByIndex(unsigned int index,unsigned int dash)498 GraphicalPrimitive1D::setDashByIndex(unsigned int index, unsigned int dash)
499 {
500 if (index >= getNumDashes()) return;
501 mStrokeDashArray[index]=dash;
502 }
503
504 /*
505 * Removes the dash at the given index
506 */
507 void
removeDash(unsigned int index)508 GraphicalPrimitive1D::removeDash(unsigned int index)
509 {
510 if (index >= getNumDashes()) return;
511 mStrokeDashArray.erase(mStrokeDashArray.begin() + index);
512 }
513
514 /*
515 * Inserts the dash at the given position.
516 */
517 void
insertDash(unsigned int index,unsigned int dash)518 GraphicalPrimitive1D::insertDash(unsigned int index, unsigned int dash)
519 {
520 if (index >= getNumDashes()) return;
521 mStrokeDashArray.insert(mStrokeDashArray.begin() + index, dash);
522 }
523
524
525 /*
526 * Unsets the value of the "id" attribute of this GraphicalPrimitive1D.
527 */
528 int
unsetId()529 GraphicalPrimitive1D::unsetId()
530 {
531 mId.erase();
532
533 if (mId.empty() == true)
534 {
535 return LIBSBML_OPERATION_SUCCESS;
536 }
537 else
538 {
539 return LIBSBML_OPERATION_FAILED;
540 }
541 }
542
543
544 /*
545 * Unsets the value of the "stroke" attribute of this GraphicalPrimitive1D.
546 */
547 int
unsetStroke()548 GraphicalPrimitive1D::unsetStroke()
549 {
550 mStroke.erase();
551
552 if (mStroke.empty() == true)
553 {
554 return LIBSBML_OPERATION_SUCCESS;
555 }
556 else
557 {
558 return LIBSBML_OPERATION_FAILED;
559 }
560 }
561
562
563 /*
564 * Unsets the value of the "stroke-width" attribute of this
565 * GraphicalPrimitive1D.
566 */
567 int
unsetStrokeWidth()568 GraphicalPrimitive1D::unsetStrokeWidth()
569 {
570 mStrokeWidth = util_NaN();
571 mIsSetStrokeWidth = false;
572
573 if (isSetStrokeWidth() == false)
574 {
575 return LIBSBML_OPERATION_SUCCESS;
576 }
577 else
578 {
579 return LIBSBML_OPERATION_FAILED;
580 }
581 }
582
583
584 /*
585 * Unsets the value of the "stroke-dasharray" attribute of this
586 * GraphicalPrimitive1D.
587 */
588 int
unsetStrokeDashArray()589 GraphicalPrimitive1D::unsetStrokeDashArray()
590 {
591 mStrokeDashArray.clear();
592 return LIBSBML_OPERATION_SUCCESS;
593 }
594
595
596 /*
597 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
598 * type Ellipse
599 */
600 bool
isEllipse() const601 GraphicalPrimitive1D::isEllipse() const
602 {
603 return dynamic_cast<const Ellipse*>(this) != NULL;
604 }
605
606
607 /*
608 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
609 * type Rectangle
610 */
611 bool
isRectangle() const612 GraphicalPrimitive1D::isRectangle() const
613 {
614 return dynamic_cast<const Rectangle*>(this) != NULL;
615 }
616
617
618 /*
619 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
620 * type Polygon
621 */
622 bool
isPolygon() const623 GraphicalPrimitive1D::isPolygon() const
624 {
625 return dynamic_cast<const Polygon*>(this) != NULL;
626 }
627
628
629 /*
630 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
631 * type RenderGroup
632 */
633 bool
isRenderGroup() const634 GraphicalPrimitive1D::isRenderGroup() const
635 {
636 return dynamic_cast<const RenderGroup*>(this) != NULL;
637 }
638
639
640 /*
641 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
642 * type LineEnding
643 */
644 bool
isLineEnding() const645 GraphicalPrimitive1D::isLineEnding() const
646 {
647 return dynamic_cast<const LineEnding*>(this) != NULL;
648 }
649
650
651 /*
652 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
653 * type Text
654 */
655 bool
isText() const656 GraphicalPrimitive1D::isText() const
657 {
658 return dynamic_cast<const Text*>(this) != NULL;
659 }
660
661
662 /*
663 * Predicate returning @c true if this abstract GraphicalPrimitive1D is of
664 * type RenderCurve
665 */
666 bool
isRenderCurve() const667 GraphicalPrimitive1D::isRenderCurve() const
668 {
669 return dynamic_cast<const RenderCurve*>(this) != NULL;
670 }
671
672
673 /*
674 * Returns the libSBML type code for this GraphicalPrimitive1D object.
675 */
676 int
getTypeCode() const677 GraphicalPrimitive1D::getTypeCode() const
678 {
679 return SBML_RENDER_GRAPHICALPRIMITIVE1D;
680 }
681
682
683 /*
684 * Predicate returning @c true if all the required attributes for this
685 * GraphicalPrimitive1D object have been set.
686 */
687 bool
hasRequiredAttributes() const688 GraphicalPrimitive1D::hasRequiredAttributes() const
689 {
690 bool allPresent = Transformation2D::hasRequiredAttributes();
691
692 return allPresent;
693 }
694
695
696
697 /** @cond doxygenLibsbmlInternal */
698
699 /*
700 * Write any contained elements
701 */
702 void
writeElements(XMLOutputStream & stream) const703 GraphicalPrimitive1D::writeElements(XMLOutputStream& stream) const
704 {
705 Transformation2D::writeElements(stream);
706
707 SBase::writeExtensionElements(stream);
708 }
709
710 /** @endcond */
711
712
713
714 /** @cond doxygenLibsbmlInternal */
715
716 /*
717 * Accepts the given SBMLVisitor
718 */
719 bool
accept(SBMLVisitor & v) const720 GraphicalPrimitive1D::accept(SBMLVisitor& v) const
721 {
722 return v.visit(*this);
723 }
724
725 /** @endcond */
726
727
728
729 /** @cond doxygenLibsbmlInternal */
730
731 /*
732 * Sets the parent SBMLDocument
733 */
734 void
setSBMLDocument(SBMLDocument * d)735 GraphicalPrimitive1D::setSBMLDocument(SBMLDocument* d)
736 {
737 Transformation2D::setSBMLDocument(d);
738 }
739
740 /** @endcond */
741
742
743
744 /** @cond doxygenLibsbmlInternal */
745
746 /** @cond doxygenLibsbmlInternal */
747
748 /*
749 * Enables/disables the given package with this element
750 */
751 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)752 GraphicalPrimitive1D::enablePackageInternal(const std::string& pkgURI,
753 const std::string& pkgPrefix,
754 bool flag)
755 {
756 Transformation2D::enablePackageInternal(pkgURI, pkgPrefix, flag);
757 }
758
759 /** @endcond */
760
761
762
763 /** @cond doxygenLibsbmlInternal */
764
765 /*
766 * Returns the value of the "attributeName" attribute of this
767 * GraphicalPrimitive1D.
768 */
769 int
getAttribute(const std::string & attributeName,bool & value) const770 GraphicalPrimitive1D::getAttribute(const std::string& attributeName,
771 bool& value) const
772 {
773 int return_value = Transformation2D::getAttribute(attributeName, value);
774
775 return return_value;
776 }
777
778 /** @endcond */
779
780
781
782 /** @cond doxygenLibsbmlInternal */
783
784 /*
785 * Returns the value of the "attributeName" attribute of this
786 * GraphicalPrimitive1D.
787 */
788 int
getAttribute(const std::string & attributeName,int & value) const789 GraphicalPrimitive1D::getAttribute(const std::string& attributeName,
790 int& value) const
791 {
792 int return_value = Transformation2D::getAttribute(attributeName, value);
793
794 return return_value;
795 }
796
797 /** @endcond */
798
799
800
801 /** @cond doxygenLibsbmlInternal */
802
803 /*
804 * Returns the value of the "attributeName" attribute of this
805 * GraphicalPrimitive1D.
806 */
807 int
getAttribute(const std::string & attributeName,double & value) const808 GraphicalPrimitive1D::getAttribute(const std::string& attributeName,
809 double& value) const
810 {
811 int return_value = Transformation2D::getAttribute(attributeName, value);
812
813 if (return_value == LIBSBML_OPERATION_SUCCESS)
814 {
815 return return_value;
816 }
817
818 if (attributeName == "stroke-width")
819 {
820 value = getStrokeWidth();
821 return_value = LIBSBML_OPERATION_SUCCESS;
822 }
823
824 return return_value;
825 }
826
827 /** @endcond */
828
829
830
831 /** @cond doxygenLibsbmlInternal */
832
833 /*
834 * Returns the value of the "attributeName" attribute of this
835 * GraphicalPrimitive1D.
836 */
837 int
getAttribute(const std::string & attributeName,unsigned int & value) const838 GraphicalPrimitive1D::getAttribute(const std::string& attributeName,
839 unsigned int& value) const
840 {
841 int return_value = Transformation2D::getAttribute(attributeName, value);
842
843 return return_value;
844 }
845
846 /** @endcond */
847
848
849
850 /** @cond doxygenLibsbmlInternal */
851
852 /*
853 * Returns the value of the "attributeName" attribute of this
854 * GraphicalPrimitive1D.
855 */
856 int
getAttribute(const std::string & attributeName,std::string & value) const857 GraphicalPrimitive1D::getAttribute(const std::string& attributeName,
858 std::string& value) const
859 {
860 int return_value = Transformation2D::getAttribute(attributeName, value);
861
862 if (return_value == LIBSBML_OPERATION_SUCCESS)
863 {
864 return return_value;
865 }
866
867 if (attributeName == "id")
868 {
869 value = getId();
870 return_value = LIBSBML_OPERATION_SUCCESS;
871 }
872 else if (attributeName == "stroke")
873 {
874 value = getStroke();
875 return_value = LIBSBML_OPERATION_SUCCESS;
876 }
877
878 return return_value;
879 }
880
881 /** @endcond */
882
883
884
885 /** @cond doxygenLibsbmlInternal */
886
887 /*
888 * Predicate returning @c true if this GraphicalPrimitive1D's attribute
889 * "attributeName" is set.
890 */
891 bool
isSetAttribute(const std::string & attributeName) const892 GraphicalPrimitive1D::isSetAttribute(const std::string& attributeName) const
893 {
894 bool value = Transformation2D::isSetAttribute(attributeName);
895
896 if (attributeName == "id")
897 {
898 value = isSetId();
899 }
900 else if (attributeName == "stroke")
901 {
902 value = isSetStroke();
903 }
904 else if (attributeName == "stroke-width")
905 {
906 value = isSetStrokeWidth();
907 }
908 else if (attributeName == "stroke-dasharray")
909 {
910 value = isSetStrokeDashArray();
911 }
912
913 return value;
914 }
915
916 /** @endcond */
917
918
919
920 /** @cond doxygenLibsbmlInternal */
921
922 /*
923 * Sets the value of the "attributeName" attribute of this
924 * GraphicalPrimitive1D.
925 */
926 int
setAttribute(const std::string & attributeName,bool value)927 GraphicalPrimitive1D::setAttribute(const std::string& attributeName,
928 bool value)
929 {
930 int return_value = Transformation2D::setAttribute(attributeName, value);
931
932 return return_value;
933 }
934
935 /** @endcond */
936
937
938
939 /** @cond doxygenLibsbmlInternal */
940
941 /*
942 * Sets the value of the "attributeName" attribute of this
943 * GraphicalPrimitive1D.
944 */
945 int
setAttribute(const std::string & attributeName,int value)946 GraphicalPrimitive1D::setAttribute(const std::string& attributeName,
947 int value)
948 {
949 int return_value = Transformation2D::setAttribute(attributeName, value);
950
951 return return_value;
952 }
953
954 /** @endcond */
955
956
957
958 /** @cond doxygenLibsbmlInternal */
959
960 /*
961 * Sets the value of the "attributeName" attribute of this
962 * GraphicalPrimitive1D.
963 */
964 int
setAttribute(const std::string & attributeName,double value)965 GraphicalPrimitive1D::setAttribute(const std::string& attributeName,
966 double value)
967 {
968 int return_value = Transformation2D::setAttribute(attributeName, value);
969
970 if (attributeName == "stroke-width")
971 {
972 return_value = setStrokeWidth(value);
973 }
974
975 return return_value;
976 }
977
978 /** @endcond */
979
980
981
982 /** @cond doxygenLibsbmlInternal */
983
984 /*
985 * Sets the value of the "attributeName" attribute of this
986 * GraphicalPrimitive1D.
987 */
988 int
setAttribute(const std::string & attributeName,unsigned int value)989 GraphicalPrimitive1D::setAttribute(const std::string& attributeName,
990 unsigned int value)
991 {
992 int return_value = Transformation2D::setAttribute(attributeName, value);
993
994 return return_value;
995 }
996
997 /** @endcond */
998
999
1000
1001 /** @cond doxygenLibsbmlInternal */
1002
1003 /*
1004 * Sets the value of the "attributeName" attribute of this
1005 * GraphicalPrimitive1D.
1006 */
1007 int
setAttribute(const std::string & attributeName,const std::string & value)1008 GraphicalPrimitive1D::setAttribute(const std::string& attributeName,
1009 const std::string& value)
1010 {
1011 int return_value = Transformation2D::setAttribute(attributeName, value);
1012
1013 if (attributeName == "id")
1014 {
1015 return_value = setId(value);
1016 }
1017 else if (attributeName == "stroke")
1018 {
1019 return_value = setStroke(value);
1020 }
1021
1022 return return_value;
1023 }
1024
1025 /** @endcond */
1026
1027
1028
1029 /** @cond doxygenLibsbmlInternal */
1030
1031 /*
1032 * Unsets the value of the "attributeName" attribute of this
1033 * GraphicalPrimitive1D.
1034 */
1035 int
unsetAttribute(const std::string & attributeName)1036 GraphicalPrimitive1D::unsetAttribute(const std::string& attributeName)
1037 {
1038 int value = Transformation2D::unsetAttribute(attributeName);
1039
1040 if (attributeName == "id")
1041 {
1042 value = unsetId();
1043 }
1044 else if (attributeName == "stroke")
1045 {
1046 value = unsetStroke();
1047 }
1048 else if (attributeName == "stroke-width")
1049 {
1050 value = unsetStrokeWidth();
1051 }
1052 else if (attributeName == "stroke-dasharray")
1053 {
1054 value = unsetStrokeDashArray();
1055 }
1056
1057 return value;
1058 }
1059
1060 /** @endcond */
1061
1062
1063
1064 /** @cond doxygenLibsbmlInternal */
1065
1066 /*
1067 * Creates a new object from the next XMLToken on the XMLInputStream
1068 */
1069 SBase*
createObject(XMLInputStream & stream)1070 GraphicalPrimitive1D::createObject(XMLInputStream& stream)
1071 {
1072 SBase* obj = Transformation2D::createObject(stream);
1073
1074 connectToChild();
1075
1076 return obj;
1077 }
1078
1079 /** @endcond */
1080
1081
1082
1083 /** @cond doxygenLibsbmlInternal */
1084
1085 /*
1086 * Adds the expected attributes for this element
1087 */
1088 void
addExpectedAttributes(ExpectedAttributes & attributes)1089 GraphicalPrimitive1D::addExpectedAttributes(ExpectedAttributes& attributes)
1090 {
1091 Transformation2D::addExpectedAttributes(attributes);
1092
1093 attributes.add("id");
1094
1095 attributes.add("stroke");
1096
1097 attributes.add("stroke-width");
1098
1099 attributes.add("stroke-dasharray");
1100 }
1101
1102 /** @endcond */
1103
1104
1105
1106 /** @cond doxygenLibsbmlInternal */
1107
1108 /*
1109 * Reads the expected attributes into the member data variables
1110 */
1111 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)1112 GraphicalPrimitive1D::readAttributes(const XMLAttributes& attributes,
1113 const ExpectedAttributes&
1114 expectedAttributes)
1115 {
1116 unsigned int level = getLevel();
1117 unsigned int version = getVersion();
1118 unsigned int pkgVersion = getPackageVersion();
1119 unsigned int numErrs;
1120 bool assigned = false;
1121 SBMLErrorLog* log = getErrorLog();
1122
1123 Transformation2D::readAttributes(attributes, expectedAttributes);
1124
1125 //
1126 // id SId (use = "optional" )
1127 //
1128
1129 assigned = attributes.readInto("id", mId);
1130
1131 if (assigned == true)
1132 {
1133 if (mId.empty() == true && log)
1134 {
1135 logEmptyString(mId, level, version, "<GraphicalPrimitive1D>");
1136 }
1137 else if (SyntaxChecker::isValidSBMLSId(mId) == false && log)
1138 {
1139 log->logPackageError("render", RenderIdSyntaxRule, pkgVersion, level,
1140 version, "The id on the <" + getElementName() + "> is '" + mId + "', "
1141 "which does not conform to the syntax.", getLine(), getColumn());
1142 }
1143 }
1144
1145 //
1146 // stroke string (use = "optional" )
1147 //
1148
1149 assigned = attributes.readInto("stroke", mStroke);
1150
1151 if (assigned == true)
1152 {
1153 if (mStroke.empty() == true && log)
1154 {
1155 logEmptyString(mStroke, level, version, "<GraphicalPrimitive1D>");
1156 }
1157 }
1158
1159 //
1160 // stroke-width double (use = "optional" )
1161 //
1162 if (log) numErrs = log->getNumErrors();
1163 mIsSetStrokeWidth = attributes.readInto("stroke-width", mStrokeWidth);
1164
1165 if (mIsSetStrokeWidth == false)
1166 {
1167 if (log && log->getNumErrors() == numErrs + 1 &&
1168 log->contains(XMLAttributeTypeMismatch))
1169 {
1170 log->remove(XMLAttributeTypeMismatch);
1171 std::string message = "Render attribute 'stroke-width' from the "
1172 "<GraphicalPrimitive1D> element must be a double.";
1173 log->logPackageError("render",
1174 RenderGraphicalPrimitive1DStrokeWidthMustBeDouble, pkgVersion, level,
1175 version, message, getLine(), getColumn());
1176 }
1177 mStrokeWidth = std::numeric_limits<double>::quiet_NaN();
1178 }
1179
1180
1181 // parse the stroke-dasharray
1182 std::string s;
1183 if(attributes.readInto("stroke-dasharray", s, getErrorLog(), false, getLine(), getColumn()) && !s.empty())
1184 {
1185 this->setDashArray(s);
1186 }
1187 }
1188 /** @endcond */
1189
1190
1191
1192 /** @cond doxygenLibsbmlInternal */
1193
1194 /*
1195 * Writes the attributes to the stream
1196 */
1197 void
writeAttributes(XMLOutputStream & stream) const1198 GraphicalPrimitive1D::writeAttributes(XMLOutputStream& stream) const
1199 {
1200 Transformation2D::writeAttributes(stream);
1201
1202 if (isSetId() == true)
1203 {
1204 stream.writeAttribute("id", getPrefix(), mId);
1205 }
1206
1207 if (isSetStroke() == true)
1208 {
1209 stream.writeAttribute("stroke", getPrefix(), mStroke);
1210 }
1211
1212 if (isSetStrokeWidth() == true)
1213 {
1214 stream.writeAttribute("stroke-width", getPrefix(), mStrokeWidth);
1215 }
1216
1217 if(this->isSetDashArray())
1218 {
1219 std::ostringstream os;
1220 std::vector<unsigned int>::const_iterator it=this->getDashArray().begin();
1221 std::vector<unsigned int>::const_iterator endit=this->getDashArray().end();
1222 os << *it;
1223 ++it;
1224 while(it!=endit)
1225 {
1226 os << " , " << *it;
1227 ++it;
1228 }
1229 stream.writeAttribute("stroke-dasharray", getPrefix(), os.str());
1230 }
1231
1232 SBase::writeExtensionAttributes(stream);
1233 }
1234 /** @endcond */
1235
1236
1237 /** @cond doxygenLibsbmlInternal */
1238 /*
1239 * Adds all set attributes specific to the given GraphicalPrimitive1D objects to the given
1240 * XMLAttributes object.
1241 */
addGraphicalPrimitive1DAttributes(const GraphicalPrimitive1D & primitive,XMLAttributes & attributes)1242 void GraphicalPrimitive1D::addGraphicalPrimitive1DAttributes(const GraphicalPrimitive1D& primitive,XMLAttributes& attributes)
1243 {
1244 if(primitive.isSetId())
1245 {
1246 attributes.add("id",primitive.getId());
1247 }
1248 // stroke, stroke_width
1249 if(primitive.isSetStroke())
1250 {
1251 attributes.add("stroke",primitive.getStroke());
1252 }
1253 if(primitive.isSetStrokeWidth())
1254 {
1255 std::ostringstream os;
1256 os << primitive.getStrokeWidth();
1257 attributes.add("stroke-width",os.str());
1258 }
1259 if(primitive.isSetDashArray())
1260 {
1261 std::ostringstream os;
1262 std::vector<unsigned int>::const_iterator it=primitive.getDashArray().begin();
1263 std::vector<unsigned int>::const_iterator endit=primitive.getDashArray().end();
1264 os << *it;
1265 ++it;
1266 while(it!=endit)
1267 {
1268 os << " , " << *it;
1269 ++it;
1270 }
1271 attributes.add("stroke-dasharray",os.str());
1272 }
1273 }
1274 /** @endcond */
1275
1276
1277 /** @cond doxygenLibsbmlInternal */
1278 /*
1279 * This method parses a dasharray string into the given vector.
1280 * The vector is first cleared.
1281 * If the dasharray is invalid, false is returned.
1282 */
parseDashArray(const std::string & s,std::vector<unsigned int> & array)1283 bool GraphicalPrimitive1D::parseDashArray(const std::string& s,std::vector<unsigned int>& array)
1284 {
1285 array.clear();
1286 bool result=true;
1287 if(!s.empty())
1288 {
1289 std::istringstream is(s);
1290 size_t size=s.size()+1;
1291 char* tmp=new char[size];
1292 char* tmp2=tmp;
1293 char* tmp3;
1294 char** endptr;
1295 long value;
1296 is.getline(tmp2,size,',');
1297 // continue until the string is empty or the stream is
1298 // no longer usable
1299 while(tmp2[0] != 0 && is.good())
1300 {
1301 endptr=&tmp2;
1302 tmp3=tmp2;
1303 value=strtol(tmp2,endptr,10);
1304 if(value < 0 || *endptr == tmp3 || ( **endptr != '\0' && **endptr != ' ' && **endptr != '\t'))
1305 {
1306 result=false;
1307 array.clear();
1308 }
1309 else
1310 {
1311 array.push_back((unsigned int)value);
1312 }
1313 // read next element
1314 is.getline(tmp2,size,',');
1315 }
1316 // check if the string was parsed to the end
1317 if(is.eof())
1318 {
1319 // we have to parse the current tmp2
1320 // and check if that was ok
1321 endptr=&tmp2;
1322 tmp3=tmp2;
1323 value=strtol(tmp2,endptr,10);
1324 if(value < 0 || *endptr == tmp3 || ( **endptr != '\0' && **endptr != ' ' && **endptr != '\t'))
1325 {
1326 result=false;
1327 array.clear();
1328 }
1329 else
1330 {
1331 array.push_back((unsigned int)value);
1332 }
1333 }
1334 else
1335 {
1336 // since we did not parse to the end,
1337 // there most have been an error
1338 result=false;
1339 array.clear();
1340 }
1341 delete[] tmp;
1342 }
1343 return result;
1344 }
1345 /** @endcond */
1346
1347
1348
1349
1350 #endif /* __cplusplus */
1351
1352
1353 /*
1354 * Creates a new Ellipse (GraphicalPrimitive1D_t) using the given SBML Level, Version
1355 * and “render” package version.
1356 */
1357 LIBSBML_EXTERN
1358 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createEllipse(unsigned int level,unsigned int version,unsigned int pkgVersion)1359 GraphicalPrimitive1D_createEllipse(unsigned int level,
1360 unsigned int version,
1361 unsigned int pkgVersion)
1362 {
1363 return new Ellipse(level, version, pkgVersion);
1364 }
1365
1366
1367 /*
1368 * Creates a new Rectangle (GraphicalPrimitive1D_t) using the given SBML Level,
1369 * Version and “render” package version.
1370 */
1371 LIBSBML_EXTERN
1372 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createRectangle(unsigned int level,unsigned int version,unsigned int pkgVersion)1373 GraphicalPrimitive1D_createRectangle(unsigned int level,
1374 unsigned int version,
1375 unsigned int pkgVersion)
1376 {
1377 return new Rectangle(level, version, pkgVersion);
1378 }
1379
1380
1381 /*
1382 * Creates a new Polygon (GraphicalPrimitive1D_t) using the given SBML Level, Version
1383 * and “render” package version.
1384 */
1385 LIBSBML_EXTERN
1386 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createPolygon(unsigned int level,unsigned int version,unsigned int pkgVersion)1387 GraphicalPrimitive1D_createPolygon(unsigned int level,
1388 unsigned int version,
1389 unsigned int pkgVersion)
1390 {
1391 return new Polygon(level, version, pkgVersion);
1392 }
1393
1394
1395 /*
1396 * Creates a new RenderGroup (GraphicalPrimitive1D_t) using the given SBML Level,
1397 * Version and “render” package version.
1398 */
1399 LIBSBML_EXTERN
1400 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createRenderGroup(unsigned int level,unsigned int version,unsigned int pkgVersion)1401 GraphicalPrimitive1D_createRenderGroup(unsigned int level,
1402 unsigned int version,
1403 unsigned int pkgVersion)
1404 {
1405 return new RenderGroup(level, version, pkgVersion);
1406 }
1407
1408
1409 /*
1410 * Creates a new Text (GraphicalPrimitive1D_t) using the given SBML Level, Version
1411 * and “render” package version.
1412 */
1413 LIBSBML_EXTERN
1414 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createText(unsigned int level,unsigned int version,unsigned int pkgVersion)1415 GraphicalPrimitive1D_createText(unsigned int level,
1416 unsigned int version,
1417 unsigned int pkgVersion)
1418 {
1419 return new Text(level, version, pkgVersion);
1420 }
1421
1422
1423 /*
1424 * Creates a new RenderCurve (GraphicalPrimitive1D_t) using the given SBML Level,
1425 * Version and “render” package version.
1426 */
1427 LIBSBML_EXTERN
1428 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createRenderCurve(unsigned int level,unsigned int version,unsigned int pkgVersion)1429 GraphicalPrimitive1D_createRenderCurve(unsigned int level,
1430 unsigned int version,
1431 unsigned int pkgVersion)
1432 {
1433 return new RenderCurve(level, version, pkgVersion);
1434 }
1435
1436
1437 /*
1438 * Creates a new LineEnding (GraphicalPrimitive1D_t) using the given SBML Level,
1439 * Version and “render” package version.
1440 */
1441 LIBSBML_EXTERN
1442 GraphicalPrimitive1D_t *
GraphicalPrimitive1D_createLineEnding(unsigned int level,unsigned int version,unsigned int pkgVersion)1443 GraphicalPrimitive1D_createLineEnding(unsigned int level,
1444 unsigned int version,
1445 unsigned int pkgVersion)
1446 {
1447 return new LineEnding(level, version, pkgVersion);
1448 }
1449
1450
1451 /*
1452 * Creates and returns a deep copy of this GraphicalPrimitive1D_t object.
1453 */
1454 LIBSBML_EXTERN
1455 GraphicalPrimitive1D_t*
GraphicalPrimitive1D_clone(const GraphicalPrimitive1D_t * gpd)1456 GraphicalPrimitive1D_clone(const GraphicalPrimitive1D_t* gpd)
1457 {
1458 if (gpd != NULL)
1459 {
1460 return static_cast<GraphicalPrimitive1D_t*>(gpd->clone());
1461 }
1462 else
1463 {
1464 return NULL;
1465 }
1466 }
1467
1468
1469 /*
1470 * Frees this GraphicalPrimitive1D_t object.
1471 */
1472 LIBSBML_EXTERN
1473 void
GraphicalPrimitive1D_free(GraphicalPrimitive1D_t * gpd)1474 GraphicalPrimitive1D_free(GraphicalPrimitive1D_t* gpd)
1475 {
1476 if (gpd != NULL)
1477 {
1478 delete gpd;
1479 }
1480 }
1481
1482
1483 /*
1484 * Returns the value of the "id" attribute of this GraphicalPrimitive1D_t.
1485 */
1486 LIBSBML_EXTERN
1487 char *
GraphicalPrimitive1D_getId(const GraphicalPrimitive1D_t * gpd)1488 GraphicalPrimitive1D_getId(const GraphicalPrimitive1D_t * gpd)
1489 {
1490 if (gpd == NULL)
1491 {
1492 return NULL;
1493 }
1494
1495 return gpd->getId().empty() ? NULL : safe_strdup(gpd->getId().c_str());
1496 }
1497
1498
1499 /*
1500 * Returns the value of the "stroke" attribute of this GraphicalPrimitive1D_t.
1501 */
1502 LIBSBML_EXTERN
1503 char *
GraphicalPrimitive1D_getStroke(const GraphicalPrimitive1D_t * gpd)1504 GraphicalPrimitive1D_getStroke(const GraphicalPrimitive1D_t * gpd)
1505 {
1506 if (gpd == NULL)
1507 {
1508 return NULL;
1509 }
1510
1511 return gpd->getStroke().empty() ? NULL :
1512 safe_strdup(gpd->getStroke().c_str());
1513 }
1514
1515
1516 /*
1517 * Returns the value of the "stroke-width" attribute of this
1518 * GraphicalPrimitive1D_t.
1519 */
1520 LIBSBML_EXTERN
1521 double
GraphicalPrimitive1D_getStrokeWidth(const GraphicalPrimitive1D_t * gpd)1522 GraphicalPrimitive1D_getStrokeWidth(const GraphicalPrimitive1D_t * gpd)
1523 {
1524 return (gpd != NULL) ? gpd->getStrokeWidth() : util_NaN();
1525 }
1526
1527
1528 /*
1529 * Predicate returning @c 1 (true) if this GraphicalPrimitive1D_t's "id"
1530 * attribute is set.
1531 */
1532 LIBSBML_EXTERN
1533 int
GraphicalPrimitive1D_isSetId(const GraphicalPrimitive1D_t * gpd)1534 GraphicalPrimitive1D_isSetId(const GraphicalPrimitive1D_t * gpd)
1535 {
1536 return (gpd != NULL) ? static_cast<int>(gpd->isSetId()) : 0;
1537 }
1538
1539
1540 /*
1541 * Predicate returning @c 1 (true) if this GraphicalPrimitive1D_t's "stroke"
1542 * attribute is set.
1543 */
1544 LIBSBML_EXTERN
1545 int
GraphicalPrimitive1D_isSetStroke(const GraphicalPrimitive1D_t * gpd)1546 GraphicalPrimitive1D_isSetStroke(const GraphicalPrimitive1D_t * gpd)
1547 {
1548 return (gpd != NULL) ? static_cast<int>(gpd->isSetStroke()) : 0;
1549 }
1550
1551
1552 /*
1553 * Predicate returning @c 1 (true) if this GraphicalPrimitive1D_t's
1554 * "stroke-width" attribute is set.
1555 */
1556 LIBSBML_EXTERN
1557 int
GraphicalPrimitive1D_isSetStrokeWidth(const GraphicalPrimitive1D_t * gpd)1558 GraphicalPrimitive1D_isSetStrokeWidth(const GraphicalPrimitive1D_t * gpd)
1559 {
1560 return (gpd != NULL) ? static_cast<int>(gpd->isSetStrokeWidth()) : 0;
1561 }
1562
1563
1564 /*
1565 * Predicate returning @c 1 (true) if this GraphicalPrimitive1D_t's
1566 * "stroke-dasharray" attribute is set.
1567 */
1568 LIBSBML_EXTERN
1569 int
GraphicalPrimitive1D_isSetStrokeDashArray(const GraphicalPrimitive1D_t * gpd)1570 GraphicalPrimitive1D_isSetStrokeDashArray(const GraphicalPrimitive1D_t * gpd)
1571 {
1572 return (gpd != NULL) ? static_cast<int>(gpd->isSetStrokeDashArray()) : 0;
1573 }
1574
1575
1576 /*
1577 * Sets the value of the "id" attribute of this GraphicalPrimitive1D_t.
1578 */
1579 LIBSBML_EXTERN
1580 int
GraphicalPrimitive1D_setId(GraphicalPrimitive1D_t * gpd,const char * id)1581 GraphicalPrimitive1D_setId(GraphicalPrimitive1D_t * gpd, const char * id)
1582 {
1583 return (gpd != NULL) ? gpd->setId(id) : LIBSBML_INVALID_OBJECT;
1584 }
1585
1586
1587 /*
1588 * Sets the value of the "stroke" attribute of this GraphicalPrimitive1D_t.
1589 */
1590 LIBSBML_EXTERN
1591 int
GraphicalPrimitive1D_setStroke(GraphicalPrimitive1D_t * gpd,const char * stroke)1592 GraphicalPrimitive1D_setStroke(GraphicalPrimitive1D_t * gpd,
1593 const char * stroke)
1594 {
1595 return (gpd != NULL) ? gpd->setStroke(stroke) : LIBSBML_INVALID_OBJECT;
1596 }
1597
1598
1599 /*
1600 * Sets the value of the "stroke-width" attribute of this
1601 * GraphicalPrimitive1D_t.
1602 */
1603 LIBSBML_EXTERN
1604 int
GraphicalPrimitive1D_setStrokeWidth(GraphicalPrimitive1D_t * gpd,double strokeWidth)1605 GraphicalPrimitive1D_setStrokeWidth(GraphicalPrimitive1D_t * gpd,
1606 double strokeWidth)
1607 {
1608 return (gpd != NULL) ? gpd->setStrokeWidth(strokeWidth) :
1609 LIBSBML_INVALID_OBJECT;
1610 }
1611
1612
1613 /*
1614 * Sets the value of the "stroke-dasharray" attribute of this
1615 * GraphicalPrimitive1D_t.
1616 */
1617 LIBSBML_EXTERN
1618 int
GraphicalPrimitive1D_setStrokeDashArray(GraphicalPrimitive1D_t * gpd,const char * strokeDash)1619 GraphicalPrimitive1D_setStrokeDashArray(GraphicalPrimitive1D_t* gpd,
1620 const char* strokeDash)
1621 {
1622 return (gpd != NULL) ? gpd->setDashArray(strokeDash)
1623 : LIBSBML_INVALID_OBJECT;
1624 }
1625
1626
1627 /*
1628 * Unsets the value of the "id" attribute of this GraphicalPrimitive1D_t.
1629 */
1630 LIBSBML_EXTERN
1631 int
GraphicalPrimitive1D_unsetId(GraphicalPrimitive1D_t * gpd)1632 GraphicalPrimitive1D_unsetId(GraphicalPrimitive1D_t * gpd)
1633 {
1634 return (gpd != NULL) ? gpd->unsetId() : LIBSBML_INVALID_OBJECT;
1635 }
1636
1637
1638 /*
1639 * Unsets the value of the "stroke" attribute of this GraphicalPrimitive1D_t.
1640 */
1641 LIBSBML_EXTERN
1642 int
GraphicalPrimitive1D_unsetStroke(GraphicalPrimitive1D_t * gpd)1643 GraphicalPrimitive1D_unsetStroke(GraphicalPrimitive1D_t * gpd)
1644 {
1645 return (gpd != NULL) ? gpd->unsetStroke() : LIBSBML_INVALID_OBJECT;
1646 }
1647
1648
1649 /*
1650 * Unsets the value of the "stroke-width" attribute of this
1651 * GraphicalPrimitive1D_t.
1652 */
1653 LIBSBML_EXTERN
1654 int
GraphicalPrimitive1D_unsetStrokeWidth(GraphicalPrimitive1D_t * gpd)1655 GraphicalPrimitive1D_unsetStrokeWidth(GraphicalPrimitive1D_t * gpd)
1656 {
1657 return (gpd != NULL) ? gpd->unsetStrokeWidth() : LIBSBML_INVALID_OBJECT;
1658 }
1659
1660
1661 /*
1662 * Unsets the value of the "stroke-dasharray" attribute of this
1663 * GraphicalPrimitive1D_t.
1664 */
1665 LIBSBML_EXTERN
1666 int
GraphicalPrimitive1D_unsetStrokeDashArray(GraphicalPrimitive1D_t * gpd)1667 GraphicalPrimitive1D_unsetStrokeDashArray(GraphicalPrimitive1D_t * gpd)
1668 {
1669 return (gpd != NULL) ? gpd->unsetStrokeDashArray() : LIBSBML_INVALID_OBJECT;
1670 }
1671
1672
1673 /*
1674 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type Ellipse_t
1675 */
1676 LIBSBML_EXTERN
1677 int
GraphicalPrimitive1D_isEllipse(const GraphicalPrimitive1D_t * gpd)1678 GraphicalPrimitive1D_isEllipse(const GraphicalPrimitive1D_t * gpd)
1679 {
1680 return (gpd != NULL) ? static_cast<int>(gpd->isEllipse()) : 0;
1681 }
1682
1683
1684 /*
1685 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type
1686 * Rectangle_t
1687 */
1688 LIBSBML_EXTERN
1689 int
GraphicalPrimitive1D_isRectangle(const GraphicalPrimitive1D_t * gpd)1690 GraphicalPrimitive1D_isRectangle(const GraphicalPrimitive1D_t * gpd)
1691 {
1692 return (gpd != NULL) ? static_cast<int>(gpd->isRectangle()) : 0;
1693 }
1694
1695
1696 /*
1697 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type Polygon_t
1698 */
1699 LIBSBML_EXTERN
1700 int
GraphicalPrimitive1D_isPolygon(const GraphicalPrimitive1D_t * gpd)1701 GraphicalPrimitive1D_isPolygon(const GraphicalPrimitive1D_t * gpd)
1702 {
1703 return (gpd != NULL) ? static_cast<int>(gpd->isPolygon()) : 0;
1704 }
1705
1706
1707 /*
1708 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type
1709 * RenderGroup_t
1710 */
1711 LIBSBML_EXTERN
1712 int
GraphicalPrimitive1D_isRenderGroup(const GraphicalPrimitive1D_t * gpd)1713 GraphicalPrimitive1D_isRenderGroup(const GraphicalPrimitive1D_t * gpd)
1714 {
1715 return (gpd != NULL) ? static_cast<int>(gpd->isRenderGroup()) : 0;
1716 }
1717
1718
1719 /*
1720 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type
1721 * LineEnding_t
1722 */
1723 LIBSBML_EXTERN
1724 int
GraphicalPrimitive1D_isLineEnding(const GraphicalPrimitive1D_t * gpd)1725 GraphicalPrimitive1D_isLineEnding(const GraphicalPrimitive1D_t * gpd)
1726 {
1727 return (gpd != NULL) ? static_cast<int>(gpd->isLineEnding()) : 0;
1728 }
1729
1730
1731 /*
1732 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type Text_t
1733 */
1734 LIBSBML_EXTERN
1735 int
GraphicalPrimitive1D_isText(const GraphicalPrimitive1D_t * gpd)1736 GraphicalPrimitive1D_isText(const GraphicalPrimitive1D_t * gpd)
1737 {
1738 return (gpd != NULL) ? static_cast<int>(gpd->isText()) : 0;
1739 }
1740
1741
1742 /*
1743 * Predicate returning @c 1 if this GraphicalPrimitive1D_t is of type
1744 * RenderCurve_t
1745 */
1746 LIBSBML_EXTERN
1747 int
GraphicalPrimitive1D_isRenderCurve(const GraphicalPrimitive1D_t * gpd)1748 GraphicalPrimitive1D_isRenderCurve(const GraphicalPrimitive1D_t * gpd)
1749 {
1750 return (gpd != NULL) ? static_cast<int>(gpd->isRenderCurve()) : 0;
1751 }
1752
1753
1754 /*
1755 * Predicate returning @c 1 (true) if all the required attributes for this
1756 * GraphicalPrimitive1D_t object have been set.
1757 */
1758 LIBSBML_EXTERN
1759 int
GraphicalPrimitive1D_hasRequiredAttributes(const GraphicalPrimitive1D_t * gpd)1760 GraphicalPrimitive1D_hasRequiredAttributes(const GraphicalPrimitive1D_t * gpd)
1761 {
1762 return (gpd != NULL) ? static_cast<int>(gpd->hasRequiredAttributes()) : 0;
1763 }
1764
1765
1766
1767
1768 LIBSBML_CPP_NAMESPACE_END
1769
1770
1771