Ramming parameters reduced to one and connected to the wipe tower generator again

This commit is contained in:
Lukas Matena 2018-03-15 14:04:12 +01:00
parent 9f18b639a8
commit 67009d80fd
10 changed files with 139 additions and 217 deletions

View file

@ -465,6 +465,7 @@ WipeTowerPrusaMM::material_type WipeTowerPrusaMM::parse_material(const char *nam
return INVALID;
}
// Returns gcode to prime the nozzles at the front edge of the print bed.
WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
// print_z of the first layer.
@ -723,8 +724,8 @@ void WipeTowerPrusaMM::toolchange_Unload(
writer.append("; CP TOOLCHANGE UNLOAD\n");
const float line_width = m_line_width * m_par.ramming_line_width_multiplicator[m_current_tool]; // desired ramming line thickness
const float y_step = line_width * m_par.ramming_step_multiplicator[m_current_tool] * m_extra_spacing; // spacing between lines in mm
const float line_width = m_line_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness
const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm
unsigned i = 0; // iterates through ramming_speed
m_left_to_right = true; // current direction of ramming
@ -778,10 +779,10 @@ void WipeTowerPrusaMM::toolchange_Unload(
}
// now the ramming itself:
while (i < m_par.ramming_speed[m_current_tool].size())
while (i < m_filpar[m_current_tool].ramming_speed.size())
{
const float x = volume_to_length(m_par.ramming_speed[m_current_tool][i] * 0.25f, line_width, m_layer_height);
const float e = m_par.ramming_speed[m_current_tool][i] * 0.25f / Filament_Area; // transform volume per sec to E move;
const float x = volume_to_length(m_filpar[m_current_tool].ramming_speed[i] * 0.25f, line_width, m_layer_height);
const float e = m_filpar[m_current_tool].ramming_speed[i] * 0.25f / Filament_Area; // transform volume per sec to E move;
const float dist = std::min(x - e_done, remaining); // distance to travel for either the next 0.25s, or to the next turnaround
const float actual_time = dist/x * 0.25;
writer.ram(writer.x(), writer.x() + (m_left_to_right ? 1.f : -1.f) * dist, 0, 0, e * (dist / x), std::hypot(dist, e * (dist / x)) / (actual_time / 60.));
@ -1092,10 +1093,10 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi
// this is an actual toolchange - let's calculate depth to reserve on the wipe tower
float depth = 0.f;
float width = m_wipe_tower_width - 3*m_perimeter_width;
float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_par.ramming_speed[old_tool].begin(), m_par.ramming_speed[old_tool].end(), 0.f),
m_line_width * m_par.ramming_line_width_multiplicator[old_tool],
float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_filpar[old_tool].ramming_speed.begin(), m_filpar[old_tool].ramming_speed.end(), 0.f),
m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator,
layer_height_par);
depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_par.ramming_line_width_multiplicator[old_tool] * m_par.ramming_step_multiplicator[old_tool]);
depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_filpar[old_tool].ramming_line_width_multiplicator * m_filpar[old_tool].ramming_step_multiplicator);
float ramming_depth = depth;
length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width;
float first_wipe_line = -length_to_extrude;

View file

