PA Calib dialog (#232)

* fix colors

Signed-off-by: SoftFever <softfeverever@gmail.com>

* calib dlg
WIP 1/2

Signed-off-by: SoftFever <softfeverever@gmail.com>

* cut tower based on range

Signed-off-by: SoftFever <softfeverever@gmail.com>

* mac menu change

Signed-off-by: SoftFever <softfeverever@gmail.com>

* minor fix

Signed-off-by: SoftFever <103989404+SoftFever@users.noreply.github.com>

Signed-off-by: SoftFever <softfeverever@gmail.com>
Signed-off-by: SoftFever <103989404+SoftFever@users.noreply.github.com>
This commit is contained in:
SoftFever 2023-01-26 01:28:47 +08:00 committed by GitHub
parent 2cdece2b14
commit 0c2309e3a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 332 additions and 76 deletions

View file

@ -1650,7 +1650,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true; if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
// SoftFever: calib // SoftFever: calib
if (print.calib_mode() == Calib_PA_DDE || print.calib_mode() == Calib_PA_Bowden) { if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
std::string gcode; std::string gcode;
gcode += m_writer.set_acceleration((unsigned int)floor(m_config.outer_wall_acceleration.value + 0.5)); gcode += m_writer.set_acceleration((unsigned int)floor(m_config.outer_wall_acceleration.value + 0.5));
@ -1665,11 +1665,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
auto fast_speed = std::min(print.default_region_config().outer_wall_speed.value, filament_max_volumetric_speed / pattern_line.mm3_per_mm()); auto fast_speed = std::min(print.default_region_config().outer_wall_speed.value, filament_max_volumetric_speed / pattern_line.mm3_per_mm());
auto slow_speed = std::max(20.0, fast_speed / 10.0); auto slow_speed = std::max(20.0, fast_speed / 10.0);
pa_test.set_speed(fast_speed, slow_speed); pa_test.set_speed(fast_speed, slow_speed);
pa_test.draw_numbers() = print.calib_params().print_numbers;
if(print.calib_mode() == Calib_PA_DDE) auto params = print.calib_params();
gcode += pa_test.generate_test(); gcode += pa_test.generate_test(params.pa_start, params.pa_step, std::llround(std::ceil((params.pa_end - params.pa_start) / params.pa_step)));
else
gcode +=pa_test.generate_test(0.0,0.02);
file.write(gcode); file.write(gcode);
} }
@ -2606,12 +2604,10 @@ GCode::LayerResult GCode::process_layer(
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z)); config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
} }
if (print.calib_mode() == Calib_PA_Tower_DDE) { if (print.calib_mode() == CalibMode::Calib_PA_Tower) {
gcode += writer().set_pressure_advance(static_cast<int>(print_z) * 0.002); gcode += writer().set_pressure_advance(print.calib_params().pa_start + static_cast<int>(print_z) * print.calib_params().pa_step);
}
else if(print.calib_mode() == Calib_PA_Tower_Bowden) {
gcode += writer().set_pressure_advance(static_cast<int>(print_z) * 0.02);
} }
//BBS //BBS
if (first_layer) { if (first_layer) {
//BBS: set first layer global acceleration //BBS: set first layer global acceleration

View file

@ -260,6 +260,11 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
return invalidated; return invalidated;
} }
void Print::set_calib_params(const Calib_Params& params) {
m_calib_params = params;
m_calib_params.mode = params.mode;
}
bool Print::invalidate_step(PrintStep step) bool Print::invalidate_step(PrintStep step)
{ {
bool invalidated = Inherited::invalidate_step(step); bool invalidated = Inherited::invalidate_step(step);

View file

@ -14,7 +14,6 @@
#include "GCode/ThumbnailData.hpp" #include "GCode/ThumbnailData.hpp"
#include "GCode/GCodeProcessor.hpp" #include "GCode/GCodeProcessor.hpp"
#include "MultiMaterialSegmentation.hpp" #include "MultiMaterialSegmentation.hpp"
#include "libslic3r.h" #include "libslic3r.h"
#include <Eigen/Geometry> #include <Eigen/Geometry>
@ -22,6 +21,8 @@
#include <functional> #include <functional>
#include <set> #include <set>
#include "calib.hpp"
namespace Slic3r { namespace Slic3r {
class GCode; class GCode;
@ -88,14 +89,6 @@ enum PrintObjectStep {
posInfill, posIroning, posSupportMaterial, posSimplifyPath, posSimplifySupportPath, posCount, posInfill, posIroning, posSupportMaterial, posSimplifyPath, posSimplifySupportPath, posCount,
}; };
enum CalibMode {
Calib_None = 0,
Calib_PA_DDE,
Calib_PA_Bowden,
Calib_PA_Tower_DDE,
Calib_PA_Tower_Bowden
};
// A PrintRegion object represents a group of volumes to print // A PrintRegion object represents a group of volumes to print
// sharing the same config (including the same assigned extruder(s)) // sharing the same config (including the same assigned extruder(s))
class PrintRegion class PrintRegion
@ -744,8 +737,10 @@ public:
//SoftFever //SoftFever
bool &is_BBL_printer() { return m_isBBLPrinter; } bool &is_BBL_printer() { return m_isBBLPrinter; }
const bool is_BBL_printer() const { return m_isBBLPrinter; } const bool is_BBL_printer() const { return m_isBBLPrinter; }
CalibMode& calib_mode() { return m_calib_mode; } CalibMode& calib_mode() { return m_calib_params.mode; }
const CalibMode calib_mode() const { return m_calib_mode; } const CalibMode calib_mode() const { return m_calib_params.mode; }
void set_calib_params(const Calib_Params& params);
const Calib_Params& calib_params() const { return m_calib_params; }
protected: protected:
// Invalidates the step, and its depending steps in Print. // Invalidates the step, and its depending steps in Print.
bool invalidate_step(PrintStep step); bool invalidate_step(PrintStep step);
@ -798,8 +793,8 @@ private:
//BBS: modified_count //BBS: modified_count
int m_modified_count {0}; int m_modified_count {0};
//SoftFever: calibration mode, change to enum later //SoftFever: calibration
CalibMode m_calib_mode; Calib_Params m_calib_params;
// To allow GCode to set the Print's GCodeExport step status. // To allow GCode to set the Print's GCodeExport step status.
friend class GCode; friend class GCode;

View file

@ -7,9 +7,9 @@
namespace Slic3r { namespace Slic3r {
calib_pressure_advance::calib_pressure_advance(GCode* gcodegen) :mp_gcodegen(gcodegen), m_length_short(20.0), m_length_long(40.0), m_space_y(3.5), m_line_width(0.6) {} calib_pressure_advance::calib_pressure_advance(GCode* gcodegen) :mp_gcodegen(gcodegen), m_length_short(20.0), m_length_long(40.0), m_space_y(3.5), m_line_width(0.6), m_draw_numbers(true) {}
std::string calib_pressure_advance::generate_test(double start_pa/*= 0*/, double step_pa /*= 0.005*/, int count/*= 10*/) { std::string calib_pressure_advance::generate_test(double start_pa/*= 0*/, double step_pa /*= 0.002*/, int count/*= 10*/) {
auto bed_sizes = mp_gcodegen->config().printable_area.values; auto bed_sizes = mp_gcodegen->config().printable_area.values;
auto w = bed_sizes[2].x() - bed_sizes[0].x(); auto w = bed_sizes[2].x() - bed_sizes[0].x();
auto h = bed_sizes[2].y() - bed_sizes[0].y(); auto h = bed_sizes[2].y() - bed_sizes[0].y();
@ -71,10 +71,10 @@ namespace Slic3r {
gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7)); gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7));
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), e * 7); gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), e * 7);
if (m_draw_numbers) {
for (int i = 0; i < num; i += 2) { for (int i = 0; i < num; i += 2) {
gcode << draw_number(start_x + m_length_short + m_length_long + m_length_short + 3, y_pos + i * m_space_y + m_space_y / 2, start_pa + i * step_pa); gcode << draw_number(start_x + m_length_short + m_length_long + m_length_short + 3, y_pos + i * m_space_y + m_space_y / 2, start_pa + i * step_pa);
}
} }
return gcode.str(); return gcode.str();
} }
@ -203,4 +203,21 @@ namespace Slic3r {
return gcode.str(); return gcode.str();
} }
Calib_Params::Calib_Params() :pa_start(0.0), pa_end(0.1), pa_step(0.002), print_numbers(true), mode(CalibMode::Calib_None) {}
Calib_Params::Calib_Params(const Calib_Params& p) {
pa_start = p.pa_start;
pa_end = p.pa_end;
pa_step = p.pa_step;
print_numbers = p.print_numbers;
mode = p.mode;
}
Calib_Params& Calib_Params::operator =(const Calib_Params& p)
{
pa_start = p.pa_start;
pa_end = p.pa_end;
pa_step = p.pa_step;
print_numbers = p.print_numbers;
mode = p.mode;
return *this;
}
} // namespace Slic3r } // namespace Slic3r

