Skip to content

Commit

Permalink
Axis: axis_grid_background_colour ( none) background colour for axis.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Feb 16, 2023
1 parent 30084f3 commit 935385f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/attributes/AxisAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ AxisAttributes::AxisAttributes():
line_colour_(MagTranslator<string, Colour>().magics("axis_line_colour")),
line_style_(MagTranslator<string, LineStyle>().magics("axis_line_style")),
grid_colour_(MagTranslator<string, Colour>().magics("axis_grid_colour")),
grid_background_colour_(MagTranslator<string, Colour>().magics("axis_grid_background_colour")),
grid_style_(MagTranslator<string, LineStyle>().magics("axis_grid_line_style")),
minor_grid_colour_(MagTranslator<string, Colour>().magics("axis_minor_grid_colour")),
minor_grid_style_(MagTranslator<string, LineStyle>().magics("axis_minor_grid_line_style")),
Expand Down Expand Up @@ -152,6 +153,7 @@ void AxisAttributes::set(const std::map<string, string>& params)
setMember(prefix, "axis_line_colour", line_colour_, params);
setAttribute(prefix, "axis_line_style", line_style_, params);
setMember(prefix, "axis_grid_colour", grid_colour_, params);
setMember(prefix, "axis_grid_background_colour", grid_background_colour_, params);
setAttribute(prefix, "axis_grid_line_style", grid_style_, params);
setMember(prefix, "axis_minor_grid_colour", minor_grid_colour_, params);
setAttribute(prefix, "axis_minor_grid_line_style", minor_grid_style_, params);
Expand Down Expand Up @@ -217,6 +219,7 @@ void AxisAttributes::copy(const AxisAttributes& other)
line_colour_ = unique_ptr<Colour>(other.line_colour_->clone());
line_style_ = other.line_style_;
grid_colour_ = unique_ptr<Colour>(other.grid_colour_->clone());
grid_background_colour_ = unique_ptr<Colour>(other.grid_background_colour_->clone());
grid_style_ = other.grid_style_;
minor_grid_colour_ = unique_ptr<Colour>(other.minor_grid_colour_->clone());
minor_grid_style_ = other.minor_grid_style_;
Expand Down Expand Up @@ -319,6 +322,7 @@ void AxisAttributes::print(ostream& out) const
out << " line_colour = " << *line_colour_;
out << " line_style = " << line_style_;
out << " grid_colour = " << *grid_colour_;
out << " grid_background_colour = " << *grid_background_colour_;
out << " grid_style = " << grid_style_;
out << " minor_grid_colour = " << *minor_grid_colour_;
out << " minor_grid_style = " << minor_grid_style_;
Expand Down Expand Up @@ -434,6 +438,8 @@ void AxisAttributes::toxml(ostream& out) const
niceprint(out, line_style_);
out << ", \"axis_grid_colour\":";
niceprint(out, *grid_colour_);
out << ", \"axis_grid_background_colour\":";
niceprint(out, *grid_background_colour_);
out << ", \"axis_grid_line_style\":";
niceprint(out, grid_style_);
out << ", \"axis_minor_grid_colour\":";
Expand Down Expand Up @@ -509,6 +515,7 @@ static MagicsParameter<string> axis_type("axis_type", "regular");
static MagicsParameter<string> axis_line_colour("axis_line_colour", "automatic");
static MagicsParameter<string> axis_line_style("axis_line_style", "solid");
static MagicsParameter<string> axis_grid_colour("axis_grid_colour", "black");
static MagicsParameter<string> axis_grid_background_colour("axis_grid_background_colour", "none");
static MagicsParameter<string> axis_grid_line_style("axis_grid_line_style", "solid");
static MagicsParameter<string> axis_minor_grid_colour("axis_minor_grid_colour", "black");
static MagicsParameter<string> axis_minor_grid_line_style("axis_minor_grid_line_style", "solid");
Expand Down
1 change: 1 addition & 0 deletions src/attributes/AxisAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class AxisAttributes
unique_ptr<Colour> line_colour_;
LineStyle line_style_;
unique_ptr<Colour> grid_colour_;
unique_ptr<Colour> grid_background_colour_;
LineStyle grid_style_;
unique_ptr<Colour> minor_grid_colour_;
LineStyle minor_grid_style_;
Expand Down
6 changes: 6 additions & 0 deletions src/attributes/AxisWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ void AxisWrapper::set(const MagRequest& request)
axis_->grid_colour_ = unique_ptr<Colour>(MagTranslator<string, Colour>()(grid_colour_value));
}

if (request.countValues("AXIS_GRID_BACKGROUND_COLOUR") ) {
string grid_background_colour_value = request("AXIS_GRID_BACKGROUND_COLOUR");
axis_->grid_background_colour_ = unique_ptr<Colour>(MagTranslator<string, Colour>()(grid_background_colour_value));
}


if (request.countValues("AXIS_GRID_LINE_STYLE") ) {
string grid_style_value = request("AXIS_GRID_LINE_STYLE");
Expand Down Expand Up @@ -403,3 +408,4 @@ static SimpleObjectMaker<HyperAxisMethodWrapper, AxisMethodWrapper> Axis_axis_ty




8 changes: 7 additions & 1 deletion src/params/Axis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ does it submit to any jurisdiction.
from="string"
name="axis_grid_colour">
<documentation>Colour of grid lines</documentation>
<migration>2.13.5 - Default changed fronm YELLOW to BLACK</migration>
</parameter>
<parameter member="grid_background_colour"
to="Colour"
default="none"WrepJS
from="string"
name="axis_grid_background_colour">
<documentation>Colour of grid background</documentation>
</parameter>
<parameter member="grid_style"
to="LineStyle"
Expand Down
16 changes: 16 additions & 0 deletions src/visualisers/Axis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,25 @@ void HorizontalAxis::highlight(DrawingVisitor& out) const {
void HorizontalAxis::grid(DrawingVisitor& out) const {
double bottom = out.minY();
double top = out.maxY();
double left = out.minX();
double right = out.maxX();
double pos;
const Transformation& transformation = out.transformation();

if (!grid_background_colour_->none()) {
Polyline* area = new Polyline();
area->setColour(*grid_background_colour_);
area->setFilled(true);
area->setShading(new FillShadingProperties());
area->setFillColour(*grid_background_colour_);
out.push_back(area);
area->push_back(PaperPoint(left, bottom));
area->push_back(PaperPoint(left, top));
area->push_back(PaperPoint(right, top));
area->push_back(PaperPoint(right, bottom));
area->push_back(PaperPoint(left, bottom));
}

if (!grid_) {
if (grid_reference_level_ != INT_MAX) {
for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x) {
Expand Down

0 comments on commit 935385f

Please sign in to comment.