[Kst] kdeextragear-2/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Tue Jul 6 23:13:30 CEST 2004
CVS commit by rchern:
Try to avoid curves with same colour as plot background
M +3 -2 datawizard.ui.h 1.53
M +16 -0 kstcolorsequence.cpp 1.5
M +1 -0 kstcolorsequence.h 1.4
--- kdeextragear-2/kst/kst/datawizard.ui.h #1.52:1.53
@@ -588,5 +588,6 @@ void DataWizard::finished()
name += "'";
}
- KstBaseCurvePtr c = new KstVCurve(name, xv, *it, 0L, 0L, KstColorSequence::next());
+ KstBaseCurvePtr c = new KstVCurve(name, xv, *it, 0L, 0L,
+ KstColorSequence::next(static_cast<Kst2DPlot*>((*pit).data())->backgroundColor()));
if (_drawBoth->isChecked()) {
c->setHasPoints(true);
@@ -639,5 +640,5 @@ void DataWizard::finished()
_kstFFTOptions->VectorUnits->text(),
_kstFFTOptions->RateUnits->text(),
- KstColorSequence::next());
+ KstColorSequence::next(static_cast<Kst2DPlot*>((*pit).data())->backgroundColor()));
if (_drawBoth->isChecked()) {
c->setHasPoints(true);
--- kdeextragear-2/kst/kst/kstcolorsequence.cpp #1.4:1.5
@@ -18,4 +18,5 @@
#include "kstcolorsequence.h"
#include <kpalette.h>
+#include <math.h>
// Default palette that is used if "Kst Colors" is not found.
@@ -53,4 +54,19 @@ return _self->_pal->color(_self->_ptr++)
}
+QColor KstColorSequence::next(const QColor& badColor) {
+ QColor suggestedColor = _self->next();
+ int sugH, sugS, sugV;
+ int badH, badS, badV;
+ suggestedColor.getHsv(sugH,sugS,sugV);
+ badColor.getHsv(badH, badS, badV);
+
+ while (1 - 1 / (sqrt((sugS*sin(sugH)-badS*sin(badH))*(sugS*sin(sugH)-badS*sin(badH)) +
+ (sugS*cos(sugH)-badS*cos(badH))*(sugS*cos(sugH)-badS*cos(badH)) +
+ (sugV-badV)*(sugV-badV))) < 0.8) {
+ suggestedColor = _self->next();
+ suggestedColor.getHsv(sugH,sugS,sugV);
+ }
+ return QColor(suggestedColor);
+}
KstColorSequence::KstColorSequence() : _ptr(0) {
--- kdeextragear-2/kst/kst/kstcolorsequence.h #1.3:1.4
@@ -28,4 +28,5 @@ friend class KStaticDeleter<KstColorSequ
public:
static QColor next();
+ static QColor next(const QColor& badColor);
private:
More information about the Kst
mailing list