View file

@ -1,10 +1,27 @@
#pragma once #pragma once
#define calib_pressure_advance_dd
#include <string> #include <string>
#include "Point.hpp" #include "Point.hpp"
namespace Slic3r { namespace Slic3r {
class GCode; class GCode;
enum class CalibMode : int {
Calib_None = 0,
Calib_PA_Line,
Calib_PA_Tower,
};
struct Calib_Params
{
Calib_Params();
Calib_Params(const Calib_Params& p);
Calib_Params& operator =(const Calib_Params& p);
double pa_start, pa_end, pa_step;
bool print_numbers;
CalibMode mode;
};
class calib_pressure_advance class calib_pressure_advance
{ {
public: public:
@ -17,6 +34,7 @@ public:
m_fast_speed = fast; m_fast_speed = fast;
} }
double& line_width() { return m_line_width; }; double& line_width() { return m_line_width; };
bool& draw_numbers() { return m_draw_numbers; }
private: private:
std::string move_to(Vec2d pt); std::string move_to(Vec2d pt);
@ -29,5 +47,6 @@ private:
double m_space_y; double m_space_y;
double m_slow_speed, m_fast_speed; double m_slow_speed, m_fast_speed;
double m_line_width; double m_line_width;
bool m_draw_numbers;
}; };
} // namespace Slic3r } // namespace Slic3r

