30 #define COSTPIX_WIDTH 25
34 static QPixmap* pixs[37];
35 static QColor cols[37];
36 static bool inited =
false;
39 for (
int i=0;i<37;i++) pixs[i]=0;
42 int hash = (w+h+c.red()+c.green()+c.blue()) % 37;
44 if ((pixs[hash]->width() == w) &&
45 (pixs[hash]->height() == h) &&
53 QPixmap* pix =
new QPixmap(w, h);
57 p.drawLine(0, 0, w-1, 0);
58 p.drawLine(0, 0, 0, h-1);
60 p.drawLine(w-1, 0, w-1, h-1);
61 p.drawLine(0, h-1, w-1, h-1);
74 int iw, ix1, ih, iy1, iy2;
79 ih = h-2, iy1 = 1, iy2 = h-2;
83 ih = h; iy1 = 0; iy2 = h-1;
86 int filled = iw*percent/100+1;
87 if (!framed) w=filled;
88 if (w<3)
return QPixmap();
95 p.drawRect(0, 0, w-1, h-1);
100 p.drawRect(ix1, iy1, filled-1,ih-1);
103 int lastY = ih-(filled*ih - iw*ih*percent/100);
104 int lastX1 = ix1+filled-2 + ((lastY>1) ? 1: 0);
105 int lastX2 = ix1+filled-2;
109 p.drawLine(ix1, iy1, lastX1, iy1);
110 p.drawLine(ix1, iy1, ix1, iy2);
112 p.drawLine(lastX1, iy1, lastX1, iy1+lastY);
113 p.drawLine(lastX2, iy1+lastY, lastX2, iy2);
114 p.drawLine(ix1+1, iy2, lastX2, iy2);
121 return QColor::fromHsv((720*d/max) % 360, 255-(128*d/max), 192);
126 double* hist,
EventTypeSet* set,
int maxIndex,
bool framed)
128 int lastPos = 0, nextPos;
129 double val=0.0, sum=0.0;
130 int d, dmin=maxIndex, dmax=0;
131 for (d = 0;d<maxIndex;d++)
134 if (dmin>d) dmin = d;
135 if (dmax<d) dmax = d;
139 int iw, ix1, ih, iy1, iy2;
142 ih = h-2, iy1 = 1, iy2 = h-2;
146 ih = h; iy1 = 0; iy2 = h-1;
149 int filled = (int)(iw*sum+1);
150 if (!framed) w=filled;
151 if (w<3)
return QPixmap();
158 p.drawRect(0, 0, w-1, h-1);
163 bool leftDrawn =
false;
169 nextPos = (int)(filled * val/sum);
173 diff = nextPos-lastPos;
174 if (diff==0) { d++;
continue; }
188 p.drawRect(x1, iy1, x2-x1, ih-1);
192 p.drawLine(x1, iy1, x2-1, iy1);
196 p.drawLine(x1, iy1+1, x1, iy2);
202 p.drawLine(x1, iy2, x2-1, iy2);
211 p.drawLine(x2, iy1, x2, iy2);
218 double total,
bool framed)
220 if (!ct)
return QPixmap();
224 double p = 100.0 * cost->
subCost(ct) / total;
230 maxIndex = ct->
histCost(cost, total, h);
232 if (maxIndex ==0)
return QPixmap();
QColor partitionColor(int d, int max)
SubCost subCost(EventType *)
Returns a sub cost.
static QColor eventTypeColor(EventType *)
#define MaxRealIndexValue
QPixmap percentagePixmap(int w, int h, int percent, QColor c, bool framed)
Create a percentage pixmap with a filling rate of p percent (0-100).
An array of basic cost metrics for a trace item.
QPixmap partitionPixmap(int w, int h, double *hist, EventTypeSet *set, int maxIndex, bool framed)
EventType * realType(int)
A class for managing a set of event types.
QPixmap costPixmap(EventType *ct, ProfileCostArray *cost, double total, bool framed)
QPixmap colorPixmap(int w, int h, QColor c)
int histCost(ProfileCostArray *c, double total, double *hist)