diff --git a/src/attributes/ColourTechniqueAttributes.cc b/src/attributes/ColourTechniqueAttributes.cc index 77857f21..2af62957 100644 --- a/src/attributes/ColourTechniqueAttributes.cc +++ b/src/attributes/ColourTechniqueAttributes.cc @@ -24,9 +24,7 @@ using namespace magics; -ColourTechniqueAttributes::ColourTechniqueAttributes(): - oob_min_colour_(ParameterManager::getString("contour_out_of_bound_min_colour")), - oob_max_colour_(ParameterManager::getString("contour_out_of_bound_max_colour")) +ColourTechniqueAttributes::ColourTechniqueAttributes() { @@ -45,16 +43,12 @@ void ColourTechniqueAttributes::set(const std::map& params) int i = 0; prefix[i++] = ""; - setAttribute(prefix, "contour_out_of_bound_min_colour", oob_min_colour_, params); - setAttribute(prefix, "contour_out_of_bound_max_colour", oob_max_colour_, params); } void ColourTechniqueAttributes::copy(const ColourTechniqueAttributes& other) { - oob_min_colour_ = other.oob_min_colour_; - oob_max_colour_ = other.oob_max_colour_; } @@ -93,8 +87,6 @@ void ColourTechniqueAttributes::set(const XmlNode& node) void ColourTechniqueAttributes::print(ostream& out) const { out << "Attributes["; - out << " oob_min_colour = " << oob_min_colour_; - out << " oob_max_colour = " << oob_max_colour_; out << "]" << "\n"; } @@ -102,12 +94,6 @@ void ColourTechniqueAttributes::print(ostream& out) const void ColourTechniqueAttributes::toxml(ostream& out) const { out << "\"\""; - out << ", \"contour_out_of_bound_min_colour\":"; - niceprint(out,oob_min_colour_); - out << ", \"contour_out_of_bound_max_colour\":"; - niceprint(out,oob_max_colour_); } -static MagicsParameter contour_out_of_bound_min_colour("contour_out_of_bound_min_colour", "automatic"); -static MagicsParameter contour_out_of_bound_max_colour("contour_out_of_bound_max_colour", "automatic"); diff --git a/src/attributes/ColourTechniqueAttributes.h b/src/attributes/ColourTechniqueAttributes.h index f4d01134..532f28a5 100644 --- a/src/attributes/ColourTechniqueAttributes.h +++ b/src/attributes/ColourTechniqueAttributes.h @@ -50,8 +50,6 @@ class ColourTechniqueAttributes virtual void toxml(std::ostream& out) const; // -- members: string tag_; - string oob_min_colour_; - string oob_max_colour_; private: diff --git a/src/attributes/ColourTechniqueWrapper.cc b/src/attributes/ColourTechniqueWrapper.cc index 740661f9..e615ccae 100644 --- a/src/attributes/ColourTechniqueWrapper.cc +++ b/src/attributes/ColourTechniqueWrapper.cc @@ -55,14 +55,6 @@ void ColourTechniqueWrapper::set(const MagRequest& request) - if (request.countValues("CONTOUR_OUT_OF_BOUND_MIN_COLOUR") ) { - string oob_min_colour_value = request("CONTOUR_OUT_OF_BOUND_MIN_COLOUR"); - colourtechnique_->oob_min_colour_ = oob_min_colour_value; - } - if (request.countValues("CONTOUR_OUT_OF_BOUND_MAX_COLOUR") ) { - string oob_max_colour_value = request("CONTOUR_OUT_OF_BOUND_MAX_COLOUR"); - colourtechnique_->oob_max_colour_ = oob_max_colour_value; - } } diff --git a/src/common/ColourTableDefinitionCompute.cc b/src/common/ColourTableDefinitionCompute.cc index 8abf2042..a62a6b51 100644 --- a/src/common/ColourTableDefinitionCompute.cc +++ b/src/common/ColourTableDefinitionCompute.cc @@ -275,10 +275,6 @@ void ColourTableDefinitionCompute::hcl(ColourTable& table, int nb) { void ColourTableDefinitionCompute::set(ColourTable& table, int nb) { prepare(); - MagLog::dev() << "ColourTableDefinitionCompute::set->min-->" << minColour_ << endl; - MagLog::dev() << "ColourTableDefinitionCompute::set->max-->" << maxColour_ << endl; - MagLog::dev() << "nb interval-->" << nb << endl; - if (nb == 1) { table.push_back(minColour_); return; @@ -292,6 +288,8 @@ void ColourTableDefinitionCompute::set(ColourTable& table, int nb) { table.push_back(maxColour_); return; } + + std::map::iterator method = methods_.find(lowerCase(method_)); if (method == methods_.end()) hsl(table, nb); @@ -394,6 +392,8 @@ void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, int nb, ColourListPolicy policy, const string& method) { + + cout << "SET" << policy << endl; auto colour = from.begin(); if (policy == ColourListPolicy::DYNAMIC) { auto helper = dynamicMethods_.find(method); @@ -409,6 +409,7 @@ void ColourTableDefinitionCompute::set(const stringarray& from, ColourTable& to, } for (int i = 0; i < nb - 1; i++) { + cout << i << "->" << *colour << endl; if (colour == from.end()) { if (policy == ColourListPolicy::LASTONE) { to.push_back(Colour(from.back())); diff --git a/src/params/ColourTechnique.xml b/src/params/ColourTechnique.xml index d0e22340..8826bfcc 100644 --- a/src/params/ColourTechnique.xml +++ b/src/params/ColourTechnique.xml @@ -9,23 +9,7 @@ does it submit to any jurisdiction. - - Colour to use below the out of bound minimum value - - - Colour to use below the out of bound maximum value - diff --git a/src/visualisers/ColourTechnique.cc b/src/visualisers/ColourTechnique.cc index 5a063675..a6d9807e 100644 --- a/src/visualisers/ColourTechnique.cc +++ b/src/visualisers/ColourTechnique.cc @@ -29,9 +29,7 @@ using namespace magics; -ColourTechnique::ColourTechnique() : policy_(ListPolicy::LASTONE), - minOutOfBound_(false), maxOutOfBound_(false) - {} +ColourTechnique::ColourTechnique() : policy_(ListPolicy::LASTONE) {} ColourTechnique::~ColourTechnique() {} @@ -45,53 +43,15 @@ void ColourTechnique::print(ostream& out) const { } void ColourTechnique::prepare(LevelSelection& out, LevelSelection& levels, bool rainbow) { - if (levels.empty()) + if (levels.empty()) return; - - clear(); bands_.clear(); ColourTable table; - - - - minOutOfBound_ = out.minOutOfBond(); - maxOutOfBound_ = out.maxOutOfBond(); - - - if (rainbow) set(out, levels, table, levels.size() + 1); - else { - - LevelSelection newlevels; - int count = levels.size(); - if (out.minOutOfBond()) count--; - - if (out.maxOutOfBond()) count--; - - - - set(out, levels, table, count); - if (out.minOutOfBond()) { - Colour min_colour = magCompare(oob_min_colour_, "automatic") ? - table.front().colour() : Colour(oob_min_colour_); - table.insert(table.begin(), min_colour); - } - if (out.maxOutOfBond()) { - Colour max_colour = magCompare(oob_max_colour_, "automatic") ? - table.back().colour() : Colour(oob_max_colour_); - table.push_back(max_colour); - } - } - - - // cout << "ColourTechnique::after(" << endl; - // for (auto l = levels.begin(); l != levels.end(); ++l) - // cout << *l << endl; - - // cout << "-------------------" << endl; - + else + set(out, levels, table, levels.size()); if (table.empty()) table.push_back(Colour("none")); @@ -131,8 +91,6 @@ void ColourTechnique::prepare(LevelSelection& out, LevelSelection& levels, bool if (!rainbow) bands_.insert(make_pair(Interval(levels.back(), levels.back() + EPSILON), left)); - - MagLog::dev() << levels.back() << "<<" << left << "<<" << levels.back() + EPSILON << endl; } diff --git a/src/visualisers/ColourTechnique.h b/src/visualisers/ColourTechnique.h index 75c3778b..4e79bc9a 100644 --- a/src/visualisers/ColourTechnique.h +++ b/src/visualisers/ColourTechnique.h @@ -87,8 +87,6 @@ class ColourTechnique : public map, void visit(LegendVisitor&); ListPolicy getPolicy() const { return policy_; } - bool minOutOfBound() const { return minOutOfBound_; } - bool maxOutOfBound() const { return maxOutOfBound_; } protected: //! Method to print string about this class on to a stream of type ostream (virtual). @@ -98,9 +96,7 @@ class ColourTechnique : public map, map > ranges_; double maxLevel_; - bool minOutOfBound_; - bool maxOutOfBound_; - + ListPolicy policy_; diff --git a/src/visualisers/CountSelectionType.cc b/src/visualisers/CountSelectionType.cc index 0fe91451..cb6b4aa2 100644 --- a/src/visualisers/CountSelectionType.cc +++ b/src/visualisers/CountSelectionType.cc @@ -34,59 +34,21 @@ CountSelectionType::CountSelectionType() {} #define MAXSET(v) !same(v, +1.0e+21) void CountSelectionType::calculate(double min, double max, bool shading) { - - - clear(); - - - double min_limit=min; - double max_limit=max; - - - if ( MINSET(min_) ) - min_limit = min_; - - if ( MAXSET(max_) ) - max_limit = max_; - - if ( shading && MINSET(shade_min_) ) - min_limit = shade_min_; - - if ( shading && MAXSET(shade_max_) ) - max_limit = shade_max_; - - minOutOfBond_ = oob_min_ > min_limit; - maxOutOfBond_ = oob_max_ < max_limit; - +clear(); + double maxi = (max_ > 1000000000) ? max : max_; + double mini = (min_ < -1000000000) ? min : min_; int i = 0; - if ( minOutOfBond_ || !MINSET(min_)) { - i++; - } - - if ( maxOutOfBond_ || !MAXSET(max_) ) { - i++; - } + i += (max_ > 1000000000) ? 1 : 0; + i += (min_ < -1000000000) ? 1 : 0; - // Commented for now, may have to be revisited soon. - // i += ( MINSET(min_limit) ) ? 1 : 0; - // i += ( MAXSET(max_limit) ) ? 1 : 0; - double nb = levelCount_ - 1; - if (same(max_limit, min_limit)) { - push_back(min_limit); + if (same(maxi, mini)) { + push_back(mini); return; } - - if (min_limit > max_limit) { - push_back(max_limit); - push_back(min_limit); - return; - } - - - double step = (max_limit - min_limit) / nb; + double step = (maxi - mini) / nb; double toleranceProportion = (double)tolerance_ / (double)(levelCount_ + 1 + i); // tolerance as a proportion of the number of levels @@ -94,7 +56,7 @@ void CountSelectionType::calculate(double min, double max, bool shading) { // number of levels we will not actually plot, ie the min/max contours). if (same(step, 0)) { // Only one isoline! - push_back(min_limit); + push_back(mini); return; } @@ -145,12 +107,13 @@ void CountSelectionType::calculate(double min, double max, bool shading) { inc *= istep; // convert back into proper range - double first = floor(min_limit / inc) * inc; - while (first > min_limit) + double first = floor(mini / inc) * inc; + + while (first > mini) first -= inc; - push_back(min_limit); + push_back(mini); first += inc; double epsilon = inc / 10000.0; while (same(epsilon, 0)) { @@ -159,20 +122,18 @@ void CountSelectionType::calculate(double min, double max, bool shading) { } - - for (double val = first; val < max_limit; val += inc) { + for (double val = first; val < maxi; val += inc) { // special case - if the value is close to zero then set it to precisely zero to avoid later formatting issues if (fabs(val) < epsilon) push_back(0.0); - else if (same(val, max_limit)) - push_back(max_limit); + else if (same(val, maxi)) + push_back(maxi); else push_back(val); } - if (max_limit != back()) - push_back(max_limit); - + if (maxi != back()) + push_back(maxi); int si = static_cast(size()); @@ -180,37 +141,28 @@ void CountSelectionType::calculate(double min, double max, bool shading) { // so as to ensure the correct number, even if they are not nice if (si - i < levelCount_ - tolerance_ || si - i > levelCount_ + tolerance_) { - MagLog::debug() << "Not using nice levels[" << levelCount_ << ", " << tolerance_ << "]-->" << size() << endl; + MagLog::debug() << "Not using nice levels[" << levelCount_ << ", " << tolerance_ << "]-->" << size() << endl; clear(); - step = (max_limit - min_limit) / (levelCount_ - 1); - double val = min_limit; + step = (maxi - mini) / (levelCount_ - 1); + double val = mini; while (1) { - if ( val >= min_limit && val <= max_limit ) push_back(val); - if (same(val, max_limit) || val > max_limit) + if (same(val, maxi) || val > maxi) break; val += step; } MagLog::debug() << "New size-->" << size() << endl; } - if ( minOutOfBond_ ) { - insert(begin(), std::max(min, min_)); - } + MagLog::debug() << "count=" << levelCount_ << ", tolerance=" << tolerance_ << ", result=" << size() << endl; - if ( maxOutOfBond_ ) { - push_back(std::min(max, max_)); - } - - ostringstream level; for (const_iterator l = begin(); l != end(); ++l) level << *l << " "; - MagLog::debug() << level.str() << endl; + MagLog::debug() << level.str() << endl; } - CountSelectionType::~CountSelectionType() {} /*! diff --git a/src/visualisers/IntervalSelectionType.cc b/src/visualisers/IntervalSelectionType.cc index 8b48f8ba..1ca7e2d0 100644 --- a/src/visualisers/IntervalSelectionType.cc +++ b/src/visualisers/IntervalSelectionType.cc @@ -95,7 +95,7 @@ void IntervalSelectionType::calculate(double min, double max, bool shading) { push_back(*level); } out << "]" << endl; - // cout << out.str() << endl; + MagLog::dev() << out.str() << endl; } diff --git a/src/visualisers/LevelListSelectionType.cc b/src/visualisers/LevelListSelectionType.cc index 1f400d8d..ae5338cb 100644 --- a/src/visualisers/LevelListSelectionType.cc +++ b/src/visualisers/LevelListSelectionType.cc @@ -45,47 +45,12 @@ void LevelListSelectionType::print(ostream& out) const { void LevelListSelectionType::calculate(double min, double max, bool shading) { clear(); - double min_level=list_.front(); - double max_level=list_.back(); - - - if ( MINSET(min_) ) - min_level = min_; - - if ( MAXSET(max_) ) - max_level = max_; - - if ( shading && MINSET(shade_min_) ) - min_level = shade_min_; - - if ( shading && MAXSET(shade_max_) ) - max_level = shade_max_; - - - - minOutOfBond_ = oob_min_ > min_level; - maxOutOfBond_ = oob_max_ < max_level; - - - - - if (minOutOfBond_) { - push_back(min); - push_back(oob_min_); - min_level = oob_min_; - } - - if (maxOutOfBond_) { - max_level = oob_max_; - } - - doublearray::const_iterator last = list_.begin(); double prevVal = min_; for (doublearray::const_iterator val = list_.begin(); val != list_.end(); ++val) { MagLog::dev() << "LevelListSelectionType::calculate(double min, double max)--->" << *val << "\n"; - if (min_level <= *val && *val <= max_level) { + if (min_ <= *val && *val <= max_) { if (*val < prevVal) { MagLog::error() << " level list values should increase, but " << *val << " follows " << prevVal << endl; break; @@ -95,24 +60,19 @@ void LevelListSelectionType::calculate(double min, double max, bool shading) { } ++last; } - if (maxOutOfBond_) { - push_back(oob_max_); - push_back(max); - } - // Just in case add another level to close the last interval ! if (last != list_.end()) push_back(*last); - // ostringstream print; - // print << "LevelListSelectionType::calculate-->"; - // string sep = "["; - // for (vector::const_iterator val = begin(); val != end(); ++val) { - // print << sep << *val; - // sep = ", "; - // } - // print << "]"; - // cout << print.str() << endl; + ostringstream print; + print << "LevelListSelectionType::calculate-->"; + string sep = "["; + for (vector::const_iterator val = begin(); val != end(); ++val) { + print << sep << *val; + sep = ", "; + } + print << "]"; + MagLog::dev() << print.str() << endl; } diff --git a/src/visualisers/LevelSelection.h b/src/visualisers/LevelSelection.h index 218d342b..1be70cc6 100644 --- a/src/visualisers/LevelSelection.h +++ b/src/visualisers/LevelSelection.h @@ -58,15 +58,11 @@ class LevelSelection : public LevelSelectionAttributes, public doublearray { virtual double reference(int) const; virtual void thinLevels(int frequency, vector&) const; - bool minOutOfBond() { return minOutOfBond_; } - bool maxOutOfBond() { return maxOutOfBond_; } - + protected: //! Method to print string about this class on to a stream of type ostream (virtual). virtual void print(ostream&) const override; - bool minOutOfBond_; - bool maxOutOfBond_; -; + private: //! Copy constructor - No copy allowed diff --git a/src/visualisers/PolyShadingTechnique.h b/src/visualisers/PolyShadingTechnique.h index 5724699c..07d24508 100644 --- a/src/visualisers/PolyShadingTechnique.h +++ b/src/visualisers/PolyShadingTechnique.h @@ -141,7 +141,6 @@ struct LegendEntryBuilder { box->setColour(colours_.right(min)); LegendEntry* entry = new BoxEntry(min, max, box); - entry->oob(colours_.minOutOfBound(), colours_.maxOutOfBound()); if (first_) { first_ = false; entry->first();