mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-16 18:50:46 +00:00
Even prettier Pie Chart
This commit is contained in:
parent
6f0d0cc6f2
commit
d733a08a38
@ -33,14 +33,14 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
double j=0.0;
|
double j=0.0;
|
||||||
double sum=0.0;
|
double sum=0.0;
|
||||||
double step=1.0/360.0;
|
double step=1.0/45.0;
|
||||||
float px,py;
|
float px,py;
|
||||||
//glEnable(GL_TEXTURE_2D);
|
//glEnable(GL_TEXTURE_2D);
|
||||||
//glEnable(GL_DEPTH_TEST);
|
//glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
//glEnable(GL_POLYGON_SMOOTH);
|
//glEnable(GL_POLYGON_SMOOTH);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1);
|
glLineWidth(1.5);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
//glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_ONE );
|
//glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_ONE );
|
||||||
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||||
@ -49,30 +49,38 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
j=(data->point[0][i].y()/total); // ratio of this pie slice
|
j=(data->point[0][i].y()/total); // ratio of this pie slice
|
||||||
QColor col1=color[i % color.size()];
|
QColor col1=color[i % color.size()];
|
||||||
w.qglColor(col1);
|
w.qglColor(col1);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
glPolygonMode(GL_BACK,GL_FILL);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
|
double q;
|
||||||
for (double q=sum;q<sum+j;q+=step) {
|
for (q=sum;q<sum+j;q+=step) {
|
||||||
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
||||||
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
||||||
glVertex2f(px,py);
|
glVertex2f(px,py);
|
||||||
}
|
}
|
||||||
|
q=sum+j;
|
||||||
|
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
||||||
|
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
||||||
|
glVertex2f(px,py);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glPolygonMode(GL_BACK,GL_LINE);
|
glPolygonMode(GL_BACK,GL_LINE);
|
||||||
w.qglColor(Qt::black);
|
w.qglColor(Qt::black);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
for (double q=sum;q<sum+j;q+=step) {
|
for (q=sum;q<sum+j;q+=step) {
|
||||||
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
||||||
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
||||||
glVertex2f(px,py);
|
glVertex2f(px,py);
|
||||||
}
|
}
|
||||||
|
q=sum+j;
|
||||||
|
px=start_px+radius+4+sin(q*2*M_PI)*radius;
|
||||||
|
py=start_py+radius+4+cos(q*2*M_PI)*radius;
|
||||||
|
glVertex2f(px,py);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
sum+=j;
|
sum=q;
|
||||||
}
|
}
|
||||||
glDisable(GL_POLYGON_SMOOTH);
|
glDisable(GL_POLYGON_SMOOTH);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -690,7 +690,7 @@ void gGraphWindow::Render(float w, float h)
|
|||||||
glEnd();
|
glEnd();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
glClearColor(0,0,0,255);
|
glClearColor(255,255,255,255);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
// glClear(GL_COLOR_BUFFER_BIT);
|
// glClear(GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
|
|||||||
l->color.push_back(QColor(20,20,20,255));
|
l->color.push_back(QColor(20,20,20,255));
|
||||||
l->color.push_back(QColor("light green"));
|
l->color.push_back(QColor("light green"));
|
||||||
G_AHI->AddLayer(l);
|
G_AHI->AddLayer(l);
|
||||||
//G_AHI->SetDrawBackground(false);
|
G_AHI->SetDrawBackground(false);
|
||||||
//G_AHI->setMaximumSize(2000,30);
|
//G_AHI->setMaximumSize(2000,30);
|
||||||
//TAP->setMaximumSize(2000,30);
|
//TAP->setMaximumSize(2000,30);
|
||||||
NoData=new QLabel(tr("No CPAP Data"),gSplitter);
|
NoData=new QLabel(tr("No CPAP Data"),gSplitter);
|
||||||
|
Loading…
Reference in New Issue
Block a user