Cut WIP: Upgrade for reset_buttons in inpot_window

This commit is contained in:
YuSanka 2022-09-21 16:29:06 +02:00
parent e676d40df5
commit 0fcb7243b7
2 changed files with 8 additions and 16 deletions

View File

@ -526,29 +526,27 @@ void GLGizmoCut3D::render_connect_mode_radio_button(CutConnectorMode mode)
m_connector_mode = mode; m_connector_mode = mode;
} }
bool GLGizmoCut3D::render_revert_button(const std::string& label_id) bool GLGizmoCut3D::render_reset_button(const std::string& label_id, const std::string& tooltip) const
{ {
const ImGuiStyle& style = ImGui::GetStyle(); const ImGuiStyle& style = ImGui::GetStyle();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y }); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, { 1, style.ItemSpacing.y });
ImGui::SameLine(m_label_width);
ImGui::PushStyleColor(ImGuiCol_Button, { 0.25f, 0.25f, 0.25f, 0.0f }); ImGui::PushStyleColor(ImGuiCol_Button, { 0.25f, 0.25f, 0.25f, 0.0f });
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.4f, 0.4f, 0.4f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.4f, 0.4f, 0.4f, 1.0f });
ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.4f, 0.4f, 0.4f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.4f, 0.4f, 0.4f, 1.0f });
std::string label; std::string btn_label;
label += ImGui::RevertButton; btn_label += ImGui::RevertButton;
bool revert = ImGui::Button((label + "##" + label_id).c_str()); const bool revert = ImGui::Button((btn_label +"##" + label_id).c_str());
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
m_imgui->tooltip(into_u8(_L("Revert")).c_str(), ImGui::GetFontSize() * 20.0f); m_imgui->tooltip(tooltip.c_str(), ImGui::GetFontSize() * 20.0f);
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::SameLine();
return revert; return revert;
} }
@ -1396,7 +1394,7 @@ void GLGizmoCut3D::render_connectors_input_window(CutConnectors &connectors)
m_imgui->disabled_begin(connectors.empty()); m_imgui->disabled_begin(connectors.empty());
ImGui::SameLine(m_label_width); ImGui::SameLine(m_label_width);
if (m_imgui->button(wxString(ImGui::RevertButton) + _L("Reset") + " ##connectors")) if (render_reset_button("connectors", _u8L("Remove connectors")))
reset_connectors(); reset_connectors();
m_imgui->disabled_end(); m_imgui->disabled_end();
@ -1486,7 +1484,7 @@ void GLGizmoCut3D::render_cut_plane_input_window(CutConnectors &connectors)
ImGui::SameLine(m_label_width); ImGui::SameLine(m_label_width);
render_move_center_input(Z); render_move_center_input(Z);
ImGui::SameLine(); ImGui::SameLine();
if (m_imgui->button(wxString(ImGui::RevertButton) + _L("Reset cutting plane"))) if (render_reset_button("cut_plane", _u8L("Reset cutting plane")))
reset_cut_plane(); reset_cut_plane();
if (wxGetApp().plater()->printer_technology() == ptFFF) { if (wxGetApp().plater()->printer_technology() == ptFFF) {
@ -1738,12 +1736,6 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
Vec3d rotation = Transformation(m_rotation_m).get_rotation(); Vec3d rotation = Transformation(m_rotation_m).get_rotation();
// FIXME experiments with transformations
const Vec3d recover_rot = Transformation(rotation_transform(rotation)).get_rotation();
if (recover_rot != rotation)
printf("\n ERROR! wrong recovered rotation");
///////////////
const bool has_connectors = !mo->cut_connectors.empty(); const bool has_connectors = !mo->cut_connectors.empty();
{ {
Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane")); Plater::TakeSnapshot snapshot(plater, _L("Cut by Plane"));

View File

@ -210,7 +210,7 @@ private:
bool render_slider_double_input(const std::string& label, double& value_in, int& tolerance_in); bool render_slider_double_input(const std::string& label, double& value_in, int& tolerance_in);
void render_move_center_input(int axis); void render_move_center_input(int axis);
void render_connect_mode_radio_button(CutConnectorMode mode); void render_connect_mode_radio_button(CutConnectorMode mode);
bool render_revert_button(const std::string& label); bool render_reset_button(const std::string& label_id, const std::string& tooltip) const;
bool render_connect_type_radio_button(CutConnectorType type); bool render_connect_type_radio_button(CutConnectorType type);
Transform3d get_volume_transformation(const ModelVolume* volume) const; Transform3d get_volume_transformation(const ModelVolume* volume) const;
void render_connectors(); void render_connectors();