BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
PlotStatusLabel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/PlotUtil/PlotStatusLabel.cpp
6 //! @brief Implements class PlotStatusLabel
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 
19  : StatusLabel(parent)
20 {
21  if (plot)
22  addPlot(plot);
23 }
24 
26 {
27  if (m_plots.contains(plot))
28  return;
29 
30  m_plots.push_back(plot);
31  setPlotLabelEnabled(plot, true);
32 }
33 
34 //! Enables/disables label. If disabled, all colorMaps are disconnected and label is hiding.
35 
37 {
38  for (auto* colorMap : m_plots)
39  setPlotLabelEnabled(colorMap, flag);
40 
41  setEnabled(flag);
42 }
43 
44 //! Disconnects all color maps from the label.
45 
47 {
48  for (auto* colorMap : m_plots)
49  setPlotLabelEnabled(colorMap, false);
50 
51  m_plots.clear();
52 }
53 
54 void PlotStatusLabel::onPlotStatusString(const QString& text)
55 {
56  setText(text);
57 }
58 
59 //! Enables/disables showing of label for given plot.
60 
62 {
63  plot->setMouseTrackingEnabled(flag);
64  setConnected(plot, flag);
65 }
66 
67 //! Connects with colorMap's status string signal.
68 
69 void PlotStatusLabel::setConnected(ScientificPlot* plot, bool flag) const
70 {
71  if (flag) {
73  Qt::UniqueConnection);
74  connect(plot, &ScientificPlot::destroyed, this, &PlotStatusLabel::onPlotDestroyed);
75  } else {
77  }
78 }
79 
81 {
82  auto it = std::remove_if(m_plots.begin(), m_plots.end(),
83  [obj](ScientificPlot* cm) { return cm == obj; });
84  m_plots.erase(it, m_plots.end());
85 }
Defines class PlotStatusLabel.
Declares class ScientificPlot.
void onPlotDestroyed(QObject *obj)
void setConnected(ScientificPlot *plot, bool flag) const
Connects with colorMap's status string signal.
void reset()
Disconnects all color maps from the label.
QList< ScientificPlot * > m_plots
void addPlot(ScientificPlot *plot)
void setPlotLabelEnabled(ScientificPlot *plot, bool flag)
Enables/disables showing of label for given plot.
void setLabelEnabled(bool flag)
Enables/disables label. If disabled, all colorMaps are disconnected and label is hiding.
void onPlotStatusString(const QString &text)
PlotStatusLabel(ScientificPlot *plot, QWidget *parent=nullptr)
Common interface for plot-descriptor interaction.
void statusString(const QString &text)
void setMouseTrackingEnabled(bool enable)
Tracks move events (used when showing profile histograms and printing status string)
The StatusLabel class shows a single line of text on a white background. Opposite to QLabel,...
Definition: StatusLabel.h:28
void setText(const QString &text)
Definition: StatusLabel.cpp:42