@@ -2974,6 +2974,69 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
29742974 return this . drawPrimitives ( indx + 1 ) ;
29752975 } ) ;
29762976 }
2977+
2978+ /** @summary Divide pad on subpads
2979+ * @returns {Promise } when finished
2980+ * @private */
2981+ TPadPainter . prototype . divide = function ( nx , ny ) {
2982+ if ( ! ny ) {
2983+ let ndiv = nx ;
2984+ if ( ndiv < 2 ) return Promise . resolve ( this ) ;
2985+ nx = ny = Math . round ( Math . sqrt ( ndiv ) ) ;
2986+ if ( nx * ny < ndiv ) nx += 1 ;
2987+ }
2988+
2989+ if ( nx * ny < 2 ) return Promise . resolve ( this ) ;
2990+
2991+ let xmargin = 0.01 , ymargin = 0.01 ,
2992+ dy = 1 / ny , dx = 1 / nx , n = 0 , subpads = [ ] ;
2993+ for ( let iy = 0 ; iy < ny ; iy ++ ) {
2994+ let y2 = 1 - iy * dy - ymargin ,
2995+ y1 = y2 - dy + 2 * ymargin ;
2996+ if ( y1 < 0 ) y1 = 0 ;
2997+ if ( y1 > y2 ) continue ;
2998+ for ( let ix = 0 ; ix < nx ; ix ++ ) {
2999+ let x1 = ix * dx + xmargin ,
3000+ x2 = x1 + dx - 2 * xmargin ;
3001+ if ( x1 > x2 ) continue ;
3002+ n ++ ;
3003+ let pad = JSROOT . create ( "TPad" ) ;
3004+ pad . fName = pad . fTitle = this . pad . fName + "_" + n ;
3005+ pad . fNumber = n ;
3006+ if ( ! this . iscan ) {
3007+ pad . fAbsWNDC = ( x2 - x1 ) * this . pad . fAbsWNDC ;
3008+ pad . fAbsHNDC = ( y2 - y1 ) * this . pad . fAbsHNDC ;
3009+ pad . fAbsXlowNDC = this . pad . fAbsXlowNDC + x1 * this . pad . fAbsWNDC ;
3010+ pad . fAbsYlowNDC = this . pad . fAbsYlowNDC + y1 * this . pad . fAbsWNDC ;
3011+ } else {
3012+ pad . fAbsWNDC = x2 - x1 ;
3013+ pad . fAbsHNDC = y2 - y1 ;
3014+ pad . fAbsXlowNDC = x1 ;
3015+ pad . fAbsYlowNDC = y1 ;
3016+ }
3017+
3018+ subpads . push ( pad ) ;
3019+ }
3020+ }
3021+
3022+ const drawNext = ( ) => {
3023+ if ( subpads . length == 0 )
3024+ return Promise . resolve ( this ) ;
3025+ return JSROOT . draw ( this . getDom ( ) , subpads . shift ( ) ) . then ( drawNext ) ;
3026+ } ;
3027+
3028+ return drawNext ( ) ;
3029+ }
3030+
3031+ /** @summary Return sub-pads painter, only direct childs are checked
3032+ * @private */
3033+ TPadPainter . prototype . getSubPadPainter = function ( n ) {
3034+ for ( let k = 0 ; k < this . painters . length ; ++ k ) {
3035+ let sub = this . painters [ k ] ;
3036+ if ( sub . pad && ( typeof sub . forEachPainterInPad === 'function' ) && ( sub . pad . fNumber === n ) ) return sub ;
3037+ }
3038+ return null ;
3039+ }
29773040
29783041 /** @summary Process tooltip event in the pad
29793042 * @private */
0 commit comments