View file

@ -433,6 +433,8 @@ set(SLIC3R_GUI_SOURCES
Utils/AstroBox.hpp Utils/AstroBox.hpp
Utils/Repetier.cpp Utils/Repetier.cpp
Utils/Repetier.hpp Utils/Repetier.hpp
GUI/SFCalibrationDlg.hpp
GUI/SFCalibrationDlg.cpp
) )
if (WIN32) if (WIN32)

View file

@ -122,7 +122,7 @@ void AMSMaterialsSetting::create_panel_normal(wxWindow* parent)
m_sizer_filament->Add(m_comboBox_filament, 1, wxALIGN_CENTER, 0); m_sizer_filament->Add(m_comboBox_filament, 1, wxALIGN_CENTER, 0);
m_readonly_filament = new TextInput(parent, wxEmptyString, "", "", wxDefaultPosition, AMS_MATERIALS_SETTING_COMBOX_WIDTH, wxTE_READONLY); m_readonly_filament = new TextInput(parent, wxEmptyString, "", "", wxDefaultPosition, AMS_MATERIALS_SETTING_COMBOX_WIDTH, wxTE_READONLY);
m_readonly_filament->SetBorderColor(StateColor(std::make_pair(0xDBDBDB, (int)StateColor::Focused), std::make_pair(0x00AE42, (int)StateColor::Hovered), m_readonly_filament->SetBorderColor(StateColor(std::make_pair(0xDBDBDB, (int)StateColor::Focused), std::make_pair(0x009688, (int)StateColor::Hovered),
std::make_pair(0xDBDBDB, (int)StateColor::Normal))); std::make_pair(0xDBDBDB, (int)StateColor::Normal)));
m_readonly_filament->GetTextCtrl()->Bind(wxEVT_SET_FOCUS, [](auto& e) { m_readonly_filament->GetTextCtrl()->Bind(wxEVT_SET_FOCUS, [](auto& e) {
; ;

View file

@ -766,9 +766,9 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent)
main_sizer->Add(m_staticText_note, 0, wxALL | wxLEFT | wxRIGHT, 34); main_sizer->Add(m_staticText_note, 0, wxALL | wxLEFT | wxRIGHT, 34);
m_button_confirm = new Button(this, _L("OK")); m_button_confirm = new Button(this, _L("OK"));
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal)); StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
m_button_confirm->SetBackgroundColor(btn_bg_green); m_button_confirm->SetBackgroundColor(btn_bg_green);
m_button_confirm->SetBorderColor(wxColour(0, 174, 66)); m_button_confirm->SetBorderColor(wxColour(0, 150, 136));
m_button_confirm->SetTextColor(wxColour(0xFFFFFE)); m_button_confirm->SetTextColor(wxColour(0xFFFFFE));
m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24))); m_button_confirm->SetSize(wxSize(FromDIP(72), FromDIP(24)));
m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24))); m_button_confirm->SetMinSize(wxSize(FromDIP(72), FromDIP(24)));

View file

