Exemplo n.º 1
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYColumnPlotData s = SDeserialize(o, info, parent);

                CreateEventChain(s);
                return(s);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="from">The object to copy from.</param>
        /// <remarks>Only clones the references to the data columns, not the columns itself.</remarks>
        public XYColumnPlotData(XYColumnPlotData from)
        {
            XColumn = from.XColumn; // also wires event, do not clone the column data here!!!
            YColumn = from.YColumn; // wires event, do not clone the column data here!!!

            this._plotRangeStart  = from._plotRangeStart;
            this._plotRangeLength = from._plotRangeLength;

            // cached or temporary data
            if (from._xBoundaries != null)
            {
                this._xBoundaries = (IPhysicalBoundaries)from._xBoundaries.Clone();
                this._xBoundaries.BoundaryChanged += new BoundaryChangedHandler(this.EhXBoundariesChanged);
            }
            if (from._yBoundaries != null)
            {
                this._yBoundaries = (IPhysicalBoundaries)from._yBoundaries.Clone();
                this._yBoundaries.BoundaryChanged += new BoundaryChangedHandler(this.EhYBoundariesChanged);
            }

            this._plottablePoints   = from._plottablePoints;
            this._pointCount        = from._pointCount;
            this._isCachedDataValid = from._isCachedDataValid;
            this._parent            = from._parent;
        }
Exemplo n.º 3
0
            /// <summary>
            /// Serializes XYColumnPlotData Version 0.
            /// </summary>
            /// <param name="obj">The XYColumnPlotData 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)
            {
                XYColumnPlotData s = (XYColumnPlotData)obj;

                info.AddValue("XColumn", s._xColumn);
                info.AddValue("YColumn", s._yColumn);

                info.AddValue("XBoundaries", s._xBoundaries);
                info.AddValue("YBoundaries", s._yBoundaries);
            }
Exemplo n.º 4
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                XYColumnPlotData s = (XYColumnPlotData)obj;

                info.AddValue("XColumn", s._xColumn);
                info.AddValue("YColumn", s._yColumn);

                info.AddValue("XBoundaries", s._xBoundaries);
                info.AddValue("YBoundaries", s._yBoundaries);
            }
Exemplo n.º 5
0
            public virtual object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                bool             bNeedsCallback = false;
                XYColumnPlotData s = null != o ? (XYColumnPlotData)o : new XYColumnPlotData();

                object xColumn = info.GetValue("XColumn", typeof(Altaxo.Data.IReadableColumn));
                object yColumn = info.GetValue("YColumn", typeof(Altaxo.Data.IReadableColumn));

                if (xColumn is Altaxo.Data.IReadableColumn)
                {
                    s.XColumn = (Altaxo.Data.IReadableColumn)xColumn;
                }
                else if (xColumn is Main.DocumentPath)
                {
                    bNeedsCallback = true;
                }


                if (yColumn is Altaxo.Data.IReadableColumn)
                {
                    s.YColumn = (Altaxo.Data.IReadableColumn)yColumn;
                }
                else if (yColumn is Main.DocumentPath)
                {
                    bNeedsCallback = true;
                }



                s._xBoundaries = (IPhysicalBoundaries)info.GetValue("XBoundaries", typeof(IPhysicalBoundaries));
                if (null != s._xBoundaries)
                {
                    s._xBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhXBoundariesChanged);
                }

                s._yBoundaries = (IPhysicalBoundaries)info.GetValue("YBoundaries", typeof(IPhysicalBoundaries));
                if (null != s._yBoundaries)
                {
                    s._yBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhYBoundariesChanged);
                }



                if (bNeedsCallback)
                {
                    XmlSerializationSurrogate0 surr = new XmlSerializationSurrogate0();
                    surr._xColumn         = xColumn as Main.DocumentPath;
                    surr._yColumn         = yColumn as Main.DocumentPath;
                    surr._plotAssociation = s;

                    info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);
                }
                return(s);
            }
Exemplo n.º 6
0
            public virtual XYColumnPlotData SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYColumnPlotData s = null != o ? (XYColumnPlotData)o : new XYColumnPlotData();

                s._xColumn = (ReadableColumnProxy)info.GetValue("XColumn", parent);
                s._yColumn = (ReadableColumnProxy)info.GetValue("YColumn", parent);

                s._xBoundaries = (IPhysicalBoundaries)info.GetValue("XBoundaries", parent);
                s._yBoundaries = (IPhysicalBoundaries)info.GetValue("YBoundaries", parent);

                return(s);
            }
