Ejemplo n.º 1
0
 public ArrayList<String> loadPrintJobSelection(String name) {
   ArrayList<String> list = new ArrayList();
   PrintJobSelection job;
   job = db.getPrintJobSelection(name);
   list.add(job.getName());
   list.add(job.getPrinterConfiguration());
   MasterSubsectionPane pane = MainWindow.printJobPanel.getMasterSubsectionPane();
   pane.removeAllSubsections();
   for (SubsetSelection subset : job.getSubsetConfigurationList()) {
     pane.addNewSubsectionPanel(new SubsectionPanel(subset));
   }
   for (ExtruderMaterialSelection extruder : job.getMaterials()) {
     PrintJobPanel.extruderMaterialArrayListForPrintJob.add(extruder.getMaterial());
   }
   return list;
 }
Ejemplo n.º 2
0
  public Boolean savePrintJobConfiguration(
      String name,
      String printerName,
      ArrayList<SubsectionPanel> panels,
      JList extruderMaterialsMapList)
      throws BadFieldException {
    PrintJobSelection job = new PrintJobSelection();
    PrinterConfiguration printer = db.getPrinterConfiguration(printerName);
    job.setName(name);
    job.setPrinterConfiguration(printerName);
    if (printer.getExtruderList().size()
        < PrintJobPanel.extruderMaterialArrayListForPrintJob.size())
      throw new BadFieldException("You can not assign more Materials than you have extruders.");
    ArrayList<ExtruderMaterialSelection> extruderMaterialSelection = new ArrayList<>();
    for (int i = 0; i < PrintJobPanel.extruderMaterialArrayListForPrintJob.size(); i++) {
      extruderMaterialSelection.add(
          new ExtruderMaterialSelection(
              printer.getExtruderList().get(i).getName(),
              PrintJobPanel.extruderMaterialArrayListForPrintJob.get(i)));
    }
    job.setMaterials(extruderMaterialSelection);

    job.setSubsetConfigurationList(new ArrayList<SubsetSelection>());
    for (int i = 0; i < panels.size(); i++) {

      SubsetSelection subset = new SubsetSelection();

      if (panels.get(i).getFileList().size() != panels.get(i).getExtruderList().size()) {
        throw new BadFieldException("All files must have a material associated with it.");
      }

      subset.setFileConfigurations(new ArrayList<FileSelection>());

      for (int j = 0; j < panels.get(i).getFileList().size(); j++) {
        String extruderName = panels.get(i).getExtruderList().get(j);
        int extruderNum = Integer.parseInt(extruderName.substring(0, 2));
        String materialName =
            PrintJobPanel.extruderMaterialArrayListForPrintJob.get(j).substring(3);
        String fileName = panels.get(i).getFileList().get(j);

        FileSelection fileSelection = new FileSelection(extruderName, materialName, fileName);
        fileSelection.setExtruderNum(extruderNum);

        /*
        for(int k = 0; k < PrintJobPanel.extruderMaterialArrayListForPrintJob.size(); k++) {
            if(PrintJobPanel.extruderMaterialArrayListForPrintJob.get(k).equals(extruderName)) {
                fileSelection.setExtruderNum(k);
            }
        }
        */

        subset.getFileConfigurations().add(fileSelection);

        subset.setPrintConfiguration(panels.get(i).getPrint());
      }
      try {
        d = Double.valueOf(panels.get(i).getStartZ());
        if (d < 0)
          throw new BadFieldException(
              "Subset start must be a double precision value greater than or equal to 0.");
        subset.setBottomZ(d);
      } catch (NumberFormatException e) {
        throw new BadFieldException(
            "Subset start must be a double precision value greater than or equal to 0.");
      }

      try {
        d = Double.valueOf(panels.get(i).getFinishZ());
        if (d < 0)
          throw new BadFieldException(
              "Subset finish must be a double precision value greater than or equal to 0.");
        subset.setTopZ(d);
      } catch (NumberFormatException e) {
        throw new BadFieldException(
            "Subset finish must be a double precision value greater than or equal to 0.");
      }
      job.getSubsetConfigurationList().add(subset);
    }
    return db.savePrintJobSelection(job);
  }