mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 11:40:42 +00:00
Pie Chart Improvements
This commit is contained in:
parent
9b93c8f6ea
commit
2e4eb2f3f2
@ -51,6 +51,13 @@ void gCandleStick::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin())-1;
|
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin())-1;
|
||||||
int height=scry-(w.GetTopMargin()+w.GetBottomMargin())-1;
|
int height=scry-(w.GetTopMargin()+w.GetBottomMargin())-1;
|
||||||
|
|
||||||
|
|
||||||
|
for (map<MachineCode,int>::iterator m=m_counts.begin();m!=m_counts.end();m++) {
|
||||||
|
if (!m->second) continue;
|
||||||
|
int j=float(m->second)/float(m_total); // ratio of this pie slice
|
||||||
|
//QColor & col1 = m_colors[m->first];
|
||||||
|
//QColor & col2 = m_gradient_color;
|
||||||
|
}
|
||||||
/* float sum=0;
|
/* float sum=0;
|
||||||
for (int i=0;i<data->np[0];i++)
|
for (int i=0;i<data->np[0];i++)
|
||||||
sum+=data->point[0][i].y();
|
sum+=data->point[0][i].y();
|
||||||
|
@ -19,11 +19,15 @@ class gCandleStick:public gLayer
|
|||||||
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
||||||
void AddSlice(MachineCode code,QColor color,QString name="");
|
void AddSlice(MachineCode code,QColor color,QString name="");
|
||||||
|
|
||||||
|
void setGradientColor(QColor & color) { m_gradient_color=color; }
|
||||||
|
void setOutlineColor(QColor & color) { m_outline_color=color; }
|
||||||
protected:
|
protected:
|
||||||
Qt::Orientation m_orientation;
|
Qt::Orientation m_orientation;
|
||||||
map<MachineCode,int> m_counts;
|
map<MachineCode,int> m_counts;
|
||||||
map<MachineCode,QString> m_names;
|
map<MachineCode,QString> m_names;
|
||||||
map<MachineCode,QColor> m_colors;
|
map<MachineCode,QColor> m_colors;
|
||||||
|
QColor m_gradient_color;
|
||||||
|
QColor m_outline_color;
|
||||||
int m_total;
|
int m_total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
gPieChart::gPieChart(QColor outline_color)
|
gPieChart::gPieChart(QColor outline_color)
|
||||||
:gLayer(MC_UNKNOWN),m_outline_color(outline_color)
|
:gLayer(MC_UNKNOWN),m_outline_color(outline_color)
|
||||||
{
|
{
|
||||||
|
m_gradient_color=QColor(200,200,200);
|
||||||
}
|
}
|
||||||
gPieChart::~gPieChart()
|
gPieChart::~gPieChart()
|
||||||
{
|
{
|
||||||
@ -57,10 +58,12 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
for (map<MachineCode,int>::iterator m=m_counts.begin();m!=m_counts.end();m++) {
|
for (map<MachineCode,int>::iterator m=m_counts.begin();m!=m_counts.end();m++) {
|
||||||
if (!m->second) continue;
|
if (!m->second) continue;
|
||||||
j=float(m->second)/float(m_total); // ratio of this pie slice
|
j=float(m->second)/float(m_total); // ratio of this pie slice
|
||||||
w.qglColor(m_colors[m->first]);
|
|
||||||
glPolygonMode(GL_BACK,GL_FILL);
|
glPolygonMode(GL_BACK,GL_FILL);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
|
bool first_col;
|
||||||
|
w.qglColor(m_gradient_color);
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
|
w.qglColor(m_colors[m->first]);
|
||||||
double q;
|
double q;
|
||||||
for (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;
|
||||||
@ -75,8 +78,12 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
|
|
||||||
glPolygonMode(GL_BACK,GL_LINE);
|
glPolygonMode(GL_BACK,GL_LINE);
|
||||||
w.qglColor(m_outline_color);
|
w.qglColor(m_outline_color);
|
||||||
glBegin(GL_POLYGON);
|
if (m_total>m->second) { // Draw the center point first
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glBegin(GL_POLYGON);
|
||||||
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
|
} else { // Only one entry, so just draw the circle
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
}
|
||||||
for (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;
|
||||||
|
@ -12,6 +12,8 @@ public:
|
|||||||
virtual void SetDay(Day *d);
|
virtual void SetDay(Day *d);
|
||||||
|
|
||||||
void AddSlice(MachineCode code,QColor col,QString name="");
|
void AddSlice(MachineCode code,QColor col,QString name="");
|
||||||
|
void setGradientColor(QColor & color) { m_gradient_color=color; }
|
||||||
|
void setOutlineColor(QColor & color) { m_outline_color=color; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
map <MachineCode,QString> m_names;
|
map <MachineCode,QString> m_names;
|
||||||
@ -19,6 +21,8 @@ protected:
|
|||||||
map <MachineCode,QColor> m_colors;
|
map <MachineCode,QColor> m_colors;
|
||||||
int m_total;
|
int m_total;
|
||||||
QColor m_outline_color;
|
QColor m_outline_color;
|
||||||
|
QColor m_gradient_color;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPIECHART_H
|
#endif // GPIECHART_H
|
||||||
|
@ -271,9 +271,10 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
|
|||||||
//gSplitter->setCollapsible(gSplitter->indexOf(SF),false);
|
//gSplitter->setCollapsible(gSplitter->indexOf(SF),false);
|
||||||
//gSplitter->setStretchFactor(gSplitter->indexOf(SF),0);
|
//gSplitter->setStretchFactor(gSplitter->indexOf(SF),0);
|
||||||
|
|
||||||
gSplitter->layout();
|
|
||||||
|
|
||||||
splitter_sizes=gSplitter->sizes();
|
splitter_sizes=gSplitter->sizes();
|
||||||
|
gSplitter->layout();
|
||||||
|
gSplitter->update();
|
||||||
|
|
||||||
|
|
||||||
QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday);
|
QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday);
|
||||||
format.setForeground(QBrush(Qt::black, Qt::SolidPattern));
|
format.setForeground(QBrush(Qt::black, Qt::SolidPattern));
|
||||||
|
Loading…
Reference in New Issue
Block a user