Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

void dataset_append_frame ( DataSet data_set,
Frame frame 
)

Append a frame to a dataset.

The new Frame is inserted into the DataSet at the appropriate time. The maximum and minimum data values for the DataSet are recalculated.

Parameters:
data_set A pointer to the DataSet.
frame A pointer to the frame which is to be appended.

Definition at line 189 of file read_data.c.

References _DataSet::frame, _DataSet::nframes, _Frame::time, _Frame::x_range, _DataSet::x_range, _Frame::y_range, and _DataSet::y_range.

Referenced by dataset_calc_derivative(), dataset_derivative(), and dataset_read_from_file().

{
  Frame* cur_frame;
  gdouble time_p_eps;
  gdouble time_m_eps;
  gint i;

  /*
   * If time values have not been specified, set the time according
   * to the frame number.
   */
  if (frame->time == UNINITIALISED_TIME)
    frame->time = data_set->nframes;

  time_p_eps = frame->time + TIME_EPSILON;
  time_m_eps = frame->time - TIME_EPSILON;

  /*
   * Fit the frame into the current list according to its time value.
   */
  if (data_set->nframes > 0)
    {
      cur_frame = g_array_index(data_set->frame, Frame*, data_set->nframes-1);

      if (cur_frame->time < time_m_eps)
        g_array_append_val(data_set->frame, frame);
      else
        {
          for (i=0; i<data_set->nframes; ++i)
            {
              cur_frame = g_array_index(data_set->frame, Frame*, i);
              /*
               * If a frame at the same time value (up to epsilon) already
               * exists, then don't replace it.
               */
              if ((cur_frame->time < time_p_eps) && 
                  (cur_frame->time > time_m_eps))
                return;

              if (cur_frame->time > time_p_eps)
                {
                  g_array_insert_val(data_set->frame, i, frame);
                  break;
                }
            }
        }
    }
  else
    {
      if (data_set->frame == NULL)
        data_set->frame = g_array_new(FALSE, FALSE, sizeof(Frame*));
      g_array_append_val(data_set->frame, frame);
    }

  data_set->x_range[0] = MIN(data_set->x_range[0], frame->x_range[0]);
  data_set->x_range[1] = MAX(data_set->x_range[1], frame->x_range[1]);
  data_set->y_range[0] = MIN(data_set->y_range[0], frame->y_range[0]);
  data_set->y_range[1] = MAX(data_set->y_range[1], frame->y_range[1]);

  data_set->nframes++;
}


Generated by  Doxygen 1.6.0   Back to index