//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/View/Plotter/PlotStatusLabel.h
//! @brief     Defines class PlotStatusLabel.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_GUI_VIEW_PLOTTER_PLOTSTATUSLABEL_H
#define BORNAGAIN_GUI_VIEW_PLOTTER_PLOTSTATUSLABEL_H

#include <QFrame>
#include <QPaintEvent>
#include <QVector>

class ScientificPlot;

//! The PlotStatusLabel class shows status string as reported by DescriptedPlot in a frame.
//! Can work with more than one DescriptedPlot. Provides automatic adjustment of font size,
//! depending on available space in parent layout. Also doesn't trigger layout resize,
//! being happy with place it has.

class PlotStatusLabel : public QFrame {
    Q_OBJECT
public:
    PlotStatusLabel(ScientificPlot* plot);

    void addPlot(ScientificPlot* plot);
    void setPlot(ScientificPlot* plot);

    void setLabelEnabled(bool flag);

private slots:
    void onPlotDestroyed(QObject* obj);
    void setText(const QString& text);

private:
    void reset();
    void paintEvent(QPaintEvent* event) override;
    void setPlotLabelEnabled(ScientificPlot* plot, bool flag);
    void setConnected(ScientificPlot* plot, bool flag) const;

    QString m_text;
    Qt::Alignment m_alignment;
    QFont m_font;

    QVector<ScientificPlot*> m_plots;
};

#endif // BORNAGAIN_GUI_VIEW_PLOTTER_PLOTSTATUSLABEL_H