Exemplo n.º 7
0
            /// <summary>
            /// Deserializes the XYColumnPlotData Version 0.
            /// </summary>
            /// <param name="obj">The empty XYColumnPlotData 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 XYColumnPlotData.</returns>
            public object SetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.ISurrogateSelector selector)
            {
                XYColumnPlotData s = (XYColumnPlotData)obj;

                s._xColumn = (ReadableColumnProxy)info.GetValue("XColumn", typeof(ReadableColumnProxy));
                s._yColumn = (ReadableColumnProxy)info.GetValue("YColumn", typeof(ReadableColumnProxy));

                s._xBoundaries = (IPhysicalBoundaries)info.GetValue("XBoundaries", typeof(IPhysicalBoundaries));
                s._yBoundaries = (IPhysicalBoundaries)info.GetValue("YBoundaries", typeof(IPhysicalBoundaries));

                return(s);
            }
Exemplo n.º 8
0
            public override object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYColumnPlotData s = null != o ? (XYColumnPlotData)o : new XYColumnPlotData();

                base.Deserialize(s, info, parent);

                bool bNeedsCallback = false;


                object labelColumn = null;

                int nOptionalData = info.OpenArray();

                {
                    if (nOptionalData == 1)
                    {
                        string keystring = info.GetNodeName();
                        labelColumn = info.GetValue(parent);

                        if (labelColumn is Altaxo.Data.IReadableColumn)
                        {
                            s._deprecatedLabelColumn = (Altaxo.Data.IReadableColumn)labelColumn;
                        }
                        else if (labelColumn is Main.DocumentPath)
                        {
                            bNeedsCallback = true;
                        }
                    }
                }
                info.CloseArray(nOptionalData);


                if (bNeedsCallback)
                {
                    XmlSerializationSurrogate2 surr = new XmlSerializationSurrogate2();
                    surr._labelColumn     = labelColumn as Main.DocumentPath;
                    surr._plotAssociation = s;

                    info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished2);
                }

                return(s);
            }
Exemplo n.º 9
0
            public virtual void CreateEventChain(XYColumnPlotData s)
            {
                if (null != s._xColumn)
                {
                    s._xColumn.Changed += new EventHandler(s.EhColumnDataChangedEventHandler);
                }
                if (null != s._yColumn)
                {
                    s._yColumn.Changed += new EventHandler(s.EhColumnDataChangedEventHandler);
                }

                if (null != s._xBoundaries)
                {
                    s._xBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhXBoundariesChanged);
                }

                if (null != s._yBoundaries)
                {
                    s._yBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhYBoundariesChanged);
                }
            }
Exemplo n.º 10
0
    /// <summary>
    /// Plots the cross PRESS value into a provided layer.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    /// <param name="layer">The layer to plot into.</param>
    public static void PlotCrossPRESSValue(Altaxo.Data.DataTable table, XYPlotLayer layer)
    {
      Altaxo.Data.DataColumn ycol = table[WorksheetAnalysis.GetCrossPRESSValue_ColumnName()];
      Altaxo.Data.DataColumn xcol = table[WorksheetAnalysis.GetNumberOfFactors_ColumnName()];

      XYColumnPlotData pa = new XYColumnPlotData(xcol,ycol);
      G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.LineAndScatter);
      layer.PlotItems.Add(new XYColumnPlotItem(pa,ps));

      layer.DefaultXAxisTitleString = "Number of factors";
      layer.DefaultYAxisTitleString   = "Cross PRESS value";
    }
Exemplo n.º 11
0
    /// <summary>
    /// This plots a label plot into the provided layer.
    /// </summary>
    /// <param name="layer">The layer to plot into.</param>
    /// <param name="xcol">The x column.</param>
    /// <param name="ycol">The y column.</param>
    /// <param name="labelcol">The label column.</param>
    public static void PlotOnlyLabel(XYPlotLayer layer, Altaxo.Data.DataColumn xcol, Altaxo.Data.DataColumn ycol, Altaxo.Data.DataColumn labelcol)  
    {
      XYColumnPlotData pa = new XYColumnPlotData(xcol,ycol);

      G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty);
      LabelPlotStyle labelStyle = new LabelPlotStyle(labelcol);
      labelStyle.FontSize = 10;
      labelStyle.BackgroundStyle = new FilledRectangle(System.Drawing.Color.LightCyan);
      ps.Add(labelStyle);
      
      layer.PlotItems.Add(new XYColumnPlotItem(pa,ps));
    }
