@@ -117,7 +117,7 @@ function addDragHandler(_painter, arg) {
117
117
arg . cleanup = true ;
118
118
119
119
if ( ! isFunc ( arg . getDrawG ) )
120
- arg . getDrawG = ( ) => painter ?. draw_g ;
120
+ arg . getDrawG = ( ) => painter ?. getG ( ) ;
121
121
122
122
function makeResizeElements ( group , handler ) {
123
123
function addElement ( cursor , d ) {
@@ -388,7 +388,7 @@ class TooltipHandler extends ObjectPainter {
388
388
processFrameTooltipEvent ( pnt , evnt ) {
389
389
if ( pnt ?. handler ) {
390
390
// special use of interactive handler in the frame painter
391
- const rect = this . draw_g ?. selectChild ( '.main_layer' ) ;
391
+ const rect = this . getG ( ) ?. selectChild ( '.main_layer' ) ;
392
392
if ( ! rect || rect . empty ( ) )
393
393
pnt = null ; // disable
394
394
else if ( pnt . touch && evnt ) {
@@ -735,8 +735,8 @@ class FrameInteractive extends TooltipHandler {
735
735
only_resize : true , minwidth : 20 , minheight : 20 , redraw : ( ) => this . sizeChanged ( ) } ) ;
736
736
}
737
737
738
- const top_rect = this . draw_g . selectChild ( 'path' ) ,
739
- main_svg = this . draw_g . selectChild ( '.main_layer' ) ;
738
+ const top_rect = this . getG ( ) . selectChild ( 'path' ) ,
739
+ main_svg = this . getG ( ) . selectChild ( '.main_layer' ) ;
740
740
741
741
top_rect . style ( 'pointer-events' , 'visibleFill' ) // let process mouse events inside frame
742
742
. style ( 'cursor' , 'default' ) ; // show normal cursor
@@ -937,7 +937,7 @@ class FrameInteractive extends TooltipHandler {
937
937
if ( evnt . buttons === this . _shifting_buttons ) {
938
938
const frame = this . getFrameSvg ( ) ,
939
939
pos = d3_pointer ( evnt , frame . node ( ) ) ,
940
- main_svg = this . draw_g . selectChild ( '.main_layer' ) ,
940
+ main_svg = this . getG ( ) . selectChild ( '.main_layer' ) ,
941
941
dx = pos0 [ 0 ] - pos [ 0 ] ,
942
942
dy = ( this . scales_ndim === 1 ) ? 0 : pos0 [ 1 ] - pos [ 1 ] ,
943
943
w = this . getFrameWidth ( ) , h = this . getFrameHeight ( ) ;
@@ -966,7 +966,7 @@ class FrameInteractive extends TooltipHandler {
966
966
/** @summary Shift scales on defined positions */
967
967
performScalesShift ( ) {
968
968
const w = this . getFrameWidth ( ) , h = this . getFrameHeight ( ) ,
969
- main_svg = this . draw_g . selectChild ( '.main_layer' ) ,
969
+ main_svg = this . getG ( ) . selectChild ( '.main_layer' ) ,
970
970
gr = this . getGrFuncs ( ) ,
971
971
xmin = gr . revertAxis ( 'x' , this . _shifting_dx ) ,
972
972
xmax = gr . revertAxis ( 'x' , this . _shifting_dx + w ) ,
@@ -1561,7 +1561,7 @@ class FrameInteractive extends TooltipHandler {
1561
1561
* @private */
1562
1562
moveTouchHandling ( evnt , kind , pos0 ) {
1563
1563
const frame = this . getFrameSvg ( ) ,
1564
- main_svg = this . draw_g . selectChild ( '.main_layer' ) ;
1564
+ main_svg = this . getG ( ) . selectChild ( '.main_layer' ) ;
1565
1565
let pos ;
1566
1566
1567
1567
try {
@@ -2451,7 +2451,7 @@ class TFramePainter extends FrameInteractive {
2451
2451
this . x2_handle ?. removeG ( ) ;
2452
2452
this . y2_handle ?. removeG ( ) ;
2453
2453
2454
- this . draw_g ?. selectChild ( '.axis_layer' ) . selectAll ( '*' ) . remove ( ) ;
2454
+ this . getG ( ) ?. selectChild ( '.axis_layer' ) . selectAll ( '*' ) . remove ( ) ;
2455
2455
this . #axes_drawn = this . #axes2_drawn = false ;
2456
2456
}
2457
2457
@@ -2478,24 +2478,22 @@ class TFramePainter extends FrameInteractive {
2478
2478
this . scale_ymin = this . scale_ymax = 0 ;
2479
2479
this . scale_zmin = this . scale_zmax = 0 ;
2480
2480
2481
- this . draw_g ?. selectChild ( '.main_layer' ) . selectAll ( '*' ) . remove ( ) ;
2482
- this . draw_g ?. selectChild ( '.upper_layer' ) . selectAll ( '*' ) . remove ( ) ;
2481
+ this . getG ( ) ?. selectChild ( '.main_layer' ) . selectAll ( '*' ) . remove ( ) ;
2482
+ this . getG ( ) ?. selectChild ( '.upper_layer' ) . selectAll ( '*' ) . remove ( ) ;
2483
2483
2484
2484
this . xaxis = null ;
2485
2485
this . yaxis = null ;
2486
2486
this . zaxis = null ;
2487
2487
2488
- if ( this . draw_g ) {
2489
- this . draw_g . selectAll ( '*' ) . remove ( ) ;
2490
- this . draw_g . on ( 'mousedown' , null )
2491
- . on ( 'dblclick' , null )
2492
- . on ( 'wheel' , null )
2493
- . on ( 'contextmenu' , null )
2494
- . property ( 'interactive_set' , null ) ;
2495
- this . draw_g . remove ( ) ;
2496
- }
2488
+ this . getG ( ) ?. selectAll ( '*' ) . remove ( ) ;
2489
+ this . getG ( ) ?. on ( 'mousedown' , null )
2490
+ . on ( 'dblclick' , null )
2491
+ . on ( 'wheel' , null )
2492
+ . on ( 'contextmenu' , null )
2493
+ . property ( 'interactive_set' , null )
2494
+ . remove ( ) ;
2497
2495
2498
- delete this . draw_g ; // frame <g> element managed by the pad
2496
+ this . setG ( undefined ) ; // frame <g> element managed by the pad
2499
2497
2500
2498
if ( this . #keys_handler) {
2501
2499
window . removeEventListener ( 'keydown' , this . #keys_handler, false ) ;
@@ -2544,35 +2542,34 @@ class TFramePainter extends FrameInteractive {
2544
2542
* @private */
2545
2543
createFrameG ( ) {
2546
2544
// this is svg:g object - container for every other items belonging to frame
2547
- this . draw_g = this . getFrameSvg ( ) ;
2548
-
2549
- let top_rect , main_svg ;
2545
+ let g = this . setG ( this . getFrameSvg ( ) ) ,
2546
+ top_rect , main_svg ;
2550
2547
2551
- if ( this . draw_g . empty ( ) ) {
2552
- this . draw_g = this . getLayerSvg ( 'primitives_layer' ) . append ( 'svg:g' ) . attr ( 'class' , 'root_frame' ) ;
2548
+ if ( g . empty ( ) ) {
2549
+ g = this . setG ( this . getLayerSvg ( 'primitives_layer' ) . append ( 'svg:g' ) . attr ( 'class' , 'root_frame' ) ) ;
2553
2550
2554
2551
// empty title on the frame required to suppress title of the canvas
2555
2552
if ( ! this . isBatchMode ( ) )
2556
- this . draw_g . append ( 'svg:title' ) . text ( '' ) ;
2553
+ g . append ( 'svg:title' ) . text ( '' ) ;
2557
2554
2558
- top_rect = this . draw_g . append ( 'svg:path' ) ;
2555
+ top_rect = g . append ( 'svg:path' ) ;
2559
2556
2560
- main_svg = this . draw_g . append ( 'svg:svg' )
2561
- . attr ( 'class' , 'main_layer' )
2562
- . attr ( 'x' , 0 )
2563
- . attr ( 'y' , 0 )
2564
- . attr ( 'overflow' , 'hidden' ) ;
2557
+ main_svg = g . append ( 'svg:svg' )
2558
+ . attr ( 'class' , 'main_layer' )
2559
+ . attr ( 'x' , 0 )
2560
+ . attr ( 'y' , 0 )
2561
+ . attr ( 'overflow' , 'hidden' ) ;
2565
2562
2566
- this . draw_g . append ( 'svg:g' ) . attr ( 'class' , 'axis_layer' ) ;
2567
- this . draw_g . append ( 'svg:g' ) . attr ( 'class' , 'upper_layer' ) ;
2563
+ g . append ( 'svg:g' ) . attr ( 'class' , 'axis_layer' ) ;
2564
+ g . append ( 'svg:g' ) . attr ( 'class' , 'upper_layer' ) ;
2568
2565
} else {
2569
- top_rect = this . draw_g . selectChild ( 'path' ) ;
2570
- main_svg = this . draw_g . selectChild ( '.main_layer' ) ;
2566
+ top_rect = g . selectChild ( 'path' ) ;
2567
+ main_svg = g . selectChild ( '.main_layer' ) ;
2571
2568
}
2572
2569
2573
2570
this . #axes_drawn = this . #axes2_drawn = false ;
2574
2571
2575
- this . draw_g . attr ( 'transform' , this . #frame_trans) ;
2572
+ g . attr ( 'transform' , this . #frame_trans) ;
2576
2573
2577
2574
top_rect . attr ( 'd' , `M0,0H${ this . #frame_width} V${ this . #frame_height} H0Z` )
2578
2575
. call ( this . fillatt . func )
@@ -2582,19 +2579,19 @@ class TFramePainter extends FrameInteractive {
2582
2579
. attr ( 'height' , this . #frame_height)
2583
2580
. attr ( 'viewBox' , `0 0 ${ this . #frame_width} ${ this . #frame_height} ` ) ;
2584
2581
2585
- this . draw_g . selectAll ( '.frame_deco' ) . remove ( ) ;
2582
+ g . selectAll ( '.frame_deco' ) . remove ( ) ;
2586
2583
if ( this . #border_mode && this . fillatt . hasColor ( ) ) {
2587
2584
const paths = getBoxDecorations ( 0 , 0 , this . #frame_width, this . #frame_height, this . #border_mode, this . #border_size || 2 , this . #border_size || 2 ) ;
2588
- this . draw_g . insert ( 'svg:path' , '.main_layer' )
2589
- . attr ( 'class' , 'frame_deco' )
2590
- . attr ( 'd' , paths [ 0 ] )
2591
- . call ( this . fillatt . func )
2592
- . style ( 'fill' , d3_rgb ( this . fillatt . color ) . brighter ( 0.5 ) . formatRgb ( ) ) ;
2593
- this . draw_g . insert ( 'svg:path' , '.main_layer' )
2594
- . attr ( 'class' , 'frame_deco' )
2595
- . attr ( 'd' , paths [ 1 ] )
2596
- . call ( this . fillatt . func )
2597
- . style ( 'fill' , d3_rgb ( this . fillatt . color ) . darker ( 0.5 ) . formatRgb ( ) ) ;
2585
+ g . insert ( 'svg:path' , '.main_layer' )
2586
+ . attr ( 'class' , 'frame_deco' )
2587
+ . attr ( 'd' , paths [ 0 ] )
2588
+ . call ( this . fillatt . func )
2589
+ . style ( 'fill' , d3_rgb ( this . fillatt . color ) . brighter ( 0.5 ) . formatRgb ( ) ) ;
2590
+ g . insert ( 'svg:path' , '.main_layer' )
2591
+ . attr ( 'class' , 'frame_deco' )
2592
+ . attr ( 'd' , paths [ 1 ] )
2593
+ . call ( this . fillatt . func )
2594
+ . style ( 'fill' , d3_rgb ( this . fillatt . color ) . darker ( 0.5 ) . formatRgb ( ) ) ;
2598
2595
}
2599
2596
2600
2597
return this ;
@@ -2841,7 +2838,7 @@ class TFramePainter extends FrameInteractive {
2841
2838
y : this . #frame_y || 0 ,
2842
2839
width : this . getFrameWidth ( ) ,
2843
2840
height : this . getFrameHeight ( ) ,
2844
- transform : this . draw_g ?. attr ( 'transform' ) || '' ,
2841
+ transform : this . getG ( ) ?. attr ( 'transform' ) || '' ,
2845
2842
hint_delta_x : 0 ,
2846
2843
hint_delta_y : 0
2847
2844
} ;
0 commit comments