├── .gitignore ├── README.md ├── Windows.nsi ├── build.gradle ├── fx-package.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src ├── main ├── java │ └── org │ │ └── cirqwizard │ │ ├── excellon │ │ └── ExcellonParser.java │ │ ├── fx │ │ ├── BoardDragListener.java │ │ ├── Context.java │ │ ├── Dialog.java │ │ ├── FirstRunWizard.java │ │ ├── Homing.java │ │ ├── MainApplication.java │ │ ├── MainViewController.java │ │ ├── ManualMovementController.java │ │ ├── OperationsScreenGroup.java │ │ ├── PCBPane.java │ │ ├── PCBSize.java │ │ ├── PanelPane.java │ │ ├── ScreenController.java │ │ ├── ScreenGroup.java │ │ ├── SettingsDependentScreenController.java │ │ ├── Terminal.java │ │ ├── Tool.java │ │ ├── Welcome.java │ │ ├── common │ │ │ ├── Message.java │ │ │ └── PCBPlacement.java │ │ ├── contour │ │ │ ├── ContourMilling.java │ │ │ └── InsertContourMill.java │ │ ├── controls │ │ │ ├── RealNumberTextField.java │ │ │ └── RealNumberTextFieldTableCell.java │ │ ├── dispensing │ │ │ ├── BottomDispensing.java │ │ │ ├── Dispensing.java │ │ │ ├── InsertSyringe.java │ │ │ ├── SyringeBleeding.java │ │ │ └── TopDispensing.java │ │ ├── drilling │ │ │ ├── Drilling.java │ │ │ ├── DrillingGroup.java │ │ │ ├── InsertDrill.java │ │ │ └── PCBPlacement.java │ │ ├── machining │ │ │ ├── LongProcessingMachining.java │ │ │ ├── Machining.java │ │ │ └── PCBPaneMouseHandler.java │ │ ├── misc │ │ │ ├── About.java │ │ │ ├── Firmware.java │ │ │ └── ManualDataInput.java │ │ ├── panel │ │ │ ├── OutlineCheckBoxTableCell.java │ │ │ ├── PanelController.java │ │ │ └── PanelValidator.java │ │ ├── popover │ │ │ ├── ManualControlPopOver.java │ │ │ ├── OffsetsPopOver.java │ │ │ ├── PopOverController.java │ │ │ └── SettingsPopOver.java │ │ ├── pp │ │ │ ├── ComponentPlacement.java │ │ │ ├── FeederSelection.java │ │ │ ├── InsertPPHead.java │ │ │ ├── MicroscopeController.java │ │ │ ├── PPGroup.java │ │ │ └── PlacingOverview.java │ │ ├── rubout │ │ │ ├── BottomRubout.java │ │ │ ├── InsertTool.java │ │ │ ├── Rubout.java │ │ │ └── TopRubout.java │ │ ├── services │ │ │ └── SerialInterfaceService.java │ │ ├── settings │ │ │ ├── SettingsEditor.java │ │ │ └── SettingsToolTable.java │ │ ├── traces │ │ │ ├── InsertTool.java │ │ │ ├── TraceMilling.java │ │ │ ├── TracesSettingsPopOver.java │ │ │ ├── ZOffset.java │ │ │ ├── bottom │ │ │ │ ├── BottomTraceMilling.java │ │ │ │ └── PCBPlacement.java │ │ │ └── top │ │ │ │ ├── PCBPlacement.java │ │ │ │ └── TopTraceMilling.java │ │ └── util │ │ │ ├── ExceptionAlert.java │ │ │ └── ToolbarPopup.java │ │ ├── generation │ │ ├── AbstractToolpathGenerator.java │ │ ├── AdditionalToolpathGenerator.java │ │ ├── DispensingToolpathGenerator.java │ │ ├── GenerationService.java │ │ ├── MatchedArc.java │ │ ├── MillingToolpathGenerator.java │ │ ├── ProcessingService.java │ │ ├── RasterWindow.java │ │ ├── RubOutGenerator.java │ │ ├── RubOutToolpathGenerator.java │ │ ├── RuboutToolpathGenerationService.java │ │ ├── SimpleEdgeDetector.java │ │ ├── ToolpathGenerationService.java │ │ ├── ToolpathGenerator.java │ │ ├── ToolpathMerger.java │ │ ├── Tracer.java │ │ ├── Vectorizer.java │ │ ├── gcode │ │ │ ├── DrillGCodeGenerator.java │ │ │ ├── GCodeGenerator.java │ │ │ ├── MillingGCodeGenerator.java │ │ │ ├── PasteGCodeGenerator.java │ │ │ └── TraceGCodeGenerator.java │ │ ├── optimizer │ │ │ ├── Chain.java │ │ │ ├── ChainDetector.java │ │ │ ├── Environment.java │ │ │ ├── Generation.java │ │ │ ├── OptimizationService.java │ │ │ ├── Optimizer.java │ │ │ ├── Phenotype.java │ │ │ └── TimeEstimator.java │ │ ├── outline │ │ │ └── OutlineGenerator.java │ │ └── toolpath │ │ │ ├── CircularToolpath.java │ │ │ ├── CuttingToolpath.java │ │ │ ├── DrillPoint.java │ │ │ ├── LinearToolpath.java │ │ │ ├── PPPoint.java │ │ │ ├── Toolpath.java │ │ │ ├── ToolpathPersistingException.java │ │ │ ├── ToolpathsCache.java │ │ │ ├── ToolpathsCacheKey.java │ │ │ └── ToolpathsPersistor.java │ │ ├── geom │ │ ├── Arc.java │ │ ├── Circle.java │ │ ├── Curve.java │ │ ├── Line.java │ │ ├── Point.java │ │ ├── Polygon.java │ │ └── Rect.java │ │ ├── gerber │ │ ├── CircularShape.java │ │ ├── DataBlock.java │ │ ├── Flash.java │ │ ├── GerberParser.java │ │ ├── GerberParsingException.java │ │ ├── GerberPrimitive.java │ │ ├── GroupRenderer.java │ │ ├── InterpolatingShape.java │ │ ├── LinearShape.java │ │ ├── Region.java │ │ └── appertures │ │ │ ├── Aperture.java │ │ │ ├── CircularAperture.java │ │ │ ├── OctagonalAperture.java │ │ │ ├── OvalAperture.java │ │ │ ├── PolygonalAperture.java │ │ │ ├── RectangularAperture.java │ │ │ └── macro │ │ │ ├── ApertureMacro.java │ │ │ ├── MacroCenterLine.java │ │ │ ├── MacroCircle.java │ │ │ ├── MacroOutline.java │ │ │ ├── MacroPolygon.java │ │ │ ├── MacroPrimitive.java │ │ │ └── MacroVectorLine.java │ │ ├── layers │ │ ├── Board.java │ │ ├── Layer.java │ │ ├── LayerElement.java │ │ ├── Panel.java │ │ └── PanelBoard.java │ │ ├── logging │ │ └── LoggerFactory.java │ │ ├── math │ │ └── MathUtil.java │ │ ├── post │ │ ├── PostProcessorFactory.java │ │ ├── Postprocessor.java │ │ └── RTPostprocessor.java │ │ ├── pp │ │ ├── ComponentId.java │ │ ├── Feeder.java │ │ ├── PPParser.java │ │ └── PackageAttributesCache.java │ │ ├── serial │ │ ├── CNCController.java │ │ ├── DataReceivedListener.java │ │ ├── ExecutionException.java │ │ ├── SerialException.java │ │ ├── SerialInterface.java │ │ ├── SerialInterfaceFactory.java │ │ ├── SerialInterfaceImpl.java │ │ └── SerialInterfaceStub.java │ │ ├── settings │ │ ├── ApplicationConstants.java │ │ ├── ApplicationSettings.java │ │ ├── ApplicationValues.java │ │ ├── ContourMillingSettings.java │ │ ├── DispensingSettings.java │ │ ├── DistanceUnit.java │ │ ├── DrillingSettings.java │ │ ├── ImportSettings.java │ │ ├── InsulationMillingSettings.java │ │ ├── MachineSettings.java │ │ ├── PPSettings.java │ │ ├── PersistentPreference.java │ │ ├── PickAndPlaceFormat.java │ │ ├── PredefinedLocationSettings.java │ │ ├── PreferenceGroup.java │ │ ├── PreferenceType.java │ │ ├── RubOutSettings.java │ │ ├── Settings.java │ │ ├── SettingsFactory.java │ │ ├── SettingsGroup.java │ │ ├── ToolLibrary.java │ │ ├── ToolSettings.java │ │ ├── UserPreference.java │ │ └── ZerosOmission.java │ │ └── stm32 │ │ ├── BootloaderException.java │ │ └── STM32BootLoaderInterface.java └── resources │ ├── application.png │ ├── gpl-3.0.txt │ ├── org │ └── cirqwizard │ │ └── fx │ │ ├── FirstRunWizard.fxml │ │ ├── Homing.fxml │ │ ├── MainView.fxml │ │ ├── ManualMovement.fxml │ │ ├── Orientation.fxml │ │ ├── Welcome.fxml │ │ ├── cirqwizard-linux.css │ │ ├── cirqwizard.css │ │ ├── common │ │ ├── Message.fxml │ │ └── PCBPlacement.fxml │ │ ├── crumb-focused.png │ │ ├── crumb-hover.png │ │ ├── crumb-selected-focused.png │ │ ├── crumb-selected.png │ │ ├── crumb.png │ │ ├── dispensing │ │ └── SyringeBleeding.fxml │ │ ├── icons │ │ ├── cross.png │ │ ├── flip-horizontal.png │ │ ├── gcode.png │ │ ├── rotate-ccw.png │ │ ├── rotate-cw.png │ │ ├── selection-exclude.png │ │ ├── selection-include.png │ │ ├── zoom-in.png │ │ └── zoom-out.png │ │ ├── machining │ │ └── Machining.fxml │ │ ├── misc │ │ ├── About.fxml │ │ ├── Firmware.fxml │ │ └── ManualDataInput.fxml │ │ ├── panel │ │ └── Panel.fxml │ │ ├── popover │ │ ├── ManualControl.fxml │ │ ├── Offsets.fxml │ │ └── SettingsPopOver.fxml │ │ ├── pp │ │ ├── ComponentPlacement.fxml │ │ ├── FeederSelection.fxml │ │ └── PlacingOverview.fxml │ │ ├── settings │ │ ├── SettingsEditor.fxml │ │ └── ToolTable.fxml │ │ └── traces │ │ ├── InsertTool.fxml │ │ ├── TracesSettingsPopOver.fxml │ │ └── ZOffset.fxml │ ├── package │ ├── linux │ │ └── cirQWizard.png │ ├── macosx │ │ └── cirQWizard.icns │ └── windows │ │ └── cirQWizard.ico │ └── version.number └── test └── java └── org └── cirqwizard └── test ├── excellon └── ExcellonParserTest.java ├── geom └── PolygonTest.java ├── gerber ├── EDAGerberTest.java └── GerberMacroTest.java └── pp └── PPParserTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .idea/ 3 | *.bak 4 | *.iml 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cirQWizard - Gerber to GCode converter and much more 2 | ========== 3 | 4 | cirQWizard is a cross-platform open source software designed to control PCB prototyping machines. It’s much more than Gerber to GCode converter – it generates GCode, controls the machine and guides a user through the processes of: 5 | 6 | * insulation milling 7 | * holes drilling 8 | * contour milling 9 | * solder paste dispensing 10 | * SMD components placement 11 | 12 | Compatible machines 13 | =================== 14 | As it is, it’s perfectly matched to work with [Cirqoid](http://cirqoid.com) machines. But, being open source and having modular architecture, can be adapted to any machine of your choice. Downloadable binaries for Mac OS X, Linux and Windows! Supports all EDAs capable of exporting Gerber and Excellon files. 15 | 16 | What exactly can it do? 17 | ====================== 18 | Check out illustrated [features](http://cirqwizard.org/features) list! 19 | 20 | Where can I get it? 21 | =================== 22 | See our [Downloads](http://cirqizard.org/downloads) section to find out where to get sources and binaries of the latest cirQWizard version. 23 | 24 | What if I have a question? 25 | ========================== 26 | Visit our [Forum](http://cirqwizard.org/forum) page to find our how to get in touch with us. 27 | 28 | Project's website 29 | ================= 30 | For more information about the project, as well as online users guide please visit http://cirqwizard.org/ 31 | -------------------------------------------------------------------------------- /fx-package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | releaseVersion=1.8.2 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonsalykov/cirqwizard/c7e9be6694f987e91f684ce6f7e8872e7246b88e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Mar 09 11:49:13 CET 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/BoardDragListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.fx; 15 | 16 | public interface BoardDragListener 17 | { 18 | void boardDragged(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/Dialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | 18 | public enum Dialog 19 | { 20 | INFO ("InfoDialog.fxml"); 21 | 22 | private String name; 23 | 24 | private Dialog(String name) 25 | { 26 | this.name = name; 27 | } 28 | 29 | public String getName() 30 | { 31 | return name; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/Homing.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.scene.control.Button; 19 | import javafx.scene.layout.VBox; 20 | import org.cirqwizard.fx.settings.SettingsEditor; 21 | import org.cirqwizard.settings.SettingsFactory; 22 | 23 | 24 | public class Homing extends ScreenController 25 | { 26 | @FXML private Button homeButton; 27 | @FXML private VBox axisDifferenceWarningBox; 28 | 29 | @Override 30 | protected String getFxmlName() 31 | { 32 | return "Homing.fxml"; 33 | } 34 | 35 | @Override 36 | protected String getName() 37 | { 38 | return "Homing"; 39 | } 40 | 41 | @Override 42 | public void refresh() 43 | { 44 | homeButton.setDisable(getMainApplication().getCNCController() == null); 45 | axisDifferenceWarningBox.setVisible(SettingsFactory.getMachineSettings().getYAxisDifference().getValue() == null); 46 | } 47 | 48 | public void home() 49 | { 50 | getMainApplication().getCNCController().home(SettingsFactory.getMachineSettings().getYAxisDifference().getValue()); 51 | } 52 | 53 | public void goToSettings() 54 | { 55 | getMainApplication().setCurrentScreen(getMainApplication().getScreen(SettingsEditor.class)); 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/OperationsScreenGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | public class OperationsScreenGroup extends ScreenGroup 18 | { 19 | public OperationsScreenGroup(String name) 20 | { 21 | super(name); 22 | } 23 | 24 | @Override 25 | protected boolean isEnabled() 26 | { 27 | return getMainApplication().getContext().getPanel() != null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/PCBSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | 18 | import org.cirqwizard.settings.ApplicationConstants; 19 | 20 | public enum PCBSize 21 | { 22 | Small(75 * ApplicationConstants.RESOLUTION, 100 * ApplicationConstants.RESOLUTION, 23 | ApplicationConstants.getRegistrationPinsInset(), "75x100"), 24 | Large(100 * ApplicationConstants.RESOLUTION, 160 * ApplicationConstants.RESOLUTION, 25 | ApplicationConstants.getRegistrationPinsInset(), "100x160"), 26 | XLarge(100 * ApplicationConstants.RESOLUTION, 205 * ApplicationConstants.RESOLUTION, 27 | 50 * ApplicationConstants.RESOLUTION, "100x205"); 28 | 29 | private int width; 30 | private int height; 31 | private int wcsYOffset; 32 | private String name; 33 | 34 | PCBSize(int width, int height, int wcsYOffset, String name) 35 | { 36 | this.width = width; 37 | this.height = height; 38 | this.wcsYOffset = wcsYOffset; 39 | this.name = name; 40 | } 41 | 42 | public int getWidth() 43 | { 44 | return width; 45 | } 46 | 47 | public int getHeight() 48 | { 49 | return height; 50 | } 51 | 52 | public int getWcsYOffset() 53 | { 54 | return wcsYOffset; 55 | } 56 | 57 | @Override 58 | public String toString() 59 | { 60 | return name; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/ScreenGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | public class ScreenGroup extends ScreenController 18 | { 19 | private String name; 20 | private boolean visible = true; 21 | 22 | public ScreenGroup(String name) 23 | { 24 | super(); 25 | this.name = name; 26 | } 27 | 28 | @Override 29 | protected String getName() 30 | { 31 | return name; 32 | } 33 | 34 | public void select() 35 | { 36 | for (ScreenController c : getChildren()) 37 | { 38 | if (c.isMandatory() && c.isEnabled()) 39 | { 40 | c.select(); 41 | return; 42 | } 43 | } 44 | } 45 | 46 | public boolean isVisible() 47 | { 48 | return visible; 49 | } 50 | 51 | public ScreenGroup setVisible(boolean visible) 52 | { 53 | this.visible = visible; 54 | return this; 55 | } 56 | 57 | @Override 58 | public boolean equals(Object o) 59 | { 60 | if (this == o) return true; 61 | if (o == null || getClass() != o.getClass()) return false; 62 | 63 | ScreenGroup that = (ScreenGroup) o; 64 | 65 | if (name != null ? !name.equals(that.name) : that.name != null) return false; 66 | if (getParent() != null ? !getParent().equals(that.getParent()) : that.getParent() != null) return false; 67 | 68 | return true; 69 | } 70 | 71 | @Override 72 | public int hashCode() 73 | { 74 | return name != null ? name.hashCode() : 0; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/SettingsDependentScreenController.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | import javafx.scene.layout.GridPane; 18 | 19 | public abstract class SettingsDependentScreenController extends ScreenController 20 | { 21 | public abstract void populateSettingsGroup(GridPane pane, SettingsDependentScreenController listener); 22 | public abstract void settingsInvalidated(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/Terminal.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | import org.cirqwizard.fx.common.Message; 18 | 19 | public class Terminal extends Message 20 | { 21 | @Override 22 | protected String getName() 23 | { 24 | return "All done"; 25 | } 26 | 27 | @Override 28 | public void refresh() 29 | { 30 | super.refresh(); 31 | header.setText("Congratulations!"); 32 | text.setText("You PCB is done."); 33 | continueButton.setVisible(false); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/Tool.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx; 16 | 17 | public class Tool 18 | { 19 | public static enum ToolType {V_TOOL, RUBOUT, CONTOUR_END_MILL, DRILL, SYRINGE, PICK_AND_PLACE} 20 | 21 | private ToolType type; 22 | private int diameter; 23 | 24 | public Tool(ToolType type, int diameter) 25 | { 26 | this.type = type; 27 | this.diameter = diameter; 28 | } 29 | 30 | public ToolType getType() 31 | { 32 | return type; 33 | } 34 | 35 | public int getDiameter() 36 | { 37 | return diameter; 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) 42 | { 43 | if (this == o) return true; 44 | if (o == null || getClass() != o.getClass()) return false; 45 | 46 | Tool tool = (Tool) o; 47 | 48 | if (diameter != tool.diameter) return false; 49 | if (type != tool.type) return false; 50 | 51 | return true; 52 | } 53 | 54 | @Override 55 | public int hashCode() 56 | { 57 | int result = type != null ? type.hashCode() : 0; 58 | result = 31 * result + diameter; 59 | return result; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/common/Message.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.common; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.scene.control.Button; 19 | import javafx.scene.control.Label; 20 | import org.cirqwizard.fx.ScreenController; 21 | 22 | 23 | public class Message extends ScreenController 24 | { 25 | @FXML protected Label header; 26 | @FXML protected Label text; 27 | @FXML protected Button continueButton; 28 | 29 | @Override 30 | protected String getFxmlName() 31 | { 32 | return "/org/cirqwizard/fx/common/Message.fxml"; 33 | } 34 | 35 | @Override 36 | public void next() 37 | { 38 | getMainApplication().getContext().setG54Z(null); 39 | super.next(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/common/PCBPlacement.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.common; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.scene.control.Button; 19 | import javafx.scene.control.Label; 20 | import org.cirqwizard.fx.Context; 21 | import org.cirqwizard.fx.ScreenController; 22 | 23 | 24 | public abstract class PCBPlacement extends ScreenController 25 | { 26 | @FXML protected Button continueButton; 27 | @FXML protected Label text; 28 | 29 | @Override 30 | protected String getFxmlName() 31 | { 32 | return "/org/cirqwizard/fx/common/PCBPlacement.fxml"; 33 | } 34 | 35 | @Override 36 | protected String getName() 37 | { 38 | return "Placement"; 39 | } 40 | 41 | @Override 42 | public void refresh() 43 | { 44 | Context context = getMainApplication().getContext(); 45 | context.setPcbPlacement(null); 46 | } 47 | 48 | protected abstract Context.PcbPlacement getExpectedPlacement(); 49 | 50 | @Override 51 | protected boolean isMandatory() 52 | { 53 | return !getExpectedPlacement().equals(getMainApplication().getContext().getPcbPlacement()); 54 | } 55 | 56 | @Override 57 | public void next() 58 | { 59 | getMainApplication().getContext().setPcbPlacement(getExpectedPlacement()); 60 | super.next(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/contour/InsertContourMill.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.contour; 16 | 17 | import org.cirqwizard.fx.Tool; 18 | import org.cirqwizard.fx.common.Message; 19 | import org.cirqwizard.gerber.GerberPrimitive; 20 | import org.cirqwizard.layers.Board; 21 | import org.cirqwizard.settings.ApplicationConstants; 22 | 23 | import java.text.DecimalFormat; 24 | import java.text.NumberFormat; 25 | 26 | public class InsertContourMill extends Message 27 | { 28 | private static final Tool EXPECTED_TOOL = new Tool(Tool.ToolType.CONTOUR_END_MILL, 0); 29 | private static NumberFormat diameterFormat = new DecimalFormat("0.0#"); 30 | 31 | @Override 32 | protected String getName() 33 | { 34 | return "Insert contour mill"; 35 | } 36 | 37 | @Override 38 | public void refresh() 39 | { 40 | super.refresh(); 41 | getMainApplication().getContext().setInsertedTool(null); 42 | GerberPrimitive primitive = (GerberPrimitive) getMainApplication().getContext().getPanel().getBoards().get(0).getBoard(). 43 | getLayer(Board.LayerType.MILLING).getElements().get(0); 44 | String diameter = diameterFormat.format((double)primitive.getAperture().getWidth() / ApplicationConstants.RESOLUTION); 45 | header.setText("Insert contour end mill: " + diameter + "mm"); 46 | text.setText("Insert contour end mill"); 47 | } 48 | 49 | @Override 50 | protected boolean isMandatory() 51 | { 52 | return !EXPECTED_TOOL.equals(getMainApplication().getContext().getInsertedTool()); 53 | } 54 | 55 | @Override 56 | public void next() 57 | { 58 | getMainApplication().getContext().setInsertedTool(EXPECTED_TOOL); 59 | super.next(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/controls/RealNumberTextFieldTableCell.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.fx.controls; 15 | 16 | import javafx.scene.control.TableCell; 17 | import org.cirqwizard.settings.ApplicationConstants; 18 | 19 | public class RealNumberTextFieldTableCell extends TableCell 20 | { 21 | private RealNumberTextField textField = new RealNumberTextField(); 22 | 23 | public RealNumberTextFieldTableCell() 24 | { 25 | textField.setMaxWidth(Double.MAX_VALUE); 26 | textField.setOnAction(event -> commitEdit(textField.getIntegerValue())); 27 | setText(""); 28 | } 29 | 30 | @Override 31 | public void startEdit() 32 | { 33 | super.startEdit(); 34 | setText(null); 35 | setGraphic(textField); 36 | textField.requestFocus(); 37 | } 38 | 39 | @Override 40 | public void cancelEdit() 41 | { 42 | super.cancelEdit(); 43 | setGraphic(null); 44 | setText(textField.getText()); 45 | } 46 | 47 | @Override 48 | public void commitEdit(Integer newValue) 49 | { 50 | super.commitEdit(newValue); 51 | setGraphic(null); 52 | setText(textField.getText()); 53 | } 54 | 55 | @Override 56 | protected void updateItem(Integer item, boolean empty) 57 | { 58 | super.updateItem(item, empty); 59 | if (empty || item == null) 60 | { 61 | setGraphic(null); 62 | setText(null); 63 | } 64 | textField.setIntegerValue(item); 65 | if (isEditing()) 66 | { 67 | setGraphic(textField); 68 | } 69 | else 70 | { 71 | setGraphic(null); 72 | setText(empty || item == null ? null : ApplicationConstants.formatInteger(item)); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/dispensing/BottomDispensing.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.fx.dispensing; 2 | 3 | import org.cirqwizard.layers.Board; 4 | 5 | /** 6 | * Created by simon on 29.06.17. 7 | */ 8 | public class BottomDispensing extends Dispensing 9 | { 10 | @Override 11 | protected Board.LayerType getCurrentLayer() 12 | { 13 | return Board.LayerType.SOLDER_PASTE_BOTTOM; 14 | } 15 | 16 | @Override 17 | protected boolean mirror() 18 | { 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/dispensing/InsertSyringe.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.dispensing; 16 | 17 | import org.cirqwizard.fx.Tool; 18 | import org.cirqwizard.fx.common.Message; 19 | 20 | public class InsertSyringe extends Message 21 | { 22 | public static Tool EXPECTED_TOOL = new Tool(Tool.ToolType.SYRINGE, 0); 23 | 24 | @Override 25 | protected String getName() 26 | { 27 | return "Syringe"; 28 | } 29 | 30 | @Override 31 | public void refresh() 32 | { 33 | super.refresh(); 34 | getMainApplication().getContext().setInsertedTool(null); 35 | header.setText("Insert syringe with solder paste"); 36 | text.setText("Connect it to the air outlet at the base of the machine. " + 37 | "Connect a pump to the valve on the front cover of the machine and pump the air until manometer reads 2.0 bar. " + 38 | "Do not disconnect the pump yet - you will need it again."); 39 | } 40 | 41 | @Override 42 | protected boolean isMandatory() 43 | { 44 | return !EXPECTED_TOOL.equals(getMainApplication().getContext().getInsertedTool()); 45 | } 46 | 47 | @Override 48 | public void next() 49 | { 50 | getMainApplication().getContext().setInsertedTool(EXPECTED_TOOL); 51 | super.next(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/dispensing/SyringeBleeding.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.dispensing; 16 | 17 | import javafx.scene.control.Button; 18 | import org.cirqwizard.fx.ScreenController; 19 | import javafx.fxml.FXML; 20 | import javafx.scene.Parent; 21 | import org.cirqwizard.settings.SettingsFactory; 22 | 23 | 24 | public class SyringeBleeding extends ScreenController 25 | { 26 | @FXML private Button pushButton; 27 | 28 | @Override 29 | protected String getFxmlName() 30 | { 31 | return "SyringeBleeding.fxml"; 32 | } 33 | 34 | @Override 35 | protected String getName() 36 | { 37 | return "Bleeding"; 38 | } 39 | 40 | @Override 41 | public void refresh() 42 | { 43 | pushButton.setDisable(getMainApplication().getCNCController() == null); 44 | } 45 | 46 | public void dispense() 47 | { 48 | getMainApplication().getCNCController().dispensePaste(SettingsFactory.getDispensingSettings().getBleedingDuration().getValue()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/dispensing/TopDispensing.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.fx.dispensing; 2 | 3 | import org.cirqwizard.layers.Board; 4 | 5 | /** 6 | * Created by simon on 29.06.17. 7 | */ 8 | public class TopDispensing extends Dispensing 9 | { 10 | @Override 11 | protected Board.LayerType getCurrentLayer() 12 | { 13 | return Board.LayerType.SOLDER_PASTE_TOP; 14 | } 15 | 16 | @Override 17 | protected boolean mirror() 18 | { 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/drilling/DrillingGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.drilling; 16 | 17 | import org.cirqwizard.fx.OperationsScreenGroup; 18 | import org.cirqwizard.fx.ScreenController; 19 | import org.cirqwizard.fx.ScreenGroup; 20 | import org.cirqwizard.generation.toolpath.DrillPoint; 21 | import org.cirqwizard.layers.Board; 22 | import org.cirqwizard.settings.ApplicationConstants; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | import java.util.stream.Collectors; 27 | 28 | public class DrillingGroup extends OperationsScreenGroup 29 | { 30 | public DrillingGroup(String name) 31 | { 32 | super(name); 33 | } 34 | 35 | @Override 36 | protected boolean isEnabled() 37 | { 38 | return super.isEnabled() && !getMainApplication().getContext().getPanel().getCombinedElements(Board.LayerType.DRILLING).isEmpty(); 39 | } 40 | 41 | @Override 42 | public List getChildren() 43 | { 44 | List children = new ArrayList<>(super.getChildren()); 45 | if (!isEnabled()) 46 | return children; 47 | 48 | List drillPoints = (List) getMainApplication().getContext().getPanel().getCombinedElements(Board.LayerType.DRILLING); 49 | List drillDiameters = drillPoints.stream(). 50 | map(DrillPoint::getToolDiameter). 51 | distinct(). 52 | sorted(). 53 | collect(Collectors.toList()); 54 | for (int d : drillDiameters) 55 | { 56 | ScreenGroup group = new ScreenGroup("Drilling " + ApplicationConstants.formatToolDiameter(d) + "mm") 57 | { 58 | @Override 59 | public void select() 60 | { 61 | getMainApplication().getContext().setCurrentDrill(d); 62 | super.select(); 63 | } 64 | }; 65 | group.setParent(this); 66 | children.add(group.setMainApplication(getMainApplication()). 67 | addChild(new InsertDrill().setMainApplication(getMainApplication())). 68 | addChild(new Drilling().setMainApplication(getMainApplication()))); 69 | } 70 | 71 | return children; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/drilling/InsertDrill.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.drilling; 16 | 17 | import org.cirqwizard.fx.Tool; 18 | import org.cirqwizard.fx.common.Message; 19 | import org.cirqwizard.settings.ApplicationConstants; 20 | 21 | public class InsertDrill extends Message 22 | { 23 | @Override 24 | protected String getName() 25 | { 26 | return "Insert drill"; 27 | } 28 | 29 | @Override 30 | public void refresh() 31 | { 32 | super.refresh(); 33 | getMainApplication().getContext().setInsertedTool(null); 34 | header.setText("Insert drill: " + 35 | ApplicationConstants.formatToolDiameter(getMainApplication().getContext().getCurrentDrill()) + "mm"); 36 | text.setText("Insert drill"); 37 | } 38 | 39 | @Override 40 | public void next() 41 | { 42 | getMainApplication().getContext().setInsertedTool( 43 | new Tool(Tool.ToolType.DRILL, getMainApplication().getContext().getCurrentDrill())); 44 | super.next(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/drilling/PCBPlacement.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.drilling; 16 | 17 | import org.cirqwizard.fx.Context; 18 | 19 | public class PCBPlacement extends org.cirqwizard.fx.common.PCBPlacement 20 | { 21 | @Override 22 | public void refresh() 23 | { 24 | super.refresh(); 25 | text.setText("Put the board FACE UP on the SPACER."); 26 | } 27 | 28 | @Override 29 | protected Context.PcbPlacement getExpectedPlacement() 30 | { 31 | return Context.PcbPlacement.FACE_UP_SPACER; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/misc/About.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.misc; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.fxml.Initializable; 19 | import javafx.scene.Parent; 20 | import javafx.scene.control.*; 21 | import org.cirqwizard.fx.ScreenController; 22 | import org.cirqwizard.logging.LoggerFactory; 23 | 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.net.URL; 27 | import java.util.ResourceBundle; 28 | 29 | 30 | public class About extends ScreenController implements Initializable 31 | { 32 | @FXML private Label versionLabel; 33 | @FXML private ScrollPane licensePane; 34 | 35 | @Override 36 | protected String getFxmlName() 37 | { 38 | return "/org/cirqwizard/fx/misc/About.fxml"; 39 | } 40 | 41 | @Override 42 | protected String getName() 43 | { 44 | return "About"; 45 | } 46 | 47 | @Override 48 | public void initialize(URL url, ResourceBundle resourceBundle) 49 | { 50 | InputStream input = getClass().getResourceAsStream("/version.number"); 51 | try 52 | { 53 | byte[] inputArray = new byte[input.available()]; 54 | input.read(inputArray, 0, inputArray.length); 55 | input.close(); 56 | 57 | versionLabel.setText("Version " + new String(inputArray)); 58 | } 59 | catch (IOException e) 60 | { 61 | versionLabel.setText("Unknown version"); 62 | LoggerFactory.logException("Could not open version number file: ", e); 63 | } 64 | 65 | input = getClass().getResourceAsStream("/gpl-3.0.txt"); 66 | try 67 | { 68 | byte[] inputArray = new byte[input.available()]; 69 | input.read(inputArray, 0, inputArray.length); 70 | input.close(); 71 | 72 | Label licenseText = new Label(new String(inputArray)); 73 | licenseText.setWrapText(true); 74 | licensePane.setContent(licenseText); 75 | } 76 | catch (IOException e) 77 | { 78 | licensePane.setContent(new Label("")); 79 | LoggerFactory.logException("Could not open license text file: ", e); 80 | } 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/misc/ManualDataInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.misc; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.scene.Parent; 19 | import javafx.scene.control.Button; 20 | import javafx.scene.control.Label; 21 | import javafx.scene.control.ProgressBar; 22 | import javafx.scene.control.TextArea; 23 | import javafx.scene.layout.BorderPane; 24 | import javafx.scene.layout.Region; 25 | import javafx.scene.layout.VBox; 26 | import org.cirqwizard.fx.ScreenController; 27 | import org.cirqwizard.fx.services.SerialInterfaceService; 28 | 29 | 30 | public class ManualDataInput extends ScreenController 31 | { 32 | @FXML private Region veil; 33 | @FXML private Button executeGCodeButton; 34 | @FXML private TextArea gCodeInputTextArea; 35 | @FXML private TextArea responseTextArea; 36 | 37 | @FXML private VBox executionPane; 38 | @FXML private ProgressBar executionProgressBar; 39 | @FXML private Label timeElapsedLabel; 40 | 41 | private SerialInterfaceService serialService; 42 | 43 | @Override 44 | protected String getFxmlName() 45 | { 46 | return "/org/cirqwizard/fx/misc/ManualDataInput.fxml"; 47 | } 48 | 49 | @Override 50 | protected String getName() 51 | { 52 | return "Direct GCode"; 53 | } 54 | 55 | @Override 56 | public void refresh() 57 | { 58 | boolean noMachineConnected = getMainApplication().getCNCController() == null; 59 | executeGCodeButton.setDisable(noMachineConnected); 60 | 61 | serialService = new SerialInterfaceService(getMainApplication()); 62 | executionProgressBar.progressProperty().bind(serialService.progressProperty()); 63 | timeElapsedLabel.textProperty().bind(serialService.executionTimeProperty()); 64 | executionPane.visibleProperty().bind(serialService.runningProperty()); 65 | responseTextArea.textProperty().bind(serialService.responsesProperty()); 66 | veil.visibleProperty().bind(serialService.runningProperty()); 67 | } 68 | 69 | public void executeGCode() 70 | { 71 | serialService.setProgram(gCodeInputTextArea.getText(), true, true); 72 | serialService.restart(); 73 | } 74 | 75 | public void stopExecution() 76 | { 77 | serialService.cancel(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/panel/OutlineCheckBoxTableCell.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.fx.panel; 15 | 16 | import javafx.beans.property.SimpleBooleanProperty; 17 | import javafx.scene.control.TableView; 18 | import javafx.scene.control.cell.CheckBoxTableCell; 19 | import org.cirqwizard.fx.PanelPane; 20 | import org.cirqwizard.generation.outline.OutlineGenerator; 21 | import org.cirqwizard.layers.PanelBoard; 22 | import org.cirqwizard.logging.LoggerFactory; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | 27 | public class OutlineCheckBoxTableCell extends CheckBoxTableCell 28 | { 29 | 30 | public OutlineCheckBoxTableCell(TableView boardsTable, PanelPane panelPane, File panelFile, PanelValidator validator) 31 | { 32 | super(); 33 | setSelectedStateCallback(index -> 34 | { 35 | PanelBoard board = boardsTable.getItems().get(index); 36 | SimpleBooleanProperty generate = new SimpleBooleanProperty(board.isGenerateOutline()); 37 | generate.addListener((v, oldV, newV) -> 38 | { 39 | board.setGenerateOutline(newV); 40 | if (newV) 41 | { 42 | new OutlineGenerator(board).generate(); 43 | } 44 | else 45 | { 46 | try 47 | { 48 | board.loadBoard(); 49 | } 50 | catch (IOException e) 51 | { 52 | LoggerFactory.logException("Could not load board files", e); 53 | } 54 | } 55 | validator.validateBoards(); 56 | panelPane.render(); 57 | panelPane.getPanel().save(panelFile); 58 | }); 59 | return generate; 60 | }); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/popover/OffsetsPopOver.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.popover; 16 | 17 | import javafx.event.EventHandler; 18 | import javafx.fxml.FXML; 19 | import javafx.scene.input.KeyCode; 20 | import javafx.scene.input.KeyEvent; 21 | import org.cirqwizard.fx.controls.RealNumberTextField; 22 | import org.cirqwizard.settings.SettingsFactory; 23 | 24 | public class OffsetsPopOver extends PopOverController 25 | { 26 | @FXML private RealNumberTextField xTextField; 27 | @FXML private RealNumberTextField yTextField; 28 | @FXML private RealNumberTextField zTextField; 29 | 30 | @Override 31 | protected String getFxmlName() 32 | { 33 | return "Offsets.fxml"; 34 | } 35 | 36 | @FXML 37 | public void initialize() 38 | { 39 | xTextField.realNumberIntegerProperty().addListener((v, oldV, newV) -> setX(newV)); 40 | yTextField.realNumberIntegerProperty().addListener((v, oldV, newV) -> setY(newV)); 41 | zTextField.realNumberIntegerProperty().addListener((v, oldV, newV) -> setZ(newV)); 42 | EventHandler keyEventEventHandler = event -> 43 | { 44 | if (event.getCode() == KeyCode.ESCAPE) 45 | popup.hide(); 46 | }; 47 | xTextField.setOnKeyPressed(keyEventEventHandler); 48 | yTextField.setOnKeyPressed(keyEventEventHandler); 49 | zTextField.setOnKeyPressed(keyEventEventHandler); 50 | } 51 | 52 | private void setX(Integer x) 53 | { 54 | getMainApplication().getContext().setG54X(x); 55 | SettingsFactory.getApplicationValues().getG54X().setValue(x); 56 | SettingsFactory.getApplicationValues().save(); 57 | } 58 | 59 | private void setY(Integer y) 60 | { 61 | getMainApplication().getContext().setG54Y(y); 62 | SettingsFactory.getApplicationValues().getG54Y().setValue(y); 63 | SettingsFactory.getApplicationValues().save(); 64 | } 65 | 66 | private void setZ(Integer z) 67 | { 68 | getMainApplication().getContext().setG54Z(z); 69 | } 70 | 71 | public void refresh() 72 | { 73 | xTextField.setIntegerValue(getMainApplication().getContext().getG54X()); 74 | yTextField.setIntegerValue(getMainApplication().getContext().getG54Y()); 75 | zTextField.setIntegerValue(getMainApplication().getContext().getG54Z()); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/popover/SettingsPopOver.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.popover; 16 | 17 | import javafx.fxml.FXML; 18 | import javafx.scene.layout.GridPane; 19 | import org.cirqwizard.fx.SettingsDependentScreenController; 20 | import org.cirqwizard.fx.settings.SettingsEditor; 21 | import org.cirqwizard.settings.SettingsGroup; 22 | 23 | public class SettingsPopOver extends PopOverController 24 | { 25 | @FXML private GridPane settingsPane; 26 | 27 | @Override 28 | protected String getFxmlName() 29 | { 30 | return "SettingsPopOver.fxml"; 31 | } 32 | 33 | public void setGroup(SettingsGroup group, SettingsDependentScreenController listener) 34 | { 35 | SettingsEditor.renderSettings(settingsPane, group, getMainApplication(), listener); 36 | } 37 | 38 | public GridPane getPane() 39 | { 40 | return settingsPane; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/pp/InsertPPHead.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.pp; 16 | 17 | import org.cirqwizard.fx.Tool; 18 | import org.cirqwizard.fx.common.Message; 19 | 20 | public class InsertPPHead extends Message 21 | { 22 | private final static Tool EXPECTED_TOOL = new Tool(Tool.ToolType.PICK_AND_PLACE, 0); 23 | 24 | @Override 25 | protected String getName() 26 | { 27 | return "Insert P&P head"; 28 | } 29 | 30 | @Override 31 | public void refresh() 32 | { 33 | super.refresh(); 34 | getMainApplication().getContext().setInsertedTool(null); 35 | header.setText("Insert pick & place head"); 36 | text.setText("Connect it to the vacuum outlet at the base of the machine and to the socket. Choose a needle that will work for your components."); 37 | 38 | } 39 | @Override 40 | protected boolean isMandatory() 41 | { 42 | return !EXPECTED_TOOL.equals(getMainApplication().getContext().getInsertedTool()); 43 | } 44 | 45 | @Override 46 | public void next() 47 | { 48 | getMainApplication().getContext().setInsertedTool(EXPECTED_TOOL); 49 | super.next(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/rubout/BottomRubout.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.rubout; 16 | 17 | import org.cirqwizard.fx.Context; 18 | import org.cirqwizard.fx.PCBPane; 19 | import org.cirqwizard.layers.Board; 20 | 21 | public class BottomRubout extends Rubout 22 | { 23 | @Override 24 | public void refresh() 25 | { 26 | pcbPane.setGerberColor(PCBPane.BOTTOM_TRACE_COLOR); 27 | super.refresh(); 28 | } 29 | 30 | @Override 31 | protected boolean isEnabled() 32 | { 33 | return super.isEnabled() && Context.PcbPlacement.FACE_DOWN.equals(getMainApplication().getContext().getPcbPlacement()); 34 | } 35 | 36 | @Override 37 | protected Board.LayerType getCurrentLayer() 38 | { 39 | return Board.LayerType.BOTTOM; 40 | } 41 | 42 | @Override 43 | protected int getCacheId() 44 | { 45 | return 3; 46 | } 47 | 48 | @Override 49 | protected long getLayerModificationDate() 50 | { 51 | return 0; 52 | // return getMainApplication().getContext().getPcbLayout().getBottomLayerModificationDate(); 53 | } 54 | 55 | @Override 56 | protected boolean mirror() 57 | { 58 | return true; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/rubout/InsertTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.rubout; 16 | 17 | import org.cirqwizard.fx.Tool; 18 | import org.cirqwizard.fx.common.Message; 19 | 20 | public class InsertTool extends Message 21 | { 22 | public static final Tool EXPECTED_TOOL = new Tool(Tool.ToolType.RUBOUT, 800); 23 | 24 | @Override 25 | protected String getName() 26 | { 27 | return "Tool"; 28 | } 29 | 30 | @Override 31 | public void refresh() 32 | { 33 | super.refresh(); 34 | getMainApplication().getContext().setInsertedTool(null); 35 | header.setText("Insert copper rub-out tool into spindle"); 36 | text.setText("Make sure the tool is fully inserted."); 37 | } 38 | 39 | @Override 40 | protected boolean isMandatory() 41 | { 42 | return !EXPECTED_TOOL.equals(getMainApplication().getContext().getInsertedTool()); 43 | } 44 | 45 | @Override 46 | public void next() 47 | { 48 | getMainApplication().getContext().setInsertedTool(EXPECTED_TOOL); 49 | super.next(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/rubout/TopRubout.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.rubout; 16 | 17 | import org.cirqwizard.fx.Context; 18 | import org.cirqwizard.layers.Board; 19 | 20 | public class TopRubout extends Rubout 21 | { 22 | @Override 23 | protected boolean isEnabled() 24 | { 25 | return super.isEnabled() && Context.PcbPlacement.FACE_UP.equals(getMainApplication().getContext().getPcbPlacement()); 26 | } 27 | 28 | @Override 29 | protected Board.LayerType getCurrentLayer() 30 | { 31 | return Board.LayerType.TOP; 32 | } 33 | 34 | @Override 35 | protected int getCacheId() 36 | { 37 | return 2; 38 | } 39 | 40 | @Override 41 | protected long getLayerModificationDate() 42 | { 43 | return 0; //getMainApplication().getContext().getPcbLayout().getTopLayerModificationDate(); 44 | } 45 | 46 | @Override 47 | protected boolean mirror() 48 | { 49 | return false; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/traces/InsertTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.traces; 16 | 17 | import javafx.beans.binding.Bindings; 18 | import javafx.collections.FXCollections; 19 | import javafx.fxml.FXML; 20 | import javafx.scene.control.Button; 21 | import javafx.scene.control.ComboBox; 22 | import org.cirqwizard.fx.ScreenController; 23 | import org.cirqwizard.fx.Tool; 24 | import org.cirqwizard.logging.LoggerFactory; 25 | import org.cirqwizard.settings.ToolLibrary; 26 | import org.cirqwizard.settings.ToolSettings; 27 | 28 | public class InsertTool extends ScreenController 29 | { 30 | public static final Tool EXPECTED_TOOL = new Tool(Tool.ToolType.V_TOOL, 0); 31 | 32 | @FXML private ComboBox toolComboBox; 33 | @FXML private Button continueButton; 34 | 35 | @Override 36 | protected String getFxmlName() 37 | { 38 | return "/org/cirqwizard/fx/traces/InsertTool.fxml"; 39 | } 40 | 41 | @Override 42 | protected String getName() 43 | { 44 | return "Tool"; 45 | } 46 | 47 | @FXML 48 | public void initialize() 49 | { 50 | continueButton.disableProperty().bind(Bindings.isNull(toolComboBox.getSelectionModel().selectedItemProperty())); 51 | } 52 | 53 | @Override 54 | public void refresh() 55 | { 56 | super.refresh(); 57 | getMainApplication().getContext().setInsertedTool(null); 58 | 59 | try 60 | { 61 | toolComboBox.setItems(FXCollections.observableArrayList(ToolLibrary.load().getToolSettings())); 62 | } 63 | catch (Exception e) 64 | { 65 | LoggerFactory.logException("Could not load tool library", e); 66 | } 67 | } 68 | 69 | @Override 70 | protected boolean isMandatory() 71 | { 72 | return !EXPECTED_TOOL.equals(getMainApplication().getContext().getInsertedTool()); 73 | } 74 | 75 | @Override 76 | public void next() 77 | { 78 | getMainApplication().getContext().setInsertedTool(EXPECTED_TOOL); 79 | getMainApplication().getContext().setCurrentMillingTool(toolComboBox.getSelectionModel().getSelectedItem()); 80 | getMainApplication().getContext().setCurrentMillingToolIndex(toolComboBox.getSelectionModel().getSelectedIndex()); 81 | super.next(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/traces/bottom/BottomTraceMilling.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.traces.bottom; 16 | 17 | import org.cirqwizard.fx.Context; 18 | import org.cirqwizard.fx.PCBPane; 19 | import org.cirqwizard.fx.traces.TraceMilling; 20 | import org.cirqwizard.layers.Board; 21 | 22 | public class BottomTraceMilling extends TraceMilling 23 | { 24 | @Override 25 | public void refresh() 26 | { 27 | pcbPane.setGerberColor(PCBPane.BOTTOM_TRACE_COLOR); 28 | super.refresh(); 29 | } 30 | 31 | @Override 32 | protected boolean isEnabled() 33 | { 34 | return super.isEnabled() && Context.PcbPlacement.FACE_DOWN.equals(getMainApplication().getContext().getPcbPlacement()); 35 | } 36 | 37 | protected Board.LayerType getCurrentLayer() 38 | { 39 | return Board.LayerType.BOTTOM; 40 | } 41 | 42 | @Override 43 | protected boolean mirror() 44 | { 45 | return true; 46 | } 47 | 48 | @Override 49 | protected int getCacheId() 50 | { 51 | return 1; 52 | } 53 | 54 | @Override 55 | protected long getLayerModificationDate() 56 | { 57 | return 0; //getMainApplication().getContext().getPcbLayout().getBottomLayerModificationDate(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/traces/bottom/PCBPlacement.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.traces.bottom; 16 | 17 | import org.cirqwizard.fx.Context; 18 | 19 | public class PCBPlacement extends org.cirqwizard.fx.common.PCBPlacement 20 | { 21 | 22 | @Override 23 | public void refresh() 24 | { 25 | super.refresh(); 26 | text.setText("Put the board FACE DOWN right on the machine bed. Make sure both the bed and PCB are clean. It is also worth checking if PCB edges are smooth."); 27 | } 28 | 29 | @Override 30 | protected Context.PcbPlacement getExpectedPlacement() 31 | { 32 | return Context.PcbPlacement.FACE_DOWN; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/traces/top/PCBPlacement.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.traces.top; 16 | 17 | import org.cirqwizard.fx.Context; 18 | 19 | public class PCBPlacement extends org.cirqwizard.fx.common.PCBPlacement 20 | { 21 | 22 | @Override 23 | public void refresh() 24 | { 25 | super.refresh(); 26 | text.setText("Put the board FACE UP right on the machine bed. Make sure both the bed and PCB are clean. It is also worth checking if PCB edges are smooth."); 27 | } 28 | 29 | @Override 30 | protected Context.PcbPlacement getExpectedPlacement() 31 | { 32 | return Context.PcbPlacement.FACE_UP; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/traces/top/TopTraceMilling.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.fx.traces.top; 16 | 17 | import org.cirqwizard.fx.Context; 18 | import org.cirqwizard.fx.PCBPane; 19 | import org.cirqwizard.fx.traces.TraceMilling; 20 | import org.cirqwizard.layers.Board; 21 | 22 | public class TopTraceMilling extends TraceMilling 23 | { 24 | @Override 25 | public void refresh() 26 | { 27 | super.refresh(); 28 | pcbPane.setGerberColor(PCBPane.TOP_TRACE_COLOR); 29 | } 30 | 31 | @Override 32 | protected boolean isEnabled() 33 | { 34 | return super.isEnabled() && Context.PcbPlacement.FACE_UP.equals(getMainApplication().getContext().getPcbPlacement()); 35 | } 36 | 37 | @Override 38 | protected Board.LayerType getCurrentLayer() 39 | { 40 | return Board.LayerType.TOP; 41 | } 42 | 43 | @Override 44 | protected boolean mirror() 45 | { 46 | return false; 47 | } 48 | 49 | @Override 50 | protected int getCacheId() 51 | { 52 | return 0; 53 | } 54 | 55 | @Override 56 | protected long getLayerModificationDate() 57 | { 58 | return 0; //getMainApplication().getContext().getPcbLayout().getTopLayerModificationDate(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/util/ExceptionAlert.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.fx.util; 15 | 16 | import javafx.scene.control.Alert; 17 | import javafx.scene.control.TextArea; 18 | 19 | import java.io.PrintWriter; 20 | import java.io.StringWriter; 21 | 22 | public class ExceptionAlert extends Alert 23 | { 24 | public ExceptionAlert(String title, String headerText, String contentText, Exception exception) 25 | { 26 | super(AlertType.ERROR); 27 | setTitle(title); 28 | setHeaderText(headerText); 29 | setContentText(contentText); 30 | 31 | StringWriter stringWriter = new StringWriter(); 32 | PrintWriter printWriter = new PrintWriter(stringWriter); 33 | exception.printStackTrace(printWriter); 34 | TextArea stackTraceArea = new TextArea(stringWriter.toString()); 35 | stackTraceArea.setEditable(false); 36 | stackTraceArea.setWrapText(true); 37 | stackTraceArea.setMaxWidth(Double.MAX_VALUE); 38 | stackTraceArea.setMaxHeight(Double.MAX_VALUE); 39 | getDialogPane().setExpandableContent(stackTraceArea); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/fx/util/ToolbarPopup.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.fx.util; 15 | 16 | import com.sun.javafx.util.Utils; 17 | import javafx.geometry.HPos; 18 | import javafx.geometry.Point2D; 19 | import javafx.geometry.VPos; 20 | import javafx.scene.Node; 21 | import javafx.stage.Popup; 22 | import org.cirqwizard.fx.popover.PopOverController; 23 | 24 | public class ToolbarPopup extends Popup 25 | { 26 | public ToolbarPopup(PopOverController controller) 27 | { 28 | super(); 29 | setAutoHide(true); 30 | setHideOnEscape(true); 31 | getContent().add(controller.getView()); 32 | controller.setPopup(this); 33 | } 34 | 35 | public void show(Node anchor) 36 | { 37 | Point2D p = Utils.pointRelativeTo(anchor, -1, -1, HPos.CENTER, VPos.BOTTOM, 0, 0, true); 38 | show(anchor, p.getX(), p.getY()); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/GenerationService.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.generation; 15 | 16 | import org.cirqwizard.fx.Context; 17 | import org.cirqwizard.generation.optimizer.Chain; 18 | import org.cirqwizard.layers.Board; 19 | 20 | import java.util.List; 21 | 22 | public abstract class GenerationService extends ProcessingService 23 | { 24 | private Board.LayerType layer; 25 | 26 | public GenerationService(Context context, Board.LayerType layer) 27 | { 28 | super(context); 29 | this.layer = layer; 30 | } 31 | 32 | public Board.LayerType getLayer() 33 | { 34 | return layer; 35 | } 36 | 37 | public abstract List generate(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/MatchedArc.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.generation; 15 | 16 | import org.cirqwizard.geom.Circle; 17 | 18 | public class MatchedArc 19 | { 20 | private Circle circle; 21 | private double uncertainty; 22 | 23 | public MatchedArc(Circle circle, double uncertainty) 24 | { 25 | this.circle = circle; 26 | this.uncertainty = uncertainty; 27 | } 28 | 29 | public Circle getCircle() 30 | { 31 | return circle; 32 | } 33 | 34 | public void setCircle(Circle circle) 35 | { 36 | this.circle = circle; 37 | } 38 | 39 | public double getUncertainty() 40 | { 41 | return uncertainty; 42 | } 43 | 44 | public void setUncertainty(double uncertainty) 45 | { 46 | this.uncertainty = uncertainty; 47 | } 48 | 49 | @Override 50 | public String toString() 51 | { 52 | return "MatchedArc{" + 53 | "circle=" + circle + 54 | ", uncertainty=" + uncertainty + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/MillingToolpathGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.generation; 15 | 16 | import org.cirqwizard.generation.toolpath.CircularToolpath; 17 | import org.cirqwizard.generation.toolpath.LinearToolpath; 18 | import org.cirqwizard.generation.toolpath.Toolpath; 19 | import org.cirqwizard.gerber.CircularShape; 20 | import org.cirqwizard.gerber.GerberPrimitive; 21 | import org.cirqwizard.gerber.LinearShape; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class MillingToolpathGenerator 27 | { 28 | private List primitives; 29 | 30 | public MillingToolpathGenerator(List primitives) 31 | { 32 | this.primitives = primitives; 33 | } 34 | 35 | public List generate() 36 | { 37 | List toolpaths = new ArrayList<>(); 38 | for (GerberPrimitive element : primitives) 39 | { 40 | if (element instanceof LinearShape) 41 | { 42 | LinearShape shape = (LinearShape) element; 43 | toolpaths.add(new LinearToolpath(element.getAperture().getWidth(), shape.getFrom(), shape.getTo())); 44 | } 45 | else if (element instanceof CircularShape) 46 | { 47 | CircularShape shape = (CircularShape) element; 48 | toolpaths.add(new CircularToolpath(element.getAperture().getWidth(), shape.getFrom(), shape.getTo(), shape.getArc().getCenter(), shape.getArc().getRadius(), 49 | shape.getArc().isClockwise())); 50 | } 51 | } 52 | return toolpaths; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/SimpleEdgeDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.generation; 15 | 16 | import java.awt.image.BufferedImage; 17 | 18 | public class SimpleEdgeDetector 19 | { 20 | private byte[] sourceData; 21 | private byte[] output; 22 | private int width; 23 | private int height; 24 | 25 | public SimpleEdgeDetector(BufferedImage image) 26 | { 27 | sourceData = (byte[]) image.getData().getDataElements(0, 0, image.getWidth(), image.getHeight(), null); 28 | this.width = image.getWidth(); 29 | this.height = image.getHeight(); 30 | } 31 | 32 | public void process() 33 | { 34 | output = new byte[sourceData.length]; 35 | for (int y = 1; y < height - 1; y++) 36 | { 37 | final int _y = y; 38 | for (int x = 1; x < width - 1; x++) 39 | { 40 | int index = _y * width + x; 41 | if (sourceData[index] == 0 && 42 | (sourceData[index - 1] != 0 || sourceData[index + 1] != 0 || sourceData[index - width] != 0 || sourceData[index + width] != 0)) 43 | output[index] = 1; 44 | } 45 | } 46 | } 47 | 48 | public byte[] getOutput() 49 | { 50 | return output; 51 | } 52 | 53 | public BufferedImage getOutputImage() 54 | { 55 | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY); 56 | image.getWritableTile(0, 0).setDataElements(0, 0, width, height, output); 57 | return image; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/Tracer.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation; 16 | 17 | import org.cirqwizard.geom.Arc; 18 | import org.cirqwizard.geom.Circle; 19 | import org.cirqwizard.geom.Curve; 20 | import org.cirqwizard.geom.Line; 21 | import org.cirqwizard.generation.toolpath.CircularToolpath; 22 | import org.cirqwizard.generation.toolpath.LinearToolpath; 23 | import org.cirqwizard.generation.toolpath.Toolpath; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | 29 | public class Tracer 30 | { 31 | private byte[] windowData; 32 | 33 | private int width; 34 | private int height; 35 | private int toolDiameter; 36 | private List knownCircles; 37 | 38 | public Tracer(byte[] windowData, int width, int height, int toolDiameter, List knownCircles) 39 | { 40 | this.windowData = windowData; 41 | this.width = width; 42 | this.height = height; 43 | this.toolDiameter = toolDiameter; 44 | this.knownCircles = knownCircles; 45 | } 46 | 47 | public List process() 48 | { 49 | ArrayList result = new ArrayList<>(); 50 | for (int y = height - 1; y >= 0; y--) 51 | { 52 | for (int x = width - 1; x >= 0; x--) 53 | { 54 | int index = x + y * width; 55 | if (windowData[index] != 0) 56 | { 57 | List curves = new Vectorizer(windowData, width, height, knownCircles, x, y).trace(); 58 | for (Curve curve : curves) 59 | result.add(getToolpath(curve)); 60 | } 61 | } 62 | } 63 | 64 | return result; 65 | } 66 | 67 | private Toolpath getToolpath(Curve curve) 68 | { 69 | if (curve instanceof Line) 70 | return new LinearToolpath(toolDiameter, curve.getFrom(), curve.getTo()); 71 | else if (curve instanceof Arc) 72 | { 73 | Arc arc = (Arc) curve; 74 | return new CircularToolpath(toolDiameter, arc.getFrom(), arc.getTo(), arc.getCenter(), arc.getRadius(), arc.isClockwise()); 75 | } 76 | 77 | throw new IllegalArgumentException("Unexpected curve supplied: " + curve); 78 | } 79 | 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/gcode/DrillGCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.gcode; 16 | 17 | import org.cirqwizard.generation.toolpath.DrillPoint; 18 | import org.cirqwizard.post.Postprocessor; 19 | 20 | import java.util.List; 21 | 22 | 23 | public class DrillGCodeGenerator 24 | { 25 | private int g54X; 26 | private int g54Y; 27 | private int g54Z; 28 | private List drillPoints; 29 | 30 | public DrillGCodeGenerator(int g54X, int g54Y, int g54Z, List drillPoints) 31 | { 32 | this.g54X = g54X; 33 | this.g54Y = g54Y; 34 | this.g54Z = g54Z; 35 | this.drillPoints = drillPoints; 36 | } 37 | 38 | public String generate(Postprocessor postprocessor, int feed, int clearance, int safetyHeight, 39 | int drillingDepth, int spindleSpeed) 40 | { 41 | StringBuilder str = new StringBuilder(); 42 | postprocessor.header(str); 43 | 44 | DrillPoint firstPoint = drillPoints.stream().filter(DrillPoint::isEnabled).findFirst().get(); 45 | postprocessor.selectMachineWS(str); 46 | postprocessor.rapid(str, null, null, 0); 47 | postprocessor.rapid(str, g54X + firstPoint.getPoint().getX(), g54Y + firstPoint.getPoint().getY(), null); 48 | 49 | postprocessor.setupG54(str, g54X, g54Y, g54Z); 50 | postprocessor.selectWCS(str); 51 | 52 | postprocessor.rapid(str, null, null, clearance); 53 | postprocessor.spindleOn(str, spindleSpeed); 54 | drillPoints.stream(). 55 | filter(DrillPoint::isEnabled). 56 | forEach(drillPoint -> 57 | { 58 | postprocessor.rapid(str, drillPoint.getPoint().getX(), drillPoint.getPoint().getY(), clearance); 59 | postprocessor.rapid(str, null, null, safetyHeight); 60 | postprocessor.linearInterpolation(str, drillPoint.getPoint().getX(), drillPoint.getPoint().getY(), drillingDepth, feed); 61 | postprocessor.rapid(str, null, null, clearance); 62 | }); 63 | postprocessor.selectMachineWS(str); 64 | postprocessor.rapid(str, null, null, 0); 65 | postprocessor.spindleOff(str); 66 | 67 | return str.toString(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/gcode/GCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.generation.gcode; 2 | 3 | import org.cirqwizard.fx.Context; 4 | import org.cirqwizard.fx.PCBSize; 5 | import org.cirqwizard.settings.MachineSettings; 6 | import org.cirqwizard.settings.SettingsFactory; 7 | 8 | /** 9 | * Created by simon on 29.06.17. 10 | */ 11 | public class GCodeGenerator 12 | { 13 | private Context context; 14 | private boolean mirror; 15 | 16 | public GCodeGenerator(Context context, boolean mirror) 17 | { 18 | this.context = context; 19 | this.mirror = mirror; 20 | } 21 | 22 | protected int getX(int x) 23 | { 24 | return mirror ? -x : x; 25 | } 26 | 27 | protected int getG54X() 28 | { 29 | int g54X = context.getG54X(); 30 | if (mirror) 31 | { 32 | MachineSettings machineSettings = SettingsFactory.getMachineSettings(); 33 | int laminateWidth = context.getPanel().getSize() == PCBSize.Small ? machineSettings.getSmallPcbWidth().getValue() : machineSettings.getLargePcbWidth().getValue(); 34 | int pinX = machineSettings.getReferencePinX().getValue(); 35 | g54X = pinX * 2 + laminateWidth - context.getG54X(); 36 | } 37 | return g54X; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/gcode/PasteGCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.gcode; 16 | 17 | import org.cirqwizard.fx.Context; 18 | import org.cirqwizard.generation.toolpath.CuttingToolpath; 19 | import org.cirqwizard.generation.toolpath.Toolpath; 20 | import org.cirqwizard.geom.Curve; 21 | import org.cirqwizard.post.Postprocessor; 22 | 23 | import java.util.List; 24 | 25 | 26 | public class PasteGCodeGenerator extends GCodeGenerator 27 | { 28 | private Context context; 29 | private List toolpaths; 30 | 31 | public PasteGCodeGenerator(Context context, List toolpaths, boolean mirror) 32 | { 33 | super(context, mirror); 34 | this.context = context; 35 | this.toolpaths = toolpaths; 36 | } 37 | 38 | public String generate(Postprocessor postprocessor, int preFeedPause, int postFeedPause, int feed, int clearance, int workingHeight) 39 | { 40 | StringBuilder str = new StringBuilder(); 41 | postprocessor.header(str); 42 | 43 | postprocessor.selectMachineWS(str); 44 | postprocessor.rapid(str, null, null, 0); 45 | postprocessor.setupG54(str, getG54X(), context.getG54Y(), context.getG54Z()); 46 | postprocessor.selectWCS(str); 47 | 48 | boolean firstPad = true; 49 | for (Toolpath toolpath : toolpaths) 50 | { 51 | if (!toolpath.isEnabled()) 52 | continue; 53 | Curve curve = ((CuttingToolpath)toolpath).getCurve(); 54 | postprocessor.rapid(str, getX(curve.getFrom().getX()), curve.getFrom().getY(), firstPad ? null : clearance); 55 | firstPad = false; 56 | postprocessor.rapid(str, null, null, workingHeight); 57 | postprocessor.syringeOn(str); 58 | postprocessor.pause(str, preFeedPause); 59 | postprocessor.linearInterpolation(str, getX(curve.getTo().getX()), curve.getTo().getY(), 60 | workingHeight, feed); 61 | postprocessor.syringeOff(str); 62 | postprocessor.pause(str, postFeedPause); 63 | postprocessor.rapid(str, null, null, clearance); 64 | } 65 | postprocessor.selectMachineWS(str); 66 | postprocessor.rapid(str, null, null, 0); 67 | postprocessor.footer(str); 68 | 69 | return str.toString(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/optimizer/Chain.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.optimizer; 16 | 17 | import org.cirqwizard.geom.Point; 18 | import org.cirqwizard.generation.toolpath.CuttingToolpath; 19 | import org.cirqwizard.generation.toolpath.Toolpath; 20 | 21 | import java.util.List; 22 | 23 | public class Chain 24 | { 25 | private List segments; 26 | 27 | public Chain(List segments) 28 | { 29 | this.segments = segments; 30 | } 31 | 32 | public List getSegments() 33 | { 34 | return segments; 35 | } 36 | 37 | public Point getStart() 38 | { 39 | return ((CuttingToolpath)segments.get(0)).getCurve().getFrom(); 40 | } 41 | 42 | public Point getEnd() 43 | { 44 | return ((CuttingToolpath)segments.get(segments.size() - 1)).getCurve().getTo(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/optimizer/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.optimizer; 16 | 17 | import java.util.List; 18 | 19 | public class Environment 20 | { 21 | private List chains; 22 | 23 | public Environment(List chains) 24 | { 25 | this.chains = chains; 26 | } 27 | 28 | public List getChains() 29 | { 30 | return chains; 31 | } 32 | 33 | public void setChains(List chains) 34 | { 35 | this.chains = chains; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/optimizer/Generation.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.optimizer; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Random; 19 | 20 | public class Generation 21 | { 22 | private ArrayList population = new ArrayList<>(); 23 | 24 | public Generation() 25 | { 26 | } 27 | 28 | public Generation(ArrayList population) 29 | { 30 | this.population = population; 31 | } 32 | 33 | public void populate(int genomeSize, int size) 34 | { 35 | Random rnd = new Random(); 36 | for (int i = 0; i < size; i++) 37 | { 38 | ArrayList toAdd = new ArrayList<>(); 39 | for (int j = 0; j < genomeSize; j++) 40 | toAdd.add(j); 41 | int[] newGenes = new int[toAdd.size()]; 42 | for (int j = 0; j < newGenes.length; j++) 43 | newGenes[j] = toAdd.remove(rnd.nextInt(toAdd.size())); 44 | population.add(new Phenotype(newGenes)); 45 | } 46 | } 47 | 48 | public Phenotype getBestFitness(Environment environment) 49 | { 50 | Phenotype mostFit = null; 51 | for (Phenotype p : population) 52 | if (mostFit == null || p.calculateFitness(environment) < mostFit.calculateFitness(environment)) 53 | mostFit = p; 54 | 55 | return mostFit; 56 | } 57 | 58 | public Phenotype tournamentWinner(Environment environment, int tournamentSize) 59 | { 60 | Phenotype winner = null; 61 | Random random = new Random(); 62 | for (int i = 0; i < tournamentSize; i++) 63 | { 64 | Phenotype p = population.get(random.nextInt(population.size())); 65 | if (winner == null || p.calculateFitness(environment) < winner.calculateFitness(environment)) 66 | winner = p; 67 | } 68 | return winner; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/CircularToolpath.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | 18 | import javafx.scene.canvas.GraphicsContext; 19 | import javafx.scene.shape.ArcType; 20 | import javafx.scene.shape.StrokeLineCap; 21 | import org.cirqwizard.geom.*; 22 | import org.cirqwizard.geom.Point; 23 | 24 | 25 | public class CircularToolpath extends CuttingToolpath 26 | { 27 | private Arc arc; 28 | 29 | public CircularToolpath(int toolDiameter, Point from, Point to, Point center, int radius, boolean clockwise) 30 | { 31 | super(toolDiameter); 32 | arc = new Arc(from, to, center, radius, clockwise); 33 | } 34 | 35 | @Override 36 | public Curve getCurve() 37 | { 38 | return arc; 39 | } 40 | 41 | @Override 42 | public void render(GraphicsContext g) 43 | { 44 | g.setLineCap(StrokeLineCap.ROUND); 45 | g.setLineWidth(getToolDiameter()); 46 | g.strokeArc(arc.getCenter().getX() - arc.getRadius(), 47 | arc.getCenter().getY() - arc.getRadius(), 48 | arc.getRadius() * 2, arc.getRadius() * 2, 49 | -Math.toDegrees(arc.getStart()), Math.toDegrees(arc.getAngle()) * (arc.isClockwise() ? 1 : -1), ArcType.OPEN); 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/CuttingToolpath.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | import org.cirqwizard.geom.Curve; 18 | 19 | 20 | public abstract class CuttingToolpath extends Toolpath 21 | { 22 | private int toolDiameter; 23 | 24 | public abstract Curve getCurve(); 25 | 26 | public CuttingToolpath(int toolDiameter) 27 | { 28 | this.toolDiameter = toolDiameter; 29 | } 30 | 31 | public int getToolDiameter() 32 | { 33 | return toolDiameter; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/DrillPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | import javafx.scene.canvas.GraphicsContext; 18 | import org.cirqwizard.geom.Curve; 19 | import org.cirqwizard.geom.Point; 20 | import org.cirqwizard.layers.LayerElement; 21 | 22 | 23 | public class DrillPoint extends CuttingToolpath implements LayerElement 24 | { 25 | private Point point; 26 | 27 | public DrillPoint(Point point, int diameter) 28 | { 29 | super(((diameter + 50) / 100 * 100)); // Rounding to tenth of millimeter 30 | this.point = point; 31 | } 32 | 33 | public Point getPoint() 34 | { 35 | return point; 36 | } 37 | 38 | public void setPoint(Point point) 39 | { 40 | this.point = point; 41 | } 42 | 43 | @Override 44 | public Point getMin() 45 | { 46 | return point.add(new Point(-getToolDiameter() / 2, -getToolDiameter() / 2)); 47 | } 48 | 49 | @Override 50 | public Point getMax() 51 | { 52 | return point.add(new Point(getToolDiameter() / 2, getToolDiameter() / 2)); 53 | 54 | } 55 | 56 | @Override 57 | public boolean isVisible() 58 | { 59 | return true; 60 | } 61 | 62 | @Override 63 | public void move(Point point) 64 | { 65 | this.point = this.point.add(point); 66 | } 67 | 68 | @Override 69 | public void rotate(boolean clockwise) 70 | { 71 | if (clockwise) 72 | point = new Point(point.getY(), -point.getX()); 73 | else 74 | point = new Point(-point.getY(), point.getX()); 75 | } 76 | 77 | @Override 78 | public Object clone() throws CloneNotSupportedException 79 | { 80 | return super.clone(); 81 | } 82 | 83 | @Override 84 | public void render(GraphicsContext g) 85 | { 86 | g.fillOval(getPoint().getX() - getToolDiameter() / 2, 87 | getPoint().getY() - getToolDiameter() / 2, 88 | getToolDiameter(), getToolDiameter()); 89 | } 90 | 91 | @Override 92 | public Curve getCurve() 93 | { 94 | return null; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/LinearToolpath.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | import javafx.scene.canvas.GraphicsContext; 18 | import javafx.scene.shape.StrokeLineCap; 19 | import org.cirqwizard.geom.Curve; 20 | import org.cirqwizard.geom.Line; 21 | import org.cirqwizard.geom.Point; 22 | 23 | 24 | public class LinearToolpath extends CuttingToolpath 25 | { 26 | private Line line; 27 | 28 | public LinearToolpath(int toolDiameter, Point from, Point to) 29 | { 30 | super(toolDiameter); 31 | line = new Line(from, to); 32 | } 33 | 34 | @Override 35 | public Curve getCurve() 36 | { 37 | return line; 38 | } 39 | 40 | @Override 41 | public void render(GraphicsContext g) 42 | { 43 | g.setLineCap(StrokeLineCap.ROUND); 44 | g.setLineWidth(getToolDiameter()); 45 | g.strokeLine(getCurve().getFrom().getX(), getCurve().getFrom().getY(), 46 | getCurve().getTo().getX(), getCurve().getTo().getY()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/Toolpath.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | 18 | import javafx.scene.canvas.GraphicsContext; 19 | 20 | import java.io.Serializable; 21 | 22 | 23 | public abstract class Toolpath implements Serializable 24 | { 25 | private boolean enabled = true; 26 | private boolean selected = false; 27 | 28 | 29 | public boolean isEnabled() 30 | { 31 | return enabled; 32 | } 33 | 34 | public void setEnabled(boolean enabled) 35 | { 36 | this.enabled = enabled; 37 | } 38 | 39 | public boolean isSelected() 40 | { 41 | return selected; 42 | } 43 | 44 | public void setSelected(boolean selected) 45 | { 46 | this.selected = selected; 47 | } 48 | 49 | public abstract void render(GraphicsContext g); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/ToolpathPersistingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | 18 | public class ToolpathPersistingException extends Exception 19 | { 20 | public ToolpathPersistingException() 21 | { 22 | } 23 | 24 | public ToolpathPersistingException(String message) 25 | { 26 | super(message); 27 | } 28 | 29 | public ToolpathPersistingException(String message, Throwable cause) 30 | { 31 | super(message, cause); 32 | } 33 | 34 | public ToolpathPersistingException(Throwable cause) 35 | { 36 | super(cause); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/ToolpathsCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | 18 | import java.io.Serializable; 19 | import java.util.HashMap; 20 | import java.util.List; 21 | 22 | 23 | public class ToolpathsCache implements Serializable 24 | { 25 | private HashMap> traces = new HashMap<>(); 26 | 27 | public List getToolpaths(ToolpathsCacheKey cacheKey) 28 | { 29 | if (traces.containsKey(cacheKey)) 30 | return traces.get(cacheKey); 31 | return null; 32 | } 33 | 34 | public void setToolpaths(ToolpathsCacheKey cacheKey, List topLayer) 35 | { 36 | this.traces.put(cacheKey, topLayer); 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/generation/toolpath/ToolpathsPersistor.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.generation.toolpath; 16 | 17 | 18 | import java.io.*; 19 | 20 | 21 | public class ToolpathsPersistor 22 | { 23 | public static ToolpathsCache loadFromFile(String filename) throws ToolpathPersistingException 24 | { 25 | if(!new File(filename).exists()) 26 | return null; 27 | 28 | ToolpathsCache toolpathsCache; 29 | try 30 | { 31 | FileInputStream fis = new FileInputStream(filename); 32 | ObjectInputStream oin = new ObjectInputStream(fis); 33 | toolpathsCache = (ToolpathsCache) oin.readObject(); 34 | } 35 | catch(IOException | ClassNotFoundException e) 36 | { 37 | throw new ToolpathPersistingException("Error loading toolpaths from file", e); 38 | } 39 | return toolpathsCache; 40 | } 41 | 42 | public static void saveToFile(ToolpathsCache cache, String filename) throws ToolpathPersistingException 43 | { 44 | if (cache != null) 45 | { 46 | try 47 | { 48 | FileOutputStream fos = new FileOutputStream(filename); 49 | ObjectOutputStream oos = new ObjectOutputStream(fos); 50 | oos.writeObject(cache); 51 | oos.flush(); 52 | oos.close(); 53 | } 54 | catch(IOException e) 55 | { 56 | throw new ToolpathPersistingException("Error saving toolpaths to file", e); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/geom/Circle.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.geom; 16 | 17 | public class Circle 18 | { 19 | private Point center; 20 | private int radius; 21 | 22 | public Circle(Point center, int radius) 23 | { 24 | this.center = center; 25 | this.radius = radius; 26 | } 27 | 28 | public Point getCenter() 29 | { 30 | return center; 31 | } 32 | 33 | public void setCenter(Point center) 34 | { 35 | this.center = center; 36 | } 37 | 38 | public int getRadius() 39 | { 40 | return radius; 41 | } 42 | 43 | public void setRadius(int radius) 44 | { 45 | this.radius = radius; 46 | } 47 | 48 | @Override 49 | public String toString() 50 | { 51 | return "Circle{" + 52 | "center=" + center + 53 | ", radius=" + radius + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/geom/Curve.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.geom; 16 | 17 | 18 | import java.io.Serializable; 19 | 20 | public abstract class Curve implements Serializable 21 | { 22 | protected Point from; 23 | protected Point to; 24 | 25 | public Point getFrom() 26 | { 27 | return from; 28 | } 29 | 30 | public void setFrom(Point from) 31 | { 32 | this.from = from; 33 | } 34 | 35 | public Point getTo() 36 | { 37 | return to; 38 | } 39 | 40 | public void setTo(Point to) 41 | { 42 | this.to = to; 43 | } 44 | 45 | public abstract Curve reverse(); 46 | 47 | @Override 48 | public boolean equals(Object o) 49 | { 50 | if (this == o) return true; 51 | if (o == null || getClass() != o.getClass()) return false; 52 | 53 | Curve curve = (Curve) o; 54 | 55 | if (from != null ? !from.equals(curve.from) : curve.from != null) return false; 56 | if (to != null ? !to.equals(curve.to) : curve.to != null) return false; 57 | 58 | return true; 59 | } 60 | 61 | @Override 62 | public int hashCode() 63 | { 64 | int result = from != null ? from.hashCode() : 0; 65 | result = 31 * result + (to != null ? to.hashCode() : 0); 66 | return result; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/geom/Line.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.geom; 16 | 17 | public class Line extends Curve implements Cloneable 18 | { 19 | private Double angleToX = null; 20 | 21 | public Line(Point from, Point to) 22 | { 23 | this.from = from; 24 | this.to = to; 25 | } 26 | 27 | public Line reverse() 28 | { 29 | return new Line(to, from); 30 | } 31 | 32 | public double angleToX() 33 | { 34 | if (angleToX == null) 35 | { 36 | Point vector = to.subtract(from); 37 | angleToX = Math.atan2(vector.getY(), vector.getX()); 38 | if (Math.abs(angleToX - Math.PI) < Math.PI / 360) 39 | angleToX = -Math.PI; 40 | } 41 | return angleToX; 42 | } 43 | 44 | public Line offset(Point point) 45 | { 46 | return new Line(from.add(point), to.add(point)); 47 | } 48 | 49 | public Line offsetFrom(int offset) 50 | { 51 | return new Line(offset(from, to, offset), to); 52 | } 53 | 54 | public Line offsetTo(int offset) 55 | { 56 | return new Line(from, offset(to, from, offset)); 57 | } 58 | 59 | private Point offset(Point start, Point end, int offset) 60 | { 61 | double length = length(); 62 | if (offset >= length) 63 | throw new IllegalArgumentException("Offset in line cannot be more or equal current distance"); 64 | 65 | double t = offset / length; 66 | int toX = (int)((1 - t) * start.getX() + t * end.getX()); 67 | int toY = (int)((1 - t) * start.getY() + t * end.getY()); 68 | return new Point(toX, toY); 69 | } 70 | 71 | public double length() 72 | { 73 | return from.distanceTo(to); 74 | } 75 | 76 | @Override 77 | public String toString() 78 | { 79 | return "Line{" + 80 | "from=" + getFrom() + 81 | ", to=" + getTo() + 82 | ", ang=" + angleToX() + 83 | '}'; 84 | } 85 | 86 | @Override 87 | public Line clone() 88 | { 89 | return new Line(new Point(from.getX(), from.getY()), new Point(to.getX(), to.getY())); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/geom/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.geom; 16 | 17 | import java.io.Serializable; 18 | 19 | public class Point implements Serializable 20 | { 21 | private int x; 22 | private int y; 23 | 24 | public Point(int x, int y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public int getX() 31 | { 32 | return x; 33 | } 34 | 35 | public int getY() 36 | { 37 | return y; 38 | } 39 | 40 | public double distanceTo(Point p) 41 | { 42 | double x = this.x - p.x; 43 | double y = this.y - p.y; 44 | return Math.sqrt(x * x + y * y); 45 | } 46 | 47 | public Point add(Point p) 48 | { 49 | return new Point(this.x + p.x, this.y + p.y); 50 | } 51 | 52 | public Point subtract(Point p) 53 | { 54 | return new Point(this.x - p.x, this.y - p.y); 55 | } 56 | 57 | public Point round() 58 | { 59 | return round(10); 60 | } 61 | 62 | public Point round(int roundTo) 63 | { 64 | return new Point((x + roundTo / 2) / roundTo * roundTo, (y + roundTo / 2) / roundTo * roundTo); 65 | } 66 | 67 | public Point rotateRelativeToOrigin(boolean clockwise) 68 | { 69 | if (clockwise) 70 | return new Point(y, -x); 71 | else 72 | return new Point(-y, x); 73 | } 74 | 75 | @Override 76 | public String toString() 77 | { 78 | return "Point{" + 79 | "x=" + x + 80 | ", y=" + y + 81 | '}'; 82 | } 83 | 84 | @Override 85 | public boolean equals(Object o) 86 | { 87 | if (this == o) return true; 88 | if (o == null || getClass() != o.getClass()) return false; 89 | 90 | Point point = (Point) o; 91 | 92 | if (x != point.x) return false; 93 | if (y != point.y) return false; 94 | 95 | return true; 96 | } 97 | 98 | public boolean equals(Point o, double precision) 99 | { 100 | return distanceTo(o) < precision; 101 | } 102 | 103 | @Override 104 | public int hashCode() 105 | { 106 | int result = x; 107 | result = 31 * result + y; 108 | return result; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/geom/Rect.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.geom; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Rect implements Serializable 6 | { 7 | private Point center; 8 | private int width; 9 | private int height; 10 | 11 | public Rect(Point center, int width, int height) 12 | { 13 | this.center = center; 14 | this.width = width; 15 | this.height = height; 16 | } 17 | 18 | public Point getCenter() 19 | { 20 | return center; 21 | } 22 | 23 | public void setCenter(Point center) 24 | { 25 | this.center = center; 26 | } 27 | 28 | public int getWidth() 29 | { 30 | return width; 31 | } 32 | 33 | public void setWidth(int width) 34 | { 35 | this.width = width; 36 | } 37 | 38 | public int getHeight() 39 | { 40 | return height; 41 | } 42 | 43 | public void setHeight(int height) 44 | { 45 | this.height = height; 46 | } 47 | 48 | public int getLeftX() 49 | { 50 | return getCenter().getX() - getWidth() / 2; 51 | } 52 | 53 | public int getRightX() 54 | { 55 | return getCenter().getX() + getWidth() / 2; 56 | } 57 | 58 | public int getTopY() 59 | { 60 | return getCenter().getY() + getHeight() / 2; 61 | } 62 | 63 | public int getBottomY() 64 | { 65 | return getCenter().getY() - getHeight() / 2; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/DataBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber; 16 | 17 | public class DataBlock 18 | { 19 | private Integer x; 20 | private Integer y; 21 | private Integer i; 22 | private Integer j; 23 | private Integer g; 24 | private Integer d; 25 | private Integer m; 26 | 27 | public Integer getX() 28 | { 29 | return x; 30 | } 31 | 32 | public void setX(Integer x) 33 | { 34 | if (this.x == null) 35 | this.x = x; 36 | } 37 | 38 | public Integer getY() 39 | { 40 | return y; 41 | } 42 | 43 | public void setY(Integer y) 44 | { 45 | if (this.y == null) 46 | this.y = y; 47 | } 48 | 49 | public Integer getI() 50 | { 51 | return i; 52 | } 53 | 54 | public void setI(Integer i) 55 | { 56 | this.i = i; 57 | } 58 | 59 | public Integer getJ() 60 | { 61 | return j; 62 | } 63 | 64 | public void setJ(Integer j) 65 | { 66 | this.j = j; 67 | } 68 | 69 | public Integer getG() 70 | { 71 | return g; 72 | } 73 | 74 | public void setG(Integer g) 75 | { 76 | if (this.g == null) 77 | this.g = g; 78 | } 79 | 80 | public Integer getD() 81 | { 82 | return d; 83 | } 84 | 85 | public void setD(Integer d) 86 | { 87 | if (this.d == null) 88 | this.d = d; 89 | } 90 | 91 | public Integer getM() 92 | { 93 | return m; 94 | } 95 | 96 | public void setM(Integer m) 97 | { 98 | if (this.m == null) 99 | this.m = m; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/GerberParsingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber; 16 | 17 | 18 | public class GerberParsingException extends Exception 19 | { 20 | public GerberParsingException() 21 | { 22 | } 23 | 24 | public GerberParsingException(String message) 25 | { 26 | super(message); 27 | } 28 | 29 | public GerberParsingException(String message, Throwable cause) 30 | { 31 | super(message, cause); 32 | } 33 | 34 | public GerberParsingException(Throwable cause) 35 | { 36 | super(cause); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/GerberPrimitive.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber; 16 | 17 | import org.cirqwizard.geom.Point; 18 | import org.cirqwizard.gerber.appertures.Aperture; 19 | import org.cirqwizard.layers.LayerElement; 20 | 21 | import java.awt.*; 22 | 23 | 24 | public abstract class GerberPrimitive implements LayerElement 25 | { 26 | protected Aperture aperture; 27 | private Polarity polarity; 28 | 29 | protected GerberPrimitive(Polarity polarity) 30 | { 31 | this.polarity = polarity; 32 | } 33 | 34 | public Polarity getPolarity() 35 | { 36 | return polarity; 37 | } 38 | 39 | public Aperture getAperture() 40 | { 41 | return aperture; 42 | } 43 | 44 | public abstract void rotate(boolean clockwise); 45 | public abstract void move(Point point); 46 | public abstract Point getMin(); 47 | public abstract Point getMax(); 48 | public abstract void render(Graphics2D g, double inflation); 49 | 50 | @Override 51 | public Object clone() throws CloneNotSupportedException 52 | { 53 | return super.clone(); 54 | } 55 | 56 | public enum Polarity 57 | { 58 | CLEAR, DARK 59 | } 60 | 61 | @Override 62 | public boolean isVisible() 63 | { 64 | return aperture != null && aperture.isVisible(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/GroupRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber; 16 | 17 | import org.cirqwizard.geom.Arc; 18 | import org.cirqwizard.geom.Curve; 19 | import org.cirqwizard.geom.Line; 20 | import org.cirqwizard.generation.toolpath.CuttingToolpath; 21 | import org.cirqwizard.generation.toolpath.Toolpath; 22 | 23 | import java.util.List; 24 | 25 | 26 | public class GroupRenderer 27 | { 28 | private static final String[] colors = new String[] {"Black", "Red", "Green"}; 29 | 30 | public static String renderCurve(Curve curve) 31 | { 32 | StringBuffer str = new StringBuffer(); 33 | if (curve instanceof Line) 34 | { 35 | Line line = (Line) curve; 36 | str.append("Line[{{").append(line.getFrom().getX()).append(','). 37 | append(line.getFrom().getY()).append("},{"). 38 | append(line.getTo().getX()).append(','). 39 | append(line.getTo().getY()).append("}}]"); 40 | } 41 | else if (curve instanceof Arc) 42 | { 43 | Arc arc = (Arc) curve; 44 | str.append("Circle[{").append(arc.getCenter().getX()).append(","). 45 | append(arc.getCenter().getY()).append("},"). 46 | append(arc.getRadius()).append(",{"). 47 | append(arc.getStart()).append(","). 48 | append(arc.getEnd(false)).append("}]"); 49 | } 50 | return str.toString(); 51 | } 52 | 53 | public static String renderToolpaths(List toolpaths) 54 | { 55 | StringBuilder str = new StringBuilder(); 56 | str.append("Graphics[{"); 57 | for (Toolpath toolpath : toolpaths) 58 | str.append(renderCurve(((CuttingToolpath)toolpath).getCurve())).append(","); 59 | str.setLength(str.length() - 1); 60 | str.append("},Axes->True]"); 61 | return str.toString(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/InterpolatingShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | public abstract class InterpolatingShape extends GerberPrimitive 20 | { 21 | protected InterpolatingShape(Polarity polarity) 22 | { 23 | super(polarity); 24 | } 25 | 26 | public abstract Point getFrom(); 27 | public abstract Point getTo(); 28 | 29 | @Override 30 | public Object clone() throws CloneNotSupportedException 31 | { 32 | return super.clone(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/Aperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures; 16 | 17 | public abstract class Aperture 18 | { 19 | public enum HoleType 20 | { 21 | NONE, 22 | CIRCULAR, 23 | RECTANGULAR 24 | } 25 | 26 | protected HoleType holeType; 27 | protected int holeDimensions[] = new int[2]; 28 | 29 | public Aperture() 30 | { 31 | this.holeType = HoleType.NONE; 32 | } 33 | 34 | public Aperture(int holeDiameter) 35 | { 36 | this.holeType = HoleType.CIRCULAR; 37 | this.holeDimensions[0] = holeDiameter; 38 | } 39 | 40 | public Aperture(int holeWidth, int holeHeight) 41 | { 42 | this.holeType = HoleType.RECTANGULAR; 43 | this.holeDimensions[0] = holeWidth; 44 | this.holeDimensions[1] = holeHeight; 45 | } 46 | 47 | public abstract Aperture rotate(boolean clockwise); 48 | 49 | public abstract boolean isVisible(); 50 | 51 | public abstract int getWidth(); 52 | public abstract int getHeight(); 53 | 54 | public abstract int getCircumRadius(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/CircularAperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures; 16 | 17 | public class CircularAperture extends Aperture 18 | { 19 | private int diameter; 20 | 21 | public CircularAperture(int diameter) 22 | { 23 | super(); 24 | this.diameter = diameter; 25 | } 26 | 27 | public CircularAperture(int diameter, int holeDiameter) 28 | { 29 | super(holeDiameter); 30 | this.diameter = diameter; 31 | } 32 | 33 | public CircularAperture(int diameter, int holeWidth, int holeHeight) 34 | { 35 | super(holeWidth, holeHeight); 36 | this.diameter = diameter; 37 | } 38 | 39 | public int getDiameter() 40 | { 41 | return diameter; 42 | } 43 | 44 | @Override 45 | public boolean isVisible() 46 | { 47 | return diameter > 0; 48 | } 49 | 50 | @Override 51 | public int getWidth() 52 | { 53 | return diameter; 54 | } 55 | 56 | @Override 57 | public int getHeight() 58 | { 59 | return diameter; 60 | } 61 | 62 | @Override 63 | public Aperture rotate(boolean clockwise) 64 | { 65 | return this; 66 | } 67 | 68 | @Override 69 | public int getCircumRadius() 70 | { 71 | return diameter / 2; 72 | } 73 | 74 | public int getRectWidth() 75 | { 76 | // pythagorean theorem 77 | return (int) Math.sqrt(diameter * diameter / 2); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/OctagonalAperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures; 16 | 17 | public class OctagonalAperture extends Aperture 18 | { 19 | private int diameter; 20 | 21 | public OctagonalAperture(int diameter) 22 | { 23 | super(); 24 | this.diameter = diameter; 25 | } 26 | 27 | public OctagonalAperture(int diameter, int holeDiameter) 28 | { 29 | super(holeDiameter); 30 | this.diameter = diameter; 31 | } 32 | 33 | public OctagonalAperture(int diameter, int holeWidth, int holeHeight) 34 | { 35 | super(holeWidth, holeHeight); 36 | this.diameter = diameter; 37 | } 38 | 39 | @Override 40 | public Aperture rotate(boolean clockwise) 41 | { 42 | return this; 43 | } 44 | 45 | public int getDiameter() 46 | { 47 | return diameter; 48 | } 49 | 50 | @Override 51 | public boolean isVisible() 52 | { 53 | return diameter > 0; 54 | } 55 | 56 | @Override 57 | public int getWidth() 58 | { 59 | return diameter; 60 | } 61 | 62 | @Override 63 | public int getHeight() 64 | { 65 | return diameter; 66 | } 67 | 68 | @Override 69 | public int getCircumRadius() 70 | { 71 | return diameter / 2; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/OvalAperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures; 16 | 17 | public class OvalAperture extends Aperture 18 | { 19 | private int width, height; 20 | 21 | public OvalAperture(int width, int height) 22 | { 23 | super(); 24 | this.width = width; 25 | this.height = height; 26 | } 27 | 28 | public OvalAperture(int width, int height, int holeDiameter) 29 | { 30 | super(holeDiameter); 31 | this.width = width; 32 | this.height = height; 33 | } 34 | 35 | public OvalAperture(int width, int height, int holeWidth, int holeHeight) 36 | { 37 | super(holeWidth, holeHeight); 38 | this.width = width; 39 | this.height = height; 40 | } 41 | 42 | public int getWidth() 43 | { 44 | return width; 45 | } 46 | 47 | public int getHeight() 48 | { 49 | return height; 50 | } 51 | 52 | public boolean isHorizontal() 53 | { 54 | return width > height; 55 | } 56 | 57 | @Override 58 | public boolean isVisible() 59 | { 60 | return height > 0 && width > 0; 61 | } 62 | 63 | @Override 64 | public Aperture rotate(boolean clockwise) 65 | { 66 | return new OvalAperture(height, width); 67 | } 68 | 69 | @Override 70 | public int getCircumRadius() 71 | { 72 | return (int) Math.sqrt(width * width + height * height); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/PolygonalAperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.gerber.appertures; 15 | 16 | import org.cirqwizard.geom.Point; 17 | 18 | import java.util.ArrayList; 19 | 20 | public class PolygonalAperture extends Aperture 21 | { 22 | private ArrayList points = new ArrayList(); 23 | private int minX = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE; 24 | private int minY = Integer.MIN_VALUE, maxY = Integer.MAX_VALUE; 25 | 26 | public PolygonalAperture(ArrayList points) 27 | { 28 | super(); 29 | this.points = points; 30 | 31 | for (Point p : points) 32 | { 33 | maxX = Math.max(maxX, p.getX()); 34 | minX = Math.min(minX, p.getX()); 35 | maxY = Math.max(maxY, p.getY()); 36 | minY = Math.min(minY, p.getY()); 37 | } 38 | } 39 | 40 | public PolygonalAperture(int diameter, int holeDiameter) 41 | { 42 | super(holeDiameter); 43 | } 44 | 45 | public PolygonalAperture(int diameter, int holeWidth, int holeHeight) 46 | { 47 | super(holeWidth, holeHeight); 48 | } 49 | 50 | public ArrayList getPoints() 51 | { 52 | return points; 53 | } 54 | 55 | @Override 56 | public Aperture rotate(boolean clockwise) 57 | { 58 | ArrayList newPoints = new ArrayList(); 59 | for(Point p : points) 60 | { 61 | Point point; 62 | if (clockwise) 63 | point = new Point(p.getY(), -p.getX()); 64 | else 65 | point = new Point(-p.getY(), p.getX()); 66 | newPoints.add(point); 67 | } 68 | points = newPoints; 69 | return this; 70 | } 71 | 72 | @Override 73 | public boolean isVisible() 74 | { 75 | return true; 76 | } 77 | 78 | @Override 79 | public int getWidth() 80 | { 81 | return maxX - minX; 82 | } 83 | 84 | @Override 85 | public int getHeight() 86 | { 87 | return maxY - minY; 88 | } 89 | 90 | @Override 91 | public int getCircumRadius() 92 | { 93 | return (maxX - minX) / 2; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/RectangularAperture.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures; 16 | 17 | public class RectangularAperture extends Aperture 18 | { 19 | private int dimensions[] = new int[2]; 20 | 21 | public RectangularAperture(int width, int height) 22 | { 23 | super(); 24 | this.dimensions[0] = width; 25 | this.dimensions[1] = height; 26 | } 27 | 28 | public RectangularAperture(int width, int height, int holeDiameter) 29 | { 30 | super(holeDiameter); 31 | this.dimensions[0] = width; 32 | this.dimensions[1] = height; 33 | } 34 | 35 | public RectangularAperture(int width, int height, int holeWidth, int holeHeight) 36 | { 37 | super(holeWidth, holeHeight); 38 | this.dimensions[0] = width; 39 | this.dimensions[1] = height; 40 | } 41 | 42 | public int[] getDimensions() 43 | { 44 | return dimensions; 45 | } 46 | 47 | @Override 48 | public Aperture rotate(boolean clockwise) 49 | { 50 | return new RectangularAperture(dimensions[1], dimensions[0], holeDimensions[1], holeDimensions[0]); 51 | } 52 | 53 | @Override 54 | public boolean isVisible() 55 | { 56 | return dimensions[0] > 0 && dimensions[1] > 0; 57 | } 58 | 59 | @Override 60 | public int getWidth() 61 | { 62 | return dimensions[0]; 63 | } 64 | 65 | @Override 66 | public int getHeight() 67 | { 68 | return dimensions[1]; 69 | } 70 | 71 | @Override 72 | public int getCircumRadius() 73 | { 74 | int width = dimensions[0] / 2; 75 | int height = dimensions[1] / 2; 76 | return (int) Math.sqrt(width * width + height * height); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroCenterLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures.macro; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | public class MacroCenterLine extends MacroPrimitive 20 | { 21 | private int width; 22 | private int height; 23 | private Point center; 24 | 25 | public MacroCenterLine(int width, int height, Point center, int rotationAngle) 26 | { 27 | super(rotationAngle); 28 | this.width = width; 29 | this.height = height; 30 | this.center = center; 31 | } 32 | 33 | public int getWidth() 34 | { 35 | return width; 36 | } 37 | 38 | public int getHeight() 39 | { 40 | return height; 41 | } 42 | 43 | public Point getCenter() 44 | { 45 | return center; 46 | } 47 | 48 | public Point getFrom() 49 | { 50 | return translate(center.subtract(new Point(width / 2, 0))); 51 | } 52 | 53 | public Point getTo() 54 | { 55 | return translate(center.add(new Point(width / 2, 0))); 56 | } 57 | 58 | @Override 59 | public MacroPrimitive clone() 60 | { 61 | return new MacroCenterLine(width, height, center, getRotationAngle()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroCircle.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures.macro; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | public class MacroCircle extends MacroPrimitive 20 | { 21 | private int diameter; 22 | private Point center; 23 | 24 | public MacroCircle(int diameter, Point center) 25 | { 26 | this(diameter, center, 0); 27 | } 28 | 29 | public MacroCircle(int diameter, Point center, int rotationAngle) 30 | { 31 | super(rotationAngle); 32 | this.diameter = diameter; 33 | this.center = center; 34 | } 35 | 36 | public int getDiameter() 37 | { 38 | return diameter; 39 | } 40 | 41 | public Point getCenter() 42 | { 43 | return translate(center); 44 | } 45 | 46 | @Override 47 | public MacroPrimitive clone() 48 | { 49 | return new MacroCircle(diameter, center, getRotationAngle()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroOutline.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures.macro; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | public class MacroOutline extends MacroPrimitive 23 | { 24 | private ArrayList points = new ArrayList<>(); 25 | 26 | public MacroOutline() 27 | { 28 | } 29 | 30 | public MacroOutline(ArrayList points, int rotationAngle) 31 | { 32 | super(rotationAngle); 33 | this.points = points; 34 | } 35 | 36 | public void addPoint(Point point) 37 | { 38 | points.add(point); 39 | } 40 | 41 | public List getPoints() 42 | { 43 | return points; 44 | } 45 | 46 | public List getTranslatedPoints() 47 | { 48 | ArrayList result = new ArrayList<>(); 49 | for (Point p : points) 50 | result.add(translate(p)); 51 | 52 | return result; 53 | } 54 | 55 | @Override 56 | public MacroPrimitive clone() 57 | { 58 | return new MacroOutline(points, getRotationAngle()); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroPolygon.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.gerber.appertures.macro; 2 | 3 | import org.cirqwizard.geom.Point; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class MacroPolygon extends MacroPrimitive 9 | { 10 | private int verticesCount; 11 | private Point center; 12 | private int diameter; 13 | 14 | public MacroPolygon(int verticesCount, Point center, int diameter, int rotationAngle) 15 | { 16 | super(rotationAngle); 17 | this.verticesCount = verticesCount; 18 | this.center = center; 19 | this.diameter = diameter; 20 | } 21 | 22 | public int getVerticesCount() 23 | { 24 | return verticesCount; 25 | } 26 | 27 | public Point getCenter() 28 | { 29 | return center; 30 | } 31 | 32 | public int getDiameter() 33 | { 34 | return diameter; 35 | } 36 | 37 | public List getPoints() 38 | { 39 | double angle = getRotationAngle(); 40 | int angularIncrement = 360 / verticesCount; 41 | ArrayList points = new ArrayList<>(); 42 | for (int i = 0; i < verticesCount; i++) 43 | { 44 | double theta = angle / 180 * Math.PI; 45 | Point p = center.add(new Point(diameter / 2, 0)); 46 | points.add(new Point((int)(Math.cos(theta) * p.getX() - Math.sin(theta) * p.getY()), 47 | (int)(Math.sin(theta) * p.getX() + Math.cos(theta) * p.getY()))); 48 | angle += angularIncrement; 49 | } 50 | return points; 51 | } 52 | 53 | @Override 54 | public MacroPrimitive clone() 55 | { 56 | return new MacroPolygon(verticesCount, new Point(center.getX(), center.getY()), 57 | diameter, getRotationAngle()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroPrimitive.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures.macro; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | public abstract class MacroPrimitive 20 | { 21 | private int rotationAngle; 22 | 23 | protected MacroPrimitive() 24 | { 25 | this(0); 26 | } 27 | 28 | protected MacroPrimitive(int rotationAngle) 29 | { 30 | this.rotationAngle = rotationAngle; 31 | } 32 | 33 | protected Point translate(Point p) 34 | { 35 | if (rotationAngle == 0) 36 | return p; 37 | double theta = Math.toRadians(rotationAngle); 38 | double x = Math.cos(theta) * p.getX() - Math.sin(theta) * p.getY(); 39 | double y = Math.sin(theta) * p.getX() + Math.cos(theta) * p.getY(); 40 | return new Point((int) x, (int) y); 41 | } 42 | 43 | public int getRotationAngle() 44 | { 45 | return rotationAngle; 46 | } 47 | 48 | public void setRotationAngle(int rotationAngle) 49 | { 50 | this.rotationAngle = rotationAngle; 51 | } 52 | 53 | public abstract MacroPrimitive clone(); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/gerber/appertures/macro/MacroVectorLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.gerber.appertures.macro; 16 | 17 | import org.cirqwizard.geom.Point; 18 | 19 | public class MacroVectorLine extends MacroPrimitive 20 | { 21 | private int width; 22 | private Point start; 23 | private Point end; 24 | 25 | public MacroVectorLine(int width, Point start, Point end, int rotationAngle) 26 | { 27 | super(rotationAngle); 28 | this.width = width; 29 | this.start = start; 30 | this.end = end; 31 | } 32 | 33 | public int getWidth() 34 | { 35 | return width; 36 | } 37 | 38 | public Point getStart() 39 | { 40 | return start; 41 | } 42 | 43 | public Point getEnd() 44 | { 45 | return end; 46 | } 47 | 48 | public Point getTranslatedStart() 49 | { 50 | return translate(start); 51 | } 52 | 53 | public Point getTranslatedEnd() 54 | { 55 | return translate(end); 56 | } 57 | 58 | @Override 59 | public MacroPrimitive clone() 60 | { 61 | return new MacroVectorLine(width, start, end, getRotationAngle()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/layers/Layer.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.layers; 15 | 16 | import org.cirqwizard.geom.Point; 17 | 18 | import java.util.List; 19 | 20 | public class Layer 21 | { 22 | private List elements; 23 | 24 | public Layer() 25 | { 26 | } 27 | 28 | public Layer(List elements) 29 | { 30 | this.elements = elements; 31 | } 32 | 33 | public List getElements() 34 | { 35 | return elements; 36 | } 37 | 38 | public void setElements(List elements) 39 | { 40 | this.elements = elements; 41 | } 42 | 43 | public Point getMinPoint() 44 | { 45 | int minX = elements.stream().mapToInt(p -> p.getMin().getX()).min().getAsInt(); 46 | int minY = elements.stream().mapToInt(p -> p.getMin().getY()).min().getAsInt(); 47 | return new Point(minX, minY); 48 | } 49 | 50 | public Point getMaxPoint() 51 | { 52 | int maxX = elements.stream().mapToInt(p -> p.getMax().getX()).max().getAsInt(); 53 | int maxY = elements.stream().mapToInt(p -> p.getMax().getY()).max().getAsInt(); 54 | return new Point(maxX, maxY); 55 | } 56 | 57 | public void move(Point p) 58 | { 59 | elements.stream().forEach(e -> e.move(p)); 60 | } 61 | 62 | public void rotate(boolean clockwise) 63 | { 64 | elements.stream().forEach(e -> e.rotate(clockwise)); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/layers/LayerElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | package org.cirqwizard.layers; 15 | 16 | import javafx.scene.canvas.GraphicsContext; 17 | import org.cirqwizard.geom.Point; 18 | 19 | public interface LayerElement extends Cloneable 20 | { 21 | Point getMin(); 22 | Point getMax(); 23 | void move(Point point); 24 | void rotate(boolean clockwise); 25 | Object clone() throws CloneNotSupportedException; 26 | void render(GraphicsContext g); 27 | boolean isVisible(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/logging/LoggerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.logging; 16 | 17 | import java.io.IOException; 18 | import java.util.logging.FileHandler; 19 | import java.util.logging.Level; 20 | import java.util.logging.Logger; 21 | import java.util.logging.SimpleFormatter; 22 | 23 | 24 | public class LoggerFactory 25 | { 26 | private static Logger applicationLogger; 27 | private static Logger serialLogger; 28 | 29 | static 30 | { 31 | applicationLogger = Logger.getLogger("cirqwizard-application"); 32 | serialLogger = Logger.getLogger("cirqwizard-serial"); 33 | try 34 | { 35 | FileHandler applicationFileHandler = new FileHandler("%t/cirqwizard-application.log", true); 36 | applicationFileHandler.setFormatter(new SimpleFormatter()); 37 | applicationLogger.addHandler(applicationFileHandler); 38 | } 39 | catch (IOException e) 40 | { 41 | applicationLogger.log(Level.SEVERE, "Could not create file handler for application logger", e); 42 | } 43 | try 44 | { 45 | FileHandler serialFileHandler = new FileHandler("%t/cirqwizard-serial.log", true); 46 | serialFileHandler.setFormatter(new SimpleFormatter()); 47 | serialLogger.setLevel(Level.ALL); 48 | serialLogger.addHandler(serialFileHandler); 49 | } 50 | catch (IOException e) 51 | { 52 | applicationLogger.log(Level.SEVERE, "Could not create file handler for serial logger"); 53 | } 54 | } 55 | 56 | public static Logger getApplicationLogger() 57 | { 58 | return applicationLogger; 59 | } 60 | 61 | public static Logger getSerialLogger() 62 | { 63 | return serialLogger; 64 | } 65 | 66 | public static void logException(String message, Throwable t) 67 | { 68 | applicationLogger.log(Level.SEVERE, message,t); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/post/PostProcessorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.post; 16 | 17 | 18 | public class PostProcessorFactory 19 | { 20 | public static Postprocessor getPostProcessor() 21 | { 22 | return new RTPostprocessor(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/post/Postprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.post; 16 | 17 | 18 | public interface Postprocessor 19 | { 20 | public void home(StringBuilder str, Integer yDiff); 21 | 22 | public void setupG54(StringBuilder str, int x, int y, int z); 23 | public void selectWCS(StringBuilder str); 24 | public void selectMachineWS(StringBuilder str); 25 | 26 | public void header(StringBuilder str); 27 | public void footer(StringBuilder str); 28 | public void comment(StringBuilder str, String comment); 29 | 30 | public void rapid(StringBuilder str, Integer x, Integer y, Integer z); 31 | public void linearInterpolation(StringBuilder str, Integer x, Integer y, Integer z, Integer feed); 32 | public void circularInterpolation(StringBuilder str, boolean clockwise, Integer x, Integer y, Integer z, Integer i, Integer j, Integer feed); 33 | 34 | public void spindleOn(StringBuilder str, int speed); 35 | public void spindleOff(StringBuilder str); 36 | 37 | public void syringeOn(StringBuilder str); 38 | public void syringeOff(StringBuilder str); 39 | 40 | public void pause(StringBuilder str, int duration); 41 | 42 | public void rotatePP(StringBuilder str, int angle, int feed); 43 | public void rotatePP(StringBuilder str, int angle); 44 | public void vacuumOn(StringBuilder str); 45 | public void vacuumOff(StringBuilder str); 46 | 47 | public void getFirmwareVersion(StringBuilder str); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/pp/ComponentId.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.pp; 16 | 17 | 18 | public class ComponentId 19 | { 20 | private String packaging; 21 | private String value; 22 | 23 | public ComponentId(String packaging, String value) 24 | { 25 | this.packaging = packaging; 26 | this.value = value; 27 | } 28 | 29 | public String getPackaging() 30 | { 31 | return packaging; 32 | } 33 | 34 | public String getValue() 35 | { 36 | return value; 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o) 41 | { 42 | if (this == o) return true; 43 | if (o == null || getClass() != o.getClass()) return false; 44 | 45 | ComponentId that = (ComponentId) o; 46 | 47 | if (packaging != null ? !packaging.equals(that.packaging) : that.packaging != null) return false; 48 | if (value != null ? !value.equals(that.value) : that.value != null) return false; 49 | 50 | return true; 51 | } 52 | 53 | @Override 54 | public int hashCode() 55 | { 56 | int result = packaging != null ? packaging.hashCode() : 0; 57 | result = 31 * result + (value != null ? value.hashCode() : 0); 58 | return result; 59 | } 60 | 61 | @Override 62 | public String toString() 63 | { 64 | return "ComponentId{" + 65 | "packaging='" + packaging + '\'' + 66 | ", value='" + value + '\'' + 67 | '}'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/DataReceivedListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | import java.util.EventListener; 18 | 19 | 20 | public abstract class DataReceivedListener implements EventListener 21 | { 22 | public abstract void dataReceived(String data); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/ExecutionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | 18 | public class ExecutionException extends Exception 19 | { 20 | public ExecutionException(String message) 21 | { 22 | super(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/SerialException.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | 18 | public class SerialException extends Exception 19 | { 20 | public SerialException(String message) 21 | { 22 | super(message); 23 | } 24 | 25 | public SerialException(Throwable throwable) 26 | { 27 | super(throwable); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/SerialInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | 18 | import java.io.IOException; 19 | 20 | 21 | public interface SerialInterface 22 | { 23 | 24 | public void setBootloaderMode(boolean bootloader) throws SerialException; 25 | public void write(int b) throws IOException; 26 | public void write(byte[] b) throws IOException; 27 | public int readByte() throws IOException; 28 | public void close() throws SerialException; 29 | public void send(String str, long timeout) throws SerialException, ExecutionException, InterruptedException; 30 | public void send(String str, long timeout, StringBuilder response, boolean suppressExceptions) throws SerialException, ExecutionException, InterruptedException; 31 | public String getPortName(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/SerialInterfaceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | 18 | import jssc.SerialPortList; 19 | 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | 24 | public class SerialInterfaceFactory 25 | { 26 | 27 | public static List getSerialInterfaces(SerialInterface currentSerialInterface) 28 | { 29 | return Arrays.asList(SerialPortList.getPortNames()); 30 | } 31 | 32 | public static SerialInterface autodetect() throws SerialException 33 | { 34 | for (String port : SerialPortList.getPortNames()) 35 | { 36 | if (port.startsWith("/dev/tty.usbserial") || port.startsWith("/dev/ttyUSB")) 37 | return new SerialInterfaceImpl(port, 38400); 38 | } 39 | 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/serial/SerialInterfaceStub.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.serial; 16 | 17 | import org.cirqwizard.logging.LoggerFactory; 18 | 19 | import java.io.IOException; 20 | import java.util.Random; 21 | 22 | 23 | public class SerialInterfaceStub implements SerialInterface 24 | { 25 | @Override 26 | public void setBootloaderMode(boolean bootloader) throws SerialException 27 | { 28 | } 29 | 30 | @Override 31 | public void write(int b) throws IOException 32 | { 33 | } 34 | 35 | @Override 36 | public void write(byte[] b) throws IOException 37 | { 38 | } 39 | 40 | @Override 41 | public int readByte() throws IOException 42 | { 43 | return -1; 44 | } 45 | 46 | @Override 47 | public void close() throws SerialException 48 | { 49 | } 50 | 51 | @Override 52 | public void send(String str, long timeout) throws SerialException, ExecutionException, InterruptedException 53 | { 54 | send(str, timeout, null, false); 55 | } 56 | 57 | @Override 58 | public void send(String str, long timeout, StringBuilder response, boolean suppressExceptions) throws SerialException, ExecutionException, InterruptedException 59 | { 60 | LoggerFactory.getSerialLogger().fine(str); 61 | try 62 | { 63 | Thread.sleep(50); 64 | } 65 | catch (InterruptedException e) 66 | { 67 | // Interrupted. That's fine 68 | } 69 | } 70 | 71 | @Override 72 | public String getPortName() 73 | { 74 | return ""; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/ApplicationSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | import java.util.logging.Level; 18 | 19 | public class ApplicationSettings extends SettingsGroup 20 | { 21 | @PersistentPreference 22 | private UserPreference serialPort = new UserPreference<>("Serial port", null, "", PreferenceType.SERIAL_PORT); 23 | 24 | @PersistentPreference 25 | private UserPreference logLevel = new UserPreference<>("Log level", Level.INFO, "").setItems(Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO, 26 | Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL).setInstantiator(Level::parse); 27 | 28 | @PersistentPreference 29 | private UserPreference processingThreads = new UserPreference<>("Processing threads", Runtime.getRuntime().availableProcessors(), "", PreferenceType.INTEGER); 30 | 31 | @Override 32 | public String getName() 33 | { 34 | return "Application"; 35 | } 36 | 37 | @Override 38 | public String getPreferencesPrefix() 39 | { 40 | return "application"; 41 | } 42 | 43 | public UserPreference getSerialPort() 44 | { 45 | return serialPort; 46 | } 47 | 48 | public void setSerialPort(UserPreference serialPort) 49 | { 50 | this.serialPort = serialPort; 51 | } 52 | 53 | public UserPreference getLogLevel() 54 | { 55 | return logLevel; 56 | } 57 | 58 | public void setLogLevel(UserPreference logLevel) 59 | { 60 | this.logLevel = logLevel; 61 | } 62 | 63 | public UserPreference getProcessingThreads() 64 | { 65 | return processingThreads; 66 | } 67 | 68 | public void setProcessingThreads(UserPreference processingThreads) 69 | { 70 | this.processingThreads = processingThreads; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/DistanceUnit.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | import java.math.BigDecimal; 18 | 19 | public enum DistanceUnit 20 | { 21 | INCHES(new BigDecimal(25_400), "Inches"), MM(new BigDecimal(1000), "Millimeters"), THOU(new BigDecimal("25.4"), "Thou"); 22 | 23 | private BigDecimal multiplier; 24 | private String name; 25 | 26 | DistanceUnit(BigDecimal multiplier, String name) 27 | { 28 | this.multiplier = multiplier; 29 | this.name = name; 30 | } 31 | 32 | public BigDecimal getMultiplier() 33 | { 34 | return multiplier; 35 | } 36 | 37 | public String getName() 38 | { 39 | return name; 40 | } 41 | 42 | @Override 43 | public String toString() 44 | { 45 | return name; 46 | } 47 | 48 | public static DistanceUnit forName(String name) 49 | { 50 | for (DistanceUnit u : values()) 51 | if (u.getName().equals(name)) 52 | return u; 53 | throw new IllegalArgumentException("Could not find DistanceUnit for " + name); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/InsulationMillingSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | public class InsulationMillingSettings extends SettingsGroup 18 | { 19 | @PersistentPreference 20 | @PreferenceGroup(name = "Tools") 21 | private UserPreference toolTable = new UserPreference<>("Tool table", "", "", PreferenceType.TOOL_TABLE); 22 | 23 | @PersistentPreference 24 | @PreferenceGroup(name = "Heights") 25 | private UserPreference clearance = new UserPreference<>("Clearance", 5000, "mm"); 26 | 27 | @PersistentPreference 28 | @PreferenceGroup(name = "Heights") 29 | private UserPreference safetyHeight = new UserPreference<>("Safety height", 2000, "mm"); 30 | 31 | @PersistentPreference 32 | @PreferenceGroup(name = "Heights") 33 | private UserPreference workingHeight = new UserPreference<>("Working height", -50, "mm"); 34 | @Override 35 | public String getName() 36 | { 37 | return "Isolation milling"; 38 | } 39 | 40 | @Override 41 | public String getPreferencesPrefix() 42 | { 43 | return "insulation-milling"; 44 | } 45 | 46 | public UserPreference getClearance() 47 | { 48 | return clearance; 49 | } 50 | 51 | public void setClearance(UserPreference clearance) 52 | { 53 | this.clearance = clearance; 54 | } 55 | 56 | public UserPreference getSafetyHeight() 57 | { 58 | return safetyHeight; 59 | } 60 | 61 | public void setSafetyHeight(UserPreference safetyHeight) 62 | { 63 | this.safetyHeight = safetyHeight; 64 | } 65 | 66 | public UserPreference getWorkingHeight() 67 | { 68 | return workingHeight; 69 | } 70 | 71 | public void setWorkingHeight(UserPreference workingHeight) 72 | { 73 | this.workingHeight = workingHeight; 74 | } 75 | 76 | public UserPreference getToolTable() 77 | { 78 | return toolTable; 79 | } 80 | 81 | public void setToolTable(UserPreference toolTable) 82 | { 83 | this.toolTable = toolTable; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/PersistentPreference.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface PersistentPreference 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/PreferenceGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface PreferenceGroup 22 | { 23 | String name(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/PreferenceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.settings; 16 | 17 | public enum PreferenceType 18 | { 19 | INTEGER, PERCENT, COMBO_BOX, SERIAL_PORT, TOOL_TABLE, USB_CAMERA; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/settings/ZerosOmission.java: -------------------------------------------------------------------------------- 1 | package org.cirqwizard.settings; 2 | 3 | /** 4 | * Created by simon on 20.06.17. 5 | */ 6 | public enum ZerosOmission 7 | { 8 | LEADING_OMITTED(false, "Leading omitted"), TRAILING_OMITTED(true, "Trailing omitted"); 9 | 10 | ZerosOmission(boolean leadingZeros, String name) 11 | { 12 | this.leadingZeros = leadingZeros; 13 | this.name = name; 14 | } 15 | 16 | private boolean leadingZeros; 17 | private String name; 18 | 19 | public boolean isLeadingZeros() 20 | { 21 | return leadingZeros; 22 | } 23 | 24 | public String getName() 25 | { 26 | return name; 27 | } 28 | 29 | public static ZerosOmission forName(String name) 30 | { 31 | for (ZerosOmission u : values()) 32 | if (u.getName().equals(name)) 33 | return u; 34 | throw new IllegalArgumentException("Could not find ZerosOmission for " + name); 35 | } 36 | 37 | @Override 38 | public String toString() 39 | { 40 | return name; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/cirqwizard/stm32/BootloaderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | This program is free software: you can redistribute it and/or modify 3 | it under the terms of the GNU General Public License version 3 as published by 4 | the Free Software Foundation. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | */ 14 | 15 | package org.cirqwizard.stm32; 16 | 17 | 18 | public class BootloaderException extends Exception 19 | { 20 | public BootloaderException(String message) 21 | { 22 | super(message); 23 | } 24 | 25 | public BootloaderException(String message, Throwable cause) 26 | { 27 | super(message, cause); 28 | } 29 | 30 | public BootloaderException(Throwable cause) 31 | { 32 | super(cause); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simonsalykov/cirqwizard/c7e9be6694f987e91f684ce6f7e8872e7246b88e/src/main/resources/application.png -------------------------------------------------------------------------------- /src/main/resources/org/cirqwizard/fx/Homing.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/org/cirqwizard/fx/Welcome.fxml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /src/main/resources/org/cirqwizard/fx/cirqwizard-linux.css: -------------------------------------------------------------------------------- 1 | .h1 { 2 | -fx-font-weight: bolder!important; 3 | } -------------------------------------------------------------------------------- /src/main/resources/org/cirqwizard/fx/common/Message.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |