/// <summary>Adds the y-values of a plot item to an array of y-values..</summary>
		/// <param name="vArray">The y array to be added to. If null, a new array will be allocated (and filled with the y-values of the plot item).</param>
		/// <param name="pdata">The pdata.</param>
		/// <returns>If the parameter <paramref name="vArray"/> was not null, then that <paramref name="vArray"/> is returned. Otherwise the newly allocated array is returned.</returns>
		public static AltaxoVariant[] AddUp(AltaxoVariant[] vArray, Processed3DPlotData pdata)
		{
			if (vArray == null)
			{
				vArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

				int j = -1;
				foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
				{
					j++;
					vArray[j] = pdata.GetZPhysical(originalIndex);
				}
			}
			else // this is not the first item
			{
				int j = -1;
				foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
				{
					j++;
					vArray[j] += pdata.GetZPhysical(originalIndex);
				}
			}
			return vArray;
		}
			/// <summary>Initializes a new instance of the <see cref="LocalArrayHolder"/> class.</summary>
			/// <param name="localArray">The local array of transformed y values. The array length is equal to the number of plot points.</param>
			/// <param name="pdata">The processed plot data. The plot range member of this instance is used to build a dictionary which associates the original row indices to the indices of the <paramref name="localArray"/>.</param>
			public LocalArrayHolder(AltaxoVariant[] localArray, Processed3DPlotData pdata)
			{
				_localArray = localArray;
				_originalRowIndexToPlotIndex = pdata.RangeList.GetDictionaryOfOriginalRowIndicesToPlotIndices();
			}
Exemple #3
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

			// adjust the skip frequency if it was not set appropriate
			if (_skipFreq <= 0)
				_skipFreq = 1;

			var dropTargets = new List<CSPlaneID>(_dropTargets.Select(id => layer.UpdateCSPlaneID(id)));
			if (_additionalDropTargetIsEnabled)
			{
				CSPlaneID userPlane;
				if (_additionalDropTargetUsePhysicalBaseValue)
				{
					userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, layer.Scales[_additionalDropTargetPerpendicularAxis].PhysicalVariantToNormal(_additionalDropTargetBaseValue));
				}
				else
				{
					userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, _additionalDropTargetBaseValue);
				}
				dropTargets.Add(userPlane);
			}

			// paint the scatter style

			PointD3D pos = PointD3D.Empty;

			if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size and constant color
			{
				var pen = _pen;
				// update pen widths
				double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
				double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
				pen = pen.WithThickness1(w1).WithThickness2(w2);

				var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
				var gapEnd = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

				for (int r = 0; r < rangeList.Count; r++)
				{
					var range = rangeList[r];
					int lower = range.LowerBound;
					int upper = range.UpperBound;

					for (int j = lower; j < upper; j += _skipFreq)
					{
						Logical3D r3d = layer.GetLogical3D(pdata, j + range.OffsetToOriginal);
						foreach (CSPlaneID id in dropTargets)
						{
							IPolylineD3D isoLine;
							layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out isoLine);
							if (gapStart != 0 || gapEnd != 0)
								isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));

							if (null != isoLine)
								g.DrawLine(pen, isoLine);
						}
					}
				} // for each range
			}
			else // using a variable symbol size or variable symbol color
			{
				for (int r = 0; r < rangeList.Count; r++)
				{
					var range = rangeList[r];
					int lower = range.LowerBound;
					int upper = range.UpperBound;
					int offset = range.OffsetToOriginal;
					for (int j = lower; j < upper; j += _skipFreq)
					{
						var pen = _pen;
						if (null == _cachedColorForIndexFunction)
						{
							_cachedSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
							double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
							double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
							pen = _pen.WithThickness1(w1).WithThickness2(w2);
						}
						else
						{
							_cachedSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _cachedSymbolSize : _cachedSymbolSizeForIndexFunction(j + offset);
							double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
							double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;

							var customSymbolColor = _cachedColorForIndexFunction(j + offset);
							pen = _pen.WithThickness1(w1).WithThickness2(w2).WithColor(NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B));
						}

						var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
						var gapEnd = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

						Logical3D r3d = layer.GetLogical3D(pdata, j + rangeList[r].OffsetToOriginal);
						foreach (CSPlaneID id in _dropTargets)
						{
							IPolylineD3D isoLine;
							layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out isoLine);

							if (gapStart != 0 || gapEnd != 0)
								isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
							if (null != isoLine)
								g.DrawLine(pen, isoLine);
						}
					}
				}
			}
		}