@ -67,82 +67,11 @@ std::istream& operator>>(std::istream& stream, std::vector<T>& vect) {
struct WipeTowerParameters {
WipeTowerParameters() { } // create new empty object
WipeTowerParameters(const std::string& init_data) { // create object and initialize from std::string
std::istringstream in(init_data); // validation of input is left to the caller
in >> sampling;
for (std::vector<float> vect{} ; in >> vect ;) { // until we get to fail state ("**")...
if (vect.size()>=2) {
ramming_line_width_multiplicator.push_back(vect[0]);
ramming_step_multiplicator.push_back(vect[1]);
vect.erase(vect.begin(),vect.begin()+2);
}
else vect.clear(); // something's not right, we will restore defaults anyway
ramming_speed.push_back(vect);
if (in.good()) {
in >> vect;
std::vector<std::pair<float,float>> pairs;
for (unsigned int i=0;i<vect.size();++i)
if (i%2==1)
pairs.push_back(std::make_pair(vect[i-1],vect[i]));
ramming_buttons.push_back(pairs);
}
}
in.clear();
in.get();
for (std::vector<float> vect{} ; in >> vect ;) { // let's keep reading
wipe_volumes.push_back(vect);
}
in.clear();
in.get();
std::vector<int> vect{};
in >> vect;
for (unsigned int i=0;i<vect.size();++i)
if (i%2==1)
filament_wipe_volumes.push_back(std::make_pair(vect[i-1],vect[i]));
if (!validate()) // in case we did not parse the input right
set_defaults();
set_defaults();
}
std::string to_string() {
std::ostringstream out;
out << sampling << "\n";
for (unsigned extruder=0;extruder<ramming_step_multiplicator.size();++extruder) {
out << "\n" << ramming_line_width_multiplicator[extruder] << " "
<< ramming_step_multiplicator[extruder] << " " << ramming_speed[extruder] << "*"
<< ramming_buttons[extruder] << "*";
}
out << "*\n";
for (auto& radek : wipe_volumes)
out << "\n" << radek << "*";
out << "*\n";
out << filament_wipe_volumes << "*";
return out.str();
}
bool validate() const { // basic check for validity to distinguish most dramatic failures
const unsigned int num = ramming_step_multiplicator.size();
if ( num < 1 || ramming_line_width_multiplicator.size()!=num || ramming_step_multiplicator.size()!=num ||
ramming_buttons.size()!=num || wipe_volumes.size()!=num ||
filament_wipe_volumes.size()!=num)
return false;
for (const auto& row : wipe_volumes)
if (row.size()!=num)
return false;
return true;
}
void set_defaults() {
sampling = 0.25f;
ramming_line_width_multiplicator = {1.5f, 1.5f, 1.5f, 1.5f};
ramming_step_multiplicator = {1.1f, 1.1f, 1.1f, 1.1f};
ramming_speed.clear();
ramming_buttons.clear();
for (unsigned int i=0;i<4;++i) {
ramming_speed.push_back(std::vector<float>{7.6f, 7.6f, 7.6f, 7.6f, 9.f, 9.f, 9.f, 10.7f, 10.7f, 10.7f});
ramming_buttons.push_back(std::vector<std::pair<float,float>>{{0.05f, 6.6f},{0.45f, 6.8f},{0.95f, 7.8f},{1.45f, 8.3f},{1.95f, 9.7f},{2.45f,10.f},{2.95f, 7.6f},{3.45f, 7.6f},{3.95f, 7.6f},{4.45f, 7.6f},{4.95f, 7.6f}});
}
wipe_volumes = {{ 0.f, 60.f, 60.f, 60.f},
{ 60.f, 0.f, 60.f, 60.f},
{ 60.f, 60.f, 0.f, 60.f},
@ -151,10 +80,6 @@ struct WipeTowerParameters {
}
float sampling = 0.25f; // this does not quite work yet, keep it fixed to 0.25f
std::vector<float> ramming_line_width_multiplicator;
std::vector<float> ramming_step_multiplicator;
std::vector<std::vector<float>> ramming_speed;
std::vector<std::vector<std::pair<float,float>>> ramming_buttons;
std::vector<std::vector<float>> wipe_volumes;
std::vector<std::pair<int,int>> filament_wipe_volumes;
};
@ -222,7 +147,7 @@ public:
// Set the extruder properties.
void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed,
float unloading_speed, float delay, int cooling_time)
float unloading_speed, float delay, int cooling_time, std::string ramming_parameters)
{
m_filpar[idx].material = material;
m_filpar[idx].temperature = temp;
@ -231,6 +156,14 @@ public:
m_filpar[idx].unloading_speed = unloading_speed;
m_filpar[idx].delay = delay;
m_filpar[idx].cooling_time = cooling_time;
std::stringstream stream{ramming_parameters};
float speed = 0.f;
stream >> m_filpar[idx].ramming_line_width_multiplicator >> m_filpar[idx].ramming_step_multiplicator;
m_filpar[idx].ramming_line_width_multiplicator /= 100;
m_filpar[idx].ramming_step_multiplicator /= 100;
while (stream >> speed)
m_filpar[idx].ramming_speed.push_back(speed);
}
@ -345,13 +278,16 @@ private:
struct FilamentParameters {
material_type material;
int temperature;
int first_layer_temperature;
float loading_speed;
float unloading_speed;
float delay;
int cooling_time;
material_type material;
int temperature;
int first_layer_temperature;
float loading_speed;
float unloading_speed;
float delay;
int cooling_time;
float ramming_line_width_multiplicator;
float ramming_step_multiplicator;
std::vector<float> ramming_speed;
};
// Extruder specific parameters.

View file

@ -189,6 +189,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
|| opt_key == "filament_unloading_speed"
|| opt_key == "filament_toolchange_delay"
|| opt_key == "filament_cooling_time"
|| opt_key == "filament_ramming_parameters"
|| opt_key == "gcode_flavor"
|| opt_key == "single_extruder_multi_material"
|| opt_key == "spiral_vase"
@ -1049,7 +1050,8 @@ void Print::_make_wipe_tower()
this->config.filament_loading_speed.get_at(i),
this->config.filament_unloading_speed.get_at(i),
this->config.filament_toolchange_delay.get_at(i),
this->config.filament_toolchange_delay.get_at(i));
this->config.filament_cooling_time.get_at(i),
this->config.filament_ramming_parameters.get_at(i));
// When printing the first layer's wipe tower, the first extruder is expected to be active and primed.
// Therefore the number of wipe sections at the wipe tower will be (m_tool_ordering.front().extruders-1) at the 1st layer.

