From a803d919da1209375cef3ea3ea82482eef57249f Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 1 Oct 2022 17:43:26 +0200 Subject: [PATCH] Allow min/max input freedom --- app/api/formulas.py | 2 +- app/static/app/js/components/Histogram.jsx | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index 62577459..a94ecb86 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -153,7 +153,7 @@ def lookup_formula(algo, band_order = 'RGB'): raise ValueError("Cannot find algorithm " + algo) input_bands = tuple(b for b in re.split(r"([A-Z][a-z]*)", band_order) if b != "") - + def repl(matches): b = matches.group(1) try: diff --git a/app/static/app/js/components/Histogram.jsx b/app/static/app/js/components/Histogram.jsx index 217d23cb..9779b34e 100644 --- a/app/static/app/js/components/Histogram.jsx +++ b/app/static/app/js/components/Histogram.jsx @@ -55,7 +55,9 @@ export default class Histogram extends React.Component { const st = { min: minX.toFixed(3), - max: maxX.toFixed(3) + max: maxX.toFixed(3), + minInput: minX.toFixed(3), + maxInput: maxX.toFixed(3) }; if (!this.state){ @@ -235,6 +237,9 @@ export default class Histogram extends React.Component { } componentDidUpdate(prevProps, prevState){ + if (prevState.min !== this.state.min) this.state.minInput = this.state.min; + if (prevState.max !== this.state.max) this.state.maxInput = this.state.max; + if (prevState.min !== this.state.min || prevState.max !== this.state.max || prevProps.colorMap !== this.props.colorMap || @@ -271,6 +276,7 @@ export default class Histogram extends React.Component { } handleChangeMax = (e) => { + this.setState({maxInput: e.target.value}); const val = parseFloat(e.target.value); if (val >= this.state.min && val <= this.rangeX[1]){ @@ -279,6 +285,7 @@ export default class Histogram extends React.Component { } handleChangeMin = (e) => { + this.setState({minInput: e.target.value}); const val = parseFloat(e.target.value); if (val <= this.state.max && val >= this.rangeX[0]){ @@ -290,8 +297,8 @@ export default class Histogram extends React.Component { return (
{ this.hgContainer = domNode; }}>
- - + +
); } }