CutGizmo: Some beautification/reorganization
This commit is contained in:
parent
b41c2045e4
commit
4da322d527
@ -3,11 +3,10 @@
|
|||||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||||
<g id="expand">
|
<g id="expand">
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="8" x2="8" y2="4"/></g>
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="4" x2="8" y2="8"/></g>
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="4" x2="12" y2="8"/></g>
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="8" x2="12" y2="4"/></g>
|
||||||
|
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="12" x2="8" y2="8"/></g>
|
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="8" x2="12" y2="12"/></g>
|
|
||||||
|
|
||||||
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="8" x2="8" y2="12"/></g>
|
||||||
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="12" x2="12" y2="8"/></g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 919 B After Width: | Height: | Size: 915 B |
@ -3,10 +3,11 @@
|
|||||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||||
<g id="expand">
|
<g id="expand">
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="4" x2="8" y2="8"/></g>
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="8" x2="8" y2="4"/></g>
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="8" x2="12" y2="4"/></g>
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="4" x2="12" y2="8"/></g>
|
||||||
|
|
||||||
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="12" x2="8" y2="8"/></g>
|
||||||
|
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="8" x2="12" y2="12"/></g>
|
||||||
|
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="8" x2="8" y2="12"/></g>
|
|
||||||
<g><line fill="none" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="12" x2="12" y2="8"/></g>
|
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 915 B After Width: | Height: | Size: 919 B |
@ -1154,7 +1154,7 @@ indexed_triangle_set its_make_frustum_dowel(double radius, double h, int sectorC
|
|||||||
else
|
else
|
||||||
for (int j = 0; j < sectorCount; ++j) {
|
for (int j = 0; j < sectorCount; ++j) {
|
||||||
// from 0 to 2pi
|
// from 0 to 2pi
|
||||||
double sectorAngle = sectorStep * j;
|
double sectorAngle = sectorStep * j + 0.25 * M_PI;
|
||||||
vertices.emplace_back(Vec3d(xy * std::cos(sectorAngle), xy * std::sin(sectorAngle), z).cast<float>());
|
vertices.emplace_back(Vec3d(xy * std::cos(sectorAngle), xy * std::sin(sectorAngle), z).cast<float>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "libslic3r/TriangleMeshSlicer.hpp"
|
#include "libslic3r/TriangleMeshSlicer.hpp"
|
||||||
|
|
||||||
#include "imgui/imgui_internal.h"
|
#include "imgui/imgui_internal.h"
|
||||||
|
#include "slic3r/GUI/MsgDialog.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -913,7 +914,7 @@ void GLGizmoCut3D::on_register_raycasters_for_picking()
|
|||||||
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, i + m_connectors_group_id, *(m_shapes[connectors[i].attribs]).mesh_raycaster, Transform3d::Identity()));
|
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, i + m_connectors_group_id, *(m_shapes[connectors[i].attribs]).mesh_raycaster, Transform3d::Identity()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (!cut_line_processing()) {
|
||||||
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, X, *m_cone.mesh_raycaster, Transform3d::Identity()));
|
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, X, *m_cone.mesh_raycaster, Transform3d::Identity()));
|
||||||
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, X, *m_cone.mesh_raycaster, Transform3d::Identity()));
|
m_raycasters.emplace_back(m_parent.add_raycaster_for_picking(SceneRaycaster::EType::Gizmo, X, *m_cone.mesh_raycaster, Transform3d::Identity()));
|
||||||
|
|
||||||
@ -991,7 +992,7 @@ void GLGizmoCut3D::update_raycasters_for_picking_transform()
|
|||||||
m_raycasters[i]->set_transform(translation_transform(pos) * m_rotation_m * scale_trafo);
|
m_raycasters[i]->set_transform(translation_transform(pos) * m_rotation_m * scale_trafo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (!cut_line_processing()){
|
||||||
const Transform3d trafo = translation_transform(m_plane_center) * m_rotation_m;
|
const Transform3d trafo = translation_transform(m_plane_center) * m_rotation_m;
|
||||||
|
|
||||||
const BoundingBoxf3 box = bounding_box();
|
const BoundingBoxf3 box = bounding_box();
|
||||||
@ -1376,10 +1377,14 @@ void GLGizmoCut3D::init_rendering_items()
|
|||||||
init_from_angle_arc(m_angle_arc, m_angle, m_grabber_connection_len);
|
init_from_angle_arc(m_angle_arc, m_angle, m_grabber_connection_len);
|
||||||
|
|
||||||
if (!m_plane.is_initialized() && !m_hide_cut_plane && !m_connectors_editing) {
|
if (!m_plane.is_initialized() && !m_hide_cut_plane && !m_connectors_editing) {
|
||||||
|
#if 1
|
||||||
|
m_plane.init_from(its_make_frustum_dowel((double)m_cut_plane_radius_koef * m_radius, 0.3, m_cut_plane_as_circle ? 180 : 4));
|
||||||
|
#else
|
||||||
if (m_cut_plane_as_circle)
|
if (m_cut_plane_as_circle)
|
||||||
m_plane.init_from(its_make_frustum_dowel(2. * m_radius, 0.3, 180));
|
m_plane.init_from(its_make_frustum_dowel(2. * m_radius, 0.3, 180));
|
||||||
else
|
else
|
||||||
m_plane.init_from(its_make_square_plane(float(m_radius)));
|
m_plane.init_from(its_make_square_plane(float(m_radius)));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1419,9 +1424,13 @@ void GLGizmoCut3D::on_render()
|
|||||||
m_selection_rectangle.render(m_parent);
|
m_selection_rectangle.render(m_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoCut3D::render_debug_input_window()
|
void GLGizmoCut3D::render_debug_input_window(float x)
|
||||||
{
|
{
|
||||||
m_imgui->begin(wxString("DEBUG"));
|
m_imgui->begin(wxString("DEBUG"));
|
||||||
|
|
||||||
|
ImVec2 pos = ImGui::GetWindowPos();
|
||||||
|
pos.x = x;
|
||||||
|
ImGui::SetWindowPos(pos, ImGuiCond_Always);
|
||||||
/*
|
/*
|
||||||
static bool hide_clipped = false;
|
static bool hide_clipped = false;
|
||||||
static bool fill_cut = false;
|
static bool fill_cut = false;
|
||||||
@ -1434,12 +1443,20 @@ void GLGizmoCut3D::render_debug_input_window()
|
|||||||
m_imgui->slider_float("contour_width", &contour_width, 0.f, 3.f);
|
m_imgui->slider_float("contour_width", &contour_width, 0.f, 3.f);
|
||||||
if (auto oc = m_c->object_clipper())
|
if (auto oc = m_c->object_clipper())
|
||||||
oc->set_behavior(hide_clipped || m_connectors_editing, fill_cut || m_connectors_editing, double(contour_width));
|
oc->set_behavior(hide_clipped || m_connectors_editing, fill_cut || m_connectors_editing, double(contour_width));
|
||||||
|
*/
|
||||||
|
ImGui::PushItemWidth(0.5f * m_label_width);
|
||||||
|
if (auto oc = m_c->object_clipper(); oc && m_imgui->slider_float("contour_width", &m_contour_width, 0.f, 3.f))
|
||||||
|
oc->set_behavior(m_connectors_editing, m_connectors_editing, double(m_contour_width));
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
*/
|
|
||||||
if (m_imgui->checkbox(_L("Render cut plane as circle"), m_cut_plane_as_circle))
|
if (m_imgui->checkbox(_L("Render cut plane as circle"), m_cut_plane_as_circle))
|
||||||
m_plane.reset();
|
m_plane.reset();
|
||||||
|
|
||||||
|
ImGui::PushItemWidth(0.5f * m_label_width);
|
||||||
|
if (m_imgui->slider_float("cut_plane_radius_koef", &m_cut_plane_radius_koef, 1.f, 2.f))
|
||||||
|
m_plane.reset();
|
||||||
|
|
||||||
m_imgui->end();
|
m_imgui->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,10 +1498,19 @@ void GLGizmoCut3D::render_shortcuts()
|
|||||||
if (m_imgui->button("? " + (m_show_shortcuts ? wxString(ImGui::CollapseBtn) : wxString(ImGui::ExpandBtn))))
|
if (m_imgui->button("? " + (m_show_shortcuts ? wxString(ImGui::CollapseBtn) : wxString(ImGui::ExpandBtn))))
|
||||||
m_show_shortcuts = !m_show_shortcuts;
|
m_show_shortcuts = !m_show_shortcuts;
|
||||||
|
|
||||||
|
if (m_shortcut_label_width < 0.f) {
|
||||||
|
for (const auto& shortcut : m_shortcuts) {
|
||||||
|
const float width = m_imgui->calc_text_size(shortcut.first).x;
|
||||||
|
if (m_shortcut_label_width < width)
|
||||||
|
m_shortcut_label_width = width;
|
||||||
|
}
|
||||||
|
m_shortcut_label_width += +m_imgui->scaled(1.f);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_show_shortcuts)
|
if (m_show_shortcuts)
|
||||||
for (const auto&shortcut : m_shortcuts ){
|
for (const auto&shortcut : m_shortcuts ){
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, shortcut.first);
|
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, shortcut.first);
|
||||||
ImGui::SameLine(m_label_width);
|
ImGui::SameLine(m_shortcut_label_width);
|
||||||
m_imgui->text(shortcut.second);
|
m_imgui->text(shortcut.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1624,8 +1650,8 @@ void GLGizmoCut3D::render_cut_plane_input_window(CutConnectors &connectors)
|
|||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
m_imgui->text(wxString(ImGui::InfoMarkerSmall));
|
m_imgui->text(wxString(ImGui::InfoMarkerSmall));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _L("Hold SHIFT key and connect some two points of an object to cut by line"));
|
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT,
|
||||||
|
get_wraped_wxString(_L("Hold SHIFT key and connect some two points of an object to cut by line"), 40));
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
render_build_size();
|
render_build_size();
|
||||||
@ -1642,13 +1668,6 @@ void GLGizmoCut3D::render_cut_plane_input_window(CutConnectors &connectors)
|
|||||||
reset_cut_plane();
|
reset_cut_plane();
|
||||||
m_imgui->disabled_end();
|
m_imgui->disabled_end();
|
||||||
|
|
||||||
ImGui::SameLine(2.25f * m_label_width);
|
|
||||||
ImGui::PushItemWidth(0.75f * m_label_width);
|
|
||||||
m_is_contour_changed = m_imgui->slider_float("contour width", &m_contour_width, 0.f, 3.f);
|
|
||||||
|
|
||||||
if (auto oc = m_c->object_clipper(); oc && m_is_contour_changed)
|
|
||||||
oc->set_behavior(m_connectors_editing, m_connectors_editing, double(m_contour_width));
|
|
||||||
|
|
||||||
if (wxGetApp().plater()->printer_technology() == ptFFF) {
|
if (wxGetApp().plater()->printer_technology() == ptFFF) {
|
||||||
m_imgui->disabled_begin(!m_keep_upper || !m_keep_lower);
|
m_imgui->disabled_begin(!m_keep_upper || !m_keep_lower);
|
||||||
if (m_imgui->button(_L("Add/Edit connectors")))
|
if (m_imgui->button(_L("Add/Edit connectors")))
|
||||||
@ -1658,18 +1677,25 @@ void GLGizmoCut3D::render_cut_plane_input_window(CutConnectors &connectors)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
auto render_part_action_line = [this, connectors](const wxString& label, const wxString& suffix, bool& keep_part, bool& place_on_cut_part, bool& rotate_part) {
|
float label_width = 0;
|
||||||
|
for (const wxString& label : {_L("Upper part"), _L("Lower part")}) {
|
||||||
|
const float width = m_imgui->calc_text_size(label).x + m_imgui->scaled(1.5f);
|
||||||
|
if (label_width < width)
|
||||||
|
label_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto render_part_action_line = [this, label_width, connectors](const wxString& label, const wxString& suffix, bool& keep_part, bool& place_on_cut_part, bool& rotate_part) {
|
||||||
bool keep = true;
|
bool keep = true;
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
m_imgui->text(label);
|
m_imgui->text(label);
|
||||||
|
|
||||||
ImGui::SameLine(m_label_width);
|
ImGui::SameLine(label_width);
|
||||||
|
|
||||||
m_imgui->disabled_begin(!connectors.empty());
|
m_imgui->disabled_begin(!connectors.empty());
|
||||||
m_imgui->checkbox(_L("Keep") + suffix, connectors.empty() ? keep_part : keep);
|
m_imgui->checkbox(_L("Keep") + suffix, connectors.empty() ? keep_part : keep);
|
||||||
m_imgui->disabled_end();
|
m_imgui->disabled_end();
|
||||||
|
|
||||||
ImGui::SameLine(2 * m_label_width);
|
ImGui::SameLine();
|
||||||
|
|
||||||
m_imgui->disabled_begin(!keep_part);
|
m_imgui->disabled_begin(!keep_part);
|
||||||
if (m_imgui->checkbox(_L("Place on cut") + suffix, place_on_cut_part))
|
if (m_imgui->checkbox(_L("Place on cut") + suffix, place_on_cut_part))
|
||||||
@ -1813,7 +1839,8 @@ void GLGizmoCut3D::on_render_input_window(float x, float y, float bottom_limit)
|
|||||||
|
|
||||||
m_imgui->end();
|
m_imgui->end();
|
||||||
|
|
||||||
render_debug_input_window();
|
if (!m_connectors_editing) // connectors mode
|
||||||
|
render_debug_input_window(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get volume transformation regarding to the "border". Border is related from the size of connectors
|
// get volume transformation regarding to the "border". Border is related from the size of connectors
|
||||||
|
@ -111,7 +111,9 @@ class GLGizmoCut3D : public GLGizmoBase
|
|||||||
bool force_update_clipper_on_render{false};
|
bool force_update_clipper_on_render{false};
|
||||||
|
|
||||||
float m_contour_width{ 0.4f };
|
float m_contour_width{ 0.4f };
|
||||||
|
float m_cut_plane_radius_koef{ 1.5f };
|
||||||
bool m_is_contour_changed{ false };
|
bool m_is_contour_changed{ false };
|
||||||
|
float m_shortcut_label_width{ -1.f };
|
||||||
|
|
||||||
mutable std::vector<bool> m_selected; // which pins are currently selected
|
mutable std::vector<bool> m_selected; // which pins are currently selected
|
||||||
int m_selected_count{ 0 };
|
int m_selected_count{ 0 };
|
||||||
@ -199,7 +201,7 @@ protected:
|
|||||||
void on_stop_dragging() override;
|
void on_stop_dragging() override;
|
||||||
void on_render() override;
|
void on_render() override;
|
||||||
|
|
||||||
void render_debug_input_window();
|
void render_debug_input_window(float x);
|
||||||
void adjust_window_position(float x, float y, float bottom_limit);
|
void adjust_window_position(float x, float y, float bottom_limit);
|
||||||
void unselect_all_connectors();
|
void unselect_all_connectors();
|
||||||
void select_all_connectors();
|
void select_all_connectors();
|
||||||
|
Loading…
Reference in New Issue
Block a user