mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-09 05:19:09 +08:00
Started to move ramming dialog into filament settings
This commit is contained in:
parent
27ab8ff4e1
commit
cf5dfb9673
@ -10,41 +10,41 @@ void Chart::draw(wxDC& dc) {
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.DrawRectangle(m_rect);
|
||||
|
||||
if (visible_area->m_width < 0.499) {
|
||||
if (visible_area.m_width < 0.499) {
|
||||
dc.DrawText("NO RAMMING AT ALL",wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-50,m_rect.GetBottom()-m_rect.GetHeight()/2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!m_line_to_draw->empty()) {
|
||||
for (unsigned int i=0;i<m_line_to_draw->size()-2;++i) {
|
||||
int color = 510*((m_rect.GetBottom()-(*m_line_to_draw)[i])/double(m_rect.GetHeight()));
|
||||
if (!m_line_to_draw.empty()) {
|
||||
for (unsigned int i=0;i<m_line_to_draw.size()-2;++i) {
|
||||
int color = 510*((m_rect.GetBottom()-(m_line_to_draw)[i])/double(m_rect.GetHeight()));
|
||||
dc.SetPen( wxPen( wxColor(std::min(255,color),255-std::max(color-255,0),0), 1 ) );
|
||||
dc.DrawLine(m_rect.GetLeft()+1+i,(*m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom());
|
||||
dc.DrawLine(m_rect.GetLeft()+1+i,(m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom());
|
||||
}
|
||||
dc.SetPen( wxPen( wxColor(0,0,0), 1 ) );
|
||||
for (unsigned int i=0;i<m_line_to_draw->size()-2;++i) {
|
||||
for (unsigned int i=0;i<m_line_to_draw.size()-2;++i) {
|
||||
if (splines)
|
||||
dc.DrawLine(m_rect.GetLeft()+i,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i+1]);
|
||||
dc.DrawLine(m_rect.GetLeft()+i,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i+1]);
|
||||
else {
|
||||
dc.DrawLine(m_rect.GetLeft()+i,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i]);
|
||||
dc.DrawLine(m_rect.GetLeft()+i+1,(*m_line_to_draw)[i],m_rect.GetLeft()+i+1,(*m_line_to_draw)[i+1]);
|
||||
}
|
||||
dc.DrawLine(m_rect.GetLeft()+i,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i]);
|
||||
dc.DrawLine(m_rect.GetLeft()+i+1,(m_line_to_draw)[i],m_rect.GetLeft()+i+1,(m_line_to_draw)[i+1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw draggable buttons
|
||||
dc.SetBrush(*wxBLUE_BRUSH);
|
||||
dc.SetPen( wxPen( wxColor(0,0,0), 1 ) );
|
||||
for (auto& button : m_buttons[m_current_extruder])
|
||||
for (auto& button : m_buttons)
|
||||
//dc.DrawRectangle(math_to_screen(button.get_pos())-wxPoint(side/2.,side/2.), wxSize(side,side));
|
||||
dc.DrawCircle(math_to_screen(button.get_pos()),side/2.);
|
||||
//dc.DrawRectangle(math_to_screen(button.get_pos()-wxPoint2DDouble(0.125,0))-wxPoint(0,5),wxSize(50,10));
|
||||
|
||||
// draw x-axis:
|
||||
float last_mark = -10000;
|
||||
for (float math_x=int(visible_area->m_x*10)/10 ; math_x <= (visible_area->m_x+visible_area->m_width) ; math_x+=0.1) {
|
||||
int x = math_to_screen(wxPoint2DDouble(math_x,visible_area->m_y)).x;
|
||||
for (float math_x=int(visible_area.m_x*10)/10 ; math_x <= (visible_area.m_x+visible_area.m_width) ; math_x+=0.1) {
|
||||
int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x;
|
||||
int y = m_rect.GetBottom();
|
||||
if (x-last_mark < 50) continue;
|
||||
dc.DrawLine(x,y+3,x,y-3);
|
||||
@ -54,8 +54,8 @@ void Chart::draw(wxDC& dc) {
|
||||
|
||||
// draw y-axis:
|
||||
last_mark=10000;
|
||||
for (int math_y=visible_area->m_y ; math_y <= (visible_area->m_y+visible_area->m_height) ; math_y+=1) {
|
||||
int y = math_to_screen(wxPoint2DDouble(visible_area->m_x,math_y)).y;
|
||||
for (int math_y=visible_area.m_y ; math_y <= (visible_area.m_y+visible_area.m_height) ; math_y+=1) {
|
||||
int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y;
|
||||
int x = m_rect.GetLeft();
|
||||
if (last_mark-y < 50) continue;
|
||||
dc.DrawLine(x-3,y,x+3,y);
|
||||
@ -72,8 +72,8 @@ void Chart::mouse_right_button_clicked(wxMouseEvent& event) {
|
||||
return;
|
||||
wxPoint point = event.GetPosition();
|
||||
int button_index = which_button_is_clicked(point);
|
||||
if (button_index != -1 && m_buttons[m_current_extruder].size()>2) {
|
||||
m_buttons[m_current_extruder].erase(m_buttons[m_current_extruder].begin()+button_index);
|
||||
if (button_index != -1 && m_buttons.size()>2) {
|
||||
m_buttons.erase(m_buttons.begin()+button_index);
|
||||
recalculate_line();
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ void Chart::mouse_clicked(wxMouseEvent& event) {
|
||||
wxPoint point = event.GetPosition();
|
||||
int button_index = which_button_is_clicked(point);
|
||||
if ( button_index != -1) {
|
||||
m_dragged = &m_buttons[m_current_extruder][button_index];
|
||||
m_dragged = &m_buttons[button_index];
|
||||
m_previous_mouse = point;
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ void Chart::mouse_moved(wxMouseEvent& event) {
|
||||
}
|
||||
int delta_x = pos.x - m_previous_mouse.x;
|
||||
int delta_y = pos.y - m_previous_mouse.y;
|
||||
m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area->m_width,-double(delta_y)/m_rect.GetHeight() * visible_area->m_height);
|
||||
m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width,-double(delta_y)/m_rect.GetHeight() * visible_area.m_height);
|
||||
m_previous_mouse = pos;
|
||||
recalculate_line();
|
||||
}
|
||||
@ -115,8 +115,8 @@ void Chart::mouse_double_clicked(wxMouseEvent& event) {
|
||||
wxPoint point = event.GetPosition();
|
||||
if (!m_rect.Contains(point)) // the click is outside the chart
|
||||
return;
|
||||
m_buttons[m_current_extruder].push_back(screen_to_math(point));
|
||||
std::sort(m_buttons[m_current_extruder].begin(),m_buttons[m_current_extruder].end());
|
||||
m_buttons.push_back(screen_to_math(point));
|
||||
std::sort(m_buttons.begin(),m_buttons.end());
|
||||
recalculate_line();
|
||||
return;
|
||||
}
|
||||
@ -126,7 +126,7 @@ void Chart::mouse_double_clicked(wxMouseEvent& event) {
|
||||
|
||||
void Chart::recalculate_line() {
|
||||
std::vector<wxPoint> points;
|
||||
for (auto& but : m_buttons[m_current_extruder]) {
|
||||
for (auto& but : m_buttons) {
|
||||
points.push_back(wxPoint(math_to_screen(but.get_pos())));
|
||||
if (points.size()>1 && points.back().x==points[points.size()-2].x) points.pop_back();
|
||||
if (points.size()>1 && points.back().x > m_rect.GetRight()) {
|
||||
@ -136,7 +136,7 @@ void Chart::recalculate_line() {
|
||||
}
|
||||
std::sort(points.begin(),points.end(),[](wxPoint& a,wxPoint& b) { return a.x < b.x; });
|
||||
|
||||
m_line_to_draw->clear();
|
||||
m_line_to_draw.clear();
|
||||
m_total_volume = 0.f;
|
||||
|
||||
|
||||
@ -205,19 +205,19 @@ void Chart::recalculate_line() {
|
||||
y = (rhs[i-1]*pow(points[i].x-x,3)+rhs[i]*pow(x-points[i-1].x,3)) / (6*h[i]) +
|
||||
(points[i-1].y-rhs[i-1]*h[i]*h[i]/6.f) * (points[i].x-x)/h[i] +
|
||||
(points[i].y -rhs[i] *h[i]*h[i]/6.f) * (x-points[i-1].x)/h[i];
|
||||
m_line_to_draw->push_back(y);
|
||||
m_line_to_draw.push_back(y);
|
||||
}
|
||||
else {
|
||||
float x_math = screen_to_math(wxPoint(x,0)).m_x;
|
||||
if (i+2<=points.size() && m_buttons[m_current_extruder][i+1].get_pos().m_x-0.125 < x_math)
|
||||
if (i+2<=points.size() && m_buttons[i+1].get_pos().m_x-0.125 < x_math)
|
||||
++i;
|
||||
m_line_to_draw->push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[m_current_extruder][i].get_pos().m_y)).y);
|
||||
m_line_to_draw.push_back(math_to_screen(wxPoint2DDouble(x_math,m_buttons[i].get_pos().m_y)).y);
|
||||
}
|
||||
|
||||
|
||||
m_line_to_draw->back() = std::max(m_line_to_draw->back(), m_rect.GetTop()-1);
|
||||
m_line_to_draw->back() = std::min(m_line_to_draw->back(), m_rect.GetBottom()-1);
|
||||
m_total_volume += (m_rect.GetBottom() - m_line_to_draw->back()) * (visible_area->m_width / m_rect.GetWidth()) * (visible_area->m_height / m_rect.GetHeight());
|
||||
m_line_to_draw.back() = std::max(m_line_to_draw.back(), m_rect.GetTop()-1);
|
||||
m_line_to_draw.back() = std::min(m_line_to_draw.back(), m_rect.GetBottom()-1);
|
||||
m_total_volume += (m_rect.GetBottom() - m_line_to_draw.back()) * (visible_area.m_width / m_rect.GetWidth()) * (visible_area.m_height / m_rect.GetHeight());
|
||||
}
|
||||
|
||||
wxPostEvent(this->GetParent(), wxCommandEvent(EVT_WIPE_TOWER_CHART_CHANGED));
|
||||
@ -226,36 +226,26 @@ void Chart::recalculate_line() {
|
||||
|
||||
|
||||
|
||||
std::vector<std::vector<float>> Chart::get_ramming_speeds(float sampling) const {
|
||||
std::vector<std::vector<float>> speeds_out;
|
||||
for (unsigned int extruder_id = 0;extruder_id<m_buttons.size();++extruder_id) { // repeat for each extruder
|
||||
std::vector<float> this_extruder;
|
||||
const int number_of_samples = std::round( visible_areas[extruder_id].m_width / sampling);
|
||||
if (number_of_samples>0) {
|
||||
const int dx = (m_lines_to_draw[extruder_id].size()-1) / number_of_samples;
|
||||
for (int j=0;j<number_of_samples;++j) {
|
||||
float left = screen_to_math(wxPoint(0,m_lines_to_draw[extruder_id][j*dx])).m_y;
|
||||
float right = screen_to_math(wxPoint(0,m_lines_to_draw[extruder_id][(j+1)*dx])).m_y;
|
||||
this_extruder.push_back((left+right)/2.f);
|
||||
}
|
||||
}
|
||||
/*else
|
||||
this_extruder.push_back(0.f); // so it does not stay empty*/
|
||||
speeds_out.push_back(std::move(this_extruder));
|
||||
}
|
||||
std::vector<float> Chart::get_ramming_speed(float sampling) const {
|
||||
std::vector<float> speeds_out;
|
||||
|
||||
const int number_of_samples = std::round( visible_area.m_width / sampling);
|
||||
if (number_of_samples>0) {
|
||||
const int dx = (m_line_to_draw.size()-1) / number_of_samples;
|
||||
for (int j=0;j<number_of_samples;++j) {
|
||||
float left = screen_to_math(wxPoint(0,m_line_to_draw[j*dx])).m_y;
|
||||
float right = screen_to_math(wxPoint(0,m_line_to_draw[(j+1)*dx])).m_y;
|
||||
speeds_out.push_back((left+right)/2.f);
|
||||
}
|
||||
}
|
||||
return speeds_out;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::vector<std::pair<float,float>>> Chart::get_buttons() const {
|
||||
std::vector<std::vector<std::pair<float, float>>> buttons_out;
|
||||
for (const auto& ext : m_buttons) {
|
||||
std::vector<std::pair<float,float>> this_extruder;
|
||||
for (const auto& button : ext)
|
||||
this_extruder.push_back(std::make_pair(button.get_pos().m_x,button.get_pos().m_y));
|
||||
buttons_out.push_back(std::move(this_extruder));
|
||||
}
|
||||
std::vector<std::pair<float,float>> Chart::get_buttons() const {
|
||||
std::vector<std::pair<float, float>> buttons_out;
|
||||
for (const auto& button : m_buttons)
|
||||
buttons_out.push_back(std::make_pair(button.get_pos().m_x,button.get_pos().m_y));
|
||||
return buttons_out;
|
||||
}
|
||||
|
||||
|
@ -13,39 +13,28 @@ wxDECLARE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent);
|
||||
class Chart : public wxWindow {
|
||||
|
||||
public:
|
||||
Chart(wxWindow* parent, wxRect rect,const std::vector<std::vector<std::pair<float,float>>>& initial_buttons,std::vector<std::vector<float>> ramming_speed, float sampling) :
|
||||
Chart(wxWindow* parent, wxRect rect,const std::vector<std::pair<float,float>>& initial_buttons,std::vector<float> ramming_speed, float sampling) :
|
||||
wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize())
|
||||
{
|
||||
m_rect=wxRect(wxPoint(30,0),rect.GetSize()-wxSize(30,30));
|
||||
for (int i=0;i<4;++i) {
|
||||
visible_areas.push_back(wxRect2DDouble(0.0, 0.0, sampling*ramming_speed[i].size(), 20.));
|
||||
m_buttons.push_back(std::vector<ButtonToDrag>());
|
||||
m_lines_to_draw.push_back(std::vector<int>());
|
||||
if (initial_buttons.size()>0)
|
||||
for (const auto& pair : initial_buttons[i])
|
||||
m_buttons.back().push_back(wxPoint2DDouble(pair.first,pair.second));
|
||||
set_extruder(i); // to calculate all interpolating splines
|
||||
}
|
||||
set_extruder(0);
|
||||
}
|
||||
void set_extruder(unsigned ext) {
|
||||
if (ext>=4) return;
|
||||
m_current_extruder = ext;
|
||||
visible_area = &(visible_areas[ext]);
|
||||
m_line_to_draw = &(m_lines_to_draw[ext]);
|
||||
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)
|
||||
m_buttons.push_back(wxPoint2DDouble(pair.first,pair.second));
|
||||
recalculate_line();
|
||||
}
|
||||
void set_xy_range(float x,float y) {
|
||||
x = int(x/0.5) * 0.5;
|
||||
if (x>=0) visible_area->SetRight(x);
|
||||
if (y>=0) visible_area->SetBottom(y);
|
||||
if (x>=0) visible_area.SetRight(x);
|
||||
if (y>=0) visible_area.SetBottom(y);
|
||||
recalculate_line();
|
||||
}
|
||||
float get_volume() const { return m_total_volume; }
|
||||
float get_time() const { return visible_area->m_width; }
|
||||
std::vector<std::vector<float>> get_ramming_speeds(float sampling) const; //returns sampled ramming speed for all extruders
|
||||
std::vector<std::vector<std::pair<float,float>>> get_buttons() const; // returns buttons position for all extruders
|
||||
|
||||
float get_time() const { return visible_area.m_width; }
|
||||
|
||||
std::vector<float> get_ramming_speed(float sampling) const; //returns sampled ramming speed
|
||||
std::vector<std::pair<float,float>> get_buttons() const; // returns buttons position
|
||||
|
||||
void draw(wxDC& dc);
|
||||
|
||||
@ -80,8 +69,8 @@ private:
|
||||
|
||||
wxPoint math_to_screen(const wxPoint2DDouble& math) const {
|
||||
wxPoint screen;
|
||||
screen.x = (math.m_x-visible_area->m_x) * (m_rect.GetWidth() / visible_area->m_width );
|
||||
screen.y = (math.m_y-visible_area->m_y) * (m_rect.GetHeight() / visible_area->m_height );
|
||||
screen.x = (math.m_x-visible_area.m_x) * (m_rect.GetWidth() / visible_area.m_width );
|
||||
screen.y = (math.m_y-visible_area.m_y) * (m_rect.GetHeight() / visible_area.m_height );
|
||||
screen.y *= -1;
|
||||
screen += m_rect.GetLeftBottom();
|
||||
return screen;
|
||||
@ -90,16 +79,16 @@ private:
|
||||
wxPoint2DDouble math = screen;
|
||||
math -= m_rect.GetLeftBottom();
|
||||
math.m_y *= -1;
|
||||
math.m_x *= visible_area->m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1]
|
||||
math.m_y *= visible_area->m_height / m_rect.GetHeight();
|
||||
return (math+visible_area->GetLeftTop());
|
||||
math.m_x *= visible_area.m_width / m_rect.GetWidth(); // scales to [0;1]x[0,1]
|
||||
math.m_y *= visible_area.m_height / m_rect.GetHeight();
|
||||
return (math+visible_area.GetLeftTop());
|
||||
}
|
||||
|
||||
int which_button_is_clicked(const wxPoint& point) const {
|
||||
if (!m_rect.Contains(point))
|
||||
return -1;
|
||||
for (unsigned int i=0;i<m_buttons[m_current_extruder].size();++i) {
|
||||
wxRect rect(math_to_screen(m_buttons[m_current_extruder][i].get_pos())-wxPoint(side/2.,side/2.),wxSize(side,side)); // bounding rectangle of this button
|
||||
for (unsigned int i=0;i<m_buttons.size();++i) {
|
||||
wxRect rect(math_to_screen(m_buttons[i].get_pos())-wxPoint(side/2.,side/2.),wxSize(side,side)); // bounding rectangle of this button
|
||||
if ( rect.Contains(point) )
|
||||
return i;
|
||||
}
|
||||
@ -111,17 +100,13 @@ private:
|
||||
void recalculate_volume();
|
||||
|
||||
|
||||
unsigned int m_current_extruder = 0;
|
||||
wxRect m_rect; // rectangle on screen the chart is mapped into (screen coordinates)
|
||||
wxPoint m_previous_mouse;
|
||||
std::vector< std::vector<ButtonToDrag> > m_buttons;
|
||||
std::vector< std::vector<int> > m_lines_to_draw;
|
||||
std::vector< wxRect2DDouble > visible_areas;
|
||||
wxRect2DDouble* visible_area = nullptr;
|
||||
std::vector<int>* m_line_to_draw = nullptr;
|
||||
std::vector<ButtonToDrag> m_buttons;
|
||||
std::vector<int> m_line_to_draw;
|
||||
wxRect2DDouble visible_area;
|
||||
ButtonToDrag* m_dragged = nullptr;
|
||||
float m_total_volume = 0.f;
|
||||
|
||||
float m_total_volume = 0.f;
|
||||
|
||||
};
|
||||
|
||||
|
@ -796,7 +796,7 @@ void TabPrint::update()
|
||||
|
||||
bool have_wipe_tower = m_config->opt_bool("wipe_tower");
|
||||
vec_enable.resize(0);
|
||||
vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle"};
|
||||
vec_enable = { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_per_color_wipe", "wipe_tower_rotation_angle", "wipe_tower_bridging"};
|
||||
for (auto el : vec_enable)
|
||||
get_field(el)->toggle(have_wipe_tower);
|
||||
m_wipe_tower_btn->Enable(have_wipe_tower);
|
||||
@ -885,20 +885,18 @@ void TabFilament::build()
|
||||
optgroup->append_single_option_line("filament_cooling_time");
|
||||
line = { _(L("Ramming")), "" };
|
||||
line.widget = [this](wxWindow* parent){
|
||||
auto ramming_dialog = new wxButton(parent, wxID_ANY, _(L("Advanced settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(ramming_dialog);
|
||||
/*m_wipe_tower_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e)
|
||||
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(ramming_dialog_btn);
|
||||
|
||||
ramming_dialog_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e)
|
||||
{
|
||||
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
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
load_key_value("wipe_tower_advanced", dlg.GetValue());
|
||||
std::cout << std::endl << "dialog returned: " << dlg.GetValue() << std::endl;
|
||||
//std::string init_data = (m_config->option<ConfigOptionString>("wipe_tower_advanced"))->value;
|
||||
RammingDialog dlg(this,std::string());
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
//load_key_value("wipe_tower_advanced", dlg.GetValue());
|
||||
}
|
||||
}));*/
|
||||
}));
|
||||
return sizer;
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
|
@ -40,12 +40,37 @@ std::ostream& operator<<(std::ostream& str,Slic3r::WipeTowerParameters& par) {
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
RammingDialog::RammingDialog(wxWindow* parent,const std::string& init_data)
|
||||
: 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->Show(true);
|
||||
this->Show();
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->Add(m_panel_ramming, 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
|
||||
: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED)
|
||||
: 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);
|
||||
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString, wxPoint(700,100), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,0.,5.0,3.,0.5);
|
||||
@ -55,56 +80,40 @@ RammingPanel::RammingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p
|
||||
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString, wxPoint(700,200), wxSize(75,25),wxSP_ARROW_KEYS|wxALIGN_RIGHT,10,200,100);
|
||||
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);
|
||||
new wxStaticText(this,wxID_ANY,wxString("Extruder #:"), wxPoint(500,12), wxSize(200,25),wxALIGN_LEFT);
|
||||
|
||||
wxArrayString choices;
|
||||
for (unsigned int i=0;i<p.ramming_line_width_multiplicator.size();++i) { // for all extruders
|
||||
choices.Add(wxString("")<<i+1);
|
||||
m_ramming_line_width_multiplicators.push_back(p.ramming_line_width_multiplicator[i]*100);
|
||||
m_ramming_step_multiplicators.push_back(p.ramming_step_multiplicator[i]*100);
|
||||
}
|
||||
m_widget_extruder = new wxChoice(this,wxID_ANY,wxPoint(580,5),wxSize(50,27),choices);
|
||||
|
||||
m_chart = new Chart(this,wxRect(10,10,480,360),p.ramming_buttons,p.ramming_speed,p.sampling);
|
||||
m_chart = new Chart(this,wxRect(10,10,480,360),p.ramming_buttons[0],p.ramming_speed[0],p.sampling);
|
||||
|
||||
m_chart->set_extruder(0);
|
||||
m_widget_time->SetValue(m_chart->get_time());
|
||||
m_widget_time->SetDigits(2);
|
||||
m_widget_volume->SetValue(m_chart->get_volume());
|
||||
m_widget_volume->Disable();
|
||||
m_widget_extruder->SetSelection(0);
|
||||
extruder_selection_changed(); // tell everyone to redraw
|
||||
m_widget_ramming_line_width_multiplicator->SetValue(m_ramming_line_width_multiplicator);
|
||||
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
|
||||
|
||||
m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_extruder->Bind(wxEVT_CHOICE,[this](wxCommandEvent&) { extruder_selection_changed(); });
|
||||
m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);});
|
||||
m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
|
||||
Refresh(this);
|
||||
}
|
||||
|
||||
|
||||
void RammingPanel::fill_parameters(Slic3r::WipeTowerParameters& p)
|
||||
{
|
||||
if (!m_chart) return;
|
||||
p.ramming_buttons = m_chart->get_buttons();
|
||||
p.ramming_speed = m_chart->get_ramming_speeds(p.sampling);
|
||||
for (unsigned int i=0;i<m_ramming_line_width_multiplicators.size();++i) { // we assume m_ramming_line_width_multiplicators.size() == m_ramming_step_multiplicators.size()
|
||||
p.ramming_line_width_multiplicator.push_back(m_ramming_line_width_multiplicators[i]/100.f);
|
||||
p.ramming_step_multiplicator.push_back(m_ramming_step_multiplicators[i]/100.f);
|
||||
}
|
||||
}
|
||||
|
||||
void RammingPanel::extruder_selection_changed() {
|
||||
m_current_extruder = m_widget_extruder->GetSelection();
|
||||
m_chart->set_extruder(m_current_extruder); // tell our chart to redraw
|
||||
m_widget_ramming_line_width_multiplicator ->SetValue(m_ramming_line_width_multiplicators[m_current_extruder]);
|
||||
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicators[m_current_extruder]);
|
||||
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_multiplicators[m_current_extruder]=m_widget_ramming_line_width_multiplicator->GetValue();
|
||||
m_ramming_step_multiplicators[m_current_extruder]=m_widget_ramming_step_multiplicator->GetValue();
|
||||
m_ramming_line_width_multiplicator = m_widget_ramming_line_width_multiplicator->GetValue();
|
||||
m_ramming_step_multiplicator = m_widget_ramming_step_multiplicator->GetValue();
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +121,7 @@ void RammingPanel::line_parameters_changed() {
|
||||
|
||||
|
||||
WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
|
||||
: wxPanel(parent,wxID_ANY,wxPoint(0,0),wxSize(0,0),wxBORDER_RAISED)
|
||||
: wxPanel(parent,wxID_ANY,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED)
|
||||
{
|
||||
const int N = 4; // number of extruders
|
||||
new wxStaticText(this,wxID_ANY,wxString("Volume to wipe when the filament is being"),wxPoint(40,55) ,wxSize(500,25));
|
||||
@ -141,6 +150,7 @@ WipingPanel::WipingPanel(wxWindow* parent,const Slic3r::WipeTowerParameters& p)
|
||||
}
|
||||
|
||||
m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){fill_in_matrix();});
|
||||
Refresh(this);
|
||||
}
|
||||
|
||||
void WipingPanel::fill_parameters(Slic3r::WipeTowerParameters& p) {
|
||||
@ -183,7 +193,7 @@ void WipingPanel::fill_in_matrix() {
|
||||
|
||||
|
||||
WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data)
|
||||
: wxDialog(parent, -1, wxT("Wipe tower advanced settings"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
: wxDialog(parent, -1, wxT("Wiping customization"), wxPoint(50,50), wxSize(800,550), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
this->Centre();
|
||||
|
||||
@ -192,21 +202,11 @@ WipeTowerDialog::WipeTowerDialog(wxWindow* parent,const std::string& init_data)
|
||||
wxMessageDialog(this,"Wipe tower parameters not parsed correctly!\nRestoring default settings.","Error",wxICON_ERROR);
|
||||
parameters.set_defaults();
|
||||
}
|
||||
|
||||
wxNotebook* notebook = new wxNotebook(this,wxID_ANY,wxPoint(0,0),wxSize(800,450));
|
||||
|
||||
//m_panel_general = new GeneralPanel(notebook,parameters);
|
||||
m_panel_ramming = new RammingPanel(notebook,parameters);
|
||||
//m_panel_cooling = new CoolingPanel(notebook,parameters);
|
||||
m_panel_wiping = new WipingPanel(notebook,parameters);
|
||||
//notebook->AddPage(m_panel_general,"General");
|
||||
notebook->AddPage(m_panel_ramming,"Ramming");
|
||||
//notebook->AddPage(m_panel_cooling,"Cooling");
|
||||
notebook->AddPage(m_panel_wiping,"Wiping");
|
||||
m_panel_wiping = new WipingPanel(this,parameters);
|
||||
this->Show();
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->Add(notebook, 1, wxEXPAND);
|
||||
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());
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
// 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);
|
||||
|
||||
@ -28,17 +28,22 @@ private:
|
||||
wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr;
|
||||
wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr;
|
||||
wxSpinCtrlDouble* m_widget_time = nullptr;
|
||||
wxChoice* m_widget_extruder = nullptr;
|
||||
std::vector<int> m_ramming_step_multiplicators;
|
||||
std::vector<int> m_ramming_line_width_multiplicators;
|
||||
int m_current_extruder = 0; // zero-based index
|
||||
|
||||
void extruder_selection_changed();
|
||||
|
||||
int m_ramming_step_multiplicator;
|
||||
int m_ramming_line_width_multiplicator;
|
||||
|
||||
void line_parameters_changed();
|
||||
};
|
||||
|
||||
|
||||
class RammingDialog : public wxDialog {
|
||||
public:
|
||||
RammingDialog(wxWindow* parent,const std::string& init_data);
|
||||
private:
|
||||
RammingPanel* m_panel_ramming = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class WipingPanel : public wxPanel {
|
||||
public:
|
||||
@ -67,13 +72,11 @@ public:
|
||||
|
||||
private:
|
||||
std::string m_file_name="config_wipe_tower";
|
||||
RammingPanel* m_panel_ramming = nullptr;
|
||||
WipingPanel* m_panel_wiping = nullptr;
|
||||
std::string m_output_data = "";
|
||||
|
||||
std::string read_dialog_values() {
|
||||
Slic3r::WipeTowerParameters p;
|
||||
m_panel_ramming->fill_parameters(p);
|
||||
m_panel_wiping ->fill_parameters(p);
|
||||
return p.to_string();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user