BornAgain  1.19.0
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/coregui/Views/IntensityDataWidgets/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 {
20  if (plot)
21  addPlot(plot);
22 }
23 
25 {
26  if (m_plots.contains(plot))
27  return;
28 
29  m_plots.push_back(plot);
30  setPlotLabelEnabled(plot, true);
31 }
32 
33 //! Enables/disables label. If disabled, all colorMaps are disconnected and label is hiding.
34 
36 {
37  for (auto colorMap : m_plots)
38  setPlotLabelEnabled(colorMap, flag);
39 
40  setEnabled(flag);
41 }
42 
43 //! Disconnects all color maps from the label.
44 
46 {
47  for (auto colorMap : m_plots)
48  setPlotLabelEnabled(colorMap, false);
49 
50  m_plots.clear();
51 }
52 
53 void PlotStatusLabel::onPlotStatusString(const QString& text)
54 {
55  setText(text);
56 }
57 
58 //! Enables/disables showing of label for given plot.
59 
61 {
62  plot->setMouseTrackingEnabled(flag);
63  setConnected(plot, flag);
64 }
65 
66 //! Connects with colorMap's status string signal.
67 
69 {
70  if (flag) {
72  Qt::UniqueConnection);
73  connect(plot, &ScientificPlot::destroyed, this, &PlotStatusLabel::onPlotDestroyed);
74  } else {
76  }
77 }
78 
80 {
81  auto it = std::remove_if(m_plots.begin(), m_plots.end(),
82  [obj](ScientificPlot* cm) { return cm == obj; });
83  m_plots.erase(it, m_plots.end());
84 }
Defines class PlotStatusLabel.
Declares class ScientificPlot.
void onPlotDestroyed(QObject *obj)
void setConnected(ScientificPlot *plot, bool flag)
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.
Definition: StatusLabel.h:28
void setText(const QString &text)
Definition: StatusLabel.cpp:39