1- import { create , gStyle } from '../core.mjs' ;
1+ import { create , gStyle , settings } from '../core.mjs' ;
22import { DrawOptions , buildSvgPath } from '../base/BasePainter.mjs' ;
33import { ObjectPainter } from '../base/ObjectPainter.mjs' ;
44import { TH1Painter } from '../hist2d/TH1Painter.mjs' ;
@@ -108,9 +108,13 @@ class TF1Painter extends ObjectPainter {
108108 let np = Math . max ( tf1 . fNpx , 101 ) ,
109109 dx = ( xmax - xmin ) / ( np - 1 ) ,
110110 res = [ ] , iserror = false ,
111- force_use_save = ( tf1 . fSave . length > 3 ) && ignore_zoom ;
111+ has_saved_points = ( tf1 . fSave . length > 3 ) ,
112+ force_use_save = has_saved_points && ( ignore_zoom || settings . PreferSavedPoints ) ;
113+
114+ if ( ! force_use_save ) {
115+ if ( ! tf1 . evalPar )
116+ proivdeEvalPar ( tf1 ) ;
112117
113- if ( ! force_use_save )
114118 for ( let n = 0 ; n < np ; n ++ ) {
115119 let xx = xmin + n * dx , yy = 0 ;
116120 if ( logx ) xx = Math . exp ( xx ) ;
@@ -125,10 +129,11 @@ class TF1Painter extends ObjectPainter {
125129 if ( Number . isFinite ( yy ) )
126130 res . push ( { x : xx , y : yy } ) ;
127131 }
132+ }
128133
129134 // in the case there were points have saved and we cannot calculate function
130135 // if we don't have the user's function
131- if ( ( iserror || ignore_zoom || ! res . length ) && ( tf1 . fSave . length > 3 ) ) {
136+ if ( ( iserror || ignore_zoom || ! res . length ) && has_saved_points ) {
132137
133138 np = tf1 . fSave . length - 2 ;
134139 xmin = tf1 . fSave [ np ] ;
@@ -198,8 +203,9 @@ class TF1Painter extends ObjectPainter {
198203
199204 updateObject ( obj /*, opt */ ) {
200205 if ( ! this . matchObjectType ( obj ) ) return false ;
201- Object . assign ( this . getObject ( ) , obj ) ;
202- proivdeEvalPar ( this . getObject ( ) ) ;
206+ let tf1 = this . getObject ( ) ;
207+ Object . assign ( tf1 , obj ) ;
208+ delete tf1 . evalPar ;
203209 return true ;
204210 }
205211
@@ -354,8 +360,6 @@ class TF1Painter extends ObjectPainter {
354360 if ( d . check ( 'RX' ) ) aopt += "RX" ;
355361 if ( d . check ( 'RY' ) ) aopt += "RY" ;
356362
357- proivdeEvalPar ( tf1 ) ;
358-
359363 let pr = Promise . resolve ( true ) ;
360364
361365 if ( ! has_main || painter . second_x || painter . second_y )
0 commit comments