From: Ion V. <vas...@pc...> - 2005-01-01 20:51:39
|
Hi, I'd like to customize the data color in a surface plot using a color gradient going from a QColor cMax to a QColor cMin (like the one in the default standard color implementation, going from red to blue). I've tried to follow the approach from the enrichements example. Using the following code I only get an uniform green color: void Graph3D::setColor() { Qwt3D::ColorVector cv; QColor cMax=QColor(green); // color for the max data QColor cMin=QColor (red); // color for the min data unsigned int size=255; double dsize = size; int r1=cMax.red(); int r2=cMin.red(); double stepR = abs(r1-r2)/dsize; int g1=cMax.green(); int g2=cMin.green(); double stepG = abs(g1-g2)/dsize; int b1=cMax.blue(); int b2=cMin.blue(); double stepB = abs(b1-b2)/dsize; RGBA rgb; for (unsigned int i=0; i<size; i++) { rgb.r = r1-i*stepR; rgb.g = g1-i*stepG; rgb.b = b1-i*stepB; cv.push_back(rgb); } StandardColor* col = new StandardColor(sp); col->setColorVector(cv); sp->setDataColor(col); sp->updateData(); sp->updateGL(); } Could anyone give me a hint, please? Thanks in advance, Ion |