@ -170,10 +170,10 @@ void ExtrusionCalibration::create()
m_button_cali = new Button(m_step_1_panel, _L("Start calibration")); m_button_cali = new Button(m_step_1_panel, _L("Start calibration"));
m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Disabled), std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered), m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Disabled), std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal)); std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
m_button_cali->SetBackgroundColor(m_btn_bg_green); m_button_cali->SetBackgroundColor(m_btn_bg_green);
m_button_cali->SetFont(Label::Body_13); m_button_cali->SetFont(Label::Body_13);
m_button_cali->SetBorderColor({ std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Disabled), std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Enabled) }); m_button_cali->SetBorderColor({ std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Disabled), std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Enabled) });
m_button_cali->SetTextColor({ std::pair<wxColour, int>(wxColour(172, 172, 172), StateColor::Disabled), std::pair<wxColour, int>(EXTRUSION_CALIBRATION_GREY200, StateColor::Enabled) }); m_button_cali->SetTextColor({ std::pair<wxColour, int>(wxColour(172, 172, 172), StateColor::Disabled), std::pair<wxColour, int>(EXTRUSION_CALIBRATION_GREY200, StateColor::Enabled) });
m_button_cali->SetCornerRadius(FromDIP(12)); m_button_cali->SetCornerRadius(FromDIP(12));
m_button_cali->SetMinSize(wxSize(-1, FromDIP(24))); m_button_cali->SetMinSize(wxSize(-1, FromDIP(24)));
@ -181,9 +181,9 @@ void ExtrusionCalibration::create()
m_cali_cancel = new Button(m_step_1_panel, _L("Cancel")); m_cali_cancel = new Button(m_step_1_panel, _L("Cancel"));
m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered), m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal)); std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
m_cali_cancel->SetBackgroundColor(m_btn_bg_green); m_cali_cancel->SetBackgroundColor(m_btn_bg_green);
m_cali_cancel->SetBorderColor(wxColour(0, 174, 66)); m_cali_cancel->SetBorderColor(wxColour(0, 150, 136));
m_cali_cancel->SetTextColor(EXTRUSION_CALIBRATION_GREY200); m_cali_cancel->SetTextColor(EXTRUSION_CALIBRATION_GREY200);
m_cali_cancel->SetMinSize(EXTRUSION_CALIBRATION_BUTTON_SIZE); m_cali_cancel->SetMinSize(EXTRUSION_CALIBRATION_BUTTON_SIZE);
m_cali_cancel->SetCornerRadius(FromDIP(12)); m_cali_cancel->SetCornerRadius(FromDIP(12));
@ -256,10 +256,10 @@ void ExtrusionCalibration::create()
// save button // save button
m_button_save_result = new Button(m_step_2_panel, _L("Save")); m_button_save_result = new Button(m_step_2_panel, _L("Save"));
m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered), m_btn_bg_green = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal)); std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
m_button_save_result->SetBackgroundColor(m_btn_bg_green); m_button_save_result->SetBackgroundColor(m_btn_bg_green);
m_button_save_result->SetFont(Label::Body_13); m_button_save_result->SetFont(Label::Body_13);
m_button_save_result->SetBorderColor(wxColour(0, 174, 66)); m_button_save_result->SetBorderColor(wxColour(0, 150, 136));
m_button_save_result->SetTextColor(EXTRUSION_CALIBRATION_GREY200); m_button_save_result->SetTextColor(EXTRUSION_CALIBRATION_GREY200);
m_button_save_result->SetMinSize(EXTRUSION_CALIBRATION_BUTTON_SIZE); m_button_save_result->SetMinSize(EXTRUSION_CALIBRATION_BUTTON_SIZE);
m_button_save_result->SetCornerRadius(FromDIP(12)); m_button_save_result->SetCornerRadius(FromDIP(12));

View file

