Merge branch 'master' of https://github.com/Prusa3d/PrusaSlicer
This commit is contained in:
commit
07250bd781
@ -210,6 +210,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
wxSize btn_size(em_unit(parent) * mirror_btn_width, em_unit(parent) * mirror_btn_width);
|
wxSize btn_size(em_unit(parent) * mirror_btn_width, em_unit(parent) * mirror_btn_width);
|
||||||
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_off", wxEmptyString, btn_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_off", wxEmptyString, btn_size, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
||||||
btn->SetToolTip(wxString::Format(_(L("Toggle %c axis mirroring")), (int)label));
|
btn->SetToolTip(wxString::Format(_(L("Toggle %c axis mirroring")), (int)label));
|
||||||
|
btn->SetBitmapDisabled_(m_mirror_bitmap_hidden);
|
||||||
|
|
||||||
m_mirror_buttons[axis_idx].first = btn;
|
m_mirror_buttons[axis_idx].first = btn;
|
||||||
m_mirror_buttons[axis_idx].second = mbShown;
|
m_mirror_buttons[axis_idx].second = mbShown;
|
||||||
@ -286,11 +287,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(btn, wxBU_EXACTFIT);
|
sizer->Add(btn, wxBU_EXACTFIT);
|
||||||
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
||||||
wxGetApp().plater()->take_snapshot(_(L("Reset scale")));
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Reset scale")));
|
||||||
// the empty strings prevent taking another three snapshots
|
change_scale_value(0, 100.);
|
||||||
change_scale_value(0, 100., std::string());
|
change_scale_value(1, 100.);
|
||||||
change_scale_value(1, 100., std::string());
|
change_scale_value(2, 100.);
|
||||||
change_scale_value(2, 100., std::string());
|
|
||||||
});
|
});
|
||||||
return sizer;
|
return sizer;
|
||||||
};
|
};
|
||||||
@ -352,11 +352,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
const Geometry::Transformation& instance_trafo = volume->get_instance_transformation();
|
const Geometry::Transformation& instance_trafo = volume->get_instance_transformation();
|
||||||
Vec3d diff = m_cache.position - instance_trafo.get_matrix(true).inverse() * Vec3d(0., 0., get_volume_min_z(volume));
|
Vec3d diff = m_cache.position - instance_trafo.get_matrix(true).inverse() * Vec3d(0., 0., get_volume_min_z(volume));
|
||||||
|
|
||||||
// Take an undo/redo snapshot and prevent change_position_value from doing it three times.
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Drop to bed")));
|
||||||
wxGetApp().plater()->take_snapshot(_(L("Drop to bed")));
|
change_position_value(0, diff.x());
|
||||||
change_position_value(0, diff.x(), std::string());
|
change_position_value(1, diff.y());
|
||||||
change_position_value(1, diff.y(), std::string());
|
change_position_value(2, diff.z());
|
||||||
change_position_value(2, diff.z(), std::string());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return sizer;
|
return sizer;
|
||||||
@ -650,13 +649,13 @@ void ObjectManipulation::update_mirror_buttons_visibility()
|
|||||||
wxGetApp().CallAfter([this, new_states]{
|
wxGetApp().CallAfter([this, new_states]{
|
||||||
for (int i=0; i<3; ++i) {
|
for (int i=0; i<3; ++i) {
|
||||||
if (new_states[i] != m_mirror_buttons[i].second) {
|
if (new_states[i] != m_mirror_buttons[i].second) {
|
||||||
const wxBitmap* bmp;
|
const ScalableBitmap* bmp;
|
||||||
switch (new_states[i]) {
|
switch (new_states[i]) {
|
||||||
case mbHidden : bmp = &m_mirror_bitmap_hidden.bmp(); m_mirror_buttons[i].first->Enable(false); break;
|
case mbHidden : bmp = &m_mirror_bitmap_hidden; m_mirror_buttons[i].first->Enable(false); break;
|
||||||
case mbShown : bmp = &m_mirror_bitmap_off.bmp(); m_mirror_buttons[i].first->Enable(true); break;
|
case mbShown : bmp = &m_mirror_bitmap_off; m_mirror_buttons[i].first->Enable(true); break;
|
||||||
case mbActive : bmp = &m_mirror_bitmap_on.bmp(); m_mirror_buttons[i].first->Enable(true); break;
|
case mbActive : bmp = &m_mirror_bitmap_on; m_mirror_buttons[i].first->Enable(true); break;
|
||||||
}
|
}
|
||||||
m_mirror_buttons[i].first->SetBitmap(*bmp);
|
m_mirror_buttons[i].first->SetBitmap_(*bmp);
|
||||||
m_mirror_buttons[i].second = new_states[i];
|
m_mirror_buttons[i].second = new_states[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,7 +700,7 @@ void ObjectManipulation::reset_settings_value()
|
|||||||
// m_dirty = true;
|
// m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_position_value(int axis, double value, const std::string& snapshot_name)
|
void ObjectManipulation::change_position_value(int axis, double value)
|
||||||
{
|
{
|
||||||
if (std::abs(m_cache.position_rounded(axis) - value) < EPSILON)
|
if (std::abs(m_cache.position_rounded(axis) - value) < EPSILON)
|
||||||
return;
|
return;
|
||||||
@ -713,14 +712,14 @@ void ObjectManipulation::change_position_value(int axis, double value, const std
|
|||||||
Selection& selection = canvas->get_selection();
|
Selection& selection = canvas->get_selection();
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
||||||
canvas->do_move(snapshot_name);
|
canvas->do_move(L("Set Position"));
|
||||||
|
|
||||||
m_cache.position = position;
|
m_cache.position = position;
|
||||||
m_cache.position_rounded(axis) = DBL_MAX;
|
m_cache.position_rounded(axis) = DBL_MAX;
|
||||||
this->UpdateAndShow(true);
|
this->UpdateAndShow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_rotation_value(int axis, double value, const std::string& snapshot_name)
|
void ObjectManipulation::change_rotation_value(int axis, double value)
|
||||||
{
|
{
|
||||||
if (std::abs(m_cache.rotation_rounded(axis) - value) < EPSILON)
|
if (std::abs(m_cache.rotation_rounded(axis) - value) < EPSILON)
|
||||||
return;
|
return;
|
||||||
@ -744,14 +743,14 @@ void ObjectManipulation::change_rotation_value(int axis, double value, const std
|
|||||||
selection.rotate(
|
selection.rotate(
|
||||||
(M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation),
|
(M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation),
|
||||||
transformation_type);
|
transformation_type);
|
||||||
canvas->do_rotate(snapshot_name);
|
canvas->do_rotate(L("Set Orientation"));
|
||||||
|
|
||||||
m_cache.rotation = rotation;
|
m_cache.rotation = rotation;
|
||||||
m_cache.rotation_rounded(axis) = DBL_MAX;
|
m_cache.rotation_rounded(axis) = DBL_MAX;
|
||||||
this->UpdateAndShow(true);
|
this->UpdateAndShow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::change_scale_value(int axis, double value, const std::string& snapshot_name)
|
void ObjectManipulation::change_scale_value(int axis, double value)
|
||||||
{
|
{
|
||||||
if (std::abs(m_cache.scale_rounded(axis) - value) < EPSILON)
|
if (std::abs(m_cache.scale_rounded(axis) - value) < EPSILON)
|
||||||
return;
|
return;
|
||||||
@ -759,7 +758,7 @@ void ObjectManipulation::change_scale_value(int axis, double value, const std::s
|
|||||||
Vec3d scale = m_cache.scale;
|
Vec3d scale = m_cache.scale;
|
||||||
scale(axis) = value;
|
scale(axis) = value;
|
||||||
|
|
||||||
this->do_scale(axis, scale, snapshot_name);
|
this->do_scale(axis, scale);
|
||||||
|
|
||||||
m_cache.scale = scale;
|
m_cache.scale = scale;
|
||||||
m_cache.scale_rounded(axis) = DBL_MAX;
|
m_cache.scale_rounded(axis) = DBL_MAX;
|
||||||
@ -767,7 +766,7 @@ void ObjectManipulation::change_scale_value(int axis, double value, const std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectManipulation::change_size_value(int axis, double value, const std::string& snapshot_name)
|
void ObjectManipulation::change_size_value(int axis, double value)
|
||||||
{
|
{
|
||||||
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
|
if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
|
||||||
return;
|
return;
|
||||||
@ -785,14 +784,14 @@ void ObjectManipulation::change_size_value(int axis, double value, const std::st
|
|||||||
selection.get_unscaled_instance_bounding_box().size() :
|
selection.get_unscaled_instance_bounding_box().size() :
|
||||||
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
|
wxGetApp().model().objects[selection.get_volume(*selection.get_volume_idxs().begin())->object_idx()]->raw_mesh_bounding_box().size();
|
||||||
|
|
||||||
this->do_scale(axis, 100. * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)), snapshot_name);
|
this->do_scale(axis, 100. * Vec3d(size(0) / ref_size(0), size(1) / ref_size(1), size(2) / ref_size(2)));
|
||||||
|
|
||||||
m_cache.size = size;
|
m_cache.size = size;
|
||||||
m_cache.size_rounded(axis) = DBL_MAX;
|
m_cache.size_rounded(axis) = DBL_MAX;
|
||||||
this->UpdateAndShow(true);
|
this->UpdateAndShow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::do_scale(int axis, const Vec3d &scale, const std::string& snapshot_name) const
|
void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
|
||||||
{
|
{
|
||||||
Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
Selection& selection = wxGetApp().plater()->canvas3D()->get_selection();
|
||||||
Vec3d scaling_factor = scale;
|
Vec3d scaling_factor = scale;
|
||||||
@ -809,7 +808,7 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale, const std::strin
|
|||||||
|
|
||||||
selection.start_dragging();
|
selection.start_dragging();
|
||||||
selection.scale(scaling_factor * 0.01, transformation_type);
|
selection.scale(scaling_factor * 0.01, transformation_type);
|
||||||
wxGetApp().plater()->canvas3D()->do_scale(snapshot_name);
|
wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::on_change(t_config_option_key opt_key, const boost::any& value)
|
void ObjectManipulation::on_change(t_config_option_key opt_key, const boost::any& value)
|
||||||
@ -837,13 +836,13 @@ void ObjectManipulation::on_change(t_config_option_key opt_key, const boost::any
|
|||||||
double new_value = boost::any_cast<double>(m_og->get_value(opt_key));
|
double new_value = boost::any_cast<double>(m_og->get_value(opt_key));
|
||||||
|
|
||||||
if (boost::starts_with(opt_key, "position_"))
|
if (boost::starts_with(opt_key, "position_"))
|
||||||
change_position_value(axis, new_value, L("Set Position"));
|
change_position_value(axis, new_value);
|
||||||
else if (boost::starts_with(opt_key, "rotation_"))
|
else if (boost::starts_with(opt_key, "rotation_"))
|
||||||
change_rotation_value(axis, new_value, L("Set Orientation"));
|
change_rotation_value(axis, new_value);
|
||||||
else if (boost::starts_with(opt_key, "scale_"))
|
else if (boost::starts_with(opt_key, "scale_"))
|
||||||
change_scale_value(axis, new_value, L("Set Scale"));
|
change_scale_value(axis, new_value);
|
||||||
else if (boost::starts_with(opt_key, "size_"))
|
else if (boost::starts_with(opt_key, "size_"))
|
||||||
change_size_value(axis, new_value, L("Set Scale"));
|
change_size_value(axis, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectManipulation::on_fill_empty_value(const std::string& opt_key)
|
void ObjectManipulation::on_fill_empty_value(const std::string& opt_key)
|
||||||
@ -929,6 +928,9 @@ void ObjectManipulation::msw_rescale()
|
|||||||
m_reset_rotation_button->msw_rescale();
|
m_reset_rotation_button->msw_rescale();
|
||||||
m_drop_to_bed_button->msw_rescale();
|
m_drop_to_bed_button->msw_rescale();
|
||||||
|
|
||||||
|
for (int id = 0; id < 3; ++id)
|
||||||
|
m_mirror_buttons[id].first->msw_rescale();
|
||||||
|
|
||||||
get_og()->msw_rescale();
|
get_og()->msw_rescale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,11 +135,11 @@ private:
|
|||||||
void update_mirror_buttons_visibility();
|
void update_mirror_buttons_visibility();
|
||||||
|
|
||||||
// change values
|
// change values
|
||||||
void change_position_value(int axis, double value, const std::string& snapshot_name);
|
void change_position_value(int axis, double value);
|
||||||
void change_rotation_value(int axis, double value, const std::string& snapshot_name);
|
void change_rotation_value(int axis, double value);
|
||||||
void change_scale_value(int axis, double value, const std::string& snapshot_name);
|
void change_scale_value(int axis, double value);
|
||||||
void change_size_value(int axis, double value, const std::string& snapshot_name);
|
void change_size_value(int axis, double value);
|
||||||
void do_scale(int axis, const Vec3d &scale, const std::string& snapshot_name) const;
|
void do_scale(int axis, const Vec3d &scale) const;
|
||||||
|
|
||||||
void on_change(t_config_option_key opt_key, const boost::any& value);
|
void on_change(t_config_option_key opt_key, const boost::any& value);
|
||||||
void on_fill_empty_value(const std::string& opt_key);
|
void on_fill_empty_value(const std::string& opt_key);
|
||||||
|
@ -2966,6 +2966,13 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
|||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
|
|
||||||
SetBitmap(create_scaled_bitmap(parent, icon_name));
|
SetBitmap(create_scaled_bitmap(parent, icon_name));
|
||||||
|
|
||||||
|
if (size != wxDefaultSize)
|
||||||
|
{
|
||||||
|
const int em = em_unit(parent);
|
||||||
|
m_width = size.x/em;
|
||||||
|
m_height= size.y/em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2992,11 +2999,24 @@ void ScalableButton::SetBitmap_(const ScalableBitmap& bmp)
|
|||||||
m_current_icon_name = bmp.name();
|
m_current_icon_name = bmp.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScalableButton::SetBitmapDisabled_(const ScalableBitmap& bmp)
|
||||||
|
{
|
||||||
|
SetBitmapDisabled(bmp.bmp());
|
||||||
|
m_disabled_icon_name = bmp.name();
|
||||||
|
}
|
||||||
|
|
||||||
void ScalableButton::msw_rescale()
|
void ScalableButton::msw_rescale()
|
||||||
{
|
{
|
||||||
const wxBitmap bmp = create_scaled_bitmap(m_parent, m_current_icon_name);
|
SetBitmap(create_scaled_bitmap(m_parent, m_current_icon_name));
|
||||||
|
if (!m_disabled_icon_name.empty())
|
||||||
|
SetBitmapDisabled(create_scaled_bitmap(m_parent, m_disabled_icon_name));
|
||||||
|
|
||||||
SetBitmap(bmp);
|
if (m_width > 0 || m_height>0)
|
||||||
|
{
|
||||||
|
const int em = em_unit(m_parent);
|
||||||
|
wxSize size(m_width * em, m_height * em);
|
||||||
|
SetMinSize(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -904,12 +904,16 @@ public:
|
|||||||
~ScalableButton() {}
|
~ScalableButton() {}
|
||||||
|
|
||||||
void SetBitmap_(const ScalableBitmap& bmp);
|
void SetBitmap_(const ScalableBitmap& bmp);
|
||||||
|
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
||||||
|
|
||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow* m_parent;
|
wxWindow* m_parent;
|
||||||
std::string m_current_icon_name = "";
|
std::string m_current_icon_name = "";
|
||||||
|
std::string m_disabled_icon_name = "";
|
||||||
|
int m_width {-1}; // should be multiplied to em_unit
|
||||||
|
int m_height{-1}; // should be multiplied to em_unit
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user