Reorganized object settings pane
+ Added new control - PrusaLockButton
This commit is contained in:
parent
41c093a258
commit
5557e59d43
@ -2236,7 +2236,7 @@ sub changed_object_settings {
|
|||||||
# recenter and re-align to Z = 0
|
# recenter and re-align to Z = 0
|
||||||
my $model_object = $self->{model}->objects->[$obj_idx];
|
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||||
$model_object->center_around_origin;
|
$model_object->center_around_origin;
|
||||||
$self->reset_thumbnail($obj_idx);
|
# $self->reset_thumbnail($obj_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
# update print
|
# update print
|
||||||
|
@ -1126,6 +1126,13 @@ void show_info_sizer(bool show)
|
|||||||
g_manifold_warning_icon->Show(show && g_show_manifold_warning_icon);
|
g_manifold_warning_icon->Show(show && g_show_manifold_warning_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show_object_name(bool show)
|
||||||
|
{
|
||||||
|
wxGridSizer* grid_sizer = get_optgroup(ogFrequentlyObjectSettings)->get_grid_sizer();
|
||||||
|
grid_sizer->Show(static_cast<size_t>(0), show);
|
||||||
|
grid_sizer->Show(static_cast<size_t>(1), show);
|
||||||
|
}
|
||||||
|
|
||||||
void update_mode()
|
void update_mode()
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker noUpdates(g_right_panel);
|
wxWindowUpdateLocker noUpdates(g_right_panel);
|
||||||
@ -1145,6 +1152,7 @@ void update_mode()
|
|||||||
g_object_list_sizer->Show(mode == ConfigMenuModeExpert);
|
g_object_list_sizer->Show(mode == ConfigMenuModeExpert);
|
||||||
show_info_sizer(mode == ConfigMenuModeExpert);
|
show_info_sizer(mode == ConfigMenuModeExpert);
|
||||||
show_buttons(mode == ConfigMenuModeExpert);
|
show_buttons(mode == ConfigMenuModeExpert);
|
||||||
|
show_object_name(mode == ConfigMenuModeSimple);
|
||||||
|
|
||||||
// TODO There is a not the best place of it!
|
// TODO There is a not the best place of it!
|
||||||
// *** Update showing of the collpane_settings
|
// *** Update showing of the collpane_settings
|
||||||
|
@ -43,8 +43,7 @@ bool g_prevent_list_events = false; // We use this flag to avoid circular even
|
|||||||
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
|
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
|
||||||
// calls this method again and again and again
|
// calls this method again and again and again
|
||||||
bool g_is_percent_scale = false; // It indicates if scale unit is percentage
|
bool g_is_percent_scale = false; // It indicates if scale unit is percentage
|
||||||
int g_rotation_x = 0; // Last value of the rotation around the X axis
|
bool g_is_uniform_scale = false; // It indicates if scale is uniform
|
||||||
int g_rotation_y = 0; // Last value of the rotation around the Y axis
|
|
||||||
ModelObjectPtrs* m_objects;
|
ModelObjectPtrs* m_objects;
|
||||||
std::shared_ptr<DynamicPrintConfig*> m_config;
|
std::shared_ptr<DynamicPrintConfig*> m_config;
|
||||||
std::shared_ptr<DynamicPrintConfig> m_default_config;
|
std::shared_ptr<DynamicPrintConfig> m_default_config;
|
||||||
@ -492,12 +491,21 @@ void add_objects_list(wxWindow* parent, wxBoxSizer* sizer)
|
|||||||
Line add_og_to_object_settings(const std::string& option_name, const std::string& sidetext, int def_value = 0)
|
Line add_og_to_object_settings(const std::string& option_name, const std::string& sidetext, int def_value = 0)
|
||||||
{
|
{
|
||||||
Line line = { _(option_name), "" };
|
Line line = { _(option_name), "" };
|
||||||
|
if (option_name == "Scale") {
|
||||||
|
line.near_label_widget = [](wxWindow* parent) {
|
||||||
|
auto btn = new PrusaLockButton(parent, wxID_ANY);
|
||||||
|
btn->Bind(wxEVT_BUTTON, [btn](wxCommandEvent &event){
|
||||||
|
event.Skip();
|
||||||
|
wxTheApp->CallAfter([btn]() { set_uniform_scaling(btn->IsLocked()); });
|
||||||
|
});
|
||||||
|
return btn;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
def.type = coInt;
|
def.type = coInt;
|
||||||
def.default_value = new ConfigOptionInt(def_value);
|
def.default_value = new ConfigOptionInt(def_value);
|
||||||
def.sidetext = sidetext;
|
def.width = 55;
|
||||||
def.width = 70;
|
|
||||||
|
|
||||||
if (option_name == "Rotation")
|
if (option_name == "Rotation")
|
||||||
def.min = -360;
|
def.min = -360;
|
||||||
@ -506,7 +514,8 @@ Line add_og_to_object_settings(const std::string& option_name, const std::string
|
|||||||
|
|
||||||
std::vector<std::string> axes{ "x", "y", "z" };
|
std::vector<std::string> axes{ "x", "y", "z" };
|
||||||
for (auto axis : axes) {
|
for (auto axis : axes) {
|
||||||
def.label = boost::algorithm::to_upper_copy(axis);
|
if (axis == "z" && option_name != "Scale")
|
||||||
|
def.sidetext = sidetext;
|
||||||
Option option = Option(def, lower_name + "_" + axis);
|
Option option = Option(def, lower_name + "_" + axis);
|
||||||
option.opt.full_width = true;
|
option.opt.full_width = true;
|
||||||
line.append_option(option);
|
line.append_option(option);
|
||||||
@ -514,15 +523,14 @@ Line add_og_to_object_settings(const std::string& option_name, const std::string
|
|||||||
|
|
||||||
if (option_name == "Scale")
|
if (option_name == "Scale")
|
||||||
{
|
{
|
||||||
def.label = L("Units");
|
def.width = 45;
|
||||||
def.type = coStrings;
|
def.type = coStrings;
|
||||||
def.gui_type = "select_open";
|
def.gui_type = "select_open";
|
||||||
def.enum_labels.push_back(L("%"));
|
def.enum_labels.push_back(L("%"));
|
||||||
def.enum_labels.push_back(L("mm"));
|
def.enum_labels.push_back(L("mm"));
|
||||||
def.default_value = new ConfigOptionStrings{ "%" };
|
def.default_value = new ConfigOptionStrings{ "mm" };
|
||||||
def.sidetext = " ";
|
|
||||||
|
|
||||||
Option option = Option(def, lower_name + "_unit");
|
const Option option = Option(def, lower_name + "_unit");
|
||||||
line.append_option(option);
|
line.append_option(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,15 +557,9 @@ void add_object_settings(wxWindow* parent, wxBoxSizer* sizer)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// def.label = L("Name");
|
|
||||||
// def.type = coString;
|
|
||||||
// def.tooltip = L("Object name");
|
|
||||||
// def.full_width = true;
|
|
||||||
// def.default_value = new ConfigOptionString{ "BlaBla_object.stl" };
|
|
||||||
// optgroup->append_single_option_line(Option(def, "object_name"));
|
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
|
|
||||||
|
// Objects(sub-objects) name
|
||||||
def.label = L("Name");
|
def.label = L("Name");
|
||||||
// def.type = coString;
|
// def.type = coString;
|
||||||
def.gui_type = "legend";
|
def.gui_type = "legend";
|
||||||
@ -566,14 +568,28 @@ void add_object_settings(wxWindow* parent, wxBoxSizer* sizer)
|
|||||||
def.default_value = new ConfigOptionString{ " " };
|
def.default_value = new ConfigOptionString{ " " };
|
||||||
optgroup->append_single_option_line(Option(def, "object_name"));
|
optgroup->append_single_option_line(Option(def, "object_name"));
|
||||||
|
|
||||||
optgroup->set_flag(ogSIDE_OPTIONS_VERTICAL);
|
|
||||||
optgroup->sidetext_width = 25;
|
|
||||||
|
|
||||||
|
// Legend for object modification
|
||||||
|
auto line = Line{ "", "" };
|
||||||
|
def.label = "";
|
||||||
|
def.type = coString;
|
||||||
|
def.width = 55;
|
||||||
|
|
||||||
|
std::vector<std::string> axes{ "x", "y", "z" };
|
||||||
|
for (const auto axis : axes) {
|
||||||
|
const auto label = boost::algorithm::to_upper_copy(axis);
|
||||||
|
def.default_value = new ConfigOptionString{ " "+label };
|
||||||
|
Option option = Option(def, axis + "_axis_legend");
|
||||||
|
line.append_option(option);
|
||||||
|
}
|
||||||
|
optgroup->append_line(line);
|
||||||
|
|
||||||
|
|
||||||
|
// Settings table
|
||||||
optgroup->append_line(add_og_to_object_settings(L("Position"), L("mm")));
|
optgroup->append_line(add_og_to_object_settings(L("Position"), L("mm")));
|
||||||
optgroup->append_line(add_og_to_object_settings(L("Rotation"), "°"));
|
optgroup->append_line(add_og_to_object_settings(L("Rotation"), "°"));
|
||||||
optgroup->append_line(add_og_to_object_settings(L("Scale"), "%"));
|
optgroup->append_line(add_og_to_object_settings(L("Scale"), "mm"));
|
||||||
|
|
||||||
optgroup->set_flag(ogDEFAULT);
|
|
||||||
|
|
||||||
def.label = L("Place on bed");
|
def.label = L("Place on bed");
|
||||||
def.type = coBool;
|
def.type = coBool;
|
||||||
@ -591,8 +607,6 @@ void add_object_settings(wxWindow* parent, wxBoxSizer* sizer)
|
|||||||
optgroup->disable();
|
optgroup->disable();
|
||||||
|
|
||||||
get_optgroups().push_back(optgroup); // ogFrequentlyObjectSettings
|
get_optgroups().push_back(optgroup); // ogFrequentlyObjectSettings
|
||||||
|
|
||||||
// add_current_settings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1557,6 +1571,11 @@ void update_rotation_value(const double angle, const std::string& axis)
|
|||||||
og->set_value("rotation_"+axis, deg);
|
og->set_value("rotation_"+axis, deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_uniform_scaling(const bool uniform_scale)
|
||||||
|
{
|
||||||
|
g_is_uniform_scale = uniform_scale;
|
||||||
|
}
|
||||||
|
|
||||||
void on_begin_drag(wxDataViewEvent &event)
|
void on_begin_drag(wxDataViewEvent &event)
|
||||||
{
|
{
|
||||||
wxDataViewItem item(event.GetItem());
|
wxDataViewItem item(event.GetItem());
|
||||||
|
@ -113,6 +113,7 @@ void update_scale_values(const Vec3d& size, float scale);
|
|||||||
void update_rotation_values();
|
void update_rotation_values();
|
||||||
// update rotation value after "gizmos"
|
// update rotation value after "gizmos"
|
||||||
void update_rotation_value(const double angle, const std::string& axis);
|
void update_rotation_value(const double angle, const std::string& axis);
|
||||||
|
void set_uniform_scaling(const bool uniform_scale);
|
||||||
|
|
||||||
void on_begin_drag(wxDataViewEvent &event);
|
void on_begin_drag(wxDataViewEvent &event);
|
||||||
void on_drop_possible(wxDataViewEvent &event);
|
void on_drop_possible(wxDataViewEvent &event);
|
||||||
|
@ -181,8 +181,18 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
|||||||
wxDefaultPosition, wxSize(label_width, -1), label_style);
|
wxDefaultPosition, wxSize(label_width, -1), label_style);
|
||||||
label->SetFont(label_font);
|
label->SetFont(label_font);
|
||||||
label->Wrap(label_width); // avoid a Linux/GTK bug
|
label->Wrap(label_width); // avoid a Linux/GTK bug
|
||||||
|
if (!line.near_label_widget)
|
||||||
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) |
|
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) |
|
||||||
(m_flag == ogSIDE_OPTIONS_VERTICAL ? wxTOP : wxALIGN_CENTER_VERTICAL), 5);
|
(m_flag == ogSIDE_OPTIONS_VERTICAL ? wxTOP : wxALIGN_CENTER_VERTICAL), 5);
|
||||||
|
else {
|
||||||
|
// If we're here, we have some widget near the label
|
||||||
|
// so we need a horizontal sizer to arrange these things
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
|
||||||
|
sizer->Add(line.near_label_widget(parent()), 0, wxRIGHT, 2);
|
||||||
|
sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) |
|
||||||
|
(m_flag == ogSIDE_OPTIONS_VERTICAL ? wxTOP : wxALIGN_CENTER_VERTICAL), 5);
|
||||||
|
}
|
||||||
if (line.label_tooltip.compare("") != 0)
|
if (line.label_tooltip.compare("") != 0)
|
||||||
label->SetToolTip(line.label_tooltip);
|
label->SetToolTip(line.label_tooltip);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ public:
|
|||||||
size_t full_width {0};
|
size_t full_width {0};
|
||||||
wxSizer* sizer {nullptr};
|
wxSizer* sizer {nullptr};
|
||||||
widget_t widget {nullptr};
|
widget_t widget {nullptr};
|
||||||
|
std::function<wxWindow*(wxWindow*)> near_label_widget{ nullptr };
|
||||||
|
|
||||||
void append_option(const Option& option) {
|
void append_option(const Option& option) {
|
||||||
m_options.push_back(option);
|
m_options.push_back(option);
|
||||||
@ -178,6 +179,8 @@ public:
|
|||||||
#endif /* __WXGTK__ */
|
#endif /* __WXGTK__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxGridSizer* get_grid_sizer(){ return m_grid_sizer; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<t_config_option_key, Option> m_options;
|
std::map<t_config_option_key, Option> m_options;
|
||||||
wxWindow* m_parent {nullptr};
|
wxWindow* m_parent {nullptr};
|
||||||
|
@ -1402,4 +1402,52 @@ void PrusaDoubleSlider::OnRightUp(wxMouseEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// PrusaLockButton
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
PrusaLockButton::PrusaLockButton( wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos /*= wxDefaultPosition*/,
|
||||||
|
const wxSize& size /*= wxDefaultSize*/):
|
||||||
|
wxButton(parent, id, wxEmptyString, pos, size, wxBU_EXACTFIT | wxNO_BORDER)
|
||||||
|
{
|
||||||
|
m_bmp_lock_on = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("one_layer_lock_on.png")), wxBITMAP_TYPE_PNG);
|
||||||
|
m_bmp_lock_off = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("one_layer_lock_off.png")), wxBITMAP_TYPE_PNG);
|
||||||
|
m_bmp_unlock_on = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("one_layer_unlock_on.png")), wxBITMAP_TYPE_PNG);
|
||||||
|
m_bmp_unlock_off = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("one_layer_unlock_off.png")), wxBITMAP_TYPE_PNG);
|
||||||
|
m_lock_icon_dim = m_bmp_lock_on.GetSize().x;
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
|
#endif // __WXMSW__
|
||||||
|
SetBitmap(m_bmp_unlock_on);
|
||||||
|
|
||||||
|
//button events
|
||||||
|
Bind(wxEVT_BUTTON, &PrusaLockButton::OnButton, this);
|
||||||
|
Bind(wxEVT_ENTER_WINDOW, &PrusaLockButton::OnEnterBtn, this);
|
||||||
|
Bind(wxEVT_LEAVE_WINDOW, &PrusaLockButton::OnLeaveBtn, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrusaLockButton::OnButton(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
m_is_pushed = !m_is_pushed;
|
||||||
|
enter_button(true);
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrusaLockButton::enter_button(const bool enter)
|
||||||
|
{
|
||||||
|
wxBitmap* icon = m_is_pushed ?
|
||||||
|
enter ? &m_bmp_lock_off : &m_bmp_lock_on :
|
||||||
|
enter ? &m_bmp_unlock_off : &m_bmp_unlock_on;
|
||||||
|
SetBitmap(*icon);
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
|
@ -521,6 +521,7 @@ public:
|
|||||||
long style = wxSL_HORIZONTAL,
|
long style = wxSL_HORIZONTAL,
|
||||||
const wxValidator& val = wxDefaultValidator,
|
const wxValidator& val = wxDefaultValidator,
|
||||||
const wxString& name = wxEmptyString);
|
const wxString& name = wxEmptyString);
|
||||||
|
~PrusaDoubleSlider(){}
|
||||||
|
|
||||||
int GetLowerValue() const {
|
int GetLowerValue() const {
|
||||||
return m_lower_value;
|
return m_lower_value;
|
||||||
@ -614,7 +615,7 @@ private:
|
|||||||
wxRect m_rect_one_layer_icon;
|
wxRect m_rect_one_layer_icon;
|
||||||
wxSize m_thumb_size;
|
wxSize m_thumb_size;
|
||||||
int m_tick_icon_dim;
|
int m_tick_icon_dim;
|
||||||
int m_lock_icon_dim = 16;
|
int m_lock_icon_dim;
|
||||||
long m_style;
|
long m_style;
|
||||||
float m_label_koef = 1.0;
|
float m_label_koef = 1.0;
|
||||||
|
|
||||||
@ -634,6 +635,41 @@ private:
|
|||||||
std::set<int> m_ticks;
|
std::set<int> m_ticks;
|
||||||
std::vector<double> m_values;
|
std::vector<double> m_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// PrusaLockButton
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class PrusaLockButton : public wxButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrusaLockButton(
|
||||||
|
wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize);
|
||||||
|
~PrusaLockButton(){}
|
||||||
|
|
||||||
|
void OnButton(wxCommandEvent& event);
|
||||||
|
void OnEnterBtn(wxMouseEvent& event){ enter_button(true); event.Skip(); }
|
||||||
|
void OnLeaveBtn(wxMouseEvent& event){ enter_button(false); event.Skip(); }
|
||||||
|
|
||||||
|
bool IsLocked() const { return m_is_pushed; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void enter_button(const bool enter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_is_pushed = false;
|
||||||
|
|
||||||
|
wxBitmap m_bmp_lock_on;
|
||||||
|
wxBitmap m_bmp_lock_off;
|
||||||
|
wxBitmap m_bmp_unlock_on;
|
||||||
|
wxBitmap m_bmp_unlock_off;
|
||||||
|
|
||||||
|
int m_lock_icon_dim;
|
||||||
|
};
|
||||||
// ******************************************************************************************
|
// ******************************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user