Exemplo n.º 12
0
    /// <summary>
    /// Copy constructor.
    /// </summary>
    /// <param name="from">The object to copy from.</param>
    /// <remarks>Only clones the references to the data columns, not the columns itself.</remarks>
    public XYColumnPlotData(XYColumnPlotData from)
    {
      XColumn = from.XColumn; // also wires event, do not clone the column data here!!!
      YColumn = from.YColumn; // wires event, do not clone the column data here!!!

      this._plotRangeStart = from._plotRangeStart;
      this._plotRangeLength = from._plotRangeLength;

      // cached or temporary data
      if (from._xBoundaries != null)
      {
        this._xBoundaries = (IPhysicalBoundaries)from._xBoundaries.Clone();
        this._xBoundaries.BoundaryChanged += new BoundaryChangedHandler(this.EhXBoundariesChanged);
      }
      if (from._yBoundaries != null)
      {
        this._yBoundaries =  (IPhysicalBoundaries)from._yBoundaries.Clone();
        this._yBoundaries.BoundaryChanged += new BoundaryChangedHandler(this.EhYBoundariesChanged);
      }

      this._plottablePoints = from._plottablePoints;
      this._pointCount = from._pointCount;
      this._isCachedDataValid = from._isCachedDataValid;
      this._parent = from._parent;
    }
Exemplo n.º 13
0
      public virtual void CreateEventChain(XYColumnPlotData s)
      {
        if (null != s._xColumn)
          s._xColumn.Changed += new EventHandler(s.EhColumnDataChangedEventHandler);
        if (null != s._yColumn)
          s._yColumn.Changed += new EventHandler(s.EhColumnDataChangedEventHandler);

        if (null != s._xBoundaries)
          s._xBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhXBoundariesChanged);

        if (null != s._yBoundaries)
          s._yBoundaries.BoundaryChanged += new BoundaryChangedHandler(s.EhYBoundariesChanged);
      }
Exemplo n.º 14
0
		/// <summary>
		/// Creates a list of plot items from data columns, using a template plot style.
		/// </summary>
		/// <param name="selectedColumns">Columns for which to create plot items.</param>
		/// <param name="xColumnName">Name of the x column. If it is null or empty, or that column is not found in the table, the current assigned x column is used.</param>
		/// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param>
		/// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are
		/// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like
		/// labels, yerr, and so on.</param>
		/// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
		/// <returns>List of plot items created.</returns>
		public static List<IGPlotItem> CreatePlotItems(IEnumerable<DataColumn> selectedColumns, string xColumnName, G2DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new List<IGPlotItem>();
			foreach (DataColumn ycol in selectedColumns)
			{
				if (processedColumns.Contains(ycol))
					continue;
				else
					processedColumns.Add(ycol);

				DataColumnCollection table = DataColumnCollection.GetParentDataColumnCollectionOf(ycol);
				Altaxo.Data.DataColumn xcol;
				if (!string.IsNullOrEmpty(xColumnName) && null != table && table.ContainsColumn(xColumnName))
					xcol = table[xColumnName];
				else
					xcol = null == table ? null : table.FindXColumnOf(ycol);

				int groupNumber = table.GetColumnGroup(ycol);
				var parentTable = DataTable.GetParentDataTableOf(table);

				XYColumnPlotData pa;
				if (null != xcol)
					pa = new XYColumnPlotData(parentTable, groupNumber, xcol, ycol);
				else
					pa = new XYColumnPlotData(parentTable, groupNumber, new Altaxo.Data.IndexerColumn(), ycol);

				G2DPlotStyleCollection ps = templatePlotStyle != null ? (G2DPlotStyleCollection)templatePlotStyle.Clone() : new G2DPlotStyleCollection();

				if (null == table)
					continue;

				ErrorBarPlotStyle unpairedPositiveError = null;
				ErrorBarPlotStyle unpairedNegativeError = null;

				bool foundMoreColumns = true;
				for (int idx = 1 + table.GetColumnNumber(ycol); foundMoreColumns && idx < table.ColumnCount; idx++)
				{
					DataColumn col = table[idx];
					switch (table.GetColumnKind(idx))
					{
						case ColumnKind.Label:
							LabelPlotStyle labelStyle = new LabelPlotStyle(col, context);
							ps.Insert(0, labelStyle);
							break;

						case ColumnKind.Err:
							ErrorBarPlotStyle errStyle = new ErrorBarYPlotStyle(context);
							errStyle.PositiveErrorColumn = col as INumericColumn;
							errStyle.NegativeErrorColumn = col as INumericColumn;
							ps.Add(errStyle);
							break;

						case ColumnKind.pErr:
							if (null != unpairedNegativeError)
							{
								unpairedNegativeError.PositiveErrorColumn = col as INumericColumn; ;
								unpairedNegativeError = null;
							}
							else
							{
								unpairedPositiveError = new ErrorBarYPlotStyle(context);
								unpairedPositiveError.PositiveErrorColumn = col as INumericColumn;
								ps.Add(unpairedPositiveError);
							}
							break;

						case ColumnKind.mErr:
							if (null != unpairedPositiveError)
							{
								unpairedPositiveError.NegativeErrorColumn = col as INumericColumn;
								unpairedPositiveError = null;
							}
							else
							{
								unpairedNegativeError = new ErrorBarYPlotStyle(context);
								unpairedNegativeError.NegativeErrorColumn = col as INumericColumn;
								ps.Add(unpairedNegativeError);
							}
							break;

						default:
							foundMoreColumns = false;
							break;
					}

					if (foundMoreColumns)
						processedColumns.Add(table[idx]);
				}

				result.Add(new XYColumnPlotItem(pa, ps));
			}
			return result;
		}
 public LineScatterPlotDataController(XYColumnPlotData pa)
 {
   m_PlotAssociation = pa;
   SetElements(true);
 }
