mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Added opencsg parameter console
This commit is contained in:
		
							parent
							
								
									66759e10e3
								
							
						
					
					
						commit
						b1186e339d
					
				
					 3 changed files with 70 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -454,7 +454,14 @@ void Display::on_moved_to(long x, long y)
 | 
			
		|||
    m_mouse_pos = {x, y};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CSGSettings::set_csg_algo(OpenCSG::Algorithm alg) { m_csgalg = alg; }
 | 
			
		||||
void Display::apply_csgsettings(const CSGSettings &settings)
 | 
			
		||||
{
 | 
			
		||||
    using namespace OpenCSG;
 | 
			
		||||
    m_csgsettings = settings;
 | 
			
		||||
    setOption(AlgorithmSetting, m_csgsettings.get_algo());
 | 
			
		||||
    setOption(DepthComplexitySetting, m_csgsettings.get_depth_algo());
 | 
			
		||||
    setOption(DepthBoundsOptimization, m_csgsettings.get_optimization());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Display::on_scene_updated()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -220,8 +220,17 @@ public:
 | 
			
		|||
 | 
			
		||||
class CSGSettings {
 | 
			
		||||
    OpenCSG::Algorithm m_csgalg = OpenCSG::Algorithm::Automatic;
 | 
			
		||||
    OpenCSG::DepthComplexityAlgorithm m_depth_algo = OpenCSG::DepthComplexityAlgorithm::NoDepthComplexitySampling;
 | 
			
		||||
    OpenCSG::Optimization m_optim = OpenCSG::Optimization::OptimizationDefault;
 | 
			
		||||
public:
 | 
			
		||||
    void set_csg_algo(OpenCSG::Algorithm alg);
 | 
			
		||||
    int get_algo() const { return int(m_csgalg); }
 | 
			
		||||
    void set_algo(OpenCSG::Algorithm alg) { m_csgalg = alg; }
 | 
			
		||||
    
 | 
			
		||||
    int get_depth_algo() const { return int(m_depth_algo); }
 | 
			
		||||
    void set_depth_algo(OpenCSG::DepthComplexityAlgorithm alg) { m_depth_algo = alg; }
 | 
			
		||||
    
 | 
			
		||||
    int  get_optimization() const { return int(m_optim); }
 | 
			
		||||
    void set_optimization(OpenCSG::Optimization o) { m_optim = o; }
 | 
			
		||||
};
 | 
			
		||||
       
 | 
			
		||||
class Display : public std::enable_shared_from_this<Display>,
 | 
			
		||||
| 
						 | 
				
			
			@ -265,8 +274,8 @@ public:
 | 
			
		|||
    
 | 
			
		||||
    void move_clip_plane(double z) { m_camera->set_clip_z(z); }
 | 
			
		||||
    
 | 
			
		||||
    const CSGSettings & csgsettings() const { return m_csgsettings; }
 | 
			
		||||
    void csgsettings(const CSGSettings &settings) { m_csgsettings = settings; }
 | 
			
		||||
    const CSGSettings & get_csgsettings() const { return m_csgsettings; }
 | 
			
		||||
    void apply_csgsettings(const CSGSettings &settings);
 | 
			
		||||
    
 | 
			
		||||
    virtual void on_scene_updated();
 | 
			
		||||
    virtual void clear_screen();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,8 +100,8 @@ public:
 | 
			
		|||
             // drivers would most likely work with some alpha plane, but
 | 
			
		||||
             // glReadPixels would not return the alpha channel on NVIDIA if
 | 
			
		||||
             // not requested when the GL context is created.
 | 
			
		||||
             WX_GL_MIN_ALPHA, 8, WX_GL_DEPTH_SIZE, 8, WX_GL_STENCIL_SIZE, 8, WX_GL_SAMPLE_BUFFERS,
 | 
			
		||||
             GL_TRUE, WX_GL_SAMPLES, 4, 0};
 | 
			
		||||
             WX_GL_MIN_ALPHA, 8, WX_GL_DEPTH_SIZE, 8, WX_GL_STENCIL_SIZE, 8,
 | 
			
		||||
             WX_GL_SAMPLE_BUFFERS, GL_TRUE, WX_GL_SAMPLES, 4, 0};
 | 
			
		||||
 | 
			
		||||
        m_canvas = std::make_shared<Canvas>(this, wxID_ANY, attribList,
 | 
			
		||||
                                            wxDefaultPosition, wxDefaultSize,
 | 
			
		||||
| 
						 | 
				
			
			@ -111,17 +111,33 @@ public:
 | 
			
		|||
        auto controlsizer = new wxBoxSizer(wxHORIZONTAL);
 | 
			
		||||
        auto slider_sizer = new wxBoxSizer(wxVERTICAL);
 | 
			
		||||
        auto console_sizer = new wxBoxSizer(wxVERTICAL);
 | 
			
		||||
        
 | 
			
		||||
          
 | 
			
		||||
        auto slider = new wxSlider(control_panel, wxID_ANY, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
 | 
			
		||||
        auto toggle = new wxToggleButton(control_panel, wxID_ANY, "Multisampling");
 | 
			
		||||
        wxString algorithms [] = {"Default", "Different"};
 | 
			
		||||
        auto alg_select = new wxComboBox(control_panel, wxID_ANY, "Default", wxDefaultPosition, wxDefaultSize, 2, algorithms);
 | 
			
		||||
        
 | 
			
		||||
        slider_sizer->Add(slider, 1, wxEXPAND);
 | 
			
		||||
        console_sizer->Add(toggle, 0, wxALL, 5);
 | 
			
		||||
        console_sizer->Add(alg_select, 0, wxALL, 5);
 | 
			
		||||
        
 | 
			
		||||
        auto toggle = new wxToggleButton(control_panel, wxID_ANY, "Multisampling");
 | 
			
		||||
        console_sizer->Add(toggle, 0, wxALL | wxEXPAND, 5);
 | 
			
		||||
 | 
			
		||||
        auto add_combobox = [control_panel, console_sizer]
 | 
			
		||||
            (const wxString &label, std::vector<wxString> &&list) {
 | 
			
		||||
            auto widget = new wxComboBox(control_panel, wxID_ANY, list[0],
 | 
			
		||||
                                         wxDefaultPosition, wxDefaultSize,
 | 
			
		||||
                                         int(list.size()), list.data());
 | 
			
		||||
            auto sz = new wxBoxSizer(wxHORIZONTAL);
 | 
			
		||||
            sz->Add(new wxStaticText(control_panel, wxID_ANY, label), 0, wxALL | wxALIGN_CENTER, 5);
 | 
			
		||||
            sz->Add(widget, 1, wxALL | wxEXPAND, 5);
 | 
			
		||||
            console_sizer->Add(sz, 0, wxEXPAND);
 | 
			
		||||
            return widget;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        auto alg_select = add_combobox("Algorithm", {"Auto", "Goldfeather", "SCS"});
 | 
			
		||||
        auto depth_select = add_combobox("Depth Complexity", {"Off", "OcclusionQuery", "On"});
 | 
			
		||||
        depth_select->Disable();
 | 
			
		||||
        auto optimization_select = add_combobox("Optimization", { "Default", "ForceOn", "On", "Off" });
 | 
			
		||||
                       
 | 
			
		||||
        controlsizer->Add(slider_sizer, 0, wxEXPAND);
 | 
			
		||||
        controlsizer->Add(console_sizer, 1, wxEXPAND);
 | 
			
		||||
        
 | 
			
		||||
        control_panel->SetSizer(controlsizer);
 | 
			
		||||
        
 | 
			
		||||
        auto sizer = new wxBoxSizer(wxHORIZONTAL);
 | 
			
		||||
| 
						 | 
				
			
			@ -141,6 +157,31 @@ public:
 | 
			
		|||
            m_canvas->repaint();
 | 
			
		||||
        }, toggle->GetId());
 | 
			
		||||
        
 | 
			
		||||
        Bind(wxEVT_COMBOBOX, [this, alg_select, depth_select](wxCommandEvent &)
 | 
			
		||||
        {
 | 
			
		||||
            int sel = alg_select->GetSelection();
 | 
			
		||||
            depth_select->Enable(sel > 0);
 | 
			
		||||
            CSGSettings settings = m_canvas->get_csgsettings();
 | 
			
		||||
            settings.set_algo(OpenCSG::Algorithm(sel));
 | 
			
		||||
            m_canvas->apply_csgsettings(settings);
 | 
			
		||||
        }, alg_select->GetId());
 | 
			
		||||
        
 | 
			
		||||
        Bind(wxEVT_COMBOBOX, [this, depth_select](wxCommandEvent &)
 | 
			
		||||
        {
 | 
			
		||||
            int sel = depth_select->GetSelection();
 | 
			
		||||
            CSGSettings settings = m_canvas->get_csgsettings();
 | 
			
		||||
            settings.set_depth_algo(OpenCSG::DepthComplexityAlgorithm(sel));
 | 
			
		||||
            m_canvas->apply_csgsettings(settings);
 | 
			
		||||
        }, depth_select->GetId());
 | 
			
		||||
        
 | 
			
		||||
        Bind(wxEVT_COMBOBOX, [this, optimization_select](wxCommandEvent &)
 | 
			
		||||
        {
 | 
			
		||||
            int sel = optimization_select->GetSelection();
 | 
			
		||||
            CSGSettings settings = m_canvas->get_csgsettings();
 | 
			
		||||
            settings.set_optimization(OpenCSG::Optimization(sel));
 | 
			
		||||
            m_canvas->apply_csgsettings(settings);
 | 
			
		||||
        }, depth_select->GetId());
 | 
			
		||||
        
 | 
			
		||||
        m_canvas->set_scene(std::make_shared<Slic3r::GL::Scene>());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue