CbmRoot
Loading...
Searching...
No Matches
CbmQaReportFigure.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include "CbmQaReportElement.h"
13#include "CbmQaReportEngine.h"
14
15namespace cbm::qa::report
16{
19 class Figure : public Element {
20 public:
23 struct Plot {
24 Plot() = default;
25
27 Plot(std::string_view path, std::string_view caption, std::string_view label)
28 : fsPath(path)
29 , fsCaption(caption)
30 , fsLabel(label)
31 {
32 }
33
34 std::string fsPath = "";
35 std::string fsCaption = "";
36 std::string fsLabel = "";
37 };
38
42 Figure(std::string_view label, std::string_view title = "")
43 : Element(std::string("fig:") + std::string(label), title)
44 {
45 }
46
48 virtual ~Figure() = default;
49
54 void AddPlot(std::string_view path, std::string_view caption = "", std::string_view label = "")
55 {
56 fvsPlots.emplace_back(path, caption, label);
57 }
58
61 std::string GetBody(const Engine& engine) const override { return engine.FigureBody(*this); }
62
64 const std::string& GetCaption() const { return fsCaption; }
65
67 const std::vector<size_t>& GetPlotGrid() const { return fvGrid; }
68
70 const std::vector<Plot>& GetPlots() const { return fvsPlots; }
71
73 void SetCaption(std::string_view caption) { fsCaption = caption; }
74
78 void SetPlotGrid(size_t nX, size_t nY)
79 {
80 fvGrid.clear();
81 fvGrid.resize(nY, nX);
82 }
83
86 void SetPlotGrid(const std::vector<size_t>& grid) { fvGrid = grid; }
87
88 private:
89 std::vector<Plot> fvsPlots{};
90 std::vector<size_t> fvGrid{};
91 std::string fsCaption{};
92 };
93} // namespace cbm::qa::report
Base class for the report element (header)
Interface for the report element.
A base abstract class to provide an interface for element body (a visitor in the Visitor pattern)
virtual std::string FigureBody(const Figure &figure) const =0
Creates a body for figure.
Figure in the report.
Figure(std::string_view label, std::string_view title="")
Constructor.
std::string fsCaption
Figure caption.
std::vector< size_t > fvGrid
Plot grid.
const std::string & GetCaption() const
Gets caption.
std::string GetBody(const Engine &engine) const override
Gets body of the element.
std::vector< Plot > fvsPlots
Vector of plots (subfigures)
const std::vector< Plot > & GetPlots() const
Gets plot vector.
virtual ~Figure()=default
Destructor.
void SetPlotGrid(size_t nX, size_t nY)
Sets plot grid.
const std::vector< size_t > & GetPlotGrid() const
Gets plot grid.
void SetPlotGrid(const std::vector< size_t > &grid)
Set plot grid.
void SetCaption(std::string_view caption)
Sets caption.
void AddPlot(std::string_view path, std::string_view caption="", std::string_view label="")
Add plot.
Hash for CbmL1LinkKey.
A structure to handle the plot details.
Plot(std::string_view path, std::string_view caption, std::string_view label)
Constructor.