Beispiel #1
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 XYZColumnPlotData(XYZColumnPlotData from)
        {
            ChildCopyToMember(ref _dataTable, from._dataTable);
            _groupNumber = from._groupNumber;
            ChildCloneToMember(ref _dataRowSelection, from._dataRowSelection);

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

            // cached or temporary data

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

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

            if (null != from._zBoundaries)
            {
                ChildCopyToMember(ref _zBoundaries, from._zBoundaries);
            }

            _pointCount         = from._pointCount;
            _isCachedDataValidX = from._isCachedDataValidX;
            _isCachedDataValidY = from._isCachedDataValidY;
        }
Beispiel #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 XYZColumnPlotData(XYZColumnPlotData 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);
			ChildCopyToMember(ref _zColumn, from._zColumn);

			// cached or temporary data

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

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

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

			this._pointCount = from._pointCount;
			this._isCachedDataValidX = from._isCachedDataValidX;
			this._isCachedDataValidY = from._isCachedDataValidY;
		}
Beispiel #3
0
		private System.Collections.Generic.IEnumerable<DocumentNodeAndName> GetLocalDocumentNodeChildrenWithName()
		{
			if (null != _plotData)
				yield return new DocumentNodeAndName(_plotData, () => _plotData = null, "Data");
		}
Beispiel #4
0
		public XYZColumnPlotItem(XYZColumnPlotData pa, G3DPlotStyleCollection ps)
		{
			this.Data = pa;
			this.Style = ps;
		}
Beispiel #5
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, string yColumnName, G3DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new List<IGPlotItem>();
			foreach (DataColumn vcol in selectedColumns)
			{
				if (processedColumns.Contains(vcol))
					continue;
				else
					processedColumns.Add(vcol);

				var table = DataTable.GetParentDataTableOf(vcol);
				var tablecoll = DataColumnCollection.GetParentDataColumnCollectionOf(vcol);
				int groupNumber = tablecoll.GetColumnGroup(vcol);

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

				if (!string.IsNullOrEmpty(yColumnName) && null != table && table.ContainsColumn(yColumnName))
					ycol = table[yColumnName];
				else
					ycol = null == table ? null : tablecoll.FindYColumnOf(vcol);

				var pa = new XYZColumnPlotData(
						table,
						groupNumber,
						(IReadableColumn)xcol ?? (IReadableColumn)new IndexerColumn(),
						(IReadableColumn)ycol ?? (IReadableColumn)new ConstantDoubleColumn(0),
						vcol);

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

				if (null == table)
					continue;

				ErrorBarPlotStyle unpairedPositiveError = null;
				ErrorBarPlotStyle unpairedNegativeError = null;

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

						case ColumnKind.Err:
							var errStyle = new ErrorBarZPlotStyle(context);
							errStyle.UseCommonErrorColumn = true;
							errStyle.CommonErrorColumn = col as INumericColumn;
							ps.Add(errStyle);
							break;

						case ColumnKind.pErr:
							if (null != unpairedNegativeError)
							{
								unpairedNegativeError.PositiveErrorColumn = col as INumericColumn; ;
								unpairedNegativeError = null;
							}
							else
							{
								unpairedPositiveError = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false };

								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 ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false };
								unpairedNegativeError.NegativeErrorColumn = col as INumericColumn;
								ps.Add(unpairedNegativeError);
							}
							break;

						default:
							foundMoreColumns = false;
							break;
					}

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

				result.Add(new XYZColumnPlotItem(pa, ps));
			}
			return result;
		}