View file

@ -483,13 +483,8 @@ PrintConfigDef::PrintConfigDef()
def->label = L("Ramming parameters");
def->tooltip = L("This string is edited by RammingDialog and contains ramming specific parameters ");
def->cli = "filament-ramming-parameters=s@";
def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0" };
def = this->add("filament_ramming_buttons", coStrings);
def->label = L("Draggable button in RammingDialog");
def->tooltip = L("This string is edited by RammingDialog and contains position of draggable buttons ");
def->cli = "filament-ramming-buttons=s@";
def->default_value = new ConfigOptionStrings { "0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" };
def->default_value = new ConfigOptionStrings { "120 100 6.6 6.8 7.2 7.6 7.9 8.2 8.7 9.4 9.9 10.0|"
" 0.05 6.6 0.45 6.8 0.95 7.8 1.45 8.3 1.95 9.7 2.45 10 2.95 7.6 3.45 7.6 3.95 7.6 4.45 7.6 4.95 7.6" };
def = this->add("filament_diameter", coFloats);
def->label = L("Diameter");

View file

@ -472,7 +472,6 @@ public:
ConfigOptionFloats filament_toolchange_delay;
ConfigOptionInts filament_cooling_time;
ConfigOptionStrings filament_ramming_parameters;
ConfigOptionStrings filament_ramming_buttons;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
ConfigOptionString layer_gcode;
@ -530,7 +529,6 @@ protected:
OPT_PTR(filament_toolchange_delay);
OPT_PTR(filament_cooling_time);
OPT_PTR(filament_ramming_parameters);
OPT_PTR(filament_ramming_buttons);
OPT_PTR(gcode_comments);
OPT_PTR(gcode_flavor);
OPT_PTR(layer_gcode);

View file

@ -211,7 +211,7 @@ const std::vector<std::string>& Preset::filament_options()
static std::vector<std::string> s_opts {
"filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed",
"extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay",
"filament_cooling_time", "filament_ramming_buttons", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature",
"filament_cooling_time", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature",
"first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers",
"fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers",
"compatible_printers_condition"

View file

@ -13,11 +13,11 @@ wxDECLARE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent);
class Chart : public wxWindow {
public:
Chart(wxWindow* parent, wxRect rect,const std::vector<std::pair<float,float>>& initial_buttons,std::vector<float> ramming_speed, float sampling) :
Chart(wxWindow* parent, wxRect rect,const std::vector<std::pair<float,float>>& initial_buttons,int ramming_speed_size, float sampling) :
wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize())
{
m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30));
visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed.size(), 20.);
visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.);
m_buttons.clear();
if (initial_buttons.size()>0)
for (const auto& pair : initial_buttons)

View file