Exemple #4
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			if (this.IsColorProvider)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this.Color; });

			// SkipFrequency should be the same for all sub plot styles, so there is no "private" property
			if (!_independentSkipFreq)
				SkipFrequencyGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return _skipFreq; });
		}
Exemple #5
0
		public Processed3DPlotData GetPlotData(IPlotArea layer)
		{
			if (_cachedPlotDataUsedForPainting == null)
				_cachedPlotDataUsedForPainting = GetRangesAndPoints(layer);

			return _cachedPlotDataUsedForPainting;
		}
Exemple #6
0
		/// <summary>
		/// Needed for coordinate transforming styles to plot the data.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="layer">The plot layer.</param>
		/// <param name="plotdata">The plot data. Since the data are transformed, you should not rely that the physical values in this item correspond to the area coordinates.</param>
		/// <param name="prevPlotData">Plot data of the previous plot item.</param>
		/// <param name="nextPlotData">Plot data of the next plot item.</param>
		public virtual void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData plotdata, Processed3DPlotData prevPlotData, Processed3DPlotData nextPlotData)
		{
			_cachedPlotDataUsedForPainting = plotdata;

			if (null != this._plotStyles)
			{
				_plotStyles.Paint(g, layer, plotdata, prevPlotData, nextPlotData);
			}
		}
Exemple #7
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			// first, we have to calculate the span of logical values from the minimum logical value to the maximum logical value
			int numberOfItems = 0;

			if (null != pdata)
			{
				double minLogicalX = double.MaxValue;
				double maxLogicalX = double.MinValue;
				double minLogicalY = double.MaxValue;
				double maxLogicalY = double.MinValue;
				foreach (int originalRowIndex in pdata.RangeList.OriginalRowIndices())
				{
					numberOfItems++;

					double logicalX = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalRowIndex));
					if (logicalX < minLogicalX)
						minLogicalX = logicalX;
					if (logicalX > maxLogicalX)
						maxLogicalX = logicalX;

					double logicalY = layer.YAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalRowIndex));
					if (logicalY < minLogicalY)
						minLogicalY = logicalY;
					if (logicalY > maxLogicalY)
						maxLogicalY = logicalY;
				}

				BarSizePosition3DGroupStyle.IntendToApply(externalGroups, localGroups, numberOfItems, minLogicalX, maxLogicalX, minLogicalY, maxLogicalY);
			}
			BarSizePosition3DGroupStyle bwp = PlotGroupStyle.GetStyleToInitialize<BarSizePosition3DGroupStyle>(externalGroups, localGroups);
			if (null != bwp)
				bwp.Initialize(_barShiftStrategy, _barShiftMaxNumberOfItemsInOneDirection, _relInnerGapX, _relOuterGapX, _relInnerGapY, _relOuterGapY);

			if (!_independentColor) // else if is used here because fill color has precedence over frame color
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this._pen.Color; });
		}
