public override void Draw(Graphics g, DrawContext dc, double xbase, double ybase) { var mylayer = (HostLayer)dc.LinkedObject; var layer = mylayer as XYPlotLayer; if (_layerNumber >= 0 && mylayer.SiblingLayers != null && _layerNumber < mylayer.SiblingLayers.Count) layer = mylayer.SiblingLayers[_layerNumber] as XYPlotLayer; if (null == layer) return; if (_plotNumber < layer.PlotItems.Flattened.Length) { var fontInfo = dc.FontCache.GetFontInfo(g, Style.FontId); IGPlotItem pa = layer.PlotItems.Flattened[_plotNumber]; var symbolpos = new PointF((float)xbase, (float)(ybase + 0.5 * fontInfo.cyDescent - 0.5 * fontInfo.cyAscent)); var symbolRect = new RectangleF(symbolpos, new SizeF((float)Width, 0)); symbolRect.Inflate(0, (float)(fontInfo.Size)); pa.PaintSymbol(g, symbolRect); if (!dc.bForPreview) { var gp = new GraphicsPath(); gp.AddRectangle(new RectangleF(symbolpos.X, (float)(symbolpos.Y - 0.5 * fontInfo.cyLineSpace), (float)Width, (float)(fontInfo.cyLineSpace))); gp.Transform(dc.transformMatrix); dc._cachedSymbolPositions.Add(gp, pa); } } }
private void EhWpfMenuItem_Clicked(object sender, System.Windows.RoutedEventArgs e) { var dmi = (System.Windows.Controls.MenuItem)sender; int plotItemNumber = (int)dmi.Tag; var ctrl = Current.Workbench.ActiveViewContent as Altaxo.Gui.Graph.Gdi.Viewing.GraphController; if (null == ctrl) { return; } var activeLayer = ctrl.ActiveLayer as XYPlotLayer; if (null == activeLayer) { return; } if (!dmi.IsChecked) { // if the menu item was not checked before, check it now // by making the plot association shown by the menu item // the actual plot association if (null != activeLayer && plotItemNumber < activeLayer.PlotItems.Flattened.Length) { dmi.IsChecked = true; ctrl.CurrentPlotNumber = plotItemNumber; } } else { IGPlotItem pa = activeLayer.PlotItems.Flattened[plotItemNumber]; Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true); } }
public override void Draw(IGraphicsContext3D g, DrawContext dc, double xbase, double ybase, double zbase) { var mylayer = (HostLayer)dc.LinkedObject; var layer = mylayer as XYZPlotLayer; if (_layerNumber >= 0 && mylayer.SiblingLayers != null && _layerNumber < mylayer.SiblingLayers.Count) { layer = mylayer.SiblingLayers[_layerNumber] as XYZPlotLayer; } if (null == layer) { return; } if (_plotNumber < layer.PlotItems.Flattened.Length) { var fontInfo = dc.FontCache.GetFontInfo(Style.FontId); IGPlotItem pa = layer.PlotItems.Flattened[_plotNumber]; var symbolpos = new PointD3D(xbase, (ybase + 0.5 * fontInfo.cyDescent - 0.5 * fontInfo.cyAscent), 0); var symbolRect = new RectangleD3D(symbolpos, new VectorD3D(SizeX, 0, 0)); symbolRect = symbolRect.WithPadding(0, fontInfo.Size, 0); pa.PaintSymbol(g, symbolRect); if (!dc.bForPreview) { var volume = new RectangleTransformedD3D( new RectangleD3D(symbolpos.X, symbolpos.Y - 0.5 * fontInfo.cyLineSpace, 0, SizeX, fontInfo.cyLineSpace, 0), dc.transformMatrix); dc._cachedSymbolPositions.Add(volume, pa); } } }
public IEnumerable <object> BuildItems(Codon codon, object owner) { var ctrl = Current.Workbench.ActiveViewContent as Altaxo.Gui.Graph.Gdi.Viewing.GraphController; if (null == ctrl) { return(null); } var activeLayer = ctrl.ActiveLayer as XYPlotLayer; if (null == activeLayer) { return(null); } int actPA = ctrl.CurrentPlotNumber; int len = activeLayer.PlotItems.Flattened.Length; var items = new List <object>(); for (int i = 0; i < len; i++) { IGPlotItem pa = activeLayer.PlotItems.Flattened[i]; var item = new System.Windows.Controls.MenuItem() { Header = pa.ToString() }; item.Click += EhWpfMenuItem_Clicked; item.IsChecked = (i == actPA); item.Tag = i; items.Add(item); } return(items); }
/// <summary> /// Handler for all submenu items of the data popup.". /// </summary> /// <param name="sender">The menuitem, must be of type <see cref="DataMenuItem"/>.</param> /// <param name="e">Not used.</param> /// <remarks>The handler either checks the menuitem, if it was unchecked. If it was already checked, /// it shows the LineScatterPlotStyleControl into a dialog box. /// </remarks> private void EhMenuData_Data(object sender, System.EventArgs e) { DataMenuItem dmi = (DataMenuItem)sender; if (!dmi.Checked) { // if the menu item was not checked before, check it now // by making the plot association shown by the menu item // the actual plot association int actLayerNum = this.CurrentLayerNumber; XYPlotLayer actLayer = this.Layers[actLayerNum]; if (null != actLayer && dmi.PlotItemNumber < actLayer.PlotItems.Flattened.Length) { dmi.Checked = true; CurrentPlotNumber = dmi.PlotItemNumber; } } else { // if it was checked before, then bring up the plot style dialog // of the plot association represented by this menu item int actLayerNum = this.CurrentLayerNumber; XYPlotLayer actLayer = this.Layers[actLayerNum]; IGPlotItem pa = actLayer.PlotItems.Flattened[CurrentPlotNumber]; Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true); } }
/// <summary> /// Updates a special menu item, the data item, with the currently available plot names. The active plot is marked with a /// check. /// </summary> public void UpdateDataPopup() { if (null == this.m_MenuDataPopup) { return; // as long there is no menu, we cannot do it } // first delete old menuitems this.m_MenuDataPopup.MenuItems.Clear(); // check there is at least one layer if (m_Graph.Layers.Count == 0) { return; // there is no layer, we can not have items in the data menu } // now it is save to get the active layer int actLayerNum = this.CurrentLayerNumber; XYPlotLayer actLayer = this.Layers[actLayerNum]; // then append the plot associations of the actual layer int actPA = CurrentPlotNumber; int len = actLayer.PlotItems.Flattened.Length; for (int i = 0; i < len; i++) { IGPlotItem pa = actLayer.PlotItems.Flattened[i]; DataMenuItem mi = new DataMenuItem(pa.ToString(), new EventHandler(EhMenuData_Data)); mi.Checked = (i == actPA); mi.PlotItemNumber = i; this.m_MenuDataPopup.MenuItems.Add(mi); } }
/// <summary> /// Get the names of the x and y column of the active plot. /// </summary> /// <param name="ctrl">The current active graph controller.</param> /// <returns>An array of two strings. The first string is the name of the x-column, the second /// the name of the y-column.</returns> public static string[] GetActivePlotName(Altaxo.Graph.GUI.GraphController ctrl) { string[] result = new string[2] { String.Empty, String.Empty }; IGPlotItem plotItem = ctrl.ActiveLayer.PlotItems.Flattened[ctrl.CurrentPlotNumber]; XYColumnPlotItem xyPlotItem = plotItem as XYColumnPlotItem; if (xyPlotItem == null) { return(result); } XYColumnPlotData data = xyPlotItem.XYColumnPlotData; if (data == null) { return(result); } result[0] = data.XColumn.FullName; result[1] = data.YColumn.FullName; return(result); }
/// <summary> /// Get the names of the x and y column of the active plot. /// </summary> /// <param name="ctrl">The current active graph controller.</param> /// <returns>An array of two strings. The first string is the name of the x-column, the second /// the name of the y-column.</returns> public static string[] GetActivePlotName(Altaxo.Gui.Graph.Gdi.Viewing.IGraphController ctrl) { string[] result = new string[2] { string.Empty, string.Empty }; var xylayer = ctrl.ActiveLayer as XYPlotLayer; if (null == xylayer || ctrl.CurrentPlotNumber < 0) { return(result); } IGPlotItem plotItem = xylayer.PlotItems.Flattened[ctrl.CurrentPlotNumber]; var xyPlotItem = plotItem as XYColumnPlotItem; if (xyPlotItem == null) { return(result); } XYColumnPlotData data = xyPlotItem.XYColumnPlotData; if (data == null) { return(result); } result[0] = data.XColumn.FullName; result[1] = data.YColumn.FullName; return(result); }
/// <summary> /// Retrieves the data points of the current active plot. /// </summary> /// <param name="ctrl">The graph controller which controls the graph from which the points are to retrieve.</param> /// <param name="xarr">The array of the data point's x values.</param> /// <param name="yarr">The array of the data point's y values.</param> /// <returns>Null if all is ok, or error message if not.</returns> public static string GetActivePlotPoints(Altaxo.Gui.Graph.Gdi.Viewing.IGraphController ctrl, out double[] xarr, out double[] yarr) { var xlist = new List <double>(); var ylist = new List <double>(); xarr = yarr = null; ctrl.EnsureValidityOfCurrentLayerNumber(); ctrl.EnsureValidityOfCurrentPlotNumber(); var xylayer = ctrl.ActiveLayer as XYPlotLayer; if (null == xylayer || ctrl.CurrentPlotNumber < 0) { return("No active plot available"); } IGPlotItem plotItem = xylayer.PlotItems.Flattened[ctrl.CurrentPlotNumber]; var xyPlotItem = plotItem as XYColumnPlotItem; if (xyPlotItem == null) { return("No active plot!"); } XYColumnPlotData data = xyPlotItem.XYColumnPlotData; if (data == null) { return("Active plot item has no data"); } if (!(data.XColumn is Altaxo.Data.INumericColumn) || !(data.YColumn is Altaxo.Data.INumericColumn)) { return("X-Y values of plot data are not both numeric"); } var xcol = (Altaxo.Data.INumericColumn)data.XColumn; var ycol = (Altaxo.Data.INumericColumn)data.YColumn; int maxRowIndex = data.GetMaximumRowIndexFromDataColumns(); foreach (int i in data.DataRowSelection.GetSelectedRowIndicesFromTo(0, maxRowIndex, data.DataTable?.DataColumns, maxRowIndex)) { double x = xcol[i]; double y = ycol[i]; if (double.IsNaN(x) || double.IsNaN(y)) { continue; } xlist.Add(x); ylist.Add(y); } xarr = xlist.ToArray(); yarr = ylist.ToArray(); return(null); }
public override bool InitializeDocument(params object[] args) { if (args != null && args.Length > 1 && args[1] is IGPlotItem) { _parent = (IGPlotItem)args[1]; } return(base.InitializeDocument(args)); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DensityImagePlotItem)) { return; } DensityImagePlotItem from = (DensityImagePlotItem)template; // m_PlotStyle.CopyFrom(from.m_PlotStyle); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is G2DPlotItem) || object.ReferenceEquals(this, template)) { return; } var from = (G2DPlotItem)template; _plotStyles.SetFromTemplate(from._plotStyles, strictness); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DataMeshPlotItem)) { return; } var from = (DataMeshPlotItem)template; _plotStyle.CopyFrom(from._plotStyle); }
public override void Dispose(bool isDisposing) { _parent = null; _availableTransfoStyles = null; _availableNormalStyles = null; _currentNormalStyles = null; _availableUpdateModes = null; _currentTransfoStyle = null; base.Dispose(isDisposing); }
/// <summary> /// Handles the double click event onto a plot item. /// </summary> /// <param name="hit">Object containing information about the double clicked object.</param> /// <returns>True if the object should be deleted, false otherwise.</returns> protected static bool EhEditPlotItem(IHitTestObject hit) { XYPlotLayer actLayer = hit.ParentLayer; IGPlotItem pa = (IGPlotItem)hit.HittedObject; // get plot group PlotGroupStyleCollection plotGroup = pa.ParentCollection.GroupStyles; Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true); return(false); }
private void TransferTreeToDoc(NGTreeNode rootnode, PlotItemCollection picoll) { picoll.Clear(); foreach (NGTreeNode node in rootnode.Nodes) { IGPlotItem item = (IGPlotItem)node.Tag; if (item is PlotItemCollection) // if this is a plot item collection { TransferTreeToDoc(node, (PlotItemCollection)item); } picoll.Add(item); } }
private string GetName(object obj) { string result = string.Empty; // first of all, retrieve the actual name var mylayer = obj as HostLayer; if (null == mylayer) return result; var layer = mylayer as XYPlotLayer; if (_layerNumber >= 0 && mylayer.SiblingLayers != null && _layerNumber < mylayer.SiblingLayers.Count) layer = mylayer.SiblingLayers[_layerNumber] as XYPlotLayer; if (null == layer) return result; IGPlotItem pa = null; if (_plotNumber < layer.PlotItems.Flattened.Length) { pa = layer.PlotItems.Flattened[_plotNumber]; } if (pa != null) { result = pa.GetName(0); if (_plotLabelStyle != null && !_plotLabelStyleIsPropColName && pa is XYColumnPlotItem) { XYColumnPlotItemLabelTextStyle style = XYColumnPlotItemLabelTextStyle.YS; try { style = (XYColumnPlotItemLabelTextStyle)Enum.Parse(typeof(XYColumnPlotItemLabelTextStyle), _plotLabelStyle, true); } catch (Exception) { } result = ((XYColumnPlotItem)pa).GetName(style); } if (_plotLabelStyleIsPropColName && _plotLabelStyle != null && pa is XYColumnPlotItem) { XYColumnPlotData pb = ((XYColumnPlotItem)pa).Data; Data.DataTable tbl = null; if (pb.YColumn is Data.DataColumn) tbl = Data.DataTable.GetParentDataTableOf((Data.DataColumn)pb.YColumn); if (tbl != null) { int colNumber = tbl.DataColumns.GetColumnNumber((Data.DataColumn)pb.YColumn); if (tbl.PropertyColumns.ContainsColumn(_plotLabelStyle)) result = tbl.PropertyColumns[_plotLabelStyle][colNumber].ToString(); } } } return result; }
public void EhView_ContentsDoubleClick(NGTreeNode selNode) { IGPlotItem pi = selNode.Tag as IGPlotItem; if (null != pi) { if (pi is PlotItemCollection) { // show not the dialog for PlotItemCollection, but only those for the group styles into that collection Current.Gui.ShowDialog(new object[] { ((PlotItemCollection)pi).GroupStyles }, pi.Name); } else { Current.Gui.ShowDialog(new object[] { pi }, pi.GetName(2), true); } } }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { PlotItemCollection s = null != o ? (PlotItemCollection)o : new PlotItemCollection(); int count = info.OpenArray(); IGPlotItem[] plotItems = new IGPlotItem[count]; for (int i = 0; i < count; i++) { s.Add((IGPlotItem)info.GetValue("PlotItem", s)); } info.CloseArray(count); s._styles = (PlotGroupStyleCollection)info.GetValue("GroupStyles", s); return(s); }
public bool InitializeDocument(params object[] args) { if (args == null || args.Length == 0 || !(args[0] is PlotGroupStyleCollection)) { return(false); } _origdoc = (PlotGroupStyleCollection)args[0]; _doc = _useDocument == UseDocument.Directly ? _origdoc : _origdoc.Clone(); if (args.Length >= 2 && args[1] is IGPlotItem) { _parent = (IGPlotItem)args[1]; } Initialize(true); return(true); }
/// <summary> /// Puts the selected data columns into the plot content. /// </summary> /// <param name="selNodes"></param> public void EhView_PutData(NGTreeNode[] selNodes) { // first, put the selected node into the list, even if it is not checked foreach (NGTreeNode sn in selNodes) { if (null != sn.Parent) { IGPlotItem newItem = this.CreatePlotItem(sn.Parent.Text, sn.Text); _doc.Add(newItem); NGTreeNode newNode = new NGTreeNode(); newNode.Text = newItem.GetName(2); newNode.Tag = newItem; _plotItemsTree.Add(newNode); } } View.Contents_SetItems(_plotItemsTree); View.DataAvailable_ClearSelection(); SetDirty(); }
/// <summary> /// Retrieves the data points of the current active plot. /// </summary> /// <param name="ctrl">The graph controller which controls the graph from which the points are to retrieve.</param> /// <param name="xarr">The array of the data point's x values.</param> /// <param name="yarr">The array of the data point's y values.</param> /// <param name="nPlotPoints">The number of plot points (may be smaller than the length of x and y arrays.</param> /// <returns>Null if all is ok, or error message if not.</returns> public static string GetActivePlotPoints(Altaxo.Graph.GUI.GraphController ctrl, ref double[] xarr, ref double[] yarr, out int nPlotPoints) { nPlotPoints = 0; ctrl.EnsureValidityOfCurrentLayerNumber(); ctrl.EnsureValidityOfCurrentPlotNumber(); IGPlotItem plotItem = ctrl.ActiveLayer.PlotItems.Flattened[ctrl.CurrentPlotNumber]; XYColumnPlotItem xyPlotItem = plotItem as XYColumnPlotItem; if (xyPlotItem == null) { return("No active plot!"); } XYColumnPlotData data = xyPlotItem.XYColumnPlotData; if (data == null) { return("Active plot item has no data"); } if (!(data.XColumn is Altaxo.Data.INumericColumn) || !(data.YColumn is Altaxo.Data.INumericColumn)) { return("X-Y values of plot data are not both numeric"); } Altaxo.Data.INumericColumn xcol = (Altaxo.Data.INumericColumn)data.XColumn; Altaxo.Data.INumericColumn ycol = (Altaxo.Data.INumericColumn)data.YColumn; int n = data.PlottablePoints; if (null == xarr || xarr.Length < n) { xarr = new double[n]; } if (null == yarr || yarr.Length < n) { yarr = new double[n]; } int end = data.PlotRangeEnd; int j = 0; for (int i = data.PlotRangeStart; i < end && j < n; i++) { double x = xcol[i]; double y = ycol[i]; if (double.IsNaN(x) || double.IsNaN(y)) { continue; } xarr[j] = x; yarr[j] = y; ++j; } nPlotPoints = j; return(null); }
/// <summary> /// This paints the plot to the layer. /// </summary> /// <param name="g">The graphics context.</param> /// <param name="context">The painting context.</param> /// <param name="layer">The plot layer.</param> /// <param name="previousPlotItem">Previous plot item.</param> /// <param name="nextPlotItem">Next plot item.</param> /// <returns>A data object, which can be used by the next plot item for some styles (like fill style).</returns> public abstract void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem);
public static string Fit(Altaxo.Graph.GUI.GraphController ctrl) { if (ctrl.CurrentPlotNumber < 0) { return("No active plot!"); } IGPlotItem plotItem = ctrl.ActiveLayer.PlotItems.Flattened[ctrl.CurrentPlotNumber]; XYColumnPlotItem xyPlotItem = plotItem as XYColumnPlotItem; if (xyPlotItem == null) { return("Active plot is not a X-Y Plot!"); } INumericColumn xColumn = xyPlotItem.XYColumnPlotData.XColumn as INumericColumn; INumericColumn yColumn = xyPlotItem.XYColumnPlotData.YColumn as INumericColumn; if (xColumn == null) { return("The x-column is not numeric"); } if (yColumn == null) { return("The y-column is not numeric"); } Calc.Regression.Nonlinear.NonlinearFitDocument localdoc = ctrl.Doc.GetGraphProperty(FitDocumentPropertyName) as Calc.Regression.Nonlinear.NonlinearFitDocument; if (localdoc == null) { if (_lastFitDocument == null) { localdoc = new Altaxo.Calc.Regression.Nonlinear.NonlinearFitDocument(); } else { localdoc = (Altaxo.Calc.Regression.Nonlinear.NonlinearFitDocument)_lastFitDocument.Clone(); } } if (localdoc.FitEnsemble.Count == 0) { Calc.Regression.Nonlinear.FitElement fitele = new Altaxo.Calc.Regression.Nonlinear.FitElement( xColumn, yColumn, xyPlotItem.XYColumnPlotData.PlotRangeStart, xyPlotItem.XYColumnPlotData.PlotRangeLength); localdoc.FitEnsemble.Add(fitele); } else // localdoc.FitEnsemble.Count>0 { localdoc.FitEnsemble[0].SetIndependentVariable(0, xColumn); localdoc.FitEnsemble[0].SetDependentVariable(0, yColumn); localdoc.FitEnsemble[0].SetRowRange(xyPlotItem.XYColumnPlotData.PlotRangeStart, xyPlotItem.XYColumnPlotData.PlotRangeLength); } localdoc.FitContext = ctrl; object fitdocasobject = localdoc; if (true == Current.Gui.ShowDialog(ref fitdocasobject, "Non-linear fitting")) { // store the fit document in the graphs property ctrl.Doc.SetGraphProperty(FitDocumentPropertyName, localdoc); _lastFitDocument = (Altaxo.Calc.Regression.Nonlinear.NonlinearFitDocument)localdoc.Clone(); } return(null); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is G2DPlotItem) || object.ReferenceEquals(this, template)) return; G2DPlotItem from = (G2DPlotItem)template; this._plotStyles.SetFromTemplate(from._plotStyles, strictness); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { PlotItemCollection s = null != o ? (PlotItemCollection)o : new PlotItemCollection(); int count = info.OpenArray(); IGPlotItem[] plotItems = new IGPlotItem[count]; for (int i = 0; i < count; i++) { plotItems[i] = (IGPlotItem)info.GetValue("PlotItem", s); } info.CloseArray(count); count = info.OpenArray(); // PlotGroups PGTrans[] plotGroups = new PGTrans[count]; for (int i = 0; i < count; i++) { plotGroups[i].PlotGroup = (PlotGroupMemento)info.GetValue(s); } info.CloseArray(count); // now assemble the new tree based collection based on the both fields for (int pix = 0; pix < plotItems.Length; pix++) { // look if this plotItem is member of some group int foundidx = -1; for (int grx = 0; grx < plotGroups.Length; grx++) { if (Array.IndexOf <int>(plotGroups[grx].PlotGroup._plotItemIndices, pix) >= 0) { foundidx = grx; break; } } if (foundidx < 0) // if not found in some group, add the item directly { s.Add(plotItems[pix]); } else { if (plotGroups[foundidx].PlotItemCollection == null) { PlotItemCollection newColl = new PlotItemCollection(); plotGroups[foundidx].PlotItemCollection = newColl; s.Add(plotGroups[foundidx].PlotItemCollection); // now set the properties of this new collection bool serial = !plotGroups[foundidx].PlotGroup._concurrently; IPlotGroupStyle curr = null; IPlotGroupStyle prev = null; if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Color)) { curr = new ColorGroupStyle(); newColl.GroupStyles.Add(curr); } if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Line)) { prev = curr; curr = new LineStyleGroupStyle(); newColl.GroupStyles.Add(curr, serial ? (prev == null?null:prev.GetType()) : null); } if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Symbol)) { prev = curr; curr = new SymbolShapeStyleGroupStyle(); newColl.GroupStyles.Add(curr, serial ? (prev == null ? null : prev.GetType()) : null); } } // now add the item to this collection plotGroups[foundidx].PlotItemCollection.Add(plotItems[pix]); } } return(s); }
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); } } }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public abstract void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness);
public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem prevPlotItem, IGPlotItem nextPlotItem) { Processed2DPlotData pdata = GetRangesAndPoints(layer); if (pdata != null) { Paint(g, layer, pdata, (prevPlotItem is G2DPlotItem) ? ((G2DPlotItem)prevPlotItem).GetPlotData(layer) : null, (nextPlotItem is G2DPlotItem) ? ((G2DPlotItem)nextPlotItem).GetPlotData(layer) : null ); } }
public bool InitializeDocument(params object[] args) { if (args == null || args.Length == 0 || !(args[0] is PlotGroupStyleCollection)) return false; _origdoc = (PlotGroupStyleCollection)args[0]; _doc = _useDocument == UseDocument.Directly ? _origdoc : _origdoc.Clone(); if (args.Length >= 2 && args[1] is IGPlotItem) _parent = (IGPlotItem)args[1]; Initialize(true); return true; }
public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem) { if (null != this._plotStyle) { _plotStyle.Paint(g, layer, _plotData); } }
public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem prevPlotItem, IGPlotItem nextPlotItem) { Processed2DPlotData pdata = GetRangesAndPoints(layer); if (pdata != null) Paint(g, layer, pdata, (prevPlotItem is G2DPlotItem) ? ((G2DPlotItem)prevPlotItem).GetPlotData(layer) : null, (nextPlotItem is G2DPlotItem) ? ((G2DPlotItem)nextPlotItem).GetPlotData(layer) : null ); }
/// <summary> /// Sets the plot style (or sub plot styles) in this item according to a template provided by the plot item in the template argument. /// </summary> /// <param name="template">The template item to copy the plot styles from.</param> /// <param name="strictness">Denotes the strictness the styles are copied from the template. See <see cref="PlotGroupStrictness" /> for more information.</param> public override void SetPlotStyleFromTemplate(IGPlotItem template, PlotGroupStrictness strictness) { if (!(template is DensityImagePlotItem)) return; DensityImagePlotItem from = (DensityImagePlotItem)template; _plotStyle.CopyFrom(from._plotStyle); }
public override void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem) { if (null != _plotStyle) { _plotStyle.Paint(g, layer, _plotData); } }
/// <summary> /// This paints the plot to the layer. /// </summary> /// <param name="g">The graphics context.</param> /// <param name="context">The painting context.</param> /// <param name="layer">The plot layer.</param> /// <param name="previousPlotItem">Previous plot item.</param> /// <param name="nextPlotItem">Next plot item.</param> /// <returns>A data object, which can be used by the next plot item for some styles (like fill style).</returns> public abstract void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem);