From c64bcbffbde466cdb520de4fa8835a2e02d3325c Mon Sep 17 00:00:00 2001 From: LucyMu Date: Thu, 22 Nov 2018 20:55:17 +0300 Subject: [PATCH 1/4] svg dashed border fixed --- .../AnnotationPlane/Columns/VisualColumnView.xaml.cs | 4 ++-- Application/Reports/SVG/VisualColumnPainter.cs | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs index 65f185a..7cabfbd 100644 --- a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs +++ b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs @@ -137,10 +137,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn case Template.BottomSideFormEnum.NotDefined: case Template.BottomSideFormEnum.Straight: case Template.BottomSideFormEnum.Wave: - strokeArr = new DoubleCollection() { 3, 0 }; + strokeArr = new DoubleCollection() { 5, 0 }; break; case Template.BottomSideFormEnum.Dotted: - strokeArr = new DoubleCollection() { 3, 3 }; + strokeArr = new DoubleCollection() { 5, 5 }; break; default: break; diff --git a/Application/Reports/SVG/VisualColumnPainter.cs b/Application/Reports/SVG/VisualColumnPainter.cs index 53c8837..9f78772 100644 --- a/Application/Reports/SVG/VisualColumnPainter.cs +++ b/Application/Reports/SVG/VisualColumnPainter.cs @@ -31,13 +31,10 @@ private static void AddPointToCollection(SvgPointCollection points, Point point) public override RenderedSvg RenderColumn() { - var result = base.RenderColumn(); - + var result = base.RenderColumn(); SvgGroup group = new SvgGroup(); - VisualLayerPresentingVM[] layers = vm.Layers.ToArray(); - - + VisualLayerPresentingVM[] layers = vm.Layers.ToArray(); for (int i = 0; i < layers.Length; i++) { @@ -88,8 +85,9 @@ public override RenderedSvg RenderColumn() { if (lvm.BottomSideClass.CurrentClass.BottomSideForm == AnnotationPlane.Template.BottomSideFormEnum.Dotted) { - bottomEdge.StrokeDashArray = new List() { 3, 3 }. - Select(p => new SvgUnit(p)) as SvgUnitCollection; + var dashedCollection = new SvgUnitCollection(); + dashedCollection.AddRange(new[] { new SvgUnit(SvgUnitType.User, 5), new SvgUnit(SvgUnitType.User, 5) }); + bottomEdge.StrokeDashArray = dashedCollection; } } From b18c6bf423bc7baa3550ee5f1986978c68dd7ff1 Mon Sep 17 00:00:00 2001 From: LucyMu Date: Fri, 23 Nov 2018 15:25:35 +0300 Subject: [PATCH 2/4] lower boundary => interlayer boundary; svg layer fix --- .../AnnotationPlane/Columns/VisualColumnView.xaml | 6 +++--- .../AnnotationPlane/Columns/VisualColumnView.xaml.cs | 10 ++++++---- Application/Reports/SVG/LayeredColumnPainter.cs | 5 +++-- Application/Reports/SVG/VisualColumnPainter.cs | 9 ++++++++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Application/AnnotationPlane/Columns/VisualColumnView.xaml b/Application/AnnotationPlane/Columns/VisualColumnView.xaml index 22d233d..aa7f8e1 100644 --- a/Application/AnnotationPlane/Columns/VisualColumnView.xaml +++ b/Application/AnnotationPlane/Columns/VisualColumnView.xaml @@ -43,13 +43,13 @@ + - - + - + diff --git a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs index 7cabfbd..01c3c4f 100644 --- a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs +++ b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs @@ -113,11 +113,13 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur { if (values.Length != 3) return null; - double width = (double)values[0]; - double height = (double)values[1]; - Template.BottomSideFormEnum bottomSideForm = (Template.BottomSideFormEnum)values[2]; + if (values[0] == DependencyProperty.UnsetValue) return new PointCollection(); + Template.BottomSideFormEnum bottomSideForm = (Template.BottomSideFormEnum)values[0]; ISideCurveGenerator bottomSideGenerator = SideCurveGeneratorFactory.GetGeneratorFor(bottomSideForm); - return new PointCollection(Drawing.GetBottomPolyline(width, height, bottomSideGenerator)); + double currentWidth = (double)values[1]; + double previousWidth = (double)values[2]; + double polylineWidth = (currentWidth > previousWidth) ? currentWidth : previousWidth; + return new PointCollection(Drawing.GetBottomPolyline(polylineWidth, 0.0, bottomSideGenerator)); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) diff --git a/Application/Reports/SVG/LayeredColumnPainter.cs b/Application/Reports/SVG/LayeredColumnPainter.cs index 5f72b35..ba1a7ee 100644 --- a/Application/Reports/SVG/LayeredColumnPainter.cs +++ b/Application/Reports/SVG/LayeredColumnPainter.cs @@ -37,10 +37,10 @@ public override RenderedSvg RenderColumn() LayerVM[] layers = columnVm.Layers.ToArray(); double boundary = 0.0; for (int i = 0; i < layers.Length; i++) - { + { LayerVM lVM = layers[i]; + boundary += lVM.Length; if (i < layers.Length - 1) { - boundary += lVM.Length; SvgLine line = new SvgLine(); line.Stroke = blackPaint; line.StartX = Helpers.dtos(0.0); @@ -49,6 +49,7 @@ public override RenderedSvg RenderColumn() line.EndY = Helpers.dtos(boundary); group.Children.Add(line); } + // drawing layer itself var layerSvg = layerPainter.Paint(layers[i], width, lVM.Length); layerSvg.Transforms.Add(new Svg.Transforms.SvgTranslate(0.0f, (float)(boundary - lVM.Length))); group.Children.Add(layerSvg); diff --git a/Application/Reports/SVG/VisualColumnPainter.cs b/Application/Reports/SVG/VisualColumnPainter.cs index 9f78772..fd33856 100644 --- a/Application/Reports/SVG/VisualColumnPainter.cs +++ b/Application/Reports/SVG/VisualColumnPainter.cs @@ -91,7 +91,14 @@ public override RenderedSvg RenderColumn() } } - var bottomPoints = Drawing.GetBottomPolyline(lvm.Width, lvm.Height, bottomSideCurveGenerator).ToArray(); + double polylineWidth = lvm.Width; + if (i < layers.Length - 1) + { + VisualLayerPresentingVM nlvm = layers[i + 1]; + polylineWidth = nlvm.Width > polylineWidth ? polylineWidth = nlvm.Width : polylineWidth; + } + + var bottomPoints = Drawing.GetBottomPolyline(polylineWidth, lvm.Height, bottomSideCurveGenerator).ToArray(); SvgPointCollection svgBottomPoints = new SvgPointCollection(); for (int j = 0; j < bottomPoints.Length; j++) From 0699e0fef6dd6e15038c66211feb6551fa90a6a3 Mon Sep 17 00:00:00 2001 From: LucyMu Date: Fri, 23 Nov 2018 21:24:51 +0300 Subject: [PATCH 3/4] changed lower&right boundaries connection --- .../AnnotationPlane/Columns/Drawing.cs | 37 ++++++++++++++--- .../Columns/VisualColumnView.xaml.cs | 41 ++++++++++++++----- .../Reports/SVG/VisualColumnPainter.cs | 31 +++++++++++--- 3 files changed, 86 insertions(+), 23 deletions(-) diff --git a/Application/AnnotationPlane/Columns/Drawing.cs b/Application/AnnotationPlane/Columns/Drawing.cs index a7d29cc..aeb2f94 100644 --- a/Application/AnnotationPlane/Columns/Drawing.cs +++ b/Application/AnnotationPlane/Columns/Drawing.cs @@ -20,12 +20,12 @@ public static IEnumerable GetRightPolyline(double width, double height, I return result; } - public static IEnumerable GetBottomPolyline(double width, double height, ISideCurveGenerator bottomSideCurve) + public static IEnumerable GetBottomPolyline(double xOffset, double width, double height, ISideCurveGenerator bottomSideCurve) { List result = new List(); IEnumerable bottomSidePoints = bottomSideCurve.GenerateSide(width). - Select(p => new Point(p.X, p.Y + height)); // parallel shift, so that (0.0;0.0);(width;0.0) is shifted to (0.0;height);(width;height) + Select(p => new Point(p.X + xOffset, p.Y + height)); // parallel shift, so that (0.0;0.0);(width;0.0) is shifted to (0.0;height);(width;height) result.AddRange(bottomSidePoints); @@ -78,24 +78,29 @@ public interface IOscillationGenerator IEnumerable GeneratePeriod(double xPeriod, double signalMaxY); } + public enum OscillationAlignment { Left, Center, Right } + /// /// Generates a side curve by repeating integer repeating periods provided by oscillationGenerator /// public class OscillatingSignalCurveGenerator : ISideCurveGenerator { private double xPeriod, signalMaxY; + private OscillationAlignment alignment; IOscillationGenerator generator; /// The period of the pattern allong X axis - /// the avsolute hight of the pattern along Y axis + /// the absolute hight of the pattern along Y axis /// Which signal to generate - public OscillatingSignalCurveGenerator(double xPeriod, double signalMaxY, IOscillationGenerator generator) + /// Where the straight part will be / where to stick the signal curve + public OscillatingSignalCurveGenerator(double xPeriod, double signalMaxY, IOscillationGenerator generator, OscillationAlignment alignment) { if (signalMaxY < 0) throw new ArgumentException("signalMaxY must be non-negative"); this.xPeriod = xPeriod; this.signalMaxY = signalMaxY; this.generator = generator; + this.alignment = alignment; } public IEnumerable GenerateSide(double length) @@ -104,15 +109,35 @@ public IEnumerable GenerateSide(double length) double straitEndsLength = length - periods * xPeriod; List result = new List(); + + double leftOffset = 0.0; + double rightOffset = 0.0; + switch (alignment) + { + case OscillationAlignment.Center: + leftOffset = straitEndsLength / 2; + rightOffset = straitEndsLength / 2; + break; + case OscillationAlignment.Left: + leftOffset = 0.0; + rightOffset = straitEndsLength; + break; + case OscillationAlignment.Right: + leftOffset = straitEndsLength; + rightOffset = 0.0; + break; + } + + //starting straight line result.Add(new Point(0.0, 0.0)); - result.Add(new Point(straitEndsLength * 0.5, 0.0)); + result.Add(new Point(leftOffset, 0.0)); //drawing curves double miniStep = xPeriod * 0.5; for (int i = 0; i < periods; i++) { - double xOffset = straitEndsLength * 0.5 + i * xPeriod; + double xOffset = leftOffset + i * xPeriod; IEnumerable periodPoints = generator.GeneratePeriod(xPeriod, signalMaxY).Select(p => new Point(p.X + xOffset, p.Y)); result.AddRange(periodPoints); diff --git a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs index 01c3c4f..31fef39 100644 --- a/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs +++ b/Application/AnnotationPlane/Columns/VisualColumnView.xaml.cs @@ -38,30 +38,41 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste public static class SideCurveGeneratorFactory { private static ISideCurveGenerator straight = new StraightSideCurveGenerator(); - private static ISideCurveGenerator steps = new OscillatingSignalCurveGenerator(20, 3, new StepOscillationGenerator()); - private static ISideCurveGenerator wave = new OscillatingSignalCurveGenerator(20, 3, new SinOscillationGenerator(11)); - private static ISideCurveGenerator zigzag = new OscillatingSignalCurveGenerator(20, 3, new ZigZagOscillationGenerator()); + private static ISideCurveGenerator stepsVertical = new OscillatingSignalCurveGenerator(20, 3, new StepOscillationGenerator(), OscillationAlignment.Center); + private static ISideCurveGenerator waveVertical = new OscillatingSignalCurveGenerator(20, 3, new SinOscillationGenerator(11), OscillationAlignment.Center); + private static ISideCurveGenerator zigzagVertical = new OscillatingSignalCurveGenerator(20, 3, new ZigZagOscillationGenerator(), OscillationAlignment.Center); + private static ISideCurveGenerator waveHorizontalLeft = new OscillatingSignalCurveGenerator(20, 3, new SinOscillationGenerator(11), OscillationAlignment.Left); + private static ISideCurveGenerator waveHorizontalRight = new OscillatingSignalCurveGenerator(20, 3, new SinOscillationGenerator(11), OscillationAlignment.Right); + private static ISideCurveGenerator waveHorizontalCenter = new OscillatingSignalCurveGenerator(20, 3, new SinOscillationGenerator(11), OscillationAlignment.Center); public static ISideCurveGenerator GetGeneratorFor(Template.RightSideFormEnum rightSideForm) { switch (rightSideForm) { case Template.RightSideFormEnum.NotDefined: return straight; case Template.RightSideFormEnum.Straight: return straight; - case Template.RightSideFormEnum.Steps: return steps; - case Template.RightSideFormEnum.Wave: return wave; - case Template.RightSideFormEnum.ZigZag: return zigzag; + case Template.RightSideFormEnum.Steps: return stepsVertical; + case Template.RightSideFormEnum.Wave: return waveVertical; + case Template.RightSideFormEnum.ZigZag: return zigzagVertical; default: throw new NotSupportedException("Unknown right side form"); } } - public static ISideCurveGenerator GetGeneratorFor(Template.BottomSideFormEnum bottomSideForm) + public static ISideCurveGenerator GetGeneratorFor(Template.BottomSideFormEnum bottomSideForm, OscillationAlignment alignment) { switch (bottomSideForm) { case Template.BottomSideFormEnum.NotDefined: return straight; case Template.BottomSideFormEnum.Straight: return straight; - case Template.BottomSideFormEnum.Wave: return wave; + case Template.BottomSideFormEnum.Wave: + switch (alignment) + { + case OscillationAlignment.Left: return waveHorizontalLeft; + case OscillationAlignment.Right: return waveHorizontalRight; + case OscillationAlignment.Center: return waveHorizontalCenter; + default: + throw new NotSupportedException("Unknown wave alignment"); + } case Template.BottomSideFormEnum.Dotted: return straight; default: throw new NotSupportedException("Unknown bottom side form"); @@ -115,11 +126,19 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur return null; if (values[0] == DependencyProperty.UnsetValue) return new PointCollection(); Template.BottomSideFormEnum bottomSideForm = (Template.BottomSideFormEnum)values[0]; - ISideCurveGenerator bottomSideGenerator = SideCurveGeneratorFactory.GetGeneratorFor(bottomSideForm); + ISideCurveGenerator bottomRightAlignedSideGenerator = SideCurveGeneratorFactory.GetGeneratorFor(bottomSideForm, OscillationAlignment.Right); + ISideCurveGenerator bottomLeftAlignedSideGenerator = SideCurveGeneratorFactory.GetGeneratorFor(bottomSideForm, OscillationAlignment.Left); double currentWidth = (double)values[1]; double previousWidth = (double)values[2]; - double polylineWidth = (currentWidth > previousWidth) ? currentWidth : previousWidth; - return new PointCollection(Drawing.GetBottomPolyline(polylineWidth, 0.0, bottomSideGenerator)); + // splitting the layer boundary into two fragments + // getting the minimum length between the two layers + double minCrepWidth = (currentWidth < previousWidth) ? currentWidth : previousWidth; + // getting the difference between the lengths + double crepWidthDiff = (currentWidth > previousWidth) ? currentWidth - minCrepWidth : previousWidth - minCrepWidth; + var bottomBoundaryRightAlign = Drawing.GetBottomPolyline(0.0, minCrepWidth, 0.0, bottomRightAlignedSideGenerator); + var bottomBoundaryLeftAlign = Drawing.GetBottomPolyline(minCrepWidth, crepWidthDiff, 0.0, bottomLeftAlignedSideGenerator); + var bottomBoundary = new PointCollection(bottomBoundaryRightAlign.Concat(bottomBoundaryLeftAlign)); + return bottomBoundary; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) diff --git a/Application/Reports/SVG/VisualColumnPainter.cs b/Application/Reports/SVG/VisualColumnPainter.cs index fd33856..a703c51 100644 --- a/Application/Reports/SVG/VisualColumnPainter.cs +++ b/Application/Reports/SVG/VisualColumnPainter.cs @@ -69,11 +69,18 @@ public override RenderedSvg RenderColumn() levelGroup.Children.Add(rightEdge); - ISideCurveGenerator bottomSideCurveGenerator = null; + ISideCurveGenerator bottomSideLeftAlignedCurveGenerator = null; + ISideCurveGenerator bottomSideRightAlignedCurveGenerator = null; if ((lvm.BottomSideClass != null) && (lvm.BottomSideClass.CurrentClass != null)) - bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.BottomSideClass.CurrentClass.BottomSideForm); + { + bottomSideLeftAlignedCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.BottomSideClass.CurrentClass.BottomSideForm, OscillationAlignment.Left); + bottomSideRightAlignedCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(lvm.BottomSideClass.CurrentClass.BottomSideForm, OscillationAlignment.Right); + } else - bottomSideCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.BottomSideFormEnum.NotDefined); + { + bottomSideLeftAlignedCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.BottomSideFormEnum.NotDefined, OscillationAlignment.Left); + bottomSideRightAlignedCurveGenerator = SideCurveGeneratorFactory.GetGeneratorFor(AnnotationPlane.Template.BottomSideFormEnum.NotDefined, OscillationAlignment.Right); + } SvgPolyline bottomEdge = new SvgPolyline { @@ -91,14 +98,26 @@ public override RenderedSvg RenderColumn() } } - double polylineWidth = lvm.Width; + double currentWidth = lvm.Width; + double minCrepWidth = currentWidth; + double crepWidthDiff = 0.0; if (i < layers.Length - 1) { VisualLayerPresentingVM nlvm = layers[i + 1]; - polylineWidth = nlvm.Width > polylineWidth ? polylineWidth = nlvm.Width : polylineWidth; + + // splitting the layer boundary into two fragments + // getting the minimum length between the two layers + minCrepWidth = (currentWidth < nlvm.Width) ? currentWidth : nlvm.Width; + // getting the difference between the lengths + crepWidthDiff = (currentWidth > nlvm.Width) ? currentWidth - minCrepWidth : nlvm.Width - minCrepWidth; } - var bottomPoints = Drawing.GetBottomPolyline(polylineWidth, lvm.Height, bottomSideCurveGenerator).ToArray(); + var bottomPointsRightAligned = Drawing.GetBottomPolyline(0.0, minCrepWidth, lvm.Height, bottomSideRightAlignedCurveGenerator).ToArray(); + var bottomPointsLeftAligned = Drawing.GetBottomPolyline(minCrepWidth, crepWidthDiff, lvm.Height, bottomSideLeftAlignedCurveGenerator).ToArray(); + + var bottomPoints = new Point[bottomPointsRightAligned.Length + bottomPointsLeftAligned.Length]; + bottomPointsRightAligned.CopyTo(bottomPoints, 0); + bottomPointsLeftAligned.CopyTo(bottomPoints, bottomPointsRightAligned.Length); SvgPointCollection svgBottomPoints = new SvgPointCollection(); for (int j = 0; j < bottomPoints.Length; j++) From 310bb4bf193f35e5eab20cc80bebb756df70684b Mon Sep 17 00:00:00 2001 From: LucyMu Date: Wed, 5 Dec 2018 17:43:11 +0300 Subject: [PATCH 4/4] 2-rows layout for crep property; enabled scrollviewer by touch on properties list --- .../ColumnSettings/ColumnDefinitionView.xaml | 13 ++-- .../ColumnSettings/ColumnSettingsView.xaml | 46 +++++++----- .../VisualColumnDefinitionView.xaml | 73 ++++++++++--------- Application/Intervals/BoreIntervalsView.xaml | 2 +- 4 files changed, 73 insertions(+), 61 deletions(-) diff --git a/Application/AnnotationPlane/ColumnSettings/ColumnDefinitionView.xaml b/Application/AnnotationPlane/ColumnSettings/ColumnDefinitionView.xaml index 51902ac..87fc38f 100644 --- a/Application/AnnotationPlane/ColumnSettings/ColumnDefinitionView.xaml +++ b/Application/AnnotationPlane/ColumnSettings/ColumnDefinitionView.xaml @@ -37,10 +37,10 @@ - - - - + + + + - - diff --git a/Application/AnnotationPlane/ColumnSettings/ColumnSettingsView.xaml b/Application/AnnotationPlane/ColumnSettings/ColumnSettingsView.xaml index 5510655..2756334 100644 --- a/Application/AnnotationPlane/ColumnSettings/ColumnSettingsView.xaml +++ b/Application/AnnotationPlane/ColumnSettings/ColumnSettingsView.xaml @@ -12,17 +12,32 @@ - - - - - - - - - - - Добавить колонку: + + + + + + + + + + + + + + + + + + @@ -34,14 +49,7 @@ - - - - -