Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate svg and gcode code from FormsUI #1102

Open
wants to merge 117 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
27735cc
Start to separate
RafaelEstevamReis Aug 21, 2020
7a6f799
Move CsPotrace and SvgLibrary
RafaelEstevamReis Aug 21, 2020
f7905e5
Migrate Tools, remove usings and fix spacings
RafaelEstevamReis Aug 21, 2020
d511b3e
Move ExpressionEvaluator
RafaelEstevamReis Aug 21, 2020
fa94f05
Refactor
RafaelEstevamReis Aug 21, 2020
e884daf
Move Dithering
RafaelEstevamReis Aug 21, 2020
fb4936d
Refactor
RafaelEstevamReis Aug 21, 2020
77a998b
Move ImageTransform and ImageProcessor
RafaelEstevamReis Aug 21, 2020
88aaa6b
Refactor
RafaelEstevamReis Aug 21, 2020
7c69d5e
Separate Cyotek namespace
RafaelEstevamReis Aug 21, 2020
0c110ed
Spaces and usings
RafaelEstevamReis Aug 21, 2020
9a1b4f2
Move CSV
RafaelEstevamReis Aug 21, 2020
452ab9e
Refactor
RafaelEstevamReis Aug 21, 2020
02dc270
Separate ProgramRange, and Element from GrblCommand
RafaelEstevamReis Aug 21, 2020
134f744
Refactor
RafaelEstevamReis Aug 21, 2020
ad3b096
Refactor and format
RafaelEstevamReis Aug 21, 2020
0fee0b4
Separate GPoint
RafaelEstevamReis Aug 21, 2020
2080938
Separate GrblCore classes
RafaelEstevamReis Aug 21, 2020
1d85feb
Separate ThreadingMode
RafaelEstevamReis Aug 21, 2020
9a059bf
Separate ImageProcessor Enums
RafaelEstevamReis Aug 21, 2020
b2a376d
Separate L2LConf
RafaelEstevamReis Aug 21, 2020
635f243
Separate GrblCore Enums
RafaelEstevamReis Aug 22, 2020
2c50d05
Separate ModalElement
RafaelEstevamReis Aug 22, 2020
b400ed9
Remove Settings dependency
RafaelEstevamReis Aug 22, 2020
5c088bc
Remove full qualifiers
RafaelEstevamReis Aug 22, 2020
6374470
Move Settings
RafaelEstevamReis Aug 22, 2020
1231020
Remove dependency from Kernal specific HiResTimer
RafaelEstevamReis Aug 22, 2020
a0eb144
Move Constants
RafaelEstevamReis Aug 22, 2020
d7a7ae3
Change Constants
RafaelEstevamReis Aug 22, 2020
85f8f95
Move GCodeFromSVG
RafaelEstevamReis Aug 22, 2020
ee1bb0f
Move GCodeFromSVG
RafaelEstevamReis Aug 22, 2020
ba02ab6
Move CommandStatus enum
RafaelEstevamReis Aug 22, 2020
b1fa22d
Update GrblEnums.cs
RafaelEstevamReis Aug 22, 2020
38430d9
Update GrblEnums.cs
RafaelEstevamReis Aug 22, 2020
1950ff9
Move IsSetWCO to Command
RafaelEstevamReis Aug 22, 2020
7e3d010
Update GrblCommand whitespaces
RafaelEstevamReis Aug 22, 2020
5ab3346
Move GrblCommand and StateBuilder
RafaelEstevamReis Aug 22, 2020
fc1e5ee
Move autotrace
RafaelEstevamReis Aug 22, 2020
4a84ff8
Migrate GrblFile and ImageProcessor
RafaelEstevamReis Aug 22, 2020
4d62a78
Separate CsPotrace
RafaelEstevamReis Aug 22, 2020
d446121
Move MS SVG
RafaelEstevamReis Aug 22, 2020
afcfe6c
Changed local WebSocket to NuGet package
RafaelEstevamReis Aug 22, 2020
602f2a6
Make autotrace call Linux friendly
RafaelEstevamReis Aug 22, 2020
8aacbe1
Cleanup
RafaelEstevamReis Aug 22, 2020
7e9bc98
Move Utils class
RafaelEstevamReis Aug 22, 2020
ed4aa4a
Move WinAPI
RafaelEstevamReis Aug 22, 2020
2130e54
Cleanup
RafaelEstevamReis Aug 22, 2020
5600482
Cleanup
RafaelEstevamReis Aug 22, 2020
c5d59ed
Separate OSVersionInfo
RafaelEstevamReis Aug 22, 2020
c33c2e7
Move OSHelper
RafaelEstevamReis Aug 22, 2020
4bf0a82
Isolate OS info access
RafaelEstevamReis Aug 22, 2020
d1dd095
Separate Timings Invoke
RafaelEstevamReis Aug 22, 2020
a9752cd
Isolate WinAPI calls
RafaelEstevamReis Aug 22, 2020
933954a
Cleanup
RafaelEstevamReis Aug 22, 2020
ba92d82
Reduce #if complexity
RafaelEstevamReis Aug 22, 2020
01ac62e
Timing port
RafaelEstevamReis Aug 22, 2020
196127e
Move HiResTimer
RafaelEstevamReis Aug 22, 2020
f44d1ba
Use stopwatch
RafaelEstevamReis Aug 22, 2020
c3c48f6
Simplify TimeFromApplicationStartup
RafaelEstevamReis Aug 22, 2020
47b96c4
Separete old from new method
RafaelEstevamReis Aug 22, 2020
2cb5449
Cleanup
RafaelEstevamReis Aug 22, 2020
2190591
Command processor
RafaelEstevamReis Aug 22, 2020
4b77e91
Image to GCode prototypes
RafaelEstevamReis Aug 22, 2020
3bd4e50
Fix command Help
RafaelEstevamReis Aug 22, 2020
3587df1
CsPotrace complete
RafaelEstevamReis Aug 22, 2020
e8a10f4
Cyotek.Drawing Complete
RafaelEstevamReis Aug 22, 2020
556abfa
MSSVG Partial
RafaelEstevamReis Aug 22, 2020
0219c3c
Partial Lib
RafaelEstevamReis Aug 22, 2020
2f60a97
Removed System.Windows.Media reference
RafaelEstevamReis Aug 22, 2020
669fdbb
Is compilling again
RafaelEstevamReis Aug 22, 2020
dfae913
Old files
RafaelEstevamReis Aug 22, 2020
81b1499
Completed Forms UI
RafaelEstevamReis Aug 22, 2020
56ac56b
Old files
RafaelEstevamReis Aug 22, 2020
ebc3aad
Completed Console
RafaelEstevamReis Aug 22, 2020
db86387
Old files
RafaelEstevamReis Aug 22, 2020
2f47e87
Revert file
RafaelEstevamReis Aug 22, 2020
5bf264c
Merge pull request #1 from RafaelEstevamReis/DotNet-Core
RafaelEstevamReis Aug 22, 2020
524333d
Create dotnet-core.yml
RafaelEstevamReis Aug 22, 2020
292bf3b
Create dotnet-core-desktop.yml
RafaelEstevamReis Aug 22, 2020
c2ce5d2
Wrong action
RafaelEstevamReis Aug 22, 2020
fd3eeb0
Update README.md
RafaelEstevamReis Aug 22, 2020
f318fe0
Release Only, do not upload
RafaelEstevamReis Aug 22, 2020
a7401ed
Separate CsPotrace classes to different files
RafaelEstevamReis Aug 29, 2020
29df564
Create CsPotrace Unittest project
RafaelEstevamReis Aug 29, 2020
3a73642
Fix region
RafaelEstevamReis Aug 29, 2020
d6d0734
Remov Tuple.cs
RafaelEstevamReis Aug 29, 2020
ce82c81
Remove Point Struct
RafaelEstevamReis Aug 29, 2020
8f18a65
Separate Bitmap_p
RafaelEstevamReis Aug 29, 2020
51d572c
Moved Path, Sum and privcurve
RafaelEstevamReis Aug 29, 2020
e6038f4
Moved Quad
RafaelEstevamReis Aug 29, 2020
ae1eaa2
Starting to move static helpers
RafaelEstevamReis Aug 29, 2020
581ee85
Move static 'auxiliary functions'
RafaelEstevamReis Aug 29, 2020
7b8a25d
Update CsPotrace.cs
RafaelEstevamReis Aug 29, 2020
05b7538
Make CsPotrace non-static
RafaelEstevamReis Aug 29, 2020
9e73fab
Remove more static fields
RafaelEstevamReis Aug 29, 2020
ee289c1
Add Potrace tests
RafaelEstevamReis Aug 29, 2020
1901c13
Remove Vector2
RafaelEstevamReis Aug 29, 2020
2e1c7c1
Cleanup
RafaelEstevamReis Aug 30, 2020
3c6aa71
Added Copyright on files
RafaelEstevamReis Aug 30, 2020
bf68307
Added ArcTests
RafaelEstevamReis Aug 30, 2020
9f3056c
Replace internal Complex for the System.Numerics one
RafaelEstevamReis Aug 30, 2020
9f5458e
Add CubicBezier tests
RafaelEstevamReis Aug 30, 2020
ce247d8
Fix IsClockwise error
RafaelEstevamReis Aug 30, 2020
a9a0815
CubicBezierTests
RafaelEstevamReis Aug 30, 2020
ca5c3a5
Remove unused summary
RafaelEstevamReis Aug 30, 2020
23ac99e
Fix spacing
RafaelEstevamReis Aug 30, 2020
cc55922
Refactor bitmap
RafaelEstevamReis Aug 30, 2020
b5a7e28
Add BitmapPTests
RafaelEstevamReis Aug 30, 2020
e8f6400
Improve readability
RafaelEstevamReis Aug 30, 2020
daa2f66
Add BitmapP Flip Tests
RafaelEstevamReis Aug 30, 2020
f75f888
Reduce number of calls
RafaelEstevamReis Aug 30, 2020
f59f8ab
Create dotnet-core.yml
RafaelEstevamReis Aug 30, 2020
7627352
Test workflow
RafaelEstevamReis Aug 30, 2020
519829e
Update dotnet-core.yml
RafaelEstevamReis Aug 30, 2020
d6ab999
Add DotNet Framework compatibility (4.6.1)
RafaelEstevamReis Sep 4, 2020
cf5cdd6
Update README.md
RafaelEstevamReis Sep 4, 2020
6e25ce1
Add error checking
RafaelEstevamReis Sep 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
80 changes: 80 additions & 0 deletions .github/workflows/dotnet-core-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow will build, test, sign and package a WPF or Windows Forms desktop application
# built on .NET Core.
# To learn how to migrate your existing application to .NET Core,
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
#
# To configure this workflow:
#
# 1. Configure environment variables
# GitHub sets default environment variables for every workflow run.
# Replace the variables relative to your project in the "env" section below.
#
# 2. Signing
# Generate a signing certificate in the Windows Application
# Packaging Project or add an existing signing certificate to the project.
# Next, use PowerShell to encode the .pfx file using Base64 encoding
# by running the following Powershell script to generate the output string:
#
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
#
# Open the output file, SigningCertificate_Encoded.txt, and copy the
# string inside. Then, add the string to the repo as a GitHub secret
# and name it "Base64_Encoded_Pfx."
# For more information on how to configure your signing certificate for
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
#
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
# See "Build the Windows Application Packaging project" below to see how the secret is used.
#
# For more information on GitHub Actions, refer to https://github.com/features/actions
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
# refer to https://github.com/microsoft/github-actions-for-desktop-apps

