protected virtual void SetElements(bool bInit) { if (bInit) { _orgRescaling = _doc.OrgRescaling; _endRescaling = _doc.EndRescaling; _spanRescaling = _doc.SpanRescaling; _org = _doc.Org; _end = _doc.End; _span = _doc.Span; if (_axis != null) { if (_orgRescaling == BoundaryRescaling.Auto) { _org = _axis.Org; } if (_endRescaling == BoundaryRescaling.Auto) { _end = _axis.End; } if (_spanRescaling == BoundaryRescaling.Auto) { _span = _axis.End - _axis.Org; } } } if (null != _view) { InitView(); } }
/// <summary>Copies from another instance.</summary> /// <param name="obj">The other instance to copy from.</param> /// <returns>True if at least some data could be copied.</returns> public virtual bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } var from = obj as NumericScaleRescaleConditions; if (null == from) { return(false); } _orgRescaling = from._orgRescaling; _endRescaling = from._endRescaling; _userProvidedOrgRelativeTo = from._userProvidedOrgRelativeTo; _userProvidedEndRelativeTo = from._userProvidedEndRelativeTo; _userProvidedOrgValue = from._userProvidedOrgValue; _userProvidedEndValue = from._userProvidedEndValue; _dataBoundsOrg = from._dataBoundsOrg; _dataBoundsEnd = from._dataBoundsEnd; _resultingOrg = from._resultingOrg; _resultingEnd = from._resultingEnd; _resultingMinOrg = from._resultingMinOrg; _resultingMaxEnd = from._resultingMaxEnd; EhSelfChanged(EventArgs.Empty); return(true); }
public virtual void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { bool isChange = _orgRescaling != orgRescaling || _userProvidedOrgRelativeTo != orgRelativeTo || _userProvidedOrgValue != orgValue || _endRescaling != endRescaling || _userProvidedEndRelativeTo != endRelativeTo || _userProvidedEndValue != endValue; _orgRescaling = orgRescaling; _userProvidedOrgRelativeTo = orgRelativeTo; _userProvidedOrgValue = orgValue; _endRescaling = endRescaling; _userProvidedEndRelativeTo = endRelativeTo; _userProvidedEndValue = endValue; if (isChange) { ProcessOrg_UserParametersChanged(); ProcessEnd_UserParametersChanged(); EhSelfChanged(); } }
public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { if (double.IsNaN(orgValue) || !Altaxo.Calc.RMath.IsFinite(orgValue) || orgValue <= 0) { if (orgRescaling == BoundaryRescaling.Auto) { orgValue = DefaultOrgValue; // ignore this error and set org to 1 } else { throw new ArgumentOutOfRangeException("orgValue should be a finite and positive number but is " + orgValue.ToString()); } } if (double.IsNaN(endValue) || !Altaxo.Calc.RMath.IsFinite(endValue) || endValue <= 0) { if (endRescaling == BoundaryRescaling.Auto) { endValue = DefaultEndValue; // ignore this error and set org to 10 } else { throw new ArgumentOutOfRangeException("endValue should be a finite and positive number but is " + endValue.ToString()); } } base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue); }
/// <summary> /// Restricts the values of orgRescaling, endRescaling and spanRescaling to allowed combinations. /// </summary> /// <param name="orgRes">Org rescaling.</param> /// <param name="endRes">End rescaling.</param> /// <param name="spanRes">Span Rescaling.</param> public static void Normalize( ref BoundaryRescaling orgRes, ref BoundaryRescaling endRes, ref BoundaryRescaling spanRes) { if (spanRes == BoundaryRescaling.UseSpan) { spanRes = BoundaryRescaling.Fixed; } if (orgRes == BoundaryRescaling.UseSpan && endRes == BoundaryRescaling.UseSpan) { orgRes = BoundaryRescaling.Auto; endRes = BoundaryRescaling.Auto; } if (orgRes == BoundaryRescaling.UseSpan && spanRes == BoundaryRescaling.Auto) { orgRes = BoundaryRescaling.Auto; } if (endRes == BoundaryRescaling.UseSpan && spanRes == BoundaryRescaling.Auto) { endRes = BoundaryRescaling.Auto; } }
/// <summary> /// Restricts the values of orgRescaling, endRescaling and spanRescaling to allowed combinations. /// </summary> /// <param name="orgRes">Org rescaling.</param> /// <param name="endRes">End rescaling.</param> /// <param name="spanRes">Span Rescaling.</param> public static void Normalize( ref BoundaryRescaling orgRes, ref BoundaryRescaling endRes, ref BoundaryRescaling spanRes) { NumericAxisRescaleConditions.Normalize(ref orgRes, ref endRes, ref spanRes); }
public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { if (orgRelativeTo != BoundariesRelativeTo.Absolute) throw new ArgumentException(string.Format("{0} does only support orgRelativeTo={1}", this.GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute))); if (endRelativeTo != BoundariesRelativeTo.Absolute) throw new ArgumentException(string.Format("{0} does only support endRelativeTo={1}", this.GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute))); if (double.IsNaN(orgValue) || !(0 < orgValue && orgValue < 1)) { if (orgRescaling == BoundaryRescaling.Auto) orgValue = DefaultOrgValue; // ignore this error and set org to 0 else throw new ArgumentOutOfRangeException("orgValue should be a number 0 < orgValue < 1, but is " + orgValue.ToString()); } if (double.IsNaN(endValue) || !(0 < endValue && endValue < 1)) { if (endRescaling == BoundaryRescaling.Auto) endValue = DefaultEndValue; // ignore this error and set end to 1 else throw new ArgumentOutOfRangeException("endValue should be number 0 < endValue < 1, but is " + endValue.ToString()); } base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue); }
protected virtual void SetElements(bool bInit) { if(bInit) { _orgRescaling = _doc.OrgRescaling; _endRescaling = _doc.EndRescaling; _spanRescaling = _doc.SpanRescaling; _org = _doc.Org; _end = _doc.End; _span = _doc.Span; if(_axis!=null) { if(_orgRescaling==BoundaryRescaling.Auto) _org = _axis.Org; if(_endRescaling==BoundaryRescaling.Auto) _end = _axis.End; if(_spanRescaling==BoundaryRescaling.Auto) _span = _axis.End - _axis.Org; } } if(null!=_view) InitView(); }
/// <summary> /// Sets the scaling behaviour to auto for both ends of the axis. /// </summary> public virtual void SetAuto() { _orgRescaling = BoundaryRescaling.Auto; _endRescaling = BoundaryRescaling.Auto; _spanRescaling = BoundaryRescaling.Auto; OnChanged(); }
/// <summary> /// Sets the scaling behavior so, that a certain size (end-org) of the axis is maintained. /// </summary> /// <param name="spanRescaling">The type of scaling for the axis span.</param> /// <param name="span">The axis span value. If spanRescaling is Auto, this value is ignored.</param> public virtual void SetSpan(BoundaryRescaling spanRescaling, TimeSpan span) { _spanRescaling = spanRescaling; _span = span; _orgRescaling = BoundaryRescaling.Auto; _endRescaling = BoundaryRescaling.Auto; OnChanged(); }
/// <summary> /// Sets the scaling behaviour of the axis by providing org and end values. /// </summary> /// <param name="orgRescaling">Type of scaling behaviour for the axis origin.</param> /// <param name="org">The axis org value. If orgRescaling is Auto, this value is ignored.</param> /// <param name="endRescaling">Type of scaling behaviour for the axis end.</param> /// <param name="end">The axis end value. If endRescaling is Auto, this value is ignored.</param> public virtual void SetOrgAndEnd(BoundaryRescaling orgRescaling, DateTime org, BoundaryRescaling endRescaling, DateTime end) { _orgRescaling = orgRescaling; _org = org; _endRescaling = endRescaling; _end = end; _spanRescaling = BoundaryRescaling.Auto; OnChanged(); }
public virtual void SetOrgEndSpan(BoundaryRescaling orgRescaling, double org, BoundaryRescaling endRescaling, double end, BoundaryRescaling spanRescaling, double span) { _orgRescaling = orgRescaling; _org = org; _endRescaling = endRescaling; _end = end; _spanRescaling = spanRescaling; _span = span; Normalize(ref _orgRescaling, ref _endRescaling, ref _spanRescaling); OnChanged(); }
/// <summary> /// Sets the scaling behavior so, that a certain size (end-org) of the axis is maintained. /// </summary> /// <param name="spanRescaling">The type of scaling for the axis span.</param> /// <param name="span">The axis span value. If spanRescaling is Auto, this value is ignored.</param> public virtual void SetSpan(BoundaryRescaling spanRescaling, double span) { _spanRescaling = spanRescaling; _span = span; _orgRescaling = BoundaryRescaling.Auto; _endRescaling = BoundaryRescaling.Auto; Normalize(ref _orgRescaling, ref _endRescaling, ref _spanRescaling); OnChanged(); }
/// <summary> /// Copies the data from another object. /// </summary> /// <param name="from">The object to copy the data from.</param> public void CopyFrom(DateTimeAxisRescaleConditions from) { bool bEqual = this.IsEqualTo(from); this._orgRescaling = from._orgRescaling; this._endRescaling = from._endRescaling; this._spanRescaling = from._spanRescaling; this._org = from._org; this._end = from._end; this._span = from._span; if(!bEqual) OnChanged(); }
/// <summary> /// Sets the scaling behaviour of the axis by providing org and end values. /// </summary> /// <param name="orgRescaling">Type of scaling behaviour for the axis origin.</param> /// <param name="org">The axis org value. If orgRescaling is Auto, this value is ignored.</param> /// <param name="endRescaling">Type of scaling behaviour for the axis end.</param> /// <param name="end">The axis end value. If endRescaling is Auto, this value is ignored.</param> public virtual void SetOrgAndEnd(BoundaryRescaling orgRescaling, double org, BoundaryRescaling endRescaling, double end) { _orgRescaling = orgRescaling; _org = org; _endRescaling = endRescaling; _end = end; _spanRescaling = BoundaryRescaling.Auto; Normalize(ref _orgRescaling, ref _endRescaling, ref _spanRescaling); OnChanged(); }
protected void ProcessEnd_DataBoundsChanged() { var resultingUserProvidedEndValue = GetResultingEndFromUserProvidedEnd(); switch (_endRescaling) { case BoundaryRescaling.Fixed: case BoundaryRescaling.FixedManually: case BoundaryRescaling.FixedZoomable: _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.GreaterOrEqual: if (resultingUserProvidedEndValue >= _dataBoundsEnd) { _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = UnboundMaxEnd; // not fixed } else { _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed } break; case BoundaryRescaling.LessOrEqual: if (resultingUserProvidedEndValue <= _dataBoundsEnd) { _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // fixed } else { _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = resultingUserProvidedEndValue; // because resultingEnd can go further up to resultingUserProvidedValue } break; case BoundaryRescaling.Auto: _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed break; case BoundaryRescaling.AutoTempFixed: _endRescaling = BoundaryRescaling.Auto; // Fall back to auto rescaling _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed break; } }
// protected abstract double GetResultingEndFromDataBoundsEnd(); #endregion Resulting Org/End to/fron User Org/End #region Process Org End protected void ProcessOrg_DataBoundsChanged() { var resultingUserProvidedOrgValue = GetResultingOrgFromUserProvidedOrg(); switch (_orgRescaling) { case BoundaryRescaling.Fixed: case BoundaryRescaling.FixedManually: case BoundaryRescaling.FixedZoomable: _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.GreaterOrEqual: if (resultingUserProvidedOrgValue >= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = resultingUserProvidedOrgValue; // not fixed because resultingOrg can go further down to resultingUserProvidedOrgValue } break; case BoundaryRescaling.LessOrEqual: if (resultingUserProvidedOrgValue <= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = UnboundMinOrg; // Not fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed } break; case BoundaryRescaling.Auto: _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; case BoundaryRescaling.AutoTempFixed: _orgRescaling = BoundaryRescaling.Auto; _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; } }
public static SelectableListNodeList CreateListNodeList(BoundaryRescaling rescalingValue) { var result = new SelectableListNodeList(); var values = System.Enum.GetValues(rescalingValue.GetType()); foreach (var value in values) { Type t = value.GetType(); string description = Current.ResourceService.GetString("ClassNames." + t.FullName + "." + Enum.GetName(t, value) + ".Description"); result.Add(new ListNodeWithDescription(value.ToString(), value, value.ToString() == rescalingValue.ToString(), description)); } return(result); }
/// <summary> /// Copies the data from another object. /// </summary> /// <param name="from">The object to copy the data from.</param> public void CopyFrom(DateTimeAxisRescaleConditions from) { bool bEqual = this.IsEqualTo(from); this._orgRescaling = from._orgRescaling; this._endRescaling = from._endRescaling; this._spanRescaling = from._spanRescaling; this._org = from._org; this._end = from._end; this._span = from._span; if (!bEqual) { OnChanged(); } }
protected void ProcessOrg_UserZoomed(double zoomValueOrg) { var resultingUserProvidedOrgValue = GetResultingOrgFromUserProvidedOrg(); switch (_orgRescaling) { case BoundaryRescaling.Auto: _orgRescaling = BoundaryRescaling.AutoTempFixed; _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(_resultingOrg); break; case BoundaryRescaling.AutoTempFixed: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(_resultingOrg); break; case BoundaryRescaling.Fixed: // Ignore zoom break; case BoundaryRescaling.FixedManually: // use the new values as user provided values _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(zoomValueOrg); break; case BoundaryRescaling.FixedZoomable: // use the new values, but keep user provided values _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.LessOrEqual: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.GreaterOrEqual: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; } }
protected void ProcessEnd_UserZoomed(double zoomValueEnd) { var resultingUserProvidedEndValue = GetResultingEndFromUserProvidedEnd(); switch (_endRescaling) { case BoundaryRescaling.Auto: _endRescaling = BoundaryRescaling.AutoTempFixed; _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(_resultingEnd); break; case BoundaryRescaling.AutoTempFixed: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(_resultingEnd); break; case BoundaryRescaling.Fixed: // Ignore zoom break; case BoundaryRescaling.FixedManually: // use the new values as user provided values _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(zoomValueEnd); break; case BoundaryRescaling.FixedZoomable: // use the new values, but keep user provided values _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.LessOrEqual: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.GreaterOrEqual: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; } }
/// <summary> /// Copies the data from another object. /// </summary> /// <param name="from">The object to copy the data from.</param> public void CopyFrom(NumericAxisRescaleConditions from) { bool bEqual = this.IsEqualTo(from); this._orgRescaling = from._orgRescaling; this._endRescaling = from._endRescaling; this._spanRescaling = from._spanRescaling; this._org = from._org; this._end = from._end; this._span = from._span; this._minGrace = from._minGrace; this._maxGrace = from._maxGrace; if (!bEqual) { OnChanged(); } }
public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { if (double.IsNaN(orgValue) || !Altaxo.Calc.RMath.IsFinite(orgValue)) { if (orgRescaling == BoundaryRescaling.Auto) orgValue = DefaultOrgValue; // ignore this error and set org to 0 else throw new ArgumentOutOfRangeException("orgValue should be a finite number but is " + orgValue.ToString()); } if (double.IsNaN(endValue) || !Altaxo.Calc.RMath.IsFinite(endValue)) { if (endRescaling == BoundaryRescaling.Auto) endValue = DefaultEndValue; // ignore this error and set end to 1 else throw new ArgumentOutOfRangeException("endValue should be a finite number but is " + endValue.ToString()); } base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue); }
void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue) { long orgV, endV; DateTimeKind orgK, endK; if (orgValue.IsType(Data.AltaxoVariant.Content.VDateTime)) { var dt = orgValue.ToDateTime(); orgV = dt.Ticks; orgK = dt.Kind; } else if (orgValue.CanConvertedToDouble) { double v = orgValue.ToDouble(); orgV = (long)(v * 1E7); orgK = DateTimeKind.Utc; } else { throw new InvalidOperationException("Can not convert orgValue to either a DateTime or a double value."); } if (endValue.IsType(Data.AltaxoVariant.Content.VDateTime)) { var dt = endValue.ToDateTime(); endV = dt.Ticks; endK = dt.Kind; } else if (orgValue.CanConvertedToDouble) { double v = endValue.ToDouble(); endV = (long)(v * 1E7); endK = DateTimeKind.Utc; } else { throw new InvalidOperationException("Can not convert endValue to either a DateTime or a double value."); } SetUserParameters(orgRescaling, orgRelativeTo, orgV, orgK, endRescaling, endRelativeTo, endV, endK); }
public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { if (orgRelativeTo != BoundariesRelativeTo.Absolute) { throw new ArgumentException(string.Format("{0} does only support orgRelativeTo={1}", GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute))); } if (endRelativeTo != BoundariesRelativeTo.Absolute) { throw new ArgumentException(string.Format("{0} does only support endRelativeTo={1}", GetType().Name, Enum.GetName(typeof(BoundariesRelativeTo), BoundariesRelativeTo.Absolute))); } if (double.IsNaN(orgValue) || !(0 < orgValue && orgValue < 1)) { if (orgRescaling == BoundaryRescaling.Auto) { orgValue = DefaultOrgValue; // ignore this error and set org to 0 } else { throw new ArgumentOutOfRangeException("orgValue should be a number 0 < orgValue < 1, but is " + orgValue.ToString()); } } if (double.IsNaN(endValue) || !(0 < endValue && endValue < 1)) { if (endRescaling == BoundaryRescaling.Auto) { endValue = DefaultEndValue; // ignore this error and set end to 1 } else { throw new ArgumentOutOfRangeException("endValue should be number 0 < endValue < 1, but is " + endValue.ToString()); } } base.SetUserParameters(orgRescaling, orgRelativeTo, orgValue, endRescaling, endRelativeTo, endValue); }
void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue) { double orgV, endV; if (orgValue.CanConvertedToDouble) { orgV = orgValue.ToDouble(); } else { throw new InvalidOperationException("Can not convert orgValue to a double value."); } if (orgValue.CanConvertedToDouble) { endV = endValue.ToDouble(); } else { throw new InvalidOperationException("Can not convert endValue to a double value."); } SetUserParameters(orgRescaling, orgRelativeTo, orgV, endRescaling, endRelativeTo, endV); }
public virtual void SetUserParameters(BoundaryRescaling orgRescaling, DateTime orgValue, BoundaryRescaling endRescaling, DateTime endValue) { SetUserParameters(orgRescaling, BoundariesRelativeTo.Absolute, orgValue.Ticks, orgValue.Kind, endRescaling, BoundariesRelativeTo.Absolute, endValue.Ticks, endValue.Kind); }
public void EhChoice2Changed(string txt, int selected) { _endRescaling = (BoundaryRescaling)selected; }
public override void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, double orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, double endValue) { orgValue = 1 / orgValue; endValue = 1 / endValue; bool isChange = _orgRescaling != orgRescaling || _userProvidedOrgRelativeTo != orgRelativeTo || _userProvidedOrgValue != orgValue || _endRescaling != endRescaling || _userProvidedEndRelativeTo != endRelativeTo || _userProvidedEndValue != endValue; _orgRescaling = orgRescaling; _userProvidedOrgRelativeTo = orgRelativeTo; _userProvidedOrgValue = orgValue; _endRescaling = endRescaling; _userProvidedEndRelativeTo = endRelativeTo; _userProvidedEndValue = endValue; if (isChange) { ProcessOrg_UserParametersChanged(); ProcessEnd_UserParametersChanged(); EhSelfChanged(); } }
void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue) { double orgV, endV; if (orgValue.CanConvertedToDouble) { orgV = orgValue.ToDouble(); } else { throw new InvalidOperationException("Can not convert orgValue to a double value."); } if (orgValue.CanConvertedToDouble) { endV = endValue.ToDouble(); } else { throw new InvalidOperationException("Can not convert endValue to a double value."); } this.SetUserParameters(orgRescaling, orgRelativeTo, orgV, endRescaling, endRelativeTo, endV); }
public void EhChoice3Changed(string txt, int selected) { _spanRescaling = (BoundaryRescaling)selected; SetEnableState(); }
/// <summary> /// Restricts the values of orgRescaling, endRescaling and spanRescaling to allowed combinations. /// </summary> /// <param name="orgRes">Org rescaling.</param> /// <param name="endRes">End rescaling.</param> /// <param name="spanRes">Span Rescaling.</param> public static void Normalize( ref BoundaryRescaling orgRes, ref BoundaryRescaling endRes, ref BoundaryRescaling spanRes) { if(spanRes==BoundaryRescaling.UseSpan) spanRes=BoundaryRescaling.Fixed; if(orgRes==BoundaryRescaling.UseSpan && endRes==BoundaryRescaling.UseSpan) { orgRes=BoundaryRescaling.Auto; endRes=BoundaryRescaling.Auto; } if(orgRes==BoundaryRescaling.UseSpan && spanRes==BoundaryRescaling.Auto) orgRes=BoundaryRescaling.Auto; if(endRes==BoundaryRescaling.UseSpan && spanRes==BoundaryRescaling.Auto) endRes=BoundaryRescaling.Auto; }
/// <summary> /// Sets the scaling behavior so, that a certain size (end-org) of the axis is maintained. /// </summary> /// <param name="spanRescaling">The type of scaling for the axis span.</param> /// <param name="span">The axis span value. If spanRescaling is Auto, this value is ignored.</param> public virtual void SetSpan(BoundaryRescaling spanRescaling, double span) { _spanRescaling = spanRescaling; _span = span; _orgRescaling = BoundaryRescaling.Auto; _endRescaling = BoundaryRescaling.Auto; Normalize(ref _orgRescaling,ref _endRescaling, ref _spanRescaling); OnChanged(); }
protected void ProcessOrg_UserZoomed(long zoomValueOrg) { var resultingUserProvidedOrgValue = GetResultingOrgFromUserProvidedOrg(); switch (_orgRescaling) { case BoundaryRescaling.Auto: _orgRescaling = BoundaryRescaling.AutoTempFixed; _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(_resultingOrg); break; case BoundaryRescaling.AutoTempFixed: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(_resultingOrg); break; case BoundaryRescaling.Fixed: // Ignore zoom break; case BoundaryRescaling.FixedManually: // use the new values as user provided values _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed _userProvidedOrgValue = GetUserProvidedOrgFromResultingOrg(zoomValueOrg); break; case BoundaryRescaling.FixedZoomable: // use the new values, but keep user provided values _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.LessOrEqual: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.GreaterOrEqual: _resultingOrg = zoomValueOrg; _resultingMinOrg = _resultingOrg; // Strictly fixed break; } }
protected void ProcessOrg_UserRescaled() { var resultingUserProvidedOrgValue = GetResultingOrgFromUserProvidedOrg(); switch (_orgRescaling) { case BoundaryRescaling.Auto: _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; case BoundaryRescaling.AutoTempFixed: _orgRescaling = BoundaryRescaling.Auto; // Fall back to Auto rescaling _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; case BoundaryRescaling.Fixed: _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.FixedManually: // TODO ask for switching to AutoTemp or AutoTempFixed // HERE as long as fixed manually, we treat this as fixed _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.FixedZoomable: // treat as fixed _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.LessOrEqual: if (resultingUserProvidedOrgValue <= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = UnboundMinOrg; // Not fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed } break; case BoundaryRescaling.GreaterOrEqual: if (resultingUserProvidedOrgValue >= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = resultingUserProvidedOrgValue; // not fixed till resultingUserProvidedOrg } break; } }
protected void ProcessEnd_UserRescaled() { var resultingUserProvidedEndValue = GetResultingEndFromUserProvidedEnd(); switch (_endRescaling) { case BoundaryRescaling.Auto: _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed break; case BoundaryRescaling.AutoTempFixed: _endRescaling = BoundaryRescaling.Auto; // Fall back to auto _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed break; case BoundaryRescaling.Fixed: _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.FixedManually: // TODO ask for switching to AutoTemp or AutoTempFixed // HERE as long as fixed manually, we treat this as fixed _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.FixedZoomable: // treat as fixed _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.GreaterOrEqual: if (resultingUserProvidedEndValue >= _dataBoundsEnd) { _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = UnboundMaxEnd; // not fixed } else { _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = UnboundMaxEnd; // not fixed } break; case BoundaryRescaling.LessOrEqual: if (resultingUserProvidedEndValue <= _dataBoundsEnd) { _resultingEnd = resultingUserProvidedEndValue; _resultingMaxEnd = _resultingEnd; // fixed } else { _resultingEnd = _dataBoundsEnd; _resultingMaxEnd = _userProvidedEndValue; // fixed until user provided end value } break; } }
protected void ProcessEnd_UserZoomed(long zoomValueEnd) { var resultingUserProvidedEndValue = GetResultingEndFromUserProvidedEnd(); switch (_endRescaling) { case BoundaryRescaling.Auto: _endRescaling = BoundaryRescaling.AutoTempFixed; _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(_resultingEnd); break; case BoundaryRescaling.AutoTempFixed: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(_resultingEnd); break; case BoundaryRescaling.Fixed: // Ignore zoom break; case BoundaryRescaling.FixedManually: // use the new values as user provided values _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed _userProvidedEndValue = GetUserProvidedEndFromResultingEnd(zoomValueEnd); break; case BoundaryRescaling.FixedZoomable: // use the new values, but keep user provided values _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.LessOrEqual: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; case BoundaryRescaling.GreaterOrEqual: _resultingEnd = zoomValueEnd; _resultingMaxEnd = _resultingEnd; // strictly fixed break; } }
/// <summary> /// Copies the data from another object. /// </summary> /// <param name="from">The object to copy the data from.</param> public void CopyFrom(NumericAxisRescaleConditions from) { bool bEqual = this.IsEqualTo(from); this._orgRescaling = from._orgRescaling; this._endRescaling = from._endRescaling; this._spanRescaling = from._spanRescaling; this._org = from._org; this._end = from._end; this._span = from._span; this._minGrace = from._minGrace; this._maxGrace = from._maxGrace; if(!bEqual) OnChanged(); }
protected void ProcessOrg_DataBoundsChanged() { var resultingUserProvidedOrgValue = GetResultingOrgFromUserProvidedOrg(); switch (_orgRescaling) { case BoundaryRescaling.Fixed: case BoundaryRescaling.FixedManually: case BoundaryRescaling.FixedZoomable: _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed break; case BoundaryRescaling.GreaterOrEqual: if (resultingUserProvidedOrgValue >= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = _resultingOrg; // Strictly fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = resultingUserProvidedOrgValue; // not fixed because resultingOrg can go further down to resultingUserProvidedOrgValue } break; case BoundaryRescaling.LessOrEqual: if (resultingUserProvidedOrgValue <= _dataBoundsOrg) { _resultingOrg = resultingUserProvidedOrgValue; _resultingMinOrg = UnboundMinOrg; // Not fixed } else { _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed } break; case BoundaryRescaling.Auto: _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; case BoundaryRescaling.AutoTempFixed: _orgRescaling = BoundaryRescaling.Auto; _resultingOrg = _dataBoundsOrg; _resultingMinOrg = UnboundMinOrg; // Not fixed break; } }
public virtual void SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, long orgValue, DateTimeKind orgValueKind, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, long endValue, DateTimeKind endValueKind) { bool isChange = _orgRescaling != orgRescaling || _userProvidedOrgRelativeTo != orgRelativeTo || _userProvidedOrgValue != orgValue || _endRescaling != endRescaling || _userProvidedEndRelativeTo != endRelativeTo || _userProvidedEndValue != endValue; _orgRescaling = orgRescaling; _userProvidedOrgRelativeTo = orgRelativeTo; _userProvidedOrgValue = orgValue; _endRescaling = endRescaling; _userProvidedEndRelativeTo = endRelativeTo; _userProvidedEndValue = endValue; if (isChange) { ProcessOrg_UserParametersChanged(); ProcessEnd_UserParametersChanged(); EhSelfChanged(); } }
public virtual void SetUserParameters(BoundaryRescaling orgRescaling, double orgValue, BoundaryRescaling endRescaling, double endValue) { SetUserParameters(orgRescaling, BoundariesRelativeTo.Absolute, orgValue, endRescaling, BoundariesRelativeTo.Absolute, endValue); }
/// <summary> /// Copies the data from another object. /// </summary> /// <param name="obj">The object to copy the data from.</param> public virtual bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) return true; var from = obj as DateTimeScaleRescaleConditions; if (null == from) return false; this._orgRescaling = from._orgRescaling; this._endRescaling = from._endRescaling; this._userProvidedOrgRelativeTo = from._userProvidedOrgRelativeTo; this._userProvidedEndRelativeTo = from._userProvidedEndRelativeTo; this._userProvidedOrgValue = from._userProvidedOrgValue; this._userProvidedOrgDateTimeKind = from._userProvidedOrgDateTimeKind; this._userProvidedEndValue = from._userProvidedEndValue; this._userProvidedEndDateTimeKind = from._userProvidedEndDateTimeKind; this._resultingOrg = from._resultingOrg; this._resultingEnd = from._resultingEnd; this._resultingMinOrg = from._resultingMinOrg; this._resultingMaxEnd = from._resultingMaxEnd; EhSelfChanged(EventArgs.Empty); return true; }
void IUnboundNumericScaleRescaleConditions.SetUserParameters(BoundaryRescaling orgRescaling, BoundariesRelativeTo orgRelativeTo, Data.AltaxoVariant orgValue, BoundaryRescaling endRescaling, BoundariesRelativeTo endRelativeTo, Data.AltaxoVariant endValue) { long orgV, endV; DateTimeKind orgK, endK; if (orgValue.IsType(Data.AltaxoVariant.Content.VDateTime)) { var dt = orgValue.ToDateTime(); orgV = dt.Ticks; orgK = dt.Kind; } else if (orgValue.CanConvertedToDouble) { double v = orgValue.ToDouble(); orgV = (long)(v * 1E7); orgK = DateTimeKind.Utc; } else { throw new InvalidOperationException("Can not convert orgValue to either a DateTime or a double value."); } if (endValue.IsType(Data.AltaxoVariant.Content.VDateTime)) { var dt = endValue.ToDateTime(); endV = dt.Ticks; endK = dt.Kind; } else if (orgValue.CanConvertedToDouble) { double v = endValue.ToDouble(); endV = (long)(v * 1E7); endK = DateTimeKind.Utc; } else { throw new InvalidOperationException("Can not convert endValue to either a DateTime or a double value."); } this.SetUserParameters(orgRescaling, orgRelativeTo, orgV, orgK, endRescaling, endRelativeTo, endV, endK); }