Exemple #8
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

			// paint the style

			PointD3D leftFrontBotton, rightBackTop;
			layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(0, 0, 0), out leftFrontBotton);
			layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(1, 1, 1), out rightBackTop);

			double globalBaseValue;
			if (_usePhysicalBaseValue)
			{
				globalBaseValue = layer.ZAxis.PhysicalVariantToNormal(_baseValue);
				if (double.IsNaN(globalBaseValue))
					globalBaseValue = 0;
			}
			else
			{
				globalBaseValue = _baseValue.ToDouble();
			}

			bool useVariableColor = null != _cachedColorForIndexFunction && !_independentColor;

			var pen = _pen;

			int j = -1;
			foreach (int originalRowIndex in pdata.RangeList.OriginalRowIndices())
			{
				j++;

				double xCenterLogical = layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalRowIndex));
				double xLowerLogical = xCenterLogical + _xOffsetLogical;
				double xUpperLogical = xLowerLogical + _xSizeLogical;

				double yCenterLogical = layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalRowIndex));
				double yLowerLogical = yCenterLogical + _yOffsetLogical;
				double yUpperLogical = yLowerLogical + _ySizeLogical;

				double zCenterLogical = layer.ZAxis.PhysicalVariantToNormal(pdata.GetZPhysical(originalRowIndex));
				double zBaseLogical = globalBaseValue;

				if (_startAtPreviousItem && pdata.PreviousItemData != null)
				{
					double prevstart = layer.ZAxis.PhysicalVariantToNormal(pdata.PreviousItemData.GetZPhysical(originalRowIndex));
					if (!double.IsNaN(prevstart))
					{
						zBaseLogical = prevstart;
						zBaseLogical += Math.Sign(zBaseLogical - globalBaseValue) * _previousItemZGap;
					}
				}

				// calculate the size at the base
				PointD3D lcp, ucp, clp, cup;
				layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xLowerLogical, yCenterLogical, zBaseLogical), out lcp);
				layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xUpperLogical, yCenterLogical, zBaseLogical), out ucp);
				layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xCenterLogical, yLowerLogical, zBaseLogical), out clp);
				layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(xCenterLogical, yUpperLogical, zBaseLogical), out cup);

				double penWidth1 = (lcp - ucp).Length;
				double penWidth2 = (clp - cup).Length;

				if (_useUniformCrossSectionThickness)
				{
					pen = pen.WithUniformThickness(Math.Min(penWidth1, penWidth2));
				}
				else
				{
					pen = pen.WithThickness1(penWidth1);
					pen = pen.WithThickness2(penWidth2);
				}

				if (useVariableColor)
					pen = pen.WithColor(GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRowIndex), "VariableColor"));

				var isoLine = layer.CoordinateSystem.GetIsoline(new Logical3D(xLowerLogical, yLowerLogical, zBaseLogical), new Logical3D(xLowerLogical, yLowerLogical, zCenterLogical));
				g.DrawLine(pen, isoLine);
			}
		}
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			if (!_independentColor)
				Graph.Plot.Groups.ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this._strokePen.Color; });

			if (!_independentSkipFrequency)
				SkipFrequencyGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return SkipFrequency; });

			// note: symbol size and barposition are only applied, but not prepared
			// this item can not be used as provider of a symbol size
		}
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			const double logicalClampMinimum = -10;
			const double logicalClampMaximum = 11;

			// Plot error bars for the dependent variable (y)
			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
			var columnX = ColumnX;
			var columnY = ColumnY;
			var columnZ = ColumnZ;

			if (columnX == null || columnY == null || columnZ == null)
				return; // nothing to do if both error columns are null

			if (!typeof(double).IsAssignableFrom(columnX.ItemType) || !typeof(double).IsAssignableFrom(columnY.ItemType) || !typeof(double).IsAssignableFrom(columnZ.ItemType))
				return; // TODO make this an runtime paint error to be reported

			var strokePen = _strokePen;

			foreach (PlotRange r in rangeList)
			{
				int lower = r.LowerBound;
				int upper = r.UpperBound;
				int offset = r.OffsetToOriginal;

				for (int j = lower; j < upper; j += _skipFrequency)
				{
					int originalRow = j + offset;
					double symbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalRow);

					strokePen = strokePen.WithThickness1(_lineWidth1Offset + _lineWidth1Factor * symbolSize);
					strokePen = strokePen.WithThickness2(_lineWidth2Offset + _lineWidth2Factor * symbolSize);

					if (null != _cachedColorForIndexFunction)
						strokePen = strokePen.WithColor(GdiColorHelper.ToNamedColor(_cachedColorForIndexFunction(originalRow), "VariableColor"));
					if (null != strokePen.LineEndCap)
						strokePen = strokePen.WithLineEndCap(strokePen.LineEndCap.WithMinimumAbsoluteAndRelativeSize(symbolSize * _endCapSizeFactor + _endCapSizeOffset, 1 + 1E-6));

					// Calculate target
					AltaxoVariant targetX, targetY, targetZ;
					switch (_meaningOfValues)
					{
						case ValueInterpretation.AbsoluteDifference:
							{
								targetX = pdata.GetXPhysical(originalRow) + columnX[originalRow];
								targetY = pdata.GetYPhysical(originalRow) + columnY[originalRow];
								targetZ = pdata.GetZPhysical(originalRow) + columnZ[originalRow];
							}
							break;

						case ValueInterpretation.AbsoluteValue:
							{
								targetX = columnX[originalRow];
								targetY = columnY[originalRow];
								targetZ = columnZ[originalRow];
							}
							break;

						default:
							throw new NotImplementedException(nameof(_meaningOfValues));
					}

					var logicalTarget = layer.GetLogical3D(targetX, targetY, targetZ);
					var logicalOrigin = layer.GetLogical3D(pdata, originalRow);

					if (!_independentOnShiftingGroupStyles && (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY || 0 != _cachedLogicalShiftZ))
					{
						logicalOrigin.RX += _cachedLogicalShiftX;
						logicalOrigin.RY += _cachedLogicalShiftY;
						logicalOrigin.RZ += _cachedLogicalShiftZ;
						logicalTarget.RX += _cachedLogicalShiftX;
						logicalTarget.RY += _cachedLogicalShiftY;
						logicalTarget.RZ += _cachedLogicalShiftZ;
					}

					if (!Calc.RMath.IsInIntervalCC(logicalOrigin.RX, logicalClampMinimum, logicalClampMaximum))
						continue;
					if (!Calc.RMath.IsInIntervalCC(logicalOrigin.RY, logicalClampMinimum, logicalClampMaximum))
						continue;
					if (!Calc.RMath.IsInIntervalCC(logicalOrigin.RZ, logicalClampMinimum, logicalClampMaximum))
						continue;

					if (!Calc.RMath.IsInIntervalCC(logicalTarget.RX, logicalClampMinimum, logicalClampMaximum))
						continue;
					if (!Calc.RMath.IsInIntervalCC(logicalTarget.RY, logicalClampMinimum, logicalClampMaximum))
						continue;
					if (!Calc.RMath.IsInIntervalCC(logicalTarget.RZ, logicalClampMinimum, logicalClampMaximum))
						continue;

					var isoLine = layer.CoordinateSystem.GetIsoline(logicalOrigin, logicalTarget);
					if (null == isoLine)
						continue;

					if (_useManualVectorLength)
					{
						double length = _vectorLengthOffset + _vectorLengthFactor * symbolSize;
						double isoLineLength = isoLine.TotalLineLength;
						isoLine = isoLine.ShortenedBy(RADouble.NewAbs(0), RADouble.NewAbs(isoLineLength - length));
						if (null == isoLine)
							continue;
					}

					if (_useSymbolGap)
					{
						double gap = _symbolGapOffset + _symbolGapFactor * symbolSize;
						if (gap != 0)
						{
							isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gap / 2), RADouble.NewAbs(0));
							if (null == isoLine)
								continue;
						}
					}

					g.DrawLine(strokePen, isoLine);
				}
			}
		}