@ -469,7 +469,7 @@ void TabPrint::build()
{
std::string init_data = (m_config->option<ConfigOptionString>("wipe_tower_advanced"))->value;
std::cout << "dialog init: " << init_data << std::endl;
WipeTowerDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy
WipingDialog dlg(this,init_data); // dlg lives on stack, no need to call Destroy
if (dlg.ShowModal() == wxID_OK) {
load_key_value("wipe_tower_advanced", dlg.GetValue());
@ -891,10 +891,10 @@ void TabFilament::build()
ramming_dialog_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e)
{
//std::string init_data = (m_config->option<ConfigOptionString>("wipe_tower_advanced"))->value;
RammingDialog dlg(this,std::string());
RammingDialog dlg(this,(m_config->option<ConfigOptionStrings>("filament_ramming_parameters"))->get_at(0));
if (dlg.ShowModal() == wxID_OK) {
//load_key_value("wipe_tower_advanced", dlg.GetValue());
wxMessageBox("DIALOG OK:\n"+dlg.get_parameters());
//load_key_value("wipe_tower_advanced", dlg.get_parameters());
}
}));
return sizer;

View file

@ -1,52 +1,13 @@
#include <algorithm>
#include <sstream>
#include "WipeTowerDialog.hpp"
// Human-readable output of Parameters structure
std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) {
str << "sampling: " << par.sampling << "\n";
str << "line widths: ";
for (const auto& a : par.ramming_line_width_multiplicator) str << a << " ";
str << "line spacing: ";
for (const auto& a : par.ramming_step_multiplicator) str << a << " ";
str<<"\n\nramming_speeds:\n";
for (const auto& a : par.ramming_speed) {
for (const auto& b : a)
str << b << " ";
str<<"\n";
}
str<<"\n\nramming_buttons:\n";
for (const auto& a : par.ramming_buttons) {
for (const auto& b : a) {
Slic3r::operator <<(str,b); // temporary hack (this << is in the namespace Slic3r)
str << " | "; // the function will be deleted after everything is debugged, anyway
}
str<<"\n";
}
str<<"\n\nwipe volumes:\n";
for (const auto& a : par.wipe_volumes) {
for (const auto& b : a)
str << b << " ";
str<<"\n";
}
str<<"\n\nfilament wipe volumes:\n";
for (const auto& a : par.filament_wipe_volumes) {
Slic3r::operator <<(str,a);
str << " ";
}
str<<"\n";
return str;
}
RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data)
RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
: wxDialog(parent, -1, wxT("Ramming customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
this->Centre();
m_panel_ramming = new RammingPanel(this,Slic3r::WipeTowerParameters(std::string()));
m_panel_ramming = new RammingPanel(this,parameters);
m_panel_ramming->Show(true);
this->Show();
@ -60,7 +21,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data)
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) {
// m_output_data=read_dialog_values();
m_output_data = m_panel_ramming->get_parameters();
EndModal(wxID_OK);
},wxID_OK);
}
@ -69,7 +30,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data)
RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED)
{
new wxStaticText(this,wxID_ANY,wxString("Total ramming time (s):"), wxPoint(500,105), wxSize(200,25),wxALIGN_LEFT);
@ -81,8 +42,22 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p
new wxStaticText(this,wxID_ANY,wxString("Ramming line spacing (%):"), wxPoint(500,235), wxSize(200,25),wxALIGN_LEFT);
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,230), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100);
std::stringstream stream{parameters};
stream >> m_ramming_line_width_multiplicator >> m_ramming_step_multiplicator;
int ramming_speed_size = 0;
float dummy = 0.f;
while (stream >> dummy)
++ramming_speed_size;
stream.clear();
stream.get();
m_chart = new Chart(this,wxRect(10,10,480,360),p.ramming_buttons[0],p.ramming_speed[0],p.sampling);
std::vector<std::pair<float,float>> buttons;
float x = 0.f;
float y = 0.f;
while (stream >> x >> y)
buttons.push_back(std::make_pair(x,y));
m_chart = new Chart(this,wxRect(10,10,480,360),buttons,ramming_speed_size,0.25f);
m_widget_time->SetValue(m_chart->get_time());
m_widget_time->SetDigits(2);
@ -100,26 +75,83 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p
Refresh(this);
}
void RammingPanel::fill_parameters(Slic3r::WipeTowerParameters& p)
{
if (!m_chart) return;
p.ramming_buttons[0] = m_chart->get_buttons();
p.ramming_speed[0] = m_chart->get_ramming_speed(p.sampling);
p.ramming_line_width_multiplicator.push_back(m_ramming_line_width_multiplicator/100.f);
p.ramming_step_multiplicator.push_back(m_ramming_step_multiplicator/100.f);
}
void RammingPanel::line_parameters_changed() {
m_ramming_line_width_multiplicator = m_widget_ramming_line_width_multiplicator->GetValue();
m_ramming_step_multiplicator = m_widget_ramming_step_multiplicator->GetValue();
}
std::string RammingPanel::get_parameters()
{
std::vector<float> speeds = m_chart->get_ramming_speed(0.25f);
std::vector<std::pair<float,float>> buttons = m_chart->get_buttons();
std::stringstream stream;
stream << m_ramming_line_width_multiplicator << " " << m_ramming_step_multiplicator;
for (const float& speed_value : speeds)
stream << " " << speed_value;
stream << "|";
for (const auto& button : buttons)
stream << " " << button.first << " " << button.second;
return stream.str();
}
/*
void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) {
p.wipe_volumes.clear();
p.filament_wipe_volumes.clear();
for (int i=0;i<4;++i) {
// first go through the full matrix:
p.wipe_volumes.push_back(std::vector<float>());
for (int j=0;j<4;++j) {
double val = 0.;
edit_boxes[j][i]->GetValue().ToDouble(&val);
p.wipe_volumes[i].push_back((float)val);
}
// now the filament volumes:
p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue()));
}
}
*/
WipingDialog::WipingDialog(wxWindow* parent,const std::string& init_data)
: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
this->Centre();
Slic3r::WipeTowerParameters parameters(init_data);
/*if (!parameters.validate()) {
wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR);
parameters.set_defaults();
}*/
m_panel_wiping = new WipingPanel(this,parameters);
this->Show();
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel_wiping, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
SetSizer(main_sizer);
SetMinSize(GetSize());
main_sizer->SetSizeHints(this);
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) {
m_output_data=read_dialog_values();
EndModal(wxID_OK);
},wxID_OK);
}
WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED)
{
@ -153,23 +185,6 @@ WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
Refresh(this);
}
void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) {
p.wipe_volumes.clear();
p.filament_wipe_volumes.clear();
for (int i=0;i<4;++i) {
// first go through the full matrix:
p.wipe_volumes.push_back(std::vector<float>());
for (int j=0;j<4;++j) {
double val = 0.;
edit_boxes[j][i]->GetValue().ToDouble(&val);
p.wipe_volumes[i].push_back((float)val);
}
// now the filament volumes:
p.filament_wipe_volumes.push_back(std::make_pair(m_old[i]->GetValue(),m_new[i]->GetValue()));
}
}
void WipingPanel::fill_in_matrix() {
wxArrayString choices;
choices.Add("sum");
@ -192,31 +207,5 @@ void WipingPanel::fill_in_matrix() {
WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data)
: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
this->Centre();
Slic3r::WipeTowerParameters parameters(init_data);
if (!parameters.validate()) {
wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR);
parameters.set_defaults();
}
m_panel_wiping = new WipingPanel(this,parameters);
this->Show();
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_panel_wiping, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
SetSizer(main_sizer);
SetMinSize(GetSize());
main_sizer->SetSizeHints(this);
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) {
m_output_data=read_dialog_values();
EndModal(wxID_OK);
},wxID_OK);
}

