/// <summary> /// Raises the <see cref="ChartElement.Updated"/> event. /// </summary> /// <remarks> /// <strong>Notes to Inheritors:</strong> When overriding <see cref="OnUpdate"/> in a /// derived class, be sure to call the base class's <see cref="OnUpdate"/> method so that /// registered delegates receive the event. /// </remarks> protected override void OnUpdate() { double xValue = X; if (Numeric.IsFinite(xValue)) { Axis xAxis = XAxis; Axis yAxis = YAxis; AxisScale xScale = xAxis.Scale; AxisScale yScale = yAxis.Scale; double yMin = yAxis.GetPosition(yScale.Min); double yMax = yAxis.GetPosition(yScale.Max); double xPosition = xAxis.GetPosition(xValue); if (_line != null) { _line.X1 = xPosition; _line.X2 = xPosition; _line.Y1 = yMin; _line.Y2 = yMax; _line.Visibility = (xScale.Min <= xValue && xValue <= xScale.Max) ? Visibility.Visible : Visibility.Collapsed; } } else { if (_line != null) _line.Visibility = Visibility.Collapsed; } base.OnUpdate(); }
/// <summary> /// Raises the <see cref="ChartElement.Updated"/> event. /// </summary> /// <remarks> /// <strong>Notes to Inheritors:</strong> When overriding <see cref="OnUpdate"/> in a /// derived class, be sure to call the base class's <see cref="OnUpdate"/> method so that /// registered delegates receive the event. /// </remarks> protected override void OnUpdate() { Axis xAxis = XAxis; Axis yAxis = YAxis; AxisScale xScale = xAxis.Scale; AxisScale yScale = yAxis.Scale; double xValue = X; if (Numeric.IsFinite(xValue)) { double yMin = yAxis.GetPosition(yScale.Min); double yMax = yAxis.GetPosition(yScale.Max); double xPosition = xAxis.GetPosition(xValue) + 0.5; if (_verticalLine != null) { _verticalLine.X1 = xPosition; _verticalLine.X2 = xPosition; _verticalLine.Y1 = yMin; _verticalLine.Y2 = yMax; _verticalLine.Visibility = (xScale.Min <= xValue && xValue <= xScale.Max) ? Visibility.Visible : Visibility.Collapsed; } } else { if (_verticalLine != null) _verticalLine.Visibility = Visibility.Collapsed; } double yValue = Y; if (Numeric.IsFinite(yValue)) { double xMin = xAxis.GetPosition(xScale.Min); double xMax = xAxis.GetPosition(xScale.Max); double yPosition = yAxis.GetPosition(yValue) + 0.5; if (_horizontalLine != null) { _horizontalLine.X1 = xMin; _horizontalLine.X2 = xMax; _horizontalLine.Y1 = yPosition; _horizontalLine.Y2 = yPosition; _horizontalLine.Visibility = (yScale.Min <= yValue && yValue <= yScale.Max) ? Visibility.Visible : Visibility.Collapsed; } } else { if (_horizontalLine != null) _horizontalLine.Visibility = Visibility.Collapsed; } base.OnUpdate(); }
private static void EnsureScaleIncludesZero(AxisScale scale) { double min = scale.Min; double max = scale.Max; if (min > 0 && max > 0) scale.Range = new DoubleRange(0, max); else if (min < 0 && max < 0) scale.Range = new DoubleRange(min, 0); }
private static IList<TextLabel> GetLabels(Axis axis) { AxisScale scale = axis.Scale; IList<TextLabel> labels = null; TextScale textScale = scale as TextScale; if (textScale != null) labels = (textScale).Labels; return labels; }
public static Filterbank GetFilterbank(AxisScale type, double scale, double @base, double bandwidth, double overlap) { Filterbank filterbank; if (type == AxisScale.SCALE_LINEAR) { filterbank = new LinearFilterbank(scale, @base, bandwidth, overlap); } else { filterbank = new LogFilterbank(scale, @base, bandwidth, overlap); } return filterbank; }
public Spectrogram() { bandwidth = 100; basefreq = 55; maxfreq = 22050; overlap = 0.8; pixpersec = 100; window = Window.WINDOW_HANN; intensity_axis = AxisScale.SCALE_LOGARITHMIC; frequency_axis = AxisScale.SCALE_LOGARITHMIC; //cancelled = false; palette = new Palette(); }
public static Filterbank GetFilterbank(AxisScale type, double scale, double @base, double bandwidth, double overlap) { Filterbank filterbank; if (type == AxisScale.SCALE_LINEAR) { filterbank = new LinearFilterbank(scale, @base, bandwidth, overlap); } else { filterbank = new LogFilterbank(scale, @base, bandwidth, overlap); } return(filterbank); }
public static double CalcIntensityInv(double val, AxisScale intensity_axis) { Debug.Assert(val >= 0 && val <= 1); switch (intensity_axis) { case AxisScale.SCALE_LOGARITHMIC: return(SpectrogramUtils.Log10ScaleInverse(val)); case AxisScale.SCALE_LINEAR: return(val); default: Debug.Assert(false); break; } return(0.0); }
/// <summary> /// Called by <see cref="SuggestYScale"/> to suggest a scale for the y-axis /// </summary> /// <inheritdoc cref="SuggestYScale"/> protected virtual AxisScale OnSuggestYScale() { AxisScale scale = null; foreach (var chart in Charts) { var suggestedScale = chart.SuggestYScale(); if (suggestedScale != null) { if (scale == null) scale = suggestedScale; else scale.Add(suggestedScale); } } return scale; }
/// <inheritdoc/> protected override AxisScale OnSuggestYScale() { if (Data == null || Data.Count == 0) return null; if (EffectiveOrientation == Orientation.Vertical) { // Make sure that scale contains 0. AxisScale scale = base.OnSuggestYScale(); EnsureScaleIncludesZero(scale); return scale; } else { return SuggestBaseScale(); } }
public static double calc_intensity_inv(double val, AxisScale intensity_axis) { Debug.Assert(val >= 0 && val <= 1); switch (intensity_axis) { case AxisScale.SCALE_LOGARITHMIC: return(GlobalMembersSpectrogram.log10scale_inv(val)); case AxisScale.SCALE_LINEAR: return(val); default: Debug.Assert(false); break; } return(0.0); }
public Spectrogram() { // arss default values // basefreq = 27.5; // maxfreq = 20000; // bandsperoctave = 12; // pixpersec = 150; bandwidth = 201; // 100 basefreq = 27.5; // 55 maxfreq = 20000; // 22050; 19912 overlap = 0.5; pixpersec = 150; // 100 window = Window.WINDOW_HANN; intensity_axis = AxisScale.SCALE_LOGARITHMIC; frequency_axis = AxisScale.SCALE_LOGARITHMIC; //cancelled = false; palette = new Palette(); }
private void UpdateMinorGridLines() { Axis xAxis = XAxis; Axis yAxis = YAxis; if (xAxis != null && yAxis != null) { AxisScale xScale = xAxis.Scale; AxisScale yScale = yAxis.Scale; if (xScale != null && yScale != null) { double xMin = xAxis.GetPosition(xScale.Min); double xMax = xAxis.GetPosition(xScale.Max); double yMin = yAxis.GetPosition(yScale.Min); double yMax = yAxis.GetPosition(yScale.Max); // Add vertical minor lines if (_verticalMinorLinesRenderer != null && VerticalMinorLineStyle != null) { using (var renderContext = _verticalMinorLinesRenderer.Open()) { for (int i = 0; i < xAxis.MinorTicks.Length; ++i) { double x = xAxis.GetPosition(xAxis.MinorTicks[i]); renderContext.DrawLine(new Point(x, yMin), new Point(x, yMax)); } } } // Add horizontal minor lines if (_horizontalMinorLinesRenderer != null && HorizontalMinorLineStyle != null) { using (var renderContext = _horizontalMinorLinesRenderer.Open()) { for (int i = 0; i < yAxis.MinorTicks.Length; ++i) { double y = yAxis.GetPosition(yAxis.MinorTicks[i]); renderContext.DrawLine(new Point(xMin, y), new Point(xMax, y)); } } } } } }
public void Init() { AddProperty(MyEmitterPropertiesEnum.Type, new MyConstPropertyEnum("Type", typeof(MyParticleEmitterType), s_emitterTypeStrings)); AddProperty(MyEmitterPropertiesEnum.Offset, new MyAnimatedPropertyVector3("Offset")); AddProperty(MyEmitterPropertiesEnum.Rotation, new MyAnimatedPropertyVector3("Rotation", true, null)); AddProperty(MyEmitterPropertiesEnum.AxisScale, new MyConstPropertyVector3("AxisScale")); AddProperty(MyEmitterPropertiesEnum.Size, new MyAnimatedPropertyFloat("Size")); AddProperty(MyEmitterPropertiesEnum.RadiusMin, new MyConstPropertyFloat("RadiusMin")); AddProperty(MyEmitterPropertiesEnum.RadiusMax, new MyConstPropertyFloat("RadiusMax")); AddProperty(MyEmitterPropertiesEnum.DirToCamera, new MyConstPropertyBool("DirToCamera")); AddProperty(MyEmitterPropertiesEnum.LimitAngle, new MyAnimatedPropertyFloat("LimitAngle")); Offset.AddKey(0, new Vector3(0, 0, 0)); Rotation.AddKey(0, new Vector3(0, 0, 0)); AxisScale.SetValue(Vector3.One); Size.AddKey(0, 1.0f); RadiusMin.SetValue(1.0f); RadiusMax.SetValue(1.0f); DirToCamera.SetValue(false); }
internal SpectrumDrawer(string label, Spectrum spectrum, AxisScale scale) { this.label = label; this.spectrum = spectrum; this.scale = scale; }
public static double CalcIntensityInv(double val, AxisScale intensity_axis) { Debug.Assert(val >= 0 && val <= 1); switch (intensity_axis) { case AxisScale.SCALE_LOGARITHMIC: return SpectrogramUtils.Log10ScaleInverse(val); case AxisScale.SCALE_LINEAR: return val; default: Debug.Assert(false); break; } return 0.0; }
/// <summary> /// This function gets called by ILTickCollection on every attempt to build/render the ticks for an axis. Here /// it is called from the colorbar rendering code. Implementors of this function can provide their own tick collections. /// Often such custom ticks are based on the standard implementation provided by ILTickCollection.CreateTicksAuto(). /// </summary> /// <param name="min">min value for the axis range</param> /// <param name="max">max value for the axis range</param> /// <param name="numberTicks">rough estimate of how many ticks will fit inside the availabel space for the the whole axis scale</param> /// <param name="axis">a reference to the axis referenced by the tick collection</param> /// <param name="scale">type of scaling of the axis. For ILColorbar: linear only</param> /// <returns>Your own collection of ticks for rendering</returns> IEnumerable <ILTick> MyTicksCreationFunc(float min, float max, int numberTicks, ILAxis axis, AxisScale scale = AxisScale.Linear) { // a custom tick creating function: use the standard ticks collection and add custom ticks for min and max values return(ILTickCollection.CreateTicksAuto(min, max, numberTicks, axis, scale) .Concat(new [] { createTick(min), createTick(max) })); }
/// <inheritdoc/> protected override void OnUpdate() { base.OnUpdate(); Debug.Assert(Canvas.Children.Count == 0, "Canvas should be cleared in base class."); if (Data == null || Data.Count == 0 || DataPointTemplate == null) { // A relevant property is not set. return; } // Fetch dependency properties. (Accessing dependency properties is expensive.) Axis xAxis = XAxis; Axis yAxis = YAxis; AxisScale xScale = xAxis.Scale; AxisScale yScale = yAxis.Scale; double centerX = CenterX; double centerY = CenterY; double hole = Hole; double outerRadius = Radius; Thickness padding = Padding; if (hole < 0 || hole > 1) throw new ChartException("Pie chart has invalid hole size. The hole size is relative to the outer radius and must be in the range [0, 1]."); if (outerRadius < 0) throw new ChartException("Pie chart has invalid radius. The radius must be a equal to or greater than 0."); // Determine available space. double left = xAxis.GetPosition(xScale.Min); double right = xAxis.GetPosition(xScale.Max); if (left > right) { // Scale is reversed. ChartHelper.Swap(ref left, ref right); } double top = yAxis.GetPosition(yScale.Max); double bottom = yAxis.GetPosition(yScale.Min); if (top > bottom) { // Scale is reversed. ChartHelper.Swap(ref top, ref bottom); } // Apply padding. left += padding.Left; right -= padding.Right; top += padding.Top; bottom -= padding.Bottom; if (Numeric.IsNaN(centerX)) { // Center pie chart horizontally. centerX = (left + right) / 2; } else { centerX = xAxis.OriginX + centerX * xAxis.Length; } if (Numeric.IsNaN(centerY)) { // Center pie chart vertically. centerY = (top + bottom) / 2; } else { centerY = yAxis.OriginY - (1.0 - centerY) * yAxis.Length; } if (Numeric.IsNaN(outerRadius)) { // Fit pie chart into available space. double radiusLeft = centerX - left; double radiusRight = right - centerX; double radiusTop = centerY - top; double radiusBottom = bottom - centerY; outerRadius = radiusLeft; if (outerRadius > radiusRight) outerRadius = radiusRight; if (outerRadius > radiusTop) outerRadius = radiusTop; if (outerRadius > radiusBottom) outerRadius = radiusBottom; } if (Numeric.IsNaN(hole)) hole = 0; double innerRadius = hole * outerRadius; ActualHoleRadius = innerRadius; // Draw pie chart inside chart panel. DrawPieChart(Canvas, centerX, centerY, innerRadius, outerRadius, BrushSelector, false); // Update legend symbols inside legends. // Use a fixed innerRadius innerRadius = (Hole > 0) ? 2 : 0; foreach (var legendSymbol in _legendSymbols) DrawPieChart(legendSymbol, 8, 8, innerRadius, 8, BrushSelector, true); }