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 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(); }
void InitializeStyles() { // Clear the previous controller cache _additionalPlotStyle = null; if (_combinedScatterLineGroupController != null) { _combinedScatterLineGroupController.ChildControlChanged -= EhView_ActiveChildControlChanged; _combinedScatterLineGroupController = null; } _styleControllerList.Clear(); // start to create new controllers if (_tempdoc.Style.Count > 0) { bool addHelperStyle = NeedsHelperStyle(); bool useCombinedTab = UseCombinedScatterLineGroupTab(); if (useCombinedTab) { List <ControlViewElement> combList = new List <ControlViewElement>(); // create the controllers IMVCANController ct1 = GetStyleController(_tempdoc.Style[0]); _styleControllerList.Add(ct1); if (addHelperStyle) { IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing <IPlotArea>(_doc); // add either line or scatter if (_tempdoc.Style[0] is LinePlotStyle) { ScatterPlotStyle scatterStyle = new ScatterPlotStyle(); scatterStyle.ParentObject = _tempdoc.Style; _tempdoc.Style.PrepareNewSubStyle(scatterStyle, layer, _doc.GetRangesAndPoints(layer)); _additionalPlotStyle = scatterStyle; scatterStyle.Shape = Altaxo.Graph.Gdi.Plot.Styles.XYPlotScatterStyles.Shape.NoSymbol; _additionalPlotStyleController = GetStyleController(_additionalPlotStyle); combList.Add(new ControlViewElement("Symbol", _additionalPlotStyleController)); combList.Add(new ControlViewElement("Line", ct1)); } else { LinePlotStyle lineStyle = new LinePlotStyle(); lineStyle.ParentObject = _tempdoc.Style; _tempdoc.Style.PrepareNewSubStyle(lineStyle, layer, _doc.GetRangesAndPoints(layer)); _additionalPlotStyle = lineStyle; lineStyle.Connection = Altaxo.Graph.Gdi.Plot.Styles.XYPlotLineStyles.ConnectionStyle.NoLine; _additionalPlotStyleController = GetStyleController(_additionalPlotStyle); combList.Add(new ControlViewElement("Symbol", ct1)); combList.Add(new ControlViewElement("Line", _additionalPlotStyleController)); } } else // no helper style, i.e. second style is line style { // create the controllers IMVCANController ct2 = GetStyleController(_tempdoc.Style[1]); _styleControllerList.Add(ct2); combList.Add(new ControlViewElement("Symbol", ct1)); combList.Add(new ControlViewElement("Line", ct2)); } combList.Add(new ControlViewElement(string.Empty, this, this._plotGroupView)); _combinedScatterLineGroupController = new Common.MultiChildController(combList.ToArray(), true); Current.Gui.FindAndAttachControlTo(_combinedScatterLineGroupController); string title; if (null != _additionalPlotStyle) { title = string.Format("#{0}:{1}", 1, Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[0].GetType())); } else { title = "#1&&2:Symbol&&Line"; } AddTab(title, _combinedScatterLineGroupController, _combinedScatterLineGroupController.ViewObject); _combinedScatterLineGroupController.ChildControlChanged += this.EhView_ActiveChildControlChanged; } // if use CombinedTab // now the remaining styles int start = useCombinedTab ? (addHelperStyle ? 1 : 2) : 0; for (int i = start; i < _tempdoc.Style.Count; i++) { IMVCANController ctrl = GetStyleController(_tempdoc.Style[i]); _styleControllerList.Add(ctrl); string title = string.Format("#{0}:{1}", (i + 1), Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[i].GetType())); AddTab(title, ctrl, ctrl != null ? ctrl.ViewObject : null); } } base.SetElements(false); }