Try to fix rotation gizmo in emboss

This commit is contained in:
Filip Sykala 2022-04-05 15:56:20 +02:00
parent 8719ec8977
commit fe697d381a
2 changed files with 22 additions and 22 deletions

View File

@ -186,6 +186,10 @@ static void draw_place_to_add_text() {
bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event) bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
{ {
if (mouse_event.Moving()) return false; if (mouse_event.Moving()) return false;
m_rotate_gizmo.on_mouse(mouse_event);
use_grabbers(mouse_event);
if (!m_dragging) return false; if (!m_dragging) return false;
assert(m_volume != nullptr); assert(m_volume != nullptr);
@ -217,11 +221,12 @@ bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
if (m_font_manager.is_activ_font()) { if (m_font_manager.is_activ_font()) {
m_font_manager.get_font_prop().angle = angle_opt; m_font_manager.get_font_prop().angle = angle_opt;
} }
return true;
} else if (mouse_event.LeftUp()) { } else if (mouse_event.LeftUp()) {
// apply rotation // apply rotation
m_parent.do_rotate(L("Text-Rotate")); m_parent.do_rotate(L("Text-Rotate"));
start_angle.reset(); start_angle.reset();
return true;
} }
return false; return false;
} }
@ -322,9 +327,9 @@ bool GLGizmoEmboss::on_mouse(const wxMouseEvent &mouse_event)
// do not process moving event // do not process moving event
if (mouse_event.Moving()) return false; if (mouse_event.Moving()) return false;
if (on_mouse_for_rotation(mouse_event)) return true; if (on_mouse_for_rotation(mouse_event)) return true;
if (on_mouse_for_translate(mouse_event)) return true; if (on_mouse_for_translate(mouse_event)) return true;
return false; return false;
} }
@ -895,29 +900,23 @@ void GLGizmoEmboss::draw_window()
m_imgui->disabled_end(); m_imgui->disabled_end();
#ifdef SHOW_CONTAIN_3MF_FIX #ifdef SHOW_CONTAIN_3MF_FIX
bool is_loaded_from_3mf = m_volume != nullptr &&
m_volume->text_configuration.has_value() &&
!m_volume->source.input_file.empty();
if (is_loaded_from_3mf) {
ImGui::SameLine();
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, m_volume->source.input_file);
}
if (m_volume!=nullptr && if (m_volume!=nullptr &&
m_volume->text_configuration.has_value() && m_volume->text_configuration.has_value() &&
m_volume->text_configuration->fix_3mf_tr.has_value()) { m_volume->text_configuration->fix_3mf_tr.has_value()) {
ImGui::SameLine(); ImGui::SameLine();
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, "3mf"); m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, ".3mf");
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
Transform3d &fix = *m_volume->text_configuration->fix_3mf_tr; Transform3d &fix = *m_volume->text_configuration->fix_3mf_tr;
std::stringstream ss; std::stringstream ss;
ss << fix.matrix(); ss << fix.matrix();
std::string filename = (m_volume->source.input_file.empty())? "unknown.3mf" :
m_volume->source.input_file + ".3mf";
ImGui::SetTooltip("Text configuation contain \n" ImGui::SetTooltip("Text configuation contain \n"
"Fix Transformation Matrix \n" "Fix Transformation Matrix \n"
"%s\n" "%s\n"
"loaded from 3mf file.", "loaded from \"%s\" file.",
ss.str().c_str()); ss.str().c_str(), filename.c_str()
);
} }
} }
#endif // SHOW_CONTAIN_3MF_FIX #endif // SHOW_CONTAIN_3MF_FIX

View File

@ -49,13 +49,7 @@ public:
/// NOTE: embossed object must be selected /// NOTE: embossed object must be selected
/// </summary> /// </summary>
void set_fine_position(); void set_fine_position();
/// <summary>
/// Rotate by text on dragging rotate grabers
/// </summary>
/// <param name="mouse_event">Information about mouse</param>
/// <returns>Propagete normaly return false.</returns>
bool on_mouse(const wxMouseEvent &mouse_event) override;
protected: protected:
bool on_init() override; bool on_init() override;
std::string on_get_name() const override; std::string on_get_name() const override;
@ -72,6 +66,13 @@ protected:
void on_start_dragging() override; void on_start_dragging() override;
void on_stop_dragging() override; void on_stop_dragging() override;
/// <summary>
/// Rotate by text on dragging rotate grabers
/// </summary>
/// <param name="mouse_event">Information about mouse</param>
/// <returns>Propagete normaly return false.</returns>
bool on_mouse(const wxMouseEvent &mouse_event) override;
bool wants_enter_leave_snapshots() const override { return true; } bool wants_enter_leave_snapshots() const override { return true; }
std::string get_gizmo_entering_text() const override { return _u8L("Enter emboss gizmo"); } std::string get_gizmo_entering_text() const override { return _u8L("Enter emboss gizmo"); }
std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); } std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); }