Commit cc585a61 authored by Robert Applin's avatar Robert Applin
Browse files

Refs #31571. Tidy up ticklabel format code.

parent d64d8426
......@@ -137,9 +137,6 @@ private:
boost::optional<char const *> overrideAxisLabel(AxisID const &axisID);
void setAxisLabel(AxisID const &axisID, char const *const label);
bool tickLabelFormatX(char *axis, char *style, bool useOffset);
bool tickLabelFormatY(char *axis, char *style, bool useOffset);
// Block redrawing from taking place
bool m_allowRedraws = true;
......
......@@ -741,10 +741,17 @@ void PreviewPlot::toggleLegend(const bool checked) {
* calculated as needed, False no offset will be used
*/
void PreviewPlot::tickLabelFormat(char *axis, char *style, bool useOffset) {
const auto xTickLabelFormatChanged = tickLabelFormatX(axis, style, useOffset);
const auto yTickLabelFormatChanged = tickLabelFormatY(axis, style, useOffset);
auto axes = m_canvas->gca();
const auto formatXTicks = (*axis == 'x' || *axis == 'both') && axes.getXScale().toStdString() == "linear";
const auto formatYTicks = (*axis == 'y' || *axis == 'both') && axes.getYScale().toStdString() == "linear";
if (formatXTicks)
axes.tickLabelFormat(std::string("x").c_str(), style, useOffset);
if (formatYTicks)
axes.tickLabelFormat(std::string("y").c_str(), style, useOffset);
if (xTickLabelFormatChanged || yTickLabelFormatChanged) {
if (formatXTicks || formatYTicks) {
// Need to save parameters to re-format on scale change
m_axis = axis;
m_style = style;
......@@ -752,27 +759,5 @@ void PreviewPlot::tickLabelFormat(char *axis, char *style, bool useOffset) {
}
}
bool PreviewPlot::tickLabelFormatX(char *axis, char *style, bool useOffset) {
auto axes = m_canvas->gca();
const auto isXLinear = (*axis == 'x' || *axis == 'both') && axes.getXScale().toStdString() == "linear";
if (isXLinear) {
char *axisType;
axisType = "x";
axes.tickLabelFormat(axisType, style, useOffset);
}
return isXLinear;
}
bool PreviewPlot::tickLabelFormatY(char *axis, char *style, bool useOffset) {
auto axes = m_canvas->gca();
const auto isYLinear = (*axis == 'y' || *axis == 'both') && axes.getYScale().toStdString() == "linear";
if (isYLinear) {
char *axisType;
axisType = "y";
axes.tickLabelFormat(axisType, style, useOffset);
}
return isYLinear;
}
} // namespace MantidWidgets
} // namespace MantidQt
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment