mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
Ramming dialog improvements & add step control for SpinInput class (#9651)
* init * update dialog buttons * Fix color on Linux & macOS * Fix dark mode dialog title color on Windows --------- Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
@@ -14,20 +14,22 @@ wxDEFINE_EVENT(EVT_WIPE_TOWER_CHART_CHANGED, wxCommandEvent);
|
||||
void Chart::draw() {
|
||||
wxAutoBufferedPaintDC dc(this); // unbuffered DC caused flickering on win
|
||||
|
||||
// scaling button and tick line from text size gives better result compared to dc.GetContentScale
|
||||
int text_width, text_height;
|
||||
dc.GetTextExtent("m",&text_width,&text_height);
|
||||
side = text_width;
|
||||
int tick_w = text_width / 2;
|
||||
|
||||
dc.SetBrush(GetBackgroundColour());
|
||||
dc.SetPen(GetBackgroundColour());
|
||||
dc.DrawRectangle(GetClientRect()); // otherwise the background would end up black on windows
|
||||
|
||||
#ifdef _WIN32
|
||||
dc.SetPen(wxPen(GetForegroundColour()));
|
||||
dc.SetBrush(wxBrush(Slic3r::GUI::wxGetApp().get_highlight_default_clr()));
|
||||
#else
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
#endif
|
||||
dc.SetPen( wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), 1)); // input box border color
|
||||
dc.SetBrush(wxBrush(StateColor::darkModeColorFor(wxColour("#F1F1F1")))); // sidebar titlebar bg color
|
||||
dc.DrawRectangle(m_rect);
|
||||
|
||||
if (visible_area.m_width < 0.499) {
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#FF6F00"))); // Use orange color for warning
|
||||
dc.DrawText(_(L("NO RAMMING AT ALL")),wxPoint(m_rect.GetLeft()+m_rect.GetWidth()/2-legend_side,m_rect.GetBottom()-m_rect.GetHeight()/2));
|
||||
return;
|
||||
}
|
||||
@@ -35,15 +37,11 @@ void Chart::draw() {
|
||||
|
||||
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 ) );
|
||||
int color = 444*((m_rect.GetBottom()-(m_line_to_draw)[i])/double(m_rect.GetHeight()));
|
||||
dc.SetPen( wxPen( wxColor(std::min(222,color), 222-std::max(color-222,0), 60), 1) ); // adding blue color sligtly gives a bit more modern look instead using raw red & green
|
||||
dc.DrawLine(m_rect.GetLeft()+1+i,(m_line_to_draw)[i],m_rect.GetLeft()+1+i,m_rect.GetBottom());
|
||||
}
|
||||
#ifdef _WIN32
|
||||
dc.SetPen(wxPen(GetForegroundColour()));
|
||||
#else
|
||||
dc.SetPen( wxPen( wxColor(0,0,0), 1 ) );
|
||||
#endif
|
||||
dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#363636")), 1));
|
||||
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]);
|
||||
@@ -55,25 +53,25 @@ void Chart::draw() {
|
||||
}
|
||||
|
||||
// draw draggable buttons
|
||||
dc.SetBrush(*wxBLUE_BRUSH);
|
||||
#ifdef _WIN32
|
||||
dc.SetPen(wxPen(GetForegroundColour()));
|
||||
#else
|
||||
dc.SetPen( wxPen( wxColor(0,0,0), 1 ) );
|
||||
#endif
|
||||
dc.SetBrush(StateColor::darkModeColorFor(wxColour("#009688"))); // orca color for draggable circles
|
||||
dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#363636")), 1));
|
||||
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));
|
||||
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#363636"))); // Label color
|
||||
|
||||
// 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.1f) {
|
||||
int x = math_to_screen(wxPoint2DDouble(math_x,visible_area.m_y)).x;
|
||||
int y = m_rect.GetBottom();
|
||||
if (x-last_mark < legend_side) continue;
|
||||
dc.DrawLine(x,y+3,x,y-3);
|
||||
dc.DrawText(wxString().Format(wxT("%.1f"), math_x),wxPoint(x-scale_unit,y+0.5*scale_unit));
|
||||
dc.DrawLine(x,y+tick_w+1,x,y-tick_w); // +1 for border; make sure drawn on both size
|
||||
auto label = math_x == 0 ? "0" : wxString().Format(wxT("%.1f") , math_x); // prefer "0" to match text with Y "0"
|
||||
dc.GetTextExtent(label,&text_width,&text_height);// center text with lines
|
||||
dc.DrawText(label ,wxPoint(x - text_width * .5, y + .8 * scale_unit));
|
||||
last_mark = x;
|
||||
}
|
||||
|
||||
@@ -83,17 +81,17 @@ void Chart::draw() {
|
||||
int y = math_to_screen(wxPoint2DDouble(visible_area.m_x,math_y)).y;
|
||||
int x = m_rect.GetLeft();
|
||||
if (last_mark-y < legend_side) continue;
|
||||
dc.DrawLine(x-3,y,x+3,y);
|
||||
dc.DrawText(wxString()<<math_y,wxPoint(x-2*scale_unit,y-0.5*scale_unit));
|
||||
dc.DrawLine(x-tick_w,y,x+tick_w+1,y); // +1 for border; make sure drawn on both size
|
||||
auto label = wxString()<<math_y;
|
||||
dc.GetTextExtent(label,&text_width,&text_height);// center text with lines & make it right aligned
|
||||
dc.DrawText(label ,wxPoint(x - scale_unit - text_width, y - .5 * text_height + 1));
|
||||
last_mark = y;
|
||||
}
|
||||
|
||||
// axis labels:
|
||||
wxString label = _(L("Time")) + " ("+_(L("s"))+")";
|
||||
int text_width = 0;
|
||||
int text_height = 0;
|
||||
dc.GetTextExtent(label,&text_width,&text_height);
|
||||
dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+0.5*legend_side));
|
||||
dc.DrawText(label,wxPoint(0.5*(m_rect.GetRight()+m_rect.GetLeft())-text_width/2.f, m_rect.GetBottom()+0.6*legend_side));
|
||||
label = _(L("Volumetric speed")) + " (" + _(L("mm³/s")) + ")";
|
||||
dc.GetTextExtent(label,&text_width,&text_height);
|
||||
dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90);
|
||||
@@ -124,9 +122,13 @@ void Chart::mouse_clicked(wxMouseEvent& event) {
|
||||
|
||||
|
||||
void Chart::mouse_moved(wxMouseEvent& event) {
|
||||
if (!event.Dragging() || !m_dragged) return;
|
||||
wxPoint pos = event.GetPosition();
|
||||
wxRect rect = m_rect;
|
||||
if (!event.Dragging() || !m_dragged){
|
||||
// change cursor while button hovered && drag
|
||||
SetCursor((which_button_is_clicked(pos) != -1) ? wxCursor(wxCURSOR_SIZENS) : wxNullCursor);
|
||||
return;
|
||||
}
|
||||
rect.Deflate(side/2.);
|
||||
if (!(rect.Contains(pos))) { // the mouse left chart area
|
||||
mouse_left_window(event);
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
wxWindow(parent,wxID_ANY,rect.GetTopLeft(),rect.GetSize()),
|
||||
scale_unit(scale_unit), legend_side(5*scale_unit)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
m_rect = wxRect(wxPoint(legend_side,0),rect.GetSize()-wxSize(legend_side,legend_side));
|
||||
visible_area = wxRect2DDouble(0.0, 0.0, sampling*ramming_speed_size, 20.);
|
||||
@@ -46,8 +47,8 @@ public:
|
||||
void mouse_right_button_clicked(wxMouseEvent& event);
|
||||
void mouse_moved(wxMouseEvent& event);
|
||||
void mouse_double_clicked(wxMouseEvent& event);
|
||||
void mouse_left_window(wxMouseEvent&) { m_dragged = nullptr; }
|
||||
void mouse_released(wxMouseEvent&) { m_dragged = nullptr; }
|
||||
void mouse_left_window(wxMouseEvent&) { m_dragged = nullptr; SetCursor(wxNullCursor);}
|
||||
void mouse_released(wxMouseEvent&) { m_dragged = nullptr; SetCursor(wxNullCursor);}
|
||||
void paint_event(wxPaintEvent&) { draw(); }
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
@@ -58,7 +59,7 @@ private:
|
||||
static const bool fixed_x = true;
|
||||
static const bool splines = true;
|
||||
static const bool manual_points_manipulation = false;
|
||||
static const int side = 10; // side of draggable button
|
||||
int side = 10; // side of draggable button
|
||||
|
||||
const int scale_unit;
|
||||
int legend_side;
|
||||
|
||||
@@ -38,10 +38,10 @@ SpinInput::SpinInput(wxWindow *parent,
|
||||
const wxPoint &pos,
|
||||
const wxSize & size,
|
||||
long style,
|
||||
int min, int max, int initial)
|
||||
int min, int max, int initial, const int& step)
|
||||
: SpinInput()
|
||||
{
|
||||
Create(parent, text, label, pos, size, style, min, max, initial);
|
||||
Create(parent, text, label, pos, size, style, min, max, initial, step);
|
||||
}
|
||||
|
||||
void SpinInput::Create(wxWindow *parent,
|
||||
@@ -50,7 +50,7 @@ void SpinInput::Create(wxWindow *parent,
|
||||
const wxPoint &pos,
|
||||
const wxSize & size,
|
||||
long style,
|
||||
int min, int max, int initial)
|
||||
int min, int max, int initial, int step)
|
||||
{
|
||||
StaticBox::Create(parent, wxID_ANY, pos, size);
|
||||
SetFont(Label::Body_12);
|
||||
@@ -76,6 +76,7 @@ void SpinInput::Create(wxWindow *parent,
|
||||
if (text.ToLong(&initialFromText)) initial = initialFromText;
|
||||
SetRange(min, max);
|
||||
SetValue(initial);
|
||||
SetStep(step);
|
||||
messureSize();
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ Button *SpinInput::createButton(bool inc)
|
||||
btn->DisableFocusFromKeyboard();
|
||||
btn->Bind(wxEVT_LEFT_DOWN, [=](auto &e) {
|
||||
delta = inc ? 1 : -1;
|
||||
SetValue(val + delta);
|
||||
SetValue(val + delta * step);
|
||||
text_ctrl->SetFocus();
|
||||
if (!btn->HasCapture())
|
||||
btn->CaptureMouse();
|
||||
@@ -241,7 +242,7 @@ Button *SpinInput::createButton(bool inc)
|
||||
delta = inc ? 1 : -1;
|
||||
if (!btn->HasCapture())
|
||||
btn->CaptureMouse();
|
||||
SetValue(val + delta);
|
||||
SetValue(val + delta * step);
|
||||
sendSpinEvent();
|
||||
});
|
||||
btn->Bind(wxEVT_LEFT_UP, [=](auto &e) {
|
||||
@@ -259,7 +260,7 @@ void SpinInput::onTimer(wxTimerEvent &evnet) {
|
||||
delta /= 2;
|
||||
return;
|
||||
}
|
||||
SetValue(val + delta);
|
||||
SetValue(val + delta * step);
|
||||
sendSpinEvent();
|
||||
}
|
||||
|
||||
@@ -293,7 +294,7 @@ void SpinInput::onTextEnter(wxCommandEvent &event)
|
||||
void SpinInput::mouseWheelMoved(wxMouseEvent &event)
|
||||
{
|
||||
auto delta = event.GetWheelRotation() < 0 ? 1 : -1;
|
||||
SetValue(val + delta);
|
||||
SetValue(val + delta * step);
|
||||
sendSpinEvent();
|
||||
text_ctrl->SetFocus();
|
||||
}
|
||||
@@ -305,10 +306,10 @@ void SpinInput::keyPressed(wxKeyEvent &event)
|
||||
case WXK_DOWN:
|
||||
long value;
|
||||
if (!text_ctrl->GetValue().ToLong(&value)) { value = val; }
|
||||
if (event.GetKeyCode() == WXK_DOWN && value > min) {
|
||||
--value;
|
||||
} else if (event.GetKeyCode() == WXK_UP && value + 1 < max) {
|
||||
++value;
|
||||
if (event.GetKeyCode() == WXK_DOWN && value - step >= min) {
|
||||
value = value - step;
|
||||
} else if (event.GetKeyCode() == WXK_UP && value + step <= max) {
|
||||
value = value + step;
|
||||
}
|
||||
if (value != val) {
|
||||
SetValue(value);
|
||||
|
||||
@@ -23,6 +23,7 @@ class SpinInput : public wxNavigationEnabled<StaticBox>
|
||||
int min;
|
||||
int max;
|
||||
int delta;
|
||||
int step;
|
||||
|
||||
static const int SpinInputWidth = 200;
|
||||
static const int SpinInputHeight = 50;
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0,
|
||||
int min = 0, int max = 100, int initial = 0);
|
||||
int min = 0, int max = 100, int initial = 0, const int& step = 1);
|
||||
|
||||
void Create(wxWindow * parent,
|
||||
wxString text,
|
||||
@@ -46,7 +47,8 @@ public:
|
||||
long style = 0,
|
||||
int min = 0,
|
||||
int max = 100,
|
||||
int initial = 0);
|
||||
int initial = 0,
|
||||
int step = 1);
|
||||
|
||||
void SetCornerRadius(double radius);
|
||||
|
||||
@@ -70,6 +72,10 @@ public:
|
||||
|
||||
int GetValue () const;
|
||||
|
||||
void SetStep(int value) { step = value; };
|
||||
|
||||
int GetStep() { return step; };
|
||||
|
||||
void SetRange(int min, int max);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "libslic3r/Color.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StaticLine.hpp"
|
||||
#include "Widgets/DialogButtons.hpp"
|
||||
#include "slic3r/Utils/ColorSpaceConvert.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
@@ -49,37 +50,27 @@ static void update_ui(wxWindow* window)
|
||||
RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
|
||||
: wxDialog(parent, wxID_ANY, _(L("Ramming customization")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/)
|
||||
{
|
||||
update_ui(this);
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_panel_ramming = new RammingPanel(this,parameters);
|
||||
|
||||
// Not found another way of getting the background colours of RammingDialog, RammingPanel and Chart correct than setting
|
||||
// them all explicitely. Reading the parent colour yielded colour that didn't really match it, no wxSYS_COLOUR_... matched
|
||||
// colour used for the dialog. Same issue (and "solution") here : https://forums.wxwidgets.org/viewtopic.php?f=1&t=39608
|
||||
// Whoever can fix this, feel free to do so.
|
||||
#ifndef _WIN32
|
||||
this-> SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
|
||||
m_panel_ramming->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
|
||||
#endif
|
||||
m_panel_ramming->Show(true);
|
||||
this->Show();
|
||||
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->Add(m_panel_ramming, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
|
||||
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxBOTTOM, 10);
|
||||
auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
|
||||
main_sizer->Add(dlg_btns, 0, wxEXPAND);
|
||||
SetSizer(main_sizer);
|
||||
main_sizer->SetSizeHints(this);
|
||||
|
||||
update_ui(static_cast<wxButton*>(this->FindWindowById(wxID_OK, this)));
|
||||
update_ui(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
|
||||
|
||||
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
|
||||
|
||||
this->Bind(wxEVT_BUTTON,[this](wxCommandEvent&) {
|
||||
m_output_data = m_panel_ramming->get_parameters();
|
||||
EndModal(wxID_OK);
|
||||
},wxID_OK);
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
this->Show();
|
||||
// wxMessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to "
|
||||
|
||||
Slic3r::GUI::MessageDialog dlg(this, _(L("Ramming denotes the rapid extrusion just before a tool change in a single-extruder MM printer. Its purpose is to "
|
||||
"properly shape the end of the unloaded filament so it does not prevent insertion of the new filament and can itself "
|
||||
"be reinserted later. This phase is important and different materials can require different extrusion speeds to get "
|
||||
@@ -100,6 +91,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
|
||||
RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxPoint(50,50), wxSize(800,350),wxBORDER_RAISED*/)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
update_ui(this);
|
||||
auto sizer_chart = new wxBoxSizer(wxVERTICAL);
|
||||
auto sizer_param = new wxBoxSizer(wxVERTICAL);
|
||||
@@ -120,48 +112,59 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
buttons.push_back(std::make_pair(x, y));
|
||||
|
||||
m_chart = new Chart(this, wxRect(scale(10),scale(10),scale(480),scale(360)), buttons, ramming_speed_size, 0.25f, scale(10));
|
||||
#ifdef _WIN32
|
||||
update_ui(m_chart);
|
||||
#else
|
||||
m_chart->SetBackgroundColour(parent->GetBackgroundColour()); // see comment in RammingDialog constructor
|
||||
#endif
|
||||
sizer_chart->Add(m_chart, 0, wxALL, 5);
|
||||
|
||||
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5);
|
||||
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0);
|
||||
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
|
||||
m_widget_time = new SpinInput(this, wxEmptyString, _L("ms") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 5000 , 3000, 500);
|
||||
m_widget_volume = new SpinInput(this, wxEmptyString, _L("mm³"), wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 0 , 10000, 0 );
|
||||
m_widget_ramming_line_width_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 );
|
||||
m_widget_ramming_step_multiplicator = new SpinInput(this, wxEmptyString, _L("%") , wxDefaultPosition, wxSize(scale(120), -1), wxSP_ARROW_KEYS, 10, 200 , 100 );
|
||||
|
||||
#ifdef _WIN32
|
||||
update_ui(m_widget_time->GetText());
|
||||
update_ui(m_widget_volume);
|
||||
update_ui(m_widget_ramming_line_width_multiplicator);
|
||||
update_ui(m_widget_ramming_step_multiplicator);
|
||||
#endif
|
||||
auto add_title = [this, sizer_param](wxString label){
|
||||
auto title = new StaticLine(this, 0, label);
|
||||
title->SetFont(Label::Head_14);
|
||||
title->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636")));
|
||||
sizer_param->Add(title, 0, wxEXPAND | wxBOTTOM, scale(8));
|
||||
};
|
||||
|
||||
auto gsizer_param = new wxFlexGridSizer(2, 5, 15);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total ramming time")) + " (" + _(L("s")) + "):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_time);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Total rammed volume")) + " (" + _(L("mm")) + wxString("³):", wxConvUTF8))), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_volume);
|
||||
gsizer_param->AddSpacer(20);
|
||||
gsizer_param->AddSpacer(20);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line width")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_ramming_line_width_multiplicator);
|
||||
gsizer_param->Add(new wxStaticText(this, wxID_ANY, wxString(_(L("Ramming line spacing")) + " (%):")), 0, wxALIGN_CENTER_VERTICAL);
|
||||
gsizer_param->Add(m_widget_ramming_step_multiplicator);
|
||||
SetFont(Label::Body_14);
|
||||
wxSize col_size;
|
||||
for(auto label : {"Time", "Volume", "Width", "Spacing"})
|
||||
col_size.IncTo(GetTextExtent(_L(label)));
|
||||
col_size = wxSize(col_size.x + scale(30) ,-1);
|
||||
|
||||
sizer_param->Add(gsizer_param, 0, wxTOP, scale(10));
|
||||
auto add_spin = [this, sizer_param, col_size](wxString label, SpinInput* spin){
|
||||
spin->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
e.Skip();
|
||||
});
|
||||
auto h_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto text = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, col_size);
|
||||
text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636")));
|
||||
h_sizer->Add(text, 0, wxALIGN_CENTER_VERTICAL);
|
||||
h_sizer->Add(spin);
|
||||
sizer_param->Add(h_sizer, 0, wxEXPAND | wxBOTTOM, scale(2));
|
||||
};
|
||||
|
||||
m_widget_time->SetValue(m_chart->get_time());
|
||||
m_widget_time->SetDigits(2);
|
||||
add_title(_L("Total ramming"));
|
||||
add_spin( _L("Time") , m_widget_time );
|
||||
add_spin( _L("Volume"), m_widget_volume);
|
||||
|
||||
sizer_param->AddSpacer(10);
|
||||
|
||||
add_title(_L("Ramming line"));
|
||||
add_spin( _L("Width") , m_widget_ramming_line_width_multiplicator);
|
||||
add_spin( _L("Spacing"), m_widget_ramming_step_multiplicator );
|
||||
|
||||
m_widget_time->SetValue(int(m_chart->get_time() * 1000));
|
||||
m_widget_volume->SetValue(m_chart->get_volume());
|
||||
m_widget_volume->Disable();
|
||||
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_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
|
||||
|
||||
m_widget_ramming_step_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) { line_parameters_changed(); });
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(sizer_chart, 0, wxALL, 5);
|
||||
@@ -170,10 +173,15 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
||||
sizer->SetSizeHints(this);
|
||||
SetSizer(sizer);
|
||||
|
||||
m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);});
|
||||
m_widget_time->Bind(wxEVT_SPINCTRL,[this](wxCommandEvent&) {
|
||||
m_chart->set_xy_range(m_widget_time->GetValue() * 0.001,-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() * 1000);
|
||||
});
|
||||
Refresh(true); // erase background
|
||||
}
|
||||
|
||||
@@ -340,7 +348,7 @@ void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
// Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode:
|
||||
WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
|
||||
const std::vector<int>&extra_flush_volume, float flush_multiplier)
|
||||
: DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||
: GUI::DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||
wxID_ANY,
|
||||
_(L("Flushing volumes for filament change")),
|
||||
wxDefaultPosition,
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include "Widgets/SpinInput.hpp"
|
||||
|
||||
#include "RammingChart.hpp"
|
||||
class Button;
|
||||
class Label;
|
||||
@@ -23,10 +25,10 @@ public:
|
||||
|
||||
private:
|
||||
Chart* m_chart = nullptr;
|
||||
wxSpinCtrl* m_widget_volume = nullptr;
|
||||
wxSpinCtrl* m_widget_ramming_line_width_multiplicator = nullptr;
|
||||
wxSpinCtrl* m_widget_ramming_step_multiplicator = nullptr;
|
||||
wxSpinCtrlDouble* m_widget_time = nullptr;
|
||||
SpinInput* m_widget_volume = nullptr;
|
||||
SpinInput* m_widget_ramming_line_width_multiplicator = nullptr;
|
||||
SpinInput* m_widget_ramming_step_multiplicator = nullptr;
|
||||
SpinInput* m_widget_time = nullptr;
|
||||
int m_ramming_step_multiplicator;
|
||||
int m_ramming_line_width_multiplicator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user