private SvgPath CreateSvgSpline(SvgElement owner, LayoutPolyLine line, LineExportConfig lineConfig) { var path = new SvgPath() { StrokeWidth = GetLineThickness(lineConfig), Stroke = new SvgColourServer(lineConfig.Color), Fill = SvgPaintServer.None }; if (lineConfig.IsDashed) path.StrokeDashArray = LineDashPattern; path.PathData.Add(new SvgMoveToSegment(GetRelativePosition(line.Spline.Curves[0].StartPoint))); for (int i = 0; i < line.Spline.Curves.Length; i++) { var curve = line.Spline.Curves[i]; path.PathData.Add(new SvgCubicCurveSegment( GetRelativePosition(curve.StartPoint), GetRelativePosition(curve.ControlPoints[0]), GetRelativePosition(curve.ControlPoints[1]), GetRelativePosition(curve.EndPoint) ) ); } if (owner != null) owner.Children.Add(path); return path; }
private LwPolyline AddDxfPolyLine(string layerName, LayoutPolyLine line, LineExportConfig lineConfig) { var splinePoints = new List <Vector2>(); foreach (var pt in line.Points) { splinePoints.Add(PointToVector(pt)); } var polyLine = new LwPolyline(splinePoints) { Layer = GetLayer(layerName), Color = GetColor(lineConfig.Color), }; //foreach (var vec in splinePoints) // polyLine.Vertexes.Add(new LwPolylineVertex(vec)); if (lineConfig.IsDashed) { polyLine.Linetype = Linetype.Dashed; } Document.AddEntity(polyLine); return(polyLine); }
private SvgPath CreateSvgPolyLine(SvgElement owner, LayoutPolyLine line, LineExportConfig lineConfig) { var path = new SvgPath() { StrokeWidth = GetLineThickness(lineConfig), Stroke = new SvgColourServer(lineConfig.Color), Fill = SvgPaintServer.None }; if (lineConfig.IsDashed) path.StrokeDashArray = LineDashPattern; path.PathData.Add(new SvgMoveToSegment(GetRelativePosition(line.Points[0]))); for (int i = 0; i < line.Points.Count - 1; i++) { path.PathData.Add(new SvgLineSegment( GetRelativePosition(line.Points[i]), GetRelativePosition(line.Points[i + 1]) ) ); } if (owner != null) owner.Children.Add(path); return path; }
private SvgLine CreateSvgLine(SvgElement owner, LayoutLine line, LineExportConfig lineConfig) { return CreateSvgLine(owner, line.P1, line.P2, GetLineThickness(lineConfig), lineConfig.Color, lineConfig.IsDashed ? LineDashPattern : null); }
private Line AddDxfLine(string layerName, LayoutLine line, LineExportConfig lineConfig) { var dxfLine = new Line(PointToVector(line.P1), PointToVector(line.P2)) { Layer = GetLayer(layerName), Color = GetColor(lineConfig.Color) }; if (lineConfig.IsDashed) { dxfLine.Linetype = Linetype.Dashed; } Document.AddEntity(dxfLine); return(dxfLine); }
private SvgUnit GetLineThickness(LineExportConfig lineExportConfig) { if (lineExportConfig.LineThickness > 0) { switch (lineExportConfig.LineUnit) { case LineUnit.Pixels: return GetRelativeUnit(lineExportConfig.LineThickness, SvgUnitType.Pixel); case LineUnit.Points: return GetRelativeUnit(lineExportConfig.LineThickness, SvgUnitType.Point); case LineUnit.Millimeters: return GetRelativeUnit( new Measure(lineExportConfig.LineThickness, UnitOfMeasure.Mm)); case LineUnit.Inches: return GetRelativeUnit( new Measure(lineExportConfig.LineThickness, UnitOfMeasure.In)); } } return GetRelativeUnit(1, SvgUnitType.Point); }
private Spline AddDxfSpline(string layerName, LayoutPolyLine line, LineExportConfig lineConfig) { var splinePoints = new List <Vector2>(); foreach (var pt in line.Points) { splinePoints.Add(PointToVector(pt)); } var splineLine = new Spline(splinePoints.Select(x => new SplineVertex(x)).ToList()) { Layer = GetLayer(layerName), Color = GetColor(lineConfig.Color) }; if (lineConfig.IsDashed) { splineLine.Linetype = Linetype.Dashed; } Document.AddEntity(splineLine); return(splineLine); }
private void GenerateFrets() { foreach (var fretLine in Layout.VisualElements.OfType <FretLine>()) { if (Options.ExtendFretSlots && !fretLine.IsNut) { var extendedFretLine = fretLine.GetExtendedFretLine(Options.Frets.ExtensionAmount); if (extendedFretLine is LayoutLine line) { line.Tag = fretLine; AddLayoutLine(line, VisualElementType.Fret, Options.Frets); continue; } else if (extendedFretLine is LayoutPolyLine polyline) { polyline.Tag = fretLine; if (polyline.Spline != null) { AddLayoutSpline(polyline, VisualElementType.Fret, Options.Frets); } else { AddLayoutPolyLine(polyline, VisualElementType.Fret, Options.Frets); } continue; } } if (fretLine.IsStraight) { var layoutLine = new LayoutLine(fretLine.Points.First(), fretLine.Points.Last()); layoutLine.Tag = fretLine; AddLayoutLine(layoutLine, VisualElementType.Fret, Options.Frets); } else { fretLine.RebuildSpline(); if (fretLine.Spline != null) { AddLayoutSpline(fretLine, VisualElementType.Fret, Options.Frets); } else { AddLayoutPolyLine(fretLine, VisualElementType.Fret, Options.Frets); } } } if (Options.ExportBridgeLine) { var bridgeLine = Layout.GetElement <LayoutPolyLine>(x => x.ElementType == VisualElementType.BridgeLine); if (bridgeLine != null) { var tmpConfig = new LineExportConfig() { Color = System.Drawing.Color.Black, LineThickness = 1d, LineUnit = LineUnit.Points }; AddLayoutPolyLine(bridgeLine, VisualElementType.BridgeLine, tmpConfig); } } }
protected virtual void AddLayoutSpline(LayoutPolyLine line, VisualElementType elementType, LineExportConfig lineConfig) { }
protected override void AddLayoutSpline(LayoutPolyLine line, VisualElementType elementType, LineExportConfig lineConfig) { switch (elementType) { case VisualElementType.Fret: AddDxfSpline("Frets", line, lineConfig); break; case VisualElementType.FingerboardEdge: case VisualElementType.FingerboardMargin: case VisualElementType.FingerboardContinuation: AddDxfSpline("Fingerboard", line, lineConfig); break; //case VisualElementType.GuideLine: default: AddDxfSpline("Layout", line, lineConfig); break; } }
protected override void AddLayoutLine(LayoutLine line, VisualElementType elementType, LineExportConfig lineConfig) { switch (elementType) { case VisualElementType.Fret: AddDxfLine("Frets", line, lineConfig); break; case VisualElementType.String: AddDxfLine("Strings", line, lineConfig); break; case VisualElementType.FingerboardEdge: case VisualElementType.FingerboardMargin: case VisualElementType.FingerboardContinuation: AddDxfLine("Fingerboard", line, lineConfig); break; case VisualElementType.CenterLine: case VisualElementType.GuideLine: case VisualElementType.StringMidline: AddDxfLine("Layout", line, lineConfig); break; } }
protected override void AddLayoutLine(LayoutLine line, VisualElementType elementType, LineExportConfig lineConfig) { switch (elementType) { case VisualElementType.Fret: { var svgLine = CreateSvgLine(GetLayer("Frets"), line, lineConfig); if (line.Tag is FretLine fretLine) { if (fretLine.IsNut) svgLine.CustomAttributes.Add("Fret", "Nut"); else svgLine.CustomAttributes.Add("Fret", fretLine.FretIndex.ToString()); } break; } case VisualElementType.FingerboardEdge: case VisualElementType.FingerboardMargin: case VisualElementType.FingerboardContinuation: CreateSvgLine(GetLayer("Fingerboard"), line, lineConfig); break; case VisualElementType.CenterLine: case VisualElementType.StringMidline: case VisualElementType.GuideLine: CreateSvgLine(GetLayer("Layout"), line, lineConfig); break; case VisualElementType.String: { var stringInfo = line as StringLine; SvgLine svgLine; if (Options.UseStringGauge && !stringInfo.String.Gauge.IsEmpty) { var lineThickness = GetRelativeUnit(stringInfo.String.Gauge); svgLine = CreateSvgLine(GetLayer("Strings"), line, lineThickness, Options.Strings.Color); } else svgLine = CreateSvgLine(GetLayer("Strings"), line, lineConfig); svgLine.CustomAttributes.Add("Index", stringInfo.Index.ToString()); break; } } }
protected override void AddLayoutSpline(LayoutPolyLine line, VisualElementType elementType, LineExportConfig lineConfig) { switch (elementType) { case VisualElementType.Fret: { var svgSpline = CreateSvgSpline(GetLayer("Frets"), line, lineConfig); FretLine fretLine = (line as FretLine) ?? (line.Tag as FretLine); if (fretLine != null) { if (fretLine.IsNut) svgSpline.CustomAttributes.Add("Fret", "Nut"); else svgSpline.CustomAttributes.Add("Fret", fretLine.FretIndex.ToString()); } break; } case VisualElementType.FingerboardEdge: case VisualElementType.FingerboardMargin: case VisualElementType.FingerboardContinuation: CreateSvgSpline(GetLayer("Fingerboard"), line, lineConfig); break; //case VisualElementType.GuideLine: default: CreateSvgSpline(GetLayer("Layout"), line, lineConfig); break; } }