indexing description: "[ An automated plot that samples its values from a {EM_VIZ_SAMPLE_SOURCE_1D} object when updating. ]" author: "" date: "$Date$" revision: "$Revision$" class EM_VIZ_SAMPLING_PLOT_2D inherit EM_VIZ_PLOT_2D redefine data end create make feature -- Initialization make (a_size: like size; a_x_interval, a_y_interval: EM_INTERVAL) is -- Make new sample plot of `a_size', with domain `a_x_interval' and range `a_y_interval' do make_plot_2d (a_size, a_x_interval, a_y_interval) set_sampling_rate (a_x_interval.size) set_sample_source (Void) end feature -- Access sampling_rate: DOUBLE -- Rate at which `sampling_source' should be sampled sample_source: EM_VIZ_SAMPLE_SOURCE_1D -- Sample-source feature -- Element change set_sampling_rate (a_rate: like sampling_rate) is -- Set sampling-rate require positive_rate: 0.0 < a_rate do sampling_rate := a_rate expire ensure set: sampling_rate = a_rate expired: needs_update end set_sample_source (a_source: like sample_source) is -- Set sample-source do sample_source := a_source expire ensure set: sample_source = a_source expired: needs_update end feature {NONE} -- Implementation data: DS_ARRAYED_LIST [EM_VECTOR2D] -- Internal data storage create_data is -- Create data storage do create data.make (1) end update_data is -- Update data by sampling source local t: DOUBLE do data.wipe_out data.resize ((interval.x.size / sampling_rate).ceiling + 1) if sample_source /= Void then from t := interval.x.min until t > interval.x.max loop data.force_last ([t, sample_source.sample (t)]) t := t + sampling_rate end else from t := interval.x.min until t > interval.x.max loop data.force_last ([t, 0.0]) t := t + sampling_rate end end end end