Skip to content

Commit c4f87f7

Browse files
committed
Introduce TVirtualX::GetDrawModeW method
Used in TGLPadPainter to handle Crosshair cursor drawing.
1 parent 46222ae commit c4f87f7

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

core/base/inc/TVirtualX.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe
109109
virtual void SetAttMarker(WinContext_t wctxt, const TAttMarker &att);
110110
virtual void SetAttText(WinContext_t wctxt, const TAttText &att);
111111
virtual void SetDrawModeW(WinContext_t wctxt, EDrawMode mode);
112+
virtual EDrawMode GetDrawModeW(WinContext_t wctxt);
112113
virtual void ClearWindowW(WinContext_t wctxt);
113114
virtual void UpdateWindowW(WinContext_t wctxt, Int_t mode);
114115

core/base/src/TVirtualX.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ void TVirtualX::SetDrawModeW(WinContext_t /* wctxt */, EDrawMode mode)
436436
SetDrawMode(mode);
437437
}
438438

439+
////////////////////////////////////////////////////////////////////////////////
440+
/// Returns window draw mode
441+
442+
TVirtualX::EDrawMode TVirtualX::GetDrawModeW(WinContext_t /* wctxt */)
443+
{
444+
return GetDrawMode();
445+
}
446+
439447
////////////////////////////////////////////////////////////////////////////////
440448
/// Clear specified window
441449

graf2d/x11/inc/TGX11.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ class TGX11 : public TVirtualX {
231231
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override;
232232
void SetAttText(WinContext_t wctxt, const TAttText &att) override;
233233
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override;
234+
EDrawMode GetDrawModeW(WinContext_t wctxt) override;
234235
void ClearWindowW(WinContext_t wctxt) override;
235236
void UpdateWindowW(WinContext_t wctxt, Int_t mode) override;
236237

graf2d/x11/src/TGX11.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,6 +4677,8 @@ void TGX11::SetAttText(WinContext_t wctxt, const TAttText &att)
46774677
ctxt->fAttText = att;
46784678
}
46794679

4680+
////////////////////////////////////////////////////////////////////////////////
4681+
/// Set window draw mode
46804682

46814683
void TGX11::SetDrawModeW(WinContext_t wctxt, EDrawMode mode)
46824684
{
@@ -4694,3 +4696,12 @@ void TGX11::SetDrawModeW(WinContext_t wctxt, EDrawMode mode)
46944696

46954697
ctxt->fDrawMode = mode;
46964698
}
4699+
4700+
////////////////////////////////////////////////////////////////////////////////
4701+
/// Returns window draw mode
4702+
4703+
TVirtualX::EDrawMode TGX11::GetDrawModeW(WinContext_t wctxt)
4704+
{
4705+
auto ctxt = (XWindow_t *) wctxt;
4706+
return ctxt ? ctxt->fDrawMode : kCopy;
4707+
}

graf3d/gl/src/TGLPadPainter.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void TGLPadPainter::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
524524
//from TView3D::ExecuteRotateView. This means in fact,
525525
//that TView3D wants to draw itself in a XOR mode, via
526526
//gVirtualX.
527-
if (fWinContext) {
527+
if (fWinContext && (gVirtualX->GetDrawModeW(fWinContext) == TVirtualX::kInvert)) {
528528
gVirtualX->DrawLineW(fWinContext,
529529
gPad->XtoAbsPixel(x1), gPad->YtoAbsPixel(y1),
530530
gPad->XtoAbsPixel(x2), gPad->YtoAbsPixel(y2));
@@ -564,7 +564,8 @@ void TGLPadPainter::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
564564
void TGLPadPainter::DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)
565565
{
566566
if (fLocked) {
567-
if (fWinContext) {
567+
// this code used when crosshair cursor is drawn
568+
if (fWinContext && (gVirtualX->GetDrawModeW(fWinContext) == TVirtualX::kInvert)) {
568569
const Int_t px1 = gPad->UtoPixel(u1);
569570
const Int_t py1 = gPad->VtoPixel(v1);
570571
const Int_t px2 = gPad->UtoPixel(u2);

0 commit comments

Comments
 (0)