[Kst] extragear/graphics/kst/kst
Ted Kisner
tskisner.public at gmail.com
Thu Oct 27 21:47:07 CEST 2005
SVN commit 474971 by tskisner:
Add a backgroundColor member to KstCurveRenderContext. In KstImage, plot pixels this color if the corresponding matrix element is infinite or NAN
M +1 -0 kst2dplot.cpp
M +1 -0 kstbasecurve.h
M +13 -5 kstimage.cpp
M +1 -1 kstimage.h
--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #474970:474971
@@ -2433,6 +2433,7 @@
context._yLog = _yLog;
context.penWidth = penWidth;
context._foregroundColor = _foregroundColor;
+ context._backgroundColor = _backgroundColor;
// paint the curves
for (KstBaseCurveList::Iterator i = Curves.begin(); i != Curves.end(); ++i) {
--- trunk/extragear/graphics/kst/kst/kstbasecurve.h #474970:474971
@@ -37,6 +37,7 @@
double XMin, YMin, XMax, YMax; // range and domain of plot
bool _xLog, _yLog;
QColor _foregroundColor; // plot foreground color
+ QColor _backgroundColor; // plot background color
int penWidth;
};
--- trunk/extragear/graphics/kst/kst/kstimage.cpp #474970:474971
@@ -246,7 +246,7 @@
return i18n("Using matrix %1" ).arg(_inputMatrices[THEMATRIX]->tagName());
}
-QRgb KstImage::getMappedColor(double x, double y) {
+QColor KstImage::getMappedColor(double x, double y) {
bool ok;
double z = _inputMatrices[THEMATRIX]->value(x,y, &ok);
if (ok) {
@@ -262,9 +262,11 @@
} else {
index = 0;
}
- return _pal->color(index).rgb();
+ return _pal->color(index);
}
- return _pal->color(0).rgb();
+ return QColor();
+ //return KstSettings::globalSettings()->backgroundColor.rgb();
+ //return _pal->color(0).rgb();
}
void KstImage::setPalette(KPalette* pal) {
@@ -470,6 +472,7 @@
double x_max = context.x_max, y_max = context.y_max, x_min = context.x_min, y_min = context.y_min;
bool _xLog = context._xLog, _yLog = context._yLog;
QPainter* p = context.p;
+ QColor invalid = context._backgroundColor;
double x, y, width, height;
double img_Lx_pix = 0, img_Ly_pix = 0, img_Hx_pix = 0, img_Hy_pix = 0;
@@ -527,6 +530,7 @@
}
// color map
+ QColor thisPixel;
if (image->hasColorMap()) {
QImage tempImage(d2i(img_Hx_pix-img_Lx_pix),
d2i(img_Hy_pix-img_Ly_pix - 1), 32);
@@ -543,8 +547,12 @@
} else {
new_y = (j + 1 + img_Ly_pix - b_Y) / m_Y;
}
- QRgb rgb = image->getMappedColor(new_x, new_y);
- tempImage.setPixel(i,j, rgb);
+ thisPixel = image->getMappedColor(new_x, new_y);
+ if (thisPixel.isValid()) {
+ tempImage.setPixel(i, j, thisPixel.rgb());
+ } else {
+ tempImage.setPixel(i, j, invalid.rgb());
+ }
}
}
p->drawImage(d2i(img_Lx_pix), d2i(img_Ly_pix + 1), tempImage);
--- trunk/extragear/graphics/kst/kst/kstimage.h #474970:474971
@@ -55,7 +55,7 @@
virtual KstCurveType curveType() const;
virtual bool getNearestZ(double x, double y, double& z);
- virtual QRgb getMappedColor(double x, double y);
+ virtual QColor getMappedColor(double x, double y);
virtual void setPalette(KPalette* pal);
virtual void setUpperThreshold(double z);
virtual void setLowerThreshold(double z);
More information about the Kst
mailing list