mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	zip file output dialog and status indication for sla in the statusbar.
This commit is contained in:
		
							parent
							
								
									90c38daeae
								
							
						
					
					
						commit
						95419370e1
					
				
					 6 changed files with 104 additions and 29 deletions
				
			
		| 
						 | 
				
			
			@ -154,6 +154,7 @@ void SLAPrint::process()
 | 
			
		|||
    };
 | 
			
		||||
 | 
			
		||||
    using slaposFn = std::function<void(const SLAPrintObject&)>;
 | 
			
		||||
    using slapsFn  = std::function<void(void)>;
 | 
			
		||||
 | 
			
		||||
    std::array<SLAPrintObjectStep, slaposCount> objectsteps = {
 | 
			
		||||
        slaposObjectSlice,
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +165,7 @@ void SLAPrint::process()
 | 
			
		|||
        slaposSliceSupports
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    std::array<slaposFn, slaposCount> fullprogram =
 | 
			
		||||
    std::array<slaposFn, slaposCount> pobj_program =
 | 
			
		||||
    {
 | 
			
		||||
        slice_model,
 | 
			
		||||
        [](const SLAPrintObject&){}, // slaposSupportIslands now empty
 | 
			
		||||
| 
						 | 
				
			
			@ -174,8 +175,14 @@ void SLAPrint::process()
 | 
			
		|||
        slice_supports
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    std::array<slapsFn, slapsCount> print_program =
 | 
			
		||||
    {
 | 
			
		||||
        rasterize,
 | 
			
		||||
        [](){}  // validate
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    for(SLAPrintObject * po : m_objects) {
 | 
			
		||||
        for(size_t s = 0; s < fullprogram.size(); ++s) {
 | 
			
		||||
        for(size_t s = 0; s < pobj_program.size(); ++s) {
 | 
			
		||||
            auto currentstep = objectsteps[s];
 | 
			
		||||
 | 
			
		||||
            // Cancellation checking. Each step will check for cancellation
 | 
			
		||||
| 
						 | 
				
			
			@ -188,11 +195,33 @@ void SLAPrint::process()
 | 
			
		|||
                           OBJ_STEP_LABELS[currentstep]);
 | 
			
		||||
 | 
			
		||||
                po->set_started(currentstep);
 | 
			
		||||
                fullprogram[s](*po);
 | 
			
		||||
                pobj_program[s](*po);
 | 
			
		||||
                po->set_done(currentstep);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::array<SLAPrintStep, slapsCount> printsteps = {
 | 
			
		||||
        slapsRasterize, slapsValidate
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    for(size_t s = 0; s < print_program.size(); ++s) {
 | 
			
		||||
        auto currentstep = printsteps[s];
 | 
			
		||||
 | 
			
		||||
        throw_if_canceled();
 | 
			
		||||
 | 
			
		||||
        if(m_stepmask[s]) {
 | 
			
		||||
            set_status(PRINT_STEP_LEVELS[currentstep],
 | 
			
		||||
                       PRINT_STEP_LABELS[currentstep]);
 | 
			
		||||
 | 
			
		||||
            set_started(currentstep);
 | 
			
		||||
            print_program[s]();
 | 
			
		||||
            set_done(currentstep);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // If everything vent well
 | 
			
		||||
    set_status(100, L("Slicing done"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SLAPrint::render_supports(SLASupportRenderer &renderer)
 | 
			
		||||
| 
						 | 
				
			
			@ -200,6 +229,11 @@ void SLAPrint::render_supports(SLASupportRenderer &renderer)
 | 
			
		|||
    std::cout << "Would show the SLA supports" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SLAPrint::export_raster(const std::string &fname)
 | 
			
		||||
{
 | 
			
		||||
    std::cout << "Would export the SLA raster" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
 | 
			
		||||
    Inherited(print),
 | 
			
		||||
    m_model_object(model_object),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ private: // Prevents erroneous use by other classes.
 | 
			
		|||
    typedef PrintBaseWithState<SLAPrintStep, slapsCount> Inherited;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    SLAPrint() {}
 | 
			
		||||
    SLAPrint(): m_stepmask(slapsCount, true) {}
 | 
			
		||||
	virtual ~SLAPrint() { this->clear(); }
 | 
			
		||||
 | 
			
		||||
	PrinterTechnology	technology() const noexcept { return ptSLA; }
 | 
			
		||||
| 
						 | 
				
			
			@ -143,11 +143,14 @@ public:
 | 
			
		|||
 | 
			
		||||
    void                render_supports(SLASupportRenderer& renderer);
 | 
			
		||||
 | 
			
		||||
    void                export_raster(const std::string& fname);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Model                           m_model;
 | 
			
		||||
    SLAPrinterConfig                m_printer_config;
 | 
			
		||||
    SLAMaterialConfig               m_material_config;
 | 
			
		||||
    PrintObjects                    m_objects;
 | 
			
		||||
    std::vector<bool>               m_stepmask;
 | 
			
		||||
 | 
			
		||||
	friend SLAPrintObject;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,19 @@ void BackgroundSlicingProcess::process_fff()
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackgroundSlicingProcess::process_sla() {
 | 
			
		||||
    assert(m_print == m_sla_print);
 | 
			
		||||
    m_print->process();
 | 
			
		||||
    if(!m_print->canceled() && ! this->is_step_done(bspsGCodeFinalize)) {
 | 
			
		||||
        this->set_step_started(bspsGCodeFinalize);
 | 
			
		||||
        if (! m_export_path.empty()) {
 | 
			
		||||
            m_sla_print->export_raster(m_export_path);
 | 
			
		||||
            m_print->set_status(100, "Zip file exported to " + m_export_path);
 | 
			
		||||
        }
 | 
			
		||||
        this->set_step_done(bspsGCodeFinalize);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackgroundSlicingProcess::thread_proc()
 | 
			
		||||
{
 | 
			
		||||
	assert(m_print != nullptr);
 | 
			
		||||
| 
						 | 
				
			
			@ -100,6 +113,7 @@ void BackgroundSlicingProcess::thread_proc()
 | 
			
		|||
			assert(m_print != nullptr);
 | 
			
		||||
			switch(m_print->technology()) {
 | 
			
		||||
				case ptFFF: this->process_fff(); break;
 | 
			
		||||
                case ptSLA: this->process_sla(); break;
 | 
			
		||||
				default: m_print->process(); break;
 | 
			
		||||
			}
 | 
			
		||||
		} catch (CanceledException & /* ex */) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,6 +96,9 @@ private:
 | 
			
		|||
	// Helper to wrap the FFF slicing & G-code generation.
 | 
			
		||||
	void	process_fff();
 | 
			
		||||
 | 
			
		||||
    // Temporary: for mimicking the fff file export behavior with the raster output
 | 
			
		||||
    void	process_sla();
 | 
			
		||||
 | 
			
		||||
	// Currently active print. It is one of m_fff_print and m_sla_print.
 | 
			
		||||
	PrintBase				   *m_print 			 = nullptr;
 | 
			
		||||
	// Non-owned pointers to Print instances.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1683,7 +1683,7 @@ void GLGizmoSlaSupports::clicked_on_object(const Vec2d& mouse_position)
 | 
			
		|||
        m_model_object->sla_support_points.push_back(new_pos);
 | 
			
		||||
 | 
			
		||||
        // This should trigger the support generation
 | 
			
		||||
        wxGetApp().plater()->reslice();
 | 
			
		||||
        // wxGetApp().plater()->reslice();
 | 
			
		||||
    }
 | 
			
		||||
    catch (...) {}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1695,7 +1695,7 @@ void GLGizmoSlaSupports::delete_current_grabber(bool delete_all)
 | 
			
		|||
        m_model_object->sla_support_points.clear();
 | 
			
		||||
 | 
			
		||||
        // This should trigger the support generation
 | 
			
		||||
        wxGetApp().plater()->reslice();
 | 
			
		||||
        // wxGetApp().plater()->reslice();
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
        if (m_hover_id != -1) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1704,7 +1704,7 @@ void GLGizmoSlaSupports::delete_current_grabber(bool delete_all)
 | 
			
		|||
            m_hover_id = -1;
 | 
			
		||||
 | 
			
		||||
            // This should trigger the support generation
 | 
			
		||||
            wxGetApp().plater()->reslice();
 | 
			
		||||
            // wxGetApp().plater()->reslice();
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -991,12 +991,15 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) :
 | 
			
		|||
	// Default printer technology for default config.
 | 
			
		||||
    background_process.select_technology(q->printer_technology());
 | 
			
		||||
    // Register progress callback from the Print class to the Platter.
 | 
			
		||||
    print.set_status_callback([this](int percent, const std::string &message) {
 | 
			
		||||
 | 
			
		||||
    auto statuscb = [this](int percent, const std::string &message) {
 | 
			
		||||
        wxCommandEvent event(EVT_PROGRESS_BAR);
 | 
			
		||||
        event.SetInt(percent);
 | 
			
		||||
        event.SetString(message);
 | 
			
		||||
        wxQueueEvent(this->q, event.Clone());
 | 
			
		||||
    });
 | 
			
		||||
    };
 | 
			
		||||
    print.set_status_callback(statuscb);
 | 
			
		||||
    sla_print.set_status_callback(statuscb);
 | 
			
		||||
    this->q->Bind(EVT_PROGRESS_BAR, &priv::on_progress_event, this);
 | 
			
		||||
 | 
			
		||||
    _3DScene::add_canvas(canvas3D);
 | 
			
		||||
| 
						 | 
				
			
			@ -2171,28 +2174,44 @@ void Plater::export_gcode(fs::path output_path)
 | 
			
		|||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Copy the names of active presets into the placeholder parser.
 | 
			
		||||
    wxGetApp().preset_bundle->export_selections(p->print.placeholder_parser());
 | 
			
		||||
    std::string final_path;
 | 
			
		||||
    if(printer_technology() == ptFFF) { // TODO: custom button for SLA export
 | 
			
		||||
 | 
			
		||||
    // select output file
 | 
			
		||||
    if (output_path.empty()) {
 | 
			
		||||
        // XXX: take output path from CLI opts? Ancient Slic3r versions used to do that...
 | 
			
		||||
        // Copy the names of active presets into the placeholder parser.
 | 
			
		||||
        wxGetApp().preset_bundle->export_selections(p->print.placeholder_parser());
 | 
			
		||||
 | 
			
		||||
        // If possible, remove accents from accented latin characters.
 | 
			
		||||
        // This function is useful for generating file names to be processed by legacy firmwares.
 | 
			
		||||
        auto default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(
 | 
			
		||||
            p->print.output_filepath(output_path.string())
 | 
			
		||||
            // FIXME: ^ errors to handle?
 | 
			
		||||
        ));
 | 
			
		||||
        auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
 | 
			
		||||
        // select output file
 | 
			
		||||
        if (output_path.empty()) {
 | 
			
		||||
            // XXX: take output path from CLI opts? Ancient Slic3r versions used to do that...
 | 
			
		||||
 | 
			
		||||
        auto fileType = printer_technology() == ptFFF ? FT_GCODE : FT_PNGZIP;
 | 
			
		||||
        std::string dtitle = printer_technology() == ptFFF ? L("Save G-code file as:")
 | 
			
		||||
                                                           : L("Save Zip file as:");
 | 
			
		||||
        wxFileDialog dlg(this, _(dtitle),
 | 
			
		||||
            start_dir,
 | 
			
		||||
            default_output_file.filename().string(),
 | 
			
		||||
            GUI::file_wildcards[fileType],
 | 
			
		||||
            // If possible, remove accents from accented latin characters.
 | 
			
		||||
            // This function is useful for generating file names to be processed by legacy firmwares.
 | 
			
		||||
            auto default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(
 | 
			
		||||
                p->print.output_filepath(output_path.string())
 | 
			
		||||
                // FIXME: ^ errors to handle?
 | 
			
		||||
            ));
 | 
			
		||||
            auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
 | 
			
		||||
 | 
			
		||||
            wxFileDialog dlg(this, _(L("Save G-code file as:")),
 | 
			
		||||
                start_dir,
 | 
			
		||||
                default_output_file.filename().string(),
 | 
			
		||||
                GUI::file_wildcards[FT_GCODE],
 | 
			
		||||
                wxFD_SAVE | wxFD_OVERWRITE_PROMPT
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            if (dlg.ShowModal() == wxID_OK) {
 | 
			
		||||
                fs::path path(dlg.GetPath());
 | 
			
		||||
                wxGetApp().app_config->update_last_output_dir(path.parent_path().string());
 | 
			
		||||
                output_path = path;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        final_path = p->print.output_filepath(output_path.string());
 | 
			
		||||
    } else {
 | 
			
		||||
        wxFileDialog dlg(this, _(L("Save Zip file as:")),
 | 
			
		||||
            wxGetApp().app_config->get_last_output_dir(""),
 | 
			
		||||
            "out.zip",
 | 
			
		||||
            GUI::file_wildcards[FT_PNGZIP],
 | 
			
		||||
            wxFD_SAVE | wxFD_OVERWRITE_PROMPT
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2201,10 +2220,12 @@ void Plater::export_gcode(fs::path output_path)
 | 
			
		|||
            wxGetApp().app_config->update_last_output_dir(path.parent_path().string());
 | 
			
		||||
            output_path = path;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        final_path = output_path.string();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (! output_path.empty()) {
 | 
			
		||||
        this->p->background_process.schedule_export(p->print.output_filepath(output_path.string()));
 | 
			
		||||
        this->p->background_process.schedule_export(final_path);
 | 
			
		||||
        this->p->background_process.start();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue