/* gBarChart Implementation Copyright (c)2011 Mark Watkins License: GPL */ #include #include #include "gBarChart.h" gBarChart::gBarChart(ChannelID code,QColor color,Qt::Orientation o) :Layer(code),m_orientation(o) { //Xaxis=new gXAxis(); addGLBuf(quads=new GLBuffer(color,20,GL_QUADS)); //addGLBuf(lines=new GLBuffer(col,20,GL_LINES)); quads->forceAntiAlias(true); //lines->setAntiAlias(true); //lines->setSize(2); } gBarChart::~gBarChart() { //delete Xaxis; } void gBarChart::paint(gGraph & w,int left, int top, int width, int height) { if (!m_visible) return; qint64 minx=w.min_x, maxx=w.max_x; qint64 xx=maxx - minx; qint32 days=xx/86400000L; float barw=float(width)/float(days); qint64 t2,ts; int day; for (QMap >::iterator d=m_profile->daylist.begin();d!=m_profile->daylist.end();d++) { t2=QDateTime(d.key(),QTime(0,0,0)).toTime_t(); ts=t2*1000L; if (tsmaxx) continue; // break; // out of order if I end up using a hash instead.?? day=t2/86400; float pos=float(day)*barw; } // if (!data) return; //if (!data->IsReady()) return; //int start_px=left; //int start_py=top; //days=data->np[0]; //days=0; /* for (int i=0;inp[0];i++) { if ((data->point[0][i].x() >= w.min_x) && (data->point[0][i].x()np[0];i++) { if (data->point[0][i].x() < w.min_x) continue; if (data->point[0][i].x() >= w.max_x) break; if (idx<0) idx=i; t1=px; px+=barwidth+1; t2=px-t1-1; QRect rect; //Qt:wxDirection dir; u2=data->point[0][i].y()*pxr; u1=start_py; if (antialias) { u1++; u2++; } if (m_orientation==Qt::Vertical) { rect=QRect(start_px,t1,u2,t2); } else { rect=QRect(t1,u1,t2,u2); } //dir=wxEAST; //RoundedRectangle(rect.x,rect.y,rect.width,rect.height,1,color[0]); //,*wxLIGHT_GREY,dir); // TODO: Put this in a function.. QColor & col1=color[0]; QColor col2("light grey"); glBegin(GL_QUADS); //red color glColor4ub(col1.red(),col1.green(),col1.blue(),col1.alpha()); glVertex2f(rect.x(), rect.y()+rect.height()); glVertex2f(rect.x(), rect.y()); //blue color glColor4ub(col2.red(),col2.green(),col2.blue(),col2.alpha()); glVertex2f(rect.x()+rect.width(),rect.y()); glVertex2f(rect.x()+rect.width(), rect.y()+rect.height()); glEnd(); glColor4ub(0,0,0,255); glLineWidth (1); glBegin(GL_LINE_LOOP); glVertex2f(rect.x(), rect.y()+rect.height()+.5); glVertex2f(rect.x(), rect.y()); glVertex2f(rect.x()+rect.width(),rect.y()); glVertex2f(rect.x()+rect.width(), rect.y()+rect.height()+.5); //glVertex2f(rect.x(), rect.y()+rect.height()); glEnd(); if (!draw_xticks_instead) { str=FormatX(data->point[0][i].x()); GetTextExtent(str, textX, textY); if (t2SetShowMinorTicks(false); Xaxis->Plot(w,scrx,scry); } else { px=zpx; for (i=idx;inp[0];i++) { if (data->point[0][i].x() < w.min_x) continue; if (data->point[0][i].x() >= w.max_x) break; t1=px; px+=barwidth+1; t2=px-t1-1; str=FormatX(data->point[0][i].x()); GetTextExtent(str, textX, textY); float j=t1+((t2/2.0)+(textY/2.0)+5); if (m_orientation==Qt::Vertical) { DrawText(str,start_px-textX-8,scry-j); } else { DrawText(str,j,scry-(start_py-3-(textX/2)),90); } } } glColor3f (0.1F, 0.1F, 0.1F); glLineWidth(1); glBegin (GL_LINES); glVertex2f (start_px, start_py); glVertex2f (start_px, start_py+height+1); //glVertex2f (start_px,start_py); //glVertex2f (start_px+width, start_py); glEnd (); */ }