name: .NET Core Desktop

on:
#push:
# branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:

strategy:
matrix:
configuration: [Release]

runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

env:
Solution_Name: LaserGRBL.sln # Replace with your solution name, i.e. MyWpfApp.sln.
#Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16

# Execute all unit tests in the solution
#- name: Execute unit tests
# run: dotnet test
30 changes: 30 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: .NET Core

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Install dependencies
run: |
dotnet restore ./CsPotrace/CsPotrace.csproj
dotnet restore ./Cyotek.Drawing/Cyotek.Drawing.csproj
dotnet restore ./LaserGRBL.Lib/LaserGRBL.Lib.csproj
dotnet restore ./LaserGRBL.CmdLine/LaserGRBL.CmdLine.csproj
dotnet restore ./CsPotrace.UnitTest/CsPotrace.UnitTest.csproj
- name: Build
run: dotnet build LaserGRBL.CmdLine --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
164 changes: 164 additions & 0 deletions CsPotrace.UnitTest/BezierToBiarcTests/ArcTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
using CsPotrace.BezierToBiarc;
using Newtonsoft.Json.Bson;
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using Xunit;

namespace CsPotrace.UnitTest.BezierToBiarcTests
{
// A lot of this tests were implemented long after the library was in-use,
// My first goal is to asssure that what was woking will continue working the SAME way
// If any bug appears, it will be frozen broken in this tests and will be fixed later

public class ArcTests
{
// Is already stated at Arc class that are redundant information

const int floatPrecision = 6;

[Fact]
public void CsPotrace_Arc_EmptyCtorIsZero()
{
var arc = new Arc();
Assert.Equal(0f, arc.C.X);
Assert.Equal(0f, arc.C.Y);

Assert.Equal(0f, arc.r);
Assert.Equal(0f, arc.startAngle);
Assert.Equal(0f, arc.sweepAngle);

Assert.Equal(0f, arc.P1.X);
Assert.Equal(0f, arc.P1.Y);
Assert.Equal(0f, arc.P2.X);
Assert.Equal(0f, arc.P2.Y);
}
[Fact]
public void CsPotrace_Arc_EmptyCtorIsNonZero()
{
var arc = new Arc(new Vector2(0.1f, 0.2f),
0.3f, 0.4f, 0.5f,
new Vector2(0.6f, 0.7f),
new Vector2(0.8f, 0.9f));

Assert.Equal(0.1f, arc.C.X);
Assert.Equal(0.2f, arc.C.Y);

Assert.Equal(0.3f, arc.r);
Assert.Equal(0.4f, arc.startAngle);
Assert.Equal(0.5f, arc.sweepAngle);

Assert.Equal(0.6f, arc.P1.X);
Assert.Equal(0.7f, arc.P1.Y);
Assert.Equal(0.8f, arc.P2.X);
Assert.Equal(0.9f, arc.P2.Y);
}

[Fact]
public void CsPotrace_Arc_IsClockwise()
{
Arc arc = new Arc();
// as today, zero is NOT clockwise
Assert.False(arc.IsClockwise);

arc = new Arc(Vector2.Zero, 0, 0, 1, Vector2.Zero, Vector2.Zero);
Assert.True(arc.IsClockwise);

arc = new Arc(Vector2.Zero, 0, 0, -1, Vector2.Zero, Vector2.Zero);
Assert.False(arc.IsClockwise);
}

[Fact]
public void CsPotrace_Arc_PoitAt()
{
var unity = unityCircle();
// 0
Vector2Equal(unity.P1, unity.PointAt(0f));
// 2Pi
Vector2Equal(unity.P2, unity.PointAt(1f));
// 1Pi
Vector2Equal(new Vector2(0, 1), unity.PointAt(0.25f));
// 3Pi/2
Vector2Equal(new Vector2(0, -1), unity.PointAt(0.75f));
}
[Fact]
public void CsPotrace_Arc_Length()
{
var unity = unityCircle();
Assert.Equal(2 * Math.PI, unity.Length, floatPrecision);
}
[Fact]
public void CsPotrace_Arc_BiggerLength()
{
// 10x bigger, use less precision !!
var unity = biggerCircle();
Assert.Equal(20 * Math.PI, unity.Length, 4);
}
[Fact]
public void CsPotrace_Arc_HalfLength()
{
var unity = new Arc(C: Vector2.Zero,
r: 1,
startAngle: 0,
sweepAngle: (float)(Math.PI), // 180deg
P1: new Vector2(1, 0),
P2: new Vector2(-1, 0));

Assert.Equal(Math.PI, unity.Length, floatPrecision);
}
[Fact]
public void CsPotrace_Arc_LinearLength()
{
var unity = unityCircle(); // Unity Circle has a ZERO LinearLength
Assert.Equal(0, unity.LinearLength);
}
[Fact]
public void CsPotrace_Arc_HalfArcLinearLength()
{
var unity = new Arc(C: Vector2.Zero,
r: 1,
startAngle: 0,
sweepAngle: (float)(Math.PI), // 180deg
P1: new Vector2(1, 0),
P2: new Vector2(-1, 0));
Assert.Equal(2, unity.LinearLength); // From -1 to 1
}
[Fact]
public void CsPotrace_Arc_TranslatedHalfArcLinearLength()
{
var unity = new Arc(C: new Vector2(1, 1), // translated
r: 1,
startAngle: 0,
sweepAngle: (float)(Math.PI), // 180deg
P1: new Vector2(1, 0),
P2: new Vector2(-1, 0));
Assert.Equal(2, unity.LinearLength); // From -1 to 1
}

private static void Vector2Equal(Vector2 v1, Vector2 v2)
{
Assert.Equal(v1.X, v2.X, floatPrecision);
Assert.Equal(v1.Y, v2.Y, floatPrecision);
}

private static Arc unityCircle()
{
return new Arc(C: Vector2.Zero,
r: 1,
startAngle: 0,
sweepAngle: (float)(2 * Math.PI), // 360deg
P1: new Vector2(1, 0),
P2: new Vector2(1, 0));
}
private static Arc biggerCircle()
{
return new Arc(C: Vector2.Zero,
r: 10,
startAngle: 0,
sweepAngle: (float)(2 * Math.PI), // 360deg
P1: new Vector2(10, 0),
P2: new Vector2(10, 0));
}
}
}
Loading