mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	png export parameters routed to SLA print config. PngExportDialog disabled.
This commit is contained in:
		
							parent
							
								
									057dfa56e3
								
							
						
					
					
						commit
						4796ef3fb2
					
				
					 3 changed files with 138 additions and 104 deletions
				
			
		|  | @ -214,6 +214,35 @@ void PrintController::gen_support_material(PrintObject *pobj) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| PrintController::PngExportData | ||||
| PrintController::query_png_export_data(const DynamicPrintConfig& conf) | ||||
| { | ||||
|     PngExportData ret; | ||||
| 
 | ||||
|     auto zippath = query_destination_path("Output zip file", "*.zip", "out"); | ||||
| 
 | ||||
|     ret.zippath = zippath; | ||||
| 
 | ||||
|     ret.width_mm = conf.opt_float("display_width"); | ||||
|     ret.height_mm = conf.opt_float("display_height"); | ||||
| 
 | ||||
|     ret.width_px = conf.opt_int("display_pixels_x"); | ||||
|     ret.height_px = conf.opt_int("display_pixels_y"); | ||||
| 
 | ||||
|     auto opt_corr = conf.opt<ConfigOptionFloats>("printer_correction"); | ||||
| 
 | ||||
|     if(opt_corr) { | ||||
|         ret.corr_x = opt_corr->values[0]; | ||||
|         ret.corr_y = opt_corr->values[1]; | ||||
|         ret.corr_z = opt_corr->values[2]; | ||||
|     } | ||||
| 
 | ||||
|     ret.exp_time_first_s = conf.opt_float("initial_exposure_time"); | ||||
|     ret.exp_time_s = conf.opt_float("exposure_time"); | ||||
| 
 | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| void PrintController::slice(AppControllerBoilerplate::ProgresIndicatorPtr pri) | ||||
| { | ||||
|     auto st = pri->state(); | ||||
|  | @ -262,18 +291,23 @@ void PrintController::slice_to_png() | |||
| { | ||||
|     using Pointf3 = Vec3d; | ||||
| 
 | ||||
|     auto exd = query_png_export_data(); | ||||
| 
 | ||||
|     if(exd.zippath.empty()) return; | ||||
| 
 | ||||
|     auto presetbundle = GUI::get_preset_bundle(); | ||||
| 
 | ||||
|     assert(presetbundle); | ||||
| 
 | ||||
|     auto conf = presetbundle->full_config(); | ||||
|     auto pt = presetbundle->printers.get_selected_preset().printer_technology(); | ||||
|     if(pt != ptSLA) { | ||||
|         report_issue(IssueType::ERR, _("Printer technology is not SLA!"), | ||||
|                      _("Error")); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     auto conf = presetbundle->full_config(); | ||||
|     conf.validate(); | ||||
| 
 | ||||
|     auto exd = query_png_export_data(conf); | ||||
|     if(exd.zippath.empty()) return; | ||||
| 
 | ||||
|     try { | ||||
|         print_->apply_config(conf); | ||||
|         print_->validate(); | ||||
|  |  | |||
|  | @ -190,7 +190,7 @@ protected: | |||
|     }; | ||||
| 
 | ||||
|     // Should display a dialog with the input fields for printing to png
 | ||||
|     PngExportData query_png_export_data(); | ||||
|     PngExportData query_png_export_data(const DynamicPrintConfig&); | ||||
| 
 | ||||
|     // The previous export data, to pre-populate the dialog
 | ||||
|     PngExportData prev_expdata_; | ||||
|  |  | |||
|  | @ -309,120 +309,120 @@ void AppController::set_global_progress_indicator( | |||
|     } | ||||
| } | ||||
| 
 | ||||
| PrintController::PngExportData PrintController::query_png_export_data() | ||||
| { | ||||
| //PrintController::PngExportData PrintController::collect_png_export_data()
 | ||||
| //{
 | ||||
| 
 | ||||
|     // Implement the logic of the PngExportDialog
 | ||||
|     class PngExportView: public PngExportDialog { | ||||
|         double ratio_, bs_ratio_; | ||||
|         PrintController& ctl_; | ||||
|     public: | ||||
| //    // Implement the logic of the PngExportDialog
 | ||||
| //    class PngExportView: public PngExportDialog {
 | ||||
| //        double ratio_, bs_ratio_;
 | ||||
| //        PrintController& ctl_;
 | ||||
| //    public:
 | ||||
| 
 | ||||
|         PngExportView(PrintController& ctl): | ||||
|             PngExportDialog(wxTheApp->GetTopWindow()), ctl_(ctl) | ||||
|         { | ||||
|             ratio_ = double(spin_reso_width_->GetValue()) / | ||||
|                     spin_reso_height_->GetValue(); | ||||
| //        PngExportView(PrintController& ctl):
 | ||||
| //            PngExportDialog(wxTheApp->GetTopWindow()), ctl_(ctl)
 | ||||
| //        {
 | ||||
| //            ratio_ = double(spin_reso_width_->GetValue()) /
 | ||||
| //                    spin_reso_height_->GetValue();
 | ||||
| 
 | ||||
|             bs_ratio_ = bed_width_spin_->GetValue() / | ||||
|                     bed_height_spin_->GetValue(); | ||||
|         } | ||||
| //            bs_ratio_ = bed_width_spin_->GetValue() /
 | ||||
| //                    bed_height_spin_->GetValue();
 | ||||
| //        }
 | ||||
| 
 | ||||
|         PngExportData export_data() const { | ||||
|             PrintController::PngExportData ret; | ||||
|             ret.zippath = filepick_ctl_->GetPath(); | ||||
|             ret.width_px = spin_reso_width_->GetValue(); | ||||
|             ret.height_px = spin_reso_height_->GetValue(); | ||||
|             ret.width_mm = bed_width_spin_->GetValue(); | ||||
|             ret.height_mm = bed_height_spin_->GetValue(); | ||||
|             ret.exp_time_s = exptime_spin_->GetValue(); | ||||
|             ret.exp_time_first_s = exptime_first_spin_->GetValue(); | ||||
|             ret.corr_x = corr_spin_x_->GetValue(); | ||||
|             ret.corr_y = corr_spin_y_->GetValue(); | ||||
|             ret.corr_z = corr_spin_z_->GetValue(); | ||||
|             return ret; | ||||
|         } | ||||
| //        PngExportData export_data() const {
 | ||||
| //            PrintController::PngExportData ret;
 | ||||
| //            ret.zippath = filepick_ctl_->GetPath();
 | ||||
| //            ret.width_px = spin_reso_width_->GetValue();
 | ||||
| //            ret.height_px = spin_reso_height_->GetValue();
 | ||||
| //            ret.width_mm = bed_width_spin_->GetValue();
 | ||||
| //            ret.height_mm = bed_height_spin_->GetValue();
 | ||||
| //            ret.exp_time_s = exptime_spin_->GetValue();
 | ||||
| //            ret.exp_time_first_s = exptime_first_spin_->GetValue();
 | ||||
| //            ret.corr_x = corr_spin_x_->GetValue();
 | ||||
| //            ret.corr_y = corr_spin_y_->GetValue();
 | ||||
| //            ret.corr_z = corr_spin_z_->GetValue();
 | ||||
| //            return ret;
 | ||||
| //        }
 | ||||
| 
 | ||||
|         void prefill(const PngExportData& data) { | ||||
|             filepick_ctl_->SetPath(data.zippath); | ||||
|             spin_reso_width_->SetValue(data.width_px); | ||||
|             spin_reso_height_->SetValue(data.height_px); | ||||
|             bed_width_spin_->SetValue(data.width_mm); | ||||
|             bed_height_spin_->SetValue(data.height_mm); | ||||
|             exptime_spin_->SetValue(data.exp_time_s); | ||||
|             exptime_first_spin_->SetValue(data.exp_time_first_s); | ||||
|             corr_spin_x_->SetValue(data.corr_x); | ||||
|             corr_spin_y_->SetValue(data.corr_y); | ||||
|             corr_spin_z_->SetValue(data.corr_z); | ||||
|             if(data.zippath.empty()) export_btn_->Disable(); | ||||
|             else export_btn_->Enable(); | ||||
|         } | ||||
| //        void prefill(const PngExportData& data) {
 | ||||
| //            filepick_ctl_->SetPath(data.zippath);
 | ||||
| //            spin_reso_width_->SetValue(data.width_px);
 | ||||
| //            spin_reso_height_->SetValue(data.height_px);
 | ||||
| //            bed_width_spin_->SetValue(data.width_mm);
 | ||||
| //            bed_height_spin_->SetValue(data.height_mm);
 | ||||
| //            exptime_spin_->SetValue(data.exp_time_s);
 | ||||
| //            exptime_first_spin_->SetValue(data.exp_time_first_s);
 | ||||
| //            corr_spin_x_->SetValue(data.corr_x);
 | ||||
| //            corr_spin_y_->SetValue(data.corr_y);
 | ||||
| //            corr_spin_z_->SetValue(data.corr_z);
 | ||||
| //            if(data.zippath.empty()) export_btn_->Disable();
 | ||||
| //            else export_btn_->Enable();
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void ResoLock( wxCommandEvent& /*event*/ ) override { | ||||
|             ratio_ = double(spin_reso_width_->GetValue()) / | ||||
|                     double(spin_reso_height_->GetValue()); | ||||
|         } | ||||
| //        virtual void ResoLock( wxCommandEvent& /*event*/ ) override {
 | ||||
| //            ratio_ = double(spin_reso_width_->GetValue()) /
 | ||||
| //                    double(spin_reso_height_->GetValue());
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void BedsizeLock( wxCommandEvent& /*event*/ ) override { | ||||
|             bs_ratio_ = bed_width_spin_->GetValue() / | ||||
|                     bed_height_spin_->GetValue(); | ||||
|         } | ||||
| //        virtual void BedsizeLock( wxCommandEvent& /*event*/ ) override {
 | ||||
| //            bs_ratio_ = bed_width_spin_->GetValue() /
 | ||||
| //                    bed_height_spin_->GetValue();
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void EvalResoSpin( wxCommandEvent& event ) override { | ||||
|             if(reso_lock_btn_->GetValue()) { | ||||
|                 if(event.GetId() == spin_reso_width_->GetId()) { | ||||
|                     spin_reso_height_->SetValue( | ||||
|                             std::round(spin_reso_width_->GetValue()/ratio_)); | ||||
|                     spin_reso_height_->Update(); | ||||
|                 } else { | ||||
|                     spin_reso_width_->SetValue( | ||||
|                             std::round(spin_reso_height_->GetValue()*ratio_)); | ||||
|                     spin_reso_width_->Update(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| //        virtual void EvalResoSpin( wxCommandEvent& event ) override {
 | ||||
| //            if(reso_lock_btn_->GetValue()) {
 | ||||
| //                if(event.GetId() == spin_reso_width_->GetId()) {
 | ||||
| //                    spin_reso_height_->SetValue(
 | ||||
| //                            std::round(spin_reso_width_->GetValue()/ratio_));
 | ||||
| //                    spin_reso_height_->Update();
 | ||||
| //                } else {
 | ||||
| //                    spin_reso_width_->SetValue(
 | ||||
| //                            std::round(spin_reso_height_->GetValue()*ratio_));
 | ||||
| //                    spin_reso_width_->Update();
 | ||||
| //                }
 | ||||
| //            }
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void EvalBedSpin( wxCommandEvent& event ) override { | ||||
|             if(bedsize_lock_btn_->GetValue()) { | ||||
|                 if(event.GetId() == bed_width_spin_->GetId()) { | ||||
|                     bed_height_spin_->SetValue( | ||||
|                             std::round(bed_width_spin_->GetValue()/bs_ratio_)); | ||||
|                     bed_height_spin_->Update(); | ||||
|                 } else { | ||||
|                     bed_width_spin_->SetValue( | ||||
|                             std::round(bed_height_spin_->GetValue()*bs_ratio_)); | ||||
|                     bed_width_spin_->Update(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| //        virtual void EvalBedSpin( wxCommandEvent& event ) override {
 | ||||
| //            if(bedsize_lock_btn_->GetValue()) {
 | ||||
| //                if(event.GetId() == bed_width_spin_->GetId()) {
 | ||||
| //                    bed_height_spin_->SetValue(
 | ||||
| //                            std::round(bed_width_spin_->GetValue()/bs_ratio_));
 | ||||
| //                    bed_height_spin_->Update();
 | ||||
| //                } else {
 | ||||
| //                    bed_width_spin_->SetValue(
 | ||||
| //                            std::round(bed_height_spin_->GetValue()*bs_ratio_));
 | ||||
| //                    bed_width_spin_->Update();
 | ||||
| //                }
 | ||||
| //            }
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void onFileChanged( wxFileDirPickerEvent& event ) { | ||||
|             if(filepick_ctl_->GetPath().IsEmpty()) export_btn_->Disable(); | ||||
|             else export_btn_->Enable(); | ||||
|         } | ||||
| //        virtual void onFileChanged( wxFileDirPickerEvent& event ) {
 | ||||
| //            if(filepick_ctl_->GetPath().IsEmpty()) export_btn_->Disable();
 | ||||
| //            else export_btn_->Enable();
 | ||||
| //        }
 | ||||
| 
 | ||||
|         virtual void Close( wxCommandEvent& /*event*/ ) { | ||||
|             auto ret = wxID_OK; | ||||
| //        virtual void Close( wxCommandEvent& /*event*/ ) {
 | ||||
| //            auto ret = wxID_OK;
 | ||||
| 
 | ||||
|             if(wxFileName(filepick_ctl_->GetPath()).Exists()) | ||||
|                 if(!ctl_.report_issue(PrintController::IssueType::WARN_Q, | ||||
|                                   _(L("File already exists. Overwrite?")), | ||||
|                                   _(L("Warning")))) ret = wxID_CANCEL; | ||||
|             EndModal(ret); | ||||
|         } | ||||
|     }; | ||||
| //            if(wxFileName(filepick_ctl_->GetPath()).Exists())
 | ||||
| //                if(!ctl_.report_issue(PrintController::IssueType::WARN_Q,
 | ||||
| //                                  _(L("File already exists. Overwrite?")),
 | ||||
| //                                  _(L("Warning")))) ret = wxID_CANCEL;
 | ||||
| //            EndModal(ret);
 | ||||
| //        }
 | ||||
| //    };
 | ||||
| 
 | ||||
|     PngExportView exdlg(*this); | ||||
| //    PngExportView exdlg(*this);
 | ||||
| 
 | ||||
|     exdlg.prefill(prev_expdata_); | ||||
| //    exdlg.prefill(prev_expdata_);
 | ||||
| 
 | ||||
|     auto r = exdlg.ShowModal(); | ||||
| //    auto r = exdlg.ShowModal();
 | ||||
| 
 | ||||
|     auto ret = exdlg.export_data(); | ||||
|     prev_expdata_ = ret; | ||||
| //    auto ret = exdlg.export_data();
 | ||||
| //    prev_expdata_ = ret;
 | ||||
| 
 | ||||
|     if(r != wxID_OK) ret.zippath.clear(); | ||||
| //    if(r != wxID_OK) ret.zippath.clear();
 | ||||
| 
 | ||||
|     return ret; | ||||
| } | ||||
| //    return ret;
 | ||||
| //}
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tamasmeszaros
						tamasmeszaros