Hook for manipulation relativity for rotation gizmo

This commit is contained in:
Filip Sykala - NTB T15p 2022-09-13 16:21:08 +02:00
parent d0ffe16964
commit 61e2cc2403
3 changed files with 7 additions and 12 deletions

View file

@ -1,7 +1,6 @@
#include "GLGizmoEmboss.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/GUI/MainFrame.hpp" // to update title when add text
#include "slic3r/GUI/NotificationManager.hpp"
@ -131,6 +130,7 @@ GLGizmoEmboss::GLGizmoEmboss(GLCanvas3D &parent)
, m_allow_update_rendered_font(false)
{
m_rotate_gizmo.set_group_id(0);
m_rotate_gizmo.set_using_local_coordinate(true);
// TODO: add suggestion to use https://fontawesome.com/
// (copy & paste) unicode symbols from web
// paste HEX unicode into notepad move cursor after unicode press [alt] + [x]
@ -596,16 +596,6 @@ void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
void GLGizmoEmboss::on_set_state()
{
// set manipulator to be able to rotate with text
ObjectManipulation *manipul = wxGetApp().obj_manipul();
static ECoordinatesType prev_coordinate_type = ECoordinatesType::World;
if (GLGizmoBase::m_state == GLGizmoBase::Off)
manipul->set_coordinates_type(prev_coordinate_type); // set previous state
else if (GLGizmoBase::m_state == GLGizmoBase::On) {
prev_coordinate_type = manipul->get_coordinates_type();
manipul->set_coordinates_type(ECoordinatesType::Local);
}
m_rotate_gizmo.set_state(GLGizmoBase::m_state);
// Closing gizmo. e.g. selecting another one

View file

@ -286,7 +286,8 @@ void GLGizmoRotate::on_render_for_picking()
void GLGizmoRotate::init_data_from_selection(const Selection& selection)
{
ECoordinatesType coordinates_type;
if (selection.is_wipe_tower())
if (m_using_local_coordinate ||
selection.is_wipe_tower())
coordinates_type = ECoordinatesType::Local;
else
coordinates_type = wxGetApp().obj_manipul()->get_coordinates_type();

View file

@ -57,6 +57,9 @@ private:
float m_old_angle{ 0.0f };
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
// emboss need to draw rotation gizmo in local coordinate systems
bool m_using_local_coordinate{false};
ColorRGBA m_drag_color;
ColorRGBA m_highlight_color;
@ -70,6 +73,7 @@ public:
std::string get_tooltip() const override;
void set_group_id(int group_id) { m_group_id = group_id; }
void set_using_local_coordinate(bool use) { m_using_local_coordinate =use;}
void start_dragging();
void stop_dragging();