Changeset 1325 for trunk


Ignore:
Timestamp:
Jan 23, 2011, 8:22:57 AM (10 years ago)
Author:
Peter Johansson
Message:

use reverse iterator instead of reversing the range

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Graph.cc

    r1323 r1325  
    150150    PLFLT dy=0.003*yrange_;
    151151    unsigned int row=0;
    152     std::reverse(legend_.begin(), legend_.end());
    153     for (std::vector<legend_data>::const_iterator i=legend_.begin();
    154          i!=legend_.end(); i++, ++row) {
     152    std::vector<legend_data>::const_reverse_iterator end = legend_.rend();
     153    for (std::vector<legend_data>::const_reverse_iterator i=legend_.rbegin();
     154         i!=end; ++i, ++row) {
    155155      PLFLT y=(0.95-0.04*row)*yrange_;
    156156      current_color(*i);
  • trunk/test/graph.cc

    r1194 r1325  
    2828#include <ostream>
    2929
     30#include <plplot/plplotP.h>
     31#include <plplot/qsastime.h>
     32
    3033using namespace theplu::svndigest;
    3134
     
    5659  test_graph("pdf", suite);
    5760
     61  Graph graph("plot.png", "png");
     62
     63  double vpwxmi = 40 * 365.25 * 24 * 60 * 60;
     64  double vpwxma = 44 * 365.25 * 24 * 60 * 60;
     65  double xtick1 = 0;
     66  int nxsub1 = 0;
     67  bool ldx = true;
     68  pldtik( vpwxmi, vpwxma, &xtick1, &nxsub1, ldx );
     69  std::cout << "xticks: " << xtick1 << std::endl;
     70  std::cout << "xticks days: " << xtick1/60/60/24 << std::endl;
     71
     72  double factor=0;
     73  double tstart=0;
     74  double sec   = 0.;
     75  int min   = 0;
     76  int hour  = 0;
     77  int day   = 0;
     78  int month = 0;
     79  int year;
     80
     81  std::cout << "vpwxmi: " << vpwxmi << "\n";
     82
     83  plbtime( &year, &month, &day, &hour, &min, &sec, vpwxmi);
     84  std::cout << year << "-" << month << "-" << day << " " << hour << "\n";
     85
     86  sec   = 0.;
     87  min   = 0;
     88  hour  = 0;
     89  day   = 0;
     90  month = 0;
     91  plctime(year, month, day, hour, min, sec, &tstart);
     92
     93  std::cout << "tstart: " << tstart << "\n";
     94
     95  std::cout << "vpwxmi-tstart: " << (vpwxmi-tstart)/3600 << "\n";
     96
     97  pldtfac( vpwxmi, vpwxma, &factor, &tstart );
     98  std::cout << "tstart: " << tstart << "\n";
     99  std::cout << "factor: " << factor/60/60/24 << "\n";
     100
     101  plbtime( &year, &month, &day, &hour, &min, &sec, tstart);
     102  std::cout << year << "-" << month << "-" << day << " " << hour
     103            << " " << min << " " << sec << "\n";
     104
     105  plbtime( &year, &month, &day, &hour, &min, &sec, tstart+3600);
     106  std::cout << year << "-" << month << "-" << day << " " << hour
     107            << " " << min << " " << sec << "\n";
     108
     109  plbtime( &year, &month, &day, &hour, &min, &sec, tstart+3600*24);
     110  std::cout << year << "-" << month << "-" << day << " " << hour
     111            << " " << min << " " << sec << "\n";
     112
     113 
     114
    58115  return suite.exit_status();
    59116}
     
    76133  graph.current_color(255, 0, 0);
    77134  SumVector data;
     135  graph.rev_max(100);
    78136  data.set(99,1);
    79   //  std::vector<unsigned int> data(100,1);
    80137  graph.plot(data, "label", 1);
    81138}
Note: See TracChangeset for help on using the changeset viewer.