Exemplo n.º 16
0
			public virtual void CreateEventChain(XYColumnPlotData s)
			{
				if (null != s._xColumn)
					s._xColumn.ParentObject = s;
				if (null != s._yColumn)
					s._yColumn.ParentObject = s;

				if (null != s._xBoundaries)
					s._xBoundaries.ParentObject = s;

				if (null != s._yBoundaries)
					s._yBoundaries.ParentObject = s;
			}
Exemplo n.º 17
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="from">The object to copy from.</param>
		/// <remarks>Only clones the references to the data columns, not the columns itself.</remarks>
		public XYColumnPlotData(XYColumnPlotData from)
		{
			ChildCopyToMember(ref _dataTable, from._dataTable);
			this._groupNumber = from._groupNumber;

			ChildCloneToMember(ref _dataRowSelection, from._dataRowSelection);

			ChildCopyToMember(ref _xColumn, from._xColumn);
			ChildCopyToMember(ref _yColumn, from._yColumn);

			// cached or temporary data

			if (null != from._xBoundaries)
				ChildCopyToMember(ref _xBoundaries, from._xBoundaries);

			if (null != from._yBoundaries)
				ChildCopyToMember(ref _yBoundaries, from._yBoundaries);

			this._pointCount = from._pointCount;
			this._isCachedDataValidX = from._isCachedDataValidX;
			this._isCachedDataValidY = from._isCachedDataValidY;
		}
Exemplo n.º 18
0
		/// <summary>
		/// This plots a label plot into the provided layer.
		/// </summary>
		/// <param name="layer">The layer to plot into.</param>
		/// <param name="table">The table of PLS output data.</param>
		/// <param name="xcol">The x column.</param>
		/// <param name="ycol">The y column.</param>
		/// <param name="labelcol">The label column.</param>
		public static void PlotOnlyLabel(XYPlotLayer layer, Altaxo.Data.DataTable table, Altaxo.Data.DataColumn xcol, Altaxo.Data.DataColumn ycol, Altaxo.Data.DataColumn labelcol)
		{
			var context = layer.GetPropertyContext();

			var groupNumber = table.DataColumns.GetColumnGroup(ycol);
			XYColumnPlotData pa = new XYColumnPlotData(table, groupNumber, xcol, ycol);

			G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty, layer.GetPropertyContext());
			LabelPlotStyle labelStyle = new LabelPlotStyle(labelcol, context);
			labelStyle.BackgroundStyle = new FilledRectangle(NamedColors.LightCyan);
			ps.Add(labelStyle);

			layer.PlotItems.Add(new XYColumnPlotItem(pa, ps));
		}