Skip to content
Snippets Groups Projects
Commit 85a7a265 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

move visibility flag down to AmplitudeAxisItem

parent ec264086
No related branches found
No related tags found
1 merge request!2652cleanup axis items
......@@ -36,6 +36,7 @@ AmplitudeAxisItem::AmplitudeAxisItem(QObject* parent)
, m_lock_min_max(false)
, m_log_scale(true)
, m_log_range_orders(6.0)
, m_visible(true)
{
}
......@@ -62,6 +63,11 @@ void AmplitudeAxisItem::writeTo(QXmlStreamWriter* w) const
w->writeStartElement(Tag::LogRangeOrders);
XML::writeAttribute(w, XML::Attrib::value, m_log_range_orders);
w->writeEndElement();
// visibility
w->writeStartElement(Tag::IsVisible);
XML::writeAttribute(w, XML::Attrib::value, m_visible);
w->writeEndElement();
}
void AmplitudeAxisItem::readFrom(QXmlStreamReader* r)
......@@ -87,6 +93,11 @@ void AmplitudeAxisItem::readFrom(QXmlStreamReader* r)
m_log_range_orders = XML::readDouble(r, XML::Attrib::value);
XML::gotoEndElementOfTag(r, tag);
// visibility?
} else if (tag == Tag::IsVisible) {
m_visible = XML::readBool(r, XML::Attrib::value);
XML::gotoEndElementOfTag(r, tag);
} else
r->skipCurrentElement();
}
......@@ -111,3 +122,9 @@ void AmplitudeAxisItem::adjustLogRangeOrders()
if (min() > 0 && max() > 0)
m_log_range_orders = std::log10(max() / min());
}
void AmplitudeAxisItem::setVisible(bool b)
{
m_visible = b;
emit axisVisibilityChanged();
}
......@@ -37,13 +37,18 @@ public:
void setLogRangeOrders(double v);
void adjustLogRangeOrders();
bool isVisible() const { return m_visible; }
void setVisible(bool b);
signals:
void logScaleChanged(bool isLog);
void axisVisibilityChanged();
private:
bool m_lock_min_max;
bool m_log_scale;
double m_log_range_orders;
bool m_visible;
};
#endif // BORNAGAIN_GUI_MODEL_AXIS_AMPLITUDEAXISITEM_H
......@@ -21,7 +21,6 @@
namespace {
namespace Tag {
const QString IsVisible("IsVisible");
const QString Nbins("Nbins");
const QString MinDeg("MinDeg");
const QString MaxDeg("MaxDeg");
......@@ -34,7 +33,6 @@ const QString LogScale("LogScale");
BasicAxisItem::BasicAxisItem(QObject* parent)
: QObject(parent)
, m_visible(true)
, m_nbins(100)
, m_min(0)
, m_max(-1)
......@@ -65,21 +63,10 @@ Scale BasicAxisItem::makeScale(std::string name) const
return EquiScan(name, size(), Units::deg2rad(min()), Units::deg2rad(max()));
}
void BasicAxisItem::setVisible(bool b)
{
m_visible = b;
emit axisVisibilityChanged();
}
void BasicAxisItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeAttribute(w, XML::Attrib::version, uint(1));
// visibility
w->writeStartElement(Tag::IsVisible);
XML::writeAttribute(w, XML::Attrib::value, m_visible);
w->writeEndElement();
// nbins
w->writeStartElement(Tag::Nbins);
XML::writeAttribute(w, XML::Attrib::value, m_nbins);
......@@ -104,13 +91,8 @@ void BasicAxisItem::readFrom(QXmlStreamReader* r)
while (r->readNextStartElement()) {
QString tag = r->name().toString();
// visibility?
if (tag == Tag::IsVisible) {
m_visible = XML::readBool(r, XML::Attrib::value);
XML::gotoEndElementOfTag(r, tag);
// nbins
} else if (tag == Tag::Nbins) {
if (tag == Tag::Nbins) {
m_nbins = XML::readInt(r, XML::Attrib::value);
XML::gotoEndElementOfTag(r, tag);
......
......@@ -41,16 +41,11 @@ public:
double max() const { return m_max; }
void setMax(double value);
bool isVisible() const { return m_visible; }
void setVisible(bool b);
signals:
void axisRangeChanged();
void axisTitleChanged();
void axisVisibilityChanged();
private:
bool m_visible;
int m_nbins;
double m_min; // in display units (if angle, then deg)
double m_max;
......
......@@ -116,7 +116,7 @@ void ColorMap::itemToMap(Data2DItem* item)
&ColorMap::setDataRangeFromItem, Qt::UniqueConnection);
connect(item->zAxisItem(), &AmplitudeAxisItem::logScaleChanged, this, &ColorMap::setLogz,
Qt::UniqueConnection);
connect(item->zAxisItem(), &BasicAxisItem::axisVisibilityChanged, this,
connect(item->zAxisItem(), &AmplitudeAxisItem::axisVisibilityChanged, this,
&ColorMap::setColorScaleVisible, Qt::UniqueConnection);
setAxesRangeConnected(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment