Engauge Digitizer  2
ColorFilterSettingsStrategyForeground.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "ColorConstants.h"
8 #include "ColorFilterSettings.h"
9 #include "ColorFilterSettingsStrategyForeground.h"
10 #include <QTextStream>
11 
13 {
14 }
15 
16 ColorFilterSettingsStrategyForeground::~ColorFilterSettingsStrategyForeground ()
17 {
18 }
19 
20 double ColorFilterSettingsStrategyForeground::high (const ColorFilterSettings &colorFilterSettings) const
21 {
22  return (double) (colorFilterSettings.foregroundHigh () - FOREGROUND_MIN) /
23  (double) (FOREGROUND_MAX - FOREGROUND_MIN);
24 }
25 
26 double ColorFilterSettingsStrategyForeground::low (const ColorFilterSettings &colorFilterSettings) const
27 {
28  return (double) (colorFilterSettings.foregroundLow () - FOREGROUND_MIN) /
29  (double) (FOREGROUND_MAX - FOREGROUND_MIN);
30 }
31 
33  QString indentation,
34  QTextStream &str) const
35 {
36  str << indentation << "foregroundLow=" << colorFilterSettings.intensityLow () << "\n";
37  str << indentation << "foregroundHigh=" << colorFilterSettings.intensityHigh () << "\n";
38 }
39 
41  double s0To1)
42 {
43  colorFilterSettings.setForegroundHigh (FOREGROUND_MIN + s0To1 * (FOREGROUND_MAX - FOREGROUND_MIN));
44 }
45 
47  double s0To1)
48 {
49  colorFilterSettings.setForegroundLow (FOREGROUND_MIN + s0To1 * (FOREGROUND_MAX - FOREGROUND_MIN));
50 }
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
virtual void setLow(ColorFilterSettings &colorFilterSettings, double s0To1)
Set the low value given the normalized value.
int foregroundLow() const
Get method for foreground lower bound.
void setForegroundLow(int foregroundLow)
Set method for foreground lower bound.
virtual double high(const ColorFilterSettings &colorFilterSettings) const
Return the high value normalized to 0 to 1.
void setForegroundHigh(int foregroundHigh)
Set method for foreground higher bound.
int foregroundHigh() const
Get method for foreground higher bound.
int intensityHigh() const
Get method for intensity higher bound.
int intensityLow() const
Get method for intensity lower bound.
virtual double low(const ColorFilterSettings &colorFilterSettings) const
Return the low value normalized to 0 to 1.
virtual void setHigh(ColorFilterSettings &colorFilterSettings, double s0To1)
Set the high value given the normalized value.
virtual void printStream(const ColorFilterSettings &colorFilterSettings, QString indentation, QTextStream &str) const
Print the low and high values.