R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BDataMonitorCanvas.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2023 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#pragma once
15#include <TCanvas.h>
16#include <TGraph.h>
17#include <TH1.h>
18#include <TH2.h>
19#include <fmt/core.h>
20#include <variant>
21
22namespace R3B
23{
24 class DataMonitor;
25
26 template <typename ElementType>
28 {
29
30 public:
31 CanvasElement() = default;
32 CanvasElement(ElementType* element, TVirtualPad* pad)
33 : element_{ element }
34 , pad_{ pad }
35 {
36 }
37 auto* get() { return element_; }
38 auto* operator->() { return element_; }
39 auto* pad() { return pad_; }
40
41 private:
42 ElementType* element_ = nullptr;
43 TVirtualPad* pad_ = nullptr;
44 };
45
47 {
48 public:
49 using DrawableElementPtr = std::variant<TH1*, TGraph*>;
50 explicit DataMonitorCanvas(DataMonitor* monitor);
51
52 template <typename... Args>
53 explicit DataMonitorCanvas(DataMonitor* monitor, Args&&... args);
54
55 template <int div_num = 1, typename ElementType, typename... Args>
56 [[nodiscard]] constexpr auto add(Args&&... args) -> CanvasElement<ElementType>;
57
58 template <typename ElementType, typename... Args>
59 [[nodiscard]] constexpr auto add(int div_num, Args&&... args) -> CanvasElement<ElementType>;
60
61 template <typename... Args>
62 void divide(Args&&... args)
63 {
64 canvas_->Divide(args...);
65 }
66
67 auto get_canvas() -> TCanvas* { return canvas_.get(); }
68
69 void draw();
70 void reset();
71
72 private:
73 DataMonitor* monitor_ = nullptr;
74 std::unique_ptr<TCanvas> canvas_;
75 std::map<int, std::vector<DrawableElementPtr>> figures_;
76 };
77} // namespace R3B
CanvasElement(ElementType *element, TVirtualPad *pad)
CanvasElement()=default
DataMonitorCanvas(DataMonitor *monitor)
constexpr auto add(Args &&... args) -> CanvasElement< ElementType >
void divide(Args &&... args)
auto get_canvas() -> TCanvas *
std::variant< TH1 *, TGraph * > DrawableElementPtr