/// <summary> /// Updates the axes, if required. /// </summary> private void UpdateAxes() { XAxis1.Update(); YAxis1.Update(); XAxis2.Update(); YAxis2.Update(); }
private bool cached = false; // at least 1 axis has been cached /// <summary> /// Cache the current axes /// </summary> public void CacheAxes() { if (!cached) { if (XAxis1 != null) { xAxis1Cache = (Axis)XAxis1.Clone(); cached = true; } if (XAxis2 != null) { xAxis2Cache = (Axis)XAxis2.Clone(); cached = true; } if (YAxis1 != null) { yAxis1Cache = (Axis)YAxis1.Clone(); cached = true; } if (YAxis2 != null) { yAxis2Cache = (Axis)YAxis2.Clone(); cached = true; } } }
/// <summary> /// Define all PlotSurface X-Axes to minProportion, maxProportion /// </summary> public void DefineXAxes(double minProportion, double maxProportion) { if (XAxis1 != null) { XAxis1.DefineRange(minProportion, maxProportion, true); } if (XAxis2 != null) { XAxis2.DefineRange(minProportion, maxProportion, true); } }
/// <summary> /// Zoom all PlotSurface X-Axes about focusPoint by zoomProportion /// </summary> public void ZoomXAxes(double zoomProportion, double focusRatio) { if (XAxis1 != null) { XAxis1.IncreaseRange(zoomProportion, focusRatio); } if (XAxis2 != null) { XAxis2.IncreaseRange(zoomProportion, focusRatio); } }
/// <summary> /// Translate all PlotSurface X-Axes by shiftProportion /// </summary> public void TranslateXAxes(double shiftProportion) { if (XAxis1 != null) { XAxis1.TranslateRange(shiftProportion); } if (XAxis2 != null) { XAxis2.TranslateRange(shiftProportion); } }
void DetermineAxesToDraw(out Axis xAxis_1, out Axis xAxis_2, out Axis yAxis_1, out Axis yAxis_2) { xAxis_1 = XAxis1; xAxis_2 = XAxis2; yAxis_1 = YAxis1; yAxis_2 = YAxis2; if (XAxis1 == null) { if (XAxis2 == null) { throw new XwPlotException("Error: No X-Axis specified"); } xAxis_1 = (Axis)XAxis2.Clone(); xAxis_1.HideTickText = true; xAxis_1.TicksAngle = -Math.PI / 2; } if (XAxis2 == null) { // don't need to check if XAxis1 == null, as case already handled above. xAxis_2 = (Axis)XAxis1.Clone(); xAxis_2.HideTickText = true; xAxis_2.TicksAngle = Math.PI / 2.0; } if (YAxis1 == null) { if (YAxis2 == null) { throw new XwPlotException("Error: No Y-Axis specified"); } yAxis_1 = (Axis)YAxis2.Clone(); yAxis_1.HideTickText = true; yAxis_1.TicksAngle = Math.PI / 2.0; } if (YAxis2 == null) { // don't need to check if YAxis1 == null, as case already handled above. yAxis_2 = (Axis)YAxis1.Clone(); yAxis_2.HideTickText = true; yAxis_2.TicksAngle = -Math.PI / 2.0; } }
/// <summary> /// Zoom all PlotSurface X-Axes about focusPoint by zoomProportion /// </summary> public void ZoomXAxes(double zoomProportion, double focusRatio) { if (XAxis1 != null) { XAxis1.IncreaseRange(zoomProportion, focusRatio); } if (XAxis2 != null) { XAxis2.IncreaseRange(zoomProportion, focusRatio); } for (int i = 0; i < xAxisOverrides_.Count; i++) { if (xAxisOverrides_[i] != null) { ((Axis)xAxisOverrides_[i]).IncreaseRange(zoomProportion, focusRatio); } } }
/// <summary> /// Translate all PlotSurface X-Axes by shiftProportion /// </summary> public void TranslateXAxes(double shiftProportion) { if (XAxis1 != null) { XAxis1.TranslateRange(shiftProportion); } if (XAxis2 != null) { XAxis2.TranslateRange(shiftProportion); } for (int i = 0; i < xAxisOverrides_.Count; i++) { if (xAxisOverrides_[i] != null) { ((Axis)xAxisOverrides_[i]).TranslateRange(shiftProportion); } } }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left && allowSelection_) { endPoint_.X = e.X; endPoint_.Y = e.Y; // terminate mouse action mouseActionInitiated_ = false; if (endPoint_ != unset_) { DrawRubberBand(startPoint_, endPoint_); } Point minPoint = new Point(0, 0); minPoint.X = Math.Min(startPoint_.X, endPoint_.X); minPoint.Y = Math.Min(startPoint_.Y, endPoint_.Y); Point maxPoint = new Point(0, 0); maxPoint.X = Math.Max(startPoint_.X, endPoint_.X); maxPoint.Y = Math.Max(startPoint_.Y, endPoint_.Y); Rectangle r = ps_.PlotAreaBoundingBoxCache; if (minPoint != maxPoint && (r.Contains(minPoint) || r.Contains(maxPoint))) { if (xAxis1Cache_ == null) { xAxis1Cache_ = (Axis)XAxis1.Clone(); xAxis2Cache_ = (Axis)XAxis2.Clone(); yAxis1Cache_ = (Axis)YAxis1.Clone(); yAxis2Cache_ = (Axis)YAxis2.Clone(); } // TODO: these bugger up if min/max point reversed. // think this implies can't have axes directed wrong way. // check out later. // middle wheel will be controlling zoom in future. left mouse may // be drag => stack zoom out not long term solution, so just make // zoom out go right out at this stage. if (XAxis1 != null) { double tempMin = PhysicalXAxis1Cache.PhysicalToWorld(minPoint, true); XAxis1.WorldMax = PhysicalXAxis1Cache.PhysicalToWorld(maxPoint, true); XAxis1.WorldMin = tempMin; } if (XAxis2 != null) { double tempMin = PhysicalXAxis2Cache.PhysicalToWorld(minPoint, true); XAxis2.WorldMax = PhysicalXAxis2Cache.PhysicalToWorld(maxPoint, true); XAxis2.WorldMin = tempMin; } if (YAxis1 != null) { double tempMin = PhysicalYAxis1Cache.PhysicalToWorld(maxPoint, true); YAxis1.WorldMax = PhysicalYAxis1Cache.PhysicalToWorld(minPoint, true); YAxis1.WorldMin = tempMin; } if (YAxis2 != null) { double tempMin = PhysicalYAxis2Cache.PhysicalToWorld(maxPoint, true); YAxis2.WorldMax = PhysicalYAxis2Cache.PhysicalToWorld(minPoint, true); YAxis2.WorldMin = tempMin; } // reset the start/end points startPoint_ = unset_; endPoint_ = unset_; Refresh(); } } else if (e.Button == MouseButtons.Right) { if (xAxis1Cache_ != null) { XAxis1 = xAxis1Cache_; XAxis2 = xAxis2Cache_; YAxis1 = yAxis1Cache_; YAxis2 = yAxis2Cache_; xAxis1Cache_ = null; xAxis2Cache_ = null; yAxis1Cache_ = null; yAxis2Cache_ = null; } Refresh(); } // don't fail to call the base method! base.OnMouseUp(e); }
void UpdateAxes(bool recalculateAll) { if (drawables.Count != xAxisPositions.Count || drawables.Count != yAxisPositions.Count) { throw new XwPlotException("plots and axis position arrays our of sync"); } int position = 0; // if we're not recalculating axes using all iplots then set // position to last one in list. if (!recalculateAll) { position = drawables.Count - 1; if (position < 0) { position = 0; } } if (recalculateAll) { XAxis1 = null; YAxis1 = null; XAxis2 = null; YAxis2 = null; } for (int i = position; i < drawables.Count; ++i) { // only update axes if this drawable is an IPlot. if (!(drawables[i] is IPlot)) { continue; } IPlot p = (IPlot)drawables[i]; XAxisPosition xap = (XAxisPosition)xAxisPositions[i]; YAxisPosition yap = (YAxisPosition)yAxisPositions[i]; if (xap == XAxisPosition.Bottom) { if (XAxis1 == null) { XAxis1 = p.SuggestXAxis(); if (XAxis1 != null) { XAxis1.TicksAngle = -Math.PI / 2.0; } } else { XAxis1.LUB(p.SuggestXAxis()); } if (XAxis1 != null) { XAxis1.MinPhysicalLargeTickStep = 50; if (AutoScaleAutoGeneratedAxes) { XAxis1.AutoScaleText = true; XAxis1.AutoScaleTicks = true; XAxis1.TicksIndependentOfPhysicalExtent = true; } else { XAxis1.AutoScaleText = false; XAxis1.AutoScaleTicks = false; XAxis1.TicksIndependentOfPhysicalExtent = false; } } } if (xap == XAxisPosition.Top) { if (XAxis2 == null) { XAxis2 = p.SuggestXAxis(); if (XAxis2 != null) { XAxis2.TicksAngle = Math.PI / 2.0; } } else { XAxis2.LUB(p.SuggestXAxis()); } if (XAxis2 != null) { XAxis2.MinPhysicalLargeTickStep = 50; if (AutoScaleAutoGeneratedAxes) { XAxis2.AutoScaleText = true; XAxis2.AutoScaleTicks = true; XAxis2.TicksIndependentOfPhysicalExtent = true; } else { XAxis2.AutoScaleText = false; XAxis2.AutoScaleTicks = false; XAxis2.TicksIndependentOfPhysicalExtent = false; } } } if (yap == YAxisPosition.Left) { if (YAxis1 == null) { YAxis1 = p.SuggestYAxis(); if (YAxis1 != null) { YAxis1.TicksAngle = Math.PI / 2.0; } } else { YAxis1.LUB(p.SuggestYAxis()); } if (YAxis1 != null) { if (AutoScaleAutoGeneratedAxes) { YAxis1.AutoScaleText = true; YAxis1.AutoScaleTicks = true; YAxis1.TicksIndependentOfPhysicalExtent = true; } else { YAxis1.AutoScaleText = false; YAxis1.AutoScaleTicks = false; YAxis1.TicksIndependentOfPhysicalExtent = false; } } } if (yap == YAxisPosition.Right) { if (YAxis2 == null) { YAxis2 = p.SuggestYAxis(); if (YAxis2 != null) { YAxis2.TicksAngle = -Math.PI / 2.0; } } else { YAxis2.LUB(p.SuggestYAxis()); } if (YAxis2 != null) { if (AutoScaleAutoGeneratedAxes) { YAxis2.AutoScaleText = true; YAxis2.AutoScaleTicks = true; YAxis2.TicksIndependentOfPhysicalExtent = true; } else { YAxis2.AutoScaleText = false; YAxis2.AutoScaleTicks = false; YAxis2.TicksIndependentOfPhysicalExtent = false; } } } } }