From a8534f6c2b57cdd139902760f5fe3334cc1bd5ff Mon Sep 17 00:00:00 2001 From: Sven Date: Thu, 25 Jan 2024 19:06:40 +0100 Subject: [PATCH] Version 1.7.1.1.a --- .../MachineControl/GCode2DViewpaths.cs | 3 ++- GRBL-Plotter/MachineControl/GCodeAnalyze.cs | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/GRBL-Plotter/MachineControl/GCode2DViewpaths.cs b/GRBL-Plotter/MachineControl/GCode2DViewpaths.cs index 9986f582..c80f2305 100644 --- a/GRBL-Plotter/MachineControl/GCode2DViewpaths.cs +++ b/GRBL-Plotter/MachineControl/GCode2DViewpaths.cs @@ -31,6 +31,7 @@ Fill GraphicPaths * 2023-09-01 new l:700 f:SetRulerDimension / l:380 f:DrawMachineLimit update grid * 2023-09-14 l:400 f:DrawMachineLimit() add toolTableOffsetX to show tool positions; issue #361 * 2024-01-13 l:675 f:CreateMarkerArrow add try/catch + * 2024-01-25 l:262 f:CreateDrawingPathFromGCode get markerSize from graphics dimension */ using System; @@ -258,7 +259,7 @@ private static bool CreateDrawingPathFromGCode(GcodeByLine newL, GcodeByLine old // mark Z-only movements - could be drills if ((onlyZ > 1) && (passLimit) && (path == pathPenUp) || (oldL.codeLine.Contains("DOT"))) // pen moved from -z to +z { - float markerSize = 1; + float markerSize = (float)markerSizeGraphic; int markerType = 1; if (!Properties.Settings.Default.importUnitmm || (modal.unitsMode == 20)) { markerSize /= 25.4F; } diff --git a/GRBL-Plotter/MachineControl/GCodeAnalyze.cs b/GRBL-Plotter/MachineControl/GCodeAnalyze.cs index 797b84da..c118ce12 100644 --- a/GRBL-Plotter/MachineControl/GCodeAnalyze.cs +++ b/GRBL-Plotter/MachineControl/GCodeAnalyze.cs @@ -1,7 +1,7 @@ /* GRBL-Plotter. Another GCode sender for GRBL. This file is part of the GRBL-Plotter application. - Copyright (C) 2015-2023 Sven Hasemann contact: svenhb@web.de + Copyright (C) 2015-2024 Sven Hasemann contact: svenhb@web.de This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ You should have received a copy of the GNU General Public License * 2023-11-15 l:579 f:GetGCodeLines add pathObjectPenColorOnlyNone = false; show default color, if all imported colors = none * 2023-11-29 l:510 f:GetGCodeLines add findSubroutineFailCounter; abort searching for subroutine if not found after 10 times * 2023-12-16 l:850 f:ProcessXmlTagStart check for fiducials via .ToUpper().Contains(fiducialLabel.ToUpper())) + * 2024-01-25 add graphicDimension, markerSizeGraphic to adapt size of point markers */ using System; @@ -186,6 +187,9 @@ public static bool CodeBlocksAvailable() internal static XyPoint clipOffset = new XyPoint(-1, -1); private static bool isHeaderSection = false; + internal static XyPoint graphicDimension = new XyPoint(-1, -1); + internal static float markerSizeGraphic = 1; + internal static bool largeDataAmount = false; internal static int numberDataLines = 0; @@ -286,6 +290,8 @@ private static void ResetGlobalObjects() clipDimension = new XyPoint(); clipOffset = new XyPoint(); isHeaderSection = false; + graphicDimension = new XyPoint(); + markerSizeGraphic = 1; modal = new ModalGroup(); // clear XmlMarker.Reset(); // reset lists, holding marker line numbers @@ -528,6 +534,17 @@ public static bool GetGCodeLines(IList oldCode, BackgroundWorker worker, if (isHeaderSection) { + if (singleLine.Contains("DIMENSION XY") && singleLine.Contains(":")) // GraphicCollectData.cs line 1100 + { + var tmpLine = singleLine.Split(':'); + var tmpVals = tmpLine[1].Trim().Split(' '); + if (double.TryParse(tmpVals[0], System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out double parsed1)) + { graphicDimension.X = parsed1; } + if (double.TryParse(tmpVals[1], System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out double parsed2)) + { graphicDimension.Y = parsed2; } + markerSizeGraphic = (float)Math.Max(Math.Sqrt(graphicDimension.X * graphicDimension.X + graphicDimension.Y * graphicDimension.Y) / 200f, 0.5); + Logger.Trace("----- graphicDimension '{0}' -> {1:0.00} {2:0.00} marker size:{3:0.0}", singleLine, graphicDimension.X, graphicDimension.Y, markerSizeGraphic); + } if (singleLine.Contains("SVG DIMENSION") && singleLine.Contains(":")) { var tmpLine = singleLine.Split(':'); @@ -536,7 +553,7 @@ public static bool GetGCodeLines(IList oldCode, BackgroundWorker worker, { clipDimension.X = parsed1; } if (double.TryParse(tmpVals[1], System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out double parsed2)) { clipDimension.Y = parsed2; } - Logger.Trace("----- clipDimension {0} -> {1:0.00} {2:0.00}", singleLine, clipDimension.X, clipDimension.Y); + Logger.Trace("----- clipDimension '{0}' -> {1:0.00} {2:0.00}", singleLine, clipDimension.X, clipDimension.Y); } else if (singleLine.Contains("GRAPHIC OFFSET") && singleLine.Contains(":")) { @@ -557,7 +574,7 @@ public static bool GetGCodeLines(IList oldCode, BackgroundWorker worker, } // finish reading lines /*********************************************************************/ - if (!largeDataAmount && (figureMarkerCount > 1) && (showArrow || showId)) + if (!largeDataAmount && (figureMarkerCount > 0) && (showArrow || showId)) { ModifyPenUpPath(worker, e, ref progressSubOld, progressMainFactor, showArrow, showId); }