-void
-AutomationLine::determine_visible_control_points (ALPoints& points)
-{
- uint32_t view_index, pi, n;
- AutomationList::iterator model;
- uint32_t npoints;
- uint32_t this_rx = 0;
- uint32_t prev_rx = 0;
- uint32_t this_ry = 0;
- uint32_t prev_ry = 0;
- double* slope;
- uint32_t box_size;
-
- /* hide all existing points, and the line */
-
- for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- (*i)->hide();
- }
-
- line->hide ();
-
- if (points.empty()) {
- return;
- }
-
- npoints = points.size();
-
- /* compute derivative/slope for the entire line */
-
- slope = new double[npoints];
-
- for (n = 0; n < npoints - 1; ++n) {
- double xdelta = points[n+1].x - points[n].x;
- double ydelta = points[n+1].y - points[n].y;
- slope[n] = ydelta/xdelta;
- }
-
- box_size = (uint32_t) control_point_box_size ();
-
- /* read all points and decide which ones to show as control points */
-
- view_index = 0;
-
- for (model = alist->begin(), pi = 0; pi < npoints; ++model, ++pi) {
-
- double tx = points[pi].x;
- double ty = points[pi].y;
-
- if (find (_always_in_view.begin(), _always_in_view.end(), (*model)->when) != _always_in_view.end()) {
- add_visible_control_point (view_index, pi, tx, ty, model, npoints);
- prev_rx = this_rx;
- prev_ry = this_ry;
- ++view_index;
- continue;
- }
-
- if (isnan (tx) || isnan (ty)) {
- warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
- _name) << endmsg;
- continue;
- }
-
- /* now ensure that the control_points vector reflects the current curve
- state, but don't plot control points too close together. also, don't
- plot a series of points all with the same value.
-
- always plot the first and last points, of course.
- */
-
- if (invalid_point (points, pi)) {
- /* for some reason, we are supposed to ignore this point,
- but still keep track of the model index.
- */
- continue;
- }
-
- if (pi > 0 && pi < npoints - 1) {
- if (slope[pi] == slope[pi-1]) {
-
- /* no reason to display this point */
-
- continue;
- }
- }
-
- /* need to round here. the ultimate coordinates are integer
- pixels, so tiny deltas in the coords will be eliminated
- and we end up with "colinear" line segments. since the
- line rendering code in libart doesn't like this very
- much, we eliminate them here. don't do this for the first and last
- points.
- */
-
- this_rx = (uint32_t) rint (tx);
- this_ry = (uint32_t) rint (ty);
-
- if (view_index && pi != npoints && /* not the first, not the last */
- (((this_rx == prev_rx) && (this_ry == prev_ry)) || /* same point */
- (((this_rx - prev_rx) < (box_size + 2)) && /* not identical, but still too close horizontally */
- (abs ((int)(this_ry - prev_ry)) < (int) (box_size + 2))))) { /* too close vertically */
- continue;
- }
-
- /* ok, we should display this point */
-
- add_visible_control_point (view_index, pi, tx, ty, model, npoints);
-
- prev_rx = this_rx;
- prev_ry = this_ry;
-
- view_index++;
- }
-
- /* discard extra CP's to avoid confusing ourselves */
-
- while (control_points.size() > view_index) {
- ControlPoint* cp = control_points.back();
- control_points.pop_back ();
- delete cp;
- }
-
- if (!terminal_points_can_slide) {
- control_points.back()->set_can_slide(false);