public G2DPlotItemController(G2DPlotItem doc, PlotGroupStyleCollection parent) { if (!InitializeDocument(doc, parent)) { throw new ArgumentException(); } }
public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll) { Dictionary <G2DPlotItem, Processed2DPlotData> plotDataList; IPhysicalBoundaries pbclone = (IPhysicalBoundaries)pb.Clone(); // before we can use CanUseStyle, we have to give physical y boundaries template CoordinateTransformingStyleBase.MergeYBoundsInto(pbclone, coll); if (!CanUseStyle(layer, coll, out plotDataList)) { pb.Add(pbclone); return; } // we put zero into the y-Boundaries, since the addition starts with that value pb.Add(new AltaxoVariant(0.0)); AltaxoVariant[] ySumArray = null; int idx = -1; foreach (IGPlotItem pi in coll) { if (pi is G2DPlotItem) { idx++; G2DPlotItem gpi = (G2DPlotItem)pi; Processed2DPlotData pdata = plotDataList[gpi]; // Note: we can not use AddUp function here, since // when we have positive/negative items, the intermediate bounds // might be wider than the bounds of the end result if (ySumArray == null) { ySumArray = new AltaxoVariant[pdata.RangeList.PlotPointCount]; int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; ySumArray[j] = pdata.GetYPhysical(originalIndex); pb.Add(ySumArray[j]); } } else // this is not the first item { int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; ySumArray[j] += pdata.GetYPhysical(originalIndex); pb.Add(ySumArray[j]); } } } } }
public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll) { System.Drawing.Region[] clippingColl = new System.Drawing.Region[coll.Count]; Processed2DPlotData[] plotDataColl = new Processed2DPlotData[coll.Count]; double[] xincColl = new double[coll.Count]; double[] yincColl = new double[coll.Count]; int idx = -1; Processed2DPlotData previousPlotData = null; for (int i = 0; i < coll.Count; i++) { if (coll[i] is G2DPlotItem) { idx++; double currxinc = xincColl[i] = idx * _xinc * _scaleXInc; double curryinc = yincColl[i] = idx * _yinc * _scaleYInc; G2DPlotItem gpi = coll[i] as G2DPlotItem; Processed2DPlotData plotdata = plotDataColl[i] = gpi.GetRangesAndPoints(layer); plotdata.PreviousItemData = previousPlotData; previousPlotData = plotdata; int j = -1; foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices()) { j++; AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc; AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc; Logical3D rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy)); double xabs, yabs; layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs); plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs); } if (_useClipping) { GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); } } } for (int i = coll.Count - 1; i >= 0; i--) { if (null == plotDataColl[i]) { coll[i].Paint(g, layer); } else { TransformedLayerWrapper layerwrapper = new TransformedLayerWrapper(layer, xincColl[i], yincColl[i]); ((G2DPlotItem)coll[i]).Paint(g, layerwrapper, plotDataColl[i]); } } }
public static bool CanUseStyle(IPlotArea layer, PlotItemCollection coll, out Dictionary <G2DPlotItem, Processed2DPlotData> plotDataList) { plotDataList = new Dictionary <G2DPlotItem, Processed2DPlotData>(); AltaxoVariant[] xArray = null; int idx = -1; foreach (IGPlotItem pi in coll) { if (pi is G2DPlotItem) { idx++; G2DPlotItem gpi = (G2DPlotItem)pi; Processed2DPlotData pdata = gpi.GetRangesAndPoints(layer); plotDataList.Add(gpi, pdata); if (xArray == null) { xArray = new AltaxoVariant[pdata.RangeList.PlotPointCount]; int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; xArray[j] = pdata.GetXPhysical(originalIndex); } } else // this is not the first item { if (pdata.RangeList.PlotPointCount != xArray.Length) { return(false); } int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; if (xArray[j] != pdata.GetXPhysical(originalIndex)) { return(false); } } } } } return(idx >= 1); }
public virtual void EhView_AddStyle(int[] selindices, int nstyle) { IG2DPlotStyle style = (IG2DPlotStyle)Activator.CreateInstance(this._plotStyleTypes[nstyle]); IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing <IPlotArea>(_doc); G2DPlotItem plotitem = Main.DocumentPath.GetRootNodeImplementing <G2DPlotItem>(_doc); if (layer != null && plotitem != null) { _doc.PrepareNewSubStyle(style, layer, plotitem.GetRangesAndPoints(layer)); } _tempdoc.Add(style); UpdateStyleList(new int[] {}); OnCollectionChangeCommit(); }
public bool InitializeDocument(params object[] args) { if (args == null || args.Length == 0) { return(false); } if (!(args[0] is G2DPlotItem)) { return(false); } else { _doc = _tempdoc = (G2DPlotItem)args[0]; } if (args.Length >= 2 && args[1] != null) { if (!(args[1] is PlotGroupStyleCollection)) { return(false); } else { _groupStyles = (PlotGroupStyleCollection)args[1]; } } else { if (_doc.ParentCollection != null) { _groupStyles = _doc.ParentCollection.GroupStyles; } } if (_useDocument == UseDocument.Copy) { _tempdoc = (G2DPlotItem)_doc.Clone(); } InitializeCollectionAndData(); InitializeStyles(); BringTabToFront(2); return(true); }
public virtual void EhView_AddStyle() { var sel = _singleStylesAvailable.FirstSelectedNode; if (null == sel) { return; } var propertyContext = Altaxo.PropertyExtensions.GetPropertyContext(_doc); IG2DPlotStyle style = null; try { style = (IG2DPlotStyle)Activator.CreateInstance((Type)sel.Tag, propertyContext); // first try with a constructor which uses a property context } catch (System.MissingMethodException) { } if (null == style) // if style was not constructed { style = (IG2DPlotStyle)Activator.CreateInstance((Type)sel.Tag); // try with parameterless constructor } IPlotArea layer = AbsoluteDocumentPath.GetRootNodeImplementing <IPlotArea>(_doc); G2DPlotItem plotitem = AbsoluteDocumentPath.GetRootNodeImplementing <G2DPlotItem>(_doc); if (layer != null && plotitem != null) { _doc.PrepareNewSubStyle(style, layer, plotitem.GetRangesAndPoints(layer)); } _currentItems.Add <IG2DPlotStyle>(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(style.GetType()), style, true), (docNodeToAdd) => _doc.Add(docNodeToAdd)); OnCollectionChangeCommit(); }
public G2DPlotItemController(G2DPlotItem doc) : this(doc, null) { }
public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll) { Dictionary <G2DPlotItem, Processed2DPlotData> plotDataDict; if (!CanUseStyle(layer, coll, out plotDataDict)) { CoordinateTransformingStyleBase.Paint(g, layer, coll); return; } AltaxoVariant[] ysumArray = null; foreach (IGPlotItem pi in coll) { if (pi is G2DPlotItem) { G2DPlotItem gpi = pi as G2DPlotItem; Processed2DPlotData pdata = plotDataDict[gpi]; ysumArray = AbsoluteStackTransform.AddUp(ysumArray, pdata); } } // now plot the data - the summed up y is in yArray AltaxoVariant[] yArray = null; Processed2DPlotData previousItemData = null; foreach (IGPlotItem pi in coll) { if (pi is G2DPlotItem) { G2DPlotItem gpi = pi as G2DPlotItem; Processed2DPlotData pdata = plotDataDict[gpi]; yArray = AbsoluteStackTransform.AddUp(yArray, pdata); AltaxoVariant[] localArray = new AltaxoVariant[yArray.Length]; int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; AltaxoVariant y = 100 * yArray[j] / ysumArray[j]; localArray[j] = y; Logical3D rel = new Logical3D( layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)), layer.YAxis.PhysicalVariantToNormal(y)); double xabs, yabs; layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs); pdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs); } // we have also to exchange the accessor for the physical y value and replace it by our own one pdata.YPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i) { return(localArray[i]); }); pdata.PreviousItemData = previousItemData; previousItemData = pdata; } } for (int i = coll.Count - 1; i >= 0; --i) { IGPlotItem pi = coll[i]; if (pi is G2DPlotItem) { G2DPlotItem gpi = pi as G2DPlotItem; Processed2DPlotData pdata = plotDataDict[gpi]; gpi.Paint(g, layer, pdata); } else { pi.Paint(g, layer); } } }
public void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll) { Dictionary <G2DPlotItem, Processed2DPlotData> plotDataDict; if (!CanUseStyle(layer, coll, out plotDataDict)) { CoordinateTransformingStyleBase.Paint(g, layer, coll); return; } AltaxoVariant[] yArray = null; // First, add up all items since we start always with the last item int idx = -1; Processed2DPlotData previousItemData = null; foreach (IGPlotItem pi in coll) { if (pi is G2DPlotItem) { idx++; G2DPlotItem gpi = pi as G2DPlotItem; Processed2DPlotData pdata = plotDataDict[gpi]; yArray = AddUp(yArray, pdata); if (idx > 0) // this is not the first item { int j = -1; foreach (int originalIndex in pdata.RangeList.OriginalRowIndices()) { j++; Logical3D rel = new Logical3D( layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)), layer.YAxis.PhysicalVariantToNormal(yArray[j])); double xabs, yabs; layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs); pdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs); } } // we have also to exchange the accessor for the physical y value and replace it by our own one AltaxoVariant[] localArray = (AltaxoVariant[])yArray.Clone(); pdata.YPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i) { return(localArray[i]); }); pdata.PreviousItemData = previousItemData; previousItemData = pdata; } } for (int i = coll.Count - 1; i >= 0; --i) { IGPlotItem pi = coll[i]; if (pi is G2DPlotItem) { G2DPlotItem gpi = pi as G2DPlotItem; Processed2DPlotData pdata = plotDataDict[gpi]; gpi.Paint(g, layer, pdata); } else { pi.Paint(g, layer); } } }