From 68b28661310bf3ce3767df98b07014590367e5aa Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 14:46:00 +0100 Subject: [PATCH 01/15] [colors] move pixel methods to TVirtualX These methods using gVirtualX for pixel -> rgb and rgb -> pixel conversion In ROOT7 all gVirtualX - related methods need to be removed from Core libraries --- core/base/inc/TVirtualX.h | 8 +++ core/base/src/TColor.cxx | 87 ++++++++-------------------- core/base/src/TVirtualX.cxx | 111 ++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 62 deletions(-) diff --git a/core/base/inc/TVirtualX.h b/core/base/inc/TVirtualX.h index 895e3e8f81a67..8ee5c78624748 100644 --- a/core/base/inc/TVirtualX.h +++ b/core/base/inc/TVirtualX.h @@ -371,6 +371,14 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe virtual void MapGCFont(GContext_t, FontStruct_t); + //---- Colors and pixels ----- + static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b); + static ULong_t RGB2Pixel(Float_t r, Float_t g, Float_t b); + static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b); + static void Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b); + static TString PixelAsHexString(ULong_t pixel); + static ULong_t Number2Pixel(Int_t ci); + static TVirtualX *&Instance(); ClassDefOverride(TVirtualX,0) //ABC defining a generic interface to graphics system diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index c2dbfc9f4e197..e4f05c7b38fec 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -2451,103 +2451,68 @@ void TColor::ListColors(Int_t ci, Int_t nb, Bool_t showEmpty) } //////////////////////////////////////////////////////////////////////////////// -/// Static method that given a color index number, returns the corresponding +/// @deprecated Use TVirtualX::Number2Pixel instead +/// +/// @brief Static method that given a color index number, returns the corresponding /// pixel value. This pixel value can be used in the GUI classes. This call /// does not work in batch mode since it needs to communicate with the /// graphics system. ULong_t TColor::Number2Pixel(Int_t ci) { - TColor::InitializeColors(); - TColor *color = gROOT->GetColor(ci); - if (color) - return color->GetPixel(); - else - ::Warning("TColor::Number2Pixel", "color with index %d not defined", ci); - - return 0; + return TVirtualX::Number2Pixel(ci); } //////////////////////////////////////////////////////////////////////////////// -/// Convert r,g,b to graphics system dependent pixel value. +/// @deprecated Use TVirtualX::RGB2Pixel instead +/// +/// @brief Convert r,g,b to graphics system dependent pixel value. /// The r,g,b triplet must be [0,1]. ULong_t TColor::RGB2Pixel(Float_t r, Float_t g, Float_t b) { - if (r < 0) r = 0; - if (g < 0) g = 0; - if (b < 0) b = 0; - if (r > 1) r = 1; - if (g > 1) g = 1; - if (b > 1) b = 1; - - ColorStruct_t color; - color.fRed = UShort_t(r * 65535); - color.fGreen = UShort_t(g * 65535); - color.fBlue = UShort_t(b * 65535); - color.fMask = kDoRed | kDoGreen | kDoBlue; - gVirtualX->AllocColor(gVirtualX->GetColormap(), color); - return color.fPixel; + return TVirtualX::RGB2Pixel(r, g, b); } //////////////////////////////////////////////////////////////////////////////// -/// Convert r,g,b to graphics system dependent pixel value. +/// @deprecated Use TVirtualX::RGB2Pixel instead +/// +/// @brief Convert r,g,b to graphics system dependent pixel value. /// The r,g,b triplet must be [0,255]. ULong_t TColor::RGB2Pixel(Int_t r, Int_t g, Int_t b) { - if (r < 0) r = 0; - if (g < 0) g = 0; - if (b < 0) b = 0; - if (r > 255) r = 255; - if (g > 255) g = 255; - if (b > 255) b = 255; - - ColorStruct_t color; - color.fRed = UShort_t(r * 256); // 65536/256 - color.fGreen = UShort_t(g * 256); - color.fBlue = UShort_t(b * 256); - color.fMask = kDoRed | kDoGreen | kDoBlue; - gVirtualX->AllocColor(gVirtualX->GetColormap(), color); - return color.fPixel; + return TVirtualX::RGB2Pixel(r, g, b); } //////////////////////////////////////////////////////////////////////////////// -/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// @deprecated Use TVirtualX::Pixel2RGB instead +/// +/// @brief Convert machine dependent pixel value (obtained via RGB2Pixel or /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet. /// The r,g,b triplet will be [0,1]. void TColor::Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b) { - ColorStruct_t color; - color.fPixel = pixel; - gVirtualX->QueryColor(gVirtualX->GetColormap(), color); - r = (Float_t)color.fRed / 65535.0f; - g = (Float_t)color.fGreen / 65535.0f; - b = (Float_t)color.fBlue / 65535.0f; + TVirtualX::Pixel2RGB(pixel, r, g, b); } //////////////////////////////////////////////////////////////////////////////// -/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// @deprecated Use TVirtualX::Pixel2RGB instead +/// +/// @brief Convert machine dependent pixel value (obtained via RGB2Pixel or /// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet. /// The r,g,b triplet will be [0,255]. void TColor::Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b) { - ColorStruct_t color; - color.fPixel = pixel; - gVirtualX->QueryColor(gVirtualX->GetColormap(), color); - // color is between 0 and 65535 inclusive. - // We need to move it to the 0 to 255 range (inclusive). - // So we need to resample the 65536 values into 256 indices. - // This would mean equal blocks of 256 high-res values per color index. - r = color.fRed / 256; - g = color.fGreen / 256; - b = color.fBlue / 256; + TVirtualX::Pixel2RGB(pixel, r, g, b); } //////////////////////////////////////////////////////////////////////////////// -/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// @deprecated Use TVirtualX::PixelAsHexString instead +/// +/// @brief Convert machine dependent pixel value (obtained via RGB2Pixel or /// via Number2Pixel() or via TColor::GetPixel()) to a hexadecimal string. /// This string can be directly passed to, for example, /// TGClient::GetColorByName(). String will be reused so copy immediately @@ -2556,10 +2521,8 @@ void TColor::Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b) const char *TColor::PixelAsHexString(ULong_t pixel) { static TString tempbuf; - Int_t r, g, b; - Pixel2RGB(pixel, r, g, b); - tempbuf.Form("#%02x%02x%02x", r, g, b); - return tempbuf; + tempbuf = TVirtualX::PixelAsHexString(pixel); + return tempbuf.Data(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/core/base/src/TVirtualX.cxx b/core/base/src/TVirtualX.cxx index 6cb34fbc06e5d..7197063dd0fc3 100644 --- a/core/base/src/TVirtualX.cxx +++ b/core/base/src/TVirtualX.cxx @@ -29,6 +29,9 @@ An instance of TVirtualX itself defines a batch interface to the graphics system #include "TVirtualX.h" #include "TString.h" #include "TPoint.h" +#include "TColor.h" +#include "TError.h" +#include "TROOT.h" Atom_t gWM_DELETE_WINDOW; @@ -2738,3 +2741,111 @@ void TVirtualX::MapGCFont(GContext_t, FontStruct_t) } +//////////////////////////////////////////////////////////////////////////////// +/// Convert r,g,b to graphics system dependent pixel value. +/// The r,g,b triplet must be [0,1]. + +ULong_t TVirtualX::RGB2Pixel(Float_t r, Float_t g, Float_t b) +{ + if (r < 0) r = 0; + if (g < 0) g = 0; + if (b < 0) b = 0; + if (r > 1) r = 1; + if (g > 1) g = 1; + if (b > 1) b = 1; + + ColorStruct_t color; + color.fRed = UShort_t(r * 65535); + color.fGreen = UShort_t(g * 65535); + color.fBlue = UShort_t(b * 65535); + color.fMask = kDoRed | kDoGreen | kDoBlue; + gVirtualX->AllocColor(gVirtualX->GetColormap(), color); + return color.fPixel; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Convert r,g,b to graphics system dependent pixel value. +/// The r,g,b triplet must be [0,255]. + +ULong_t TVirtualX::RGB2Pixel(Int_t r, Int_t g, Int_t b) +{ + if (r < 0) r = 0; + if (g < 0) g = 0; + if (b < 0) b = 0; + if (r > 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + + ColorStruct_t color; + color.fRed = UShort_t(r * 256); // 65536/256 + color.fGreen = UShort_t(g * 256); + color.fBlue = UShort_t(b * 256); + color.fMask = kDoRed | kDoGreen | kDoBlue; + gVirtualX->AllocColor(gVirtualX->GetColormap(), color); + return color.fPixel; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet. +/// The r,g,b triplet will be [0,1]. + +void TVirtualX::Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b) +{ + ColorStruct_t color; + color.fPixel = pixel; + gVirtualX->QueryColor(gVirtualX->GetColormap(), color); + r = (Float_t)color.fRed / 65535.0f; + g = (Float_t)color.fGreen / 65535.0f; + b = (Float_t)color.fBlue / 65535.0f; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// via Number2Pixel() or via TColor::GetPixel()) to r,g,b triplet. +/// The r,g,b triplet will be [0,255]. + +void TVirtualX::Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b) +{ + ColorStruct_t color; + color.fPixel = pixel; + gVirtualX->QueryColor(gVirtualX->GetColormap(), color); + // color is between 0 and 65535 inclusive. + // We need to move it to the 0 to 255 range (inclusive). + // So we need to resample the 65536 values into 256 indices. + // This would mean equal blocks of 256 high-res values per color index. + r = color.fRed / 256; + g = color.fGreen / 256; + b = color.fBlue / 256; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Convert machine dependent pixel value (obtained via RGB2Pixel or +/// via Number2Pixel() or via TColor::GetPixel()) to a hexadecimal string. +/// This string can be directly passed to, for example, +/// TGClient::GetColorByName(). String will be reused so copy immediately +/// if needed. + +TString TVirtualX::PixelAsHexString(ULong_t pixel) +{ + Int_t r, g, b; + Pixel2RGB(pixel, r, g, b); + return TString::Format("#%02x%02x%02x", r, g, b); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Static method that given a color index number, returns the corresponding +/// pixel value. This pixel value can be used in the GUI classes. This call +/// does not work in batch mode since it needs to communicate with the +/// graphics system. + +ULong_t TVirtualX::Number2Pixel(Int_t ci) +{ + TColor::InitializeColors(); + auto color = gROOT->GetColor(ci); + if (color) + return color->GetPixel(); + + ::Warning("TVirtualX::Number2Pixel", "color with index %d not defined", ci); + return 0; +} From 6aafdc61ee9df716692736398124a326ab85ffe7 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 14:55:25 +0100 Subject: [PATCH 02/15] [gui] use new TVirtualX pixels methods instead one from TColor Methods from TColor will be deprecated and removed in ROOT7 --- graf2d/asimage/src/TASImage.cxx | 2 +- graf3d/gl/src/TGLOverlayButton.cxx | 7 +++-- gui/gui/src/TGColorDialog.cxx | 36 +++++++++++------------ gui/gui/src/TGColorSelect.cxx | 4 +-- gui/gui/src/TGDockableFrame.cxx | 4 +-- gui/gui/src/TGFrame.cxx | 6 ++-- gui/gui/src/TGGC.cxx | 6 ++-- gui/gui/src/TGProgressBar.cxx | 2 +- gui/gui/src/TGTable.cxx | 13 ++++---- gui/guibuilder/src/TGuiBldDragManager.cxx | 2 +- gui/guibuilder/src/TRootGuiBuilder.cxx | 6 ++-- test/guitest.cxx | 2 +- tutorials/visualisation/gui/guitest.C | 2 +- 13 files changed, 47 insertions(+), 45 deletions(-) diff --git a/graf2d/asimage/src/TASImage.cxx b/graf2d/asimage/src/TASImage.cxx index ff78bf7c7196b..e8ba418056508 100644 --- a/graf2d/asimage/src/TASImage.cxx +++ b/graf2d/asimage/src/TASImage.cxx @@ -2445,7 +2445,7 @@ TArrayL *TASImage::GetPixels(Int_t x, Int_t y, UInt_t width, UInt_t height) r = (Int_t)imdec->buffer.red[i]; g = (Int_t)imdec->buffer.green[i]; b = (Int_t)imdec->buffer.blue[i]; - p = (Long_t)TColor::RGB2Pixel(r, g, b); + p = (Long_t)TVirtualX::RGB2Pixel(r, g, b); } ret->AddAt(p, k*width + i); } diff --git a/graf3d/gl/src/TGLOverlayButton.cxx b/graf3d/gl/src/TGLOverlayButton.cxx index 92fffd76fe3d8..12bcf531d44f2 100644 --- a/graf3d/gl/src/TGLOverlayButton.cxx +++ b/graf3d/gl/src/TGLOverlayButton.cxx @@ -12,6 +12,7 @@ #include "TGLOverlayButton.h" #include "TColor.h" #include "TMath.h" +#include "TVirtualX.h" #include #include @@ -87,7 +88,7 @@ void TGLOverlayButton::Render(TGLRnrCtx& rnrCtx) glPushMatrix(); glTranslatef(fPosX, offset+fPosY, 0); // First the border, same color as text - TColor::Pixel2RGB(fTextColor, r, g, b); + TVirtualX::Pixel2RGB(fTextColor, r, g, b); (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha):TGLUtil::Color4f(r, g, b, fNormAlpha); TGLUtil::LineWidth(1); glBegin(GL_LINE_LOOP); @@ -98,7 +99,7 @@ void TGLOverlayButton::Render(TGLRnrCtx& rnrCtx) glEnd(); // then the button itself, with its own color // decrease a bit the highlight, to avoid bad effects... - TColor::Pixel2RGB(fBackColor, r, g, b); + TVirtualX::Pixel2RGB(fBackColor, r, g, b); (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha * 0.8):TGLUtil::Color4f(r, g, b, fNormAlpha); glBegin(GL_QUADS); glVertex2f(0.0, 0.0); @@ -114,7 +115,7 @@ void TGLOverlayButton::Render(TGLRnrCtx& rnrCtx) rnrCtx.RegisterFontNoScale(TMath::Nint(fHeight*0.8), "arial", TGLFont::kPixmap, fFont); fFont.PreRender(kFALSE); - TColor::Pixel2RGB(fTextColor, r, g, b); + TVirtualX::Pixel2RGB(fTextColor, r, g, b); (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha):TGLUtil::Color4f(r, g, b, fNormAlpha); glPushMatrix(); glTranslatef(fPosX+(fWidth/2.0), offset+fPosY+(fHeight/2.0), 0); diff --git a/gui/gui/src/TGColorDialog.cxx b/gui/gui/src/TGColorDialog.cxx index 1191601025816..218fe9b4b92c1 100644 --- a/gui/gui/src/TGColorDialog.cxx +++ b/gui/gui/src/TGColorDialog.cxx @@ -143,7 +143,7 @@ TGColorPalette::TGColorPalette(const TGWindow *p, Int_t cols, Int_t rows, Int_t fPixels = new ULong_t[fRows * fCols]; for (Int_t i = 0; i < fRows * fCols; ++i) { - fPixels[i] = TColor::RGB2Pixel(255, 255, 255); + fPixels[i] = TVirtualX::RGB2Pixel(255, 255, 255); } gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier, @@ -327,7 +327,7 @@ ULong_t TGColorPalette::GetCurrentColor() const if (fCx >= 0 && fCy >= 0) return GetColorByIndex(fCy * fCols + fCx); else - return TColor::RGB2Pixel(0, 0, 0); + return TVirtualX::RGB2Pixel(0, 0, 0); } //////////////////////////////////////////////////////////////////////////////// @@ -672,7 +672,7 @@ void TGColorPick::CreateDitheredImage(Pixmap_t image, Int_t which) } else if (which == kIMG_L) { - TColor::Pixel2RGB(fCurrentColor, r, g, b); + TVirtualX::Pixel2RGB(fCurrentColor, r, g, b); TColor::RGB2HLS(r, g, b, h, l, s); Int_t ll = (ih - y) * 255 / ih; @@ -805,7 +805,7 @@ void TGColorPick::InitImages() TColor::HLS2RGB(h, l, s, r, g, b); - ULong_t pixel = TColor::RGB2Pixel(r, g, b); + ULong_t pixel = TVirtualX::RGB2Pixel(r, g, b); gVirtualX->PutPixel(fHSimage, x, y, pixel); } } @@ -835,14 +835,14 @@ void TGColorPick::SetSliderColor() for (Int_t y = 0; y < height; ++y) { - TColor::Pixel2RGB(fCurrentColor, r, g, b); + TVirtualX::Pixel2RGB(fCurrentColor, r, g, b); TColor::RGB2HLS(r, g, b, h, l, s); l = (height - y) * 255 / height; TColor::HLS2RGB(h, l, s, r, g, b); - ULong_t pixel = TColor::RGB2Pixel(r, g, b); + ULong_t pixel = TVirtualX::RGB2Pixel(r, g, b); for (Int_t x = 0; x < width; ++x) { gVirtualX->PutPixel(fLimage, x, y, pixel); @@ -868,7 +868,7 @@ void TGColorPick::SetColor(ULong_t color) fCurrentColor = color; - TColor::Pixel2RGB(fCurrentColor, r, g, b); + TVirtualX::Pixel2RGB(fCurrentColor, r, g, b); TColor::RGB2HLS(r, g, b, h, l, s); SetHScursor(h * (Int_t)width / 256, (255 - s) * (Int_t)height / 256); @@ -898,7 +898,7 @@ void TGColorPick::UpdateCurrentColor() s = Int_t((sheight - fCy) * 255 / sheight); TColor::HLS2RGB(h, l, s, r, g, b); - fCurrentColor = TColor::RGB2Pixel(r, g, b); + fCurrentColor = TVirtualX::RGB2Pixel(r, g, b); } //////////////////////////////////////////////////////////////////////////////// @@ -1201,7 +1201,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, b = 222./255; // Gui Builder background - Pixel_t pixel = TColor::RGB2Pixel(r, g, b); + Pixel_t pixel = TVirtualX::RGB2Pixel(r, g, b); fPalette->SetColor(46, pixel); r = 230./255; @@ -1209,7 +1209,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, b = 230./255; // a la MAC background - pixel = TColor::RGB2Pixel(r, g, b); + pixel = TVirtualX::RGB2Pixel(r, g, b); fPalette->SetColor(45, pixel); r = 172./255; @@ -1217,7 +1217,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, b = 205./255; // a la CDE background - pixel = TColor::RGB2Pixel(r, g, b); + pixel = TVirtualX::RGB2Pixel(r, g, b); fPalette->SetColor(44, pixel); r = 205./255; @@ -1225,7 +1225,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, b = 175./255; // a la FOX background - pixel = TColor::RGB2Pixel(r, g, b); + pixel = TVirtualX::RGB2Pixel(r, g, b); fPalette->SetColor(43, pixel); // custom colors @@ -1239,7 +1239,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, if (gUcolor[0] == 0xff000000) { for (i = 0; i < 24; i++) - gUcolor[i] = TColor::RGB2Pixel(255, 255, 255); + gUcolor[i] = TVirtualX::RGB2Pixel(255, 255, 255); } fCpalette->SetColors(gUcolor); @@ -1415,7 +1415,7 @@ void TGColorDialog::UpdateRGBentries(ULong_t *c) Char_t tmp[20]; Int_t r, g, b; - TColor::Pixel2RGB(*c, r, g, b); + TVirtualX::Pixel2RGB(*c, r, g, b); snprintf(tmp, 20, "%d", r); fRtb->Clear(); @@ -1443,7 +1443,7 @@ void TGColorDialog::UpdateHLSentries(ULong_t *c) Int_t h, l, s; Int_t r, g, b; - TColor::Pixel2RGB(*c, r, g, b); + TVirtualX::Pixel2RGB(*c, r, g, b); TColor::RGB2HLS(r, g, b, h, l, s); snprintf(tmp, 20, "%d", h); @@ -1482,7 +1482,7 @@ Bool_t TGColorDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t / case kCDLG_OK: *fRetc = kMBOk; - *fRetColor = TColor::RGB2Pixel(atoi(fRtb->GetString()), + *fRetColor = TVirtualX::RGB2Pixel(atoi(fRtb->GetString()), atoi(fGtb->GetString()), atoi(fBtb->GetString())); if ((fRetTColor = gROOT->GetColor(TColor::GetColor(*fRetColor)))) { @@ -1560,7 +1560,7 @@ Bool_t TGColorDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t / s = atoi(fStb->GetString()); TColor::HLS2RGB(h, l, s, r, g, b); - color = TColor::RGB2Pixel(r, g, b); + color = TVirtualX::RGB2Pixel(r, g, b); fSample->SetBackgroundColor(color); ColorSelected(color); gClient->NeedRedraw(fSample); @@ -1572,7 +1572,7 @@ Bool_t TGColorDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t / case kCDLG_RTE: case kCDLG_GTE: case kCDLG_BTE: - color = TColor::RGB2Pixel(atoi(fRtb->GetString()), + color = TVirtualX::RGB2Pixel(atoi(fRtb->GetString()), atoi(fGtb->GetString()), atoi(fBtb->GetString())); fSample->SetBackgroundColor(color); diff --git a/gui/gui/src/TGColorSelect.cxx b/gui/gui/src/TGColorSelect.cxx index a708aeb1d871e..1ff128639095a 100644 --- a/gui/gui/src/TGColorSelect.cxx +++ b/gui/gui/src/TGColorSelect.cxx @@ -677,8 +677,8 @@ void TGColorSelect::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/) TString cvar = TString::Format("ColPar%d",nn++); ULong_t color = GetColor(); - const char *colorname = TColor::PixelAsHexString(color); - gClient->GetColorByName(colorname, color); + TString colorname = TVirtualX::PixelAsHexString(color); + gClient->GetColorByName(colorname.Data(), color); out << "\n // color select widget\n"; out << " ULong_t " << cvar << ";\n"; diff --git a/gui/gui/src/TGDockableFrame.cxx b/gui/gui/src/TGDockableFrame.cxx index 3adf3af31d2a7..f23ad41eb0792 100644 --- a/gui/gui/src/TGDockableFrame.cxx +++ b/gui/gui/src/TGDockableFrame.cxx @@ -60,11 +60,11 @@ TGDockButton::TGDockButton(const TGCompositeFrame *p, int id) : fNormBg = fBackground; Float_t r, g, b, h, l, s; - TColor::Pixel2RGB(fNormBg, r, g, b); + TVirtualX::Pixel2RGB(fNormBg, r, g, b); TColor::RGB2HLS(r, g, b, h, l, s); l = l + (1. - l) * 45. / 100.; TColor::HLS2RGB(h, l, s, r, g, b); - fHiBg = TColor::RGB2Pixel(r, g, b); + fHiBg = TVirtualX::RGB2Pixel(r, g, b); AddInput(kEnterWindowMask | kLeaveWindowMask); SetWindowName(); diff --git a/gui/gui/src/TGFrame.cxx b/gui/gui/src/TGFrame.cxx index 04fdb1a84bd8a..8ea3060c9e689 100644 --- a/gui/gui/src/TGFrame.cxx +++ b/gui/gui/src/TGFrame.cxx @@ -1370,11 +1370,11 @@ Bool_t TGCompositeFrame::HandleDragEnter(TGFrame *) } Float_t r, g, b; - TColor::Pixel2RGB(fBackground, r, g, b); + TVirtualX::Pixel2RGB(fBackground, r, g, b); r *= 1.12; g *= 1.13; b *= 1.12; - Pixel_t back = TColor::RGB2Pixel(r, g, b); + Pixel_t back = TVirtualX::RGB2Pixel(r, g, b); gVirtualX->SetWindowBackground(fId, back); DoRedraw(); return kTRUE; @@ -2481,7 +2481,7 @@ void TGFrame::SaveUserColor(std::ostream &out, Option_t *option) else ucolor = GetBackground(); if ((ucolor != fgUserColor) || (ucolor == GetWhitePixel())) { - const char *ucolorname = TColor::PixelAsHexString(ucolor); + auto ucolorname = TVirtualX::PixelAsHexString(ucolor); out << " gClient->GetColorByName(\"" << ucolorname << "\", ucolor);\n"; fgUserColor = ucolor; } diff --git a/gui/gui/src/TGGC.cxx b/gui/gui/src/TGGC.cxx index 7d5b52071a2a9..cf946a07d50a0 100644 --- a/gui/gui/src/TGGC.cxx +++ b/gui/gui/src/TGGC.cxx @@ -626,7 +626,7 @@ void TGGC::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/) Mask_t fmask = GetMask(); TString valname = TString::Format("val%s", option); - const char *colorname; + TString colorname; ULong_t color; out << " // graphics context changes\n"; @@ -697,12 +697,12 @@ void TGGC::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/) break; case kGCForeground: color = GetForeground(); - colorname = TColor::PixelAsHexString(color); + colorname = TVirtualX::PixelAsHexString(color); out << " gClient->GetColorByName(\"" << colorname << "\", " << valname << ".fForeground);\n"; break; case kGCBackground: color = GetBackground(); - colorname = TColor::PixelAsHexString(color); + colorname = TVirtualX::PixelAsHexString(color); out << " gClient->GetColorByName(\"" << colorname << "\", " << valname << ".fBackground);\n"; break; case kGCLineWidth: diff --git a/gui/gui/src/TGProgressBar.cxx b/gui/gui/src/TGProgressBar.cxx index d1b46ee8a7835..f90772fab2ce2 100644 --- a/gui/gui/src/TGProgressBar.cxx +++ b/gui/gui/src/TGProgressBar.cxx @@ -413,7 +413,7 @@ void TGProgressBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/) } if (fBarColorGC.GetForeground() != GetDefaultSelectedBackground()) { - out << " " << GetName() << "->SetBarColor(\"" << TColor::PixelAsHexString(fBarColorGC.GetForeground()) + out << " " << GetName() << "->SetBarColor(\"" << TVirtualX::PixelAsHexString(fBarColorGC.GetForeground()) << "\");\n"; } diff --git a/gui/gui/src/TGTable.cxx b/gui/gui/src/TGTable.cxx index a32559e79f2bb..cf9802508be70 100644 --- a/gui/gui/src/TGTable.cxx +++ b/gui/gui/src/TGTable.cxx @@ -26,6 +26,7 @@ #include "TGTextEntry.h" #include "TGLabel.h" #include "TColor.h" +#include "TVirtualX.h" @@ -168,9 +169,9 @@ TGTable::TGTable(const TGWindow *p, Int_t id, TVirtualTableInterface *interface, // To be done: GetBackground colors for .rootrc SetBackgroundColor(GetWhitePixel()); - fEvenRowBackground = TColor::RGB2Pixel(204, 255, 204); - fOddRowBackground = TColor::RGB2Pixel(255, 255, 255); - fHeaderBackground = TColor::RGB2Pixel(204, 204, 255); + fEvenRowBackground = TVirtualX::RGB2Pixel(204, 255, 204); + fOddRowBackground = TVirtualX::RGB2Pixel(255, 255, 255); + fHeaderBackground = TVirtualX::RGB2Pixel(204, 204, 255); fCurrentRange->fXbr = ncolumns; fCurrentRange->fYbr = nrows; @@ -1307,9 +1308,9 @@ void TGTable::SetHeaderBackground(Pixel_t pixel) void TGTable::SetDefaultColors() { - SetEvenRowBackground(TColor::RGB2Pixel(204, 255, 204)); - SetOddRowBackground(TColor::RGB2Pixel(255, 255, 255)); - SetHeaderBackground(TColor::RGB2Pixel(204, 204, 255)); + SetEvenRowBackground(TVirtualX::RGB2Pixel(204, 255, 204)); + SetOddRowBackground(TVirtualX::RGB2Pixel(255, 255, 255)); + SetHeaderBackground(TVirtualX::RGB2Pixel(204, 204, 255)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/gui/guibuilder/src/TGuiBldDragManager.cxx b/gui/guibuilder/src/TGuiBldDragManager.cxx index ca03f64174751..914c2e7c7baad 100644 --- a/gui/guibuilder/src/TGuiBldDragManager.cxx +++ b/gui/guibuilder/src/TGuiBldDragManager.cxx @@ -615,7 +615,7 @@ void TGuiBldDragManagerGrid::InitBgnd() g = 232./255; b = 226./255; - fgPixel = TColor::RGB2Pixel(r, g, b); + fgPixel = TVirtualX::RGB2Pixel(r, g, b); fgBgnd->SetForeground(fgPixel); } diff --git a/gui/guibuilder/src/TRootGuiBuilder.cxx b/gui/guibuilder/src/TRootGuiBuilder.cxx index cef94f8af2d71..6f2ce0463a766 100644 --- a/gui/guibuilder/src/TRootGuiBuilder.cxx +++ b/gui/guibuilder/src/TRootGuiBuilder.cxx @@ -2167,7 +2167,7 @@ ULong_t TRootGuiBuilder::GetBgnd() g = 232./255; b = 222./255; - gPixel = TColor::RGB2Pixel(r, g, b); + gPixel = TVirtualX::RGB2Pixel(r, g, b); return gPixel; } @@ -2225,7 +2225,7 @@ ULong_t TRootGuiBuilder::GetPopupBgnd() g = 250./255; b = 250./255; - gPixel = TColor::RGB2Pixel(r, g, b); + gPixel = TVirtualX::RGB2Pixel(r, g, b); return gPixel; } @@ -2263,7 +2263,7 @@ ULong_t TRootGuiBuilder::GetPopupHlght() g = 120./255; b = 222./255; - gPixel = TColor::RGB2Pixel(r, g, b); + gPixel = TVirtualX::RGB2Pixel(r, g, b); return gPixel; } diff --git a/test/guitest.cxx b/test/guitest.cxx index c24728e753943..cb0f5e2a06251 100644 --- a/test/guitest.cxx +++ b/test/guitest.cxx @@ -635,7 +635,7 @@ TestMainFrame::TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h) // Fill canvas with 256 colored frames for (int i=0; i < 256; ++i) fCanvasWindow->AddFrame(new TGFrame(fCanvasWindow->GetContainer(), - 32, 32, 0, TColor::RGB2Pixel(0,0,(i+1)&255)), + 32, 32, 0, TVirtualX::RGB2Pixel(0,0,(i+1)&255)), new TGLayoutHints(kLHintsExpandY | kLHintsRight)); AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, diff --git a/tutorials/visualisation/gui/guitest.C b/tutorials/visualisation/gui/guitest.C index 33a71507152ff..4c775e658f112 100644 --- a/tutorials/visualisation/gui/guitest.C +++ b/tutorials/visualisation/gui/guitest.C @@ -679,7 +679,7 @@ TestMainFrame::TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h) // Fill canvas with 256 colored frames for (int i = 0; i < 256; ++i) fCanvasWindow->AddFrame( - new TGFrame(fCanvasWindow->GetContainer(), 32, 32, 0, TColor::RGB2Pixel(0, 0, (i + 1) & 255)), + new TGFrame(fCanvasWindow->GetContainer(), 32, 32, 0, TVirtualX::RGB2Pixel(0, 0, (i + 1) & 255)), new TGLayoutHints(kLHintsExpandY | kLHintsRight)); fMain->AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2)); From 5097b012199cdff8493a9ea5fa18f4c9ab4d1253 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 15:30:16 +0100 Subject: [PATCH 03/15] [gui] use TVirtualX::Number2Pixel instead of TColor method Pixels are only relevant for the TVirtualX instances - therefore change makes it clear where TVirtualX is used --- graf3d/eve/src/TEveBrowser.cxx | 8 +-- graf3d/eve/src/TEveCaloLegoEditor.cxx | 7 +-- graf3d/eve/src/TEveCaloVizEditor.cxx | 3 +- graf3d/eve/src/TEveElementEditor.cxx | 3 +- graf3d/eve/src/TEveRGBAPaletteEditor.cxx | 7 +-- graf3d/eve/src/TEveShapeEditor.cxx | 3 +- graf3d/gl/src/TGL5DDataSetEditor.cxx | 3 +- graf3d/gl/src/TGLViewerEditor.cxx | 3 +- gui/fitpanel/src/TAdvancedGraphicsDialog.cxx | 5 +- gui/ged/src/TAttFillEditor.cxx | 3 +- gui/ged/src/TAttLineEditor.cxx | 3 +- gui/ged/src/TAttMarkerEditor.cxx | 3 +- gui/ged/src/TAttTextEditor.cxx | 3 +- gui/ged/src/TAxisEditor.cxx | 7 +-- gui/ged/src/TH2Editor.cxx | 2 +- gui/ged/src/TPieEditor.cxx | 2 +- gui/ged/src/TStyleManager.cxx | 52 ++++++++++---------- gui/gui/src/TGColorDialog.cxx | 2 +- gui/gui/src/TGColorSelect.cxx | 34 ++++++------- gui/gui/src/TGListTree.cxx | 2 +- gui/guibuilder/src/TGuiBldDragManager.cxx | 4 +- gui/guibuilder/src/TRootGuiBuilder.cxx | 4 +- tree/treeviewer/src/TParallelCoordEditor.cxx | 11 +++-- tree/treeviewer/src/TSpiderEditor.cxx | 5 +- 24 files changed, 97 insertions(+), 82 deletions(-) diff --git a/graf3d/eve/src/TEveBrowser.cxx b/graf3d/eve/src/TEveBrowser.cxx index 52dcb83367dba..9632fc2d65c28 100644 --- a/graf3d/eve/src/TEveBrowser.cxx +++ b/graf3d/eve/src/TEveBrowser.cxx @@ -68,10 +68,10 @@ Pixel_t TEveListTreeItem::GetActiveColor() const { switch (fElement->GetSelectedLevel()) { - case 1: return TColor::Number2Pixel(kBlue - 2); - case 2: return TColor::Number2Pixel(kBlue - 6); - case 3: return TColor::Number2Pixel(kCyan - 2); - case 4: return TColor::Number2Pixel(kCyan - 6); + case 1: return TVirtualX::Number2Pixel(kBlue - 2); + case 2: return TVirtualX::Number2Pixel(kBlue - 6); + case 3: return TVirtualX::Number2Pixel(kCyan - 2); + case 4: return TVirtualX::Number2Pixel(kCyan - 6); } return TGFrame::GetDefaultSelectedBackground(); } diff --git a/graf3d/eve/src/TEveCaloLegoEditor.cxx b/graf3d/eve/src/TEveCaloLegoEditor.cxx index 4c63bd5caee55..f8be3c9641828 100644 --- a/graf3d/eve/src/TEveCaloLegoEditor.cxx +++ b/graf3d/eve/src/TEveCaloLegoEditor.cxx @@ -15,6 +15,7 @@ #include "TGComboBox.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGColorSelect.h" #include "TGLabel.h" #include "TG3DLine.h" @@ -184,10 +185,10 @@ void TEveCaloLegoEditor::SetModel(TObject* obj) { fM = dynamic_cast(obj); - fGridColor->SetColor(TColor::Number2Pixel(fM->GetGridColor() < 0 ? 0 : fM->GetGridColor()), kFALSE); - fFontColor->SetColor(TColor::Number2Pixel(fM->GetFontColor() < 0 ? 0 : fM->GetFontColor()), kFALSE); + fGridColor->SetColor(TVirtualX::Number2Pixel(fM->GetGridColor() < 0 ? 0 : fM->GetGridColor()), kFALSE); + fFontColor->SetColor(TVirtualX::Number2Pixel(fM->GetFontColor() < 0 ? 0 : fM->GetFontColor()), kFALSE); - fPlaneColor->SetColor(TColor::Number2Pixel(fM->GetPlaneColor()), kFALSE); + fPlaneColor->SetColor(TVirtualX::Number2Pixel(fM->GetPlaneColor()), kFALSE); fTransparency->SetNumber(fM->GetPlaneTransparency()); fCell2DTextMin->SetValue(fM->GetDrawNumberCellPixels()); diff --git a/graf3d/eve/src/TEveCaloVizEditor.cxx b/graf3d/eve/src/TEveCaloVizEditor.cxx index a7cc27dabc189..8faeba0cbb1ef 100644 --- a/graf3d/eve/src/TEveCaloVizEditor.cxx +++ b/graf3d/eve/src/TEveCaloVizEditor.cxx @@ -25,6 +25,7 @@ #include "TG3DLine.h" #include "TGButtonGroup.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGColorSelect.h" #include "TMathBase.h" @@ -209,7 +210,7 @@ void TEveCaloVizEditor::MakeSliceInfo() threshold->GetLabel()->SetText(si.fName); threshold->SetValue(si.fThreshold); - color->SetColor(TColor::Number2Pixel(si.fColor), kFALSE); + color->SetColor(TVirtualX::Number2Pixel(si.fColor), kFALSE); transp->SetNumber(si.fTransparency); if (! fr->IsMapped()) { diff --git a/graf3d/eve/src/TEveElementEditor.cxx b/graf3d/eve/src/TEveElementEditor.cxx index 7f73248216b35..8c29ca04c258f 100644 --- a/graf3d/eve/src/TEveElementEditor.cxx +++ b/graf3d/eve/src/TEveElementEditor.cxx @@ -14,6 +14,7 @@ #include "TEveTransEditor.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGLabel.h" #include "TGNumberEntry.h" @@ -117,7 +118,7 @@ void TEveElementEditor::SetModel(TObject* obj) } if (fRE->CanEditMainColor()) { - fMainColor->SetColor(TColor::Number2Pixel(fRE->GetMainColor()), kFALSE); + fMainColor->SetColor(TVirtualX::Number2Pixel(fRE->GetMainColor()), kFALSE); fMainColor->MapWindow(); } else { fMainColor->UnmapWindow(); diff --git a/graf3d/eve/src/TEveRGBAPaletteEditor.cxx b/graf3d/eve/src/TEveRGBAPaletteEditor.cxx index 2d98557ab3a02..246cb06fd7820 100644 --- a/graf3d/eve/src/TEveRGBAPaletteEditor.cxx +++ b/graf3d/eve/src/TEveRGBAPaletteEditor.cxx @@ -14,6 +14,7 @@ #include "TEveGValuators.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGLabel.h" #include "TGButton.h" @@ -169,11 +170,11 @@ void TEveRGBAPaletteSubEditor::SetModel(TEveRGBAPalette* p) fInterpolate ->SetState(fM->fInterpolate ? kButtonDown : kButtonUp); fShowDefValue ->SetState(fM->fShowDefValue ? kButtonDown : kButtonUp); - fDefaultColor ->SetColor(TColor::Number2Pixel(fM->GetDefaultColor()), kFALSE); + fDefaultColor ->SetColor(TVirtualX::Number2Pixel(fM->GetDefaultColor()), kFALSE); fFixColorRange->SetState(fM->fFixColorRange ? kButtonDown : kButtonUp); - fUnderColor->SetColor(TColor::Number2Pixel(fM->GetUnderColor()), kFALSE); - fOverColor ->SetColor(TColor::Number2Pixel(fM->GetOverColor()), kFALSE); + fUnderColor->SetColor(TVirtualX::Number2Pixel(fM->GetUnderColor()), kFALSE); + fOverColor ->SetColor(TVirtualX::Number2Pixel(fM->GetOverColor()), kFALSE); fUnderflowAction->Select(fM->fUnderflowAction, kFALSE); fOverflowAction ->Select(fM->fOverflowAction, kFALSE); diff --git a/graf3d/eve/src/TEveShapeEditor.cxx b/graf3d/eve/src/TEveShapeEditor.cxx index dc2bfd0cd060c..99aaa24ee5b59 100644 --- a/graf3d/eve/src/TEveShapeEditor.cxx +++ b/graf3d/eve/src/TEveShapeEditor.cxx @@ -13,6 +13,7 @@ #include "TEveShape.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGLabel.h" #include "TGButton.h" @@ -81,7 +82,7 @@ void TEveShapeEditor::SetModel(TObject* obj) fM = dynamic_cast(obj); fLineWidth->SetNumber(fM->fLineWidth); - fLineColor->SetColor(TColor::Number2Pixel(fM->fLineColor), kFALSE); + fLineColor->SetColor(TVirtualX::Number2Pixel(fM->fLineColor), kFALSE); fDrawFrame ->SetState(fM->fDrawFrame ? kButtonDown : kButtonUp); fHighlightFrame->SetState(fM->fHighlightFrame ? kButtonDown : kButtonUp); } diff --git a/graf3d/gl/src/TGL5DDataSetEditor.cxx b/graf3d/gl/src/TGL5DDataSetEditor.cxx index fff75c3cca4b3..7f3ac47fd4b8f 100644 --- a/graf3d/gl/src/TGL5DDataSetEditor.cxx +++ b/graf3d/gl/src/TGL5DDataSetEditor.cxx @@ -21,6 +21,7 @@ #include "TGLabel.h" #include "TString.h" #include "TColor.h" +#include "TVirtualX.h" #include "TAxis.h" #include "TGL5DDataSetEditor.h" @@ -747,7 +748,7 @@ void TGL5DDataSetEditor::SurfaceSelected(Int_t id) surf->fHighlight = fHighlightCheck->IsOn(); //Surface is visible/invisible - check/uncheck. fVisibleCheck->SetOn(!surf->fHide); - fSurfColorSelect->SetColor(TColor::Number2Pixel(surf->fColor), kFALSE); + fSurfColorSelect->SetColor(TVirtualX::Number2Pixel(surf->fColor), kFALSE); fSurfAlphaSlider->SetPosition(surf->fAlpha); if (gPad) diff --git a/graf3d/gl/src/TGLViewerEditor.cxx b/graf3d/gl/src/TGLViewerEditor.cxx index a53ac41e9cf9e..307e5d7fb48bd 100644 --- a/graf3d/gl/src/TGLViewerEditor.cxx +++ b/graf3d/gl/src/TGLViewerEditor.cxx @@ -20,6 +20,7 @@ #include "TG3DLine.h" #include "TGButton.h" #include "TColor.h" +#include "TVirtualX.h" #include "TString.h" #include "TGLabel.h" #include "TGComboBox.h" @@ -194,7 +195,7 @@ void TGLViewerEditor::SetModel(TObject* obj) fClipSet->SetModel(fViewer->GetClipSet()); // style tab - fClearColor->SetColor(TColor::Number2Pixel(fViewer->RnrCtx().ColorSet().Background().GetColorIndex()), kFALSE); + fClearColor->SetColor(TVirtualX::Number2Pixel(fViewer->RnrCtx().ColorSet().Background().GetColorIndex()), kFALSE); fClearColor->Enable(!fViewer->IsUsingDefaultColorSet()); fIgnoreSizesOnUpdate->SetState(fViewer->GetIgnoreSizesOnUpdate() ? kButtonDown : kButtonUp); fResetCamerasOnUpdate->SetState(fViewer->GetResetCamerasOnUpdate() ? kButtonDown : kButtonUp); diff --git a/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx b/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx index 06efbd1aff6a7..88fa74b621815 100644 --- a/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx +++ b/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx @@ -25,6 +25,7 @@ confidence levels. #include "TAxis.h" #include "TVirtualPad.h" #include "TColor.h" +#include "TVirtualX.h" #include "Fit/BinData.h" #include "Math/IParamFunction.h" @@ -186,7 +187,7 @@ void TAdvancedGraphicsDialog::CreateContourFrame() label = new TGLabel(frame, "Fill Colour: "); frame->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0)); - fContourColor = new TGColorSelect(frame, TColor::Number2Pixel(kYellow - 10), kAGD_CONTCOLOR); + fContourColor = new TGColorSelect(frame, TVirtualX::Number2Pixel(kYellow - 10), kAGD_CONTCOLOR); frame->AddFrame(fContourColor, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0)); fContourOver = new TGCheckButton(frame, "Superimpose", kAGD_CONTOVER); @@ -289,7 +290,7 @@ void TAdvancedGraphicsDialog::CreateConfFrame() label = new TGLabel(frame, "Fill Colour: "); frame->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0)); - fConfColor = new TGColorSelect(frame, TColor::Number2Pixel(kYellow - 10), kAGD_CONTCOLOR); + fConfColor = new TGColorSelect(frame, TVirtualX::Number2Pixel(kYellow - 10), kAGD_CONTCOLOR); frame->AddFrame(fConfColor, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0)); fConfFrame->AddFrame(frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5)); diff --git a/gui/ged/src/TAttFillEditor.cxx b/gui/ged/src/TAttFillEditor.cxx index 874fdbc4cd8dd..92235463466a7 100644 --- a/gui/ged/src/TAttFillEditor.cxx +++ b/gui/ged/src/TAttFillEditor.cxx @@ -22,6 +22,7 @@ Implements GUI for editing fill attributes. #include "TGedPatternSelect.h" #include "TGColorSelect.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGLabel.h" #include "TGSlider.h" #include "TGNumberEntry.h" @@ -113,7 +114,7 @@ void TAttFillEditor::SetModel(TObject* obj) fAvoidSignal = kTRUE; Color_t c = fAttFill->GetFillColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fColorSelect->SetColor(p, kFALSE); Style_t s = fAttFill->GetFillStyle(); diff --git a/gui/ged/src/TAttLineEditor.cxx b/gui/ged/src/TAttLineEditor.cxx index 0d898eda1a23d..e827774b78602 100644 --- a/gui/ged/src/TAttLineEditor.cxx +++ b/gui/ged/src/TAttLineEditor.cxx @@ -22,6 +22,7 @@ Implements GUI for editing line attributes. #include "TGColorSelect.h" #include "TGComboBox.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGraph.h" #include "TGLabel.h" #include "TGSlider.h" @@ -131,7 +132,7 @@ void TAttLineEditor::SetModel(TObject* obj) } Color_t c = fAttLine->GetLineColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fColorSelect->SetColor(p); if (fInit) ConnectSignals2Slots(); diff --git a/gui/ged/src/TAttMarkerEditor.cxx b/gui/ged/src/TAttMarkerEditor.cxx index ec2de0c65b408..fbbe502fdab20 100644 --- a/gui/ged/src/TAttMarkerEditor.cxx +++ b/gui/ged/src/TAttMarkerEditor.cxx @@ -24,6 +24,7 @@ Implements GUI for editing marker attributes. #include "TGColorSelect.h" #include "TGNumberEntry.h" #include "TColor.h" +#include "TVirtualX.h" #include "TGLabel.h" #include "TGSlider.h" #include "TCanvas.h" @@ -141,7 +142,7 @@ void TAttMarkerEditor::SetModel(TObject* obj) fMarkerType->SetMarkerStyle(marker); Color_t c = fAttMarker->GetMarkerColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fColorSelect->SetColor(p); if (fInit) ConnectSignals2Slots(); diff --git a/gui/ged/src/TAttTextEditor.cxx b/gui/ged/src/TAttTextEditor.cxx index 475e10363b48d..c711e972872a9 100644 --- a/gui/ged/src/TAttTextEditor.cxx +++ b/gui/ged/src/TAttTextEditor.cxx @@ -24,6 +24,7 @@ Implements GUI for editing text attributes. #include "TGColorSelect.h" #include "TGComboBox.h" #include "TColor.h" +#include "TVirtualX.h" #include "TPaveLabel.h" #include "TGLabel.h" #include "TGSlider.h" @@ -144,7 +145,7 @@ void TAttTextEditor::SetModel(TObject* obj) fAlignCombo->Select(fAttText->GetTextAlign(), kFALSE); Color_t c = fAttText->GetTextColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fColorSelect->SetColor(p, kFALSE); if (fInit) ConnectSignals2Slots(); diff --git a/gui/ged/src/TAxisEditor.cxx b/gui/ged/src/TAxisEditor.cxx index 6dd616f1b1cef..8757c20ddb90b 100644 --- a/gui/ged/src/TAxisEditor.cxx +++ b/gui/ged/src/TAxisEditor.cxx @@ -41,6 +41,7 @@ Implements GUI for axis attributes. #include "TGLabel.h" #include "TColor.h" #include "TVirtualPad.h" +#include "TVirtualX.h" #include "TStyle.h" @@ -278,7 +279,7 @@ void TAxisEditor::SetModel(TObject* obj) fAvoidSignal = kTRUE; Color_t c = fAxis->GetAxisColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fAxisColor->SetColor(p); Float_t fl = fAxis->GetTickLength(); @@ -318,7 +319,7 @@ void TAxisEditor::SetModel(TObject* obj) fTitle->SetText(text); c = fAxis->GetTitleColor(); - p = TColor::Number2Pixel(c); + p = TVirtualX::Number2Pixel(c); fTitleColor->SetColor(p); fl = fAxis->GetTitleSize(); @@ -340,7 +341,7 @@ void TAxisEditor::SetModel(TObject* obj) else fRotated->SetState(kButtonUp); c = fAxis->GetLabelColor(); - p = TColor::Number2Pixel(c); + p = TVirtualX::Number2Pixel(c); fLabelColor->SetColor(p); fl = fAxis->GetLabelSize(); diff --git a/gui/ged/src/TH2Editor.cxx b/gui/ged/src/TH2Editor.cxx index d034561ba353e..a6a0fde1f349d 100644 --- a/gui/ged/src/TH2Editor.cxx +++ b/gui/ged/src/TH2Editor.cxx @@ -955,7 +955,7 @@ void TH2Editor::SetModel(TObject* obj) fContLevels->SetIntNumber(fHist->GetContour()); fContLevels1->SetIntNumber(fHist->GetContour()); - fFrameColor->SetColor(TColor::Number2Pixel(fGedEditor->GetPad()->GetFrameFillColor())); + fFrameColor->SetColor(TVirtualX::Number2Pixel(fGedEditor->GetPad()->GetFrameFillColor())); fFramePattern->SetPattern(fGedEditor->GetPad()->GetFrameFillStyle()); TTreePlayer *player = (TTreePlayer*)TVirtualTreePlayer::GetCurrentPlayer(); diff --git a/gui/ged/src/TPieEditor.cxx b/gui/ged/src/TPieEditor.cxx index aab776a536165..e590743678667 100644 --- a/gui/ged/src/TPieEditor.cxx +++ b/gui/ged/src/TPieEditor.cxx @@ -243,7 +243,7 @@ void TPieEditor::SetModel(TObject* obj) fTypeCombo->Select(fPie->GetTextFont() / 10); Color_t c = fPie->GetTextColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fColorSelect->SetColor(p, kFALSE); Float_t s = fPie->GetTextSize(); diff --git a/gui/ged/src/TStyleManager.cxx b/gui/ged/src/TStyleManager.cxx index af96c9d878ada..1474516d8a055 100644 --- a/gui/ged/src/TStyleManager.cxx +++ b/gui/ged/src/TStyleManager.cxx @@ -1283,19 +1283,19 @@ void TStyleManager::UpdateEditor(Int_t tabNum) Int_t tmp2; switch (tabNum) { case 0: // GENERAL - fFillColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetFillColor())); + fFillColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetFillColor())); fFillStyle->SetPattern(fCurSelStyle->GetFillStyle()); fHatchesLineWidth->Select(fCurSelStyle->GetHatchesLineWidth()); fHatchesSpacing->SetNumber(fCurSelStyle->GetHatchesSpacing()); - fMarkerColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetMarkerColor())); + fMarkerColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetMarkerColor())); fMarkerStyle->SetMarkerStyle(fCurSelStyle->GetMarkerStyle()); fMarkerSize->Select((Int_t) fCurSelStyle->GetMarkerSize() * 5); fScreenFactor->SetNumber(fCurSelStyle->GetScreenFactor()); - fLineColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetLineColor())); + fLineColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetLineColor())); fLineWidth->Select(fCurSelStyle->GetLineWidth()); fLineStyle->Select(fCurSelStyle->GetLineStyle()); // Nothing to do with fLineStyleEdit. - fTextColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTextColor())); + fTextColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTextColor())); if (fCurSelStyle->GetTextFont()%10 > 2) { fTextSizeInPixels->SetState(kButtonDown, kFALSE); ModTextSizeInPixels(kTRUE); @@ -1308,14 +1308,14 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fTextAngle->SetNumber(fCurSelStyle->GetTextAngle()); break; case 1: // CANVAS - fCanvasColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetCanvasColor())); + fCanvasColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetCanvasColor())); fCanvasDefX->SetIntNumber(fCurSelStyle->GetCanvasDefX()); fCanvasDefY->SetIntNumber(fCurSelStyle->GetCanvasDefY()); fCanvasDefW->SetIntNumber(fCurSelStyle->GetCanvasDefW()); fCanvasDefH->SetIntNumber(fCurSelStyle->GetCanvasDefH()); fCanvasBorderMode->SetButton(fCurSelStyle->GetCanvasBorderMode() + 1 + kCanvasBorderModeSunken); fCanvasBorderSize->Select(fCurSelStyle->GetCanvasBorderSize()); - fAttDateTextColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetAttDate()->GetTextColor())); + fAttDateTextColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetAttDate()->GetTextColor())); if (fCurSelStyle->GetAttDate()->GetTextFont()%10 > 2) { fAttDateTextSizeInPixels->SetState(kButtonDown, kFALSE); ModAttDateTextSizeInPixels(kTRUE); @@ -1364,7 +1364,7 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fPadRightMargin->SetIntNumber((Int_t) (fCurSelStyle->GetPadRightMargin() * 100 + 0.5)); fPadBorderMode->SetButton(fCurSelStyle->GetPadBorderMode() + 1 + kPadBorderModeSunken); fPadBorderSize->Select(fCurSelStyle->GetPadBorderSize()); - fPadColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetPadColor())); + fPadColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetPadColor())); if (fCurSelStyle->GetPadTickX()) fPadTickX->SetState(kButtonDown, kFALSE); else @@ -1381,14 +1381,14 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fPadGridY->SetState(kButtonDown, kFALSE); else fPadGridY->SetState(kButtonUp, kFALSE); - fGridColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetGridColor())); + fGridColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetGridColor())); fGridWidth->Select(fCurSelStyle->GetGridWidth()); fGridStyle->Select(fCurSelStyle->GetGridStyle()); break; case 3: // HISTOS - fHistFillColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetHistFillColor())); + fHistFillColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetHistFillColor())); fHistFillStyle->SetPattern(fCurSelStyle->GetHistFillStyle()); - fHistLineColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetHistLineColor())); + fHistLineColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetHistLineColor())); fHistLineWidth->Select(fCurSelStyle->GetHistLineWidth()); fHistLineStyle->Select(fCurSelStyle->GetHistLineStyle()); fBarWidth->SetNumber(fCurSelStyle->GetBarWidth()); @@ -1400,15 +1400,15 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fPaintTextFormat->SetText(fCurSelStyle->GetPaintTextFormat()); fNumberContours->SetIntNumber(fCurSelStyle->GetNumberContours()); fLegoInnerR->SetIntNumber((Int_t) (fCurSelStyle->GetLegoInnerR() * 100 + 0.5)); - fFrameFillColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetFrameFillColor())); + fFrameFillColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetFrameFillColor())); fFrameFillStyle->SetPattern(fCurSelStyle->GetFrameFillStyle()); - fFrameLineColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetFrameLineColor())); + fFrameLineColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetFrameLineColor())); fFrameLineWidth->Select(fCurSelStyle->GetFrameLineWidth()); fFrameLineStyle->Select(fCurSelStyle->GetFrameLineStyle()); // Nothing to do with fPaletteEdit; fFrameBorderMode->SetButton(fCurSelStyle->GetFrameBorderMode() + 1 + kFrameBorderModeSunken); fFrameBorderSize->Select(fCurSelStyle->GetFrameBorderSize()); - fFuncColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetFuncColor())); + fFuncColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetFuncColor())); fFuncWidth->Select(fCurSelStyle->GetFuncWidth()); fFuncStyle->Select(fCurSelStyle->GetFuncStyle()); if (fCurSelStyle->GetDrawBorder()) @@ -1468,7 +1468,7 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fXTitleSizeInPixels->SetState(kButtonUp, kFALSE); ModXTitleSizeInPixels(kFALSE); } - fXTitleColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTitleColor("X"))); + fXTitleColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTitleColor("X"))); fXTitleOffset->SetNumber(fCurSelStyle->GetTitleOffset("X")); fXTitleFont->Select(fCurSelStyle->GetTitleFont("X")/10); fXLabelSize->SetNumber(fCurSelStyle->GetLabelSize("X")); @@ -1479,10 +1479,10 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fXLabelSizeInPixels->SetState(kButtonUp, kFALSE); ModXLabelSizeInPixels(kFALSE); } - fXLabelColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetLabelColor("X"))); + fXLabelColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetLabelColor("X"))); fXLabelOffset->SetNumber(fCurSelStyle->GetLabelOffset("X")); fXLabelFont->Select(fCurSelStyle->GetLabelFont("X")/10); - fXAxisColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetAxisColor("X"))); + fXAxisColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetAxisColor("X"))); fXTickLength->SetNumber(fCurSelStyle->GetTickLength("X")); if (fCurSelStyle->GetOptLogx()) fOptLogx->SetState(kButtonDown, kFALSE); @@ -1503,7 +1503,7 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fYTitleSizeInPixels->SetState(kButtonUp, kFALSE); ModYTitleSizeInPixels(kFALSE); } - fYTitleColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTitleColor("Y"))); + fYTitleColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTitleColor("Y"))); fYTitleOffset->SetNumber(fCurSelStyle->GetTitleOffset("Y")); fYTitleFont->Select(fCurSelStyle->GetTitleFont("Y")/10); fYLabelSize->SetNumber(fCurSelStyle->GetLabelSize("Y")); @@ -1514,10 +1514,10 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fYLabelSizeInPixels->SetState(kButtonUp, kFALSE); ModYLabelSizeInPixels(kFALSE); } - fYLabelColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetLabelColor("Y"))); + fYLabelColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetLabelColor("Y"))); fYLabelOffset->SetNumber(fCurSelStyle->GetLabelOffset("Y")); fYLabelFont->Select(fCurSelStyle->GetLabelFont("Y")/10); - fYAxisColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetAxisColor("Y"))); + fYAxisColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetAxisColor("Y"))); fYTickLength->SetNumber(fCurSelStyle->GetTickLength("Y")); if (fCurSelStyle->GetOptLogy()) fOptLogy->SetState(kButtonDown, kFALSE); @@ -1538,7 +1538,7 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fZTitleSizeInPixels->SetState(kButtonUp, kFALSE); ModZTitleSizeInPixels(kFALSE); } - fZTitleColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTitleColor("Z"))); + fZTitleColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTitleColor("Z"))); fZTitleOffset->SetNumber(fCurSelStyle->GetTitleOffset("Z")); fZTitleFont->Select(fCurSelStyle->GetTitleFont("Z")/10); fZLabelSize->SetNumber(fCurSelStyle->GetLabelSize("Z")); @@ -1549,10 +1549,10 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fZLabelSizeInPixels->SetState(kButtonUp, kFALSE); ModZLabelSizeInPixels(kFALSE); } - fZLabelColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetLabelColor("Z"))); + fZLabelColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetLabelColor("Z"))); fZLabelOffset->SetNumber(fCurSelStyle->GetLabelOffset("Z")); fZLabelFont->Select(fCurSelStyle->GetLabelFont("Z")/10); - fZAxisColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetAxisColor("Z"))); + fZAxisColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetAxisColor("Z"))); fZTickLength->SetNumber(fCurSelStyle->GetTickLength("Z")); if (fCurSelStyle->GetOptLogz()) @@ -1569,9 +1569,9 @@ void TStyleManager::UpdateEditor(Int_t tabNum) fZNdivisionsOptimize->SetState(kButtonUp, kFALSE); break; case 5: // TITLES - fTitleColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTitleFillColor())); + fTitleColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTitleFillColor())); fTitleStyle->SetPattern(fCurSelStyle->GetTitleStyle()); - fTitleTextColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetTitleTextColor())); + fTitleTextColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetTitleTextColor())); fTitleFontSize->SetNumber(fCurSelStyle->GetTitleFontSize()); if (fCurSelStyle->GetTitleFont()%10 > 2) { fTitleFontSizeInPixels->SetState(kButtonDown, kFALSE); @@ -1625,9 +1625,9 @@ void TStyleManager::UpdateEditor(Int_t tabNum) } break; case 6: // STATS - fStatColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetStatColor())); + fStatColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetStatColor())); fStatStyle->SetPattern(fCurSelStyle->GetStatStyle()); - fStatTextColor->SetColor(TColor::Number2Pixel(fCurSelStyle->GetStatTextColor())); + fStatTextColor->SetColor(TVirtualX::Number2Pixel(fCurSelStyle->GetStatTextColor())); fStatFont->Select(fCurSelStyle->GetStatFont()/10); if (fCurSelStyle->GetStatFont()%10 > 2) { fStatFontSizeInPixels->SetState(kButtonDown, kFALSE); diff --git a/gui/gui/src/TGColorDialog.cxx b/gui/gui/src/TGColorDialog.cxx index 218fe9b4b92c1..03eef9fdf46c7 100644 --- a/gui/gui/src/TGColorDialog.cxx +++ b/gui/gui/src/TGColorDialog.cxx @@ -1187,7 +1187,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, fPalette->Associate(this); for (i = 0; i < 48; ++i) - fPalette->SetColor(i, TColor::Number2Pixel(i+10)); // root colors + fPalette->SetColor(i, TVirtualX::Number2Pixel(i+10)); // root colors // the basic colors were set via bcolor //fPalette->SetColor(i, TColor::GetPixel(bcolor[i][0], bcolor[i][1], bcolor[i][2])); diff --git a/gui/gui/src/TGColorSelect.cxx b/gui/gui/src/TGColorSelect.cxx index 1ff128639095a..eb0eda22a1efd 100644 --- a/gui/gui/src/TGColorSelect.cxx +++ b/gui/gui/src/TGColorSelect.cxx @@ -128,22 +128,22 @@ TG16ColorSelector::TG16ColorSelector(const TGWindow *p) : { SetLayoutManager(new TGMatrixLayout(this, 4, 4, 1, 1)); - fCe[0] = new TGColorFrame(this, TColor::Number2Pixel(0), 0); - fCe[1] = new TGColorFrame(this, TColor::Number2Pixel(1), 1); - fCe[2] = new TGColorFrame(this, TColor::Number2Pixel(2), 2); - fCe[3] = new TGColorFrame(this, TColor::Number2Pixel(3), 3); - fCe[4] = new TGColorFrame(this, TColor::Number2Pixel(4), 4); - fCe[5] = new TGColorFrame(this, TColor::Number2Pixel(5), 5); - fCe[6] = new TGColorFrame(this, TColor::Number2Pixel(6), 6); - fCe[7] = new TGColorFrame(this, TColor::Number2Pixel(7), 7); - fCe[8] = new TGColorFrame(this, TColor::Number2Pixel(8), 8); - fCe[9] = new TGColorFrame(this, TColor::Number2Pixel(9), 9); - fCe[10] = new TGColorFrame(this, TColor::Number2Pixel(30), 10); - fCe[11] = new TGColorFrame(this, TColor::Number2Pixel(38), 11); - fCe[12] = new TGColorFrame(this, TColor::Number2Pixel(41), 12); - fCe[13] = new TGColorFrame(this, TColor::Number2Pixel(42), 13); - fCe[14] = new TGColorFrame(this, TColor::Number2Pixel(50), 14); - fCe[15] = new TGColorFrame(this, TColor::Number2Pixel(51), 15); + fCe[0] = new TGColorFrame(this, TVirtualX::Number2Pixel(0), 0); + fCe[1] = new TGColorFrame(this, TVirtualX::Number2Pixel(1), 1); + fCe[2] = new TGColorFrame(this, TVirtualX::Number2Pixel(2), 2); + fCe[3] = new TGColorFrame(this, TVirtualX::Number2Pixel(3), 3); + fCe[4] = new TGColorFrame(this, TVirtualX::Number2Pixel(4), 4); + fCe[5] = new TGColorFrame(this, TVirtualX::Number2Pixel(5), 5); + fCe[6] = new TGColorFrame(this, TVirtualX::Number2Pixel(6), 6); + fCe[7] = new TGColorFrame(this, TVirtualX::Number2Pixel(7), 7); + fCe[8] = new TGColorFrame(this, TVirtualX::Number2Pixel(8), 8); + fCe[9] = new TGColorFrame(this, TVirtualX::Number2Pixel(9), 9); + fCe[10] = new TGColorFrame(this, TVirtualX::Number2Pixel(30), 10); + fCe[11] = new TGColorFrame(this, TVirtualX::Number2Pixel(38), 11); + fCe[12] = new TGColorFrame(this, TVirtualX::Number2Pixel(41), 12); + fCe[13] = new TGColorFrame(this, TVirtualX::Number2Pixel(42), 13); + fCe[14] = new TGColorFrame(this, TVirtualX::Number2Pixel(50), 14); + fCe[15] = new TGColorFrame(this, TVirtualX::Number2Pixel(51), 15); for (Int_t i = 0; i < 16; i++) AddFrame(fCe[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY)); @@ -404,7 +404,7 @@ TGColorSelect::TGColorSelect(const TGWindow *p, Pixel_t color, Int_t id) : TGCheckButton(p, "", id) { if (!p && fClient->IsEditable() && !color) { - color = TColor::Number2Pixel(6); // magenta + color = TVirtualX::Number2Pixel(6); // magenta } fColor = color; diff --git a/gui/gui/src/TGListTree.cxx b/gui/gui/src/TGListTree.cxx index 6cd8e8928b1aa..4d8f23396f7eb 100644 --- a/gui/gui/src/TGListTree.cxx +++ b/gui/gui/src/TGListTree.cxx @@ -1650,7 +1650,7 @@ void TGListTree::DrawItemName(Handle_t id, TGListTreeItem *item) if (fColorMode != 0 && item->HasColor()) { UInt_t width = TextWidth(item->GetText()); - gVirtualX->SetForeground(fColorGC, TColor::Number2Pixel(item->GetColor())); + gVirtualX->SetForeground(fColorGC, TVirtualX::Number2Pixel(item->GetColor())); if (fColorMode & kColorUnderline) { Int_t y = item->fYtext-pos.fY + FontAscent() + 2; gVirtualX->DrawLine(id, fColorGC, item->fXtext, y, diff --git a/gui/guibuilder/src/TGuiBldDragManager.cxx b/gui/guibuilder/src/TGuiBldDragManager.cxx index 914c2e7c7baad..938778f32d7aa 100644 --- a/gui/guibuilder/src/TGuiBldDragManager.cxx +++ b/gui/guibuilder/src/TGuiBldDragManager.cxx @@ -5795,10 +5795,10 @@ TGColorDialog *TGuiBldDragManager::GetGlobalColorDialog(Bool_t create) &retc, &color, kFALSE); int i = 0; for (i = 0; i < 10; i++) { - fgGlobalColorDialog->GetCustomPalette()->SetColor(i, TColor::Number2Pixel(i)); + fgGlobalColorDialog->GetCustomPalette()->SetColor(i, TVirtualX::Number2Pixel(i)); } for (i = 0; i < 10; i++) { - fgGlobalColorDialog->GetCustomPalette()->SetColor(10+i, TColor::Number2Pixel(180+i)); + fgGlobalColorDialog->GetCustomPalette()->SetColor(10+i, TVirtualX::Number2Pixel(180+i)); } } return fgGlobalColorDialog; diff --git a/gui/guibuilder/src/TRootGuiBuilder.cxx b/gui/guibuilder/src/TRootGuiBuilder.cxx index 6f2ce0463a766..a9bfde883c6b5 100644 --- a/gui/guibuilder/src/TRootGuiBuilder.cxx +++ b/gui/guibuilder/src/TRootGuiBuilder.cxx @@ -695,7 +695,7 @@ TRootGuiBuilder::TRootGuiBuilder(const TGWindow *p) : TGuiBuilder(), AddSection("User's Macros"); TGShutterItem *item = fShutter->GetItem("User's Macros"); TGCompositeFrame *cont = (TGCompositeFrame *)item->GetContainer(); - cont->SetBackgroundColor(TColor::Number2Pixel(18)); + cont->SetBackgroundColor(TVirtualX::Number2Pixel(18)); TGuiBldAction *act = new TGuiBldAction("TGMainFrame", "Empty Frame", kGuiBldProj); @@ -1003,7 +1003,7 @@ void TRootGuiBuilder::AddAction(TGuiBldAction *act, const char *sect) if (!item) return; TGCompositeFrame *cont = (TGCompositeFrame *)item->GetContainer(); - cont->SetBackgroundColor(TColor::Number2Pixel(18)); + cont->SetBackgroundColor(TVirtualX::Number2Pixel(18)); const TGPicture *pic = 0; if (!act->fPicture) { diff --git a/tree/treeviewer/src/TParallelCoordEditor.cxx b/tree/treeviewer/src/TParallelCoordEditor.cxx index 5f1984fe581cc..8b914bf5766cf 100644 --- a/tree/treeviewer/src/TParallelCoordEditor.cxx +++ b/tree/treeviewer/src/TParallelCoordEditor.cxx @@ -22,6 +22,7 @@ #include "TGComboBox.h" #include "TGColorSelect.h" #include "TColor.h" +#include "TVirtualX.h" #include "TG3DLine.h" #include "TGSlider.h" #include "TGDoubleSlider.h" @@ -340,7 +341,7 @@ void TParallelCoordEditor::CleanUpSelections() fSelectionSelect->AddEntry(sel->GetTitle(),i); TGLBEntry *entry = fSelectionSelect->GetListBox()->GetEntry(i); if (entry) - entry->SetBackgroundColor(TColor::Number2Pixel(sel->GetLineColor())); + entry->SetBackgroundColor(TVirtualX::Number2Pixel(sel->GetLineColor())); ++i; } sel = fParallel->GetCurrentSelection(); @@ -349,7 +350,7 @@ void TParallelCoordEditor::CleanUpSelections() Color_t c; Pixel_t p; c = sel->GetLineColor(); - p = TColor::Number2Pixel(c); + p = TVirtualX::Number2Pixel(c); fSelectLineColor->SetColor(p); fSelectLineWidth->Select(sel->GetLineWidth()); fActivateSelection->SetOn(sel->TestBit(TParallelCoordSelect::kActivated)); @@ -892,7 +893,7 @@ void TParallelCoordEditor::DoSelectionSelect(const char* title) if (!fParallel->SetCurrentSelection(title)) return; Color_t c = fParallel->GetCurrentSelection()->GetLineColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fSelectLineColor->SetColor(p,false); fSelectLineWidth->Select(fParallel->GetCurrentSelection()->GetLineWidth(),false); @@ -957,7 +958,7 @@ void TParallelCoordEditor::SetModel(TObject* obj) fAvoidSignal = true; Color_t c = fParallel->GetLineColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fGlobalLineColor->SetColor(p); fGlobalLineWidth->Select(fParallel->GetLineWidth()); @@ -996,7 +997,7 @@ void TParallelCoordEditor::SetModel(TObject* obj) fWeightCut->SetPosition(fParallel->GetWeightCut()); fWeightCutField->SetNumber(fParallel->GetWeightCut()); - fHistColorSelect->SetColor(TColor::Number2Pixel(((TParallelCoordVar*)fParallel->GetVarList()->Last())->GetFillColor()), false); + fHistColorSelect->SetColor(TVirtualX::Number2Pixel(((TParallelCoordVar*)fParallel->GetVarList()->Last())->GetFillColor()), false); fHistPatternSelect->SetPattern(((TParallelCoordVar*)fParallel->GetVarList()->Last())->GetFillStyle(),false); if (fInit) ConnectSignals2Slots(); diff --git a/tree/treeviewer/src/TSpiderEditor.cxx b/tree/treeviewer/src/TSpiderEditor.cxx index 07fd90d02a994..bc08a938f3877 100644 --- a/tree/treeviewer/src/TSpiderEditor.cxx +++ b/tree/treeviewer/src/TSpiderEditor.cxx @@ -22,6 +22,7 @@ #include "TGColorSelect.h" #include "TGedPatternSelect.h" #include "TColor.h" +#include "TVirtualX.h" /** \class TSpiderEditor @@ -275,10 +276,10 @@ void TSpiderEditor::SetModel(TObject* obj) fAvLineStyleCombo->Select(fSpider->GetAverageLineStyle()); fAvLineWidthCombo->Select(fSpider->GetAverageLineWidth()); Color_t c = fSpider->GetAverageLineColor(); - Pixel_t p = TColor::Number2Pixel(c); + Pixel_t p = TVirtualX::Number2Pixel(c); fAvLineColorSelect->SetColor(p); c = fSpider->GetAverageFillColor(); - p = TColor::Number2Pixel(c); + p = TVirtualX::Number2Pixel(c); fAvFillColorSelect->SetColor(p,false); fAvFillPatternSelect->SetPattern(fSpider->GetAverageFillStyle(),false); From 382a0b5e9031095cacc42a760e9a703143ebd8ac Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 15:04:49 +0100 Subject: [PATCH 04/15] [colors] mark pixel methods of TColor deprecated in ROOT7 --- core/base/inc/TColor.h | 12 ++++++------ core/base/src/TColor.cxx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/base/inc/TColor.h b/core/base/inc/TColor.h index 4c68a6e1959b0..3385dc783442f 100644 --- a/core/base/inc/TColor.h +++ b/core/base/inc/TColor.h @@ -96,12 +96,12 @@ class TColor : public TNamed { static const TArrayI& GetPalette(); static Int_t GetLinearGradient(Double_t angle, const std::vector &colors, const std::vector &positions = {}); static Int_t GetRadialGradient(Double_t r, const std::vector &colors, const std::vector &positions = {}); - static ULong_t Number2Pixel(Int_t ci); - static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b); - static ULong_t RGB2Pixel(Float_t r, Float_t g, Float_t b); - static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b); - static void Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b); - static const char *PixelAsHexString(ULong_t pixel); + static ULong_t R__DEPRECATED(7,00, "Use TVirtualX::Number2Pixel instead") Number2Pixel(Int_t ci); + static ULong_t R__DEPRECATED(7,00, "Use TVirtualX::RGB2Pixel instead") RGB2Pixel(Int_t r, Int_t g, Int_t b); + static ULong_t R__DEPRECATED(7,00, "Use TVirtualX::RGB2Pixel instead") RGB2Pixel(Float_t r, Float_t g, Float_t b); + static void R__DEPRECATED(7,00, "Use TVirtualX::Pixel2RGB instead") Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b); + static void R__DEPRECATED(7,00, "Use TVirtualX::Pixel2RGB instead") Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b); + static const char * R__DEPRECATED(7,00, "Use TVirtualX::PixelAsHexString instead") PixelAsHexString(ULong_t pixel); static TString SavePrimitiveColor(Int_t ci); static Bool_t SaveColor(std::ostream &out, Int_t ci); static void SaveColorsPalette(std::ostream &out); diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index e4f05c7b38fec..bda97538b3822 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -1977,7 +1977,7 @@ Int_t TColor::GetColor(ULong_t pixel) { Int_t r, g, b; - Pixel2RGB(pixel, r, g, b); + TVirtualX::Pixel2RGB(pixel, r, g, b); return GetColor(r, g, b); } From 1deb1e41734216ab78ee56cc25e828a591e22660 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 15:40:55 +0100 Subject: [PATCH 05/15] [colors] introduce TVirtualX::Pixel2Number(pixel) It converts pixel to color number and should replace TColor::GetColor(pixel) method. As in previous methods, TColor method will be deprecated in ROOT7 --- core/base/inc/TVirtualX.h | 2 ++ core/base/src/TColor.cxx | 11 ++++------- core/base/src/TVirtualX.cxx | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/base/inc/TVirtualX.h b/core/base/inc/TVirtualX.h index 8ee5c78624748..30286721c79a3 100644 --- a/core/base/inc/TVirtualX.h +++ b/core/base/inc/TVirtualX.h @@ -378,6 +378,8 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe static void Pixel2RGB(ULong_t pixel, Float_t &r, Float_t &g, Float_t &b); static TString PixelAsHexString(ULong_t pixel); static ULong_t Number2Pixel(Int_t ci); + static Int_t Pixel2Number(ULong_t pixel); + static TVirtualX *&Instance(); diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index bda97538b3822..f12d3b37bffb2 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -1966,20 +1966,17 @@ Int_t TColor::GetColor(Float_t r, Float_t g, Float_t b, Float_t a) } //////////////////////////////////////////////////////////////////////////////// -/// Static method returning color number for color specified by +/// @deprecated Use TVirtualX::Pixel2Number instead +/// +/// @brief Static method returning color number for color specified by /// system dependent pixel value. Pixel values can be obtained, e.g., /// from the GUI color picker. /// /// The color retrieval is done using a threshold defined by SetColorThreshold. - Int_t TColor::GetColor(ULong_t pixel) { - Int_t r, g, b; - - TVirtualX::Pixel2RGB(pixel, r, g, b); - - return GetColor(r, g, b); + return TVirtualX::Pixel2Number(pixel); } //////////////////////////////////////////////////////////////////////////////// diff --git a/core/base/src/TVirtualX.cxx b/core/base/src/TVirtualX.cxx index 7197063dd0fc3..85197d601c79a 100644 --- a/core/base/src/TVirtualX.cxx +++ b/core/base/src/TVirtualX.cxx @@ -2849,3 +2849,19 @@ ULong_t TVirtualX::Number2Pixel(Int_t ci) ::Warning("TVirtualX::Number2Pixel", "color with index %d not defined", ci); return 0; } + +//////////////////////////////////////////////////////////////////////////////// +/// Static method returning color number for color specified by +/// system dependent pixel value. Pixel values can be obtained, e.g., +/// from the GUI color picker. +/// +/// The color retrieval is done using a threshold defined by TColor::SetColorThreshold. + +Int_t TVirtualX::Pixel2Number(ULong_t pixel) +{ + Int_t r, g, b; + + Pixel2RGB(pixel, r, g, b); + + return TColor::GetColor(r, g, b); +} From 03fe89d45376a552d13af0db036647c303bd491d Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:02:33 +0100 Subject: [PATCH 06/15] [graf3d] use new TVirtualX::Pixel2Number Replace TColor::GetColor(pixel) calls To be checked why used in REVE --- graf3d/eve/src/TEveCaloLegoEditor.cxx | 6 +++--- graf3d/eve/src/TEveCaloVizEditor.cxx | 2 +- graf3d/eve/src/TEveElement.cxx | 3 ++- graf3d/eve/src/TEveFrameBox.cxx | 5 +++-- graf3d/eve/src/TEveRGBAPalette.cxx | 7 ++++--- graf3d/eve/src/TEveShapeEditor.cxx | 2 +- graf3d/eve7/src/REveElement.cxx | 3 ++- graf3d/eve7/src/REveFrameBox.cxx | 5 +++-- graf3d/eve7/src/REveRGBAPalette.cxx | 7 ++++--- graf3d/gl/src/TGL5DDataSetEditor.cxx | 2 +- graf3d/gl/src/TGLViewerEditor.cxx | 4 ++-- graf3d/gviz3d/src/TStructNodeProperty.cxx | 3 ++- graf3d/gviz3d/src/TStructViewer.cxx | 3 ++- 13 files changed, 30 insertions(+), 22 deletions(-) diff --git a/graf3d/eve/src/TEveCaloLegoEditor.cxx b/graf3d/eve/src/TEveCaloLegoEditor.cxx index f8be3c9641828..18b521e974087 100644 --- a/graf3d/eve/src/TEveCaloLegoEditor.cxx +++ b/graf3d/eve/src/TEveCaloLegoEditor.cxx @@ -207,7 +207,7 @@ void TEveCaloLegoEditor::SetModel(TObject* obj) void TEveCaloLegoEditor::DoGridColor(Pixel_t pixel) { - fM->SetGridColor(Color_t(TColor::GetColor(pixel))); + fM->SetGridColor(Color_t(TVirtualX::Pixel2Number(pixel))); Update(); } @@ -216,7 +216,7 @@ void TEveCaloLegoEditor::DoGridColor(Pixel_t pixel) void TEveCaloLegoEditor::DoFontColor(Pixel_t pixel) { - fM->SetFontColor(Color_t(TColor::GetColor(pixel))); + fM->SetFontColor(Color_t(TVirtualX::Pixel2Number(pixel))); Update(); } @@ -225,7 +225,7 @@ void TEveCaloLegoEditor::DoFontColor(Pixel_t pixel) void TEveCaloLegoEditor::DoPlaneColor(Pixel_t pixel) { - fM->SetPlaneColor(Color_t(TColor::GetColor(pixel))); + fM->SetPlaneColor(Color_t(TVirtualX::Pixel2Number(pixel))); Update(); } diff --git a/graf3d/eve/src/TEveCaloVizEditor.cxx b/graf3d/eve/src/TEveCaloVizEditor.cxx index 8faeba0cbb1ef..3d83bd0f9e3b3 100644 --- a/graf3d/eve/src/TEveCaloVizEditor.cxx +++ b/graf3d/eve/src/TEveCaloVizEditor.cxx @@ -365,7 +365,7 @@ void TEveCaloVizEditor::DoSliceThreshold() void TEveCaloVizEditor::DoSliceColor(Pixel_t pixel) { TGColorSelect *cs = (TGColorSelect *) gTQSender; - fM->SetDataSliceColor(cs->WidgetId(), Color_t(TColor::GetColor(pixel))); + fM->SetDataSliceColor(cs->WidgetId(), Color_t(TVirtualX::Pixel2Number(pixel))); Update(); } diff --git a/graf3d/eve/src/TEveElement.cxx b/graf3d/eve/src/TEveElement.cxx index 521ceed10d323..8d01c0fa03bc6 100644 --- a/graf3d/eve/src/TEveElement.cxx +++ b/graf3d/eve/src/TEveElement.cxx @@ -28,6 +28,7 @@ #include "TPRegexp.h" #include "TROOT.h" #include "TColor.h" +#include "TVirtualX.h" #include "TEveBrowser.h" #include "TGListTree.h" #include "TGPicture.h" @@ -1171,7 +1172,7 @@ void TEveElement::SetMainColor(Color_t color) void TEveElement::SetMainColorPixel(Pixel_t pixel) { - SetMainColor(TColor::GetColor(pixel)); + SetMainColor(TVirtualX::Pixel2Number(pixel)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/eve/src/TEveFrameBox.cxx b/graf3d/eve/src/TEveFrameBox.cxx index 6aa79bb8b3af5..a0dfc3b35775d 100644 --- a/graf3d/eve/src/TEveFrameBox.cxx +++ b/graf3d/eve/src/TEveFrameBox.cxx @@ -11,6 +11,7 @@ #include "TEveFrameBox.h" #include "TColor.h" +#include "TVirtualX.h" /** \class TEveFrameBox \ingroup TEve @@ -161,7 +162,7 @@ void TEveFrameBox::SetFrameColor(Color_t ci) void TEveFrameBox::SetFrameColorPixel(Pixel_t pix) { - SetFrameColor(Color_t(TColor::GetColor(pix))); + SetFrameColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -190,7 +191,7 @@ void TEveFrameBox::SetBackColor(Color_t ci) void TEveFrameBox::SetBackColorPixel(Pixel_t pix) { - SetBackColor(Color_t(TColor::GetColor(pix))); + SetBackColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/eve/src/TEveRGBAPalette.cxx b/graf3d/eve/src/TEveRGBAPalette.cxx index d09e28155678a..5c6384201a6e5 100644 --- a/graf3d/eve/src/TEveRGBAPalette.cxx +++ b/graf3d/eve/src/TEveRGBAPalette.cxx @@ -12,6 +12,7 @@ #include "TEveRGBAPalette.h" #include "TColor.h" +#include "TVirtualX.h" #include "TStyle.h" #include "TMath.h" @@ -268,7 +269,7 @@ void TEveRGBAPalette::SetDefaultColor(Color_t ci) void TEveRGBAPalette::SetDefaultColorPixel(Pixel_t pix) { - SetDefaultColor(Color_t(TColor::GetColor(pix))); + SetDefaultColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -297,7 +298,7 @@ void TEveRGBAPalette::SetUnderColor(Color_t ci) void TEveRGBAPalette::SetUnderColorPixel(Pixel_t pix) { - SetUnderColor(Color_t(TColor::GetColor(pix))); + SetUnderColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -326,7 +327,7 @@ void TEveRGBAPalette::SetOverColor(Color_t ci) void TEveRGBAPalette::SetOverColorPixel(Pixel_t pix) { - SetOverColor(Color_t(TColor::GetColor(pix))); + SetOverColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/eve/src/TEveShapeEditor.cxx b/graf3d/eve/src/TEveShapeEditor.cxx index 99aaa24ee5b59..b45edfce67496 100644 --- a/graf3d/eve/src/TEveShapeEditor.cxx +++ b/graf3d/eve/src/TEveShapeEditor.cxx @@ -101,7 +101,7 @@ void TEveShapeEditor::DoLineWidth() void TEveShapeEditor::DoLineColor(Pixel_t pixel) { - fM->SetLineColor(TColor::GetColor(pixel)); + fM->SetLineColor(TVirtualX::Pixel2Number(pixel)); Update(); } diff --git a/graf3d/eve7/src/REveElement.cxx b/graf3d/eve7/src/REveElement.cxx index 937040b3619b4..ef0c6a2c311f2 100644 --- a/graf3d/eve7/src/REveElement.cxx +++ b/graf3d/eve7/src/REveElement.cxx @@ -27,6 +27,7 @@ #include "TROOT.h" #include "TBase64.h" #include "TColor.h" +#include "TVirtualX.h" #include #include @@ -743,7 +744,7 @@ void REveElement::SetMainColor(Color_t color) void REveElement::SetMainColorPixel(Pixel_t pixel) { - SetMainColor(TColor::GetColor(pixel)); + SetMainColor(TVirtualX::Pixel2Number(pixel)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/eve7/src/REveFrameBox.cxx b/graf3d/eve7/src/REveFrameBox.cxx index 5351089d694bf..28b793b203d29 100644 --- a/graf3d/eve7/src/REveFrameBox.cxx +++ b/graf3d/eve7/src/REveFrameBox.cxx @@ -11,6 +11,7 @@ #include "ROOT/REveFrameBox.hxx" #include "TColor.h" +#include "TVirtualX.h" using namespace ROOT::Experimental; @@ -162,7 +163,7 @@ void REveFrameBox::SetFrameColor(Color_t ci) void REveFrameBox::SetFrameColorPixel(Pixel_t pix) { - SetFrameColor(Color_t(TColor::GetColor(pix))); + SetFrameColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -191,7 +192,7 @@ void REveFrameBox::SetBackColor(Color_t ci) void REveFrameBox::SetBackColorPixel(Pixel_t pix) { - SetBackColor(Color_t(TColor::GetColor(pix))); + SetBackColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/eve7/src/REveRGBAPalette.cxx b/graf3d/eve7/src/REveRGBAPalette.cxx index f837862da43e3..853d9e879c1aa 100644 --- a/graf3d/eve7/src/REveRGBAPalette.cxx +++ b/graf3d/eve7/src/REveRGBAPalette.cxx @@ -12,6 +12,7 @@ #include "ROOT/REveRGBAPalette.hxx" #include "TColor.h" +#include "TVirtualX.h" #include "TStyle.h" #include "TMath.h" #include @@ -274,7 +275,7 @@ void REveRGBAPalette::SetDefaultColor(Color_t ci) void REveRGBAPalette::SetDefaultColorPixel(Pixel_t pix) { - SetDefaultColor(Color_t(TColor::GetColor(pix))); + SetDefaultColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -303,7 +304,7 @@ void REveRGBAPalette::SetUnderColor(Color_t ci) void REveRGBAPalette::SetUnderColorPixel(Pixel_t pix) { - SetUnderColor(Color_t(TColor::GetColor(pix))); + SetUnderColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// @@ -334,7 +335,7 @@ void REveRGBAPalette::SetOverColor(Color_t ci) void REveRGBAPalette::SetOverColorPixel(Pixel_t pix) { - SetOverColor(Color_t(TColor::GetColor(pix))); + SetOverColor(Color_t(TVirtualX::Pixel2Number(pix))); } //////////////////////////////////////////////////////////////////////////////// diff --git a/graf3d/gl/src/TGL5DDataSetEditor.cxx b/graf3d/gl/src/TGL5DDataSetEditor.cxx index 7f3ac47fd4b8f..a8e9f00641d63 100644 --- a/graf3d/gl/src/TGL5DDataSetEditor.cxx +++ b/graf3d/gl/src/TGL5DDataSetEditor.cxx @@ -785,7 +785,7 @@ void TGL5DDataSetEditor::VisibleClicked() void TGL5DDataSetEditor::ColorChanged(Pixel_t pixel) { if (fSelectedSurface != -1) { - fHidden->fIterators[fSelectedSurface]->fColor = Color_t(TColor::GetColor(pixel)); + fHidden->fIterators[fSelectedSurface]->fColor = (Color_t) TVirtualX::Pixel2Number(pixel); if (gPad) gPad->Update(); } diff --git a/graf3d/gl/src/TGLViewerEditor.cxx b/graf3d/gl/src/TGLViewerEditor.cxx index 307e5d7fb48bd..01940a07fdc40 100644 --- a/graf3d/gl/src/TGLViewerEditor.cxx +++ b/graf3d/gl/src/TGLViewerEditor.cxx @@ -264,9 +264,9 @@ void TGLViewerEditor::SetModel(TObject* obj) //////////////////////////////////////////////////////////////////////////////// /// Clear-color was changed. -void TGLViewerEditor::DoClearColor(Pixel_t color) +void TGLViewerEditor::DoClearColor(Pixel_t pixel) { - fViewer->RnrCtx().ColorSet().Background().SetColor(Color_t(TColor::GetColor(color))); + fViewer->RnrCtx().ColorSet().Background().SetColor(Color_t(TVirtualX::Pixel2Number(pixel))); ViewerRedraw(); } diff --git a/graf3d/gviz3d/src/TStructNodeProperty.cxx b/graf3d/gviz3d/src/TStructNodeProperty.cxx index 0e39ca8e986a2..fbb00919a6d9d 100644 --- a/graf3d/gviz3d/src/TStructNodeProperty.cxx +++ b/graf3d/gviz3d/src/TStructNodeProperty.cxx @@ -12,6 +12,7 @@ #include "TStructNodeProperty.h" #include #include +#include //________________________________________________________________________ @@ -150,5 +151,5 @@ void TStructNodeProperty::SetColor(Int_t color) void TStructNodeProperty::SetColor(Pixel_t pixel) { - SetColor(TColor::GetColor(pixel)); + SetColor(TVirtualX::Pixel2Number(pixel)); } diff --git a/graf3d/gviz3d/src/TStructViewer.cxx b/graf3d/gviz3d/src/TStructViewer.cxx index 860ef6b5331e1..8c1e27ab46716 100644 --- a/graf3d/gviz3d/src/TStructViewer.cxx +++ b/graf3d/gviz3d/src/TStructViewer.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -452,7 +453,7 @@ void TStructViewer::SetColor(TString name, Int_t color) TStructNodeProperty* prop; while ((prop = (TStructNodeProperty*) it() )) { if (name == prop->GetName()) { - prop->SetColor(TColor::GetColor(color)); + prop->SetColor(TVirtualX::Pixel2Number(color)); fGUI->Update(); return; From cb88ecbe516d13fba397c2c215fd9aa49597651e Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:02:39 +0100 Subject: [PATCH 07/15] [gui] use new TVirtualX::Pixel2Number Replace TColor::GetColor(pixel) calls To be checked why used in REVE --- gui/fitpanel/src/TAdvancedGraphicsDialog.cxx | 10 ++-- gui/ged/src/TAttFillEditor.cxx | 4 +- gui/ged/src/TAttLineEditor.cxx | 4 +- gui/ged/src/TAttMarkerEditor.cxx | 4 +- gui/ged/src/TAttTextEditor.cxx | 6 +-- gui/ged/src/TAxisEditor.cxx | 6 +-- gui/ged/src/TH2Editor.cxx | 2 +- gui/ged/src/TPieEditor.cxx | 2 +- gui/ged/src/TStyleManager.cxx | 52 ++++++++++---------- gui/gui/src/TGColorDialog.cxx | 12 ++--- tree/treeviewer/src/TParallelCoordEditor.cxx | 6 +-- tree/treeviewer/src/TSpiderEditor.cxx | 4 +- tutorials/visualisation/gui/calendar.C | 5 +- 13 files changed, 59 insertions(+), 58 deletions(-) diff --git a/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx b/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx index 88fa74b621815..129630635a137 100644 --- a/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx +++ b/gui/fitpanel/src/TAdvancedGraphicsDialog.cxx @@ -370,7 +370,7 @@ void TAdvancedGraphicsDialog::DrawContour() // contour error is actually the desired confidence level Double_t cl = fContourError->GetNumber(); fFitter->Contour( par1, par2, graph, cl); - graph->SetFillColor( TColor::GetColor( fContourColor->GetColor() ) ); + graph->SetFillColor( TVirtualX::Pixel2Number( fContourColor->GetColor() ) ); graph->GetXaxis()->SetTitle( fFitter->GetParName(par1) ); graph->GetYaxis()->SetTitle( fFitter->GetParName(par2) ); graph->Draw( options.c_str() ); @@ -437,8 +437,8 @@ void TAdvancedGraphicsDialog::DrawConfidenceLevels() os << "Confidence Intervals with " << fConfLevel->GetNumber() << " conf. band."; g->SetTitle(os.str().c_str()); - g->SetLineColor( TColor::GetColor( fConfColor->GetColor() )); - g->SetFillColor( TColor::GetColor( fConfColor->GetColor() )); + g->SetLineColor( TVirtualX::Pixel2Number( fConfColor->GetColor() )); + g->SetFillColor( TVirtualX::Pixel2Number( fConfColor->GetColor() )); g->SetFillStyle(3001); g->Draw("C3same"); } else if ( data->NDim() == 2 ) @@ -455,8 +455,8 @@ void TAdvancedGraphicsDialog::DrawConfidenceLevels() os << "Confidence Intervals with " << fConfLevel->GetNumber() << " conf. band."; g->SetTitle(os.str().c_str()); - g->SetLineColor( TColor::GetColor( fConfColor->GetColor() )); - g->SetFillColor( TColor::GetColor( fConfColor->GetColor() )); + g->SetLineColor( TVirtualX::Pixel2Number( fConfColor->GetColor() )); + g->SetFillColor( TVirtualX::Pixel2Number( fConfColor->GetColor() )); g->SetFillStyle(3001); g->Draw("C3same"); } diff --git a/gui/ged/src/TAttFillEditor.cxx b/gui/ged/src/TAttFillEditor.cxx index 92235463466a7..688e39e66f238 100644 --- a/gui/ged/src/TAttFillEditor.cxx +++ b/gui/ged/src/TAttFillEditor.cxx @@ -150,9 +150,9 @@ void TAttFillEditor::DoFillAlphaColor(ULongptr_t p) void TAttFillEditor::DoFillColor(Pixel_t color) { if (fAvoidSignal) return; - fAttFill->SetFillColor(TColor::GetColor(color)); + fAttFill->SetFillColor(TVirtualX::Pixel2Number(color)); - if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) { + if (TColor *tcolor = gROOT->GetColor(TVirtualX::Pixel2Number(color))) { fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000)); fAlphaField->SetNumber(tcolor->GetAlpha()); } diff --git a/gui/ged/src/TAttLineEditor.cxx b/gui/ged/src/TAttLineEditor.cxx index e827774b78602..58cae44994295 100644 --- a/gui/ged/src/TAttLineEditor.cxx +++ b/gui/ged/src/TAttLineEditor.cxx @@ -151,9 +151,9 @@ void TAttLineEditor::SetModel(TObject* obj) void TAttLineEditor::DoLineColor(Pixel_t color) { if (fAvoidSignal) return; - fAttLine->SetLineColor(TColor::GetColor(color)); + fAttLine->SetLineColor(TVirtualX::Pixel2Number(color)); - if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) { + if (TColor *tcolor = gROOT->GetColor(TVirtualX::Pixel2Number(color))) { fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000)); fAlphaField->SetNumber(tcolor->GetAlpha()); } diff --git a/gui/ged/src/TAttMarkerEditor.cxx b/gui/ged/src/TAttMarkerEditor.cxx index fbbe502fdab20..b54006e8e1a35 100644 --- a/gui/ged/src/TAttMarkerEditor.cxx +++ b/gui/ged/src/TAttMarkerEditor.cxx @@ -161,9 +161,9 @@ void TAttMarkerEditor::SetModel(TObject* obj) void TAttMarkerEditor::DoMarkerColor(Pixel_t color) { if (fAvoidSignal) return; - fAttMarker->SetMarkerColor(TColor::GetColor(color)); + fAttMarker->SetMarkerColor(TVirtualX::Pixel2Number(color)); - if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) { + if (TColor *tcolor = gROOT->GetColor(TVirtualX::Pixel2Number(color))) { fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000)); fAlphaField->SetNumber(tcolor->GetAlpha()); } diff --git a/gui/ged/src/TAttTextEditor.cxx b/gui/ged/src/TAttTextEditor.cxx index c711e972872a9..87851d315e5c6 100644 --- a/gui/ged/src/TAttTextEditor.cxx +++ b/gui/ged/src/TAttTextEditor.cxx @@ -163,9 +163,9 @@ void TAttTextEditor::SetModel(TObject* obj) void TAttTextEditor::DoTextColor(Pixel_t color) { if (fAvoidSignal) return; - fAttText->SetTextColor(TColor::GetColor(color)); + fAttText->SetTextColor(TVirtualX::Pixel2Number(color)); - if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) { + if (TColor *tcolor = gROOT->GetColor(TVirtualX::Pixel2Number(color))) { fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000)); fAlphaField->SetNumber(tcolor->GetAlpha()); } @@ -198,7 +198,7 @@ Bool_t TAttTextEditor::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t Bool_t b = kFALSE; if (GET_MSG(msg) == kC_COLORSEL && GET_SUBMSG(msg) == kCOL_SELCHANGED) { - if (parm1 != 0) fAttText->SetTextColor(TColor::GetColor(parm2)); + if (parm1 != 0) fAttText->SetTextColor(TVirtualX::Pixel2Number(parm2)); b = kTRUE; // SendMessage(fMsgWindow, msg, parm1, parm2); } diff --git a/gui/ged/src/TAxisEditor.cxx b/gui/ged/src/TAxisEditor.cxx index 8757c20ddb90b..a6b3e49e60c2a 100644 --- a/gui/ged/src/TAxisEditor.cxx +++ b/gui/ged/src/TAxisEditor.cxx @@ -372,7 +372,7 @@ void TAxisEditor::SetModel(TObject* obj) void TAxisEditor::DoAxisColor(Pixel_t color) { if (fAvoidSignal) return; - fAxis->SetAxisColor(TColor::GetColor(color)); + fAxis->SetAxisColor(TVirtualX::Pixel2Number(color)); Update(); } @@ -476,7 +476,7 @@ void TAxisEditor::DoTitle(const char *text) void TAxisEditor::DoTitleColor(Pixel_t color) { if (fAvoidSignal) return; - fAxis->SetTitleColor(TColor::GetColor(color)); + fAxis->SetTitleColor(TVirtualX::Pixel2Number(color)); Update(); } @@ -541,7 +541,7 @@ void TAxisEditor::DoTitleRotated() void TAxisEditor::DoLabelColor(Pixel_t color) { if (fAvoidSignal) return; - fAxis->SetLabelColor(TColor::GetColor(color)); + fAxis->SetLabelColor(TVirtualX::Pixel2Number(color)); Update(); } diff --git a/gui/ged/src/TH2Editor.cxx b/gui/ged/src/TH2Editor.cxx index a6a0fde1f349d..610c17c8259f8 100644 --- a/gui/ged/src/TH2Editor.cxx +++ b/gui/ged/src/TH2Editor.cxx @@ -2681,7 +2681,7 @@ void TH2Editor::DoFillColor(Pixel_t color) { if (fAvoidSignal || !fGedEditor->GetPad()) return; fGedEditor->GetPad()->cd(); - fGedEditor->GetPad()->SetFrameFillColor(TColor::GetColor(color)); + fGedEditor->GetPad()->SetFrameFillColor(TVirtualX::Pixel2Number(color)); Update(); } diff --git a/gui/ged/src/TPieEditor.cxx b/gui/ged/src/TPieEditor.cxx index e590743678667..0234b6ac59c4a 100644 --- a/gui/ged/src/TPieEditor.cxx +++ b/gui/ged/src/TPieEditor.cxx @@ -367,7 +367,7 @@ void TPieEditor::DoTextChange() if (fAvoidSignal) return; // font color - fPie->SetTextColor(TColor::GetColor(fColorSelect->GetColor())); + fPie->SetTextColor(TVirtualX::Pixel2Number(fColorSelect->GetColor())); // font type Int_t fontPrec = fPie->GetTextFont()%10; diff --git a/gui/ged/src/TStyleManager.cxx b/gui/ged/src/TStyleManager.cxx index 1474516d8a055..d303814c86797 100644 --- a/gui/ged/src/TStyleManager.cxx +++ b/gui/ged/src/TStyleManager.cxx @@ -4657,7 +4657,7 @@ void TStyleManager::CloseWindow() void TStyleManager::ModFillColor() { - fCurSelStyle->SetFillColor(TColor::GetColor(fFillColor->GetColor())); + fCurSelStyle->SetFillColor(TVirtualX::Pixel2Number(fFillColor->GetColor())); DoEditor(); } @@ -4693,7 +4693,7 @@ void TStyleManager::ModHatchesSpacing() void TStyleManager::ModMarkerColor() { - fCurSelStyle->SetMarkerColor(TColor::GetColor(fMarkerColor->GetColor())); + fCurSelStyle->SetMarkerColor(TVirtualX::Pixel2Number(fMarkerColor->GetColor())); DoEditor(); } @@ -4729,7 +4729,7 @@ void TStyleManager::ModScreenFactor() void TStyleManager::ModLineColor() { - fCurSelStyle->SetLineColor(TColor::GetColor(fLineColor->GetColor())); + fCurSelStyle->SetLineColor(TVirtualX::Pixel2Number(fLineColor->GetColor())); DoEditor(); } @@ -4764,7 +4764,7 @@ void TStyleManager::ModLineStyleEdit() void TStyleManager::ModTextColor() { - fCurSelStyle->SetTextColor(TColor::GetColor(fTextColor->GetColor())); + fCurSelStyle->SetTextColor(TVirtualX::Pixel2Number(fTextColor->GetColor())); DoEditor(); } @@ -4837,7 +4837,7 @@ void TStyleManager::ModTextAngle() void TStyleManager::ModCanvasColor() { - fCurSelStyle->SetCanvasColor(TColor::GetColor(fCanvasColor->GetColor())); + fCurSelStyle->SetCanvasColor(TVirtualX::Pixel2Number(fCanvasColor->GetColor())); DoEditor(); } @@ -4920,7 +4920,7 @@ void TStyleManager::ModOptDateBool() void TStyleManager::ModAttDateTextColor() { // To modify this entry, the user must have check 'Show' - fCurSelStyle->GetAttDate()->SetTextColor(TColor::GetColor(fAttDateTextColor->GetColor())); + fCurSelStyle->GetAttDate()->SetTextColor(TVirtualX::Pixel2Number(fAttDateTextColor->GetColor())); DoEditor(); } @@ -5082,7 +5082,7 @@ void TStyleManager::ModPadBorderSize() void TStyleManager::ModPadColor() { - fCurSelStyle->SetPadColor(TColor::GetColor(fPadColor->GetColor())); + fCurSelStyle->SetPadColor(TVirtualX::Pixel2Number(fPadColor->GetColor())); DoEditor(); } @@ -5127,7 +5127,7 @@ void TStyleManager::ModPadGridY() void TStyleManager::ModGridColor() { - fCurSelStyle->SetGridColor(TColor::GetColor(fGridColor->GetColor())); + fCurSelStyle->SetGridColor(TVirtualX::Pixel2Number(fGridColor->GetColor())); DoEditor(); } @@ -5154,7 +5154,7 @@ void TStyleManager::ModGridStyle() void TStyleManager::ModHistFillColor() { - fCurSelStyle->SetHistFillColor(TColor::GetColor(fHistFillColor->GetColor())); + fCurSelStyle->SetHistFillColor(TVirtualX::Pixel2Number(fHistFillColor->GetColor())); DoEditor(); } @@ -5172,7 +5172,7 @@ void TStyleManager::ModHistFillStyle() void TStyleManager::ModHistLineColor() { - fCurSelStyle->SetHistLineColor(TColor::GetColor(fHistLineColor->GetColor())); + fCurSelStyle->SetHistLineColor(TVirtualX::Pixel2Number(fHistLineColor->GetColor())); DoEditor(); } @@ -5254,7 +5254,7 @@ void TStyleManager::ModLegoInnerR() void TStyleManager::ModFrameFillColor() { - fCurSelStyle->SetFrameFillColor(TColor::GetColor(fFrameFillColor->GetColor())); + fCurSelStyle->SetFrameFillColor(TVirtualX::Pixel2Number(fFrameFillColor->GetColor())); DoEditor(); } @@ -5272,7 +5272,7 @@ void TStyleManager::ModFrameFillStyle() void TStyleManager::ModFrameLineColor() { - fCurSelStyle->SetFrameLineColor(TColor::GetColor(fFrameLineColor->GetColor())); + fCurSelStyle->SetFrameLineColor(TVirtualX::Pixel2Number(fFrameLineColor->GetColor())); DoEditor(); } @@ -5329,7 +5329,7 @@ void TStyleManager::ModFrameBorderSize() void TStyleManager::ModFuncColor() { - fCurSelStyle->SetFuncColor(TColor::GetColor(fFuncColor->GetColor())); + fCurSelStyle->SetFuncColor(TVirtualX::Pixel2Number(fFuncColor->GetColor())); DoEditor(); } @@ -5536,7 +5536,7 @@ void TStyleManager::ModXTitleSizeInPixels(Bool_t b) void TStyleManager::ModXTitleColor() { - fCurSelStyle->SetTitleColor(TColor::GetColor(fXTitleColor->GetColor()), "X"); + fCurSelStyle->SetTitleColor(TVirtualX::Pixel2Number(fXTitleColor->GetColor()), "X"); DoEditor(); } @@ -5600,7 +5600,7 @@ void TStyleManager::ModXLabelSizeInPixels(Bool_t b) void TStyleManager::ModXLabelColor() { - fCurSelStyle->SetLabelColor(TColor::GetColor(fXLabelColor->GetColor()), "X"); + fCurSelStyle->SetLabelColor(TVirtualX::Pixel2Number(fXLabelColor->GetColor()), "X"); DoEditor(); } @@ -5628,7 +5628,7 @@ void TStyleManager::ModXLabelFont() void TStyleManager::ModXAxisColor() { - fCurSelStyle->SetAxisColor(TColor::GetColor(fXAxisColor->GetColor()), "X"); + fCurSelStyle->SetAxisColor(TVirtualX::Pixel2Number(fXAxisColor->GetColor()), "X"); DoEditor(); } @@ -5706,7 +5706,7 @@ void TStyleManager::ModYTitleSizeInPixels(Bool_t b) void TStyleManager::ModYTitleColor() { - fCurSelStyle->SetTitleColor(TColor::GetColor(fYTitleColor->GetColor()), "Y"); + fCurSelStyle->SetTitleColor(TVirtualX::Pixel2Number(fYTitleColor->GetColor()), "Y"); DoEditor(); } @@ -5770,7 +5770,7 @@ void TStyleManager::ModYLabelSizeInPixels(Bool_t b) void TStyleManager::ModYLabelColor() { - fCurSelStyle->SetLabelColor(TColor::GetColor(fYLabelColor->GetColor()), "Y"); + fCurSelStyle->SetLabelColor(TVirtualX::Pixel2Number(fYLabelColor->GetColor()), "Y"); DoEditor(); } @@ -5798,7 +5798,7 @@ void TStyleManager::ModYLabelFont() void TStyleManager::ModYAxisColor() { - fCurSelStyle->SetAxisColor(TColor::GetColor(fYAxisColor->GetColor()), "Y"); + fCurSelStyle->SetAxisColor(TVirtualX::Pixel2Number(fYAxisColor->GetColor()), "Y"); DoEditor(); } @@ -5875,7 +5875,7 @@ void TStyleManager::ModZTitleSizeInPixels(Bool_t b) void TStyleManager::ModZTitleColor() { - fCurSelStyle->SetTitleColor(TColor::GetColor(fZTitleColor->GetColor()), "Z"); + fCurSelStyle->SetTitleColor(TVirtualX::Pixel2Number(fZTitleColor->GetColor()), "Z"); DoEditor(); } @@ -5939,7 +5939,7 @@ void TStyleManager::ModZLabelSizeInPixels(Bool_t b) void TStyleManager::ModZLabelColor() { - fCurSelStyle->SetLabelColor(TColor::GetColor(fZLabelColor->GetColor()), "Z"); + fCurSelStyle->SetLabelColor(TVirtualX::Pixel2Number(fZLabelColor->GetColor()), "Z"); DoEditor(); } @@ -5967,7 +5967,7 @@ void TStyleManager::ModZLabelFont() void TStyleManager::ModZAxisColor() { - fCurSelStyle->SetAxisColor(TColor::GetColor(fZAxisColor->GetColor()), "Z"); + fCurSelStyle->SetAxisColor(TVirtualX::Pixel2Number(fZAxisColor->GetColor()), "Z"); DoEditor(); } @@ -6020,7 +6020,7 @@ void TStyleManager::ModOptTitle() void TStyleManager::ModTitleFillColor() { - fCurSelStyle->SetTitleFillColor(TColor::GetColor(fTitleColor->GetColor())); + fCurSelStyle->SetTitleFillColor(TVirtualX::Pixel2Number(fTitleColor->GetColor())); DoEditor(); } @@ -6038,7 +6038,7 @@ void TStyleManager::ModTitleStyle() void TStyleManager::ModTitleTextColor() { - fCurSelStyle->SetTitleTextColor(TColor::GetColor(fTitleTextColor->GetColor())); + fCurSelStyle->SetTitleTextColor(TVirtualX::Pixel2Number(fTitleTextColor->GetColor())); DoEditor(); } @@ -6156,7 +6156,7 @@ void TStyleManager::ModTitleH() void TStyleManager::ModStatColor(Pixel_t color) { - fCurSelStyle->SetStatColor(TColor::GetColor(color)); + fCurSelStyle->SetStatColor(TVirtualX::Pixel2Number(color)); DoEditor(); } @@ -6174,7 +6174,7 @@ void TStyleManager::ModStatStyle(Style_t pattern) void TStyleManager::ModStatTextColor(Pixel_t color) { - fCurSelStyle->SetStatTextColor(TColor::GetColor(color)); + fCurSelStyle->SetStatTextColor(TVirtualX::Pixel2Number(color)); DoEditor(); } diff --git a/gui/gui/src/TGColorDialog.cxx b/gui/gui/src/TGColorDialog.cxx index 03eef9fdf46c7..ba4133bdb2cb7 100644 --- a/gui/gui/src/TGColorDialog.cxx +++ b/gui/gui/src/TGColorDialog.cxx @@ -1068,7 +1068,7 @@ TGColorDialog::TGColorDialog(const TGWindow *p, const TGWindow *m, fInitColor = 0; if (color) { fRetColor = color; - fRetTColor = gROOT->GetColor(TColor::GetColor(*color)); + fRetTColor = gROOT->GetColor(TVirtualX::Pixel2Number(*color)); fInitColor = *fRetColor; } fWaitFor = wait; @@ -1338,7 +1338,7 @@ void TGColorDialog::SetCurrentColor(Pixel_t col) return; } fInitColor = *fRetColor = col; - if((fRetTColor = gROOT->GetColor(TColor::GetColor(col)))) {}; + if((fRetTColor = gROOT->GetColor(TVirtualX::Pixel2Number(col)))) {}; fCurrentColor = col; fColors->SetColor(col); fSample->SetBackgroundColor(col); @@ -1373,7 +1373,7 @@ void TGColorDialog::CloseWindow() if (*fRetc != kMBOk) { ColorSelected(fInitColor); ULongptr_t ptr; - if((ptr = (ULongptr_t)gROOT->GetColor(TColor::GetColor(fInitColor)))) AlphaColorSelected(ptr); + if((ptr = (ULongptr_t)gROOT->GetColor(TVirtualX::Pixel2Number(fInitColor)))) AlphaColorSelected(ptr); } else { ColorSelected(*fRetColor); AlphaColorSelected((ULongptr_t)fRetTColor); @@ -1397,7 +1397,7 @@ void TGColorDialog::UpdateAlpha(ULong_t *c) Char_t tmp[20]; Double_t alpha; - if (TColor *color = gROOT->GetColor(TColor::GetColor(*c))) { + if (TColor *color = gROOT->GetColor(TVirtualX::Pixel2Number(*c))) { alpha = color->GetAlpha(); snprintf(tmp, 20, "%.1f", alpha); fAlb->Clear(); @@ -1485,7 +1485,7 @@ Bool_t TGColorDialog::ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t / *fRetColor = TVirtualX::RGB2Pixel(atoi(fRtb->GetString()), atoi(fGtb->GetString()), atoi(fBtb->GetString())); - if ((fRetTColor = gROOT->GetColor(TColor::GetColor(*fRetColor)))) { + if ((fRetTColor = gROOT->GetColor(TVirtualX::Pixel2Number(*fRetColor)))) { fRetTColor->SetAlpha(TMath::Max((Double_t)0, TMath::Min((Double_t)1, atof(fAlb->GetString())))); } @@ -1624,7 +1624,7 @@ void TGColorDialog::SetColorInfo(Int_t event, Int_t px, Int_t py, TObject *objec void TGColorDialog::DoPreview() { TColor *tcolor; - if ((tcolor = gROOT->GetColor(TColor::GetColor(fSample->GetBackground())))) { + if ((tcolor = gROOT->GetColor(TVirtualX::Pixel2Number(fSample->GetBackground())))) { tcolor->SetAlpha(TMath::Max((Double_t)0, TMath::Min((Double_t)1, atof(fAlb->GetString())))); } diff --git a/tree/treeviewer/src/TParallelCoordEditor.cxx b/tree/treeviewer/src/TParallelCoordEditor.cxx index 8b914bf5766cf..4d1220f0ee240 100644 --- a/tree/treeviewer/src/TParallelCoordEditor.cxx +++ b/tree/treeviewer/src/TParallelCoordEditor.cxx @@ -665,7 +665,7 @@ void TParallelCoordEditor::DoGlobalLineColor(Pixel_t a) if (TColor *color = gROOT->GetColor(fParallel->GetLineColor())) { color->SetAlpha(1); - color = gROOT->GetColor(TColor::GetColor(a)); + color = gROOT->GetColor(TVirtualX::Pixel2Number(a)); if (color) { color->SetAlpha((Float_t)fAlphaField->GetNumber()); fParallel->SetLineColor(color->GetNumber()); @@ -719,7 +719,7 @@ void TParallelCoordEditor::DoHistColorSelect(Pixel_t p) { if (fAvoidSignal) return; - Color_t col = TColor::GetColor(p); + Color_t col = TVirtualX::Pixel2Number(p); TIter next(fParallel->GetVarList()); TParallelCoordVar *var = nullptr; while ((var = (TParallelCoordVar*)next())) var->SetFillColor(col); @@ -864,7 +864,7 @@ void TParallelCoordEditor::DoSelectLineColor(Pixel_t a) if (fAvoidSignal) return; TParallelCoordSelect* sel = fParallel->GetCurrentSelection(); - if (sel) sel->SetLineColor(TColor::GetColor(a)); + if (sel) sel->SetLineColor(TVirtualX::Pixel2Number(a)); fSelectionSelect->GetSelectedEntry()->SetBackgroundColor(a); Update(); } diff --git a/tree/treeviewer/src/TSpiderEditor.cxx b/tree/treeviewer/src/TSpiderEditor.cxx index bc08a938f3877..4b556c9f84628 100644 --- a/tree/treeviewer/src/TSpiderEditor.cxx +++ b/tree/treeviewer/src/TSpiderEditor.cxx @@ -329,7 +329,7 @@ void TSpiderEditor::DoAvLineColor(Pixel_t a) { if (fAvoidSignal) return; - fSpider->SetAverageLineColor(TColor::GetColor(a)); + fSpider->SetAverageLineColor(TVirtualX::Pixel2Number(a)); Update(); } @@ -340,7 +340,7 @@ void TSpiderEditor::DoAvFillColor(Pixel_t a) { if (fAvoidSignal) return; - fSpider->SetAverageFillColor(TColor::GetColor(a)); + fSpider->SetAverageFillColor(TVirtualX::Pixel2Number(a)); Update(); } diff --git a/tutorials/visualisation/gui/calendar.C b/tutorials/visualisation/gui/calendar.C index c7a310683d703..e6bf25adcd314 100644 --- a/tutorials/visualisation/gui/calendar.C +++ b/tutorials/visualisation/gui/calendar.C @@ -21,6 +21,7 @@ #include "TApplication.h" #include "TROOT.h" #include "TColor.h" +#include "TVirtualX.h" /////////////////////////// HTML calendar ////////////////////////////////////// @@ -407,7 +408,7 @@ void CalendarWindow::UpdateHTML() // table background pixel = fTableColor->GetColor(); - color = gROOT->GetColor(TColor::GetColor(pixel)); + color = gROOT->GetColor(TVirtualX::Pixel2Number(pixel)); if (color) { fHtmlText->fMonthTable.fBgColor = color->AsHexString(); @@ -415,7 +416,7 @@ void CalendarWindow::UpdateHTML() // cell background pixel = fCellColor->GetColor(); - color = gROOT->GetColor(TColor::GetColor(pixel)); + color = gROOT->GetColor(TVirtualX::Pixel2Number(pixel)); if (color) { fHtmlText->fMonthTable.fCellBgcolor = color->AsHexString(); From 9be67db852c46e4aaae1a52cdf4cc325ba0479f1 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:04:28 +0100 Subject: [PATCH 08/15] [colors] deprecate TColor::GetColor(pixel) While this methods uses gVirtualX - it was moved to TVirtualX and replaced in all places --- core/base/inc/TColor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/inc/TColor.h b/core/base/inc/TColor.h index 3385dc783442f..f8be6fa1eb26b 100644 --- a/core/base/inc/TColor.h +++ b/core/base/inc/TColor.h @@ -86,7 +86,7 @@ class TColor : public TNamed { static Int_t GetColor(const char *hexcolor); static Int_t GetColor(Float_t r, Float_t g, Float_t b, Float_t a = 1.); static Int_t GetColor(Int_t r, Int_t g, Int_t b, Float_t a = 1.); - static Int_t GetColor(ULong_t pixel); + static Int_t R__DEPRECATED(7,00, "Use TVirtualX::Pixel2Number instead") GetColor(ULong_t pixel); static Int_t GetColorBright(Int_t color); static Int_t GetColorDark(Int_t color); static Int_t GetColorTransparent(Int_t color, Float_t a); From 4170bedba49b0ba99305e62e6eceec2796f4a0ab Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:19:32 +0100 Subject: [PATCH 09/15] [gui] use gVirtualX->GetPixel(number) instead of TColor::GetPixel TColor::GetPixel() forces graphics initialization which is really big overhead and will be removed in ROOT7 --- graf3d/gviz3d/src/TStructNodeProperty.cxx | 2 +- gui/gui/src/TGColorDialog.cxx | 2 +- gui/gui/src/TGColorSelect.cxx | 2 +- gui/gui/src/TGLabel.cxx | 2 +- gui/gui/src/TGTextEntry.cxx | 2 +- gui/gui/src/TRootBrowserLite.cxx | 2 +- gui/guibuilder/src/TGuiBldNameFrame.cxx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/graf3d/gviz3d/src/TStructNodeProperty.cxx b/graf3d/gviz3d/src/TStructNodeProperty.cxx index fbb00919a6d9d..cee0e224d4d30 100644 --- a/graf3d/gviz3d/src/TStructNodeProperty.cxx +++ b/graf3d/gviz3d/src/TStructNodeProperty.cxx @@ -119,7 +119,7 @@ TColor TStructNodeProperty::GetColor() const Pixel_t TStructNodeProperty::GetPixel() const { - return fColor.GetPixel(); + return gVirtualX->GetPixel(fColor.GetNumber()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/gui/gui/src/TGColorDialog.cxx b/gui/gui/src/TGColorDialog.cxx index ba4133bdb2cb7..4a58614ce8a97 100644 --- a/gui/gui/src/TGColorDialog.cxx +++ b/gui/gui/src/TGColorDialog.cxx @@ -1602,7 +1602,7 @@ void TGColorDialog::SetColorInfo(Int_t event, Int_t px, Int_t py, TObject *objec if (n < 0) return; TColor *color = gROOT->GetColor(n); if (!color) return; - ULong_t pcolor = color->GetPixel(); + ULong_t pcolor = gVirtualX->GetPixel(color->GetNumber()); if (event == kButton1Down) { UpdateRGBentries(&pcolor); UpdateHLSentries(&pcolor); diff --git a/gui/gui/src/TGColorSelect.cxx b/gui/gui/src/TGColorSelect.cxx index eb0eda22a1efd..dd45565b29050 100644 --- a/gui/gui/src/TGColorSelect.cxx +++ b/gui/gui/src/TGColorSelect.cxx @@ -390,7 +390,7 @@ void TGColorPopup::PreviewAlphaColor(ULongptr_t color) if (fClient->IsEditable()) return; TColor *tcolor = (TColor *)color; - fCurrentColor = tcolor->GetPixel(); + fCurrentColor = gVirtualX->GetPixel(tcolor->GetNumber()); SendMessage(fMsgWindow, MK_MSG(kC_COLORSEL, kCOL_SELCHANGED), 0, (ULongptr_t)tcolor); } diff --git a/gui/gui/src/TGLabel.cxx b/gui/gui/src/TGLabel.cxx index 7875c1c4b2af2..4df99b8c96e7f 100644 --- a/gui/gui/src/TGLabel.cxx +++ b/gui/gui/src/TGLabel.cxx @@ -383,7 +383,7 @@ void TGLabel::SetTextColor(Pixel_t color, Bool_t global) void TGLabel::SetTextColor(TColor *color, Bool_t global) { if (color) { - SetTextColor(color->GetPixel(), global); + SetTextColor(gVirtualX->GetPixel(color->GetNumber()), global); } } diff --git a/gui/gui/src/TGTextEntry.cxx b/gui/gui/src/TGTextEntry.cxx index 01b65a528c5e0..5f2c657a0d965 100644 --- a/gui/gui/src/TGTextEntry.cxx +++ b/gui/gui/src/TGTextEntry.cxx @@ -1776,7 +1776,7 @@ void TGTextEntry::SetTextColor(Pixel_t color, Bool_t local) void TGTextEntry::SetTextColor(TColor *color, Bool_t local) { if (color) { - SetTextColor(color->GetPixel(), local); + SetTextColor(gVirtualX->GetPixel(color->GetNumber()), local); } } diff --git a/gui/gui/src/TRootBrowserLite.cxx b/gui/gui/src/TRootBrowserLite.cxx index bdd460ab79838..a7b08b8bc2af9 100644 --- a/gui/gui/src/TRootBrowserLite.cxx +++ b/gui/gui/src/TRootBrowserLite.cxx @@ -3041,7 +3041,7 @@ void TRootBrowserLite::BrowseTextFile(const char *file) kSunkenFrame | kDoubleBorder); TColor *col = gROOT->GetColor(19); if (col) - fTextEdit->SetBackgroundColor(col->GetPixel()); + fTextEdit->SetBackgroundColor(gVirtualX->GetPixel(col->GetNumber())); if (TGSearchDialog::SearchDialog()) { TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGTextEdit", fTextEdit, "Search(char *,Bool_t,Bool_t)"); diff --git a/gui/guibuilder/src/TGuiBldNameFrame.cxx b/gui/guibuilder/src/TGuiBldNameFrame.cxx index 3e31b7f533ff2..c72019ddaab54 100644 --- a/gui/guibuilder/src/TGuiBldNameFrame.cxx +++ b/gui/guibuilder/src/TGuiBldNameFrame.cxx @@ -107,7 +107,7 @@ TGuiBldNameFrame::TGuiBldNameFrame(const TGWindow *p, TGuiBldEditor *editor) : void TGuiBldNameFrame::DoRedraw() { //TColor *col = gROOT->GetColor(29); - //TRootGuiBuilder::SetBgndColor(fTitleFrame, col->GetPixel()); + //TRootGuiBuilder::SetBgndColor(fTitleFrame, gVirtualX->GetPixel(col->GetNumber())); TGCompositeFrame::DoRedraw(); } From a7548727f8196e811d9646c8967f83e1c70e9c4c Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:33:07 +0100 Subject: [PATCH 10/15] [colors] move TColor::GetPixel() implementation to TVirtualX class It includes application and colors initialisation inside Number2Pixel method --- core/base/src/TVirtualX.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/core/base/src/TVirtualX.cxx b/core/base/src/TVirtualX.cxx index 85197d601c79a..99a3ab9e1b7ea 100644 --- a/core/base/src/TVirtualX.cxx +++ b/core/base/src/TVirtualX.cxx @@ -32,6 +32,7 @@ An instance of TVirtualX itself defines a batch interface to the graphics system #include "TColor.h" #include "TError.h" #include "TROOT.h" +#include "TApplication.h" Atom_t gWM_DELETE_WINDOW; @@ -2843,11 +2844,20 @@ ULong_t TVirtualX::Number2Pixel(Int_t ci) { TColor::InitializeColors(); auto color = gROOT->GetColor(ci); - if (color) - return color->GetPixel(); + if (!color) { + ::Warning("TVirtualX::Number2Pixel", "color with index %d not defined", ci); + return 0; + } - ::Warning("TVirtualX::Number2Pixel", "color with index %d not defined", ci); - return 0; + if (!gVirtualX || gROOT->IsBatch()) + return 0; + + if (gApplication) { + TApplication::NeedGraphicsLibs(); + gApplication->InitializeGraphics(gROOT->IsWebDisplay()); + } + + return gVirtualX->GetPixel(color->GetNumber()); } //////////////////////////////////////////////////////////////////////////////// From afb5874287e716c04317bd7e1255c34dcc6f1f5a Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:25:52 +0100 Subject: [PATCH 11/15] [colors] deprecate TColor::GetPixel() It redirects to gVirtualX method and better should be used directly via gVirtaulX instance. All usage in ROOT already was removed --- core/base/inc/TColor.h | 2 +- core/base/src/TColor.cxx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/base/inc/TColor.h b/core/base/inc/TColor.h index f8be6fa1eb26b..7fa0c6355d958 100644 --- a/core/base/inc/TColor.h +++ b/core/base/inc/TColor.h @@ -57,7 +57,7 @@ class TColor : public TNamed { virtual void GetHLS(Float_t &h, Float_t &l, Float_t &s) const { h=GetHue(); l=GetLight(); s=GetSaturation(); } Int_t GetNumber() const { return fNumber; } - ULong_t GetPixel() const; + ULong_t R__DEPRECATED(7,00, "Use gVirtualX->GetPixel(number) instead") GetPixel() const; Float_t GetRed() const { return IsGrayscale() ? GetGrayscale() : fRed; } Float_t GetGreen() const { return IsGrayscale() ? GetGrayscale() : fGreen; } Float_t GetBlue() const { return IsGrayscale() ? GetGrayscale() : fBlue; } diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index f12d3b37bffb2..e8d5d21c13119 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -1571,7 +1571,9 @@ Bool_t TColor::DefinedColors(Int_t set_always_on) } //////////////////////////////////////////////////////////////////////////////// -/// Return pixel value corresponding to this color. This pixel value can +/// @deprecated Use gVirtualX->GetPixel(number) instead +/// +/// @brief Return pixel value corresponding to this color. This pixel value can /// be used in the GUI classes. This call does not work in batch mode since /// it needs to communicate with the graphics system. From 3e3eb7a4232315dc2ce1a75378d91a153e984639 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 16:53:00 +0100 Subject: [PATCH 12/15] [colors] provide static TColor::ConfigureColorsHandler() method It configures actual number of color planes and assign callback function which is invoked when color will be updated. Make private and only available for TVirtualX class - just to decouple last dependency between gVirtualX and TColor --- core/base/inc/TColor.h | 4 ++++ core/base/src/TColor.cxx | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/base/inc/TColor.h b/core/base/inc/TColor.h index 7fa0c6355d958..12531150e3f94 100644 --- a/core/base/inc/TColor.h +++ b/core/base/inc/TColor.h @@ -18,8 +18,10 @@ #include class TArrayI; +class TVirtualX; class TColor : public TNamed { + friend class TVirtualX; // to let configure colors change handler protected: Int_t fNumber; ///< Color number identifier private: @@ -34,6 +36,8 @@ class TColor : public TNamed { void Allocate(); static Float_t HLStoRGB1(Float_t rn1, Float_t rn2, Float_t huei); + static void ConfigureColorsHandler(Int_t depth, void (*colorfuncptr)(TColor *)); + public: TColor(); TColor(Int_t color, Float_t r, Float_t g, Float_t b, const char *name="", Float_t a = 1); diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index e8d5d21c13119..16031a7f383e9 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -46,11 +46,12 @@ namespace { static Int_t gHighestColorIndex = 0; ///< Highest color index defined static Float_t gColorThreshold = -1.; ///< Color threshold used by GetColor +static Int_t gNColorPlanes = 24; ///< number of color planes, set from TVirtualX +static void (*gColorHandler)(TColor*) = nullptr; ///< callback for handling new colors static Int_t gDefinedColors = 0; ///< Number of defined colors. static Int_t gLastDefinedColors = 649; ///< Previous number of defined colors static Int_t gPaletteType = 0; ///< selected palete type - #define fgGrayscaleMode TColor__GrayScaleMode() #define fgPalette TColor__Palette() #define fgPalettesList TColor__PalettesList() @@ -2010,6 +2011,19 @@ void TColor::SetColorThreshold(Float_t t) gColorThreshold = t; } +//////////////////////////////////////////////////////////////////////////////// +/// This method defines number of color planes in the current graphic display +/// +/// Normally set by TVirtualX-derived class when display is initialized +/// and used for color precision calculations. To set user-defined precision +/// better use TColor::SetColorThreshold() method + +void TColor::ConfigureColorsHandler(Int_t depth, void (*colorfuncptr)(TColor*)) +{ + gNColorPlanes = depth; + gColorHandler = colorfuncptr; +} + //////////////////////////////////////////////////////////////////////////////// /// Static method returning color number for color specified by /// r, g and b. The r,g,b should be in the range [0,255]. From 64e7455d8c5aeaff2e5d181cd91439dfc90e09e4 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 17:44:52 +0100 Subject: [PATCH 13/15] [virtualx] implement TVirtualX::ConfigureColorsHandler() Simple callback to update color instance --- core/base/inc/TVirtualX.h | 2 ++ core/base/src/TVirtualX.cxx | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/core/base/inc/TVirtualX.h b/core/base/inc/TVirtualX.h index 30286721c79a3..e567f862526e1 100644 --- a/core/base/inc/TVirtualX.h +++ b/core/base/inc/TVirtualX.h @@ -56,6 +56,8 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe protected: EDrawMode fDrawMode; //Drawing mode + static void ConfigureColorsHandler(); + public: TVirtualX(): fDrawMode() {} TVirtualX(const char *name, const char *title); diff --git a/core/base/src/TVirtualX.cxx b/core/base/src/TVirtualX.cxx index 99a3ab9e1b7ea..816038183d907 100644 --- a/core/base/src/TVirtualX.cxx +++ b/core/base/src/TVirtualX.cxx @@ -2875,3 +2875,22 @@ Int_t TVirtualX::Pixel2Number(ULong_t pixel) return TColor::GetColor(r, g, b); } + +namespace { + void updateTColorInstance(TColor *color) + { + if (gVirtualX && color) + gVirtualX->SetRGB(color->GetNumber(), color->GetRed(), color->GetGreen(), color->GetBlue()); + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// Protected method to configure handler when color is modified and need to be updated +/// system dependent pixel value. Pixel values can be obtained, e.g., + +void TVirtualX::ConfigureColorsHandler() +{ + Int_t nplanes = 0; + gVirtualX->GetPlanes(nplanes); + TColor::ConfigureColorsHandler(nplanes, updateTColorInstance); +} From 76460ca4fd5f2cce702cbe1a0b61df46040481e9 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 17:03:16 +0100 Subject: [PATCH 14/15] [virtualx] configure colors handler when open display In all TVirtualX implementations configure colors handler immediately after display is intitialized. Allows "on-the-fly" update colors --- graf2d/cocoa/src/TGCocoa.mm | 3 +++ graf2d/win32gdk/src/TGWin32.cxx | 3 +++ graf2d/x11/src/TGX11.cxx | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/graf2d/cocoa/src/TGCocoa.mm b/graf2d/cocoa/src/TGCocoa.mm index 1f759f949fc3c..79f06b62ffd3b 100644 --- a/graf2d/cocoa/src/TGCocoa.mm +++ b/graf2d/cocoa/src/TGCocoa.mm @@ -502,6 +502,9 @@ void FixAscii(std::vector &text) // session, i.e no windows message handler etc. if (CGMainDisplayID() == kCGNullDirectDisplay) return -1; + + ConfigureColorsHandler(); + return 0; } diff --git a/graf2d/win32gdk/src/TGWin32.cxx b/graf2d/win32gdk/src/TGWin32.cxx index a99c6b7400763..3da38487f9820 100644 --- a/graf2d/win32gdk/src/TGWin32.cxx +++ b/graf2d/win32gdk/src/TGWin32.cxx @@ -1045,6 +1045,9 @@ Int_t TGWin32::OpenDisplay(const char *dpyName) TGWin32VirtualXProxy::fMaxResponseTime = 1000; fHasTTFonts = TTFhandle::Init(); + + ConfigureColorsHandler(); + return 0; } diff --git a/graf2d/x11/src/TGX11.cxx b/graf2d/x11/src/TGX11.cxx index db4fc39c333e4..b833296f777fa 100644 --- a/graf2d/x11/src/TGX11.cxx +++ b/graf2d/x11/src/TGX11.cxx @@ -922,6 +922,9 @@ void TGX11::FindBestVisual() fBlackPixel = BlackPixel((Display*)fDisplay, fScreenNumber); fWhitePixel = WhitePixel((Display*)fDisplay, fScreenNumber); } + + ConfigureColorsHandler(); + if (gDebug > 1) Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s", fVisual->visualid, fDepth, fVisual->c_class, @@ -987,6 +990,8 @@ void TGX11::FindUsableVisual(RXVisualInfo *vlist, Int_t nitems) XFreeColormap((Display*)fDisplay, attr.colormap); } XSetErrorHandler(oldErrorHandler); + + ConfigureColorsHandler(); } //////////////////////////////////////////////////////////////////////////////// From 6cbe155a21df15faf39cb77bcf82284223c0e3fd Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Fri, 20 Nov 2026 17:07:21 +0100 Subject: [PATCH 15/15] [colors] use configured color handlers instead of gVirtualX calls TVirtualX has to initialize handler and planes number when calling OpenDisplay This handler invoked when color is changes - in private Allocate() method In ROOT7 one can fully remove TVirtualX usage then --- core/base/src/TColor.cxx | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index 16031a7f383e9..569a60694f4c0 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -1881,11 +1881,10 @@ void TColor::SetRGB(Float_t r, Float_t g, Float_t b) RGBtoHLS(r, g, b, fHue, fLight, fSaturation); SetTitle(AsHexString()); - Int_t nplanes = 16; - if (gVirtualX) gVirtualX->GetPlanes(nplanes); - if (nplanes == 0) nplanes = 16; + Int_t nplanes = gNColorPlanes; + if (nplanes <= 0) nplanes = 16; - // allocate color now (can be delayed when we have a large colormap) + // update color now (can be delayed when we have a large colormap) #ifndef R__WIN32 if (nplanes < 15) #endif @@ -1925,8 +1924,8 @@ void TColor::SetRGB(Float_t r, Float_t g, Float_t b) void TColor::Allocate() { - if (gVirtualX && !gROOT->IsBatch()) - gVirtualX->SetRGB(fNumber, GetRed(), GetGreen(), GetBlue()); + if (gColorHandler && !gROOT->IsBatch()) + gColorHandler(this); } //////////////////////////////////////////////////////////////////////////////// @@ -2073,14 +2072,12 @@ Int_t TColor::GetColor(Int_t r, Int_t g, Int_t b, Float_t a) TIter next(colors); Float_t thres; - if (gColorThreshold >= 0) { + if (gColorThreshold >= 0) thres = gColorThreshold; - } else { - Int_t nplanes = 24; + else if ((gNColorPlanes > 0) && (gNColorPlanes <= 16)) + thres = 1.0f/31.0f; // 5 bits per color : 0 - 0x1F ! + else thres = 1.0f/255.0f; // 8 bits per color : 0 - 0xFF ! - if (gVirtualX) gVirtualX->GetPlanes(nplanes); - if ((nplanes > 0) && (nplanes <= 16)) thres = 1.0f/31.0f; // 5 bits per color : 0 - 0x1F ! - } // Loop over all defined colors while (auto color = static_cast(next())) { @@ -2593,16 +2590,17 @@ Bool_t TColor::IsGrayscale() void TColor::SetGrayscale(Bool_t set /*= kTRUE*/) { - if (fgGrayscaleMode == set) return; + if (fgGrayscaleMode == set) + return; fgGrayscaleMode = set; - if (!gVirtualX || gROOT->IsBatch()) return; + if (gROOT->IsBatch()) + return; TColor::InitializeColors(); - TIter iColor(gROOT->GetListOfColors()); - TColor* color = nullptr; - while ((color = (TColor*) iColor())) + TIter iter(gROOT->GetListOfColors()); + while (auto color = static_cast (iter())) color->Allocate(); }