Added dialog with shortcuts to the SLA gizmo, tried to improve the dialog look
This commit is contained in:
parent
3f74ec491e
commit
55c07394e5
@ -5,8 +5,11 @@
|
|||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
#include "slic3r/GUI/GUI_ObjectSettings.hpp"
|
||||||
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
#include "slic3r/GUI/GUI_ObjectList.hpp"
|
||||||
#include "slic3r/GUI/PresetBundle.hpp"
|
#include "slic3r/GUI/PresetBundle.hpp"
|
||||||
@ -863,33 +866,32 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l
|
|||||||
bool first_run = true; // This is a hack to redraw the button when all points are removed,
|
bool first_run = true; // This is a hack to redraw the button when all points are removed,
|
||||||
// so it is not delayed until the background process finishes.
|
// so it is not delayed until the background process finishes.
|
||||||
RENDER_AGAIN:
|
RENDER_AGAIN:
|
||||||
|
//m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||||
|
//const ImVec2 window_size(m_imgui->scaled(18.f, 16.f));
|
||||||
|
//ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
||||||
|
//ImGui::SetNextWindowSize(ImVec2(window_size));
|
||||||
|
|
||||||
|
const float approx_height = m_imgui->scaled(18.0f);
|
||||||
|
y = std::min(y, bottom_limit - approx_height);
|
||||||
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
m_imgui->set_next_window_pos(x, y, ImGuiCond_Always);
|
||||||
|
|
||||||
const ImVec2 window_size(m_imgui->scaled(17.f, 20.f));
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) ));
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(window_size));
|
|
||||||
|
|
||||||
m_imgui->set_next_window_bg_alpha(0.5f);
|
m_imgui->set_next_window_bg_alpha(0.5f);
|
||||||
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
m_imgui->begin(on_get_name(), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
ImGui::PushItemWidth(100.0f);
|
ImGui::PushItemWidth(m_imgui->scaled(5.55f));
|
||||||
|
|
||||||
bool force_refresh = false;
|
bool force_refresh = false;
|
||||||
bool remove_selected = false;
|
bool remove_selected = false;
|
||||||
bool remove_all = false;
|
bool remove_all = false;
|
||||||
|
|
||||||
if (m_editing_mode) {
|
if (m_editing_mode) {
|
||||||
m_imgui->text(_(L("Left mouse click - add point")));
|
|
||||||
m_imgui->text(_(L("Right mouse click - remove point")));
|
|
||||||
m_imgui->text(_(L("Shift + Left (+ drag) - select point(s)")));
|
|
||||||
m_imgui->text(" "); // vertical gap
|
|
||||||
|
|
||||||
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
|
float diameter_upper_cap = static_cast<ConfigOptionFloat*>(wxGetApp().preset_bundle->sla_prints.get_edited_preset().config.option("support_pillar_diameter"))->value;
|
||||||
if (m_new_point_head_diameter > diameter_upper_cap)
|
if (m_new_point_head_diameter > diameter_upper_cap)
|
||||||
m_new_point_head_diameter = diameter_upper_cap;
|
m_new_point_head_diameter = diameter_upper_cap;
|
||||||
|
|
||||||
m_imgui->text(_(L("Head diameter: ")));
|
m_imgui->text(_(L("Head diameter: ")));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine(m_imgui->scaled(6.66f));
|
||||||
|
ImGui::PushItemWidth(m_imgui->scaled(8.33f));
|
||||||
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
|
if (ImGui::SliderFloat("", &m_new_point_head_diameter, 0.1f, diameter_upper_cap, "%.1f")) {
|
||||||
// value was changed
|
// value was changed
|
||||||
for (auto& cache_entry : m_editing_mode_cache)
|
for (auto& cache_entry : m_editing_mode_cache)
|
||||||
@ -925,9 +927,9 @@ RENDER_AGAIN:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // not in editing mode:
|
else { // not in editing mode:
|
||||||
ImGui::PushItemWidth(100.0f);
|
ImGui::PushItemWidth(m_imgui->scaled(5.55f));
|
||||||
m_imgui->text(_(L("Minimal points distance: ")));
|
m_imgui->text(_(L("Minimal points distance: ")));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine(m_imgui->scaled(9.44f));
|
||||||
|
|
||||||
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
|
std::vector<const ConfigOption*> opts = get_config_options({"support_points_density_relative", "support_points_minimal_distance"});
|
||||||
float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
|
float density = static_cast<const ConfigOptionInt*>(opts[0])->value;
|
||||||
@ -938,7 +940,7 @@ RENDER_AGAIN:
|
|||||||
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
||||||
|
|
||||||
m_imgui->text(_(L("Support points density: ")));
|
m_imgui->text(_(L("Support points density: ")));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine(m_imgui->scaled(9.44f));
|
||||||
if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) {
|
if (ImGui::SliderFloat(" ", &density, 0.f, 200.f, "%.f %%")) {
|
||||||
value_changed = true;
|
value_changed = true;
|
||||||
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
||||||
@ -951,43 +953,51 @@ RENDER_AGAIN:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generate = m_imgui->button(_(L("Auto-generate points [A]")));
|
bool generate = m_imgui->button(_(L("Auto-generate points")));
|
||||||
|
|
||||||
if (generate)
|
if (generate)
|
||||||
auto_generate();
|
auto_generate();
|
||||||
|
|
||||||
m_imgui->text("");
|
m_imgui->text("");
|
||||||
if (m_imgui->button(_(L("Manual editing [M]"))))
|
if (m_imgui->button(_(L("Manual editing"))))
|
||||||
switch_to_editing_mode();
|
switch_to_editing_mode();
|
||||||
|
|
||||||
m_imgui->disabled_begin(m_editing_mode_cache.empty());
|
m_imgui->disabled_begin(m_editing_mode_cache.empty());
|
||||||
remove_all = m_imgui->button(_(L("Remove all points")));
|
remove_all = m_imgui->button(_(L("Remove all points")));
|
||||||
m_imgui->disabled_end();
|
m_imgui->disabled_end();
|
||||||
|
|
||||||
m_imgui->text("");
|
// m_imgui->text("");
|
||||||
|
// m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? _(L("No points (will be autogenerated)")) :
|
||||||
m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? _(L("No points (will be autogenerated)")) :
|
// (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) :
|
||||||
(m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) :
|
// (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) :
|
||||||
(m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) :
|
// (m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS"))));
|
||||||
(m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Following is rendered in both editing and non-editing mode:
|
// Following is rendered in both editing and non-editing mode:
|
||||||
|
m_imgui->text("");
|
||||||
if (m_clipping_plane_distance == 0.f)
|
if (m_clipping_plane_distance == 0.f)
|
||||||
m_imgui->text("Clipping of view: ");
|
m_imgui->text("Clipping of view: ");
|
||||||
else {
|
else {
|
||||||
if (m_imgui->button(_(L("Reset direction [R] ")))) {
|
if (m_imgui->button(_(L("Reset direction")))) {
|
||||||
wxGetApp().CallAfter([this](){
|
wxGetApp().CallAfter([this](){
|
||||||
reset_clipping_plane_normal();
|
reset_clipping_plane_normal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine(140.f);
|
ImGui::SameLine(m_imgui->scaled(6.66f));
|
||||||
ImGui::PushItemWidth(150.0f);
|
ImGui::PushItemWidth(m_imgui->scaled(8.33f));
|
||||||
ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");
|
ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f");
|
||||||
|
|
||||||
|
|
||||||
|
if (m_imgui->button("?")) {
|
||||||
|
wxGetApp().CallAfter([]() {
|
||||||
|
SlaGizmoHelpDialog help_dlg;
|
||||||
|
help_dlg.ShowModal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
m_imgui->end();
|
m_imgui->end();
|
||||||
|
|
||||||
if (m_editing_mode != m_old_editing_state) { // user toggled between editing/non-editing mode
|
if (m_editing_mode != m_old_editing_state) { // user toggled between editing/non-editing mode
|
||||||
@ -1240,6 +1250,66 @@ void GLGizmoSlaSupports::reset_clipping_plane_normal() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SlaGizmoHelpDialog::SlaGizmoHelpDialog()
|
||||||
|
: wxDialog(NULL, wxID_ANY, _(L("SLA gizmo keyboard shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
|
||||||
|
{
|
||||||
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||||
|
const std::string &ctrl = GUI::shortkey_ctrl_prefix();
|
||||||
|
const std::string &alt = GUI::shortkey_alt_prefix();
|
||||||
|
|
||||||
|
|
||||||
|
// fonts
|
||||||
|
const wxFont& font = wxGetApp().small_font();
|
||||||
|
const wxFont& bold_font = wxGetApp().bold_font();
|
||||||
|
|
||||||
|
auto note_text = new wxStaticText(this, wxID_ANY, "Note: some shortcuts work in (non)editing mode only.");
|
||||||
|
note_text->SetFont(font);
|
||||||
|
|
||||||
|
auto vsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
auto gridsizer = new wxFlexGridSizer(2, 5, 15);
|
||||||
|
auto hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
hsizer->AddSpacer(20);
|
||||||
|
hsizer->Add(vsizer);
|
||||||
|
hsizer->AddSpacer(20);
|
||||||
|
|
||||||
|
vsizer->AddSpacer(20);
|
||||||
|
vsizer->Add(note_text, 1, wxALIGN_CENTRE_HORIZONTAL);
|
||||||
|
vsizer->AddSpacer(20);
|
||||||
|
vsizer->Add(gridsizer);
|
||||||
|
vsizer->AddSpacer(20);
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, wxString>> shortcuts;
|
||||||
|
shortcuts.push_back(std::make_pair("Left click", _(L("Add point"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Right click", _(L("Remove point"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Drag", _(L("Move point"))));
|
||||||
|
shortcuts.push_back(std::make_pair(ctrl+"Left click", _(L("Add point to selection"))));
|
||||||
|
shortcuts.push_back(std::make_pair(alt+"Left click", _(L("Remove point from selection"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Shift+drag", _(L("Select by rectangle"))));
|
||||||
|
shortcuts.push_back(std::make_pair(alt+"drag", _(L("Deselect by rectangle"))));
|
||||||
|
shortcuts.push_back(std::make_pair(ctrl+"A", _(L("Select all points"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Delete", _(L("Remove selected points"))));
|
||||||
|
shortcuts.push_back(std::make_pair(ctrl+"mouse wheel", _(L("Move clipping plane"))));
|
||||||
|
shortcuts.push_back(std::make_pair("R", _(L("Reset clipping plane"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Enter", _(L("Apply changes"))));
|
||||||
|
shortcuts.push_back(std::make_pair("Esc", _(L("Discard changes"))));
|
||||||
|
shortcuts.push_back(std::make_pair("M", _(L("Switch to editing mode"))));
|
||||||
|
shortcuts.push_back(std::make_pair("A", _(L("Auto-generate points"))));
|
||||||
|
|
||||||
|
for (const auto& pair : shortcuts) {
|
||||||
|
auto shortcut = new wxStaticText(this, wxID_ANY, pair.first);
|
||||||
|
auto desc = new wxStaticText(this, wxID_ANY, pair.second);
|
||||||
|
shortcut->SetFont(bold_font);
|
||||||
|
desc->SetFont(font);
|
||||||
|
gridsizer->Add(shortcut, -1, wxALIGN_CENTRE_VERTICAL);
|
||||||
|
gridsizer->Add(desc, -1, wxALIGN_CENTRE_VERTICAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSizer(hsizer);
|
||||||
|
hsizer->SetSizeHints(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "libslic3r/SLA/SLACommon.hpp"
|
#include "libslic3r/SLA/SLACommon.hpp"
|
||||||
#include "libslic3r/SLAPrint.hpp"
|
#include "libslic3r/SLAPrint.hpp"
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@ -139,6 +140,12 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SlaGizmoHelpDialog : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SlaGizmoHelpDialog();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user