/[H9]/trunk/tntnet/dynamic/temperaturegraph.ecpp
ViewVC logotype

Diff of /trunk/tntnet/dynamic/temperaturegraph.ecpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 118 by torben, Sat Dec 1 20:53:59 2007 UTC revision 177 by torben, Thu Dec 6 14:12:36 2007 UTC
# Line 17  dburl; Line 17  dburl;
17  int id;  int id;
18  </%args>  </%args>
19  <{  <{
20    reply.setHeader("Cache-Control", "no-cache, must-revalidate"); // Http/1.1
21    reply.setHeader("Expires",  "Mon, 26 Jul 1997 05:00:00 GMT"); //date in the past
22    
23  GD::Image image;  GD::Image image;
24  image.CreateTrueColor( GD::Size(600,350));  image.CreateTrueColor( GD::Size(600,360));
25    
26  GD::TrueColor green(45,95,0);  //Black color scheme
27  GD::TrueColor text(200,200,200);  //GD::TrueColor decoration(45,95,0);
28  GD::TrueColor red(255,0,0);  //GD::TrueColor text(200,200,200);
29    //GD::TrueColor line(255,0,0);
30    
31    //White color scheme
32    image.Fill( GD::Point(1,1), GD::TrueColor(255,255,255).Int() );
33    GD::TrueColor decoration(60,60,60);
34    GD::TrueColor text(0,0,0);
35    GD::TrueColor line(255,0,0);
36    
37    
38  image.String(gdFontSmall, 250,5, "Temperature graph", text.Int());  image.String(gdFontSmall, 250,5, "Temperature graph", text.Int());
39    image.String(gdFontSmall, 200,18, "Latest 20 samples, in degrees Celcius", text.Int());
40    
41  for (int i=0; i<11; ++i)  for (int i=0; i<11; ++i)
42  {  {
43          std::stringstream marker;          std::stringstream marker;
44          marker << (100- (i*10));          marker << (100- (i*10));
45          int y = (i*30) + 25;          int y = (i*30) + 40;
46          image.Line(     30, y, 590, y, green.Int());          image.Line(     30, y, 590, y, decoration.Int());
47    
48          image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int());          image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int());
49    
# Line 54  query << "ORDER BY messagenr ASC"; Line 64  query << "ORDER BY messagenr ASC";
64  tntdb::Result res = conn.select(query.str());  tntdb::Result res = conn.select(query.str());
65    
66  GD::Point previous;  GD::Point previous;
67  for (int i=0; i<res.size(); ++i)  for (unsigned int i=0; i<res.size(); ++i)
68  {  {
69          int current = res[i].getInt(0);          int current = res[i].getInt(0);
70          int x = (i*28) + 40;          int x = (i*28) + 45;
71          int y = ((100-current) * 3) + 25;          int y = ((100-current) * 3) + 40;
72    
73          //image.FilledArc( GD::Point(x,y), GD::Size(3,3), 0, 360, red.Int(), gdPie);          //image.FilledArc( GD::Point(x,y), GD::Size(3,3), 0, 360, line.Int(), gdPie);
74          image.FilledRectangle( GD::Point(x-1,y-1), GD::Point(x+1,y+1), red.Int() );          image.FilledRectangle( GD::Point(x-1,y-1), GD::Point(x+1,y+1), line.Int() );
75    
76          if (i>0)          if (i>0)
77          {          {
78                  image.Line( GD::Point(x,y), previous, red.Int());                  image.Line( GD::Point(x,y), previous, line.Int());
79          }          }
80    
81          previous = GD::Point(x,y);          previous = GD::Point(x,y);

Legend:
Removed from v.118  
changed lines
  Added in v.177

  ViewVC Help
Powered by ViewVC 1.1.20