-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcommitdiff.txt
More file actions
561 lines (530 loc) · 21 KB
/
commitdiff.txt
File metadata and controls
561 lines (530 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
diff --git a/PolyCut.Core/GeoLine.vb b/PolyCut.Core/GeoLine.vb
index c98e9f7..5150aee 100644
--- a/PolyCut.Core/GeoLine.vb
+++ b/PolyCut.Core/GeoLine.vb
@@ -221,7 +221,7 @@ Public Structure GeoLine
End Structure
-Partial Module GeoLineExtensions
+Partial Public Module GeoLineExtensions
<Extension>
Public Function TransformLinesG(lines As IEnumerable(Of GeoLine), transforms As System.Drawing.Drawing2D.Matrix) As IEnumerable(Of GeoLine)
@@ -321,4 +321,59 @@ Partial Module GeoLineExtensions
Return New Point(vec.X, vec.Y)
End Function
+
+
+ ' -------------------------
+ ' Get Bounds
+ ' -------------------------
+ Friend Function ComputeBounds(lines As List(Of GeoLine)) As Rect
+ If lines Is Nothing OrElse lines.Count = 0 Then Return New Rect(0, 0, 0, 0)
+
+ Dim minX = Double.PositiveInfinity
+ Dim minY = Double.PositiveInfinity
+ Dim maxX = Double.NegativeInfinity
+ Dim maxY = Double.NegativeInfinity
+
+ For Each ln In lines
+ Dim x1 = ln.X1, y1 = ln.Y1
+ Dim x2 = ln.X2, y2 = ln.Y2
+
+ minX = Math.Min(minX, Math.Min(x1, x2))
+ minY = Math.Min(minY, Math.Min(y1, y2))
+ maxX = Math.Max(maxX, Math.Max(x1, x2))
+ maxY = Math.Max(maxY, Math.Max(y1, y2))
+ Next
+
+ Return New Rect(minX, minY, maxX - minX, maxY - minY)
+ End Function
+ <Extension>
+ Public Function ComputeBounds(figures As List(Of List(Of GeoLine))) As Rect
+ Dim minX = Double.PositiveInfinity
+ Dim minY = Double.PositiveInfinity
+ Dim maxX = Double.NegativeInfinity
+ Dim maxY = Double.NegativeInfinity
+
+ If figures Is Nothing Then Return Rect.Empty
+
+ For Each fig In figures
+ If fig Is Nothing Then Continue For
+ For Each ln In fig
+ ' start
+ minX = Math.Min(minX, ln.X1)
+ minY = Math.Min(minY, ln.Y1)
+ maxX = Math.Max(maxX, ln.X1)
+ maxY = Math.Max(maxY, ln.Y1)
+
+ ' end
+ minX = Math.Min(minX, ln.X2)
+ minY = Math.Min(minY, ln.Y2)
+ maxX = Math.Max(maxX, ln.X2)
+ maxY = Math.Max(maxY, ln.Y2)
+ Next
+ Next
+
+ If Double.IsInfinity(minX) Then Return Rect.Empty
+ Return New Rect(minX, minY, Math.Max(0, maxX - minX), Math.Max(0, maxY - minY))
+ End Function
+
End Module
\ No newline at end of file
diff --git a/PolyCut.Core/Helpers/GeometryHelpers.vb b/PolyCut.Core/Helpers/GeometryHelpers.vb
index c93a16e..c2c227d 100644
--- a/PolyCut.Core/Helpers/GeometryHelpers.vb
+++ b/PolyCut.Core/Helpers/GeometryHelpers.vb
@@ -3,6 +3,8 @@ Imports System.Windows
Imports System.Windows.Media
Imports System.Windows.Shapes
+Imports MeasurePerformance.IL.Weaver
+
Imports Svg
Imports Svg.Transforms
@@ -12,7 +14,7 @@ Imports Svg.Transforms
Public Module GeometryHelpers
-
+ <MeasurePerformance>
Public Function BuildLinesFromGeometry(geo As PathGeometry, tolerance As Double) As List(Of List(Of GeoLine))
Dim segs As New List(Of List(Of GeoLine))
diff --git a/PolyCut.Core/Processors/Fill/FillGeneratorShared.vb b/PolyCut.Core/Processors/Fill/FillGeneratorShared.vb
index fe56683..ba12624 100644
--- a/PolyCut.Core/Processors/Fill/FillGeneratorShared.vb
+++ b/PolyCut.Core/Processors/Fill/FillGeneratorShared.vb
@@ -223,28 +223,5 @@ Module FillGeneratorShared
End Function
- ' -------------------------
- ' Get Bounds
- ' -------------------------
- Friend Function ComputeBounds(lines As List(Of GeoLine)) As Rect
- If lines Is Nothing OrElse lines.Count = 0 Then Return New Rect(0, 0, 0, 0)
-
- Dim minX = Double.PositiveInfinity
- Dim minY = Double.PositiveInfinity
- Dim maxX = Double.NegativeInfinity
- Dim maxY = Double.NegativeInfinity
-
- For Each ln In lines
- Dim x1 = ln.X1, y1 = ln.Y1
- Dim x2 = ln.X2, y2 = ln.Y2
-
- minX = Math.Min(minX, Math.Min(x1, x2))
- minY = Math.Min(minY, Math.Min(y1, y2))
- maxX = Math.Max(maxX, Math.Max(x1, x2))
- maxY = Math.Max(maxY, Math.Max(y1, y2))
- Next
-
- Return New Rect(minX, minY, maxX - minX, maxY - minY)
- End Function
End Module
diff --git a/PolyCut.RichCanvas/PolyCanvas.vb b/PolyCut.RichCanvas/PolyCanvas.vb
index 0a8c0fd..03d1bb0 100644
--- a/PolyCut.RichCanvas/PolyCanvas.vb
+++ b/PolyCut.RichCanvas/PolyCanvas.vb
@@ -129,6 +129,11 @@ Public Class PolyCanvas : Inherits Controls.Canvas : Implements INotifyPropertyC
' Static wrappers for backwards compatibility
Private Shared _activeInstance As PolyCanvas
+ Public Shared ReadOnly Property ActiveInstance As PolyCanvas
+ Get
+ Return _activeInstance
+ End Get
+ End Property
Public Shared Event SelectionCountChanged As EventHandler
diff --git a/PolyCut/Helpers/Extensions.vb b/PolyCut/Helpers/Extensions.vb
index ca3c8d6..0bc8048 100644
--- a/PolyCut/Helpers/Extensions.vb
+++ b/PolyCut/Helpers/Extensions.vb
@@ -94,17 +94,34 @@ Public Module Extensions
End Function
<Extension()>
- Public Function IsWithinBounds(drawableElement As IDrawable, x As Double, y As Double) As Boolean
-
- Dim renderable = drawableElement.DrawableElement
- Dim cxLeft = Canvas.GetLeft(renderable.Parent)
- Dim cxTop = Canvas.GetTop(renderable.Parent)
- Dim cxWidth = renderable.ActualWidth
- Dim cxHeight = renderable.ActualHeight
- If cxLeft >= 0 AndAlso cxTop >= 0 AndAlso cxWidth + cxLeft < x AndAlso cxHeight + cxTop < y Then
- Return True
- End If
- Return False
+ Public Function IsWithinBounds(drawable As IDrawable, canvasWidth As Double, canvasHeight As Double, mainCanvas As Visual) As Boolean
+ If drawable Is Nothing OrElse mainCanvas Is Nothing Then Return False
+
+ Dim fe = TryCast(drawable.DrawableElement, FrameworkElement)
+ If fe Is Nothing Then Return False
+
+ Dim testElement As FrameworkElement = fe
+
+ If testElement.ActualWidth <= 0 OrElse testElement.ActualHeight <= 0 Then Return False
+
+ Dim gt As GeneralTransform
+ Try
+ gt = testElement.TransformToVisual(mainCanvas)
+ Catch
+ ' not in visual tree
+ Return False
+ End Try
+
+ ' Local bounds of the element (axis-aligned in its own space)
+ Dim localRect As New Rect(0, 0, testElement.ActualWidth, testElement.ActualHeight)
+
+ ' Transform into canvas space; result is axis-aligned bounds of the transformed quad
+ Dim worldRect As Rect = gt.TransformBounds(localRect)
+
+ Dim canvasRect As New Rect(0, 0, canvasWidth, canvasHeight)
+
+
+ Return canvasRect.Contains(worldRect)
End Function
End Module
diff --git a/PolyCut/Helpers/GeometryExtractor.vb b/PolyCut/Helpers/GeometryExtractor.vb
new file mode 100644
index 0000000..412e491
--- /dev/null
+++ b/PolyCut/Helpers/GeometryExtractor.vb
@@ -0,0 +1,272 @@
+
+Imports System.Numerics
+
+Imports MeasurePerformance.IL.Weaver
+
+Imports PolyCut.Core
+Imports PolyCut.[Shared]
+
+Public Class GeometryExtractor
+
+ Public Shared Function ExtractFromDrawable(drawable As IDrawable, cfg As ProcessorConfiguration, mainCanvas As UIElement) As List(Of IPathBasedElement)
+
+ If drawable Is Nothing OrElse mainCanvas Is Nothing Then
+ Return New List(Of IPathBasedElement)
+ End If
+
+ ' Handle nested groups by recursing through children
+ Dim nestedGroup = TryCast(drawable, NestedDrawableGroup)
+ If nestedGroup IsNot Nothing Then
+ Dim results As New List(Of IPathBasedElement)
+ For Each child In nestedGroup.GroupChildren
+ If child IsNot Nothing Then
+ results.AddRange(ExtractFromDrawable(child, cfg, mainCanvas))
+ End If
+ Next
+ Return results
+ End If
+
+ ' Handle simple (non-group) drawable
+ Dim element = TryCast(drawable.DrawableElement, FrameworkElement)
+ If element Is Nothing Then Return New List(Of IPathBasedElement)
+
+ ' 1. Get geometry in element's local coordinate space
+ Dim geometry = GetGeometryFromElement(element)
+ If geometry Is Nothing Then Return New List(Of IPathBasedElement)
+
+ ' 2. Get accumulated transform from element to main canvas. WHY THE FUCK DID I NOT JUST DO THIS MONTHS AGO
+ Dim gt As GeneralTransform
+ Try
+ gt = element.TransformToVisual(mainCanvas)
+ Catch
+ Return New List(Of IPathBasedElement)
+ End Try
+
+ Dim t As Transform = If(TryCast(gt, Transform), GeneralToMatrixTransform(gt))
+
+ ' 3. Flatten in local space first
+ Dim flattened As PathGeometry = geometry.GetFlattenedPathGeometry(cfg.Tolerance, ToleranceType.Absolute)
+
+ ' 4. Apply transform
+ Dim transformed As PathGeometry = flattened.Clone()
+ transformed.Transform = t
+
+ ' 5. Flatten again after transform
+ transformed = transformed.GetFlattenedPathGeometry(cfg.Tolerance, ToleranceType.Absolute)
+
+ ' now build lines from transformed
+ Dim figures = BuildLinesFromGeometry(transformed, cfg.Tolerance)
+ If figures Is Nothing OrElse figures.Count = 0 Then Return New List(Of IPathBasedElement)
+
+ Dim b = figures.ComputeBounds()
+
+ Dim skipBoundsCheck = Keyboard.IsKeyDown(Key.LeftShift) OrElse Keyboard.IsKeyDown(Key.RightShift)
+
+ If Not skipBoundsCheck AndAlso Not IsFullyOnCanvas(b, cfg.WorkAreaWidth, cfg.WorkAreaHeight) Then
+ Return New List(Of IPathBasedElement)
+ End If
+
+ ' 6. Create IPathBasedElement
+ Dim pathElement = CreatePathBasedElement(drawable, figures)
+ If pathElement Is Nothing Then Return New List(Of IPathBasedElement)
+
+ pathElement.FillColor = GetFillColor(drawable)
+ pathElement.Config = cfg
+
+ Return New List(Of IPathBasedElement) From {pathElement}
+ End Function
+
+ Private Shared Function GeneralToMatrixTransform(gt As GeneralTransform) As MatrixTransform
+ Dim p0 = gt.Transform(New Point(0, 0))
+ Dim p1 = gt.Transform(New Point(1, 0))
+ Dim p2 = gt.Transform(New Point(0, 1))
+
+ Dim m As New Matrix(p1.X - p0.X, p1.Y - p0.Y, p2.X - p0.X, p2.Y - p0.Y, p0.X, p0.Y)
+
+ Return New MatrixTransform(m)
+ End Function
+
+
+ Private Shared Function GetGeometryFromElement(element As FrameworkElement) As Geometry
+
+ Select Case True
+ Case TypeOf element Is Rectangle
+ Dim r = DirectCast(element, Rectangle)
+ Return New RectangleGeometry(New Rect(0, 0, r.ActualWidth, r.ActualHeight))
+
+ Case TypeOf element Is Ellipse
+ Dim e = DirectCast(element, Ellipse)
+ Dim cx = e.ActualWidth / 2
+ Dim cy = e.ActualHeight / 2
+ Return New EllipseGeometry(New Point(cx, cy), cx, cy)
+
+ Case TypeOf element Is Line
+ Dim ln = DirectCast(element, Line)
+ Return New LineGeometry(New Point(ln.X1, ln.Y1), New Point(ln.X2, ln.Y2))
+
+ Case TypeOf element Is Path
+ Dim p = DirectCast(element, Path)
+
+ Dim g As Geometry = If(p.Data?.Clone(), Nothing)
+ If g Is Nothing Then Return Nothing
+
+ ' If Path is stretched by wrapper, apply stretch explicitly
+ If p.Stretch = Stretch.Fill Then
+ Dim wrapper = TryCast(p.Parent, ContentControl)
+ If wrapper IsNot Nothing Then
+ Dim b = g.Bounds
+ Dim w = wrapper.ActualWidth
+ Dim h = wrapper.ActualHeight
+
+ If b.Width > 0 AndAlso b.Height > 0 AndAlso w > 0 AndAlso h > 0 Then
+ Dim m As Matrix = Matrix.Identity
+ m.Translate(-b.X, -b.Y)
+ m.Scale(w / b.Width, h / b.Height)
+ g.Transform = New MatrixTransform(m)
+ End If
+ End If
+ End If
+
+ Return g
+
+
+ Case TypeOf element Is TextBox
+ Return GetTextBoxGeometry(DirectCast(element, TextBox))
+ End Select
+
+ Return Nothing
+ End Function
+
+
+ Private Shared Function GetTextBoxGeometry(tb As TextBox) As Geometry
+ If tb Is Nothing OrElse tb.ActualWidth <= 0 OrElse tb.ActualHeight <= 0 Then
+ Return Nothing
+ End If
+
+ Dim textToDraw As String = If(String.IsNullOrEmpty(tb.Text), " ", tb.Text)
+
+ Dim r As Rect = tb.GetRectFromCharacterIndex(0, False)
+ If r.IsEmpty OrElse Double.IsNaN(r.X) OrElse Double.IsNaN(r.Y) Then
+ r = New Rect(0, 0, 0, 0)
+ End If
+
+ Dim dpi = VisualTreeHelper.GetDpi(tb)
+ Dim ft As New FormattedText(
+ textToDraw,
+ Globalization.CultureInfo.CurrentCulture,
+ tb.FlowDirection,
+ New Typeface(tb.FontFamily, tb.FontStyle, tb.FontWeight, tb.FontStretch),
+ tb.FontSize,
+ Brushes.Black,
+ dpi.PixelsPerDip
+ ) With {
+ .Trimming = TextTrimming.None,
+ .TextAlignment = tb.TextAlignment
+ }
+
+ Dim origin As New Point(r.X, r.Y)
+ Return ft.BuildGeometry(origin)
+ End Function
+
+
+ Private Shared Function CreatePathBasedElement(drawable As IDrawable, figures As List(Of List(Of GeoLine))) As IPathBasedElement
+ If figures Is Nothing OrElse figures.Count = 0 Then Return Nothing
+
+ Dim element = drawable.DrawableElement
+
+ Select Case element.GetType()
+ Case GetType(Rectangle)
+ Return New RectangleElement With {.Figures = figures}
+ Case GetType(Ellipse)
+ Return New EllipseElement With {.Figures = figures}
+ Case GetType(Path)
+ Return New PathElement With {.Figures = figures}
+ Case GetType(Line)
+ Return New LineElement With {.Figures = figures}
+ Case GetType(TextBox)
+ Return New TextElement With {.Figures = figures}
+ Case Else
+ Return New PathElement With {.Figures = figures}
+ End Select
+ End Function
+
+
+ Private Shared Function GetFillColor(drawable As IDrawable) As String
+ If drawable Is Nothing Then Return Nothing
+
+ Try
+ Dim fillBrush = drawable.Fill
+ If fillBrush Is Nothing Then Return Nothing
+
+ Dim solidBrush = TryCast(fillBrush, SolidColorBrush)
+ If solidBrush IsNot Nothing Then
+ Dim c = solidBrush.Color
+ Return String.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B)
+ End If
+
+ Return "#000000"
+ Catch
+ Return Nothing
+ End Try
+ End Function
+
+
+ <MeasurePerformance>
+ Private Shared Function BuildLinesFromGeometry(geometry As PathGeometry, tolerance As Double) As List(Of List(Of GeoLine))
+ If geometry Is Nothing Then Return New List(Of List(Of GeoLine))
+
+ Dim figures As New List(Of List(Of GeoLine))
+
+ For Each figure In geometry.Figures
+ Dim lines As New List(Of GeoLine)
+ Dim currentPoint = New Vector2(figure.StartPoint.X, figure.StartPoint.Y)
+
+ For Each segment In figure.Segments
+ Dim lineSegment = TryCast(segment, LineSegment)
+ If lineSegment IsNot Nothing Then
+ Dim endPoint = New Vector2(lineSegment.Point.X, lineSegment.Point.Y)
+ lines.Add(New GeoLine(currentPoint, endPoint))
+ currentPoint = endPoint
+ Continue For
+ End If
+
+ Dim polyLineSegment = TryCast(segment, PolyLineSegment)
+ If polyLineSegment IsNot Nothing Then
+ For Each pt In polyLineSegment.Points
+ Dim endPoint = New Vector2(pt.X, pt.Y)
+ lines.Add(New GeoLine(currentPoint, endPoint))
+ currentPoint = endPoint
+ Next
+ Continue For
+ End If
+
+ Next
+
+ If figure.IsClosed AndAlso lines.Count > 0 Then
+ Dim firstPoint = lines(0).StartPoint
+ If Not currentPoint.Equals(firstPoint) Then
+ lines.Add(New GeoLine(currentPoint, firstPoint))
+ End If
+ End If
+
+ If lines.Count > 0 Then
+ figures.Add(lines)
+ End If
+ Next
+
+ Return figures
+ End Function
+
+ Private Shared Function IsOnCanvas(bounds As Rect, canvasW As Double, canvasH As Double) As Boolean
+ If bounds.IsEmpty Then Return False
+ Dim canvasRect As New Rect(0, 0, canvasW, canvasH)
+ Return canvasRect.IntersectsWith(bounds) ' policy 1: any part visible
+ End Function
+
+ Private Shared Function IsFullyOnCanvas(bounds As Rect, canvasW As Double, canvasH As Double) As Boolean
+ If bounds.IsEmpty Then Return False
+ Dim canvasRect As New Rect(0, 0, canvasW, canvasH)
+ Return canvasRect.Contains(bounds) ' policy 2: fully inside
+ End Function
+
+End Class
diff --git a/PolyCut/Models/Generators/PolyCutGenerator.vb b/PolyCut/Models/Generators/PolyCutGenerator.vb
index 2d30458..bda488d 100644
--- a/PolyCut/Models/Generators/PolyCutGenerator.vb
+++ b/PolyCut/Models/Generators/PolyCutGenerator.vb
@@ -1,23 +1,21 @@
-'Generator that uses PolyCut.Core
-Imports MeasurePerformance.IL.Weaver
+Imports System.Windows
Imports PolyCut.Core
-
-Imports WPF.Ui.Controls
+Imports PolyCut.Shared
Public Class PolyCutGenerator : Implements IGenerator
Private Property Configuration As ProcessorConfiguration Implements IGenerator.Configuration
Private Property Printer As Printer Implements IGenerator.Printer
Private Property GCodes As List(Of GCode) Implements IGenerator.GCodes
- Private Property SVGText As String
+ Private Property DrawableObjects As List(Of IDrawable)
+ Private Property MainCanvas As UIElement
- <MeasurePerformance>
Public Async Function GenerateGcode() As Task(Of (StatusCode As Integer, Message As String)) Implements IGenerator.GenerateGcodeAsync
- Dim processedElements As List(Of IPathBasedElement) = Await SVGProcessor.ProcessSVG(SVGText, Configuration)
+ Dim processedElements = GeneratePathBasedElements()
If processedElements.Count = 0 Then
Return (1, "No paths on canvas")
@@ -36,14 +34,30 @@ Public Class PolyCutGenerator : Implements IGenerator
End Function
+ Public Function GeneratePathBasedElements() As List(Of IPathBasedElement)
+ Dim elements As New List(Of IPathBasedElement)
+
+ For Each drawable In DrawableObjects
+ If TypeOf drawable Is DrawableGroup Then Continue For
+
+ Dim pathElements = GeometryExtractor.ExtractFromDrawable(drawable, Configuration, MainCanvas)
+ If pathElements IsNot Nothing AndAlso pathElements.Count > 0 Then
+ elements.AddRange(pathElements)
+ End If
+ Next
+
+ Return elements
+ End Function
+
Public Function GetGCode() As List(Of GCode) Implements IGenerator.GetGCode
Return GCodes
End Function
- Public Sub New(Configuration As ProcessorConfiguration, Printer As Printer, SVGText As String)
+ Public Sub New(Configuration As ProcessorConfiguration, Printer As Printer, DrawableObjects As List(Of IDrawable), MainCanvas As UIElement)
Me.Configuration = Configuration
Me.Printer = Printer
- Me.SVGText = SVGText
+ Me.DrawableObjects = DrawableObjects
+ Me.MainCanvas = MainCanvas
End Sub
End Class
diff --git a/PolyCut/ViewModels/MainViewModel.vb b/PolyCut/ViewModels/MainViewModel.vb
index 1cde38c..81a1b3c 100644
--- a/PolyCut/ViewModels/MainViewModel.vb
+++ b/PolyCut/ViewModels/MainViewModel.vb
@@ -646,7 +646,7 @@ Partial Public Class MainViewModel
Dim generator As IGenerator = If(UsingGCodePlot,
New GCodePlotGenerator(Configuration, Printer, GenerateSVGText),
- New PolyCutGenerator(Configuration, Printer, GenerateSVGText))
+ New PolyCutGenerator(Configuration, Printer, DrawableCollection.Where(Function(d) Not d.IsHidden).ToList(), PolyCanvas.ActiveInstance))
Dim retcode = Await generator.GenerateGcodeAsync
@@ -719,7 +719,7 @@ Partial Public Class MainViewModel
If finalElement?.IsWithinBounds(Printer.BedWidth, Printer.BedHeight) Then
outDoc.Children.Add(finalElement)
ElseIf TypeOf (drawableL) Is DrawablePath Then
- If drawableL?.IsWithinBounds(Printer.BedWidth, Printer.BedHeight) Then
+ If drawableL?.IsWithinBounds(Printer.BedWidth, Printer.BedHeight, PolyCanvas.ActiveInstance) Then
outDoc.Children.Add(finalElement)
End If
End If