mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 11:40:42 +00:00
Fix pie labels
This commit is contained in:
parent
e32ac39d08
commit
b810cf8acc
@ -164,8 +164,6 @@ gGraph::gGraph(gGraphView *graphview, QString title, QString units, int height,
|
|||||||
invalidate_yAxisImage = true;
|
invalidate_yAxisImage = true;
|
||||||
invalidate_xAxisImage = true;
|
invalidate_xAxisImage = true;
|
||||||
|
|
||||||
m_quad = new gVertexBuffer(64, GL_QUADS);
|
|
||||||
m_quad->forceAntiAlias(true);
|
|
||||||
m_enforceMinY = m_enforceMaxY = false;
|
m_enforceMinY = m_enforceMaxY = false;
|
||||||
m_showTitle = true;
|
m_showTitle = true;
|
||||||
m_printing = false;
|
m_printing = false;
|
||||||
@ -179,7 +177,6 @@ gGraph::~gGraph()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_layers.clear();
|
m_layers.clear();
|
||||||
delete m_quad;
|
|
||||||
|
|
||||||
timer->stop();
|
timer->stop();
|
||||||
disconnect(timer, 0, 0, 0);
|
disconnect(timer, 0, 0, 0);
|
||||||
@ -247,7 +244,6 @@ void gGraph::drawGLBuf()
|
|||||||
m_layers[i]->drawGLBuf(linesize);
|
m_layers[i]->drawGLBuf(linesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_quad->draw();
|
|
||||||
}
|
}
|
||||||
void gGraph::setDay(Day *day)
|
void gGraph::setDay(Day *day)
|
||||||
{
|
{
|
||||||
@ -389,16 +385,7 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h
|
|||||||
|
|
||||||
if (isPinned()) {
|
if (isPinned()) {
|
||||||
// Fill the background on pinned graphs
|
// Fill the background on pinned graphs
|
||||||
|
|
||||||
// m_graphview->quads->add(originX+left,originY+top, originX+width-right,originY+top, originX+width-right,originY+height-bottom, originX+left,originY+height-bottom, 0xffffffff);
|
|
||||||
painter.fillRect(originX + left, originY + top, width - right, height - bottom - top, QBrush(QColor(Qt::white)));
|
painter.fillRect(originX + left, originY + top, width - right, height - bottom - top, QBrush(QColor(Qt::white)));
|
||||||
// glBegin(GL_QUADS);
|
|
||||||
// glColor4f(1.0, 1.0, 1.0, 1.0); // Gradient End
|
|
||||||
// glVertex2i(originX + left, originY + top);
|
|
||||||
// glVertex2i(originX + width - right, originY + top);
|
|
||||||
// glVertex2i(originX + width - right, originY + height - bottom);
|
|
||||||
// glVertex2i(originX + left, originY + height - bottom);
|
|
||||||
// glEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (int i = 0; i < m_layers.size(); i++) {
|
||||||
|
@ -344,7 +344,6 @@ class gGraph : public QObject
|
|||||||
short m_group;
|
short m_group;
|
||||||
short m_lastx23;
|
short m_lastx23;
|
||||||
Day *m_day;
|
Day *m_day;
|
||||||
gVertexBuffer *m_quad;
|
|
||||||
bool m_enforceMinY, m_enforceMaxY;
|
bool m_enforceMinY, m_enforceMaxY;
|
||||||
bool m_showTitle;
|
bool m_showTitle;
|
||||||
bool m_printing;
|
bool m_printing;
|
||||||
|
@ -1304,7 +1304,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
|
|
||||||
// lines->setSize(linesize);
|
// lines->setSize(linesize);
|
||||||
|
|
||||||
// DrawTextQue();
|
DrawTextQue(painter);
|
||||||
//glDisable(GL_TEXTURE_2D);
|
//glDisable(GL_TEXTURE_2D);
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@ void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int w
|
|||||||
// length of this segment in degrees
|
// length of this segment in degrees
|
||||||
float len = 360.0 / float(m_total) * float(data);
|
float len = 360.0 / float(m_total) * float(data);
|
||||||
|
|
||||||
qDebug() << m_names[m];
|
|
||||||
// Setup the shiny radial gradient
|
// Setup the shiny radial gradient
|
||||||
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
@ -141,18 +140,18 @@ void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int w
|
|||||||
painter.drawPie(pierect, -sum * 16.0, -len * 16.0);
|
painter.drawPie(pierect, -sum * 16.0, -len * 16.0);
|
||||||
|
|
||||||
|
|
||||||
if (len > 10) {
|
// Draw text labels if they fit
|
||||||
|
if (len > 20) {
|
||||||
float angle = (sum+90.0) + len / 2.0;
|
float angle = (sum+90.0) + len / 2.0;
|
||||||
double tpx = (start_px + width/2) + (sin(angle * (M_PI / 180.0)) * (radius / 1.7));
|
double tpx = (pierect.x() + pierect.width()/2) + (sin((180 - angle) * (M_PI / 180.0)) * (radius / 1.65));
|
||||||
double tpy = (start_py + height/2) + (cos(angle * (M_PI / 180.0)) * (radius / 1.7));
|
double tpy = (pierect.y() + pierect.height()/2) + (cos((180 - angle) * (M_PI / 180.0)) * (radius / 1.65));
|
||||||
|
|
||||||
QString txt = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%";
|
QString txt = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%";
|
||||||
int x, y;
|
int x, y;
|
||||||
GetTextExtent(txt, x, y);
|
GetTextExtent(txt, x, y);
|
||||||
// antialiasing looks like crap here..
|
// antialiasing looks like crap here..
|
||||||
painter.setPen(QColor(Qt::black));
|
painter.setPen(QColor(Qt::black));
|
||||||
painter.drawText(tpx - (x / 2.0), (tpy - y / 2.0), txt);
|
painter.drawText(tpx - (x / 2.0), tpy+3, txt);
|
||||||
//painter.drawText(txt, tpx - (x / 2.0), (tpy + y / 2.0), 0, Qt::black, defaultfont,false);
|
|
||||||
}
|
}
|
||||||
sum += len;
|
sum += len;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user