@@ -355,11 +355,10 @@ void TGLPadPainter::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
355355 // that TView3D wants to draw itself in a XOR mode, via
356356 // gVirtualX.
357357 // TODO: only here set line attributes to virtual x
358- if (fWinContext && ( gVirtualX -> GetDrawModeW ( fWinContext ) == TVirtualX:: kInvert )) {
358+ if (IsInvertMode ())
359359 gVirtualX ->DrawLineW (fWinContext ,
360360 gPad ->XtoAbsPixel (x1), gPad ->YtoAbsPixel (y1),
361361 gPad ->XtoAbsPixel (x2), gPad ->YtoAbsPixel (y2));
362- }
363362
364363 return ;
365364 }
@@ -395,13 +394,11 @@ void TGLPadPainter::DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
395394void TGLPadPainter::DrawLineNDC (Double_t u1, Double_t v1, Double_t u2, Double_t v2)
396395{
397396 if (fLocked ) {
398- // this code used when crosshair cursor is drawn
399- if (fWinContext && (gVirtualX ->GetDrawModeW (fWinContext ) == TVirtualX::kInvert )) {
400- // TODO: only here set line attributes to virtual x
397+ // this code used when crosshair cursor is drawn or interactive objects move
398+ if (IsInvertMode ())
401399 gVirtualX ->DrawLineW (fWinContext ,
402400 gPad ->UtoAbsPixel (u1), gPad ->VtoAbsPixel (v1),
403401 gPad ->UtoAbsPixel (u2), gPad ->VtoAbsPixel (v2));
404- }
405402 return ;
406403 }
407404
@@ -427,12 +424,11 @@ void TGLPadPainter::DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
427424 // that TView3D wants to draw itself in a XOR mode, via
428425 // gVirtualX.
429426 // TODO: only here set line attributes to virtual x
430- if (fWinContext && ( gVirtualX -> GetDrawModeW ( fWinContext ) == TVirtualX:: kInvert )) {
427+ if (IsInvertMode ())
431428 gVirtualX ->DrawBoxW (fWinContext ,
432429 gPad ->XtoAbsPixel (x1), gPad ->YtoAbsPixel (y1),
433430 gPad ->XtoAbsPixel (x2), gPad ->YtoAbsPixel (y2),
434431 (TVirtualX::EBoxMode) mode);
435- }
436432 return ;
437433 }
438434
@@ -521,9 +517,20 @@ void TGLPadPainter::DrawFillArea(Int_t n, const Float_t *x, const Float_t *y)
521517// //////////////////////////////////////////////////////////////////////////////
522518// /Draw poly-line in user coordinates.
523519
524- void TGLPadPainter::DrawPolyLine (Int_t n, const Double_t *x, const Double_t *y)
520+ template <class ValueType >
521+ void TGLPadPainter::DrawPolyLineHelper (Int_t n, const ValueType *x, const ValueType *y)
525522{
526- if (fLocked ) return ;
523+ if (fLocked ) {
524+ if (IsInvertMode () && (n > 1 )) {
525+ std::vector<TPoint> xy (n);
526+ for (Int_t i = 0 ; i < n; ++i) {
527+ xy[i].fX = (SCoord_t) gPad ->XtoAbsPixel (x[i]);
528+ xy[i].fY = (SCoord_t) gPad ->YtoAbsPixel (y[i]);
529+ }
530+ gVirtualX ->DrawPolyLineW (fWinContext , xy.size (), xy.data ());
531+ }
532+ return ;
533+ }
527534
528535 const Rgl::Pad::LineAttribSet lineAttribs (kTRUE , GetAttLine ().GetLineStyle (), fLimits .GetMaxLineWidth (), kTRUE , &GetAttLine ());
529536
@@ -556,25 +563,19 @@ void TGLPadPainter::DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y)
556563}
557564
558565// //////////////////////////////////////////////////////////////////////////////
559- // /Never called?
566+ // / Draw poly-line in user coordinates.
560567
561- void TGLPadPainter::DrawPolyLine (Int_t n, const Float_t *x, const Float_t *y)
568+ void TGLPadPainter::DrawPolyLine (Int_t n, const Double_t *x, const Double_t *y)
562569{
563- if (fLocked ) return ;
564-
565- const Rgl::Pad::LineAttribSet lineAttribs (kTRUE , GetAttLine ().GetLineStyle (), fLimits .GetMaxLineWidth (), kTRUE , &GetAttLine ());
566-
567- glBegin (GL_LINE_STRIP );
568-
569- for (Int_t i = 0 ; i < n; ++i)
570- glVertex2f (x[i], y[i]);
570+ DrawPolyLineHelper (n, x, y);
571+ }
571572
572- if (fIsHollowArea ) {
573- glVertex2f (x[0 ], y[0 ]);
574- fIsHollowArea = kFALSE ;
575- }
573+ // //////////////////////////////////////////////////////////////////////////////
574+ // / Draw poly-line in user coordinates.
576575
577- glEnd ();
576+ void TGLPadPainter::DrawPolyLine (Int_t n, const Float_t *x, const Float_t *y)
577+ {
578+ DrawPolyLineHelper (n, x, y);
578579}
579580
580581// //////////////////////////////////////////////////////////////////////////////
@@ -601,9 +602,9 @@ void TGLPadPainter::DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *
601602// / Returns true when invert mode is configured and painter in locked state
602603// / Used when non-opaque of objects moving is involved
603604
604- Bool_t TGLPadPainter::IsInteractiveMode ()
605+ Bool_t TGLPadPainter::IsInvertMode ()
605606{
606- return fLocked && fWinContext && (gVirtualX ->GetDrawModeW (fWinContext ) == TVirtualX::kInvert );
607+ return fWinContext && (gVirtualX ->GetDrawModeW (fWinContext ) == TVirtualX::kInvert );
607608}
608609
609610// //////////////////////////////////////////////////////////////////////////////
@@ -615,13 +616,13 @@ void TGLPadPainter::DrawPolyMarkerHelper(Int_t n, const ValueType *x, const Valu
615616 std::vector<TPoint> poly (n);
616617
617618 if (fLocked ) {
618- if (!IsInteractiveMode ())
619- return ;
620- for (Int_t i = 0 ; i < n; ++i) {
621- poly[i].fX = gPad ->XtoAbsPixel (x[i]);
622- poly[i].fY = gPad ->YtoAbsPixel (y[i]);
619+ if (IsInvertMode ()) {
620+ for (Int_t i = 0 ; i < n; ++i) {
621+ poly[i].fX = gPad ->XtoAbsPixel (x[i]);
622+ poly[i].fY = gPad ->YtoAbsPixel (y[i]);
623+ }
624+ gVirtualX ->DrawPolyMarkerW (fWinContext , poly.size (), poly.data ());
623625 }
624- gVirtualX ->DrawPolyMarkerW (fWinContext , poly.size (), poly.data ());
625626 return ;
626627 }
627628
0 commit comments