diff --git a/Modules/Common/include/Common/BigScreenCanvas.h b/Modules/Common/include/Common/BigScreenCanvas.h index af6d1370a2..b6529fb438 100644 --- a/Modules/Common/include/Common/BigScreenCanvas.h +++ b/Modules/Common/include/Common/BigScreenCanvas.h @@ -31,7 +31,8 @@ struct BigScreenElement; class BigScreenCanvas : public TCanvas { public: - BigScreenCanvas(std::string name, std::string title, int nRows, int nCols, int borderWidth); + BigScreenCanvas(std::string name, std::string title, int nRows, int nCols, int borderWidth, + int foregroundColor = kBlack, int backgroundColor = kWhite); ~BigScreenCanvas() = default; /// \brief add a box in the canvas at a given index, with "name" displayed above the box @@ -60,6 +61,9 @@ class BigScreenCanvas : public TCanvas float mLabelOffset{ 0.05 }; /// \brief colors associated to each quality state (Good/Medium/Bad/Null) std::unordered_map mColors; + int mForegroundColor{ kBlack }; /// ROOT color index for the foreground text + int mBackgroundColor{ kWhite }; /// ROOT color index for the canvas backgound + std::shared_ptr mBackgoundPad; /// TPad used to draw the background color /// \brief elements (colored boxes + labels) displayed in the canvas std::unordered_map> mBoxes; }; diff --git a/Modules/Common/src/BigScreen.cxx b/Modules/Common/src/BigScreen.cxx index 3f9996b238..9525ba84dd 100644 --- a/Modules/Common/src/BigScreen.cxx +++ b/Modules/Common/src/BigScreen.cxx @@ -16,6 +16,7 @@ /// #include "Common/BigScreen.h" +#include "Common/Utils.h" #include "QualityControl/QcInfoLogger.h" #include "QualityControl/DatabaseInterface.h" #include "QualityControl/ActivityHelpers.h" @@ -54,46 +55,22 @@ std::string getParameter(o2::quality_control::core::CustomParameters customParam void BigScreen::initialize(quality_control::postprocessing::Trigger t, framework::ServiceRegistryRef services) { - int nRows = 1; - int nCols = 1; - int borderWidth = 5; + int nRows = getFromExtendedConfig(t.activity, mCustomParameters, "nRows", 1); + int nCols = getFromExtendedConfig(t.activity, mCustomParameters, "nCols", 1); + int borderWidth = getFromExtendedConfig(t.activity, mCustomParameters, "borderWidth", 5); + int foregroundColor = getFromExtendedConfig(t.activity, mCustomParameters, "foregroundColor", 1); + int backgroundColor = getFromExtendedConfig(t.activity, mCustomParameters, "backgroundColor", 0); - std::string parValue; - parValue = getParameter(mCustomParameters, "nRows", t.activity); - if (!parValue.empty()) { - nRows = std::stoi(parValue); - } - - parValue = getParameter(mCustomParameters, "nCols", t.activity); - if (!parValue.empty()) { - nCols = std::stoi(parValue); - } - - parValue = getParameter(mCustomParameters, "borderWidth", t.activity); - if (!parValue.empty()) { - borderWidth = std::stoi(parValue); - } - - parValue = getParameter(mCustomParameters, "maxObjectTimeShift", t.activity); - if (!parValue.empty()) { - mMaxObjectTimeShift = std::stoi(parValue); - } - - parValue = getParameter(mCustomParameters, "ignoreActivity", t.activity); - if (!parValue.empty()) { - mIgnoreActivity = (std::stoi(parValue) != 0); - } - - // get the list of labels - parValue = getParameter(mCustomParameters, "labels", t.activity); - auto labels = o2::utils::Str::tokenize(parValue, ',', false, false); + mMaxObjectTimeShift = getFromExtendedConfig(t.activity, mCustomParameters, "maxObjectTimeShift", mMaxObjectTimeShift); + mIgnoreActivity = getFromExtendedConfig(t.activity, mCustomParameters, "maxObjectTimeShift", mIgnoreActivity); + auto labels = o2::utils::Str::tokenize(getFromExtendedConfig(t.activity, mCustomParameters, "labels"), ',', false, false); if (labels.size() > (nRows * nCols)) { - ILOG(Warning, Support) << "Number of labels larger than nRos*nCols, some labels will not be displayed correctly" << ENDM; + ILOG(Warning, Support) << "Number of labels larger than nRows*nCols, some labels will not be displayed correctly" << ENDM; } mCanvas.reset(); - mCanvas = std::make_unique("BigScreen", "QC Big Screen", nRows, nCols, borderWidth); + mCanvas = std::make_unique("BigScreen", "QC Big Screen", nRows, nCols, borderWidth, foregroundColor, backgroundColor); int index = 0; // add the paves associated to each quality source diff --git a/Modules/Common/src/BigScreenCanvas.cxx b/Modules/Common/src/BigScreenCanvas.cxx index 6e090159c5..75d551e1d0 100644 --- a/Modules/Common/src/BigScreenCanvas.cxx +++ b/Modules/Common/src/BigScreenCanvas.cxx @@ -26,7 +26,8 @@ namespace o2::quality_control_modules::common { struct BigScreenElement { - BigScreenElement(std::string name, int index, float padding, float labelOffset, int borderWidth) + BigScreenElement(std::string name, int index, float padding, float labelOffset, int borderWidth, + int foregroundColor) : mLabel(padding, 1.0 - padding, name.c_str()), mPave(padding, padding, 1.0 - padding, 1.0 - padding - labelOffset, "NB NDC"), mBox(padding, padding, 1.0 - padding, 1.0 - padding - labelOffset), @@ -36,6 +37,7 @@ struct BigScreenElement { mLabel.SetTextAlign(11); mLabel.SetTextSize(0.2); mLabel.SetTextFont(42); + mLabel.SetTextColor(foregroundColor); mPave.SetBorderSize(0); mPave.SetFillColor(kWhite); @@ -45,9 +47,9 @@ struct BigScreenElement { mBox.SetFillStyle(0); } - void DrawInCanvas(TCanvas& c) + void DrawInCanvas(TPad* c) { - c.cd(mPadIndex); + c->cd(mPadIndex); mPave.Draw(); mBox.Draw(); mLabel.Draw(); @@ -59,18 +61,27 @@ struct BigScreenElement { int mPadIndex; }; -BigScreenCanvas::BigScreenCanvas(std::string name, std::string title, int nRows, int nCols, int borderWidth) - : TCanvas(name.c_str(), title.c_str(), 800, 600), mNRows(nRows), mNCols(nCols), mBorderWidth(borderWidth) +BigScreenCanvas::BigScreenCanvas(std::string name, std::string title, int nRows, int nCols, int borderWidth, + int foregroundColor, int backgroundColor) + : TCanvas(name.c_str(), title.c_str(), 800, 600), mNRows(nRows), mNCols(nCols), mBorderWidth(borderWidth), mForegroundColor(foregroundColor), mBackgroundColor(backgroundColor) { mColors[Quality::Null.getName()] = kViolet - 6; mColors[Quality::Bad.getName()] = kRed; mColors[Quality::Medium.getName()] = kOrange - 3; mColors[Quality::Good.getName()] = kGreen + 2; + + // TPad filling the whole canvas and used to draw the background color + mBackgoundPad = std::make_shared((name + "_pad").c_str(), (title + "_pad").c_str(), 0, 0, 1, 1); + mBackgoundPad->SetBorderSize(0); + mBackgoundPad->SetBorderMode(0); + mBackgoundPad->SetMargin(0, 0, 0, 0); + mBackgoundPad->SetFillColor(mBackgroundColor); + mBackgoundPad->Draw(); } void BigScreenCanvas::addBox(std::string boxName, int index) { - mBoxes[boxName] = std::make_shared(boxName, index, mPadding, mLabelOffset, mBorderWidth); + mBoxes[boxName] = std::make_shared(boxName, index, mPadding, mLabelOffset, mBorderWidth, mForegroundColor); } void BigScreenCanvas::setText(std::string boxName, int color, std::string text) @@ -95,11 +106,17 @@ void BigScreenCanvas::setQuality(std::string boxName, Quality quality) void BigScreenCanvas::update() { - Clear(); - Divide(mNCols, mNRows); + mBackgoundPad->Clear(); + mBackgoundPad->Divide(mNCols, mNRows, 0, 0); + + // set the sub-pads as fully transparent to show the color of the main backgound pad + for (int padIndex = 1; padIndex <= (mNCols * mNRows); padIndex++) { + mBackgoundPad->cd(padIndex); + gPad->SetFillStyle(4000); + } for (auto& [key, box] : mBoxes) { - box->DrawInCanvas(*this); + box->DrawInCanvas(mBackgoundPad.get()); } } diff --git a/doc/PostProcessing.md b/doc/PostProcessing.md index 677a91a165..99e89ffb11 100644 --- a/doc/PostProcessing.md +++ b/doc/PostProcessing.md @@ -890,6 +890,8 @@ The system names are displayed above each box, while the quality flag is display In addition, the boxes are filled with a grey color is the corresponding QualityObjects cannot be retrieved or are too old. +The color of the canvas background and of the detector labels can be customized with the `"foregroundColor"` and `"backgroundColor"` parameters. They accept interger values corresponding to the indexes of the [default ROOT colors](https://root.cern.ch/doc/master/classTColor.html#C01) or the indexes defined in the [color wheel](https://root.cern.ch/doc/master/classTColor.html#C02). The example below shows a color combination with white text over a dark gray background. + The task is configured as follows: ```json { @@ -909,6 +911,9 @@ The task is configured as follows: "nRows": "4", "nCols": "5", "borderWidth": "1", + "": "white text over dark gray background", + "foregroundColor": "0", + "backgroundColor": "923", "maxObjectTimeShift": "10000", "ignoreActivity": "0", "labels": "CPV,EMC,FDD,FT0,FV0,HMP,ITS,MCH,MFT,MID,PHS,TPC,TOF,TRD,,TRK,MTK,VTX,PID"