public void TransferFrom(IPlotGroupStyle fromb) { var from = (ScatterSymbolGroupStyle)fromb; _value = from._value; _listOfValues = from._listOfValues; }
private void GetPathGeometries(IScatterSymbol symbol, double symbolSize, out PathGeometry fill, out PathGeometry frame, out PathGeometry inset) { symbol.CalculatePolygons(null, out var framePolygon, out var insetPolygon, out var fillPolygon); fill = fillPolygon == null ? null : GetPathGeometry(fillPolygon, symbolSize); frame = framePolygon == null ? null : GetPathGeometry(framePolygon, symbolSize); inset = insetPolygon == null ? null : GetPathGeometry(insetPolygon, symbolSize); }
/// <summary> /// Calculates the brushes. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="plotColor">The current plot color.</param> /// <param name="cachedPathData">The cached path data.</param> /// <param name="cachedBrushData">Cached brush data, which will be filled-in during this call..</param> /// <returns>True if new cached brush data were calculated; false if the cached data were up-to-date.</returns> private bool CalculateBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { if (plotColor == cachedBrushData.PlotColor) { return(false); // cached data valid and could be reused; } cachedBrushData.Clear(); cachedBrushData.PlotColor = plotColor; var plotColorInfluence = _overridePlotColorInfluence ?? scatterSymbol.PlotColorInfluence; if (null != cachedPathData.InsetPath) { var insetColor = _overrideInsetColor ?? scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) { insetColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) { insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); } cachedBrushData.InsetBrush = new SolidBrush(insetColor); } if (null != cachedPathData.FillPath) { var fillColor = _overrideFillColor ?? scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) { fillColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) { fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); } cachedBrushData.FillBrush = new SolidBrush(fillColor); } if (null != cachedPathData.FramePath) { var frameColor = _overrideFrameColor ?? scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) { frameColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) { frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); } cachedBrushData.FrameBrush = new SolidBrush(frameColor); } return(true); }
internal ScatterPlotStyle(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, bool oldDeserializationRequiresFullConstruction) { double symbolSize = 8; var color = ColorSetManager.Instance.BuiltinDarkPlotColors[0]; _scatterSymbol = ScatterSymbolListManager.Instance.BuiltinDefault[0]; _color = NamedColors.Black; _independentColor = false; _symbolSize = symbolSize; _skipFreq = 1; }
public ScatterPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { double penWidth = GraphDocument.GetDefaultPenWidth(context); double symbolSize = GraphDocument.GetDefaultSymbolSize(context); var color = GraphDocument.GetDefaultPlotColor(context); _scatterSymbol = ScatterSymbolListManager.Instance.BuiltinDefault[0]; _color = color; _independentColor = false; _symbolSize = symbolSize; _skipFreq = 1; }
private void SetValueCoercedToGroup(IScatterSymbol value) { if (_isStepEnabled) { var idx = Math.Max(0, _listOfValues.IndexOf(value)); _value = _listOfValues[idx]; } else { _value = value; } }
/// <summary> /// Calculates the paths and stores them into a structure given by the argument <paramref name="cachedPathData"/>. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="symbolSize">The size of the symbol for which to calculate the paths.</param> /// <param name="cachedPathData">The cached path data.</param> /// <returns>True if new paths have been calculated; false if the previously cached data could be used.</returns> private bool CalculatePaths(IScatterSymbol scatterSymbol, double symbolSize, ref CachedPathData cachedPathData) { if (symbolSize == cachedPathData.SymbolSize) { return(false); // we assume that the structure already contains valid data. } cachedPathData.SymbolSize = symbolSize; cachedPathData.FillPath = cachedPathData.FramePath = cachedPathData.InsetPath = null; if (scatterSymbol is NoSymbol) { return(true); } double?overrideRelativeStructureWidth = null; if (_overrideStructureWidthOffset.HasValue || _overrideStructureWidthFactor.HasValue) { overrideRelativeStructureWidth = (_overrideStructureWidthFactor ?? 0) + (_overrideStructureWidthOffset ?? 0) / symbolSize; } scatterSymbol.CalculatePolygons(overrideRelativeStructureWidth, out var framePolygon, out var insetPolygon, out var fillPolygon); // calculate the path only once if (null != insetPolygon) { cachedPathData.InsetPath = new GraphicsPath(); foreach (var list in insetPolygon) { cachedPathData.InsetPath.AddPolygon(ToPointFArray(list, symbolSize)); } } if (null != fillPolygon) { cachedPathData.FillPath = new GraphicsPath(); foreach (var list in fillPolygon) { cachedPathData.FillPath.AddPolygon(ToPointFArray(list, symbolSize)); } } if (null != framePolygon) { cachedPathData.FramePath = new GraphicsPath(); foreach (var list in framePolygon) { cachedPathData.FramePath.AddPolygon(ToPointFArray(list, symbolSize)); } } return(true); }
private void GetBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, PathGeometry fillPath, PathGeometry framePath, PathGeometry insetPath, out Brush fillBrush, out Brush frameBrush, out Brush insetBrush) { fillBrush = frameBrush = insetBrush = null; var plotColorInfluence = scatterSymbol.PlotColorInfluence; if (null != insetPath) { var insetColor = scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) { insetColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) { insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); } insetBrush = new SolidColorBrush(GuiHelper.ToWpf(insetColor)); } if (null != fillPath) { var fillColor = scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) { fillColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) { fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); } fillBrush = new SolidColorBrush(GuiHelper.ToWpf(fillColor)); } if (null != framePath) { var frameColor = scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) { frameColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) { frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); } frameBrush = new SolidColorBrush(GuiHelper.ToWpf(frameColor)); } }
protected static void SerializeSetV0(IScatterSymbol obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { var parent = ScatterSymbolListManager.Instance.GetParentList(obj); if (null != parent) { if (null == info.GetProperty(ScatterSymbolList.GetSerializationRegistrationKey(parent))) { info.AddValue("Set", parent); } else { info.AddValue("SetName", parent.Name); } } }
public ScatterPlotStyle(IScatterSymbol symbol, double size, double penWidth, NamedColor penColor) { if (null == symbol) { throw new ArgumentNullException(nameof(symbol)); } _symbolShape = symbol; _material = new MaterialWithUniformColor(penColor); _symbolSize = size; _skipFreq = 1; _independentSkipFreq = false; // Cached values SetCachedValues(); }
public void Initialize(IScatterSymbol value) { if (null == value) { throw new ArgumentNullException(nameof(value)); } _isInitialized = true; var parentList = ScatterSymbolListManager.Instance.GetParentList(value); if (null != parentList) { _listOfValues = parentList; } SetValueCoercedToGroup(value); }
public int Step(int step) { if (0 == step) { return(0); // nothing changed } var list = _listOfValues; var listcount = list.Count; if (listcount == 0) { return(0); } var currentIdx = Math.Max(0, list.IndexOf(_value)); var valueIndex = Calc.BasicFunctions.PMod(currentIdx + step, _listOfValues.Count); int wraps = Calc.BasicFunctions.NumberOfWraps(_listOfValues.Count, currentIdx, step); _value = _listOfValues[valueIndex]; return(wraps); }
/// <inheritdoc/> public void CopyFrom(ScatterPlotStyle from, Main.EventFiring eventFiring) { if (object.ReferenceEquals(this, from)) { return; } using (var suspendToken = SuspendGetToken()) { _independentSkipFreq = from._independentSkipFreq; _skipFreq = from._skipFreq; _ignoreMissingDataPoints = from._ignoreMissingDataPoints; _independentOnShiftingGroupStyles = from._independentOnShiftingGroupStyles; _independentScatterSymbol = from._independentScatterSymbol; _scatterSymbol = from._scatterSymbol; _independentSymbolSize = from._independentSymbolSize; _symbolSize = from._symbolSize; _independentColor = from._independentColor; _color = from._color; _overrideFrame = from._overrideFrame; _overriddenFrame = from._overriddenFrame; _overrideInset = from._overrideInset; _overriddenInset = from._overriddenInset; _overrideStructureWidthOffset = from._overrideStructureWidthOffset; _overrideStructureWidthFactor = from._overrideStructureWidthFactor; _overridePlotColorInfluence = from._overridePlotColorInfluence; _overrideFillColor = from._overrideFillColor; _overrideFrameColor = from._overrideFrameColor; _overrideInsetColor = from._overrideInsetColor; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(eventFiring); } }
private void ClearAllOverridesThatAreEqualToScatterSymbol(IScatterSymbol symbol) { if (symbol.Frame?.GetType() == (Type)_symbolFrameChoices.FirstSelectedNode?.Tag) { _view.OverrideFrame = false; } if (symbol.Inset?.GetType() == (Type)_symbolInsetChoices.FirstSelectedNode?.Tag) { _view.OverrideInset = false; } if ((_view.OverrideRelativeStructureWidth == false || symbol.RelativeStructureWidth == _view.OverriddenRelativeStructureWidth) && (_view.OverrideAbsoluteStructureWidth == false || _view.OverriddenAbsoluteStructureWidth == 0)) { _view.OverrideAbsoluteStructureWidth = false; _view.OverrideRelativeStructureWidth = false; } if (symbol.PlotColorInfluence == _view.OverriddenPlotColorInfluence) { _view.OverridePlotColorInfluence = false; } if (symbol.FillColor == _view.OverriddenFillColor) { _view.OverrideFillColor = false; } if (symbol.Frame == null || symbol.Frame.Color == _view.OverriddenFrameColor) { _view.OverrideFrameColor = false; } if (symbol.Inset == null || symbol.Inset.Color == _view.OverriddenInsetColor) { _view.OverrideInsetColor = false; } }
public void CopyFrom(ScatterPlotStyle from, Main.EventFiring eventFiring) { if (object.ReferenceEquals(this, from)) { return; } using (var suspendToken = SuspendGetToken()) { _independentSkipFreq = from._independentSkipFreq; _skipFreq = from._skipFreq; _symbolShape = from._symbolShape; // immutable _independentSymbolSize = from._independentSymbolSize; _symbolSize = from._symbolSize; _material = from._material; // immutable _independentColor = from._independentColor; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(eventFiring); } }
public void Initialize(IScatterSymbol value) { if (null == value) throw new ArgumentNullException(nameof(value)); _isInitialized = true; var parentList = ScatterSymbolListManager.Instance.GetParentList(value); if (null != parentList) { _listOfValues = parentList; } SetValueCoercedToGroup(value); }
public int Step(int step) { if (0 == step) return 0; // nothing changed var list = _listOfValues; var listcount = list.Count; if (listcount == 0) { return 0; } var currentIdx = Math.Max(0, list.IndexOf(_value)); var valueIndex = Calc.BasicFunctions.PMod(currentIdx + step, _listOfValues.Count); int wraps = Calc.BasicFunctions.NumberOfWraps(_listOfValues.Count, currentIdx, step); _value = _listOfValues[valueIndex]; return wraps; }
public ScatterPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { double penWidth = GraphDocument.GetDefaultPenWidth(context); double symbolSize = GraphDocument.GetDefaultSymbolSize(context); var color = GraphDocument.GetDefaultPlotColor(context); this._scatterSymbol = ScatterSymbolListManager.Instance.BuiltinDefault[0]; _color = color; this._independentColor = false; this._symbolSize = symbolSize; this._skipFreq = 1; }
public override string GetDisplayName(IScatterSymbol item) { return((string)_itemToItemNameConverter.Convert(item, typeof(string), null, System.Globalization.CultureInfo.InvariantCulture)); }
private void GetPathGeometries(IScatterSymbol symbol, double symbolSize, out PathGeometry fill, out PathGeometry frame, out PathGeometry inset) { List<List<ClipperLib.IntPoint>> framePolygon, insetPolygon, fillPolygon; symbol.CalculatePolygons(null, out framePolygon, out insetPolygon, out fillPolygon); fill = fillPolygon == null ? null : GetPathGeometry(fillPolygon, symbolSize); frame = framePolygon == null ? null : GetPathGeometry(framePolygon, symbolSize); inset = insetPolygon == null ? null : GetPathGeometry(insetPolygon, symbolSize); }
private IScatterSymbol CreateNewSymbolSetFromOverrides(IScatterSymbol symbol, out bool cancellationRequested) { cancellationRequested = false; double overriddenAbsoluteStructureWidth = _view.OverrideAbsoluteStructureWidth ? _view.OverriddenAbsoluteStructureWidth : 0; double overriddenRelativeStructureWidth = _view.OverrideRelativeStructureWidth ? _view.OverriddenRelativeStructureWidth : symbol.RelativeStructureWidth; double resultingRelativeStructureWidth = overriddenRelativeStructureWidth; if (_view.OverrideAbsoluteStructureWidth && _view.OverriddenAbsoluteStructureWidth != 0) { if (overriddenRelativeStructureWidth <= 0) { var dlgResult = Current.Gui.YesNoCancelMessageBox( "Currently the absolute structure width has been overriden.\r\n" + "However, in the new symbol set to be created, only the relative structure width can be stored.\r\n" + "This is especially problematic, since the relative structure width is set to 0 (zero).\r\n" + "Do you want to convert the absolute structure width into a relative value?\r\n" + "Yes: Converts absolute structure width into relative width, using current symbol size\r\n" + "No: Sets relative structure width to zero (probably not very useful)\r\n" + "Cancel: Cancels the creation of a new symbol set", "Question concerning absolute/relative structure width", true); if (null == dlgResult) { cancellationRequested = true; return(symbol); } else if (true == dlgResult) { resultingRelativeStructureWidth = overriddenAbsoluteStructureWidth / _view.SymbolSize; } else { resultingRelativeStructureWidth = 0; } } else { var dlgResult = Current.Gui.YesNoCancelMessageBox( "Currently the absolute structure width has been overriden.\r\n" + "However, in the new symbol set to be created, only the relative structure width can be stored.\r\n" + "Do you want to take both the absolute and the relative structure width into account?\r\n" + "Yes: Converts the combined absolute and relative structure width into relative width, using current symbol size\r\n" + "No: Sets relative structure, using the overridden relative structure width or the default value.\r\n" + "Cancel: Cancels the creation of a new symbol set", "Question concerning absolute/relative structure width", false); if (null == dlgResult) { cancellationRequested = true; return(symbol); } else if (true == dlgResult) { resultingRelativeStructureWidth = overriddenRelativeStructureWidth + overriddenAbsoluteStructureWidth / _view.SymbolSize; } else { resultingRelativeStructureWidth = overriddenRelativeStructureWidth; } } } // we have to create a new symbol - if IsIndependent symbol is not checked, we have to create a new series of symbols bool createNewSymbolList; int originalItemIndex; IEnumerable <IScatterSymbol> scatterSymbolsToModify; if (_view.IndependentScatterSymbol) { scatterSymbolsToModify = new IScatterSymbol[] { symbol }; originalItemIndex = 0; createNewSymbolList = false; } else { var parentList = ScatterSymbolListManager.Instance.GetParentList(symbol); if (null != parentList) { scatterSymbolsToModify = parentList; originalItemIndex = parentList.IndexOf(symbol); createNewSymbolList = true; } else { scatterSymbolsToModify = new IScatterSymbol[] { symbol }; originalItemIndex = 0; createNewSymbolList = false; } } var newSymbols = new List <IScatterSymbol>(); foreach (var symbolToModify in scatterSymbolsToModify) { var newSymbol = symbolToModify; if (_view.OverrideInset) { var newInsetType = (Type)_symbolInsetChoices.FirstSelectedNode?.Tag; if (newInsetType != newSymbol.Inset?.GetType()) { var newInset = null == newInsetType ? null : (IScatterSymbolInset)Activator.CreateInstance(newInsetType); newSymbol = newSymbol.WithInset(newInset); } } if (_view.OverrideFrame) { var newFrameType = (Type)_symbolFrameChoices.FirstSelectedNode?.Tag; if (newFrameType != newSymbol.Frame?.GetType()) { var newFrame = null == newFrameType ? null : (IScatterSymbolFrame)Activator.CreateInstance(newFrameType); newSymbol = newSymbol.WithFrame(newFrame); } } if (_view.OverrideRelativeStructureWidth || _view.OverrideRelativeStructureWidth) { newSymbol = newSymbol.WithRelativeStructureWidth(resultingRelativeStructureWidth); } if (_view.OverridePlotColorInfluence) { newSymbol = newSymbol.WithPlotColorInfluence(_view.OverriddenPlotColorInfluence); } if (_view.OverrideFillColor) { newSymbol = newSymbol.WithFillColor(_view.OverriddenFillColor); } if (_view.OverrideFrameColor && newSymbol.Frame != null) { newSymbol = newSymbol.WithFrame(newSymbol.Frame.WithColor(_view.OverriddenFrameColor)); } if (_view.OverrideInsetColor && newSymbol.Inset != null) { newSymbol = newSymbol.WithInset(newSymbol.Inset.WithColor(_view.OverriddenInsetColor)); } newSymbols.Add(newSymbol); } if (createNewSymbolList) { if (ScatterSymbolListManager.Instance.TryGetListByMembers(newSymbols, null, out var existingListName)) { Current.Gui.InfoMessageBox("A symbol set with the chosen parameters already exists under the name: " + existingListName, "Symbol set exists"); return(ScatterSymbolListManager.Instance.GetList(existingListName)[originalItemIndex]); } else { string newName = "Custom"; if (!Current.Gui.ShowDialog(ref newName, "Enter a name for the new scatter symbol set", false)) { cancellationRequested = true; return(symbol); } var newScatterSymbolList = new ScatterSymbolList(newName, newSymbols); ScatterSymbolListManager.Instance.TryRegisterList(newScatterSymbolList, Altaxo.Main.ItemDefinitionLevel.Project, out var resultList); // return the item at the original list index. return(resultList[originalItemIndex]); } } else { if (ScatterSymbolListManager.Instance.TryFindListContaining(newSymbols[originalItemIndex], out var dummyList, out var result)) { return(result); }
/// <inheritdoc/> public void CopyFrom(ScatterPlotStyle from, Main.EventFiring eventFiring) { if (object.ReferenceEquals(this, from)) return; using (var suspendToken = SuspendGetToken()) { this._independentSkipFreq = from._independentSkipFreq; this._skipFreq = from._skipFreq; this._ignoreMissingDataPoints = from._ignoreMissingDataPoints; this._independentOnShiftingGroupStyles = from._independentOnShiftingGroupStyles; this._independentScatterSymbol = from._independentScatterSymbol; this._scatterSymbol = from._scatterSymbol; this._independentSymbolSize = from._independentSymbolSize; this._symbolSize = from._symbolSize; this._independentColor = from._independentColor; this._color = from._color; this._overrideFrame = from._overrideFrame; this._overriddenFrame = from._overriddenFrame; this._overrideInset = from._overrideInset; this._overriddenInset = from._overriddenInset; this._overrideStructureWidthOffset = from._overrideStructureWidthOffset; this._overrideStructureWidthFactor = from._overrideStructureWidthFactor; this._overridePlotColorInfluence = from._overridePlotColorInfluence; this._overrideFillColor = from._overrideFillColor; this._overrideFrameColor = from._overrideFrameColor; this._overrideInsetColor = from._overrideInsetColor; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(eventFiring); } }
public ScatterPlotStyle(IScatterSymbol symbol, double size, double penWidth, NamedColor penColor) { if (null == symbol) throw new ArgumentNullException(nameof(symbol)); _symbolShape = symbol; _material = new MaterialWithUniformColor(penColor); _symbolSize = size; _skipFreq = 1; _independentSkipFreq = false; // Cached values SetCachedValues(); }
private void PaintOneRange( Graphics g, IPlotArea layer, PointF[] plotPositions, IPlotRange range, IScatterSymbol scatterSymbol, ref CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { var ptArray = plotPositions; float xpos = 0, ypos = 0; float xdiff, ydiff; int originalIndex; // save the graphics stat since we have to translate the origin System.Drawing.Drawing2D.GraphicsState gs = g.Save(); if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size { // calculate the path only once CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } // end for } else // using a variable symbol size or variable symbol color { CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { originalIndex = range.GetOriginalRowIndexFromPlotPointIndex(plotPointIndex); if (null == _cachedColorForIndexFunction) { double customSymbolSize = _cachedSymbolSizeForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); } else { double customSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalIndex); var customSymbolColor = _cachedColorForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B), cachedPathData, ref cachedBrushData); } xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } g.Restore(gs); // Restore the graphics state }
/// <summary> /// Calculates the brushes. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="plotColor">The current plot color.</param> /// <param name="cachedPathData">The cached path data.</param> /// <param name="cachedBrushData">Cached brush data, which will be filled-in during this call..</param> /// <returns>True if new cached brush data were calculated; false if the cached data were up-to-date.</returns> private bool CalculateBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { if (plotColor == cachedBrushData.PlotColor) return false; // cached data valid and could be reused; cachedBrushData.Clear(); cachedBrushData.PlotColor = plotColor; var plotColorInfluence = _overridePlotColorInfluence ?? scatterSymbol.PlotColorInfluence; if (null != cachedPathData.InsetPath) { var insetColor = _overrideInsetColor ?? scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) insetColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); cachedBrushData.InsetBrush = new SolidBrush(insetColor); } if (null != cachedPathData.FillPath) { var fillColor = _overrideFillColor ?? scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) fillColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); cachedBrushData.FillBrush = new SolidBrush(fillColor); } if (null != cachedPathData.FramePath) { var frameColor = _overrideFrameColor ?? scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) frameColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); cachedBrushData.FrameBrush = new SolidBrush(frameColor); } return true; }
/// <summary> /// Calculates the paths and stores them into a structure given by the argument <paramref name="cachedPathData"/>. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="symbolSize">The size of the symbol for which to calculate the paths.</param> /// <param name="cachedPathData">The cached path data.</param> /// <returns>True if new paths have been calculated; false if the previously cached data could be used.</returns> private bool CalculatePaths(IScatterSymbol scatterSymbol, double symbolSize, ref CachedPathData cachedPathData) { if (symbolSize == cachedPathData.SymbolSize) return false; // we assume that the structure already contains valid data. cachedPathData.SymbolSize = symbolSize; cachedPathData.FillPath = cachedPathData.FramePath = cachedPathData.InsetPath = null; if (scatterSymbol is NoSymbol) { return true; } List<List<ClipperLib.IntPoint>> insetPolygon = null; List<List<ClipperLib.IntPoint>> framePolygon = null; List<List<ClipperLib.IntPoint>> fillPolygon = null; double? overrideRelativeStructureWidth = null; if (_overrideStructureWidthOffset.HasValue || _overrideStructureWidthFactor.HasValue) { overrideRelativeStructureWidth = (_overrideStructureWidthFactor ?? 0) + (_overrideStructureWidthOffset ?? 0) / symbolSize; } scatterSymbol.CalculatePolygons(overrideRelativeStructureWidth, out framePolygon, out insetPolygon, out fillPolygon); // calculate the path only once if (null != insetPolygon) { cachedPathData.InsetPath = new GraphicsPath(); foreach (var list in insetPolygon) cachedPathData.InsetPath.AddPolygon(ToPointFArray(list, symbolSize)); } if (null != fillPolygon) { cachedPathData.FillPath = new GraphicsPath(); foreach (var list in fillPolygon) cachedPathData.FillPath.AddPolygon(ToPointFArray(list, symbolSize)); } if (null != framePolygon) { cachedPathData.FramePath = new GraphicsPath(); foreach (var list in framePolygon) cachedPathData.FramePath.AddPolygon(ToPointFArray(list, symbolSize)); } return true; }
public ScatterSymbolGroupStyle() { _listOfValues = ScatterSymbolListManager.Instance.BuiltinDefault; _value = _listOfValues[0]; }
public ScatterSymbolGroupStyle(ScatterSymbolGroupStyle from) { this._isStepEnabled = from._isStepEnabled; this._value = from._value; this._listOfValues = from._listOfValues; }
private void GetBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, PathGeometry fillPath, PathGeometry framePath, PathGeometry insetPath, out Brush fillBrush, out Brush frameBrush, out Brush insetBrush) { fillBrush = frameBrush = insetBrush = null; var plotColorInfluence = scatterSymbol.PlotColorInfluence; if (null != insetPath) { var insetColor = scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) insetColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); insetBrush = new SolidColorBrush(GuiHelper.ToWpf(insetColor)); } if (null != fillPath) { var fillColor = scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) fillColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); fillBrush = new SolidColorBrush(GuiHelper.ToWpf(fillColor)); } if (null != framePath) { var frameColor = scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) frameColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); frameBrush = new SolidColorBrush(GuiHelper.ToWpf(frameColor)); } }
public ScatterSymbolGroupStyle(ScatterSymbolGroupStyle from) { _isStepEnabled = from._isStepEnabled; _value = from._value; _listOfValues = from._listOfValues; }
private void PaintOneRange( Graphics g, IPlotArea layer, PointF[] plotPositions, IPlotRange range, IScatterSymbol scatterSymbol, ref CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { var ptArray = plotPositions; float xpos = 0, ypos = 0; float xdiff, ydiff; int originalIndex; // save the graphics stat since we have to translate the origin System.Drawing.Drawing2D.GraphicsState gs = g.Save(); if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size { // calculate the path only once CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) { g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); } if (null != cachedPathData.FillPath) { g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); } if (null != cachedPathData.FramePath) { g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } // end for } else // using a variable symbol size or variable symbol color { CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { originalIndex = range.GetOriginalRowIndexFromPlotPointIndex(plotPointIndex); if (null == _cachedColorForIndexFunction) { double customSymbolSize = _cachedSymbolSizeForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); } else { double customSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalIndex); var customSymbolColor = _cachedColorForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B), cachedPathData, ref cachedBrushData); } xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) { g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); } if (null != cachedPathData.FillPath) { g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); } if (null != cachedPathData.FramePath) { g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } } g.Restore(gs); // Restore the graphics state }
public void TransferFrom(IPlotGroupStyle fromb) { ScatterSymbolGroupStyle from = (ScatterSymbolGroupStyle)fromb; this._value = from._value; this._listOfValues = from._listOfValues; }
public void CopyFrom(ScatterPlotStyle from, Main.EventFiring eventFiring) { if (object.ReferenceEquals(this, from)) return; using (var suspendToken = SuspendGetToken()) { this._independentSkipFreq = from._independentSkipFreq; this._skipFreq = from._skipFreq; this._symbolShape = from._symbolShape; // immutable this._independentSymbolSize = from._independentSymbolSize; this._symbolSize = from._symbolSize; this._material = from._material; // immutable this._independentColor = from._independentColor; EhSelfChanged(EventArgs.Empty); suspendToken.Resume(eventFiring); } }
internal ScatterPlotStyle(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, bool oldDeserializationRequiresFullConstruction) { double symbolSize = 8; var color = ColorSetManager.Instance.BuiltinDarkPlotColors[0]; this._scatterSymbol = ScatterSymbolListManager.Instance.BuiltinDefault[0]; this._color = NamedColors.Black; this._independentColor = false; this._symbolSize = symbolSize; this._skipFreq = 1; }