use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.
the class CreateCalibrationTargetGui method saveFile.
private void saveFile(boolean sendToPrinter) {
// grab the focus and force what the user is editing to be saved
File f;
// see where the document is to be sent
if (sendToPrinter) {
// dummy to make the code below happy and less complex
f = new File("");
} else {
f = FileSystemView.getFileSystemView().getHomeDirectory();
f = new File(f, "calibration_target.pdf");
f = BoofSwingUtil.fileChooser(this, false, f.getPath());
if (f == null) {
return;
}
if (f.isDirectory()) {
JOptionPane.showMessageDialog(this, "Can't save to a directory!");
return;
}
}
// Make sure the file has the correct extension
String outputFile = f.getAbsolutePath();
String ext = FilenameUtils.getExtension(outputFile);
if (ext.compareToIgnoreCase("pdf") != 0) {
outputFile = FilenameUtils.removeExtension(outputFile);
outputFile += "." + "pdf";
}
try {
switch(selectedType) {
case CHESSBOARD:
{
ConfigChessboard config = (ConfigChessboard) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.chessboard((float) config.squareWidth);
}
break;
case SQUARE_GRID:
{
ConfigSquareGrid config = (ConfigSquareGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.squareGrid((float) config.squareWidth, (float) config.spaceWidth);
}
break;
case CIRCLE_GRID:
{
ConfigCircleRegularGrid config = (ConfigCircleRegularGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.circleGrid((float) config.circleDiameter, (float) config.centerDistance);
}
break;
case CIRCLE_HEX:
{
ConfigCircleHexagonalGrid config = (ConfigCircleHexagonalGrid) selectedCalib;
CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
generator.sendToPrinter = sendToPrinter;
generator.circleHexagonal((float) config.circleDiameter, (float) config.centerDistance);
}
break;
default:
throw new RuntimeException("Unknown type " + selectedType);
}
} catch (IOException e) {
BoofSwingUtil.warningDialog(this, e);
}
}
Aggregations