Changeset 1568 for trunk/examples


Ignore:
Timestamp:
Sep 16, 2009 5:39:51 AM (15 years ago)
Author:
dkearney
Message:

adding dump/configure interface to curve object, plot object is broken

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/objects/curve/curve.cc

    r1560 r1568  
    2121}
    2222
    23 int
    24 printCurve(Rappture::Curve *n)
    25 {
    26     std::cout << "path: " << n->path() << std::endl;
    27     std::cout << "label: " << n->label() << std::endl;
    28     std::cout << "desc: " << n->desc() << std::endl;
    29     std::cout << "group: " << n->group() << std::endl;
    30     std::cout << "dims: " << n->dims() << std::endl;
    31 
    32     const Rappture::Array1D *a = NULL;
    33 
    34     for (size_t i = 0; i < n->dims(); i++) {
    35         a = n->getNthAxis(i);
    36         std::cout << "a[" << i << "] = " << a->label() << std::endl;
    37     }
    38 
    39     std::cout << "xml: " << n->xml(indent,tabstop) << std::endl;
    40     return 0;
    41 }
    42 
    4323int curve_0_0 ()
    4424{
     
    4626    const char *testname = "curve_0_0";
    4727
    48     const char *expected = "output.curve(myid)";
     28    const char *expected = "myid";
    4929    const char *received = NULL;
    5030
    5131    Rappture::Curve c(expected);
    52     received = c.path();
     32    received = c.name();
     33
     34    return test(testname,desc,expected,received);
     35}
     36
     37int curve_1_0 ()
     38{
     39    const char *desc = "test generating xml text for curve object";
     40    const char *testname = "curve_1_0";
     41
     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\
     64         2         4\n\
     65         3         9\n\
     66         4        16\n\
     67         5        25\n\
     68         6        36\n\
     69         7        49\n\
     70         8        64\n\
     71         9        81\n\
     72        10       100\n\
     73</xy>\n\
     74    </component>\n\
     75</curve>\n\
     76";
     77    const char *received = NULL;
     78
     79    Rappture::Curve *c = NULL;
     80    double x[] = {1,2,3,4,5,6,7,8,9,10};
     81    double y[] = {1,4,9,16,25,36,49,64,81,100};
     82
     83    c = new Rappture::Curve("myid","mylabel","mydesc","mygroup");
     84
     85    c->axis("xaxis","xlabel","xdesc","xunits","xscale",x,10);
     86    c->axis("yaxis","ylabel","ydesc","yunits","yscale",y,10);
     87
     88    Rappture::ClientDataXml xmldata;
     89    xmldata.indent = indent;
     90    xmldata.tabstop = tabstop;
     91    xmldata.retStr = NULL;
     92    c->dump(Rappture::RPCONFIG_XML,&xmldata);
     93    received = xmldata.retStr;
    5394
    5495    return test(testname,desc,expected,received);
     
    5798int main()
    5899{
    59     Rappture::Curve *n = NULL;
    60     double x[] = {1,2,3,4,5,6,7,8,9,10};
    61     double z[] = {1,2,3,4,5,6,7,8,9,10};
    62     double y[] = {1,4,9,16,25,36,49,64,91,100};
    63 
    64     n = new Rappture::Curve("output.curve(temperature)","mylabel",
    65                             "mydesc","mygroup");
    66 
    67     n->axis("xaxis","xlabel","xdesc","xunits","xscale",x,10);
    68     n->axis("yaxis","ylabel","ydesc","yunits","yscale",y,10);
    69     n->axis("zaxis","zlabel","zdesc","zunits","zscale",z,10);
    70     printCurve(n);
    71     n->delAxis("zlabel");
    72     n->delAxis("xzylabel");
    73     printCurve(n);
    74 
    75     delete n;
     100    curve_0_0 ();
     101    curve_1_0 ();
    76102    return 0;
    77103}
Note: See TracChangeset for help on using the changeset viewer.