public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { XYColumnPlotData pa = (XYColumnPlotData)info.GetValue("Data", typeof(XYColumnPlotData)); XYLineScatterPlotStyle lsps = (XYLineScatterPlotStyle)info.GetValue("Style", typeof(XYLineScatterPlotStyle)); if (lsps.XYPlotLineStyle != null) { lsps.XYPlotLineStyle.LineSymbolGap = lsps.LineSymbolGap; // this has changed and is now hosted in the LineStyle itself } G2DPlotStyleCollection ps = new G2DPlotStyleCollection(new IG2DPlotStyle[] { lsps.XYPlotLineStyle, lsps.ScatterStyle, lsps.XYPlotLabelStyle }); if (lsps.XYPlotLabelStyle != null) { XmlSerializationSurrogate0 surr = new XmlSerializationSurrogate0(); surr._item = pa; surr._label = lsps.XYPlotLabelStyle; info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.info_DeserializationFinished); } if (null == o) { return(new XYColumnPlotItem(pa, ps)); } else { XYColumnPlotItem s = (XYColumnPlotItem)o; s.Data = pa; s.Style = ps; return(s); } }
/// <summary> /// Serializes XYColumnPlotItem Version 0. /// </summary> /// <param name="obj">The XYColumnPlotItem to serialize.</param> /// <param name="info">The serialization info.</param> /// <param name="context">The streaming context.</param> public void GetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { XYColumnPlotItem s = (XYColumnPlotItem)obj; info.AddValue("Data", s._plotData); info.AddValue("Style", s._plotStyles); }
public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { XYColumnPlotItem s = (XYColumnPlotItem)obj; info.AddValue("Data", s._plotData); info.AddValue("Style", s._plotStyles); }
/// <summary> /// Deserializes the XYColumnPlotItem Version 0. /// </summary> /// <param name="obj">The empty XYColumnPlotItem object to deserialize into.</param> /// <param name="info">The serialization info.</param> /// <param name="context">The streaming context.</param> /// <param name="selector">The deserialization surrogate selector.</param> /// <returns>The deserialized XYColumnPlotItem.</returns> public object SetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.ISurrogateSelector selector) { XYColumnPlotItem s = (XYColumnPlotItem)obj; s.Data = (XYColumnPlotData)info.GetValue("Data", typeof(XYColumnPlotData)); s.Style = (G2DPlotStyleCollection)info.GetValue("Style", typeof(G2DPlotStyleCollection)); return(s); }
protected override void CopyFrom(PlotItem fromb) { base.CopyFrom(fromb); XYColumnPlotItem from = fromb as XYColumnPlotItem; if (null != from) { this.Data = (XYColumnPlotData)from.Data.Clone(); // also wires the event } }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { XYColumnPlotData pa = (XYColumnPlotData)info.GetValue("Data", typeof(XYColumnPlotData)); G2DPlotStyleCollection ps = (G2DPlotStyleCollection)info.GetValue("Style", typeof(G2DPlotStyleCollection)); if (null == o) { return(new XYColumnPlotItem(pa, ps)); } else { XYColumnPlotItem s = (XYColumnPlotItem)o; s.Data = pa; s.Style = ps; return(s); } }
public void CopyFrom(XYColumnPlotItem from) { CopyFrom((PlotItem)from); }
public XYColumnPlotItem(XYColumnPlotItem from) { CopyFrom(from); }
/// <summary> /// Find the plot item number of a given plot item. /// </summary> /// <param name="layer">The layer in which this plot item resides.</param> /// <param name="plotitem">The plot item for which the number should be retrieved.</param> /// <returns></returns> private int GetPlotItemNumber(XYPlotLayer layer, XYColumnPlotItem plotitem) { if (null != layer) { for (int i = 0; i < layer.PlotItems.Flattened.Length; i++) if (object.ReferenceEquals(layer.PlotItems.Flattened[i], plotitem)) return i; } return -1; }
/// <summary> /// Handles the MouseDown event when the plot point tool is selected /// </summary> /// <param name="e">The mouse event args</param> public override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { base.OnMouseDown(e); PointF mouseXY = new PointF(e.X,e.Y); PointF graphXY = _grac.WinFormsController.PixelToPrintableAreaCoordinates(mouseXY); // search for a object first IHitTestObject clickedObject; int clickedLayerNumber=0; _grac.WinFormsController.FindGraphObjectAtPixelPosition(mouseXY, true, out clickedObject, out clickedLayerNumber); if(null!=clickedObject && clickedObject.HittedObject is XYColumnPlotItem) { m_PlotItem = (XYColumnPlotItem)clickedObject.HittedObject; PointF transXY = clickedObject.Transformation.InverseTransformPoint(graphXY); XYScatterPointInformation scatterPoint = m_PlotItem.GetNearestPlotPoint(clickedObject.ParentLayer,transXY); this._PlotItemNumber = GetPlotItemNumber(clickedLayerNumber,m_PlotItem); this._LayerNumber = clickedLayerNumber; if(null!=scatterPoint) { this._PlotIndex = scatterPoint.PlotIndex; this._RowIndex = scatterPoint.RowIndex; // convert this layer coordinates first to PrintableAreaCoordinates PointF printableCoord = clickedObject.ParentLayer.LayerToGraphCoordinates(scatterPoint.LayerCoordinates); m_Cross = printableCoord; // m_Cross.X -= _grac.GraphViewOffset.X; // m_Cross.Y -= _grac.GraphViewOffset.Y; PointF newPixelCoord = _grac.WinFormsController.PrintableAreaToPixelCoordinates(printableCoord); Cursor.Position = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y)); this.DisplayData(m_PlotItem,scatterPoint.RowIndex, m_PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex], m_PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]); // here we shoud switch the bitmap cache mode on and link us with the AfterPaint event // of the grac _grac.WinFormsController.RepaintGraphArea(); // no refresh necessary, only invalidate to show the cross } } } // end of function
/// <summary> /// Find the plot item number of a given plot item. /// </summary> /// <param name="layernumber"></param> /// <param name="plotitem"></param> /// <returns></returns> int GetPlotItemNumber(int layernumber, XYColumnPlotItem plotitem) { if(layernumber<_grac.Doc.Layers.Count) { for(int i=0;i<_grac.Doc.Layers[layernumber].PlotItems.Flattened.Length;i++) if(object.ReferenceEquals(_grac.Doc.Layers[layernumber].PlotItems.Flattened[i],plotitem)) return i; } return -1; }
/// <summary> /// Moves the cross to the next plot item. If no plot item is found in this layer, it moves the cross to the next layer. /// </summary> /// <param name="increment"></param> void MoveUpDown(int increment) { if(!TestMovementPresumtions()) return; int numlayers = _grac.GC.Layers.Count; int nextlayer = _LayerNumber; int nextplotitemnumber = this._PlotItemNumber; XYScatterPointInformation scatterPoint=null; XYColumnPlotItem plotitem = null; do { nextplotitemnumber = nextplotitemnumber + Math.Sign(increment); if(nextplotitemnumber<0) { nextlayer-=1; nextplotitemnumber = nextlayer<0 ? int.MaxValue : _grac.GC.Layers[nextlayer].PlotItems.Flattened.Length-1; } else if(nextplotitemnumber>=_grac.GC.Layers[nextlayer].PlotItems.Flattened.Length) { nextlayer+=1; nextplotitemnumber=0; } // check if this results in a valid information if(nextlayer<0 || nextlayer>=numlayers) break; if(nextplotitemnumber<0 || nextplotitemnumber>=_grac.GC.Layers[nextlayer].PlotItems.Flattened.Length) continue; plotitem = _grac.GC.Layers[nextlayer].PlotItems.Flattened[nextplotitemnumber] as XYColumnPlotItem; if(null==plotitem) continue; scatterPoint = plotitem.GetNextPlotPoint(_grac.GC.Layers[nextlayer],this._PlotIndex,0); } while(scatterPoint==null); if(null!=scatterPoint) { this.m_PlotItem = plotitem; this._LayerNumber = nextlayer; this._PlotItemNumber = nextplotitemnumber; this._PlotIndex = scatterPoint.PlotIndex; this._RowIndex = scatterPoint.RowIndex; ShowCross(scatterPoint); } }
/// <summary> /// Handles the MouseDown event when the plot point tool is selected /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">The mouse event args</param> public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); var graphXY = _grac.ConvertMouseToRootLayerCoordinates(position); // search for a object first IHitTestObject clickedObject; int[] clickedLayerNumber = null; _grac.FindGraphObjectAtPixelPosition(position, true, out clickedObject, out clickedLayerNumber); if (null != clickedObject && clickedObject.HittedObject is XYColumnPlotItem) { _PlotItem = (XYColumnPlotItem)clickedObject.HittedObject; var transXY = clickedObject.Transformation.InverseTransformPoint(graphXY); this._layer = (XYPlotLayer)(clickedObject.ParentLayer); XYScatterPointInformation scatterPoint = _PlotItem.GetNearestPlotPoint(_layer, transXY); this._PlotItemNumber = GetPlotItemNumber(_layer, _PlotItem); if (null != scatterPoint) { this._PlotIndex = scatterPoint.PlotIndex; this._RowIndex = scatterPoint.RowIndex; // convert this layer coordinates first to PrintableAreaCoordinates var rootLayerCoord = clickedObject.ParentLayer.TransformCoordinatesFromHereToRoot(scatterPoint.LayerCoordinates); _positionOfCrossInRootLayerCoordinates = rootLayerCoord; // m_Cross.X -= _grac.GraphViewOffset.X; // m_Cross.Y -= _grac.GraphViewOffset.Y; var newPixelCoord = _grac.ConvertGraphToMouseCoordinates(rootLayerCoord); // TODO (Wpf) //var newCursorPosition = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y)); //SetCursorPos(newCursorPosition.X, newCursorPosition.Y); this.DisplayData(_PlotItem, scatterPoint.RowIndex, _PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex], _PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]); // here we shoud switch the bitmap cache mode on and link us with the AfterPaint event // of the grac _grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross } } } // end of function
private IGPlotItem CreatePlotItem(string tablename, string columnname) { // create a new plotassociation from the column // first, get the y column from table and name Data.DataTable tab = Current.Project.DataTableCollection[tablename]; if(null!=tab) { Data.DataColumn ycol = tab[columnname]; if(null!=ycol) { Data.DataColumn xcol = tab.DataColumns.FindXColumnOf(ycol); XYColumnPlotItem result; if(null==xcol) result = new XYColumnPlotItem(new XYColumnPlotData(new Altaxo.Data.IndexerColumn(),ycol),new G2DPlotStyleCollection(LineScatterPlotStyleKind.Scatter)); else result = new XYColumnPlotItem(new XYColumnPlotData(xcol,ycol),new G2DPlotStyleCollection(LineScatterPlotStyleKind.LineAndScatter)); return result; } } return null; }
/// <summary> /// Moves the cross to the next plot item. If no plot item is found in this layer, it moves the cross to the next layer. /// </summary> /// <param name="increment"></param> private void MoveUpDown(int increment) { if (!TestMovementPresumtions()) return; var layerList = _layer.SiblingLayers; int numlayers = layerList.Count; var nextlayer = _layer as XYPlotLayer; int indexOfNextLayer = layerList.IndexOf(_layer); int nextplotitemnumber = this._PlotItemNumber; XYScatterPointInformation scatterPoint = null; XYColumnPlotItem plotitem = null; do { nextplotitemnumber = nextplotitemnumber + Math.Sign(increment); if (nextplotitemnumber < 0) // then try to use the previous layer { --indexOfNextLayer; nextlayer = indexOfNextLayer >= 0 ? layerList[indexOfNextLayer] as XYPlotLayer : null; nextplotitemnumber = nextlayer == null ? int.MaxValue : nextlayer.PlotItems.Flattened.Length - 1; } else if (nextplotitemnumber >= nextlayer.PlotItems.Flattened.Length) { ++indexOfNextLayer; nextlayer = indexOfNextLayer < layerList.Count ? layerList[indexOfNextLayer] as XYPlotLayer : null; nextplotitemnumber = 0; } // check if this results in a valid information if (indexOfNextLayer < 0 || indexOfNextLayer >= numlayers) break; // no more layers available if (nextlayer == null) continue; // this is not an XYPlotLayer if (nextplotitemnumber < 0 || nextplotitemnumber >= nextlayer.PlotItems.Flattened.Length) continue; plotitem = nextlayer.PlotItems.Flattened[nextplotitemnumber] as XYColumnPlotItem; if (null == plotitem) continue; scatterPoint = plotitem.GetNextPlotPoint(nextlayer, this._PlotIndex, 0); } while (scatterPoint == null); if (null != scatterPoint) { this._PlotItem = plotitem; this._layer = nextlayer; this._PlotItemNumber = nextplotitemnumber; this._PlotIndex = scatterPoint.PlotIndex; this._RowIndex = scatterPoint.RowIndex; ShowCross(scatterPoint); } }