Exemple #11
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

			// adjust the skip frequency if it was not set appropriate
			if (_skipFreq <= 0)
				_skipFreq = 1;

			// paint the scatter style
			if (!ScatterSymbols.NoSymbol.Instance.Equals(_symbolShape))
			{
				PointD3D pos = PointD3D.Empty;
				VectorD3D diff;

				if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size
				{
					for (int r = 0; r < rangeList.Count; r++)
					{
						var range = rangeList[r];
						int lower = range.LowerBound;
						int upper = range.UpperBound;
						for (int j = lower; j < upper; j += _skipFreq)
						{
							_symbolShape.Paint(g, _material, ptArray[j], _symbolSize);
						} // end for all points in range
					} // end for all ranges
				}
				else // using a variable symbol size or variable symbol color
				{
					for (int r = 0; r < rangeList.Count; r++)
					{
						int lower = rangeList[r].LowerBound;
						int upper = rangeList[r].UpperBound;
						int offset = rangeList[r].OffsetToOriginal;
						for (int j = lower; j < upper; j += _skipFreq)
						{
							if (null == _cachedColorForIndexFunction)
							{
								double customSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
								_symbolShape.Paint(g, _material, ptArray[j], customSymbolSize);
							}
							else
							{
								double customSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(j + offset);
								var customSymbolColor = _cachedColorForIndexFunction(j + offset);
								_symbolShape.Paint(g, _material.WithColor(NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B)), ptArray[j], customSymbolSize);
							}
						}
					}
				}
			}
		}
