|
1 | | -import { settings, gStyle, create, BIT, clTPaveText, kTitle } from '../core.mjs'; |
| 1 | +import { settings, create, BIT } from '../core.mjs'; |
2 | 2 | import { scaleLinear, pointer as d3_pointer } from '../d3.mjs'; |
3 | 3 | import { DrawOptions, buildSvgCurve, makeTranslate } from '../base/BasePainter.mjs'; |
4 | 4 | import { ObjectPainter, getElementMainPainter } from '../base/ObjectPainter.mjs'; |
5 | | -import { TPavePainter, kPosTitle } from '../hist/TPavePainter.mjs'; |
| 5 | +import { drawObjectTitle } from '../hist/TPavePainter.mjs'; |
6 | 6 | import { ensureTCanvas } from '../gpad/TCanvasPainter.mjs'; |
7 | 7 | import { TooltipHandler } from '../gpad/TFramePainter.mjs'; |
8 | 8 | import { assignContextMenu, kNoReorder } from '../gui/menu.mjs'; |
@@ -496,9 +496,15 @@ class TGraphPolarPainter extends ObjectPainter { |
496 | 496 | return true; |
497 | 497 | } |
498 | 498 |
|
| 499 | + /** @summary Draw TGraphPolar title */ |
| 500 | + async drawTitle(first_time) { |
| 501 | + return drawObjectTitle(this, first_time, this._draw_axis, !this.getObject()?.TestBit(kNoTitle)); |
| 502 | + } |
| 503 | + |
499 | 504 | /** @summary Redraw TGraphPolar */ |
500 | | - redraw() { |
501 | | - return this.drawGraphPolar().then(() => this.updateTitle()); |
| 505 | + async redraw() { |
| 506 | + return this.drawGraphPolar() |
| 507 | + .then(() => this.drawTitle()); |
502 | 508 | } |
503 | 509 |
|
504 | 510 | /** @summary Drawing TGraphPolar */ |
@@ -681,64 +687,6 @@ class TGraphPolarPainter extends ObjectPainter { |
681 | 687 | return res; |
682 | 688 | } |
683 | 689 |
|
684 | | - /** @summary Only redraw histogram title |
685 | | - * @return {Promise} with painter */ |
686 | | - async updateTitle() { |
687 | | - // case when histogram drawn over other histogram (same option) |
688 | | - if (!this._draw_axis) |
689 | | - return this; |
690 | | - |
691 | | - const tpainter = this.getPadPainter()?.findPainterFor(null, kTitle, clTPaveText), |
692 | | - pt = tpainter?.getObject(); |
693 | | - |
694 | | - if (!tpainter || !pt) |
695 | | - return this; |
696 | | - |
697 | | - const gr = this.getObject(), |
698 | | - draw_title = !gr.TestBit(kNoTitle) && (gStyle.fOptTitle > 0); |
699 | | - |
700 | | - pt.Clear(); |
701 | | - if (draw_title) |
702 | | - pt.AddText(gr.fTitle); |
703 | | - return tpainter.redraw().then(() => this); |
704 | | - } |
705 | | - |
706 | | - |
707 | | - /** @summary Draw histogram title |
708 | | - * @return {Promise} with painter */ |
709 | | - async drawTitle() { |
710 | | - // case when histogram drawn over other histogram (same option) |
711 | | - if (!this._draw_axis) |
712 | | - return this; |
713 | | - |
714 | | - const gr = this.getObject(), |
715 | | - st = gStyle, |
716 | | - draw_title = !gr.TestBit(kNoTitle) && (st.fOptTitle > 0), |
717 | | - pp = this.getPadPainter(); |
718 | | - |
719 | | - let pt = pp.findInPrimitives(kTitle, clTPaveText); |
720 | | - |
721 | | - if (pt) { |
722 | | - pt.Clear(); |
723 | | - if (draw_title) |
724 | | - pt.AddText(gr.fTitle); |
725 | | - return this; |
726 | | - } |
727 | | - |
728 | | - pt = create(clTPaveText); |
729 | | - Object.assign(pt, { |
730 | | - fName: kTitle, fFillColor: st.fTitleColor, fFillStyle: st.fTitleStyle, fBorderSize: st.fTitleBorderSize, |
731 | | - fTextFont: st.fTitleFont, fTextSize: st.fTitleFontSize, fTextColor: st.fTitleTextColor, fTextAlign: 22 |
732 | | - }); |
733 | | - |
734 | | - if (draw_title) |
735 | | - pt.AddText(gr.fTitle); |
736 | | - return TPavePainter.draw(pp, pt, kPosTitle).then(p => { |
737 | | - p?.setSecondaryId(this, kTitle); |
738 | | - return this; |
739 | | - }); |
740 | | - } |
741 | | - |
742 | 690 | /** @summary Show tooltip */ |
743 | 691 | showTooltip(hint) { |
744 | 692 | let ttcircle = this.getG()?.selectChild('.tooltip_bin'); |
@@ -797,7 +745,7 @@ class TGraphPolarPainter extends ObjectPainter { |
797 | 745 | gram_painter?.setSecondaryId(painter, 'polargram'); |
798 | 746 | painter.addToPadPrimitives(); |
799 | 747 | return painter.drawGraphPolar(); |
800 | | - }).then(() => painter.drawTitle()); |
| 748 | + }).then(() => painter.drawTitle(true)); |
801 | 749 | } |
802 | 750 |
|
803 | 751 | } // class TGraphPolarPainter |
|
0 commit comments