@ -2477,22 +2477,13 @@ void MainFrame::init_menubar_as_editor()
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_flowrate(2); }, "", nullptr, [this](wxCommandEvent&) { if (m_plater) m_plater->calib_flowrate(2); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this); [this]() {return m_plater->is_view3D_shown();; }, this);
m_topbar->GetCalibMenu()->AppendSubMenu(flowrate_menu, _L("Flow rate")); m_topbar->GetCalibMenu()->AppendSubMenu(flowrate_menu, _L("Flow rate"));
append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("Presure Advance"), _L(""),
// PA [this](wxCommandEvent&) {
auto pa_menu = new wxMenu(); if (!m_pa_calib_dlg)
append_menu_item(pa_menu, wxID_ANY, _L("Line method - DDE"), _L(""), m_pa_calib_dlg = new PA_Calibration_Dlg((wxWindow*)this, wxID_ANY, m_plater);
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(true, false); }, "", nullptr, m_pa_calib_dlg->ShowModal();
}, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this); [this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Line method - Bowden"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(true, true); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Tower method - DDE"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(false, false); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Tower method - Bowden"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(false, true); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
m_topbar->GetCalibMenu()->AppendSubMenu(pa_menu, _L("Presure/Linear Advance"));
// help // help
append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("Tutorial"), _L("Calibration help"), append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("Tutorial"), _L("Calibration help"),
@ -2519,23 +2510,17 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(flowrate_menu, wxID_ANY, _L("Pass 2"), _L("Flow rate test - Pass 2"), append_menu_item(flowrate_menu, wxID_ANY, _L("Pass 2"), _L("Flow rate test - Pass 2"),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_flowrate(2); }, "", nullptr, [this](wxCommandEvent&) { if (m_plater) m_plater->calib_flowrate(2); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this); [this]() {return m_plater->is_view3D_shown();; }, this);
calib_menu->AppendSubMenu(flowrate_menu, _L("Flow rate")); append_submenu(calib_menu,flowrate_menu,wxID_ANY,_L("Flow rate"),_L("Flow rate"),"",
[this]() {return m_plater->is_view3D_shown();; });
// PA // PA
auto pa_menu = new wxMenu(); append_menu_item(calib_menu, wxID_ANY, _L("Presure Advance"), _L("Presure Advance"),
append_menu_item(pa_menu, wxID_ANY, _L("Line method - DDE"), _L(""), [this](wxCommandEvent&) {
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(true, false); }, "", nullptr, if (!m_pa_calib_dlg)
m_pa_calib_dlg = new PA_Calibration_Dlg((wxWindow*)this, wxID_ANY, m_plater);
m_pa_calib_dlg->ShowModal();
}, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this); [this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Line method - Bowden"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(true, true); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Tower method - DDE"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(false, false); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
append_menu_item(pa_menu, wxID_ANY, _L("Tower method - Bowden"), _L(""),
[this](wxCommandEvent&) { if (m_plater) m_plater->calib_pa(false, true); }, "", nullptr,
[this]() {return m_plater->is_view3D_shown();; }, this);
calib_menu->AppendSubMenu(pa_menu, _L("Presure/Linear Advance"));
// help // help
append_menu_item(calib_menu, wxID_ANY, _L("Tutorial"), _L("Calibration help"), append_menu_item(calib_menu, wxID_ANY, _L("Tutorial"), _L("Calibration help"),

View file

@ -29,6 +29,7 @@
#include "PrinterWebView.hpp" #include "PrinterWebView.hpp"
#include "SFCalibrationDlg.hpp"
#define ENABEL_PRINT_ALL 0 #define ENABEL_PRINT_ALL 0
@ -330,6 +331,8 @@ public:
//SoftFever //SoftFever
void show_device(bool bBBLPrinter); void show_device(bool bBBLPrinter);
PA_Calibration_Dlg* m_pa_calib_dlg{ nullptr };
// BBS. Replace title bar and menu bar with top bar. // BBS. Replace title bar and menu bar with top bar.
BBLTopbar* m_topbar{ nullptr }; BBLTopbar* m_topbar{ nullptr };
PrintHostQueueDialog* printhost_queue_dlg() { return m_printhost_queue_dlg; } PrintHostQueueDialog* printhost_queue_dlg() { return m_printhost_queue_dlg; }

View file

@ -2896,7 +2896,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
if (input_files.empty()) { return std::vector<size_t>(); } if (input_files.empty()) { return std::vector<size_t>(); }
// SoftFever: ugly fix so we can exist pa calib mode // SoftFever: ugly fix so we can exist pa calib mode
background_process.fff_print()->calib_mode() = Calib_None; background_process.fff_print()->calib_mode() = CalibMode::Calib_None;
// BBS // BBS
@ -7897,18 +7897,16 @@ void Plater::add_model(bool imperial_units/* = false*/, std::string fname/* = "
} }
} }
void Plater::calib_pa(bool line_method, bool bowden) { void Plater::calib_pa(const Calib_Params& params) {
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test - %s%s", line_method ? L"Line" : L"Tower", bowden ? L"Bowden" : L"DDE"); const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
new_project(false, false, calib_pa_name); new_project(false, false, calib_pa_name);
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor)); wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
if (line_method) { if (params.mode == CalibMode::Calib_PA_Line) {
add_model(false, Slic3r::resources_dir() + "/calib/PresureAdvnace/pressure_advance_test.stl"); add_model(false, Slic3r::resources_dir() + "/calib/PresureAdvnace/pressure_advance_test.stl");
p->background_process.fff_print()->calib_mode() = bowden ? Calib_PA_Bowden : Calib_PA_DDE;
} }
else { else {
add_model(false, Slic3r::resources_dir() + "/calib/PresureAdvnace/tower_with_seam.stl"); add_model(false, Slic3r::resources_dir() + "/calib/PresureAdvnace/tower_with_seam.stl");
p->background_process.fff_print()->calib_mode() = bowden ? Calib_PA_Tower_Bowden: Calib_PA_Tower_DDE;
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
@ -7924,6 +7922,16 @@ void Plater::calib_pa(bool line_method, bool bowden) {
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_ui_from_settings(); wxGetApp().get_tab(Preset::TYPE_PRINT)->update_ui_from_settings();
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_ui_from_settings(); wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_ui_from_settings();
auto new_height = std::ceil((params.pa_end - params.pa_start) / params.pa_step) + 1;
auto obj_bb = model().objects[0]->bounding_box();
if (new_height < obj_bb.size().z()) {
std::array<Vec3d, 4> plane_pts;
plane_pts[0] = Vec3d(obj_bb.min(0), obj_bb.min(1), new_height);
plane_pts[1] = Vec3d(obj_bb.min(0), obj_bb.max(1), new_height);
plane_pts[2] = Vec3d(obj_bb.max(0), obj_bb.max(1), new_height);
plane_pts[3] = Vec3d(obj_bb.max(0), obj_bb.min(1), new_height);
cut(0, 0, plane_pts, ModelObjectCutAttribute::KeepLower);
}
// automatic selection of added objects // automatic selection of added objects
// update printable state for new volumes on canvas3D // update printable state for new volumes on canvas3D
@ -7939,8 +7947,8 @@ void Plater::calib_pa(bool line_method, bool bowden) {
if (p->view3D->get_canvas3d()->get_gizmos_manager().is_enabled()) if (p->view3D->get_canvas3d()->get_gizmos_manager().is_enabled())
// this is required because the selected object changed and the flatten on face an sla support gizmos need to be updated accordingly // this is required because the selected object changed and the flatten on face an sla support gizmos need to be updated accordingly
p->view3D->get_canvas3d()->update_gizmos_on_off_state(); p->view3D->get_canvas3d()->update_gizmos_on_off_state();
} }
p->background_process.fff_print()->set_calib_params(params);
} }

View file

@ -24,6 +24,8 @@
#include "libslic3r/Model.hpp" #include "libslic3r/Model.hpp"
#include "libslic3r/PrintBase.hpp" #include "libslic3r/PrintBase.hpp"
#include "libslic3r/calib.hpp"
#define FILAMENT_SYSTEM_COLORS_NUM 16 #define FILAMENT_SYSTEM_COLORS_NUM 16
class wxButton; class wxButton;
@ -227,7 +229,7 @@ public:
void refresh_print(); void refresh_print();
// SoftFever // SoftFever
void calib_pa(bool line_method = true, bool bowden = false); void calib_pa(const Calib_Params& params);
void calib_flowrate(int pass); void calib_flowrate(int pass);
//BBS: add only gcode mode //BBS: add only gcode mode

View file

@ -0,0 +1,174 @@
#include "SFCalibrationDlg.hpp"
#include "GUI_App.hpp"
#include "MsgDialog.hpp"
#include "I18N.hpp"
#include <wx/dcgraph.h>
#include "MainFrame.hpp"
namespace Slic3r { namespace GUI {
PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* plater)
: DPIDialog(parent, id, _L("PA Calibration"), wxDefaultPosition, parent->FromDIP(wxSize(-1, 280)), wxDEFAULT_DIALOG_STYLE), m_plater(plater)
{
wxBoxSizer* v_sizer = new wxBoxSizer(wxVERTICAL);
SetSizer(v_sizer);
wxBoxSizer* choice_sizer = new wxBoxSizer(wxHORIZONTAL);
wxString m_rbExtruderTypeChoices[] = { wxT("DDE"), wxT("Bowden") };
int m_rbExtruderTypeNChoices = sizeof(m_rbExtruderTypeChoices) / sizeof(wxString);
m_rbExtruderType = new wxRadioBox(this, wxID_ANY, wxT("Extruder type"), wxDefaultPosition, wxDefaultSize, m_rbExtruderTypeNChoices, m_rbExtruderTypeChoices, 2, wxRA_SPECIFY_COLS);
m_rbExtruderType->SetSelection(0);
choice_sizer->Add(m_rbExtruderType, 0, wxALL, 5);
choice_sizer->Add(FromDIP(5), 0, 0, wxEXPAND, 5);
wxString m_rbMethodChoices[] = { wxT("Tower"), wxT("Line") };
int m_rbMethodNChoices = sizeof(m_rbMethodChoices) / sizeof(wxString);
m_rbMethod = new wxRadioBox(this, wxID_ANY, wxT("Method"), wxDefaultPosition, wxDefaultSize, m_rbMethodNChoices, m_rbMethodChoices, 2, wxRA_SPECIFY_COLS);
m_rbMethod->SetSelection(0);
choice_sizer->Add(m_rbMethod, 0, wxALL, 5);
v_sizer->Add(choice_sizer);
// Settings
//
wxString start_pa_str = _L("Start PA: ");
wxString end_pa_str = _L("End PA: ");
wxString PA_step_str = _L("PA step: ");
auto text_size = wxWindow::GetTextExtent(start_pa_str);
text_size.IncTo(wxWindow::GetTextExtent(end_pa_str));
text_size.IncTo(wxWindow::GetTextExtent(PA_step_str));
text_size.x = text_size.x * 1.5;
wxStaticBoxSizer* settings_sizer = new wxStaticBoxSizer(wxVERTICAL, this, L"Settings");
auto st_size = FromDIP(wxSize(text_size.x, -1));
auto ti_size = FromDIP(wxSize(90, -1));
// start PA
auto start_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
auto start_pa_text = new wxStaticText(this, wxID_ANY, start_pa_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
m_tiStartPA = new TextInput(this, L"0.0", _L(""), "", wxDefaultPosition, ti_size, wxTE_CENTRE | wxTE_PROCESS_ENTER);
m_tiStartPA->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
start_PA_sizer->Add(start_pa_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
start_PA_sizer->Add(m_tiStartPA, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(start_PA_sizer);
// end PA
auto end_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
auto end_pa_text = new wxStaticText(this, wxID_ANY, end_pa_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
m_tiEndPA = new TextInput(this, L"0.1", _L(""), "", wxDefaultPosition, ti_size, wxTE_CENTRE | wxTE_PROCESS_ENTER);
m_tiStartPA->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
end_PA_sizer->Add(end_pa_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
end_PA_sizer->Add(m_tiEndPA, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(end_PA_sizer);
// PA step
auto PA_step_sizer = new wxBoxSizer(wxHORIZONTAL);
auto PA_step_text = new wxStaticText(this, wxID_ANY, PA_step_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
m_tiPAStep = new TextInput(this, L"0.002", _L(""), "", wxDefaultPosition, ti_size, wxTE_CENTRE | wxTE_PROCESS_ENTER);
m_tiStartPA->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
PA_step_sizer->Add(PA_step_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
PA_step_sizer->Add(m_tiPAStep, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(PA_step_sizer);
settings_sizer->Add(create_item_checkbox(L"Print numbers", this, &m_params.print_numbers, m_cbPrintNum));
v_sizer->Add(settings_sizer);
v_sizer->Add(0, FromDIP(10), 0, wxEXPAND, 5);
m_btnStart = new Button(this, _L("Start"));
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
m_btnStart->SetBackgroundColor(btn_bg_green);
m_btnStart->SetBorderColor(wxColour(0, 150, 136));
m_btnStart->SetTextColor(wxColour("#FFFFFE"));
m_btnStart->SetSize(wxSize(FromDIP(48), FromDIP(24)));
m_btnStart->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
m_btnStart->SetCornerRadius(FromDIP(3));
m_btnStart->Bind(wxEVT_BUTTON, &PA_Calibration_Dlg::on_start, this);
v_sizer->Add(m_btnStart, 0, wxALL | wxALIGN_RIGHT, FromDIP(5));
// Connect Events
m_rbExtruderType->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_extruder_type_changed), NULL, this);
m_rbMethod->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_method_changed), NULL, this);
this->Connect(wxEVT_SHOW, wxShowEventHandler(PA_Calibration_Dlg::on_show));
//wxGetApp().UpdateDlgDarkUI(this);
}
PA_Calibration_Dlg::~PA_Calibration_Dlg() {
// Disconnect Events
m_rbExtruderType->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_extruder_type_changed), NULL, this);
m_rbMethod->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_method_changed), NULL, this);
m_btnStart->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PA_Calibration_Dlg::on_start), NULL, this);
}
void PA_Calibration_Dlg::on_start(wxCommandEvent& event) {
m_tiStartPA->GetTextCtrl()->GetValue().ToDouble(&m_params.pa_start);
m_tiEndPA->GetTextCtrl()->GetValue().ToDouble(&m_params.pa_end);
m_tiPAStep->GetTextCtrl()->GetValue().ToDouble(&m_params.pa_step);
if (m_params.pa_start < 0 || m_params.pa_step < 0 || m_params.pa_end < m_params.pa_start + m_params.pa_step) {
MessageDialog msg_dlg(nullptr, _L("Please input valid values:\nStart PA: >= 0.0\nEnd PA: > Start PA\nPA step: >= 0)"), wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return;
}
m_plater->calib_pa(m_params);
EndModal(wxID_OK);
}
void PA_Calibration_Dlg::on_extruder_type_changed(wxCommandEvent& event) {
int selection = event.GetSelection();
m_bDDE = selection == 0 ? true : false;
m_tiEndPA->GetTextCtrl()->SetValue(m_bDDE ? L"0.1" : L"1.0");
m_tiStartPA->GetTextCtrl()->SetValue(L"0.0");
m_tiPAStep->GetTextCtrl()->SetValue(m_bDDE ? L"0.002" : L"0.02");
event.Skip();
}
void PA_Calibration_Dlg::on_method_changed(wxCommandEvent& event) {
int selection = event.GetSelection();
m_params.mode = selection == 0 ? CalibMode::Calib_PA_Tower : CalibMode::Calib_PA_Line;
if (selection == 0)
m_cbPrintNum->Enable(false);
else
m_cbPrintNum->Enable(true);
event.Skip();
}
void PA_Calibration_Dlg::on_dpi_changed(const wxRect& suggested_rect) {
this->Refresh();
}
void PA_Calibration_Dlg::on_show(wxShowEvent& event) {
if (m_rbMethod->GetSelection() == 0)
m_cbPrintNum->Enable(false);
else
m_cbPrintNum->Enable(true);
}
wxBoxSizer* PA_Calibration_Dlg::create_item_checkbox(wxString title, wxWindow* parent, bool* value, CheckBox*& checkbox)
{
wxBoxSizer* m_sizer_checkbox = new wxBoxSizer(wxHORIZONTAL);
m_sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, 5);
checkbox = new ::CheckBox(parent);
m_sizer_checkbox->Add(checkbox, 0, wxALIGN_CENTER, 0);
m_sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, 8);
auto checkbox_title = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxSize(-1, -1), 0);
checkbox_title->SetForegroundColour(wxColour(144, 144, 144));
checkbox_title->SetFont(::Label::Body_13);
checkbox_title->Wrap(-1);
m_sizer_checkbox->Add(checkbox_title, 0, wxALIGN_CENTER | wxALL, 3);
checkbox->SetValue(true);
checkbox->Bind(wxEVT_TOGGLEBUTTON, [parent, checkbox, value](wxCommandEvent& e) {
(*value) = (*value) ? false : true;
e.Skip();
});
return m_sizer_checkbox;
}
}} // namespace Slic3r::GUI

View file

@ -0,0 +1,50 @@
#ifndef slic3r_SFCalibrationDlg_hpp_
#define slic3r_SFCalibrationDlg_hpp_
#include "wxExtensions.hpp"
#include "GUI_Utils.hpp"
#include "Widgets/RadioBox.hpp"
#include "Widgets/Button.hpp"
#include "Widgets/RoundedRectangle.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/CheckBox.hpp"
#include "Widgets/ComboBox.hpp"
#include "Widgets/TextInput.hpp"
#include "GUI_App.hpp"
#include "wx/hyperlink.h"
#include <wx/radiobox.h>
#include "libslic3r/calib.hpp"
namespace Slic3r { namespace GUI {
class PA_Calibration_Dlg : public DPIDialog
{
public:
PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* plater);
~PA_Calibration_Dlg();
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_show(wxShowEvent& event);
protected:
wxBoxSizer* create_item_checkbox(wxString title, wxWindow* parent, bool* value ,CheckBox*& checkbox);
virtual void on_start(wxCommandEvent& event);
virtual void on_extruder_type_changed(wxCommandEvent& event);
virtual void on_method_changed(wxCommandEvent& event);
protected:
bool m_bDDE;
Calib_Params m_params;
wxRadioBox* m_rbExtruderType;
wxRadioBox* m_rbMethod;
TextInput* m_tiStartPA;
TextInput* m_tiEndPA;
TextInput* m_tiPAStep;
CheckBox* m_cbPrintNum;
Button* m_btnStart;
Plater* m_plater;
};
}} // namespace Slic3r::GUI
#endif