/[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 126 by torben, Sun Dec 2 20:26:43 2007 UTC
# Line 19  int id; Line 19  int id;
19  <{  <{
20    
21  GD::Image image;  GD::Image image;
22  image.CreateTrueColor( GD::Size(600,350));  image.CreateTrueColor( GD::Size(600,360));
23    
24  GD::TrueColor green(45,95,0);  //Black color scheme
25  GD::TrueColor text(200,200,200);  //GD::TrueColor decoration(45,95,0);
26  GD::TrueColor red(255,0,0);  //GD::TrueColor text(200,200,200);
27    //GD::TrueColor line(255,0,0);
28    
29    //White color scheme
30    image.Fill( GD::Point(1,1), GD::TrueColor(255,255,255).Int() );
31    GD::TrueColor decoration(60,60,60);
32    GD::TrueColor text(0,0,0);
33    GD::TrueColor line(255,0,0);
34    
35    
36  image.String(gdFontSmall, 250,5, "Temperature graph", text.Int());  image.String(gdFontSmall, 250,5, "Temperature graph", text.Int());
37    image.String(gdFontSmall, 200,18, "Latest 20 samples, in degrees Celcius", text.Int());
38    
39  for (int i=0; i<11; ++i)  for (int i=0; i<11; ++i)
40  {  {
41          std::stringstream marker;          std::stringstream marker;
42          marker << (100- (i*10));          marker << (100- (i*10));
43          int y = (i*30) + 25;          int y = (i*30) + 40;
44          image.Line(     30, y, 590, y, green.Int());          image.Line(     30, y, 590, y, decoration.Int());
45    
46          image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int());          image.String(gdFontSmall, 5, y-7, marker.str().c_str(), text.Int());
47    
# Line 54  query << "ORDER BY messagenr ASC"; Line 62  query << "ORDER BY messagenr ASC";
62  tntdb::Result res = conn.select(query.str());  tntdb::Result res = conn.select(query.str());
63    
64  GD::Point previous;  GD::Point previous;
65  for (int i=0; i<res.size(); ++i)  for (unsigned int i=0; i<res.size(); ++i)
66  {  {
67          int current = res[i].getInt(0);          int current = res[i].getInt(0);
68          int x = (i*28) + 40;          int x = (i*28) + 45;
69          int y = ((100-current) * 3) + 25;          int y = ((100-current) * 3) + 40;
70    
71          //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);
72          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() );
73    
74          if (i>0)          if (i>0)
75          {          {
76                  image.Line( GD::Point(x,y), previous, red.Int());                  image.Line( GD::Point(x,y), previous, line.Int());
77          }          }
78    
79          previous = GD::Point(x,y);          previous = GD::Point(x,y);

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

  ViewVC Help
Powered by ViewVC 1.1.20