View file

@ -13,14 +13,13 @@
#include "RammingChart.hpp"
// Human-readable output of Parameters structure
std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par);
class RammingPanel : public wxPanel {
public:
RammingPanel(wxWindow* parent);
RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p);
void fill_parameters(Slic3r::WipeTowerParameters& p);
RammingPanel(wxWindow* parent,const std::string& data);
std::string get_parameters();
private:
Chart* m_chart = nullptr;
@ -37,9 +36,11 @@ private:
class RammingDialog : public wxDialog {
public:
RammingDialog(wxWindow* parent,const std::string& init_data);
RammingDialog(wxWindow* parent,const std::string& parameters);
std::string get_parameters() { return m_output_data; }
private:
RammingPanel* m_panel_ramming = nullptr;
std::string m_output_data;
};
@ -63,9 +64,9 @@ private:
class WipeTowerDialog : public wxDialog {
class WipingDialog : public wxDialog {
public:
WipeTowerDialog(wxWindow* parent,const std::string& init_data);
WipingDialog(wxWindow* parent,const std::string& init_data);
std::string GetValue() const { return m_output_data; }
@ -78,7 +79,7 @@ private:
std::string read_dialog_values() {
Slic3r::WipeTowerParameters p;
m_panel_wiping ->fill_parameters(p);
return p.to_string();
//return p.to_string();
}
};