466{
468 return;
469
470
471
475 canvas.request_extra_frame();
476 return;
477 }
478
480 bool params_changed = false;
481 {
484 }
485
486 Size cnv_size = canvas.get_canvas_size();
487
488 ImGuiWrapper& imgui = *wxGetApp().imgui();
489 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);
490
491 float space_size = imgui.get_style_scaling() * 8;
492
493 float speed_size = imgui.calc_text_size(
_L(
"Speed:")).x + imgui.scaled(1.5f);
494 float dead_size = imgui.calc_text_size(
_L(
"Deadzone:")).x + imgui.scaled(1.5f);
495 float option_size = imgui.calc_text_size(
_L(
"Options:")).x + imgui.scaled(1.5f);
496 float max_left_size = std::max(speed_size,std::max(dead_size,option_size)) + space_size;
497
498 float trans_size = imgui.calc_text_size(
_L(
"Translate")).x + space_size;
499 float zoom_size = imgui.calc_text_size(
_L(
"Zoom")).x + space_size;
500 float rota_size = imgui.calc_text_size(
_L(
"Rotation")).x + space_size;
501 float trasn_zoom_size = imgui.calc_text_size(
_L(
"Translation/Zoom")).x + space_size;
502 float max_slider_txt_size = std::max(std::max(trans_size,zoom_size),std::max(rota_size,trasn_zoom_size));
503
505 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 20.0f));
506 static ImVec2 last_win_size(0.0f, 0.0f);
507 bool shown = true;
508 if (imgui.begin(
_L(
"3Dconnexion settings"), &shown, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) {
509 if (shown) {
510 ImVec2 win_size = ImGui::GetWindowSize();
511 if (last_win_size.x != win_size.x || last_win_size.y != win_size.y) {
512
513
514 last_win_size = win_size;
515 canvas.request_extra_frame();
516 }
517
518 const ImVec4& color = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
519
520
521
522 ImGui::AlignTextToFramePadding();
523 imgui.text_colored(color,
_L(
"Speed:"));
524 ImGui::SameLine(max_left_size + max_slider_txt_size - trans_size);
525 imgui.text(
_L(
"Translate"));
526 ImGui::SameLine(max_left_size + max_slider_txt_size);
527
528 ImGui::PushItemWidth(imgui.scaled(6.0f));
531 ImGui::SameLine();
532 ImGui::PushItemWidth(imgui.scaled(3.0f));
534 if (b_translation || b_translation_dragfloat) {
536 params_changed = true;
537 }
538 ImGui::SameLine();
539 ImGui::Dummy({space_size, 0.0});
540
541 ImGui::Dummy({0.0, 0.0});
542 ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
543 ImGui::AlignTextToFramePadding();
544 imgui.text(
_L(
"Rotation"));
545 ImGui::SameLine(max_left_size + max_slider_txt_size);
546 ImGui::PushItemWidth(imgui.scaled(6.0f));
548 bool b_rotation1 = imgui.bbl_slider_float_style("##Rotation1", &rotation_scale, 0.1f, 10.0f, "%.1f");
549 ImGui::SameLine();
550 ImGui::PushItemWidth(imgui.scaled(3.0f));
551 bool b_rotation1_dragfloat = ImGui::BBLDragFloat("##Rotation1_input", &rotation_scale, 0.1f, 10.0f, 0.0, "%.1f");
552 if (b_rotation1 || b_rotation1_dragfloat) {
554 params_changed = true;
555 }
556 ImGui::SameLine();
557 ImGui::Dummy({space_size, 0.0});
558
559 ImGui::Dummy({0.0, 0.0});
560 ImGui::SameLine(max_left_size + max_slider_txt_size - zoom_size);
561 ImGui::AlignTextToFramePadding();
562 imgui.text(
_L(
"Zoom"));
563 ImGui::SameLine(max_left_size + max_slider_txt_size);
564 ImGui::PushItemWidth(imgui.scaled(6.0f));
566 bool b_zoom = imgui.bbl_slider_float_style("##Zoom", &zoom_scale, 0.1f, 10.0f, "%.1f");
567 ImGui::SameLine();
568 ImGui::PushItemWidth(imgui.scaled(3.0f));
569 bool b_zoom_dragfloat = ImGui::BBLDragFloat("##Zoom_input", &zoom_scale, 0.1f, 10.0f, 0.0, "%.1f");
570 if (b_zoom || b_zoom_dragfloat) {
572 params_changed = true;
573 }
574
575 ImGui::Separator();
576 ImGui::AlignTextToFramePadding();
577 imgui.text_colored(color,
_L(
"Deadzone:"));
578 ImGui::SameLine(max_left_size + max_slider_txt_size - trasn_zoom_size);
579 imgui.text(
_L(
"Translation/Zoom"));
580 ImGui::SameLine(max_left_size + max_slider_txt_size);
581
582 ImGui::PushItemWidth(imgui.scaled(6.0f));
583 float translation_deadzone = (float) params_copy.translation.deadzone;
584 bool b_tran_zoom = imgui.bbl_slider_float_style(
"##Translation/Zoom", &translation_deadzone, 0.0f, (
float)
Params::MaxTranslationDeadzone,
"%.2f");
585 ImGui::SameLine();
586 ImGui::PushItemWidth(imgui.scaled(3.0f));
587 bool b_tran_zoom_dragfloat = ImGui::BBLDragFloat(
"##Translation/Zoom_input", &translation_deadzone, 0.0f, (
float)
Params::MaxTranslationDeadzone, 0.0,
"%.1f");
588 if (b_tran_zoom || b_tran_zoom_dragfloat) {
589 params_copy.translation.deadzone = (double) translation_deadzone;
590 params_changed = true;
591 }
592 ImGui::SameLine();
593 ImGui::Dummy({space_size, 0.0});
594
595 ImGui::Dummy({0.0, 0.0});
596 ImGui::SameLine(max_left_size + max_slider_txt_size - rota_size);
597 ImGui::AlignTextToFramePadding();
598 imgui.text(
_L(
"Rotation"));
599 ImGui::SameLine(max_left_size + max_slider_txt_size);
600 ImGui::PushItemWidth(imgui.scaled(6.0f));
601 float rotation_deadzone = params_copy.rotation.deadzone;
603 ImGui::SameLine();
604 ImGui::PushItemWidth(imgui.scaled(3.0f));
605 bool b_rotation2_dragfloat = ImGui::BBLDragFloat(
"##Rotation2_input", &rotation_deadzone, 0.0f,
Params::MaxRotationDeadzone, 0.0,
"%.1f");
606 if (b_rotation2 || b_rotation2_dragfloat) {
607 params_copy.rotation.deadzone = rotation_deadzone;
608 params_changed = true;
609 }
610 ImGui::SameLine();
611 ImGui::Dummy({space_size, 0.0});
612 ImGui::PopItemWidth();
613
614 ImGui::Separator();
615 ImGui::AlignTextToFramePadding();
616 imgui.text_colored(color,
_L(
"Options:"));
617 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
618
619 bool swap_yz = params_copy.swap_yz;
620 if (imgui.bbl_checkbox(
_L(
"Swap Y/Z axes"), swap_yz)) {
621 params_copy.swap_yz = swap_yz;
622 params_changed = true;
623 }
624 ImGui::Dummy({0.0, 0.0});
625 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
626 bool invert_x = params_copy.invert_x;
627 if (imgui.bbl_checkbox(
_L(
"Invert X axis"), invert_x)) {
628 params_copy.invert_x = invert_x;
629 params_changed = true;
630 }
631 ImGui::Dummy({0.0, 0.0});
632 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
633 bool invert_y = params_copy.invert_y;
634 if (imgui.bbl_checkbox(
_L(
"Invert Y axis"), invert_y)) {
635 params_copy.invert_y = invert_y;
636 params_changed = true;
637 }
638 ImGui::Dummy({0.0, 0.0});
639 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
640 bool invert_z = params_copy.invert_z;
641 if (imgui.bbl_checkbox(
_L(
"Invert Z axis"), invert_z)) {
642 params_copy.invert_z = invert_z;
643 params_changed = true;
644 }
645 ImGui::Dummy({0.0, 0.0});
646 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
647 bool invert_yaw = params_copy.invert_yaw;
648 if (imgui.bbl_checkbox(
_L(
"Invert Yaw axis"), invert_yaw)) {
649 params_copy.invert_yaw = invert_yaw;
650 params_changed = true;
651 }
652 ImGui::Dummy({0.0, 0.0});
653 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
654 bool invert_pitch = params_copy.invert_pitch;
655 if (imgui.bbl_checkbox(
_L(
"Invert Pitch axis"), invert_pitch)) {
656 params_copy.invert_pitch = invert_pitch;
657 params_changed = true;
658 }
659 ImGui::Dummy({0.0, 0.0});
660 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
661 bool invert_roll = params_copy.invert_roll;
662 if (imgui.bbl_checkbox(
_L(
"Invert Roll axis"), invert_roll)) {
663 params_copy.invert_roll = invert_roll;
664 params_changed = true;
665 }
666 ImGui::Dummy({0.0, 0.0});
667 ImGui::SameLine(max_left_size + max_slider_txt_size - imgui.get_slider_icon_size().x + + space_size);
668
669#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
670 ImGui::Separator();
671 ImGui::Separator();
672 imgui.text_colored(color, "DEBUG:");
673 imgui.text_colored(color, "Vectors:");
676 ImGui::InputFloat3("Translation##2", translation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly);
677 ImGui::InputFloat3("Rotation##3", rotation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly);
678
679 imgui.text_colored(color, "Queue size:");
680
681 int input_queue_size_current[2] = { int(
m_state.input_queue_size_current()), int(
m_state.input_queue_max_size_achieved) };
682 ImGui::InputInt2("Current", input_queue_size_current, ImGuiInputTextFlags_ReadOnly);
683
684 int input_queue_size_param = int(params_copy.input_queue_max_size);
685 if (ImGui::InputInt("Max size", &input_queue_size_param, 1, 1, ImGuiInputTextFlags_ReadOnly)) {
686 if (input_queue_size_param > 0) {
687 params_copy.input_queue_max_size = input_queue_size_param;
688 params_changed = true;
689 }
690 }
691
692 ImGui::Separator();
693 imgui.text_colored(color, "Camera:");
694 Vec3f target = wxGetApp().plater()->get_camera().get_target().cast<
float>();
695 ImGui::InputFloat3("Target", target.data(), "%.3f", ImGuiInputTextFlags_ReadOnly);
696#endif
697
698 ImGui::Separator();
699 float window_width = ImGui::GetWindowWidth();
700 ImGui::Dummy({0.0, 0.0});
701 ImGui::SameLine((window_width - imgui.calc_text_size(
_L(
"Close")).x)/2);
702 if (imgui.button(
_L(
"Close"))) {
703
705 canvas.set_as_dirty();
706 }
707 }
708 else {
709
711 canvas.set_as_dirty();
712 }
713 }
714
715 imgui.end();
716 ImGui::PopStyleVar(1);
718 if (params_changed) {
719
721 auto pthis = const_cast<Mouse3DController*>(this);
722#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
723 if (params_copy.input_queue_max_size != params_copy.input_queue_max_size)
724
725 m_state.input_queue_max_size_achieved = 0;
726#endif
727 pthis->m_params_ui = params_copy;
728 pthis->m_params_ui_changed = true;
729 }
730}
#define _L(s)
Definition OBJ.cpp:34
static void push_toolbar_style(const float scale)
Definition ImGuiWrapper.cpp:2705
static void pop_toolbar_style()
Definition ImGuiWrapper.cpp:2757
static constexpr unsigned int TranslationType
Definition Mouse3DController.hpp:95
static constexpr unsigned int RotationType
Definition Mouse3DController.hpp:96