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
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using UVtools.Core.Extensions;
namespace UVtools.Core.Printer
{
public class Machine
{
#region Properties
public PrinterBrand Brand { get; set; }
public string Name { get; set; } = FileFormats.FileFormat.DefaultMachineName;
public string Model { get; set; } = FileFormats.FileFormat.DefaultMachineName;
public ushort ResolutionX { get; set; }
public ushort ResolutionY { get; set; }
public float DisplayWidth { get; set; }
public float DisplayHeight { get; set; }
public float MachineZ { get; set; }
public FlipDirection DisplayMirror { get; set; }
public object? Tag { get; set; }
#endregion
#region Constructor
public Machine() { }
public Machine(PrinterBrand brand, string name, string? model, ushort resolutionX, ushort resolutionY, float displayWidth, float displayHeight, float machineZ, FlipDirection displayMirror = default)
{
Brand = brand;
Name = name;
Model = model ?? name;
ResolutionX = resolutionX;
ResolutionY = resolutionY;
DisplayWidth = displayWidth;
DisplayHeight = displayHeight;
MachineZ = machineZ;
DisplayMirror = displayMirror;
}
public Machine(PrinterBrand brand, string name, string? model, Size resolution, SizeF display, float machineZ, FlipDirection displayMirror = default)
: this(brand, name, model, (ushort)resolution.Width, (ushort)resolution.Height, display.Width, display.Height, machineZ, displayMirror) { }
public Machine(ushort resolutionX, ushort resolutionY, float displayWidth, float displayHeight, float machineZ, FlipDirection displayMirror = default, PrinterBrand brand = default, string name = FileFormats.FileFormat.DefaultMachineName, string? model = null)
: this(brand, name, model, resolutionX, resolutionY, displayWidth, displayHeight, machineZ, displayMirror) {}
#endregion
#region Overrides
protected bool Equals(Machine other)
{
return ResolutionX == other.ResolutionX && ResolutionY == other.ResolutionY && DisplayWidth.Equals(other.DisplayWidth) && DisplayHeight.Equals(other.DisplayHeight) && MachineZ.Equals(other.MachineZ) && Brand == other.Brand && Name == other.Name && Model == other.Model;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Machine)obj);
}
public override int GetHashCode()
{
return HashCode.Combine(ResolutionX, ResolutionY, DisplayWidth, DisplayHeight, MachineZ, (int)Brand, Name, Model);
}
public override string ToString()
{
return $"{Name} | Resolution={ResolutionX}x{ResolutionY}(px) Display={DisplayWidth}x{DisplayHeight}(mm) Z={MachineZ}mm";
}
#endregion
#region Methods
/// <summary>
/// Gets or sets the pixels per mm on X direction
/// </summary>
public virtual float Xppmm => DisplayWidth > 0 ? ResolutionX / DisplayWidth : 0;
/// <summary>
/// Gets or sets the pixels per mm on Y direction
/// </summary>
public virtual float Yppmm => DisplayHeight > 0 ? ResolutionY / DisplayHeight : 0;
/// <summary>
/// Gets or sets the pixels per mm
/// </summary>
public SizeF Ppmm => new(Xppmm, Yppmm);
/// <summary>
/// Gets the maximum (Width or Height) pixels per mm
/// </summary>
public float PpmmMax => Ppmm.Max();
/// <summary>
/// Gets the pixel width in millimeters
/// </summary>
public float PixelWidth => DisplayWidth > 0 && ResolutionX > 0 ? (float)Math.Round(DisplayWidth / ResolutionX, 3) : 0;
/// <summary>
/// Gets the pixel height in millimeters
/// </summary>
public float PixelHeight => DisplayHeight > 0 && ResolutionY > 0 ? (float)Math.Round(DisplayHeight / ResolutionY, 3) : 0;
/// <summary>
/// Gets the pixel size in millimeters
/// </summary>
public SizeF PixelSize => new(PixelWidth, PixelHeight);
/// <summary>
/// Gets the maximum pixel between width and height in millimeters
/// </summary>
public float PixelSizeMax => PixelSize.Max();
/// <summary>
/// Gets the pixel area in millimeters
/// </summary>
public float PixelArea => PixelSize.Area();
/// <summary>
/// Gets the pixel width in microns
/// </summary>
public float PixelWidthMicrons => DisplayWidth > 0 ? (float)Math.Round(DisplayWidth / ResolutionX * 1000, 3) : 0;
/// <summary>
/// Gets the pixel height in microns
/// </summary>
public float PixelHeightMicrons => DisplayHeight > 0 ? (float)Math.Round(DisplayHeight / ResolutionY * 1000, 3) : 0;
/// <summary>
/// Gets the pixel size in microns
/// </summary>
public SizeF PixelSizeMicrons => new(PixelWidthMicrons, PixelHeightMicrons);
/// <summary>
/// Gets the maximum pixel between width and height in microns
/// </summary>
public float PixelSizeMicronsMax => PixelSizeMicrons.Max();
/// <summary>
/// Gets the pixel area in millimeters
/// </summary>
public float PixelAreaMicrons => PixelSizeMicrons.Area();
public Machine Clone()
{
return (Machine)MemberwiseClone();
}
#endregion
#region Static methods
/// <summary>
/// Preset list of machines
/// </summary>
public static Machine[] Machines =>
new Machine[]{
// Creality
/*new(PrinterBrand.Creality, "Halot One", "CL-60", 1620, 2560, 81, 128, 160),
new(PrinterBrand.Creality, "Halot One Pro", "CL-70", 2560, 2400, 130.56f, 122.4f, 160),
new(PrinterBrand.Creality, "Halot One Plus", "CL-79", 4320, 2560, 172.8f, 102.4f, 160),
new(PrinterBrand.Creality, "Halot Sky", "CL-89", 3840, 2400, 192, 120, 200),
new(PrinterBrand.Creality, "Halot Sky Plus", "CL-92", 5760, 3600, 198.14f, 123.84f, 210),
new(PrinterBrand.Creality, "Halot Lite", "CL-89L", 3840, 2400, 192, 120, 200),
new(PrinterBrand.Creality, "Halot Max", "CL-133", 3840, 2160, 293.76f, 165.28f, 300),
new(PrinterBrand.Creality, "CT133 Pro", "CT133PRO", 3840, 2160, 293.76f, 165.24f, 300),
new(PrinterBrand.Creality, "CT-005 Pro", "CT-005", 3840, 2400, 192, 120, 250),*/
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono 4K", "Photon Mono 4K", 3840, 2400, 134.4f, 84f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono SE", "Photon Mono SE", 1620, 2560, 82.62f, 130.56f, 160f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono SQ", "Photon Mono SQ", 2400, 2560, 120f, 128f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono X 6K", "Photon Mono X 6K", 5760, 3600, 198.14f, 123.84f, 245f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono X", "Photon Mono X", 3840, 2400, 192f, 120f, 245f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono", "Photon Mono", 1620, 2560, 82.62f, 130.56f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon S", "Photon S", 1440, 2560, 68.04f, 120.96f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Ultra", "Photon Ultra", 1280, 720, 102.4f, 57.6f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon X", "Photon X", 2560, 1600, 192f, 120f, 245f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Zero", "Photon Zero", 480, 854, 55.4f, 98.63f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon", "Photon", 1440, 2560, 68.04f, 120.96f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.Creality, "Creality CT-005 Pro", "CT-005", 3840, 2400, 192f, 120f, 250f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality CT-133 Pro", "CT133PRO", 3840, 2160, 293.76f, 165.24f, 300f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot Lite CL-89L", "CL-89L", 3840, 2400, 192f, 120f, 200f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot Max CL-133", "CL-133", 3840, 2160, 293.76f, 165.24f, 300f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot One CL-60", "CL-60", 1620, 2560, 81f, 128f, 160f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot One Plus CL-79", "CL-79", 4320, 2560, 172.8f, 102.4f, 160f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot One Pro CL-70", "CL-70", 2560, 2400, 130.56f, 122.4f, 160f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot Sky CL-89", "", 3840, 2400, 192f, 120f, 200f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality Halot Sky Plus CL-92", "CL-92", 5760, 3600, 198.14f, 123.84f, 210f, FlipDirection.None),
new(PrinterBrand.Creality, "Creality LD-002H", "LD-002H", 1620, 2560, 82.62f, 130.56f, 160f, FlipDirection.Horizontally),
new(PrinterBrand.Creality, "Creality LD-002R", "LD-002R", 1440, 2560, 68.04f, 120.96f, 160f, FlipDirection.Horizontally),
new(PrinterBrand.Creality, "Creality LD-006", "LD-006", 3840, 2400, 192f, 120f, 245f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Jupiter", "Jupiter", 5448, 3064, 277.848f, 156.264f, 300f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Mars 2 Pro", "Mars 2 Pro", 1620, 2560, 82.62f, 130.56f, 160f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Mars 2", "Mars 2", 1620, 2560, 82.62f, 130.56f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Mars 3", "Mars 3", 4098, 2560, 143.43f, 89.6f, 175f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Mars C", "Mars C", 1440, 2560, 68.04f, 120.96f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Mars", "Mars", 1440, 2560, 68.04f, 120.96f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Elegoo, "Elegoo Saturn", "Saturn", 3840, 2400, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX DX1 PRO", "DX1 PRO", 4098, 2560, 143.43f, 89.6f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX DX10 Pro 5K", "DX10 Pro 5K", 4920, 2880, 221.4f, 129.6f, 120f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX DX10 Pro 8K", "DX10 Pro 8K", 7680, 4320, 218.88f, 123.12f, 120f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX E10 5K", "E10 5K", 4920, 2880, 221.4f, 129.6f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX E10 8K", "E10 8K", 7680, 4320, 218.88f, 123.12f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX E10 Mono", "E10 Mono", 3840, 2400, 192f, 120f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX E6 Mono", "E6 Mono", 1620, 2560, 81f, 128f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X1 4KS", "X1 4KS", 4098, 2560, 143.43f, 89.6f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X1", "X1", 1440, 2560, 68.04f, 120.96f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X10 4K Mono", "X10 4K Mono", 3840, 2400, 192f, 120f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X10 5K", "X10 5K", 4920, 2880, 221.4f, 129.6f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X10", "X10", 1600, 2560, 135.36f, 216.57f, 250f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X133 4K Mono", "X133 4K Mono", 3840, 2160, 293.76f, 165.24f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X133 6K", "X133 6K", 5760, 3240, 288f, 162f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X156 4K Color", "X156 4K Color", 3840, 2160, 345.6f, 194.4f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.EPAX, "EPAX X1K 2K Mono", "X1K 2K Mono", 1620, 2560, 82.62f, 130.56f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.FlashForge, "FlashForge Explorer MAX", "Explorer MAX", 2560, 1600, 192f, 120f, 200f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Focus 13.3", "Focus 13.3", 3842, 2171, 292f, 165f, 400f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Focus 8.9", "Focus 8.9", 3840, 2400, 192f, 120f, 200f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Foto 13.3", "Foto 13.3", 3842, 2171, 292f, 165f, 400f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Foto 6.0", "Foto 6.0", 2600, 1560, 130f, 78f, 155f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Foto 8.9", "Foto 8.9", 3840, 2400, 192f, 120f, 200f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Foto 8.9S", "Foto 8.9S", 3840, 2400, 192f, 120f, 200f, FlipDirection.Vertically),
new(PrinterBrand.FlashForge, "FlashForge Hunter", "Hunter", 1920, 1080, 120f, 67.5f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Kelant, "Kelant S400", "S400", 2560, 1600, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Longer, "Longer Orange 10", "Orange 10", 480, 854, 55.44f, 98.64f, 140f, FlipDirection.Horizontally),
new(PrinterBrand.Longer, "Longer Orange 120", "Orange 120", 1440, 2560, 68.04f, 120.96f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Longer, "Longer Orange 30", "Orange 30", 1440, 2560, 68.04f, 120.96f, 170f, FlipDirection.Horizontally),
new(PrinterBrand.Longer, "Longer Orange 4K", "Orange 4K", 3840, 6480, 120.96f, 68.04f, 190f, FlipDirection.Horizontally),
new(PrinterBrand.Nova3D, "Nova3D Bene4 Mono", "Bene4 Mono", 1566, 2549, 79.865f, 129.998f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Bene4", "Bene4", 1352, 2512, 70f, 130f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Bene5", "Bene5", 1566, 2549, 79.865f, 129.998f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Elfin", "Elfin", 1410, 2531, 73f, 131f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Elfin2 Mono SE", "Elfin2 Mono SE", 1470, 2549, 75f, 130f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Elfin2", "Elfin2", 1352, 2512, 70f, 130f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Elfin3 Mini", "Elfin3 Mini", 1079, 1904, 68f, 120f, 150f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Whale", "Whale", 3840, 2400, 192f, 120f, 250f, FlipDirection.Vertically),
new(PrinterBrand.Nova3D, "Nova3D Whale2", "Whale2", 3840, 2400, 192f, 120f, 250f, FlipDirection.Vertically),
new(PrinterBrand.Peopoly, "Peopoly Phenom L", "Phenom L", 3840, 2160, 345.6f, 194.4f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.Peopoly, "Peopoly Phenom Noir", "Phenom Noir", 3840, 2160, 293.76f, 165.24f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.Peopoly, "Peopoly Phenom XXL", "Phenom XXL", 3840, 2160, 527.04f, 296.46f, 550f, FlipDirection.Horizontally),
new(PrinterBrand.Peopoly, "Peopoly Phenom", "Phenom", 3840, 2160, 276.48f, 155.52f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Shuffle 16", "Shuffle 16", 3840, 2160, 337.92f, 190.08f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Shuffle 4K", "Shuffle 4K", 2160, 3840, 68.04f, 120.96f, 170f, FlipDirection.None),
new(PrinterBrand.Phrozen, "Phrozen Shuffle Lite", "Shuffle Lite", 1440, 2560, 68.04f, 120.96f, 170f, FlipDirection.None),
new(PrinterBrand.Phrozen, "Phrozen Shuffle XL Lite", "Shuffle XL Lite", 2560, 1600, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Shuffle XL", "Shuffle XL", 2560, 1600, 192f, 120f, 200f, FlipDirection.None),
new(PrinterBrand.Phrozen, "Phrozen Shuffle", "Shuffle", 1440, 2560, 67.68f, 120.32f, 200f, FlipDirection.None),
new(PrinterBrand.Phrozen, "Phrozen Sonic 4K", "Sonic 4K", 3840, 2160, 134.4f, 75.6f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Sonic Mega 8K", "Sonic Mega 8K", 7680, 4320, 330.24f, 185.76f, 400f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Sonic Mighty 4K", "Sonic Mighty 4K", 3840, 2400, 199.68f, 124.8f, 220f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Sonic Mini 4K", "Sonic Mini 4K", 3840, 2160, 134.4f, 75.6f, 130f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Sonic Mini 8K", "Sonic Mini 8K", 7500, 3240, 165f, 71.28f, 180f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Sonic Mini", "Sonic Mini", 1080, 1920, 68.04f, 120.96f, 130f, FlipDirection.None),
new(PrinterBrand.Phrozen, "Phrozen Sonic", "Sonic", 1080, 1920, 68.04f, 120.96f, 170f, FlipDirection.Horizontally),
new(PrinterBrand.Phrozen, "Phrozen Transform", "Transform", 3840, 2160, 291.84f, 164.16f, 400f, FlipDirection.None),
new(PrinterBrand.QIDI, "QIDI I-Box Mono", "I-Box Mono", 3840, 2400, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.QIDI, "QIDI S-Box", "S-Box", 1600, 2560, 135.36f, 216.576f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.QIDI, "QIDI Shadow5.5", "Shadow5.5", 1440, 2560, 68.04f, 120.96f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.QIDI, "QIDI Shadow6.0 Pro", "Shadow6.0 Pro", 1440, 2560, 74.52f, 132.48f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Uniformation, "Uniformation GKone", "GKone", 4920, 2880, 221.4f, 129.6f, 245f, FlipDirection.Vertically),
new(PrinterBrand.Uniz, "Uniz IBEE", "IBEE", 3840, 2400, 192f, 120f, 220f, FlipDirection.Vertically),
new(PrinterBrand.Prusa, "Prusa SL1", "SL1", 1440, 2560, 68.04f, 120.96f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Prusa, "Prusa SL1S SPEED", "SL1S SPEED", 1620, 2560, 128f, 81f, 150f, FlipDirection.Horizontally),
new(PrinterBrand.Voxelab, "Voxelab Ceres 8.9", "Ceres 8.9", 3840, 2400, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Voxelab, "Voxelab Polaris 5.5", "Polaris 5.5", 1440, 2560, 68.04f, 120.96f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.Voxelab, "Voxelab Proxima 6", "Proxima 6", 1620, 2560, 82.62f, 130.56f, 155f, FlipDirection.Horizontally),
new(PrinterBrand.Wanhao, "Wanhao CGR Mini Mono", "CGR Mini Mono", 1620, 2560, 82.62f, 130.56f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Wanhao, "Wanhao CGR Mono", "CGR Mono", 1620, 2560, 192f, 120f, 200f, FlipDirection.Horizontally),
new(PrinterBrand.Wanhao, "Wanhao D7", "D7", 2560, 1440, 120.96f, 68.5f, 180f, FlipDirection.Horizontally),
new(PrinterBrand.Wanhao, "Wanhao D8", "D8", 2560, 1600, 192f, 120f, 180f, FlipDirection.Horizontally),
new(PrinterBrand.Zortrax, "Zortrax Inkspire", "Inkspire", 1440, 2560, 74.67f, 132.88f, 175f, FlipDirection.Horizontally),
};
/// <summary>
/// Gets all machines from PrusaSlicer profiles
/// </summary>
/// <returns></returns>
public static IEnumerable<Machine> GetMachinesFromPrusaSlicer()
{
var psPrinterFiles = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Assets", "PrusaSlicer", "printer"));
foreach (var file in psPrinterFiles)
{
var displayMirror = FlipDirection.None;
var filenameNoExt = Path.GetFileNameWithoutExtension(file);
var split = filenameNoExt.Split(' ', 2);
if (!Enum.TryParse(split[0], true, out PrinterBrand brand))
{
brand = filenameNoExt.StartsWith("UVtools Prusa") ? PrinterBrand.Prusa : PrinterBrand.Generic;
}
using var reader = new StreamReader(file);
string? line;
var machine = new Machine
{
Name = filenameNoExt,
Model = split[1]
};
while ((line = reader.ReadLine()) is not null)
{
var keyValue = line.Split('=', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if(keyValue.Length < 2) continue;
var key = keyValue[0];
var value = keyValue[1];
if (key.StartsWith("display_pixels_x"))
{
if (!ushort.TryParse(value, out var resolutionX)) continue;
machine.ResolutionX = resolutionX;
}
if (key.StartsWith("display_pixels_y"))
{
if (!ushort.TryParse(value, out var resolutionY)) continue;
machine.ResolutionY = resolutionY;
}
if (key.StartsWith("display_width"))
{
if (!float.TryParse(value, out var displayWidth)) continue;
machine.DisplayWidth = displayWidth;
}
if (key.StartsWith("display_height"))
{
if (!float.TryParse(value, out var displayHeight)) continue;
machine.DisplayHeight = displayHeight;
}
if (key.StartsWith("max_print_height"))
{
if (!float.TryParse(value, out var machineZ)) continue;
machine.MachineZ = machineZ;
}
if (key.StartsWith("display_mirror_x"))
{
if(value.StartsWith("1")) displayMirror = displayMirror == FlipDirection.None ? FlipDirection.Horizontally : FlipDirection.Both;
}
if (key.StartsWith("display_mirror_y"))
{
if (value.StartsWith("1")) displayMirror = displayMirror == FlipDirection.None ? FlipDirection.Vertically : FlipDirection.Both;
}
}
if(machine.ResolutionX == 0 || machine.ResolutionY == 0) continue;
machine.Brand = brand;
machine.DisplayMirror = displayMirror;
yield return machine;
}
}
public static string GenerateMachinePresetsFromPrusaSlicer()
{
var machines = GetMachinesFromPrusaSlicer();
var sb = new StringBuilder();
PrinterBrand lastBrand = default;
foreach (var machine in machines)
{
if (lastBrand != machine.Brand)
{
if(sb.Length > 0) sb.AppendLine();
lastBrand = machine.Brand;
}
sb.AppendLine($"new(PrinterBrand.{machine.Brand}, \"{machine.Name}\", \"{machine.Model}\", {machine.ResolutionX}, {machine.ResolutionY}, {machine.DisplayWidth}f, {machine.DisplayHeight}f, {machine.MachineZ}f, FlipDirection.{machine.DisplayMirror}),");
}
return sb.ToString();
}
#endregion
}
}
|