source: trunk/lib/Graph.cc @ 863

Last change on this file since 863 was 863, checked in by Jari Häkkinen, 12 years ago

Addresses #97. Fixed background, added doxygen and other comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1// $Id: Graph.cc 863 2009-11-20 18:21:17Z jari $
2
3/*
4  Copyright (C) 2009 Jari Häkkinen
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "Graph.h"
23
24namespace theplu {
25namespace svndigest {
26
27  std::vector<std::string> Graph::xticks_;
28
29  Graph::Graph(const std::string& filename)
30    : plots_(0), pls_(1,1,"svg",filename.c_str())
31  {
32    // we use colour map 0 position 0 for background colour
33    pls_.scolbga(230,230,230,1);
34    pls_.init();
35    pls_.adv(0);
36    pls_.vsta();
37  }
38
39
40  Graph::~Graph(void)
41  {
42  }
43
44
45  bool Graph::date_xticks(void)
46  {
47    return xticks_.size() != 0;
48  }
49
50
51  void Graph::current_colour(unsigned char r, unsigned char g, unsigned char b)
52  {
53    // we use colour map 0 position 1 for current colour
54    pls_.scol0a(1,r,g,b,1.0);
55    pls_.col0(1);
56  }
57
58
59  void Graph::plot(const std::vector<unsigned int>& x)
60  {
61    pls_.wind(0, x.size(), 0, yrange_);
62    if (!plots_) {
63      // draw plot frame, x and y ticks only for the first plot
64      pls_.scol0a(2,0,0,0,1.0);
65      pls_.col0(2);
66      pls_.box("bcnstv", 10, 1, "bcnstv", yrange_/5, 1);
67      pls_.col0(1);
68    }
69    ++plots_;
70    for (unsigned int i=1; i<x.size(); ++i) {
71      pls_.join(i-1,x[i-1],i-1,x[i]);
72      pls_.join(i-1,x[i],i,x[i]);
73    }
74  }
75
76
77  const std::vector<std::string>& Graph::xticks(void)
78  {
79    return xticks_;
80  }
81
82
83  double Graph::yrange(double ymax)
84  {
85    return yrange_=ymax;
86  }
87
88}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.