Skip to content

Commit

Permalink
Symbol Plotting legend for CAMS plots.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Nov 24, 2023
1 parent a667551 commit f4c9d29
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 88 deletions.
21 changes: 0 additions & 21 deletions src/attributes/SymbolPlottingAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, SymbolMode>().magics("symbol_table_mode")),
Expand Down Expand Up @@ -94,9 +91,6 @@ void SymbolPlottingAttributes::set(const std::map<string, string>& 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);
Expand Down Expand Up @@ -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<SymbolMode>(other.mode_->clone());
outline_colour_ = unique_ptr<Colour>(other.outline_colour_->clone());
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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\":";
Expand Down Expand Up @@ -302,9 +284,6 @@ static MagicsParameter<doublearray> symbol_property_lightness_values_list("symbo
static MagicsParameter<double> symbol_property_saturation_value("symbol_property_saturation_value", 1);
static MagicsParameter<string> symbol_property_height_name("symbol_property_height_name", "colour");
static MagicsParameter<double> symbol_property_height_scaling_factor("symbol_property_height_scaling_factor", 1);
static MagicsParameter<string> symbol_property_filter_name("symbol_property_filter_name", "");
static MagicsParameter<double> symbol_property_filter_min_value("symbol_property_filter_min_value", LLONG_MIN);
static MagicsParameter<double> symbol_property_filter_max_value("symbol_property_filter_max_value", LLONG_MAX);
static MagicsParameter<int> symbol_marker_index("symbol_marker_index", 1);
static MagicsParameter<string> symbol_table_mode("symbol_table_mode", "OFF");
static MagicsParameter<string> symbol_outline_colour("symbol_outline_colour", "black");
Expand Down
3 changes: 0 additions & 3 deletions src/attributes/SymbolPlottingAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SymbolMode> mode_;
unique_ptr<Colour> outline_colour_;
Expand Down
12 changes: 0 additions & 12 deletions src/attributes/SymbolPlottingWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 1 addition & 24 deletions src/params/SymbolPlotting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,30 +328,7 @@ does it submit to any jurisdiction.
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>

<parameter member="property_filter_name"
to="string"
default=""
from="string"
name="symbol_property_filter_name"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_filter_min_value"
to="float"
default="LLONG_MIN"
from="float"
name="symbol_property_filter_min_value"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>
<parameter member="property_filter_max_value"
to="float"
default="LLONG_MAX"
from="float"
name="symbol_property_filter_max_value"
visible='off'>
<documentation>With GeoSon : property name to use to set the colour</documentation>
</parameter>

<parameter member="marker"
to="int"
default="1"
Expand Down
86 changes: 59 additions & 27 deletions src/visualisers/SymbolPlotting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,10 @@ struct SortHelper {
}
};



void SymbolPlotting::by_property(Data& data, BasicGraphicsObjectContainer& out) {

const Transformation& transformation = out.transformation();

std::set<string> 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<float> hueFinder;
void SymbolPlotting::by_property_prepare(IntervalMap<float>& hueFinder, IntervalMap<float>& lightnessFinder)
{
auto value_hue = property_hue_values_list_.begin();
auto hue = property_hue_list_.begin();
IntervalMap<float> lightnessFinder;
auto value_lightness = property_lightness_values_list_.begin();
auto lightness = property_lightness_list_.begin();

Expand All @@ -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<string> 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<float> hueFinder;
IntervalMap<float> lightnessFinder;

by_property_prepare(hueFinder, lightnessFinder);


Colour red("blue");

double factor = ( out.absoluteHeight()*transformation.patchDistance(1))/(transformation.getMaxPCY()-transformation.getMinPCY()) ;

Expand All @@ -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);


Expand All @@ -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);

}
Expand Down Expand Up @@ -312,11 +311,44 @@ void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out) {
}
}


void SymbolPlotting::by_property_legend(Data& data, LegendVisitor& legend) {

IntervalMap<float> hueFinder;
IntervalMap<float> lightnessFinder;

by_property_prepare(hueFinder, lightnessFinder);



for (IntervalMap<float>::const_iterator hue = hueFinder.begin(); hue != hueFinder.end(); ++hue)
for (IntervalMap<float>::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);
}

Expand Down
6 changes: 5 additions & 1 deletion src/visualisers/SymbolPlotting.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>&, IntervalMap<float>&);
bool needLegend() override { return legend_; }

virtual void visit(Data&, HistoVisitor&) override;
void operator()(const PaperPoint&, BasicGraphicsObjectContainer&) const;
void getReady(const LegendVisitor& legend) override;
Expand Down

0 comments on commit f4c9d29

Please sign in to comment.