Exemple #12
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			if (this.IsColorProvider)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this.Material.Color; });
			else if (this.IsBackgroundColorProvider)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this._backgroundStyle.Material.Color; });
		}
Exemple #13
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			if (this._labelColumnProxy.Document == null)
				return;

			if (null != _attachedPlane)
				_attachedPlane = layer.UpdateCSPlaneID(_attachedPlane);

			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
			Altaxo.Data.IReadableColumn labelColumn = this._labelColumnProxy.Document;

			bool isUsingVariableColorForLabelText = null != _cachedColorForIndexFunction && IsColorReceiver;
			bool isUsingVariableColorForLabelBackground = null != _cachedColorForIndexFunction &&
				(null != _backgroundStyle && _backgroundStyle.SupportsUserDefinedMaterial && (_backgroundColorLinkage == ColorLinkage.Dependent || _backgroundColorLinkage == ColorLinkage.PreserveAlpha));
			bool isUsingVariableColor = isUsingVariableColorForLabelText || isUsingVariableColorForLabelBackground;
			IMaterial clonedTextBrush = _material;
			IMaterial clonedBackBrush = null;
			if (isUsingVariableColorForLabelBackground)
				clonedBackBrush = _backgroundStyle.Material;

			// save the graphics stat since we have to translate the origin
			var gs = g.SaveGraphicsState();

			double xpos = 0, ypos = 0, zpos = 0;
			double xpre, ypre, zpre;
			double xdiff, ydiff, zdiff;

			bool isFormatStringContainingBraces = _labelFormatString?.IndexOf('{') >= 0;
			var culture = System.Threading.Thread.CurrentThread.CurrentCulture;

			bool mustUseLogicalCoordinates = null != this._attachedPlane || 0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY || 0 != _cachedLogicalShiftZ;

			for (int r = 0; r < rangeList.Count; r++)
			{
				int lower = rangeList[r].LowerBound;
				int upper = rangeList[r].UpperBound;
				int offset = rangeList[r].OffsetToOriginal;
				for (int j = lower; j < upper; j += _skipFrequency)
				{
					string label;
					if (string.IsNullOrEmpty(_labelFormatString))
					{
						label = labelColumn[j + offset].ToString();
					}
					else if (!isFormatStringContainingBraces)
					{
						label = labelColumn[j + offset].ToString(_labelFormatString, culture);
					}
					else
					{
						// the label format string can contain {0} for the label column item, {1} for the row index, {2} .. {4} for the x, y and z component of the data point
						label = string.Format(_labelFormatString, labelColumn[j + offset], j + offset, pdata.GetPhysical(0, j + offset), pdata.GetPhysical(1, j + offset), pdata.GetPhysical(2, j + offset));
					}

					if (string.IsNullOrEmpty(label))
						continue;

					double localSymbolSize = _symbolSize;
					if (null != _cachedSymbolSizeForIndexFunction)
					{
						localSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
					}

					double localFontSize = _fontSizeOffset + _fontSizeFactor * localSymbolSize;
					if (!(localFontSize > 0))
						continue;

					_font = _font.WithSize(localFontSize);

					// Start of preparation of brushes, if a variable color is used
					if (isUsingVariableColor)
					{
						var c = _cachedColorForIndexFunction(j + offset);

						if (isUsingVariableColorForLabelText)
						{
							clonedTextBrush = clonedTextBrush.WithColor(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), "e"));
						}
						if (isUsingVariableColorForLabelBackground)
						{
							if (_backgroundColorLinkage == ColorLinkage.PreserveAlpha)
								clonedBackBrush = clonedBackBrush.WithColor(new NamedColor(AxoColor.FromArgb(clonedBackBrush.Color.Color.A, c.R, c.G, c.B), "e"));
							else
								clonedBackBrush = clonedBackBrush.WithColor(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), "e"));
						}
					}
					// end of preparation of brushes for variable colors

					if (mustUseLogicalCoordinates) // we must use logical coordinates because either there is a shift of logical coordinates, or an attached plane
					{
						Logical3D r3d = layer.GetLogical3D(pdata, j + offset);
						r3d.RX += _cachedLogicalShiftX;
						r3d.RY += _cachedLogicalShiftY;
						r3d.RZ += _cachedLogicalShiftZ;

						if (null != this._attachedPlane)
						{
							var pp = layer.CoordinateSystem.GetPointOnPlane(this._attachedPlane, r3d);
							xpre = pp.X;
							ypre = pp.Y;
							zpre = pp.Z;
						}
						else
						{
							PointD3D pt;
							layer.CoordinateSystem.LogicalToLayerCoordinates(r3d, out pt);
							xpre = pt.X;
							ypre = pt.Y;
							zpre = pt.Z;
						}
					}
					else // no shifting, thus we can use layer coordinates
					{
						xpre = ptArray[j].X;
						ypre = ptArray[j].Y;
						zpre = ptArray[j].Z;
					}

					xdiff = xpre - xpos;
					ydiff = ypre - ypos;
					zdiff = zpre - zpos;
					xpos = xpre;
					ypos = ypre;
					zpos = zpre;
					g.TranslateTransform(xdiff, ydiff, zdiff);
					g.RotateTransform(_rotationX, _rotationY, _rotationZ);

					this.Paint(g, label, localSymbolSize, clonedTextBrush, clonedBackBrush);

					g.RotateTransform(-_rotationX, -_rotationY, -_rotationZ);
				} // end for
			}

			g.RestoreGraphicsState(gs); // Restore the graphics state
		}
