source: branches/blt4/src/objects/RpAxisMarker.cc @ 1897

Last change on this file since 1897 was 1560, checked in by dkearney, 15 years ago

updates to the object system, fixed up tree and xml parser objects, added some basic tests for them and adopted number object to accept xml text and configure itself from the parsed xml. added fermi3.cc example program which contains suggested interface from apps meeting.

File size: 3.0 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture 2.0 AxisMarker Object Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2005-2009  Purdue Research Foundation
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#include "RpAxisMarker.h"
15
16using namespace Rappture;
17
18AxisMarker::AxisMarker()
19    : Object(),
20      _axisName(NULL),
21      _style(NULL),
22      _at(0.0)
23{}
24
25AxisMarker::AxisMarker(const char *axisName, const char *label,
26                       const char *style, double at)
27    : Object(),
28      _axisName(NULL),
29      _style(NULL),
30      _at(0.0)
31{
32    this->axisName(axisName);
33    this->label(label);
34    this->style(style);
35    this->at(at);
36}
37
38AxisMarker::AxisMarker(const AxisMarker &o)
39    : Object(),
40      _axisName(NULL),
41      _style(NULL),
42      _at(0.0)
43{
44    this->axisName(o.axisName());
45    this->label(o.label());
46    this->style(o.style());
47    this->at(o.at());
48}
49
50AxisMarker::~AxisMarker()
51{
52    if (_axisName != NULL) {
53        delete[] _axisName;
54    }
55
56    if (_style != NULL) {
57        delete[] _style;
58    }
59}
60
61
62void
63AxisMarker::axisName (const char *a)
64{
65    size_t len = 0;
66
67    if (a == NULL) {
68        return;
69    }
70
71    if (_axisName != NULL) {
72        delete[] _axisName;
73    }
74
75    len = strlen(a);
76    char *tmp = new char[len+1];
77
78    strncpy(tmp,a,len+1);
79
80    _axisName = tmp;
81
82    return;
83}
84
85const char *
86AxisMarker::axisName (void) const
87{
88    return _axisName;
89}
90
91void
92AxisMarker::style (const char *s)
93{
94    size_t len = 0;
95
96    if (s == NULL) {
97        return;
98    }
99
100    if (_style != NULL) {
101        delete[] _style;
102    }
103
104    len = strlen(s);
105    char *tmp = new char[len+1];
106
107    strncpy(tmp,s,len+1);
108
109    _style = tmp;
110
111    return;
112}
113
114const char *
115AxisMarker::style (void) const
116{
117    return _style;
118}
119
120void
121AxisMarker::at (double a)
122{
123    _at = a;
124    return;
125}
126
127double
128AxisMarker::at (void) const
129{
130    return _at;
131}
132
133/**********************************************************************/
134// METHOD: xml()
135/// Return the xml of the object
136/**
137 * Return the xml of the object
138 */
139
140const char *
141AxisMarker::xml(size_t indent, size_t tabstop)
142{
143    size_t l1width = indent + tabstop;
144    const char *sp = "";
145
146    _tmpBuf.clear();
147
148    _tmpBuf.appendf(
149"%6$*4$s<marker>\n\
150%6$*5$s<at>%1$g</at>\n\
151%6$*5$s<label>%2$s</label>\n\
152%6$*5$s<style>%3$s</style>\n\
153%6$*4$s<marker>\n",
154        _at,label(),_style,indent,l1width,sp);
155
156    _tmpBuf.append("\0",1);
157
158    return _tmpBuf.bytes();
159}
160
161/**********************************************************************/
162// METHOD: is()
163/// what kind of object is this
164/**
165 * return hex value telling what kind of object this is.
166 */
167
168const int
169AxisMarker::is() const
170{
171    // return "mark" in hex
172    return 0x6D61726B;
173}
174
175// -------------------------------------------------------------------- //
176
Note: See TracBrowser for help on using the repository browser.