mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fixed #1238 Pie chart not always complete
This commit is contained in:
parent
c76078bd6b
commit
0b806c7664
11
ThirdParty/nightcharts/nightcharts.cpp
vendored
11
ThirdParty/nightcharts/nightcharts.cpp
vendored
@ -37,7 +37,13 @@ Nightcharts::Nightcharts()//QPainter *painter)
|
|||||||
lX = cX+cW+20;
|
lX = cX+cW+20;
|
||||||
lY = cY;
|
lY = cY;
|
||||||
shadows = true;
|
shadows = true;
|
||||||
|
|
||||||
|
// NOTE: This value is accumulated, and might end up with overflow
|
||||||
|
// Was originally uninitialized, and caused overflow issues and invalid drawing when running debug
|
||||||
|
// Suggest rewrite and use locally defined aggregatedAngle (see below for usage)
|
||||||
|
palpha = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Nightcharts::~Nightcharts()
|
Nightcharts::~Nightcharts()
|
||||||
{
|
{
|
||||||
pieces.clear();
|
pieces.clear();
|
||||||
@ -143,6 +149,7 @@ int Nightcharts::draw(QPainter *painter)
|
|||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
|
|
||||||
|
double aggregatedAngle = 0.0;
|
||||||
for (int i=0;i<pieces.size();i++)
|
for (int i=0;i<pieces.size();i++)
|
||||||
{
|
{
|
||||||
gradient.setColorAt(0,pieces[i].rgbColor);
|
gradient.setColorAt(0,pieces[i].rgbColor);
|
||||||
@ -155,8 +162,8 @@ int Nightcharts::draw(QPainter *painter)
|
|||||||
pen.setColor(pieces[i].rgbColor);
|
pen.setColor(pieces[i].rgbColor);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
pdegree = 3.6*pieces[i].pPerc;
|
pdegree = 3.6*pieces[i].pPerc;
|
||||||
painter->drawPie(cX,cY,cW,cH,palpha*16,pdegree*16);
|
painter->drawPie(cX,cY,cW,cH,aggregatedAngle*16,pdegree*16);
|
||||||
palpha += pdegree;
|
aggregatedAngle += pdegree;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this->ctype==Nightcharts::Dpie)
|
else if (this->ctype==Nightcharts::Dpie)
|
||||||
|
Loading…
Reference in New Issue
Block a user