Exemple #14
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			if (this.IsColorProvider)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this.Color; });

			if (!_independentDashStyle)
				DashPatternGroupStyle.PrepareStyle(externalGroups, localGroups, delegate { return this.LinePen.DashPattern ?? DashPatternListManager.Instance.BuiltinDefaultSolid; });
		}
Exemple #15
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			var linePoints = pdata.PlotPointsInAbsoluteLayerCoordinates;
			var rangeList = pdata.RangeList;
			var symbolGap = _symbolSize;
			int rangelistlen = rangeList.Count;

			Func<int, double> symbolGapFunction = null;

			if (_useSymbolGap)
			{
				if (null != _cachedSymbolSizeForIndexFunction && !_independentSymbolSize)
				{
					symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _cachedSymbolSizeForIndexFunction(idx);
				}
				else
				{
					symbolGapFunction = (idx) => _symbolGapOffset + _symbolGapFactor * _symbolSize;
				}
			}

			if (this._ignoreMissingDataPoints)
			{
				// in case we ignore the missing points, all ranges can be plotted
				// as one range, i.e. continuously
				// for this, we create the totalRange, which contains all ranges
				PlotRange totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
				_connectionStyle.Paint(g, pdata, totalRange, layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
			}
			else // we not ignore missing points, so plot all ranges separately
			{
				for (int i = 0; i < rangelistlen; i++)
				{
					_connectionStyle.Paint(g, pdata, rangeList[i], layer, _linePen, symbolGapFunction, _skipFreq, _connectCircular);
				}
			}
		}