mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
NEW:add 3Dconnexion dialog
Change-Id: I0dd1160decb11e5040399bb9c27f571a03b1d082
This commit is contained in:
parent
440bcc8090
commit
65393b8f73
6 changed files with 130 additions and 57 deletions
|
@ -3767,16 +3767,18 @@ bool ImGui::BBLSliderScalar(const char *label, ImGuiDataType data_type, void *p_
|
|||
|
||||
// Render grab
|
||||
if (grab_bb.Max.x > grab_bb.Min.x) {
|
||||
float offset = 1.0f;
|
||||
ImVec2 p1 = ImVec2((grab_bb.Min.x + grab_bb.Max.x) / 2, (grab_bb.Min.y + grab_bb.Max.y) / 2 - offset);
|
||||
ImVec2 p2 = ImVec2(grab_bb.Min.x, grab_bb.Max.y);
|
||||
ImVec2 p3 = ImVec2(grab_bb.Max.x, grab_bb.Max.y);
|
||||
float line_high = 2.0f;
|
||||
const float offset = 2.0f;
|
||||
|
||||
ImVec2 p1 = ImVec2((grab_bb.Min.x + grab_bb.Max.x) / 2, (grab_bb.Min.y + grab_bb.Max.y) / 2 + offset);
|
||||
ImVec2 p2 = ImVec2(grab_bb.Min.x, grab_bb.Max.y + offset);
|
||||
ImVec2 p3 = ImVec2(grab_bb.Max.x, grab_bb.Max.y + offset);
|
||||
window->DrawList->AddTriangleFilled(p1, p2, p3, GetColorU32(ImGuiCol_SliderGrabActive));
|
||||
ImVec2 start_pos = ImVec2(frame_bb.Min.x, frame_bb.GetCenter().y - offset);
|
||||
ImVec2 curr_pos = ImVec2(grab_bb.GetCenter().x, frame_bb.GetCenter().y + offset);
|
||||
ImVec2 end_pos = ImVec2(frame_bb.Max.x, frame_bb.GetCenter().y + offset);
|
||||
window->DrawList->AddRectFilled(start_pos, curr_pos, GetColorU32(ImGuiCol_SliderGrabActive), style.GrabRounding);
|
||||
ImVec2 curr_pos = ImVec2(grab_bb.GetCenter().x, frame_bb.GetCenter().y + line_high - offset);
|
||||
ImVec2 end_pos = ImVec2(frame_bb.Max.x, frame_bb.GetCenter().y + line_high - offset);
|
||||
window->DrawList->AddRectFilled(start_pos, end_pos, GetColorU32(ImGuiCol_SliderGrab), style.GrabRounding);
|
||||
window->DrawList->AddRectFilled(start_pos, curr_pos, GetColorU32(ImGuiCol_SliderGrabActive), style.GrabRounding);
|
||||
}
|
||||
|
||||
if (label_size.x > 0.0f) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
|
|
@ -184,10 +184,10 @@ void AppConfig::set_defaults()
|
|||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef SUPPORT_3D_CONNEXION
|
||||
//#ifdef SUPPORT_3D_CONNEXION
|
||||
if (get("use_legacy_3DConnexion").empty())
|
||||
set_bool("use_legacy_3DConnexion", false);
|
||||
#endif
|
||||
set_bool("use_legacy_3DConnexion", true);
|
||||
//#endif
|
||||
|
||||
#ifdef SUPPORT_DARK_MODE
|
||||
if (get("dark_color_mode").empty())
|
||||
|
|
|
@ -2292,30 +2292,25 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||
case WXK_CONTROL_M:
|
||||
#endif /* __APPLE__ */
|
||||
{
|
||||
//#ifdef _WIN32
|
||||
// if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "1") {
|
||||
//#endif //_WIN32
|
||||
//#ifdef __APPLE__
|
||||
// // On OSX use Cmd+Shift+M to "Show/Hide 3Dconnexion devices settings dialog"
|
||||
// if ((evt.GetModifiers() & shiftMask) != 0) {
|
||||
//#endif // __APPLE__
|
||||
//
|
||||
//#ifdef SUPPORT_3D_CONNEXION
|
||||
// Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
|
||||
// controller.show_settings_dialog(!controller.is_settings_dialog_shown());
|
||||
// m_dirty = true;
|
||||
//#endif
|
||||
|
||||
//#ifdef __APPLE__
|
||||
// }
|
||||
// else
|
||||
// // and Cmd+M to minimize application
|
||||
// wxGetApp().mainframe->Iconize();
|
||||
//#endif // __APPLE__
|
||||
//#ifdef _WIN32
|
||||
// }
|
||||
//#endif //_WIN32
|
||||
post_event(SimpleEvent(EVT_GLTOOLBAR_CLONE));
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().app_config->get("use_legacy_3DConnexion") == "true") {
|
||||
#endif //_WIN32
|
||||
#ifdef __APPLE__
|
||||
// On OSX use Cmd+Shift+M to "Show/Hide 3Dconnexion devices settings dialog"
|
||||
if ((evt.GetModifiers() & shiftMask) != 0) {
|
||||
#endif // __APPLE__
|
||||
Mouse3DController& controller = wxGetApp().plater()->get_mouse3d_controller();
|
||||
controller.show_settings_dialog(!controller.is_settings_dialog_shown());
|
||||
m_dirty = true;
|
||||
#ifdef __APPLE__
|
||||
}
|
||||
else
|
||||
// and Cmd+M to minimize application
|
||||
wxGetApp().mainframe->Iconize();
|
||||
#endif // __APPLE__
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif //_WIN32
|
||||
break;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -543,7 +543,7 @@ bool ImGuiWrapper::bbl_slider_float_style(const std::string &label, float *v, fl
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 0.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 0.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.81f, 0.81f, 0.81f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
|
||||
|
||||
bool ret = bbl_slider_float(label, v, v_min,v_max, format, power, clamp,tooltip);
|
||||
|
|
|
@ -1821,7 +1821,7 @@ void MainFrame::init_menubar_as_editor()
|
|||
"menu_remove", nullptr, [this](){return can_delete_all(); }, this);
|
||||
editMenu->AppendSeparator();
|
||||
// BBS Clone Selected
|
||||
append_menu_item(editMenu, wxID_ANY, _L("Clone selected") + "\tCtrl+M",
|
||||
append_menu_item(editMenu, wxID_ANY, _L("Clone selected") /*+ "\tCtrl+M"*/,
|
||||
_L("Clone copies of selections"),[this](wxCommandEvent&) {
|
||||
m_plater->clone_selection();
|
||||
},
|
||||
|
|
|
@ -448,9 +448,24 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
imgui.set_next_window_pos(0.5f * (float)cnv_size.get_width(), 0.5f * (float)cnv_size.get_height(), ImGuiCond_Always, 0.5f, 0.5f);
|
||||
|
||||
float space_size = imgui.get_style_scaling() * 8;
|
||||
|
||||
float speed_size = imgui.calc_text_size(_L("Speed:")).x + imgui.scaled(1.5f);
|
||||
float dead_size = imgui.calc_text_size(_L("Deadzone:")).x + imgui.scaled(1.5f);
|
||||
float option_size = imgui.calc_text_size(_L("Options:")).x + imgui.scaled(1.5f);
|
||||
float max_left_size = std::max(speed_size,std::max(dead_size,option_size)) + space_size;
|
||||
|
||||
float trans_size = imgui.calc_text_size(_L("Translate")).x + space_size;
|
||||
float zoom_size = imgui.calc_text_size(_L("Zoom")).x + space_size;
|
||||
float rota_size = imgui.calc_text_size(_L("Rotation")).x + space_size;
|
||||
float trasn_zoom_size = imgui.calc_text_size(_L("Translation/Zoom")).x + space_size;
|
||||
float max_slider_txt_size = std::max(std::max(trans_size,zoom_size),std::max(rota_size,trasn_zoom_size));
|
||||
|
||||
ImGuiWrapper::push_toolbar_style(wxGetApp().plater()->canvas3D()->get_scale());
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
|
||||
static ImVec2 last_win_size(0.0f, 0.0f);
|
||||
bool shown = true;
|
||||
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse)) {
|
||||
if (imgui.begin(_L("3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) {
|
||||
if (shown) {
|
||||
ImVec2 win_size = ImGui::GetWindowSize();
|
||||
if (last_win_size.x != win_size.x || last_win_size.y != win_size.y) {
|
||||
|
@ -460,52 +475,109 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
canvas.request_extra_frame();
|
||||
}
|
||||
|
||||
const ImVec4& color = ImGui::GetStyleColorVec4(ImGuiCol_Separator);
|
||||
imgui.text_colored(color, _L("Device:"));
|
||||
const ImVec4& color = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
|
||||
/*imgui.text(_L("Device:"));
|
||||
ImGui::SameLine();
|
||||
imgui.text(m_device_str);
|
||||
|
||||
ImGui::Separator();
|
||||
imgui.text_colored(color, _L("Speed:"));
|
||||
imgui.text(m_device_str);*/
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text_colored(color,_L("Speed:"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - trans_size);
|
||||
imgui.text(_L("Translate"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size);
|
||||
|
||||
ImGui::PushItemWidth(imgui.scaled(6.0f));
|
||||
float translation_scale = float(params_copy.translation.scale) / float(Params::DefaultTranslationScale);
|
||||
if (imgui.slider_float(_L("Translation"), &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale), "%.1f")) {
|
||||
bool b_translation = imgui.bbl_slider_float_style("##Translate", &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale), "%.1f");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(imgui.scaled(3.0f));
|
||||
bool b_translation_dragfloat = ImGui::BBLDragFloat("##Translate_input", &translation_scale, float(Params::MinTranslationScale), float(Params::MaxTranslationScale),0.0, "%.1f");
|
||||
if (b_translation || b_translation_dragfloat) {
|
||||
params_copy.translation.scale = Params::DefaultTranslationScale * double(translation_scale);
|
||||
params_changed = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy({space_size, 0.0});
|
||||
|
||||
ImGui::Dummy({0.0, 0.0});
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text(_L("Rotation"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size);
|
||||
ImGui::PushItemWidth(imgui.scaled(6.0f));
|
||||
float rotation_scale = params_copy.rotation.scale / Params::DefaultRotationScale;
|
||||
if (imgui.slider_float(_L("Rotation") + "##1", &rotation_scale, 0.1f, 10.0f, "%.1f")) {
|
||||
bool b_rotation1 = imgui.bbl_slider_float_style("##Rotation1", &rotation_scale, 0.1f, 10.0f, "%.1f");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(imgui.scaled(3.0f));
|
||||
bool b_rotation1_dragfloat = ImGui::BBLDragFloat("##Rotation1_input", &rotation_scale, 0.1f, 10.0f, 0.0, "%.1f");
|
||||
if (b_rotation1 || b_rotation1_dragfloat) {
|
||||
params_copy.rotation.scale = Params::DefaultRotationScale * rotation_scale;
|
||||
params_changed = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy({space_size, 0.0});
|
||||
|
||||
ImGui::Dummy({0.0, 0.0});
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - zoom_size);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text(_L("Zoom"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size);
|
||||
ImGui::PushItemWidth(imgui.scaled(6.0f));
|
||||
float zoom_scale = params_copy.zoom.scale / Params::DefaultZoomScale;
|
||||
if (imgui.slider_float(_L("Zoom"), &zoom_scale, 0.1f, 10.0f, "%.1f")) {
|
||||
bool b_zoom = imgui.bbl_slider_float_style("##Zoom", &zoom_scale, 0.1f, 10.0f, "%.1f");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(imgui.scaled(3.0f));
|
||||
bool b_zoom_dragfloat = ImGui::BBLDragFloat("##Zoom_input", &zoom_scale, 0.1f, 10.0f, 0.0, "%.1f");
|
||||
if (b_zoom || b_zoom_dragfloat) {
|
||||
params_copy.zoom.scale = Params::DefaultZoomScale * zoom_scale;
|
||||
params_changed = true;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
imgui.text_colored(color, _L("Deadzone:"));
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text_colored(color,_L("Deadzone:"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - trasn_zoom_size);
|
||||
imgui.text(_L("Translation/Zoom"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size);
|
||||
|
||||
float translation_deadzone = (float)params_copy.translation.deadzone;
|
||||
if (imgui.slider_float(_L("Translation") + "/" + _L("Zoom"), &translation_deadzone, 0.0f, (float)Params::MaxTranslationDeadzone, "%.2f")) {
|
||||
params_copy.translation.deadzone = (double)translation_deadzone;
|
||||
ImGui::PushItemWidth(imgui.scaled(6.0f));
|
||||
float translation_deadzone = (float) params_copy.translation.deadzone;
|
||||
bool b_tran_zoom = imgui.bbl_slider_float_style("##Translation/Zoom", &translation_deadzone, 0.0f, (float) Params::MaxTranslationDeadzone, "%.2f");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(imgui.scaled(3.0f));
|
||||
bool b_tran_zoom_dragfloat = ImGui::BBLDragFloat("##Translation/Zoom_input", &translation_deadzone, 0.0f, (float) Params::MaxTranslationDeadzone, 0.0, "%.1f");
|
||||
if (b_tran_zoom || b_tran_zoom_dragfloat) {
|
||||
params_copy.translation.deadzone = (double) translation_deadzone;
|
||||
params_changed = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy({space_size, 0.0});
|
||||
|
||||
ImGui::Dummy({0.0, 0.0});
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text(_L("Rotation"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size);
|
||||
ImGui::PushItemWidth(imgui.scaled(6.0f));
|
||||
float rotation_deadzone = params_copy.rotation.deadzone;
|
||||
if (imgui.slider_float(_L("Rotation") + "##2", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, "%.2f")) {
|
||||
bool b_rotation2 = imgui.bbl_slider_float_style("##Rotation2", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, "%.2f");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(imgui.scaled(3.0f));
|
||||
bool b_rotation2_dragfloat = ImGui::BBLDragFloat("##Rotation2_input", &rotation_deadzone, 0.0f, Params::MaxRotationDeadzone, 0.0, "%.1f");
|
||||
if (b_rotation2 || b_rotation2_dragfloat) {
|
||||
params_copy.rotation.deadzone = rotation_deadzone;
|
||||
params_changed = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy({space_size, 0.0});
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Separator();
|
||||
imgui.text_colored(color, _L("Options:"));
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui.text_colored(color,_L("Options:"));
|
||||
ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
|
||||
|
||||
bool swap_yz = params_copy.swap_yz;
|
||||
if (imgui.checkbox(_L("Swap Y/Z axes"), swap_yz)) {
|
||||
if (imgui.bbl_checkbox(_L("Swap Y/Z axes"), swap_yz)) {
|
||||
params_copy.swap_yz = swap_yz;
|
||||
params_changed = true;
|
||||
}
|
||||
|
@ -540,6 +612,9 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
|
||||
|
||||
ImGui::Separator();
|
||||
float window_width = ImGui::GetWindowWidth();
|
||||
ImGui::Dummy({0.0, 0.0});
|
||||
ImGui::SameLine((window_width - imgui.calc_text_size(_L("Close")).x)/2);
|
||||
if (imgui.button(_L("Close"))) {
|
||||
// the user clicked on the [Close] button
|
||||
m_settings_dialog_closed_by_user = true;
|
||||
|
@ -554,7 +629,8 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
}
|
||||
|
||||
imgui.end();
|
||||
|
||||
ImGui::PopStyleVar(1);
|
||||
ImGuiWrapper::pop_toolbar_style();
|
||||
if (params_changed) {
|
||||
// Synchronize front end parameters to back end.
|
||||
std::scoped_lock<std::mutex> lock(m_params_ui_mutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue