Example #1
0
        public void AddShift(float[] cursor_position, Point shift)
        {
            var closest_shifts = cache.ClosestPoints;

            if (closest_shifts != null && closest_shifts[0].distance < calibration_mode.zone_size)
            {
                cache.SaveToCache(cursor_position, closest_shifts[0].index);
                Corrections[closest_shifts[0].index] = new UserCorrection(cursor_position, shift);
                if (closest_shifts.Count > 1 && closest_shifts[1].distance < calibration_mode.zone_size)
                {
                    cache.FreeIndex(closest_shifts[1].index);
                    Corrections.RemoveAt(closest_shifts[1].index);
                }
            }
            else if (Corrections.Count() < calibration_mode.max_zones_count)
            {
                if (cache.AllocateIndex() != Corrections.Count)
                {
                    throw new Exception("Logic error");
                }
                cache.SaveToCache(cursor_position, Corrections.Count);
                Corrections.Add(new UserCorrection(cursor_position, shift));
            }
            else
            {
                var highest_density_point = GetClosestPointOfHihestDensity();
                cache.SaveToCache(cursor_position, highest_density_point);
                Corrections[highest_density_point] = new UserCorrection(cursor_position, shift);
            }

            OnShiftsChanged();
        }
Example #2
0
 public void UpdateCurrentCorrection(UserCorrection correction)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         color_calculator.AdjustColorBoundaries(correction.Coordinates);
         InitArrowWithUserCorrection(correction, current_arrow);
     }));
 }
Example #3
0
 private void InitArrowWithUserCorrection(UserCorrection shift, Petzold.Media2D.ArrowLine arrow)
 {
     arrow.X1 = shift.Coordinates[0];
     arrow.Y1 = shift.Coordinates[1];
     arrow.X2 = shift.Coordinates[0] + shift.Shift.X;
     arrow.Y2 = shift.Coordinates[1] + shift.Shift.Y;
     if (arrow == current_arrow)
     {
         arrow.Stroke = Brushes.Green;
     }
     else
     {
         arrow.Stroke = Options.Instance.calibration_mode.additional_dimensions_configuration.Equals(AdditionalDimensionsConfguration.Disabled) ?
                        Brushes.Red : new SolidColorBrush(color_calculator.GetColor(shift.Coordinates));
     }
     arrow.StrokeThickness = 3;
 }
Example #4
0
 private int GetSectorNumber(UserCorrection shift, int max_sector_x)
 {
     return(GetSectorNumber(shift.Coordinates[0]) +
            GetSectorNumber(shift.Coordinates[1]) * (max_sector_x + 1));
 }