From f4c9d29518aaf28055c7f576ec989b63d32a5b38 Mon Sep 17 00:00:00 2001 From: Sylvie Lamy-Thepaut Date: Fri, 24 Nov 2023 11:57:11 +0000 Subject: [PATCH] Symbol Plotting legend for CAMS plots. --- src/attributes/SymbolPlottingAttributes.cc | 21 ------ src/attributes/SymbolPlottingAttributes.h | 3 - src/attributes/SymbolPlottingWrapper.cc | 12 --- src/params/SymbolPlotting.xml | 25 +------ src/visualisers/SymbolPlotting.cc | 86 +++++++++++++++------- src/visualisers/SymbolPlotting.h | 6 +- 6 files changed, 65 insertions(+), 88 deletions(-) diff --git a/src/attributes/SymbolPlottingAttributes.cc b/src/attributes/SymbolPlottingAttributes.cc index 72b0c0f6..217725b3 100644 --- a/src/attributes/SymbolPlottingAttributes.cc +++ b/src/attributes/SymbolPlottingAttributes.cc @@ -46,9 +46,6 @@ SymbolPlottingAttributes::SymbolPlottingAttributes(): property_saturation_value_(ParameterManager::getDouble("symbol_property_saturation_value")), property_height_name_(ParameterManager::getString("symbol_property_height_name")), property_height_scaling_factor_(ParameterManager::getDouble("symbol_property_height_scaling_factor")), - property_filter_name_(ParameterManager::getString("symbol_property_filter_name")), - property_filter_min_value_(ParameterManager::getDouble("symbol_property_filter_min_value")), - property_filter_max_value_(ParameterManager::getDouble("symbol_property_filter_max_value")), marker_(ParameterManager::getInt("symbol_marker_index")) , mode_(MagTranslator().magics("symbol_table_mode")), @@ -94,9 +91,6 @@ void SymbolPlottingAttributes::set(const std::map& params) setAttribute(prefix, "symbol_property_saturation_value", property_saturation_value_, params); setAttribute(prefix, "symbol_property_height_name", property_height_name_, params); setAttribute(prefix, "symbol_property_height_scaling_factor", property_height_scaling_factor_, params); - setAttribute(prefix, "symbol_property_filter_name", property_filter_name_, params); - setAttribute(prefix, "symbol_property_filter_min_value", property_filter_min_value_, params); - setAttribute(prefix, "symbol_property_filter_max_value", property_filter_max_value_, params); setAttribute(prefix, "symbol_marker_index", marker_, params); setMember(prefix, "symbol_table_mode", mode_, params); @@ -130,9 +124,6 @@ void SymbolPlottingAttributes::copy(const SymbolPlottingAttributes& other) property_saturation_value_ = other.property_saturation_value_; property_height_name_ = other.property_height_name_; property_height_scaling_factor_ = other.property_height_scaling_factor_; - property_filter_name_ = other.property_filter_name_; - property_filter_min_value_ = other.property_filter_min_value_; - property_filter_max_value_ = other.property_filter_max_value_; marker_ = other.marker_; mode_ = unique_ptr(other.mode_->clone()); outline_colour_ = unique_ptr(other.outline_colour_->clone()); @@ -202,9 +193,6 @@ void SymbolPlottingAttributes::print(ostream& out) const out << " property_saturation_value = " << property_saturation_value_; out << " property_height_name = " << property_height_name_; out << " property_height_scaling_factor = " << property_height_scaling_factor_; - out << " property_filter_name = " << property_filter_name_; - out << " property_filter_min_value = " << property_filter_min_value_; - out << " property_filter_max_value = " << property_filter_max_value_; out << " marker = " << marker_; out << " mode = " << *mode_; out << " outline_colour = " << *outline_colour_; @@ -260,12 +248,6 @@ void SymbolPlottingAttributes::toxml(ostream& out) const niceprint(out,property_height_name_); out << ", \"symbol_property_height_scaling_factor\":"; niceprint(out,property_height_scaling_factor_); - out << ", \"symbol_property_filter_name\":"; - niceprint(out,property_filter_name_); - out << ", \"symbol_property_filter_min_value\":"; - niceprint(out,property_filter_min_value_); - out << ", \"symbol_property_filter_max_value\":"; - niceprint(out,property_filter_max_value_); out << ", \"symbol_marker_index\":"; niceprint(out,marker_); out << ", \"symbol_table_mode\":"; @@ -302,9 +284,6 @@ static MagicsParameter symbol_property_lightness_values_list("symbo static MagicsParameter symbol_property_saturation_value("symbol_property_saturation_value", 1); static MagicsParameter symbol_property_height_name("symbol_property_height_name", "colour"); static MagicsParameter symbol_property_height_scaling_factor("symbol_property_height_scaling_factor", 1); -static MagicsParameter symbol_property_filter_name("symbol_property_filter_name", ""); -static MagicsParameter symbol_property_filter_min_value("symbol_property_filter_min_value", LLONG_MIN); -static MagicsParameter symbol_property_filter_max_value("symbol_property_filter_max_value", LLONG_MAX); static MagicsParameter symbol_marker_index("symbol_marker_index", 1); static MagicsParameter symbol_table_mode("symbol_table_mode", "OFF"); static MagicsParameter symbol_outline_colour("symbol_outline_colour", "black"); diff --git a/src/attributes/SymbolPlottingAttributes.h b/src/attributes/SymbolPlottingAttributes.h index d41a0492..2d46d6ff 100644 --- a/src/attributes/SymbolPlottingAttributes.h +++ b/src/attributes/SymbolPlottingAttributes.h @@ -73,9 +73,6 @@ class SymbolPlottingAttributes double property_saturation_value_; string property_height_name_; double property_height_scaling_factor_; - string property_filter_name_; - double property_filter_min_value_; - double property_filter_max_value_; int marker_; unique_ptr mode_; unique_ptr outline_colour_; diff --git a/src/attributes/SymbolPlottingWrapper.cc b/src/attributes/SymbolPlottingWrapper.cc index bdd41661..f57fd136 100644 --- a/src/attributes/SymbolPlottingWrapper.cc +++ b/src/attributes/SymbolPlottingWrapper.cc @@ -155,18 +155,6 @@ void SymbolPlottingWrapper::set(const MagRequest& request) double property_height_scaling_factor_value = request("SYMBOL_PROPERTY_HEIGHT_SCALING_FACTOR"); symbolplotting_->property_height_scaling_factor_ = property_height_scaling_factor_value; } - if (request.countValues("SYMBOL_PROPERTY_FILTER_NAME") ) { - string property_filter_name_value = request("SYMBOL_PROPERTY_FILTER_NAME"); - symbolplotting_->property_filter_name_ = property_filter_name_value; - } - if (request.countValues("SYMBOL_PROPERTY_FILTER_MIN_VALUE") ) { - double property_filter_min_value_value = request("SYMBOL_PROPERTY_FILTER_MIN_VALUE"); - symbolplotting_->property_filter_min_value_ = property_filter_min_value_value; - } - if (request.countValues("SYMBOL_PROPERTY_FILTER_MAX_VALUE") ) { - double property_filter_max_value_value = request("SYMBOL_PROPERTY_FILTER_MAX_VALUE"); - symbolplotting_->property_filter_max_value_ = property_filter_max_value_value; - } if (request.countValues("SYMBOL_MARKER_INDEX") ) { int marker_value = request("SYMBOL_MARKER_INDEX"); symbolplotting_->marker_ = marker_value; diff --git a/src/params/SymbolPlotting.xml b/src/params/SymbolPlotting.xml index 571a3d49..e2c28d46 100644 --- a/src/params/SymbolPlotting.xml +++ b/src/params/SymbolPlotting.xml @@ -328,30 +328,7 @@ does it submit to any jurisdiction. With GeoSon : property name to use to set the colour - - With GeoSon : property name to use to set the colour - - - With GeoSon : property name to use to set the colour - - - With GeoSon : property name to use to set the colour - + needs; - - needs.insert(property_height_name_); - needs.insert(property_hue_name_); - needs.insert(property_lightness_name_); - - - if ( property_hue_list_.empty() ) - property_hue_list_.push_back(1); - if ( property_lightness_list_.empty() ) - property_lightness_list_.push_back(0.5); - - - IntervalMap hueFinder; +void SymbolPlotting::by_property_prepare(IntervalMap& hueFinder, IntervalMap& lightnessFinder) +{ auto value_hue = property_hue_values_list_.begin(); auto hue = property_hue_list_.begin(); - IntervalMap lightnessFinder; auto value_lightness = property_lightness_values_list_.begin(); auto lightness = property_lightness_list_.begin(); @@ -162,10 +143,32 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) lightness++; ++value_lightness; } +} +void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) { + const Transformation& transformation = out.transformation(); - Colour red("red"); + std::set needs; + + needs.insert(property_height_name_); + needs.insert(property_hue_name_); + needs.insert(property_lightness_name_); + + + if ( property_hue_list_.empty() ) + property_hue_list_.push_back(1); + if ( property_lightness_list_.empty() ) + property_lightness_list_.push_back(0.5); + + + IntervalMap hueFinder; + IntervalMap lightnessFinder; + + by_property_prepare(hueFinder, lightnessFinder); + + + Colour red("blue"); double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ; @@ -189,6 +192,7 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) Hsl hsl(hueFinder.find(hue, 0), property_saturation_value_, lightnessFinder.find(lightness, 0.5)); Colour colour(hsl); + cout << colour << endl; symbol->setColour(colour); @@ -210,11 +214,6 @@ void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) duplicates.pop(); } - - // PaperPoint xy = transformation(UserPoint(point->longitude(), point->latitude())); - - // symbol->push_back(xy); - out.push_back(symbol); } @@ -312,11 +311,44 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) { } } + +void SymbolPlotting::by_property_legend(Data& data, LegendVisitor& legend) { + + IntervalMap hueFinder; + IntervalMap lightnessFinder; + + by_property_prepare(hueFinder, lightnessFinder); + + + + for (IntervalMap::const_iterator hue = hueFinder.begin(); hue != hueFinder.end(); ++hue) + for (IntervalMap::const_iterator lightness = lightnessFinder.begin(); lightness != lightnessFinder.end(); ++lightness) + { + Polyline* box = new Polyline(); + double min = lightness->first.min_; + double max = lightness->first.max_; + + box->setShading(new FillShadingProperties()); + + Hsl hsl(hue->second, property_saturation_value_, lightness->second); + Colour colour(hsl); + cout << "add legend " << colour << endl; + + box->setFillColour(colour); + box->setFilled(true); + + legend.add(new BoxEntry(min, max, box)); + } +} + void SymbolPlotting::visit(Data& data, LegendVisitor& legend) { MagLog::debug() << " SymbolPlotting::visit to create a legend ... " << "\n"; if (!legend_) return; + if ( magCompare("property", type_) ) + return by_property_legend(data, legend); + (*mode_).visit(data, legend); } diff --git a/src/visualisers/SymbolPlotting.h b/src/visualisers/SymbolPlotting.h index 3811571c..322849b1 100644 --- a/src/visualisers/SymbolPlotting.h +++ b/src/visualisers/SymbolPlotting.h @@ -44,9 +44,13 @@ class SymbolPlotting : public SymbolPlottingAttributes, public Visdef { virtual void operator()(Data&, BasicGraphicsObjectContainer&) override; - void by_property(Data&, BasicGraphicsObjectContainer&); + virtual void visit(Data&, LegendVisitor&) override; + void by_property(Data&, BasicGraphicsObjectContainer&); + void by_property_legend(Data&, LegendVisitor&); + void by_property_prepare(IntervalMap&, IntervalMap&); bool needLegend() override { return legend_; } + virtual void visit(Data&, HistoVisitor&) override; void operator()(const PaperPoint&, BasicGraphicsObjectContainer&) const; void getReady(const LegendVisitor& legend) override;