public void set_parameters(Chart_GUI chart_gui_) { timeslice = chart_gui_.timeslice; maxTicks = chart_gui_.chart_area_width / 5; // Max number of ticks is one tick every 5 distance calculate(chart_gui_); }
// Same as function below except timeslice is set to entire logfile width plus some padding public int set_initial_timeslice_data() { if (logfile == null) { return(0); } // Set initial gui window to entire logfile timeslice, with some padding if (logfile.num_points != 0) { double initial_time_start = logfile.point_list[0].timestamp - 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp); double initial_time_end = logfile.point_list[logfile.num_points - 1].timestamp + 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp); Timeslice initial_timeslice = new Timeslice { start = initial_time_start, end = initial_time_end }; update_timeslice_data(initial_timeslice); } else { MessageBox.Show("Logfile empty"); } return(1); // Not yet used }
// Updates chart areas to show data in new timeslice public int update_timeslice_data(Timeslice timeslice_new) { if (logfile == null) { return(0); } //// Clear chart, will be repopulated later //chart.ChartAreas.Clear(); // Update timeslice and checked_list_box timeslice = timeslice_new; //// Create list of ChartAreas which will be populated later //List<ChartArea> chart_areas = new List<ChartArea>(); //// Populate list of ChartAreas with all signals selected in checked_list_box, which are arranged alphabetically by default //for (int i = 0; i < checked_list_box.CheckedItems.Count; i++) //{ // ChartArea new_chart_area = new ChartArea(checked_list_box.CheckedItems[i].ToString()); // chart_areas.Add(new_chart_area); //} //// Find start and end indices of set of logfile points that are encompassed by timeslice_new //int start_index = logfile.point_list.IndexOf(logfile.point_list.Find(x => x.timestamp >= timeslice.start)); // Index of first signal greater than timeslice start //int end_index = logfile.point_list.IndexOf(logfile.point_list.FindLast(x => x.timestamp <= timeslice.end)); // Index of last signal less than timeslice end //MessageBox.Show(start_index.ToString() + " " + end_index.ToString() + " | " + "0" + " " + (logfile.point_list.Count - 1).ToString()); //// Create sublist of points from list of points in logfile //List<Logfile_Point> timeslice_points; //if (start_index != -1 && end_index != -1 && end_index > start_index) // timeslice_points = logfile.point_list.GetRange(start_index, end_index - start_index); //else // timeslice_points = new List<Logfile_Point>(); //// At each Logfile_Point within timeslice, for each of its signals, add the data to the series of that signal //foreach (Logfile_Point current_point in timeslice_points) //{ // foreach (Logfile_Signal_Point current_signal_point in current_point.signal_point_list) // { // int current_signal_name_index_in_checked_list_box = checked_list_box.Items.IndexOf(current_signal_point.name); // // If current signal's box is checked // if (checked_list_box.GetItemChecked(current_signal_name_index_in_checked_list_box) == true) // { // if (series.Find(series_of_signal => !Convert.ToBoolean(string.Compare(series_of_signal.Name, current_signal_point.name))) != null) // { // series.Find(series_of_signal => !Convert.ToBoolean(string.Compare(series_of_signal.Name, current_signal_point.name))).Points.AddXY(current_point.timestamp, current_signal_point.value); // //MessageBox.Show(current_point.timestamp.ToString() + " " + current_signal_point.value.ToString()); // } // } // } //} //// Add now-populated chart_areas and series lists to signals list //if (chart_areas.Count != series.Count) // throw new ArgumentException("size of chart_area and series not same"); //for (int i = 0; i < chart_areas.Count; i++) // add_signal_from_series(chart_areas[i], series[i]); //for (int i = 0; i < chart_areas.Count; i++) //{ // chart_areas[i].BackColor = Color.Black; // Set chart_area to black // // X axis stylize // chart_areas[i].AxisX.Enabled = AxisEnabled.True; // chart_areas[i].AxisX.LineColor = Color.White; // chart_areas[i].AxisX.InterlacedColor = Color.White; // chart_areas[i].AxisX.MajorGrid.LineColor = Color.FromArgb(77, 77, 77); // chart_areas[i].AxisX.LabelStyle.ForeColor = Color.White; // // Find nice x axis parameters, need to do this after refresh because need new chart area width // nicescale.set_parameters(this); // chart_areas[i].AxisX.Minimum = nicescale.get_nice_min(); // chart_areas[i].AxisX.Maximum = nicescale.get_nice_max(); // chart_areas[i].AxisX.Interval = nicescale.get_tick_spacing(); // // Y axis stylize // chart_areas[i].AxisY.Enabled = AxisEnabled.True; // chart_areas[i].AxisY.LineColor = Color.White; // chart_areas[i].AxisY.InterlacedColor = Color.White; // chart_areas[i].AxisY.MajorGrid.LineColor = Color.FromArgb(77, 77, 77); // chart_areas[i].AxisY.LabelStyle.ForeColor = Color.White; // chart_areas[i].AxisY.Minimum = double.NaN; // Autoscales y axis // chart_areas[i].AxisY.Maximum = double.NaN; // chart_areas[i].AxisY.IntervalAutoMode = IntervalAutoMode.FixedCount; // chart.ChartAreas.Add(chart_areas[i]); //} // Find nice x axis parameters, need to do this after refresh because need new chart area width nicescale.set_parameters(this); foreach (ChartArea chart_area in chart.ChartAreas) { chart_area.AxisX.Minimum = nicescale.get_nice_min(); chart_area.AxisX.Maximum = nicescale.get_nice_max(); chart_area.AxisX.Interval = nicescale.get_tick_spacing(); } // Refresh chart chart.Refresh(); return(1); // Not yet used }