@@ -84,8 +84,6 @@ def __init__(self, parent=None):
8484 self ._wppf_object = None
8585 self ._prev_background_method = None
8686 self ._undo_stack = []
87- self ._last_pv_binned = None
88- self ._last_texture_pv_sim = None
8987 self ._texture_simulated_polar_dialog = None
9088
9189 self .amorphous_experiment_files = []
@@ -1603,7 +1601,15 @@ def wppf_object_kwargs(self):
16031601
16041602 extra_kwargs = {}
16051603 if self .includes_texture :
1606- extra_kwargs ['texture_model' ] = self .texture_model_dict
1604+ extra_kwargs = {
1605+ ** extra_kwargs ,
1606+ 'texture_model' : self .texture_model_dict ,
1607+ 'eta_max' : HexrdConfig ().polar_res_eta_max ,
1608+ 'eta_min' : HexrdConfig ().polar_res_eta_min ,
1609+ # We have to make sure this is correct every time we update
1610+ # the 2D spectrum.
1611+ 'eta_step' : self .texture_settings ['azimuthal_interval' ],
1612+ }
16071613
16081614 return {
16091615 'expt_spectrum' : expt_spectrum ,
@@ -1918,8 +1924,6 @@ def save_texture_binning_settings(self):
19181924 settings [key ] = w .value ()
19191925
19201926 def invalidate_texture_data (self ):
1921- self ._last_pv_binned = None
1922- self ._last_texture_pv_sim = None
19231927 self .clear_texture_data ()
19241928
19251929 def on_texture_binning_setting_changed (self ):
@@ -1929,20 +1933,39 @@ def on_texture_binning_setting_changed(self):
19291933 self .invalidate_texture_data ()
19301934 self .update_simulated_polar_dialog ()
19311935
1932- def compute_binned_polar_view (self ):
1936+ def _compute_2d_pv_bin (self ):
19331937 canvas = HexrdConfig ().active_canvas
19341938 if canvas .mode != 'polar' or canvas .iviewer is None :
19351939 return
19361940
19371941 settings = self .texture_settings
19381942
1939- self . _last_pv_binned = bin_polar_view (
1943+ return bin_polar_view (
19401944 canvas .iviewer .pv ,
19411945 canvas .iviewer .img ,
19421946 settings ['azimuthal_interval' ],
19431947 settings ['integration_range' ],
19441948 )
19451949
1950+ def _compute_2d_pv_sim (self ):
1951+ # We have to have an object to do this.
1952+ # If we must, temporarily create one and destroy it later...
1953+ had_object = self ._wppf_object is not None
1954+
1955+ obj = self .wppf_object
1956+ if not isinstance (obj , Rietveld ):
1957+ # Nothing we can do
1958+ return None
1959+
1960+ try :
1961+ # Make sure the `eta_step` is up-to-date
1962+ obj .eta_step = self .texture_settings ['azimuthal_interval' ]
1963+ obj .computespectrum_2D ()
1964+ return obj .simulated_2d
1965+ finally :
1966+ if not had_object :
1967+ self .reset_object ()
1968+
19461969 @property
19471970 def polar_extent (self ) -> list [float ] | None :
19481971 canvas = HexrdConfig ().active_canvas
@@ -2056,27 +2079,20 @@ def update_texture_data(self):
20562079 if not isinstance (obj , Rietveld ):
20572080 return
20582081
2059- if self ._last_pv_binned is None :
2060- # A recompute is necessary
2061- self .compute_binned_polar_view ()
2062-
2082+ pv_bin = self ._compute_2d_pv_bin ()
20632083 settings = self .texture_settings
20642084
20652085 # This also updates the texture data on all of the texture models
20662086 obj .compute_texture_data (
2067- self . _last_pv_binned ,
2087+ pv_bin ,
20682088 bvec = HexrdConfig ().beam_vector ,
20692089 evec = ct .eta_vec ,
20702090 azimuthal_interval = settings ['azimuthal_interval' ],
20712091 )
20722092
20732093 def on_texture_show_simulated_spectrum_clicked (self ):
2074- if self ._last_pv_binned is None :
2075- # A recompute is necessary
2076- self .compute_binned_polar_view ()
2077-
2078- pv_bin = self ._last_pv_binned
2079- pv_sim = self ._last_texture_pv_sim
2094+ pv_bin = self ._compute_2d_pv_bin ()
2095+ pv_sim = self ._compute_2d_pv_sim ()
20802096 extent = self .polar_extent
20812097
20822098 d = self ._texture_simulated_polar_dialog
@@ -2139,15 +2155,14 @@ def on_texture_params_modified(self):
21392155 self .update_texture_index_label ()
21402156
21412157 def update_simulated_polar_dialog (self ):
2142- # FIXME: recalculate `self._last_texture_pv_sim`
21432158 d = self ._texture_simulated_polar_dialog
21442159 if d is None or not d .ui .isVisible ():
21452160 return
21462161
2147- if self ._last_pv_binned is None :
2148- self .compute_binned_polar_view ()
2162+ pv_bin = self ._compute_2d_pv_bin ()
2163+ pv_sim = self ._compute_2d_pv_sim ()
21492164
2150- d .set_data (self . _last_pv_binned , self . _last_texture_pv_sim )
2165+ d .set_data (pv_bin , pv_sim )
21512166
21522167 def update_pole_figure_plots (self ):
21532168 obj = self ._wppf_object
0 commit comments