CbmRoot
Loading...
Searching...
No Matches
CanvasConfig.cxx
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#include "CanvasConfig.h"
11
13
14#include <sstream>
15
18
19// ---------------------------------------------------------------------------------------------------------------------
20//
21CanvasConfig::CanvasConfig(std::string_view name, std::string_view title, int nPadsX, int nPadsY)
22 : fsName(name)
23 , fsTitle(title)
24 , fNofPadsX(nPadsX)
25 , fNofPadsY(nPadsY)
26{
27}
28
29// ---------------------------------------------------------------------------------------------------------------------
30//
32{
33 fvsPadConfigs.push_back(pad.ToString());
34
35 // Re-calculate number of pads
36 if (fNofPadsX * fNofPadsY < static_cast<int>(fvsPadConfigs.size())) {
37 if (fNofPadsX > fNofPadsY) {
38 ++fNofPadsY;
39 }
40 else {
41 ++fNofPadsX;
42 }
43 }
44}
45
46// ---------------------------------------------------------------------------------------------------------------------
47//
48std::string CanvasConfig::ToString() const
49{
50 // TODO: What to return (throw), if 0 pads defined?
51
52 std::stringstream cfg;
53 cfg << fsName << ';' << fsTitle << ';' << fNofPadsX << ';' << fNofPadsY;
54 if (fvsPadConfigs.empty()) {
55 L_(warning) << "CanvasConfig::ToString(): creating a config message for an empty pad";
56 auto pad = PadConfig();
57 cfg << ';' << pad.ToString();
58 }
59 else {
60 for (const auto& padCfg : fvsPadConfigs) {
61 cfg << ';' << padCfg;
62 }
63 }
64 return cfg.str() + ";";
65}
#define L_(level)
A class representing a canvas in the message for the Histogram server.
A canvas configuration for the histogram server.
std::string ToString() const
Returns message config.
std::vector< std::string > fvsPadConfigs
Vector of pad config messages.
void AddPadConfig(const PadConfig &pad)
Adds a pad to the canvas.
int fNofPadsY
Number of pads along the y-axis.
int fNofPadsX
Number of pads along the x-axis.
std::string fsName
Name of the canvas.
std::string fsTitle
Name of the pad.
A pad configuration for the histogram server.
Definition PadConfig.h:26
std::string ToString() const
Returns message config.
Definition PadConfig.cxx:37