protected override string FormatItem(Altaxo.Data.AltaxoVariant item) { const double tolerance = 1E-8; int denominator = 1440; // this allows for resolution of a quarter of a degree if (!item.CanConvertedToDouble) { return(item.ToString()); } double value = item; double multipvalue = value * denominator / Math.PI; double multipround = Math.Round(multipvalue, 0); if (Math.Abs(multipvalue - multipround) < tolerance && Math.Abs(multipround) < int.MaxValue) // then it is a ratio of pi { int nominator = (int)multipround; Shorten(ref nominator, ref denominator); if (nominator == 0) { return("0"); } else { string pre; if (nominator == 1) { pre = string.Empty; } else if (nominator == -1) { pre = "-"; } else { pre = nominator.ToString(); } string post; if (denominator == 1) { post = string.Empty; } else { post = "/" + denominator.ToString(); } return(pre + '\u03c0' + post); } } return(item.ToString()); }
/// <summary> /// Processes a single value . /// If the data value is text, the boundaries are /// updated and the number of items is increased by one (if not contained already). The function returns true /// in this case. On the other hand, if the value is outside the range, the function has to /// return false. /// </summary> /// <param name="item">The data item.</param> /// <returns>True if data is in the tracked range, false if the data is not in the tracked range.</returns> public bool Add(Altaxo.Data.AltaxoVariant item) { if (!(item.IsType(Altaxo.Data.AltaxoVariant.Content.VString))) { return(false); } string s = item.ToString(); if (string.IsNullOrEmpty(s)) { return(false); // we consider empty string as invalid data here } if (IsSuspended) // when suspended: performance tweak, see overrides OnSuspended and OnResume for details (if suspended, we have saved the state of the instance for comparison when we resume). { if (!_itemList.Contains(s)) { _itemList.Add(s); } } else // not suspended: normal behaviour with change notification { if (!_itemList.Contains(s)) { _itemList.Add(s); EhSelfChanged(new BoundariesChangedEventArgs(BoundariesChangedData.NumberOfItemsChanged | BoundariesChangedData.UpperBoundChanged)); } } return(true); }
protected override string FormatItem(Altaxo.Data.AltaxoVariant item) { if (item.IsType(Altaxo.Data.AltaxoVariant.Content.VDouble)) { return(FormatItem(item)); } else { return(item.ToString()); } }
/// <summary> /// Processes a single value . /// If the data value is text, the boundaries are /// updated and the number of items is increased by one (if not contained already). The function returns true /// in this case. On the other hand, if the value is outside the range, the function has to /// return false. /// </summary> /// <param name="item">The data item.</param> /// <returns>True if data is in the tracked range, false if the data is not in the tracked range.</returns> public bool Add(Altaxo.Data.AltaxoVariant item) { if (item.IsType(Altaxo.Data.AltaxoVariant.Content.VString)) { string s = item.ToString(); if (!_itemList.Contains(s)) { _itemList.Add(s); if (_eventSuspendCount == 0) { OnNumberOfItemsChanged(); OnBoundaryChanged(false, true); } return(true); } } return(false); }
protected override string FormatItem(Altaxo.Data.AltaxoVariant item) { return(item.ToString()); }