* (Add) Tool: Layer Clone
* (Add) Mutator: Mask
* (Add) Mutator - Pixel Dimming: "Strips" pattern
* (Remove) Bottom progress bar
This commit is contained in:
Tiago Conceição
2020-08-21 02:56:51 +01:00
parent 094c33184d
commit ba5b52791e
25 changed files with 3849 additions and 27 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
# Changelog
## ?/08/2020 - v0.6.6.2
## 21/08/2020 - v0.6.7.0
* (Add) Tool: Layer Clone
* (Add) Mutator: Mask
* (Add) Mutator - Pixel Dimming: "Strips" pattern
* (Remove) Bottom progress bar
## 17/08/2020 - v0.6.6.1
+1
View File
@@ -25,3 +25,4 @@
* Sven Vogt
* Paul Hammerstrom
* Jeremy Lauzon
* Peter Teal
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UVtools.Core.Extensions
{
+3 -3
View File
@@ -63,7 +63,7 @@ namespace UVtools.Core.FileFormats
{
base.Decode(fileFullPath, progress);
ImageMat = CvInvoke.Imread(fileFullPath, ImreadModes.AnyColor);
ImageMat = CvInvoke.Imread(fileFullPath, ImreadModes.Grayscale);
const byte startDivisor = 2;
for (int i = 0; i < ThumbnailsCount; i++)
{
@@ -73,10 +73,10 @@ namespace UVtools.Core.FileFormats
new Size(ImageMat.Width / divisor, ImageMat.Height / divisor));
}
if (ImageMat.NumberOfChannels > 1)
/*if (ImageMat.NumberOfChannels > 1)
{
CvInvoke.CvtColor(ImageMat, ImageMat, ColorConversion.Bgr2Gray);
}
}*/
LayerManager = new LayerManager(1, this);
this[0] = new Layer(0, ImageMat, Path.GetFileName(fileFullPath));
+12 -4
View File
@@ -568,6 +568,15 @@ namespace UVtools.Core
}
}
public void MutateMask(Mat mask)
{
using (var mat = LayerMat)
{
CvInvoke.BitwiseAnd(mat, mask, mat);
LayerMat = mat;
}
}
public void MutatePixelDimming(Matrix<byte> evenPattern = null, Matrix<byte> oddPattern = null, ushort borderSize = 5)
{
var anchor = new Point(-1, -1);
@@ -602,7 +611,7 @@ namespace UVtools.Core
{
using (Mat mask = dst.CloneBlank())
{
CvInvoke.Erode(dst, erode, kernel, anchor, borderSize, BorderType.Default, default);
CvInvoke.Erode(dst, erode, kernel, anchor, borderSize, BorderType.Reflect101, default);
CvInvoke.Subtract(dst, erode, diff);
if (Index % 2 == 0)
@@ -643,7 +652,7 @@ namespace UVtools.Core
{
using (Mat diff = new Mat())
{
CvInvoke.Erode(dst, erode, kernel, anchor, borderSize, BorderType.Default, default);
CvInvoke.Erode(dst, erode, kernel, anchor, borderSize, BorderType.Reflect101, default);
CvInvoke.Subtract(dst, erode, diff);
CvInvoke.BitwiseAnd(erode, Index % 2 == 0 ? evenPatternMask : oddPatternMask, dst);
CvInvoke.Add(dst, diff, dst);
@@ -834,8 +843,6 @@ namespace UVtools.Core
}
}
public Layer Clone()
{
return new Layer(Index, CompressedBytes, Filename, ParentLayerManager)
@@ -850,5 +857,6 @@ namespace UVtools.Core
#endregion
}
}
+73
View File
@@ -37,6 +37,7 @@ namespace UVtools.Core
Flip,
Rotate,
Solidify,
Mask,
PixelDimming,
Erode,
Dilate,
@@ -188,6 +189,21 @@ namespace UVtools.Core
#region Methods
/// <summary>
/// Rebuild layer properties based on slice settings
/// </summary>
public void RebuildLayersProperties()
{
var layerHeight = SlicerFile.LayerHeight;
for (uint layerIndex = 0; layerIndex < Count; layerIndex++)
{
var layer = this[layerIndex];
layer.Index = layerIndex;
layer.PositionZ = (float) Math.Round(layerHeight * (layerIndex + 1), 2);
layer.ExposureTime = SlicerFile.GetInitialLayerValueOrNormal(layerIndex, SlicerFile.InitialExposureTime, SlicerFile.LayerExposureTime);
}
}
public Rectangle GetBoundingRectangle(OperationProgress progress = null)
{
if (!_boundingRectangle.IsEmpty) return _boundingRectangle;
@@ -391,6 +407,24 @@ namespace UVtools.Core
progress.Token.ThrowIfCancellationRequested();
}
public void MutateMask(uint startLayerIndex, uint endLayerIndex, Mat mask, OperationProgress progress = null)
{
if (ReferenceEquals(progress, null)) progress = new OperationProgress();
progress.Reset("Masking pixels", endLayerIndex - startLayerIndex + 1);
Parallel.For(startLayerIndex, endLayerIndex + 1, layerIndex =>
{
if (progress.Token.IsCancellationRequested) return;
this[layerIndex].MutateMask(mask);
lock (progress.Mutex)
{
progress++;
}
});
progress.Token.ThrowIfCancellationRequested();
}
public void MutatePixelDimming(uint startLayerIndex, uint endLayerIndex, Matrix<byte> evenPattern = null, Matrix<byte> oddPattern = null, ushort borderSize = 5, OperationProgress progress = null)
{
if (ReferenceEquals(progress, null)) progress = new OperationProgress();
@@ -1331,6 +1365,45 @@ namespace UVtools.Core
progress.Token.ThrowIfCancellationRequested();
}
public void CloneLayer(uint layerIndexStart, uint layerIndexEnd, uint clones = 1, OperationProgress progress = null)
{
var oldLayers = Layers;
uint totalClones = (layerIndexEnd - layerIndexStart + 1) * clones;
uint newLayerCount = Count + totalClones;
Layers = new Layer[newLayerCount];
progress.Reset("Cloned layers", totalClones);
uint newLayerIndex = 0;
for (uint layerIndex = 0; layerIndex < oldLayers.Length; layerIndex++)
{
Layers[newLayerIndex] = oldLayers[layerIndex];
if (layerIndex >= layerIndexStart && layerIndex <= layerIndexEnd)
{
for (uint i = 0; i < clones; i++)
{
newLayerIndex++;
Layers[newLayerIndex] = oldLayers[layerIndex].Clone();
Layers[newLayerIndex].IsModified = true;
progress++;
}
}
newLayerIndex++;
}
SlicerFile.LayerCount = Count;
BoundingRectangle = Rectangle.Empty;
SlicerFile.RequireFullEncode = true;
RebuildLayersProperties();
progress.Token.ThrowIfCancellationRequested();
}
public void RemoveLayer(uint layerIndex) => RemoveLayer(layerIndex, layerIndex);
public void RemoveLayer(uint layerIndexStart, uint layerIndexEnd)
+2 -2
View File
@@ -14,8 +14,8 @@
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyVersion>0.6.6.1</AssemblyVersion>
<FileVersion>0.6.6.1</FileVersion>
<AssemblyVersion>0.6.7.0</AssemblyVersion>
<FileVersion>0.6.7.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+475
View File
@@ -0,0 +1,475 @@
using UVtools.GUI.Controls;
namespace UVtools.GUI.Forms
{
partial class FrmMutationMask
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMutationMask));
this.lbDescription = new System.Windows.Forms.Label();
this.lbLayerRange = new System.Windows.Forms.Label();
this.nmLayerRangeStart = new System.Windows.Forms.NumericUpDown();
this.nmLayerRangeEnd = new System.Windows.Forms.NumericUpDown();
this.lbLayerRangeTo = new System.Windows.Forms.Label();
this.cmLayerRange = new System.Windows.Forms.ContextMenuStrip(this.components);
this.btnLayerRangeAllLayers = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeCurrentLayer = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeBottomLayers = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeNormalLayers = new System.Windows.Forms.ToolStripMenuItem();
this.btnCancel = new System.Windows.Forms.Button();
this.btnMutate = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton();
this.btnImportImageMask = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pbMask = new System.Windows.Forms.PictureBox();
this.lbPrinterResolution = new System.Windows.Forms.Label();
this.lbMaskResolution = new System.Windows.Forms.Label();
this.cbInvertMask = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.nmGeneratorMinBrightness = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.nmGeneratorMaxBrightness = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.nmGeneratorDiameter = new System.Windows.Forms.NumericUpDown();
this.btnMaskGenerate = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit();
this.cmLayerRange.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbMask)).BeginInit();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).BeginInit();
this.SuspendLayout();
//
// lbDescription
//
this.lbDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbDescription.Location = new System.Drawing.Point(13, 14);
this.lbDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbDescription.Name = "lbDescription";
this.lbDescription.Size = new System.Drawing.Size(584, 128);
this.lbDescription.TabIndex = 0;
this.lbDescription.Text = "Description";
//
// lbLayerRange
//
this.lbLayerRange.AutoSize = true;
this.lbLayerRange.Location = new System.Drawing.Point(13, 150);
this.lbLayerRange.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbLayerRange.Name = "lbLayerRange";
this.lbLayerRange.Size = new System.Drawing.Size(97, 20);
this.lbLayerRange.TabIndex = 9;
this.lbLayerRange.Text = "Layer range:";
this.toolTip.SetToolTip(this.lbLayerRange, resources.GetString("lbLayerRange.ToolTip"));
//
// nmLayerRangeStart
//
this.nmLayerRangeStart.Location = new System.Drawing.Point(118, 147);
this.nmLayerRangeStart.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nmLayerRangeStart.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.nmLayerRangeStart.Name = "nmLayerRangeStart";
this.nmLayerRangeStart.Size = new System.Drawing.Size(120, 26);
this.nmLayerRangeStart.TabIndex = 0;
//
// nmLayerRangeEnd
//
this.nmLayerRangeEnd.Location = new System.Drawing.Point(314, 147);
this.nmLayerRangeEnd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nmLayerRangeEnd.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.nmLayerRangeEnd.Name = "nmLayerRangeEnd";
this.nmLayerRangeEnd.Size = new System.Drawing.Size(120, 26);
this.nmLayerRangeEnd.TabIndex = 1;
//
// lbLayerRangeTo
//
this.lbLayerRangeTo.AutoSize = true;
this.lbLayerRangeTo.Location = new System.Drawing.Point(275, 150);
this.lbLayerRangeTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbLayerRangeTo.Name = "lbLayerRangeTo";
this.lbLayerRangeTo.Size = new System.Drawing.Size(31, 20);
this.lbLayerRangeTo.TabIndex = 12;
this.lbLayerRangeTo.Text = "To:";
//
// cmLayerRange
//
this.cmLayerRange.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btnLayerRangeAllLayers,
this.btnLayerRangeCurrentLayer,
this.btnLayerRangeBottomLayers,
this.btnLayerRangeNormalLayers});
this.cmLayerRange.Name = "cmLayerRange";
this.cmLayerRange.Size = new System.Drawing.Size(226, 92);
//
// btnLayerRangeAllLayers
//
this.btnLayerRangeAllLayers.Name = "btnLayerRangeAllLayers";
this.btnLayerRangeAllLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.A)));
this.btnLayerRangeAllLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeAllLayers.Text = "&All Layers";
this.btnLayerRangeAllLayers.Click += new System.EventHandler(this.ItemClicked);
//
// btnLayerRangeCurrentLayer
//
this.btnLayerRangeCurrentLayer.Name = "btnLayerRangeCurrentLayer";
this.btnLayerRangeCurrentLayer.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.C)));
this.btnLayerRangeCurrentLayer.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeCurrentLayer.Text = "&Current Layer";
this.btnLayerRangeCurrentLayer.Click += new System.EventHandler(this.ItemClicked);
//
// btnLayerRangeBottomLayers
//
this.btnLayerRangeBottomLayers.Name = "btnLayerRangeBottomLayers";
this.btnLayerRangeBottomLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.B)));
this.btnLayerRangeBottomLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeBottomLayers.Text = "&Bottom Layers";
this.btnLayerRangeBottomLayers.Click += new System.EventHandler(this.ItemClicked);
//
// btnLayerRangeNormalLayers
//
this.btnLayerRangeNormalLayers.Name = "btnLayerRangeNormalLayers";
this.btnLayerRangeNormalLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.N)));
this.btnLayerRangeNormalLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeNormalLayers.Text = "&Normal Layers";
this.btnLayerRangeNormalLayers.Click += new System.EventHandler(this.ItemClicked);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Image = global::UVtools.GUI.Properties.Resources.Cancel_24x24;
this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnCancel.Location = new System.Drawing.Point(434, 733);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(150, 48);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "&Cancel";
this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.ItemClicked);
//
// btnMutate
//
this.btnMutate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnMutate.Enabled = false;
this.btnMutate.Image = global::UVtools.GUI.Properties.Resources.Ok_24x24;
this.btnMutate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnMutate.Location = new System.Drawing.Point(276, 733);
this.btnMutate.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnMutate.Name = "btnMutate";
this.btnMutate.Size = new System.Drawing.Size(150, 48);
this.btnMutate.TabIndex = 5;
this.btnMutate.Text = "&Mutate";
this.btnMutate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnMutate.UseVisualStyleBackColor = true;
this.btnMutate.Click += new System.EventHandler(this.ItemClicked);
//
// toolTip
//
this.toolTip.AutoPopDelay = 32767;
this.toolTip.InitialDelay = 500;
this.toolTip.IsBalloon = true;
this.toolTip.ReshowDelay = 100;
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.toolTip.ToolTipTitle = "Information";
//
// btnLayerRangeSelect
//
this.btnLayerRangeSelect.Location = new System.Drawing.Point(446, 146);
this.btnLayerRangeSelect.Menu = this.cmLayerRange;
this.btnLayerRangeSelect.Name = "btnLayerRangeSelect";
this.btnLayerRangeSelect.Size = new System.Drawing.Size(138, 26);
this.btnLayerRangeSelect.TabIndex = 2;
this.btnLayerRangeSelect.Text = "Select";
this.btnLayerRangeSelect.UseVisualStyleBackColor = true;
//
// btnImportImageMask
//
this.btnImportImageMask.Location = new System.Drawing.Point(17, 181);
this.btnImportImageMask.Name = "btnImportImageMask";
this.btnImportImageMask.Size = new System.Drawing.Size(417, 32);
this.btnImportImageMask.TabIndex = 31;
this.btnImportImageMask.Text = "Import grayscale mask image from file";
this.btnImportImageMask.UseVisualStyleBackColor = true;
this.btnImportImageMask.Click += new System.EventHandler(this.ItemClicked);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.pbMask);
this.groupBox1.Location = new System.Drawing.Point(14, 387);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(567, 335);
this.groupBox1.TabIndex = 32;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Mask image";
//
// pbMask
//
this.pbMask.Dock = System.Windows.Forms.DockStyle.Fill;
this.pbMask.Location = new System.Drawing.Point(3, 22);
this.pbMask.Name = "pbMask";
this.pbMask.Size = new System.Drawing.Size(561, 310);
this.pbMask.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbMask.TabIndex = 0;
this.pbMask.TabStop = false;
//
// lbPrinterResolution
//
this.lbPrinterResolution.AutoSize = true;
this.lbPrinterResolution.Location = new System.Drawing.Point(13, 322);
this.lbPrinterResolution.Name = "lbPrinterResolution";
this.lbPrinterResolution.Size = new System.Drawing.Size(136, 20);
this.lbPrinterResolution.TabIndex = 33;
this.lbPrinterResolution.Text = "Printer resolution: ";
//
// lbMaskResolution
//
this.lbMaskResolution.AutoSize = true;
this.lbMaskResolution.Location = new System.Drawing.Point(13, 352);
this.lbMaskResolution.Name = "lbMaskResolution";
this.lbMaskResolution.Size = new System.Drawing.Size(207, 20);
this.lbMaskResolution.TabIndex = 34;
this.lbMaskResolution.Text = "Mask resolution: (Unloaded)";
//
// cbInvertMask
//
this.cbInvertMask.AutoSize = true;
this.cbInvertMask.Location = new System.Drawing.Point(446, 186);
this.cbInvertMask.Name = "cbInvertMask";
this.cbInvertMask.Size = new System.Drawing.Size(110, 24);
this.cbInvertMask.TabIndex = 35;
this.cbInvertMask.Text = "Invert Mask";
this.cbInvertMask.UseVisualStyleBackColor = true;
this.cbInvertMask.CheckedChanged += new System.EventHandler(this.ItemClicked);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnMaskGenerate);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.nmGeneratorDiameter);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.nmGeneratorMaxBrightness);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.nmGeneratorMinBrightness);
this.groupBox2.Location = new System.Drawing.Point(17, 219);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(564, 96);
this.groupBox2.TabIndex = 36;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Mask Generator (Round from center)";
//
// nmGeneratorMinBrightness
//
this.nmGeneratorMinBrightness.Location = new System.Drawing.Point(166, 25);
this.nmGeneratorMinBrightness.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nmGeneratorMinBrightness.Name = "nmGeneratorMinBrightness";
this.nmGeneratorMinBrightness.Size = new System.Drawing.Size(78, 26);
this.nmGeneratorMinBrightness.TabIndex = 0;
this.nmGeneratorMinBrightness.Value = new decimal(new int[] {
200,
0,
0,
0});
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(154, 20);
this.label1.TabIndex = 35;
this.label1.Text = "Minimum brightness:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(320, 28);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(158, 20);
this.label2.TabIndex = 37;
this.label2.Text = "Maximum brightness:";
//
// nmGeneratorMaxBrightness
//
this.nmGeneratorMaxBrightness.Location = new System.Drawing.Point(480, 25);
this.nmGeneratorMaxBrightness.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.nmGeneratorMaxBrightness.Name = "nmGeneratorMaxBrightness";
this.nmGeneratorMaxBrightness.Size = new System.Drawing.Size(78, 26);
this.nmGeneratorMaxBrightness.TabIndex = 36;
this.nmGeneratorMaxBrightness.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(255, 28);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 20);
this.label3.TabIndex = 38;
this.label3.Text = "(0-255)";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 60);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(137, 20);
this.label4.TabIndex = 40;
this.label4.Text = "Diameter in pixels:";
//
// nmGeneratorDiameter
//
this.nmGeneratorDiameter.Location = new System.Drawing.Point(166, 57);
this.nmGeneratorDiameter.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.nmGeneratorDiameter.Name = "nmGeneratorDiameter";
this.nmGeneratorDiameter.Size = new System.Drawing.Size(78, 26);
this.nmGeneratorDiameter.TabIndex = 39;
//
// btnMaskGenerate
//
this.btnMaskGenerate.Location = new System.Drawing.Point(259, 57);
this.btnMaskGenerate.Name = "btnMaskGenerate";
this.btnMaskGenerate.Size = new System.Drawing.Size(299, 26);
this.btnMaskGenerate.TabIndex = 41;
this.btnMaskGenerate.Text = "Generate";
this.btnMaskGenerate.UseVisualStyleBackColor = true;
this.btnMaskGenerate.Click += new System.EventHandler(this.ItemClicked);
//
// FrmMutationMask
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(599, 795);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.cbInvertMask);
this.Controls.Add(this.lbMaskResolution);
this.Controls.Add(this.lbPrinterResolution);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnImportImageMask);
this.Controls.Add(this.btnLayerRangeSelect);
this.Controls.Add(this.lbLayerRangeTo);
this.Controls.Add(this.nmLayerRangeEnd);
this.Controls.Add(this.nmLayerRangeStart);
this.Controls.Add(this.lbLayerRange);
this.Controls.Add(this.btnMutate);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.lbDescription);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmMutationMask";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Form1";
this.TopMost = true;
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).EndInit();
this.cmLayerRange.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbMask)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbDescription;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnMutate;
private System.Windows.Forms.Label lbLayerRange;
private System.Windows.Forms.NumericUpDown nmLayerRangeStart;
private System.Windows.Forms.NumericUpDown nmLayerRangeEnd;
private System.Windows.Forms.Label lbLayerRangeTo;
private Controls.SplitButton btnLayerRangeSelect;
private System.Windows.Forms.ContextMenuStrip cmLayerRange;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeAllLayers;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeCurrentLayer;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeBottomLayers;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeNormalLayers;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Button btnImportImageMask;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.PictureBox pbMask;
private System.Windows.Forms.Label lbPrinterResolution;
private System.Windows.Forms.Label lbMaskResolution;
private System.Windows.Forms.CheckBox cbInvertMask;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown nmGeneratorMaxBrightness;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown nmGeneratorMinBrightness;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.NumericUpDown nmGeneratorDiameter;
private System.Windows.Forms.Button btnMaskGenerate;
}
}
+232
View File
@@ -0,0 +1,232 @@
/*
* 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.Drawing;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using UVtools.Core.Extensions;
namespace UVtools.GUI.Forms
{
public partial class FrmMutationMask : Form
{
#region Properties
private Mutation Mutation { get; }
public uint LayerRangeStart
{
get => (uint) nmLayerRangeStart.Value;
set => nmLayerRangeStart.Value = value;
}
public uint LayerRangeEnd
{
get => (uint)Math.Min(nmLayerRangeEnd.Value, Program.SlicerFile.LayerCount-1);
set => nmLayerRangeEnd.Value = value;
}
public Mat Mask { get; private set; }
#endregion
#region Constructors
public FrmMutationMask(Mutation mutation)
{
InitializeComponent();
Mutation = mutation;
Text = $"Mutate: {mutation.MenuName}";
lbDescription.Text = Mutation.Description;
nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
lbPrinterResolution.Text = $"Printer Resolution: {Program.FrmMain.ActualLayerImage.Size}";
}
#endregion
#region Overrides
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.KeyCode == Keys.Enter)
{
btnMutate.PerformClick();
e.Handled = true;
return;
}
if ((ModifierKeys & Keys.Shift) == Keys.Shift && (ModifierKeys & Keys.Control) == Keys.Control)
{
if (e.KeyCode == Keys.A)
{
btnLayerRangeAllLayers.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.C)
{
btnLayerRangeCurrentLayer.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.B)
{
btnLayerRangeBottomLayers.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.N)
{
btnLayerRangeNormalLayers.PerformClick();
e.Handled = true;
return;
}
}
}
#endregion
#region Events
private void ItemClicked(object sender, EventArgs e)
{
if (ReferenceEquals(sender, btnLayerRangeAllLayers))
{
nmLayerRangeStart.Value = 0;
nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
return;
}
if (ReferenceEquals(sender, btnLayerRangeCurrentLayer))
{
nmLayerRangeStart.Value = Program.FrmMain.ActualLayer;
nmLayerRangeEnd.Value = Program.FrmMain.ActualLayer;
return;
}
if (ReferenceEquals(sender, btnLayerRangeBottomLayers))
{
nmLayerRangeStart.Value = 0;
nmLayerRangeEnd.Value = Program.SlicerFile.InitialLayerCount-1;
return;
}
if (ReferenceEquals(sender, btnLayerRangeNormalLayers))
{
nmLayerRangeStart.Value = Program.SlicerFile.InitialLayerCount - 1;
nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1;
return;
}
if (ReferenceEquals(sender, btnImportImageMask))
{
using (var fileOpen = new OpenFileDialog
{
CheckFileExists = true,
Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF"
})
{
if (fileOpen.ShowDialog() != DialogResult.OK) return;
Mask = CvInvoke.Imread(fileOpen.FileName, ImreadModes.Grayscale);
if (Mask.Size != Program.FrmMain.ActualLayerImage.Size)
{
CvInvoke.Resize(Mask, Mask, Program.FrmMain.ActualLayerImage.Size);
}
if (cbInvertMask.Checked)
{
CvInvoke.BitwiseNot(Mask, Mask);
}
lbMaskResolution.Text = $"Mask Resolution: {Mask.Size}";
pbMask.Image = Mask.ToBitmap();
btnMutate.Enabled = true;
}
return;
}
if (ReferenceEquals(sender, cbInvertMask))
{
CvInvoke.BitwiseNot(Mask, Mask);
pbMask.Image = Mask.ToBitmap();
return;
}
if (ReferenceEquals(sender, btnMaskGenerate))
{
Mask = Program.FrmMain.ActualLayerImage.CloneBlank();
lbMaskResolution.Text = $"Mask Resolution: {Mask.Size}";
int radius = (int) nmGeneratorDiameter.Value;
if (radius == 0)
{
radius = Math.Min(Mask.Width, Mask.Height) / 2;
}
else
{
radius = radius.Clamp(2, Math.Min(Mask.Width, Mask.Height)) / 2;
}
var maxScalar = new MCvScalar((double)nmGeneratorMaxBrightness.Value);
Mask.SetTo(maxScalar);
var center = new Point(Mask.Width / 2, Mask.Height / 2);
var colorDifference = nmGeneratorMinBrightness.Value - nmGeneratorMaxBrightness.Value;
//CvInvoke.Circle(Mask, center, radius, minScalar, -1);
for (decimal i = 1; i < radius; i++)
{
int color = (int) (nmGeneratorMinBrightness.Value - i / radius * colorDifference); //or some another color calculation
CvInvoke.Circle(Mask, center, (int) i, new MCvScalar(color), 2);
}
if (cbInvertMask.Checked)
CvInvoke.BitwiseNot(Mask, Mask);
pbMask.Image = Mask.ToBitmap();
btnMutate.Enabled = true;
return;
}
if (ReferenceEquals(sender, btnMutate))
{
if (!btnMutate.Enabled) return;
if (LayerRangeStart > LayerRangeEnd)
{
MessageBox.Show("Layer range start can't be higher than layer end.\nPlease fix and try again.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
nmLayerRangeStart.Select();
return;
}
if (MessageBox.Show($"Are you sure you want to {Mutation.Mutate}?", Text, MessageBoxButtons.YesNo,
MessageBoxIcon.Question) != DialogResult.Yes) return;
DialogResult = DialogResult.OK;
Close();
return;
}
if (ReferenceEquals(sender, btnCancel))
{
Mask?.Dispose();
DialogResult = DialogResult.Cancel;
return;
}
}
#endregion
}
}
+131
View File
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>148, 17</value>
</metadata>
<data name="lbLayerRange.ToolTip" xml:space="preserve">
<value>Selects the layers range within start layer and end layer where mutator will operate.
Select same layer start as end to operate only within that layer.
Note: "Layer Start" start can't be higher than "Layer End".</value>
</data>
<metadata name="cmLayerRange.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+27
View File
@@ -79,7 +79,9 @@ namespace UVtools.GUI.Forms
this.nmInfillThickness = new System.Windows.Forms.NumericUpDown();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.btnImportImageMask = new System.Windows.Forms.Button();
this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton();
this.btnDimPatternStrips = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit();
this.cmLayerRange.SuspendLayout();
@@ -366,6 +368,7 @@ namespace UVtools.GUI.Forms
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnDimPatternStrips);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.btnDimPatternWaves);
this.groupBox1.Controls.Add(this.btnPatternRandom);
@@ -645,6 +648,17 @@ namespace UVtools.GUI.Forms
this.label10.TabIndex = 21;
this.label10.Text = "Thickness:";
//
// btnImportImageMask
//
this.btnImportImageMask.Location = new System.Drawing.Point(314, 181);
this.btnImportImageMask.Name = "btnImportImageMask";
this.btnImportImageMask.Size = new System.Drawing.Size(273, 32);
this.btnImportImageMask.TabIndex = 30;
this.btnImportImageMask.Text = "Import grayscale image as mask";
this.btnImportImageMask.UseVisualStyleBackColor = true;
this.btnImportImageMask.Visible = false;
this.btnImportImageMask.Click += new System.EventHandler(this.ItemClicked);
//
// btnLayerRangeSelect
//
this.btnLayerRangeSelect.Location = new System.Drawing.Point(446, 146);
@@ -655,12 +669,23 @@ namespace UVtools.GUI.Forms
this.btnLayerRangeSelect.Text = "Select";
this.btnLayerRangeSelect.UseVisualStyleBackColor = true;
//
// btnDimPatternStrips
//
this.btnDimPatternStrips.Location = new System.Drawing.Point(332, 25);
this.btnDimPatternStrips.Name = "btnDimPatternStrips";
this.btnDimPatternStrips.Size = new System.Drawing.Size(94, 35);
this.btnDimPatternStrips.TabIndex = 31;
this.btnDimPatternStrips.Text = "Strips";
this.btnDimPatternStrips.UseVisualStyleBackColor = true;
this.btnDimPatternStrips.Click += new System.EventHandler(this.ItemClicked);
//
// FrmMutationPixelDimming
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(599, 916);
this.Controls.Add(this.btnImportImageMask);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
@@ -756,5 +781,7 @@ namespace UVtools.GUI.Forms
private System.Windows.Forms.NumericUpDown nmInfillSpacing;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Button btnImportImageMask;
private System.Windows.Forms.Button btnDimPatternStrips;
}
}
@@ -11,6 +11,7 @@ using System.Globalization;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.CvEnum;
using UVtools.Core.Extensions;
namespace UVtools.GUI.Forms
@@ -151,6 +152,43 @@ namespace UVtools.GUI.Forms
return;
}
if (ReferenceEquals(sender, btnImportImageMask))
{
using (var fileOpen = new OpenFileDialog
{
CheckFileExists = true,
Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF"
})
{
if (fileOpen.ShowDialog() != DialogResult.OK) return;
using (var image = CvInvoke.Imread(fileOpen.FileName, ImreadModes.Grayscale))
{
StringBuilder sb = new StringBuilder();
for (int y = 0; y < image.Height; y++)
{
var span = image.GetPixelRowSpan<byte>(y);
string line = string.Empty;
for (int x = 0; x < span.Length; x++)
{
line += $"{span[x]} ";
}
line = line.Trim();
sb.Append(line);
if(y < image.Height-1)
sb.AppendLine();
}
tbEvenPattern.Text = sb.ToString();
tbOddPattern.Text = string.Empty;
}
}
return;
}
if (ReferenceEquals(sender, btnDimPatternChessBoard))
{
tbEvenPattern.Text = string.Format(
@@ -199,6 +237,21 @@ namespace UVtools.GUI.Forms
return;
}
if (ReferenceEquals(sender, btnDimPatternStrips))
{
tbEvenPattern.Text = string.Format(
"{0}{1}" +
"255"
, nmPixelDimBrightness.Value, Environment.NewLine);
tbOddPattern.Text = string.Format(
"255{1}" +
"{0}"
, nmPixelDimBrightness.Value, Environment.NewLine);
return;
}
if (ReferenceEquals(sender, btnDimPatternRhombus))
{
+316
View File
@@ -0,0 +1,316 @@
using UVtools.GUI.Controls;
namespace UVtools.GUI.Forms
{
partial class FrmToolLayerClone
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmToolLayerClone));
this.lbDescription = new System.Windows.Forms.Label();
this.lbLayerRange = new System.Windows.Forms.Label();
this.nmLayerRangeStart = new System.Windows.Forms.NumericUpDown();
this.nmLayerRangeEnd = new System.Windows.Forms.NumericUpDown();
this.lbLayerRangeTo = new System.Windows.Forms.Label();
this.cmLayerRange = new System.Windows.Forms.ContextMenuStrip(this.components);
this.btnLayerRangeAllLayers = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeCurrentLayer = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeBottomLayers = new System.Windows.Forms.ToolStripMenuItem();
this.btnLayerRangeNormalLayers = new System.Windows.Forms.ToolStripMenuItem();
this.label4 = new System.Windows.Forms.Label();
this.nmClones = new System.Windows.Forms.NumericUpDown();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOk = new System.Windows.Forms.Button();
this.lbLayersCount = new System.Windows.Forms.Label();
this.lbHeights = new System.Windows.Forms.Label();
this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit();
this.cmLayerRange.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nmClones)).BeginInit();
this.SuspendLayout();
//
// lbDescription
//
this.lbDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbDescription.Location = new System.Drawing.Point(13, 14);
this.lbDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbDescription.Name = "lbDescription";
this.lbDescription.Size = new System.Drawing.Size(584, 39);
this.lbDescription.TabIndex = 0;
this.lbDescription.Text = "Clone layers, usefull to fix a model height, for structural parts and fix raft he" +
"igth.";
//
// lbLayerRange
//
this.lbLayerRange.AutoSize = true;
this.lbLayerRange.Location = new System.Drawing.Point(13, 62);
this.lbLayerRange.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbLayerRange.Name = "lbLayerRange";
this.lbLayerRange.Size = new System.Drawing.Size(97, 20);
this.lbLayerRange.TabIndex = 9;
this.lbLayerRange.Text = "Layer range:";
//
// nmLayerRangeStart
//
this.nmLayerRangeStart.Location = new System.Drawing.Point(118, 59);
this.nmLayerRangeStart.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nmLayerRangeStart.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.nmLayerRangeStart.Name = "nmLayerRangeStart";
this.nmLayerRangeStart.Size = new System.Drawing.Size(120, 26);
this.nmLayerRangeStart.TabIndex = 0;
this.nmLayerRangeStart.ValueChanged += new System.EventHandler(this.EventValueChanged);
//
// nmLayerRangeEnd
//
this.nmLayerRangeEnd.Location = new System.Drawing.Point(314, 59);
this.nmLayerRangeEnd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nmLayerRangeEnd.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.nmLayerRangeEnd.Name = "nmLayerRangeEnd";
this.nmLayerRangeEnd.Size = new System.Drawing.Size(120, 26);
this.nmLayerRangeEnd.TabIndex = 1;
this.nmLayerRangeEnd.ValueChanged += new System.EventHandler(this.EventValueChanged);
//
// lbLayerRangeTo
//
this.lbLayerRangeTo.AutoSize = true;
this.lbLayerRangeTo.Location = new System.Drawing.Point(275, 62);
this.lbLayerRangeTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbLayerRangeTo.Name = "lbLayerRangeTo";
this.lbLayerRangeTo.Size = new System.Drawing.Size(31, 20);
this.lbLayerRangeTo.TabIndex = 12;
this.lbLayerRangeTo.Text = "To:";
//
// cmLayerRange
//
this.cmLayerRange.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btnLayerRangeAllLayers,
this.btnLayerRangeCurrentLayer,
this.btnLayerRangeBottomLayers,
this.btnLayerRangeNormalLayers});
this.cmLayerRange.Name = "cmLayerRange";
this.cmLayerRange.Size = new System.Drawing.Size(226, 92);
//
// btnLayerRangeAllLayers
//
this.btnLayerRangeAllLayers.Name = "btnLayerRangeAllLayers";
this.btnLayerRangeAllLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.A)));
this.btnLayerRangeAllLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeAllLayers.Text = "&All Layers";
this.btnLayerRangeAllLayers.Click += new System.EventHandler(this.EventClick);
//
// btnLayerRangeCurrentLayer
//
this.btnLayerRangeCurrentLayer.Name = "btnLayerRangeCurrentLayer";
this.btnLayerRangeCurrentLayer.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.C)));
this.btnLayerRangeCurrentLayer.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeCurrentLayer.Text = "&Current Layer";
this.btnLayerRangeCurrentLayer.Click += new System.EventHandler(this.EventClick);
//
// btnLayerRangeBottomLayers
//
this.btnLayerRangeBottomLayers.Name = "btnLayerRangeBottomLayers";
this.btnLayerRangeBottomLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.B)));
this.btnLayerRangeBottomLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeBottomLayers.Text = "&Bottom Layers";
this.btnLayerRangeBottomLayers.Click += new System.EventHandler(this.EventClick);
//
// btnLayerRangeNormalLayers
//
this.btnLayerRangeNormalLayers.Name = "btnLayerRangeNormalLayers";
this.btnLayerRangeNormalLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.N)));
this.btnLayerRangeNormalLayers.Size = new System.Drawing.Size(225, 22);
this.btnLayerRangeNormalLayers.Text = "&Normal Layers";
this.btnLayerRangeNormalLayers.Click += new System.EventHandler(this.EventClick);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(48, 96);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(62, 20);
this.label4.TabIndex = 21;
this.label4.Text = "Clones:";
//
// nmClones
//
this.nmClones.Location = new System.Drawing.Point(118, 93);
this.nmClones.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.nmClones.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nmClones.Name = "nmClones";
this.nmClones.Size = new System.Drawing.Size(121, 26);
this.nmClones.TabIndex = 19;
this.nmClones.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nmClones.ValueChanged += new System.EventHandler(this.EventValueChanged);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Image = global::UVtools.GUI.Properties.Resources.Cancel_24x24;
this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnCancel.Location = new System.Drawing.Point(434, 196);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(150, 48);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "&Cancel";
this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.EventClick);
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnOk.Image = global::UVtools.GUI.Properties.Resources.Ok_24x24;
this.btnOk.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnOk.Location = new System.Drawing.Point(276, 196);
this.btnOk.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(150, 48);
this.btnOk.TabIndex = 5;
this.btnOk.Text = "&Clone";
this.btnOk.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.EventClick);
//
// lbLayersCount
//
this.lbLayersCount.AutoSize = true;
this.lbLayersCount.Location = new System.Drawing.Point(13, 137);
this.lbLayersCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbLayersCount.Name = "lbLayersCount";
this.lbLayersCount.Size = new System.Drawing.Size(56, 20);
this.lbLayersCount.TabIndex = 22;
this.lbLayersCount.Text = "Layers";
//
// lbHeights
//
this.lbHeights.AutoSize = true;
this.lbHeights.Location = new System.Drawing.Point(13, 161);
this.lbHeights.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbHeights.Name = "lbHeights";
this.lbHeights.Size = new System.Drawing.Size(56, 20);
this.lbHeights.TabIndex = 23;
this.lbHeights.Text = "Height";
//
// btnLayerRangeSelect
//
this.btnLayerRangeSelect.Location = new System.Drawing.Point(446, 58);
this.btnLayerRangeSelect.Menu = this.cmLayerRange;
this.btnLayerRangeSelect.Name = "btnLayerRangeSelect";
this.btnLayerRangeSelect.Size = new System.Drawing.Size(138, 26);
this.btnLayerRangeSelect.TabIndex = 2;
this.btnLayerRangeSelect.Text = "Select";
this.btnLayerRangeSelect.UseVisualStyleBackColor = true;
//
// FrmToolLayerClone
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(599, 258);
this.Controls.Add(this.lbHeights);
this.Controls.Add(this.lbLayersCount);
this.Controls.Add(this.btnLayerRangeSelect);
this.Controls.Add(this.lbLayerRangeTo);
this.Controls.Add(this.nmLayerRangeEnd);
this.Controls.Add(this.nmLayerRangeStart);
this.Controls.Add(this.lbLayerRange);
this.Controls.Add(this.btnOk);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.label4);
this.Controls.Add(this.lbDescription);
this.Controls.Add(this.nmClones);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmToolLayerClone";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Pattern";
this.TopMost = true;
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).EndInit();
this.cmLayerRange.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.nmClones)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbDescription;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Label lbLayerRange;
private System.Windows.Forms.NumericUpDown nmLayerRangeStart;
private System.Windows.Forms.NumericUpDown nmLayerRangeEnd;
private System.Windows.Forms.Label lbLayerRangeTo;
private System.Windows.Forms.ContextMenuStrip cmLayerRange;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeAllLayers;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeCurrentLayer;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeBottomLayers;
private System.Windows.Forms.ToolStripMenuItem btnLayerRangeNormalLayers;
private System.Windows.Forms.NumericUpDown nmClones;
private System.Windows.Forms.Label label4;
private SplitButton btnLayerRangeSelect;
private System.Windows.Forms.Label lbLayersCount;
private System.Windows.Forms.Label lbHeights;
}
}
+164
View File
@@ -0,0 +1,164 @@
/*
* 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.Windows.Forms;
namespace UVtools.GUI.Forms
{
public partial class FrmToolLayerClone : Form
{
#region Properties
public uint LayerRangeStart
{
get => (uint) nmLayerRangeStart.Value;
set => nmLayerRangeStart.Value = value;
}
public uint LayerRangeEnd
{
get => (uint)Math.Min(nmLayerRangeEnd.Value, Program.SlicerFile.LayerCount-1);
set => nmLayerRangeEnd.Value = value;
}
public uint Clones => (uint) nmClones.Value;
#endregion
#region Constructors
public FrmToolLayerClone(int layerIndex = -1)
{
InitializeComponent();
//nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1;
if (layerIndex > 0)
{
nmLayerRangeStart.Value =
nmLayerRangeEnd.Value = layerIndex;
}
EventValueChanged(nmClones, null);
}
#endregion
#region Overrides
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.KeyCode == Keys.Enter)
{
btnOk.PerformClick();
e.Handled = true;
return;
}
if ((ModifierKeys & Keys.Shift) == Keys.Shift && (ModifierKeys & Keys.Control) == Keys.Control)
{
if (e.KeyCode == Keys.A)
{
btnLayerRangeAllLayers.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.C)
{
btnLayerRangeCurrentLayer.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.B)
{
btnLayerRangeBottomLayers.PerformClick();
e.Handled = true;
return;
}
if (e.KeyCode == Keys.N)
{
btnLayerRangeNormalLayers.PerformClick();
e.Handled = true;
return;
}
}
}
#endregion
#region Events
private void EventClick(object sender, EventArgs e)
{
if (ReferenceEquals(sender, btnLayerRangeAllLayers))
{
nmLayerRangeStart.Value = 0;
nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
return;
}
if (ReferenceEquals(sender, btnLayerRangeCurrentLayer))
{
nmLayerRangeStart.Value = Program.FrmMain.ActualLayer;
nmLayerRangeEnd.Value = Program.FrmMain.ActualLayer;
return;
}
if (ReferenceEquals(sender, btnLayerRangeBottomLayers))
{
nmLayerRangeStart.Value = 0;
nmLayerRangeEnd.Value = Program.SlicerFile.InitialLayerCount-1;
return;
}
if (ReferenceEquals(sender, btnLayerRangeNormalLayers))
{
nmLayerRangeStart.Value = Program.SlicerFile.InitialLayerCount - 1;
nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1;
return;
}
if (ReferenceEquals(sender, btnOk))
{
if (!btnOk.Enabled) return;
if (LayerRangeStart > LayerRangeEnd)
{
MessageBox.Show("Layer range start can't be higher than layer end.\nPlease fix and try again.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
nmLayerRangeStart.Select();
return;
}
if (MessageBox.Show($"Are you sure you want to clone the selected layers times {nmClones.Value}?", Text, MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
DialogResult = DialogResult.OK;
Close();
}
return;
}
if (ReferenceEquals(sender, btnCancel))
{
DialogResult = DialogResult.Cancel;
return;
}
}
#endregion
private void EventValueChanged(object sender, EventArgs e)
{
uint extraLayers = (uint) Math.Max(0, (nmLayerRangeEnd.Value - nmLayerRangeStart.Value + 1) * nmClones.Value);
float extraHeight = (float) Math.Round(extraLayers * Program.SlicerFile.LayerHeight, 2);
lbLayersCount.Text = $"Layers: {Program.SlicerFile.TotalHeight} → {Program.SlicerFile.TotalHeight + extraLayers} (+ {extraLayers})";
lbHeights.Text = $"Heights: {Program.SlicerFile.TotalHeight}mm → {Program.SlicerFile.TotalHeight + extraHeight}mm (+ {extraHeight}mm)";
}
}
}
File diff suppressed because it is too large Load Diff
-2
View File
@@ -250,7 +250,5 @@ namespace UVtools.GUI.Forms
return true;
}
#endregion
}
}
+27 -1
View File
@@ -51,6 +51,7 @@
this.menuToolsRepairLayers = new System.Windows.Forms.ToolStripMenuItem();
this.menuToolsChangeResolution = new System.Windows.Forms.ToolStripMenuItem();
this.menuToolsLayerReHeight = new System.Windows.Forms.ToolStripMenuItem();
this.menuToolsLayerClone = new System.Windows.Forms.ToolStripMenuItem();
this.menuToolsLayerRemoval = new System.Windows.Forms.ToolStripMenuItem();
this.menuToolsPattern = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -84,6 +85,7 @@
this.tsLayerImagePixelEdit = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator();
this.tsLayerRmove = new System.Windows.Forms.ToolStripButton();
this.tsLayerClone = new System.Windows.Forms.ToolStripButton();
this.tsLayerInfo = new System.Windows.Forms.ToolStrip();
this.tsLayerPreviewTime = new System.Windows.Forms.ToolStripLabel();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
@@ -474,6 +476,7 @@
this.menuToolsRepairLayers,
this.menuToolsChangeResolution,
this.menuToolsLayerReHeight,
this.menuToolsLayerClone,
this.menuToolsLayerRemoval,
this.menuToolsPattern});
this.menuTools.Enabled = false;
@@ -510,6 +513,15 @@
this.menuToolsLayerReHeight.Text = "Layer Re-&Height";
this.menuToolsLayerReHeight.Click += new System.EventHandler(this.EventClick);
//
// menuToolsLayerClone
//
this.menuToolsLayerClone.Enabled = false;
this.menuToolsLayerClone.Image = global::UVtools.GUI.Properties.Resources.layers_alt_16x16;
this.menuToolsLayerClone.Name = "menuToolsLayerClone";
this.menuToolsLayerClone.Size = new System.Drawing.Size(261, 22);
this.menuToolsLayerClone.Text = "Layer &Clone";
this.menuToolsLayerClone.Click += new System.EventHandler(this.EventClick);
//
// menuToolsLayerRemoval
//
this.menuToolsLayerRemoval.Enabled = false;
@@ -677,7 +689,8 @@
this.toolStripSeparator9,
this.tsLayerImagePixelEdit,
this.toolStripSeparator18,
this.tsLayerRmove});
this.tsLayerRmove,
this.tsLayerClone});
this.tsLayer.Location = new System.Drawing.Point(0, 0);
this.tsLayer.Name = "tsLayer";
this.tsLayer.Size = new System.Drawing.Size(1228, 25);
@@ -848,6 +861,17 @@
this.tsLayerRmove.ToolTipText = "Delete current layer";
this.tsLayerRmove.Click += new System.EventHandler(this.EventClick);
//
// tsLayerClone
//
this.tsLayerClone.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsLayerClone.Image = global::UVtools.GUI.Properties.Resources.copy_16x16;
this.tsLayerClone.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsLayerClone.Name = "tsLayerClone";
this.tsLayerClone.Size = new System.Drawing.Size(89, 22);
this.tsLayerClone.Text = "Clone Layer";
this.tsLayerClone.ToolTipText = "Clone current layer";
this.tsLayerClone.Click += new System.EventHandler(this.EventClick);
//
// tsLayerInfo
//
this.tsLayerInfo.Dock = System.Windows.Forms.DockStyle.Bottom;
@@ -3071,6 +3095,8 @@
private System.Windows.Forms.ToolStripLabel tsLayerImagePixelCount;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator17;
private System.Windows.Forms.ToolStripLabel tsLayerBounds;
private System.Windows.Forms.ToolStripButton tsLayerClone;
private System.Windows.Forms.ToolStripMenuItem menuToolsLayerClone;
}
}
+72 -5
View File
@@ -46,30 +46,36 @@ namespace UVtools.GUI
{
{LayerManager.Mutate.Move, new Mutation(LayerManager.Mutate.Move, null, Resources.move_16x16,
"Moves the entire print volume around the plate.\n" +
"Note: Margins are in pixel values"
"Note: Margins are in pixel values."
)},
{LayerManager.Mutate.Resize, new Mutation(LayerManager.Mutate.Resize, null, Resources.crop_16x16,
"Resizes layer images in a X and/or Y factor, starting from 100% value\n" +
"Resizes layer images in a X and/or Y factor, starting from 100% value.\n" +
"NOTE 1: Build volume bounds are not validated after operation, please ensure scaling stays inside your limits.\n" +
"NOTE 2: X and Y are applied to original image, not to the rotated preview (If enabled)."
)},
{LayerManager.Mutate.Flip, new Mutation(LayerManager.Mutate.Flip, null, Resources.flip_16x16,
"Flips layer images vertically and/or horizontally"
"Flips layer images vertically and/or horizontally."
)},
{LayerManager.Mutate.Rotate, new Mutation(LayerManager.Mutate.Rotate, null, Resources.refresh_16x16,
"Rotate layer images in a certain degrees"
"Rotate layer images in a certain degrees."
)},
{LayerManager.Mutate.Solidify, new Mutation(LayerManager.Mutate.Solidify, null, Resources.square_solid_16x16,
"Solidifies the selected layers, closes all inner holes.\n" +
"Warning: All surrounded holes are filled, no exceptions! Make sure you don't require any of holes in layer path.",
Resources.mutation_solidify
)},
{LayerManager.Mutate.Mask, new Mutation(LayerManager.Mutate.Mask, "Mask", Resources.mask_16x16,
"Masks the LCD output image given a greyscale (0-255) pixel input image.\n" +
"Useful to correct light uniformity, but a proper mask must be created first based on real measurements per printer.\n" +
"NOTE 1: Masks should respect printer resolution or they will be resized to fit.\n" +
"NOTE 2: Run only this tool after all repairs and other transformations."
)},
{LayerManager.Mutate.PixelDimming, new Mutation(LayerManager.Mutate.PixelDimming, "Pixel Dimming", Resources.chessboard_16x16,
"Dims pixels in a chosen pattern over white pixels neighborhood. The selected pattern will be repeated over the image width and height as a mask. Benefits are:\n" +
"1) Reduce layer expansion in big masses\n" +
"2) Reduce cross layer exposure\n" +
"3) Extend pixels life\n" +
"NOTE: Run only this tool after all repairs and other transformations"
"NOTE: Run only this tool after all repairs and other transformations."
)},
{LayerManager.Mutate.Erode, new Mutation(LayerManager.Mutate.Erode, null, Resources.compress_alt_16x16,
"The basic idea of erosion is just like soil erosion only, it erodes away the boundaries of foreground object (Always try to keep foreground in white). " +
@@ -1088,6 +1094,52 @@ namespace UVtools.GUI
}
}
if (ReferenceEquals(sender, menuToolsLayerClone) || ReferenceEquals(sender, tsLayerClone))
{
using (var frm = new FrmToolLayerClone(ReferenceEquals(sender, menuToolsLayerClone) ? -1 : (int)ActualLayer))
{
if (frm.ShowDialog() != DialogResult.OK) return;
DisableGUI();
FrmLoading.SetDescription($"Layer clone from {frm.LayerRangeStart} to {frm.LayerRangeEnd}");
var task = Task.Factory.StartNew(() =>
{
try
{
SlicerFile.LayerManager.CloneLayer(frm.LayerRangeStart, frm.LayerRangeEnd, frm.Clones, FrmLoading.RestartProgress());
}
catch (OperationCanceledException)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
Invoke((MethodInvoker)delegate
{
// Running on the UI thread
EnableGUI(true);
});
}
});
var loadingResult = FrmLoading.ShowDialog();
UpdateLayerLimits();
RefreshInfo();
ShowLayer();
menuFileSave.Enabled =
menuFileSaveAs.Enabled = true;
}
return;
}
if (ReferenceEquals(sender, menuNewVersion))
{
try
@@ -3163,6 +3215,8 @@ namespace UVtools.GUI
double x = 0;
double y = 0;
Mat mat = null;
Matrix<byte> evenPattern = null;
Matrix<byte> oddPattern = null;
@@ -3219,6 +3273,15 @@ namespace UVtools.GUI
layerEnd = inputBox.LayerRangeEnd;
}
break;
case LayerManager.Mutate.Mask:
using (FrmMutationMask inputBox = new FrmMutationMask(Mutations[mutator]))
{
if (inputBox.ShowDialog() != DialogResult.OK) return;
layerStart = inputBox.LayerRangeStart;
layerEnd = inputBox.LayerRangeEnd;
mat = inputBox.Mask;
}
break;
case LayerManager.Mutate.PixelDimming:
using (FrmMutationPixelDimming inputBox = new FrmMutationPixelDimming(Mutations[mutator]))
{
@@ -3315,6 +3378,10 @@ namespace UVtools.GUI
case LayerManager.Mutate.Solidify:
SlicerFile.LayerManager.MutateSolidify(layerStart, layerEnd, progress);
break;
case LayerManager.Mutate.Mask:
SlicerFile.LayerManager.MutateMask(layerStart, layerEnd, mat, progress);
mat?.Dispose();
break;
case LayerManager.Mutate.PixelDimming:
SlicerFile.LayerManager.MutatePixelDimming(layerStart, layerEnd, evenPattern, oddPattern, (ushort) iterationsStart, progress);
break;
+2 -2
View File
@@ -158,7 +158,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk
FAAAAk1TRnQBSQFMAgEBBgEAAeABCAHgAQgBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
FAAAAk1TRnQBSQFMAgEBBgEAAQgBCQEIAQkBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUDMAAQEDJAE2AysBQqwAAyIBMQNWAbkDXQHi
AwAB/wMAAf8BKgEtASgB/gNTAawDTQGVAwABARgAAwkBDAMzAVIDUAGdA1cB6AMAAf4DKwH8Ay8BSqQA
AyEBMANZAewBKwEuASkB+gNRAfcDUgH0A1MB8QNIAfYDQQH5AwAB/wNPAZsDAAEBCAADFQEdAz8BbgNV
@@ -206,7 +206,7 @@
BAADUgGpAzQBVQM0AVUgAAM0AVUDNAFVA1IBqQgAA0oBiwMAAf8DAAH/A08BnAQAA00BlQMAAf8DVAGr
CAADTwGcAwAB/wMAAf8DSgGLBAADUQGgAQABzAH3Af8BAAHMAfcB/wEAAcwB9wH/AQABzAH3Af8DQwF3
CAADSgGNAgAB7AH/AgAB7AH/AgAB7wH/AgAB7AH/AgAB7AH/AgAB7QH/AVICUwGoA1IBqAMAAf8DAAH/
AwAB/wNRAfcDIwH9A1ABnwsAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNSAagEAANSAakDNAFVAzQBVQNG
AwAB/wNRAfcDKAH9A1ABnwsAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNSAagEAANSAakDNAFVAzQBVQNG
AYADUgGpA1IBqQNSAakDUgGpA1IBqQNSAakDRQF/AzQBVQM0AVUDUgGpBAADUQGiAwAB/wMAAf8DSQGJ
CAADLwFKAwAB/wNUAe4MAANJAYkDAAH/AwAB/wNRAaIDAAEBAT8CQAFvAT4CXAH4AQABzQH3Af8BAAHN
AfcB/wMSARgIAAMBAQIDRgF+AlIBXQHwAgAB7gH/AgAB7gH/AkABqAH9AUUCRgF+AwMBBANSAagDAAH/
Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

+2 -2
View File
@@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.6.1")]
[assembly: AssemblyFileVersion("0.6.6.1")]
[assembly: AssemblyVersion("0.6.7.0")]
[assembly: AssemblyFileVersion("0.6.7.0")]
+20
View File
@@ -280,6 +280,16 @@ namespace UVtools.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap copy_16x16 {
get {
object obj = ResourceManager.GetObject("copy_16x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@@ -530,6 +540,16 @@ namespace UVtools.GUI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap mask_16x16 {
get {
object obj = ResourceManager.GetObject("mask-16x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
+8 -2
View File
@@ -139,6 +139,9 @@
<data name="layers-alt-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\layers-alt-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="mask-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\mask-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Back-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\Back-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -166,6 +169,9 @@
<data name="CNCMachine-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\CNCMachine-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="list-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\list-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="UVtools" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\UVtools.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -352,7 +358,7 @@
<data name="expand-alt-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\expand-alt-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="list-16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\list-16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="copy_16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Images\copy_16x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
+20
View File
@@ -168,6 +168,12 @@
<Compile Include="Forms\FrmMutationBlur.Designer.cs">
<DependentUpon>FrmMutationBlur.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FrmMutationMask.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\FrmMutationMask.Designer.cs">
<DependentUpon>FrmMutationMask.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FrmMutationThreshold.cs">
<SubType>Form</SubType>
</Compile>
@@ -198,6 +204,12 @@
<Compile Include="Forms\FrmToolEmpty.Designer.cs">
<DependentUpon>FrmToolEmpty.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FrmToolLayerClone.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\FrmToolLayerClone.Designer.cs">
<DependentUpon>FrmToolLayerClone.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FrmToolPattern.cs">
<SubType>Form</SubType>
</Compile>
@@ -286,6 +298,9 @@
<EmbeddedResource Include="Forms\FrmMutationBlur.resx">
<DependentUpon>FrmMutationBlur.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FrmMutationMask.resx">
<DependentUpon>FrmMutationMask.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FrmMutationThreshold.resx">
<DependentUpon>FrmMutationThreshold.cs</DependentUpon>
</EmbeddedResource>
@@ -301,6 +316,9 @@
<EmbeddedResource Include="Forms\FrmToolEmpty.resx">
<DependentUpon>FrmToolEmpty.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FrmToolLayerClone.resx">
<DependentUpon>FrmToolLayerClone.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FrmToolPattern.resx">
<DependentUpon>FrmToolPattern.cs</DependentUpon>
</EmbeddedResource>
@@ -404,6 +422,8 @@
<None Include="Images\burn-16x16.png" />
<None Include="Images\th-16x16.png" />
<None Include="Images\list-16x16.png" />
<None Include="Images\mask-16x16.png" />
<None Include="Images\copy_16x16.png" />
<Content Include="UVtools.ico" />
<None Include="UVtools.png" />
<None Include="Images\Exit-16x16.png" />