Changeset 1569 for trunk/examples/objects
- Timestamp:
- Sep 16, 2009 2:22:36 PM (11 years ago)
- Location:
- trunk/examples/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/objects/curve/curve.cc
r1568 r1569 41 41 42 42 const char *expected = "<?xml version=\"1.0\"?>\n\ 43 <curve id=\"myid\">\n\ 44 <about>\n\ 45 <group>mygroup</group>\n\ 46 <label>mylabel</label>\n\ 47 <description>mydesc</description>\n\ 48 <type>(null)</type>\n\ 49 </about>\n\ 50 <xaxis>\n\ 51 <label>xlabel</label>\n\ 52 <description>xdesc</description>\n\ 53 <units>xunits</units>\n\ 54 <scale>xscale</scale>\n\ 55 </xaxis>\n\ 56 <yaxis>\n\ 57 <label>ylabel</label>\n\ 58 <description>ydesc</description>\n\ 59 <units>yunits</units>\n\ 60 <scale>yscale</scale>\n\ 61 </yaxis>\n\ 62 <component>\n\ 63 <xy> 1 1\n\ 43 <run>\n\ 44 <curve id=\"myid\">\n\ 45 <about>\n\ 46 <group>mygroup</group>\n\ 47 <label>mylabel</label>\n\ 48 <description>mydesc</description>\n\ 49 <type>(null)</type>\n\ 50 </about>\n\ 51 <xaxis>\n\ 52 <label>xlabel</label>\n\ 53 <description>xdesc</description>\n\ 54 <units>xunits</units>\n\ 55 <scale>xscale</scale>\n\ 56 </xaxis>\n\ 57 <yaxis>\n\ 58 <label>ylabel</label>\n\ 59 <description>ydesc</description>\n\ 60 <units>yunits</units>\n\ 61 <scale>yscale</scale>\n\ 62 </yaxis>\n\ 63 <component>\n\ 64 <xy> 1 1\n\ 64 65 2 4\n\ 65 66 3 9\n\ … … 72 73 10 100\n\ 73 74 </xy>\n\ 74 </component>\n\ 75 </curve>\n\ 75 </component>\n\ 76 </curve>\n\ 77 </run>\n\ 76 78 "; 77 79 const char *received = NULL; -
trunk/examples/objects/plot/plot.cc
r1560 r1569 2 2 #include "RpPlot.h" 3 3 4 size_t indent = 0; 5 size_t tabstop = 4; 6 7 int test( 8 const char *testname, 9 const char *desc, 10 const char *expected, 11 const char *received) 12 { 13 if (strcmp(expected,received) != 0) { 14 printf("Error: %s\n", testname); 15 printf("\t%s\n", desc); 16 printf("\texpected \"%s\"\n",expected); 17 printf("\treceived \"%s\"\n",received); 18 return 1; 19 } 20 return 0; 21 } 22 23 int plot_0_0 () 24 { 25 const char *desc = "test basic plot object constructor"; 26 const char *testname = "plot_0_0"; 27 28 const char *expected = "run"; 29 const char *received = NULL; 30 31 Rappture::Plot p; 32 received = p.path(); 33 34 return test(testname,desc,expected,received); 35 } 36 37 int plot_1_0 () 38 { 39 const char *desc = "test generating xml text for single curve"; 40 const char *testname = "plot_1_0"; 41 42 const char *expected = "<?xml version=\"1.0\"?>\n\ 43 <run>\n\ 44 <curve id=\"myid\">\n\ 45 <about>\n\ 46 <group>plotlabel</group>\n\ 47 <label>plotlabel</label>\n\ 48 <description>describe plot here</description>\n\ 49 <type>(null)</type>\n\ 50 </about>\n\ 51 <xaxis>\n\ 52 <label>Voltage</label>\n\ 53 <description>Voltage along the Gate</description>\n\ 54 <units>Volt</units>\n\ 55 <scale>linear</scale>\n\ 56 </xaxis>\n\ 57 <yaxis>\n\ 58 <label>Current</label>\n\ 59 <description>Current along the Drain</description>\n\ 60 <units>Amp</units>\n\ 61 <scale>log</scale>\n\ 62 </yaxis>\n\ 63 <component>\n\ 64 <xy> 1 1\n\ 65 2 4\n\ 66 3 9\n\ 67 4 16\n\ 68 5 25\n\ 69 6 36\n\ 70 7 49\n\ 71 8 64\n\ 72 9 81\n\ 73 10 100\n\ 74 </xy>\n\ 75 </component>\n\ 76 </curve>\n\ 77 </run>\n\ 78 "; 79 const char *received = NULL; 80 81 Rappture::Plot p; 82 size_t npts = 10; 83 double x[] = {1,2,3,4,5,6,7,8,9,10}; 84 double y[] = {1,4,9,16,25,36,49,64,81,100}; 85 86 p.add(npts, x, y, NULL, "myid"); 87 88 p.propstr("label","plotlabel"); 89 p.propstr("desc","describe plot here"); 90 p.propstr("xlabel","Voltage"); 91 p.propstr("xdesc","Voltage along the Gate"); 92 p.propstr("xunits","Volt"); 93 p.propstr("xscale","linear"); 94 p.propstr("ylabel","Current"); 95 p.propstr("ydesc","Current along the Drain"); 96 p.propstr("yunits","Amp"); 97 p.propstr("yscale","log"); 98 99 Rappture::ClientDataXml xmldata; 100 xmldata.indent = indent; 101 xmldata.tabstop = tabstop; 102 xmldata.retStr = NULL; 103 p.dump(Rappture::RPCONFIG_XML,&xmldata); 104 received = xmldata.retStr; 105 106 return test(testname,desc,expected,received); 107 } 108 109 int main() 110 { 111 plot_0_0 (); 112 plot_1_0 (); 113 return 0; 114 } 115 116 /* 4 117 int main() 5 118 { … … 46 159 std::printf("xml: %s\n",p1->xml(indent,tabstop)); 47 160 48 /*49 // retrieve curve from curve name50 // may want to add curve to another plot51 // or just read through the values52 Rappture::Curve *c = p1->curve("curve1");53 54 const double *ax = NULL;55 const double *ay = NULL;56 size_t xlen = 0;57 size_t ylen = 0;58 59 xlen = c->data(Rappture::Curve::xaxis,&ax);60 ylen = c->data(Rappture::Curve::yaxis,&ay);61 62 std::printf("xlen = %zu\nylen = %zu\n",xlen,ylen);63 std::printf("fmt = %s\n",c->propstr(Rappture::Curve::format,NULL));64 65 if ( (ax != NULL)66 && (ay != NULL)) {67 for (size_t i = 0; (i < xlen) && (i < ylen); i++) {68 std::printf("x = %g y = %g\n",ax[i],ay[i]);69 }70 }71 */72 73 161 delete p1; 74 162 75 163 return 0; 76 164 } 165 */
Note: See TracChangeset
for help on using the changeset viewer.