OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GizmoObjectManipulation Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp>

Collaboration diagram for Slic3r::GUI::GizmoObjectManipulation:

Classes

struct  Cache

Public Types

enum class  RotateType { None , Relative , Absolute }

Public Member Functions

 GizmoObjectManipulation (GLCanvas3D &glcanvas)
 ~GizmoObjectManipulation ()
bool IsShown ()
void UpdateAndShow (const bool show)
void update_ui_from_settings ()
void set_dirty ()
void update_if_dirty ()
void set_uniform_scaling (const bool uniform_scale)
bool get_uniform_scaling () const
void set_use_object_cs (bool flag)
bool get_use_object_cs ()
void set_coordinates_type (ECoordinatesType type)
ECoordinatesType get_coordinates_type () const
bool is_world_coordinates () const
bool is_instance_coordinates () const
bool is_local_coordinates () const
const Cache & get_cache ()
void reset_cache ()
void limit_scaling_ratio (Vec3d &scaling_factor) const
void on_change (const std::string &opt_key, int axis, double new_value)
bool render_combo (ImGuiWrapper *imgui_wrapper, const std::string &label, const std::vector< std::string > &lines, size_t &selection_idx, float label_width, float item_width)
void do_render_move_window (ImGuiWrapper *imgui_wrapper, std::string window_name, float x, float y, float bottom_limit)
void do_render_rotate_window (ImGuiWrapper *imgui_wrapper, std::string window_name, float x, float y, float bottom_limit)
void do_render_scale_input_window (ImGuiWrapper *imgui_wrapper, std::string window_name, float x, float y, float bottom_limit)
float max_unit_size (int number, Vec3d &vec1, Vec3d &vec2, std::string str)
bool reset_button (ImGuiWrapper *imgui_wrapper, bool enabled)
bool reset_zero_button (ImGuiWrapper *imgui_wrapper, bool enabled)
bool bbl_checkbox (const wxString &label, bool &value)
void set_init_rotation (const Geometry::Transformation &value)
const GLGizmoAlignment & get_alignment_helper () const
GLGizmoAlignment::AlignType get_hovered_align_type () const
bool get_align_to_parent () const
void reset_align_state ()

Public Attributes

Cache m_cache
bool m_imperial_units { false }
bool m_use_object_cs {false}
bool m_dirty = false
std::string m_new_title_string
std::string m_new_move_label_string
std::string m_new_rotate_label_string
std::string m_new_scale_label_string
std::string m_new_unit_string
Vec3d m_new_position
Vec3d m_new_rotation
Vec3d m_new_absolute_rotation
Vec3d m_new_scale
Vec3d m_new_size
Vec3d m_unscale_size
Vec3d m_buffered_position
Vec3d m_buffered_rotation
Vec3d m_buffered_absolute_rotation
Vec3d m_buffered_scale
Vec3d m_buffered_size
Vec3d cs_center
bool m_new_enabled {true}
bool m_uniform_scale {true}
ECoordinatesType m_coordinates_type {ECoordinatesType::World}
bool m_show_reset_0_rotation {false}
bool m_show_clear_rotation { false }
bool m_show_clear_scale { false }
bool m_enable_drop_to_bed { false }
RotateType m_last_rotate_type {RotateType::None}

Static Public Attributes

static const double in_to_mm = 25.4
static const double mm_to_in = 0.0393700787
static const double g_to_oz = 0.035274
static const double oz_to_g = 28.34952

Protected Attributes

float last_move_input_window_width = 0.0f
float last_rotate_input_window_width = 0.0f
float last_scale_input_window_width = 0.0f

Private Member Functions

void reset_settings_value ()
void update_settings_value (const Selection &selection)
void update_buffered_value ()
void update_reset_buttons_visibility ()
void change_position_value (int axis, double value)
void change_rotation_value (int axis, double value)
void change_absolute_rotation_value (int axis, double value)
void change_scale_value (int axis, double value)
void change_size_value (int axis, double value)
void do_scale (int axis, const Vec3d &scale) const
void reset_position_value ()
void reset_rotation_value (bool reset_relative)
void reset_scale_value ()

Private Attributes

GLCanvas3D & m_glcanvas
unsigned int m_last_active_item { 0 }
GLGizmoAlignment m_alignment_helper
GLGizmoAlignment::AlignType m_hovered_align_type {GLGizmoAlignment::AlignType::NONE}
bool m_align_to_parent {false}
bool m_can_align_within {false}
std::vector< std::pair< wxString, wxString > > m_shortcuts_move
std::vector< std::pair< wxString, wxString > > m_shortcuts_rotate
std::vector< std::pair< wxString, wxString > > m_shortcuts_scale
Vec3d m_init_rotation
Transform3d m_init_rotation_scale_tran

Detailed Description

Member Enumeration Documentation

◆ RotateType

Enumerator
None 
Relative 
Absolute 
107 { None, Relative, Absolute
108 };
@ None
Definition SketchEngine.hpp:180

Constructor & Destructor Documentation

◆ GizmoObjectManipulation()

Slic3r::GUI::GizmoObjectManipulation::GizmoObjectManipulation ( GLCanvas3D & glcanvas)
61 : m_glcanvas(glcanvas), m_alignment_helper(glcanvas)
62{
63 m_imperial_units = wxGetApp().app_config->get("use_inches") == "1";
64 m_new_unit_string = m_imperial_units ? L_CONTEXT("in", "inches") : L("mm");
65
66 const wxString shift = GUI::shortkey_shift_prefix();
67 const wxString alt = GUI::shortkey_alt_prefix();
68 const wxString ctrl = GUI::shortkey_ctrl_prefix();
69
71 {alt + _L("Left mouse button"), _L("Part selection")},
72 {ctrl + _L("Left mouse button"), _L("Select multiple objects")},
73 {shift + _L("Left mouse button"), _L("Fixed step drag")},
74 {_L("Context Menu"), _L("Toggle Auto-Drop")}
75 };
76
78 {alt + _L("Left mouse button"), _L("Part selection")},
79 {_L("Context Menu"), _L("Toggle Auto-Drop")}
80 };
81
83 {alt + _L("Left mouse button"), _L("Part selection")},
84 {shift + _L("Left mouse button"), _L("Fixed step drag")},
85 {ctrl + _L("Left mouse button"), _L("Single sided scaling")},
86 {_L("Context Menu"), _L("Toggle Auto-Drop")}
87 };
88}
#define L_CONTEXT(s, context)
Definition DesignOffer.hpp:17
#define L(s)
Definition ExtrusionEntity.cpp:25
#define _L(s)
Definition OBJ.cpp:34
std::vector< std::pair< wxString, wxString > > m_shortcuts_move
Definition GizmoObjectManipulation.hpp:195
GLGizmoAlignment m_alignment_helper
Definition GizmoObjectManipulation.hpp:186
std::vector< std::pair< wxString, wxString > > m_shortcuts_scale
Definition GizmoObjectManipulation.hpp:199
std::vector< std::pair< wxString, wxString > > m_shortcuts_rotate
Definition GizmoObjectManipulation.hpp:197
GLCanvas3D & m_glcanvas
Definition GizmoObjectManipulation.hpp:183
bool m_imperial_units
Definition GizmoObjectManipulation.hpp:68
std::string m_new_unit_string
Definition GizmoObjectManipulation.hpp:85
const std::string & shortkey_shift_prefix()
Definition GUI.cpp:109
const std::string & shortkey_alt_prefix()
Definition GUI.cpp:127
const std::string & shortkey_ctrl_prefix()
Definition GUI.cpp:115

References _L, L, L_CONTEXT, m_alignment_helper, m_glcanvas, m_imperial_units, m_new_unit_string, m_shortcuts_move, m_shortcuts_rotate, m_shortcuts_scale, Slic3r::GUI::shortkey_alt_prefix(), Slic3r::GUI::shortkey_ctrl_prefix(), and Slic3r::GUI::shortkey_shift_prefix().

Here is the call graph for this function:

◆ ~GizmoObjectManipulation()

Slic3r::GUI::GizmoObjectManipulation::~GizmoObjectManipulation ( )
inline
118{}

Member Function Documentation

◆ bbl_checkbox()

bool Slic3r::GUI::GizmoObjectManipulation::bbl_checkbox ( const wxString & label,
bool & value )
728{
729 bool result;
730 bool b_value = value;
731 if (b_value) {
732 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
733 ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
734 ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
735 }
736 auto label_utf8 = into_u8(label);
737 result = ImGui::BBLCheckbox(label_utf8.c_str(), &value);
738
739 if (b_value) { ImGui::PopStyleColor(3); }
740 return result;
741}
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References Slic3r::GUI::into_u8().

Here is the call graph for this function:

◆ change_absolute_rotation_value()

void Slic3r::GUI::GizmoObjectManipulation::change_absolute_rotation_value ( int axis,
double value )
private
380 {
381 if (std::abs(m_cache.absolute_rotation_rounded(axis) - value) < EPSILON)
382 return;
383
384 Vec3d absolute_rotation = m_cache.absolute_rotation;
385 absolute_rotation(axis) = value;
386
387 Selection &selection = m_glcanvas.get_selection();
388 TransformationType transformation_type;
389 transformation_type.set_relative();
390 if (selection.is_single_full_instance())
391 transformation_type.set_independent();
393 transformation_type.set_local();
395 transformation_type.set_instance();
396
397 selection.setup_cache();
398 auto diff_rotation = transformation_type.absolute() ? absolute_rotation : absolute_rotation - m_cache.absolute_rotation;
399 selection.rotate((M_PI / 180.0) * diff_rotation, transformation_type);
400 wxGetApp().plater()->take_snapshot("set absolute orientation", UndoRedo::SnapshotType::GizmoAction);
401 m_glcanvas.do_rotate("");
402
403 m_cache.absolute_rotation = absolute_rotation;
404 m_cache.absolute_rotation_rounded(axis) = DBL_MAX;
405 this->UpdateAndShow(true);
406}
#define EPSILON
Definition ColorUtils.cpp:64
#define M_PI
Definition ExtrusionSimulator.cpp:31
bool is_instance_coordinates() const
Definition GizmoObjectManipulation.hpp:136
bool is_local_coordinates() const
Definition GizmoObjectManipulation.hpp:137
void UpdateAndShow(const bool show)
Definition GizmoObjectManipulation.cpp:90
Cache m_cache
Definition GizmoObjectManipulation.hpp:66
@ Selection
Definition Shortcuts.hpp:72
@ GizmoAction
Definition UndoRedo.hpp:36
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

References Slic3r::GUI::TransformationType::absolute(), EPSILON, Slic3r::UndoRedo::GizmoAction, is_instance_coordinates(), is_local_coordinates(), Slic3r::GUI::Selection::is_single_full_instance(), m_cache, m_glcanvas, M_PI, Slic3r::GUI::Selection::rotate(), Slic3r::GUI::TransformationType::set_independent(), Slic3r::GUI::TransformationType::set_instance(), Slic3r::GUI::TransformationType::set_local(), Slic3r::GUI::TransformationType::set_relative(), Slic3r::GUI::Selection::setup_cache(), and UpdateAndShow().

Referenced by on_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_position_value()

void Slic3r::GUI::GizmoObjectManipulation::change_position_value ( int axis,
double value )
private
318{
319 if (std::abs(m_cache.position_rounded(axis) - value) < EPSILON)
320 return;
321
322 Vec3d position = m_cache.position;
323 position(axis) = value;
324
325 Selection& selection = m_glcanvas.get_selection();
326 selection.setup_cache();
327 TransformationType trafo_type;
328 trafo_type.set_relative();
329 switch (m_coordinates_type) {
331 trafo_type.set_instance();
332 break;
333 }
335 trafo_type.set_local();
336 break;
337 }
338 default: {
339 break;
340 }
341 }
342 selection.translate(position - m_cache.position, trafo_type);
343 wxGetApp().plater()->take_snapshot("Set Position", UndoRedo::SnapshotType::GizmoAction);
344 m_glcanvas.do_move("");
345
346 m_cache.position = position;
347 m_cache.position_rounded(axis) = DBL_MAX;
348 this->UpdateAndShow(true);
349}
ECoordinatesType m_coordinates_type
Definition GizmoObjectManipulation.hpp:101
@ Local
Definition GUI_Geometry.hpp:11
@ Instance
Definition GUI_Geometry.hpp:10

References EPSILON, Slic3r::UndoRedo::GizmoAction, Slic3r::GUI::Instance, Slic3r::GUI::Local, m_cache, m_coordinates_type, m_glcanvas, Slic3r::GUI::TransformationType::set_instance(), Slic3r::GUI::TransformationType::set_local(), Slic3r::GUI::TransformationType::set_relative(), Slic3r::GUI::Selection::setup_cache(), Slic3r::GUI::Selection::translate(), and UpdateAndShow().

Referenced by on_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_rotation_value()

void Slic3r::GUI::GizmoObjectManipulation::change_rotation_value ( int axis,
double value )
private
352{
353 if (std::abs(m_cache.rotation_rounded(axis) - value) < EPSILON)
354 return;
355
356 Vec3d rotation = m_cache.rotation;
357 rotation(axis) = value;
358
359 Selection& selection = m_glcanvas.get_selection();
360
361 TransformationType transformation_type;
362 transformation_type.set_relative();
363 if (selection.is_single_full_instance())
364 transformation_type.set_independent();
366 transformation_type.set_local();
368 transformation_type.set_instance();
369
370 selection.setup_cache();
371 selection.rotate((M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation), transformation_type);
372 wxGetApp().plater()->take_snapshot(_u8L("Set orientation"), UndoRedo::SnapshotType::GizmoAction);
373 m_glcanvas.do_rotate("");
374
375 m_cache.rotation = rotation;
376 m_cache.rotation_rounded(axis) = DBL_MAX;
377 this->UpdateAndShow(true);
378}
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, Slic3r::GUI::TransformationType::absolute(), EPSILON, Slic3r::UndoRedo::GizmoAction, is_instance_coordinates(), is_local_coordinates(), Slic3r::GUI::Selection::is_single_full_instance(), m_cache, m_glcanvas, M_PI, Slic3r::GUI::Selection::rotate(), Slic3r::GUI::TransformationType::set_independent(), Slic3r::GUI::TransformationType::set_instance(), Slic3r::GUI::TransformationType::set_local(), Slic3r::GUI::TransformationType::set_relative(), Slic3r::GUI::Selection::setup_cache(), and UpdateAndShow().

Referenced by on_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_scale_value()

void Slic3r::GUI::GizmoObjectManipulation::change_scale_value ( int axis,
double value )
private
409{
410 if (value <= 0.0)
411 return;
412 if (std::abs(m_cache.scale_rounded(axis) - value) < EPSILON) {
413 m_show_clear_scale = (m_cache.scale / 100.0f - Vec3d::Ones()).norm() > 0.001;
414 return;
415 }
416 Vec3d scale = m_cache.scale;
417 scale(axis) = value;
418 Vec3d ref_scale = m_cache.scale;
419 const Selection &selection = m_glcanvas.get_selection();
420 if (selection.is_single_volume_or_modifier()) {
421 scale = scale.cwiseQuotient(ref_scale); // scale / ref_scale
422 ref_scale = Vec3d::Ones();
423 } else if (selection.is_single_full_instance())
424 ref_scale = 100 * Vec3d::Ones();
425 this->do_scale(axis, scale.cwiseQuotient(ref_scale));
426
427 m_cache.scale = scale;
428 m_cache.scale_rounded(axis) = DBL_MAX;
429 this->UpdateAndShow(true);
430}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
bool m_show_clear_scale
Definition GizmoObjectManipulation.hpp:105
void do_scale(int axis, const Vec3d &scale) const
Definition GizmoObjectManipulation.cpp:463

References do_scale(), EPSILON, Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), m_cache, m_glcanvas, m_show_clear_scale, scale(), and UpdateAndShow().

Referenced by on_change(), and reset_scale_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_size_value()

void Slic3r::GUI::GizmoObjectManipulation::change_size_value ( int axis,
double value )
private
434{
435 if (value <= 0.0)
436 return;
437 if (std::abs(m_cache.size_rounded(axis) - value) < EPSILON)
438 return;
439
440 Vec3d size = m_cache.size;
441 size(axis) = value;
442
443 const Selection& selection = m_glcanvas.get_selection();
444
445 Vec3d ref_size = m_cache.size;
446 if (selection.is_single_volume_or_modifier()) {
447 size = size.cwiseQuotient(ref_size);
448 ref_size = Vec3d::Ones();
449 } else if (selection.is_single_full_instance()) {
451 ref_size = selection.get_full_unscaled_instance_bounding_box().size();
452 else
453 ref_size = selection.get_full_unscaled_instance_local_bounding_box().size();
454 }
455
456 this->do_scale(axis, size.cwiseQuotient(ref_size));
457
458 m_cache.size = size;
459 m_cache.size_rounded(axis) = DBL_MAX;
460 this->UpdateAndShow(true);
461}
bool is_world_coordinates() const
Definition GizmoObjectManipulation.hpp:135

References do_scale(), EPSILON, Slic3r::GUI::Selection::get_full_unscaled_instance_bounding_box(), Slic3r::GUI::Selection::get_full_unscaled_instance_local_bounding_box(), Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), is_world_coordinates(), m_cache, m_glcanvas, Slic3r::BoundingBox3Base< PointType >::size(), and UpdateAndShow().

Referenced by on_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_render_move_window()

void Slic3r::GUI::GizmoObjectManipulation::do_render_move_window ( ImGuiWrapper * imgui_wrapper,
std::string window_name,
float x,
float y,
float bottom_limit )
756{
757 float scale = m_glcanvas.get_scale();
758#ifdef WIN32
759 scale *= (float)get_dpi_for_window(wxGetApp().GetTopWindow()) / (float)DPI_DEFAULT;
760#endif // WIN32
761
762 // BBS: GUI refactor: move gizmo to the right
763 if (abs(last_move_input_window_width) > 0.01f) {
764 if (x + last_move_input_window_width > m_glcanvas.get_canvas_size().get_width()) {
765 if (last_move_input_window_width > m_glcanvas.get_canvas_size().get_width())
766 x = 0;
767 else
768 x = m_glcanvas.get_canvas_size().get_width() - last_move_input_window_width;
769 }
770 }
771#if BBS_TOOLBAR_ON_TOP
772 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 0.f, 0.0f);
773#else
774 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f);
775#endif
776
777 // BBS
779 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 6.0));
780
781 const ImGuiStyle &style = ImGui::GetStyle();
782
783 std::string name = this->m_new_title_string + "##" + window_name;
784 imgui_wrapper->begin(_L(name), ImGuiWrapper::TOOLBAR_WINDOW_FLAGS);
785
786 auto update = [this](unsigned int active_id, std::string opt_key, Vec3d original_value, Vec3d new_value) -> int {
787 for (int i = 0; i < 3; i++) {
788 if (original_value[i] != new_value[i]) {
789 if (active_id != m_last_active_item) {
790 on_change(opt_key, i, new_value[i]);
791 return i;
792 }
793 }
794 }
795 return -1;
796 };
797
798 float space_size = imgui_wrapper->get_style_scaling() * 8;
799 // The align section shares the combo width, the caption column and the input columns of the position row.
800 const bool show_align = m_glcanvas.get_canvas_type() == GLCanvas3D::ECanvasType::CanvasView3D &&
801 !m_glcanvas.get_selection().is_wipe_tower();
802 //ORCA
803 float coord_combo_width = std::max({
804 imgui_wrapper->calc_text_size(_L("World")).x,
805 imgui_wrapper->calc_text_size(_L("Object")).x,
806 imgui_wrapper->calc_text_size(_L("Part")).x
807 });
808 float label_max = std::max({
809 imgui_wrapper->calc_text_size(_L("Position")).x,
810 imgui_wrapper->calc_text_size(_L("Relative")).x
811 });
812 if (show_align) {
813 coord_combo_width = std::max({coord_combo_width, imgui_wrapper->calc_text_size(_L("Selection")).x,
814 imgui_wrapper->calc_text_size(_L("Object")).x,
815 imgui_wrapper->calc_text_size(_L("Plate")).x});
816 label_max = std::max(label_max, imgui_wrapper->calc_text_size(_L("Distribute")).x);
817 }
818 coord_combo_width += imgui_wrapper->calc_text_size("xxx"sv).x + imgui_wrapper->scaled(3.5f);
819 float caption_max = std::max(label_max, coord_combo_width - 3 * space_size);
820 float end_text_size = imgui_wrapper->calc_text_size(this->m_new_unit_string).x;
821
822 // position
823 Vec3d original_position;
824 if (this->m_imperial_units)
825 original_position = this->m_new_position * this->mm_to_in;
826 else
827 original_position = this->m_new_position;
828 Vec3d display_position = m_buffered_position;
829
830 // Rotation
831 float unit_size = imgui_wrapper->calc_text_size(MAX_SIZE).x + space_size;
832 // Four align buttons sit under each axis' input, a space before the next axis, so the inputs widen to hold them.
833 const float align_icon_size = 16.f * scale;
834 const float align_button_size = align_icon_size + 2.f * style.FramePadding.x; // ORCA
835 if (show_align) {
836 unit_size = std::max(unit_size, 3.f * align_button_size);
837 unit_size = std::round(unit_size); // ORCA keep columns on whole pixels
838 }
839 int index = 1;
840 int index_unit = 1;
841
842 ImGui::AlignTextToFramePadding();
843 unsigned int current_active_id = ImGui::GetActiveID();
844
845 Selection & selection = m_glcanvas.get_selection();
846 std::vector<std::string> modes = {_u8L("World"), _u8L("Object")};//_u8L("Part") // ORCA use shorter terms to make UI more compact
847 if (selection.is_multiple_full_object() || selection.is_wipe_tower()) {
848 modes.pop_back();
849 }
850 size_t selection_idx = (int) m_coordinates_type;
851 if (selection_idx >= modes.size()) {
853 selection_idx = 0;
854 }
855
857 bool combox_changed = false;
858 if (render_combo(imgui_wrapper, "", modes, selection_idx, 0, coord_combo_width)) {
859 combox_changed = true;
860 }
862 // After pop_combo_style(): its light popup background would hide the tooltip's white text.
863 if (ImGui::IsItemHovered()) {
864 auto tooltip_str = _L("Coordinate system used for transform actions.");
865 imgui_wrapper->tooltip(tooltip_str, imgui_wrapper->calc_text_size(tooltip_str).x + 3 * space_size);
866 }
867
868 // ORCA use TextColored to match axes color
869 float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2;
870 ImGui::SameLine(caption_max + index * space_size + offset_to_center);
871 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X");
872 ImGui::SameLine(caption_max + unit_size + (++index) * space_size + offset_to_center);
873 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y");
874 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center);
875 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z");
876
877 index = 1;
878 index_unit = 1;
879 ImGui::AlignTextToFramePadding();
880 if (selection.is_single_full_instance() && is_instance_coordinates()) {
881 imgui_wrapper->text(_L("Relative")); // ORCA
882 }
883 else {
884 imgui_wrapper->text(_L("Position"));
885 }
886
887 ImGui::SameLine(caption_max + index * space_size);
888 ImGui::PushItemWidth(unit_size);
889 ImGui::BBLInputDouble(label_values[0][0], &display_position[0], 0.0f, 0.0f, "%.2f");
890 ImGui::SameLine(caption_max + unit_size + (++index) * space_size);
891 ImGui::PushItemWidth(unit_size);
892 ImGui::BBLInputDouble(label_values[0][1], &display_position[1], 0.0f, 0.0f, "%.2f");
893 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
894 ImGui::PushItemWidth(unit_size);
895 ImGui::BBLInputDouble(label_values[0][2], &display_position[2], 0.0f, 0.0f, "%.2f");
896 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
897 imgui_wrapper->text(this->m_new_unit_string);
898 bool is_avoid_one_update{false};
899 if (combox_changed) {
900 combox_changed = false;
901 set_coordinates_type((ECoordinatesType) selection_idx);
902 UpdateAndShow(true);
903 is_avoid_one_update = true; // avoid update(current_active_id, "position", original_position
904 }
905
906 if (!is_avoid_one_update) {
907 for (int i = 0; i < display_position.size(); i++) {
908 if (display_position[i] > MAX_NUM) display_position[i] = MAX_NUM;
909 if (display_position[i] < -MAX_NUM) display_position[i] = -MAX_NUM;
910 }
911 m_buffered_position = display_position;
912 update(current_active_id, "position", original_position, m_buffered_position);
913 }
914 // the init position values are not zero, won't add reset button
915
916 // send focus to m_glcanvas
917 bool focued_on_text = false;
918 for (int j = 0; j < 3; j++) {
919 unsigned int id = ImGui::GetID(label_values[0][j]);
920 if (current_active_id == id) {
921 m_glcanvas.handle_sidebar_focus_event(label_values[0][j] + 2, true);
922 focued_on_text = true;
923 break;
924 }
925 }
926 if (!focued_on_text) m_glcanvas.handle_sidebar_focus_event("", false);
927
928 // Align and distribute along the coordinate system of the panel, within the selection or to the object or plate holding it.
929 using AlignType = GLGizmoAlignment::AlignType;
930 const bool old_align_to_parent = m_align_to_parent;
931 AlignType hovered_align_type = AlignType::NONE;
932 if (show_align) {
933 ImGui::Spacing();
934 ImGui::Separator();
935 ImGui::Spacing();
937
938 // Each row is row_height tall, separated by ItemSpacing.y. Every control is centered vertically in its row.
939 const float row_y = ImGui::GetCursorPosY();
940 const float button_height = align_icon_size + 2.f * style.FramePadding.y;
942 const float combo_height = ImGui::GetFrameHeight();
944 const float row_height = std::max({ImGui::GetTextLineHeight(), button_height, combo_height});
945 const float row_gap = style.ItemSpacing.y;
946 int row = 0;
947 auto row_top = [&](int r) { return row_y + r * (row_height + row_gap); };
948 // Snap to whole pixels to avoid blurry icons
949 auto center_in_row = [&](int r, float item_height) { return std::floor(row_top(r) + (row_height - item_height) * 0.5f); };
950
951 // Row 0: align mode combo in the caption column.
952 ImGui::SetCursorPosY(center_in_row(row, combo_height));
953
954 // The last mode aligns to the parent. Aligning within the selection needs two items.
955 std::vector<std::string> align_modes = {
956 _u8L("Selection"),
957 m_alignment_helper.is_parts_selection(true) ? _u8L("Object") : _u8L("Plate")
958 };
959 // Selecting enough items to align within them makes that the default, as when the tool opens.
960 const bool can_align_within = m_alignment_helper.can_align(AlignType::X_MIN);
961 if (can_align_within != m_can_align_within) {
962 m_can_align_within = can_align_within;
963 m_align_to_parent = !can_align_within;
964 }
965 if (!can_align_within) {
966 align_modes.erase(align_modes.begin());
967 m_align_to_parent = true;
968 }
969 size_t align_mode_idx = m_align_to_parent ? align_modes.size() - 1 : 0;
971 // render_combo() takes its ImGui id from the empty label, which the coordinate combo uses too.
972 ImGui::PushID("align_mode");
973 if (render_combo(imgui_wrapper, "", align_modes, align_mode_idx, 0, coord_combo_width))
974 m_align_to_parent = align_mode_idx + 1 == align_modes.size();
975 ImGui::PopID();
977 // After pop_combo_style(): its light popup background would hide the tooltip's white text.
978 if (ImGui::IsItemHovered()) {
979 wxString tooltip_str = _L("Reference for alignment");
980 imgui_wrapper->tooltip(tooltip_str, imgui_wrapper->calc_text_size(tooltip_str).x + 3 * space_size);
981 }
982
983 const bool dark_mode = wxGetApp().dark_mode();
984 int current_axis = -1;
985 auto align_icon = [&](int axis, AlignType type, GLGizmosManager::MENU_ICON_NAME icon,
986 GLGizmosManager::MENU_ICON_NAME dark_icon, const wxString &tip) {
987 const bool distribute = type >= AlignType::DISTRIBUTE_X;
988 const bool enabled = m_align_to_parent ? m_alignment_helper.can_align(type, true) :
989 distribute ? m_alignment_helper.can_distribute(type) :
990 m_alignment_helper.can_align(type);
991 if (axis != current_axis) {
992 ImGui::SameLine(int(caption_max + (axis + 1) * space_size + axis * unit_size)); // ORCA ensure placement snaps to pixel to fix blur
993 if (current_axis < 0)
994 ImGui::SetCursorPosY(center_in_row(row, button_height));
995 current_axis = axis;
996 } else
997 ImGui::SameLine(0, 0);
998
999 if (!enabled) {
1000 ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3f);
1001 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_Button]);
1002 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyle().Colors[ImGuiCol_Button]);
1003 }
1004 ImTextureID texture = m_glcanvas.get_gizmos_manager().get_icon_texture_id(dark_mode ? dark_icon : icon);
1005 if (ImGui::ImageButton3(texture, texture, ImVec2(align_icon_size, align_icon_size)) && enabled) {
1006 if (distribute)
1007 m_alignment_helper.distribute_objects(type);
1008 else
1009 m_alignment_helper.align_objects(type, m_align_to_parent);
1010 }
1011 if (!enabled) {
1012 ImGui::PopStyleColor(2);
1013 ImGui::PopStyleVar();
1014 }
1015
1016 if (ImGui::IsItemHovered()) {
1017 wxString text = tip;
1018 if (enabled)
1019 hovered_align_type = type;
1020 else {
1021 // Too few items is the reason when there are items to move (only distribute needs three);
1022 // otherwise the helper names it.
1023 std::string why_not;
1024 if (m_alignment_helper.get_items_count(type, m_align_to_parent, &why_not) > 0)
1025 why_not = _u8L("Select at least 3 parts or objects");
1026 if (!why_not.empty())
1027 text += "\n" + from_u8(why_not);
1028 }
1029 imgui_wrapper->tooltip(text, imgui_wrapper->calc_text_size(text).x + 3 * space_size);
1030 }
1031 };
1032 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
1033 align_icon(0, AlignType::X_MIN, GLGizmosManager::IC_ALIGN_X_MIN, GLGizmosManager::IC_ALIGN_X_MIN_DARK, _L("Align left") + " (-X)");
1034 align_icon(0, AlignType::CENTER_X, GLGizmosManager::IC_ALIGN_X_CENTER, GLGizmosManager::IC_ALIGN_X_CENTER_DARK, _L("Align left-right center") + " (X)");
1035 align_icon(0, AlignType::X_MAX, GLGizmosManager::IC_ALIGN_X_MAX, GLGizmosManager::IC_ALIGN_X_MAX_DARK, _L("Align right") + " (+X)");
1036
1037 align_icon(1, AlignType::Y_MIN, GLGizmosManager::IC_ALIGN_Y_MIN, GLGizmosManager::IC_ALIGN_Y_MIN_DARK, _L("Align front") + " (-Y)");
1038 align_icon(1, AlignType::CENTER_Y, GLGizmosManager::IC_ALIGN_Y_CENTER, GLGizmosManager::IC_ALIGN_Y_CENTER_DARK, _L("Align front-back center") + " (Y)");
1039 align_icon(1, AlignType::Y_MAX, GLGizmosManager::IC_ALIGN_Y_MAX, GLGizmosManager::IC_ALIGN_Y_MAX_DARK, _L("Align back") + " (+Y)");
1040
1041 align_icon(2, AlignType::Z_MIN, GLGizmosManager::IC_ALIGN_Z_MIN, GLGizmosManager::IC_ALIGN_Z_MIN_DARK, _L("Align bottom") + " (-Z)");
1042 align_icon(2, AlignType::CENTER_Z, GLGizmosManager::IC_ALIGN_Z_CENTER, GLGizmosManager::IC_ALIGN_Z_CENTER_DARK, _L("Align top-bottom center") + " (Z)");
1043 align_icon(2, AlignType::Z_MAX, GLGizmosManager::IC_ALIGN_Z_MAX, GLGizmosManager::IC_ALIGN_Z_MAX_DARK, _L("Align top") + " (+Z)");
1044
1045 if (!m_align_to_parent) {
1046 row = 1;
1047 current_axis = -1;
1048 ImGui::SetCursorPosY(center_in_row(row, ImGui::GetTextLineHeight()));
1049 imgui_wrapper->text(_L("Distribute"));
1050 align_icon(0, AlignType::DISTRIBUTE_X, GLGizmosManager::IC_DISTRIBUTE_X, GLGizmosManager::IC_DISTRIBUTE_X_DARK, _L("Distribute left-right") + " (X)");
1051 align_icon(1, AlignType::DISTRIBUTE_Y, GLGizmosManager::IC_DISTRIBUTE_Y, GLGizmosManager::IC_DISTRIBUTE_Y_DARK, _L("Distribute front-back") + " (Y)");
1052 align_icon(2, AlignType::DISTRIBUTE_Z, GLGizmosManager::IC_DISTRIBUTE_Z, GLGizmosManager::IC_DISTRIBUTE_Z_DARK, _L("Distribute top-bottom") + " (Z)");
1053 }
1054 ImGui::PopStyleVar();
1055 ImGui::SetCursorPosY(row_top(row + 1));
1056 }
1057 // The Move gizmo draws the preview with the scene, which an ImGui-only frame does not redraw.
1058 if (hovered_align_type != m_hovered_align_type || m_align_to_parent != old_align_to_parent) {
1059 m_hovered_align_type = hovered_align_type;
1060 m_glcanvas.set_as_dirty();
1061 m_glcanvas.request_extra_frame();
1062 }
1063
1064 ImGui::Spacing();
1065 ImGui::Separator();
1066 ImGui::Spacing();
1067 float f_scale = m_glcanvas.get_gizmos_manager().get_layout_scale();
1068 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f * f_scale));
1069
1071
1072 // ORCA use existing function for drop and show button on bottom bar to keep gizmo compact
1073 imgui_wrapper->disabled_begin(!m_enable_drop_to_bed);
1074 ImGui::SameLine(0, space_size * 1.5f);
1075 if (imgui_wrapper->button(_L("Drop"))){
1076 wxGetApp().plater()->drop_selection();
1077 UpdateAndShow(true);
1078 }
1079 imgui_wrapper->disabled_end();
1080 if(ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
1081 imgui_wrapper->tooltip(_L("Move the selection along Z so that its lowest point touches the bed."), ImGui::GetFontSize() * 20.0f);
1082
1083 ImGui::SameLine();
1085 if (imgui_wrapper->button(_L("Done"))) {
1086 m_glcanvas.reset_all_gizmos();
1087 }
1088
1089 m_last_active_item = current_active_id;
1090 last_move_input_window_width = ImGui::GetWindowWidth();
1091 ImGui::PopStyleVar();
1092 imgui_wrapper->end();
1093 ImGui::PopStyleVar();
1095}
#define MAX_SIZE
Definition GizmoObjectManipulation.cpp:46
#define MAX_NUM
Definition GizmoObjectManipulation.cpp:45
#define style
Definition WipeTowerDialog.cpp:101
static const ColorRGBA Y()
Definition Color.hpp:146
static const ColorRGBA X()
Definition Color.hpp:145
static const ColorRGBA Z()
Definition Color.hpp:147
@ CanvasView3D
Definition GLCanvas3D.hpp:626
AlignType
Definition GLGizmoAlignment.hpp:19
MENU_ICON_NAME
Definition GLGizmosManager.hpp:179
@ IC_ALIGN_Z_CENTER
Definition GLGizmosManager.hpp:211
@ IC_DISTRIBUTE_Y
Definition GLGizmosManager.hpp:214
@ IC_ALIGN_Y_MAX
Definition GLGizmosManager.hpp:209
@ IC_ALIGN_X_CENTER_DARK
Definition GLGizmosManager.hpp:217
@ IC_ALIGN_X_CENTER
Definition GLGizmosManager.hpp:205
@ IC_ALIGN_Y_MAX_DARK
Definition GLGizmosManager.hpp:221
@ IC_DISTRIBUTE_X
Definition GLGizmosManager.hpp:213
@ IC_DISTRIBUTE_X_DARK
Definition GLGizmosManager.hpp:225
@ IC_DISTRIBUTE_Z
Definition GLGizmosManager.hpp:215
@ IC_ALIGN_X_MAX
Definition GLGizmosManager.hpp:206
@ IC_ALIGN_X_MIN
Definition GLGizmosManager.hpp:204
@ IC_DISTRIBUTE_Y_DARK
Definition GLGizmosManager.hpp:226
@ IC_ALIGN_Y_MIN
Definition GLGizmosManager.hpp:207
@ IC_ALIGN_Z_MIN_DARK
Definition GLGizmosManager.hpp:222
@ IC_ALIGN_Y_CENTER_DARK
Definition GLGizmosManager.hpp:220
@ IC_ALIGN_Z_MAX_DARK
Definition GLGizmosManager.hpp:224
@ IC_ALIGN_Z_MAX
Definition GLGizmosManager.hpp:212
@ IC_DISTRIBUTE_Z_DARK
Definition GLGizmosManager.hpp:227
@ IC_ALIGN_X_MIN_DARK
Definition GLGizmosManager.hpp:216
@ IC_ALIGN_X_MAX_DARK
Definition GLGizmosManager.hpp:218
@ IC_ALIGN_Z_MIN
Definition GLGizmosManager.hpp:210
@ IC_ALIGN_Y_MIN_DARK
Definition GLGizmosManager.hpp:219
@ IC_ALIGN_Y_CENTER
Definition GLGizmosManager.hpp:208
@ IC_ALIGN_Z_CENTER_DARK
Definition GLGizmosManager.hpp:223
void set_coordinates_type(ECoordinatesType type)
Definition GizmoObjectManipulation.cpp:628
Vec3d m_buffered_position
Definition GizmoObjectManipulation.hpp:92
void on_change(const std::string &opt_key, int axis, double new_value)
Definition GizmoObjectManipulation.cpp:492
bool m_enable_drop_to_bed
Definition GizmoObjectManipulation.hpp:106
std::string m_new_title_string
Definition GizmoObjectManipulation.hpp:81
float last_move_input_window_width
Definition GizmoObjectManipulation.hpp:112
GLGizmoAlignment::AlignType m_hovered_align_type
Definition GizmoObjectManipulation.hpp:188
bool render_combo(ImGuiWrapper *imgui_wrapper, const std::string &label, const std::vector< std::string > &lines, size_t &selection_idx, float label_width, float item_width)
Definition GizmoObjectManipulation.cpp:512
Vec3d m_new_position
Definition GizmoObjectManipulation.hpp:86
static const double mm_to_in
Definition GizmoObjectManipulation.hpp:31
unsigned int m_last_active_item
Definition GizmoObjectManipulation.hpp:184
bool m_can_align_within
Definition GizmoObjectManipulation.hpp:192
bool m_align_to_parent
Definition GizmoObjectManipulation.hpp:190
static void push_toolbar_style(const float scale)
Definition ImGuiWrapper.cpp:2705
static ImVec4 to_ImVec4(const ColorRGB &color)
Definition ImGuiWrapper.cpp:1053
static void pop_combo_style()
Definition ImGuiWrapper.cpp:2932
static void pop_toolbar_style()
Definition ImGuiWrapper.cpp:2757
static void push_combo_style(const float scale)
Definition ImGuiWrapper.cpp:2907
static int TOOLBAR_WINDOW_FLAGS
Definition ImGuiWrapper.hpp:435
void begin_right_aligned_buttons(const std::vector< wxString > &labels)
Definition GLGizmoUtils.cpp:135
void render_tooltip_button(ImGuiWrapper *imgui_wrapper, const GLCanvas3D &canvas, const std::vector< std::pair< wxString, wxString > > &shortcuts, float x, float y)
Definition GLGizmoUtils.cpp:48
int get_dpi_for_window(const wxWindow *window)
Definition GUI_Utils.cpp:234
static const char * label_values[3][3]
Definition GizmoObjectManipulation.cpp:645
ECoordinatesType
Definition GUI_Geometry.hpp:8
@ World
Definition GUI_Geometry.hpp:9
@ DPI_DEFAULT
Definition GUI_Utils.hpp:92
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, _u8L, Slic3r::GUI::ImGuiWrapper::begin(), Slic3r::GUI::GLGizmoUtils::begin_right_aligned_buttons(), Slic3r::GUI::ImGuiWrapper::button(), Slic3r::GUI::ImGuiWrapper::calc_text_size(), Slic3r::GUI::GLCanvas3D::CanvasView3D, Slic3r::GUI::ImGuiWrapper::disabled_begin(), Slic3r::GUI::ImGuiWrapper::disabled_end(), Slic3r::GUI::DPI_DEFAULT, Slic3r::GUI::ImGuiWrapper::end(), Slic3r::GUI::from_u8(), Slic3r::GUI::get_dpi_for_window(), Slic3r::GUI::ImGuiWrapper::get_style_scaling(), Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_CENTER, Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_CENTER_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_MAX, Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_MAX_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_MIN, Slic3r::GUI::GLGizmosManager::IC_ALIGN_X_MIN_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_CENTER, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_CENTER_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_MAX, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_MAX_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_MIN, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Y_MIN_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_CENTER, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_CENTER_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_MAX, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_MAX_DARK, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_MIN, Slic3r::GUI::GLGizmosManager::IC_ALIGN_Z_MIN_DARK, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_X, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_X_DARK, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_Y, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_Y_DARK, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_Z, Slic3r::GUI::GLGizmosManager::IC_DISTRIBUTE_Z_DARK, is_instance_coordinates(), Slic3r::GUI::Selection::is_multiple_full_object(), Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_wipe_tower(), Slic3r::GUI::label_values, last_move_input_window_width, m_align_to_parent, m_alignment_helper, m_buffered_position, m_can_align_within, m_coordinates_type, m_enable_drop_to_bed, m_glcanvas, m_hovered_align_type, m_imperial_units, m_last_active_item, m_new_position, m_new_title_string, m_new_unit_string, m_shortcuts_move, MAX_NUM, MAX_SIZE, mm_to_in, on_change(), Slic3r::GUI::ImGuiWrapper::pop_combo_style(), Slic3r::GUI::ImGuiWrapper::pop_toolbar_style(), Slic3r::GUI::ImGuiWrapper::push_combo_style(), Slic3r::GUI::ImGuiWrapper::push_toolbar_style(), render_combo(), Slic3r::GUI::GLGizmoUtils::render_tooltip_button(), scale(), Slic3r::GUI::ImGuiWrapper::scaled(), set_coordinates_type(), Slic3r::GUI::ImGuiWrapper::set_next_window_pos(), style, Slic3r::GUI::ImGuiWrapper::text(), Slic3r::GUI::ImGuiWrapper::to_ImVec4(), Slic3r::GUI::ImGuiWrapper::TOOLBAR_WINDOW_FLAGS, Slic3r::GUI::ImGuiWrapper::tooltip(), UpdateAndShow(), Slic3r::GUI::World, Slic3r::ColorRGBA::X(), Slic3r::ColorRGBA::Y(), and Slic3r::ColorRGBA::Z().

Here is the call graph for this function:

◆ do_render_rotate_window()

void Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window ( ImGuiWrapper * imgui_wrapper,
std::string window_name,
float x,
float y,
float bottom_limit )
1098{
1099 // BBS: GUI refactor: move gizmo to the right
1100 if (abs(last_rotate_input_window_width) > 0.01f) {
1101 if (x + last_rotate_input_window_width > m_glcanvas.get_canvas_size().get_width()) {
1102 if (last_rotate_input_window_width > m_glcanvas.get_canvas_size().get_width())
1103 x = 0;
1104 else
1105 x = m_glcanvas.get_canvas_size().get_width() - last_rotate_input_window_width;
1106 }
1107 }
1108#if BBS_TOOLBAR_ON_TOP
1109 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 0.f, 0.0f);
1110#else
1111 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f);
1112#endif
1113
1114 // BBS
1116 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 6.0));
1117
1118 std::string name = this->m_new_title_string + "##" + window_name;
1119 imgui_wrapper->begin(_L(name), ImGuiWrapper::TOOLBAR_WINDOW_FLAGS);
1120
1121 auto update = [this](unsigned int active_id, std::string opt_key, Vec3d original_value, Vec3d new_value) -> int {
1122 for (int i = 0; i < 3; i++) {
1123 if (original_value[i] != new_value[i]) {
1124 if (active_id != m_last_active_item) {
1125 on_change(opt_key, i, new_value[i]);
1126 return i;
1127 }
1128 }
1129 }
1130 return -1;
1131 };
1132
1133 float space_size = imgui_wrapper->get_style_scaling() * 8;
1134 // ORCA
1135 float caption_max = std::max({
1136 imgui_wrapper->calc_text_size(_L("Relative")).x,
1137 imgui_wrapper->calc_text_size(_L("Absolute")).x,
1138 imgui_wrapper->calc_text_size(_L("World")).x
1139 //imgui_wrapper->calc_text_size(_L("Object")).x,
1140 //imgui_wrapper->calc_text_size(_L("Part")).x
1141 }) + 3.f * space_size;
1142 float end_text_size = ImGui::CalcTextSize("°").x; // ORCA rotate gizmo not uses mm or inch
1143
1144 // position
1145 Vec3d original_position;
1146 if (this->m_imperial_units)
1147 original_position = this->m_new_position * this->mm_to_in;
1148 else
1149 original_position = this->m_new_position;
1150 Vec3d display_position = m_buffered_position;
1151 // Rotation
1152 Vec3d rotation = this->m_buffered_rotation;
1153 Vec3d absolute_rotation = this->m_buffered_absolute_rotation;
1154 float unit_size = imgui_wrapper->calc_text_size(MAX_SIZE).x + space_size;
1155 int index = 1;
1156 int index_unit = 1;
1157
1158 ImGui::AlignTextToFramePadding();
1159 unsigned int current_active_id = ImGui::GetActiveID();
1160 ImGui::PushItemWidth(caption_max);
1161 imgui_wrapper->text(_L("World")); // ORCA
1162 if (ImGui::IsItemHovered()) {
1163 auto tooltip_str = _L("Coordinate system used for transform actions.");
1164 imgui_wrapper->tooltip(tooltip_str, imgui_wrapper->calc_text_size(tooltip_str).x + 3 * space_size);
1165 }
1166 // ORCA use TextColored to match axes color
1167 float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2;
1168 ImGui::SameLine(caption_max + index * space_size + offset_to_center);
1169 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X");
1170 ImGui::SameLine(caption_max + unit_size + (++index) * space_size + offset_to_center);
1171 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y");
1172 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center);
1173 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z");
1174
1175 index = 1;
1176 index_unit = 1;
1177
1178 // ImGui::PushItemWidth(unit_size * 2);
1179 bool is_relative_input = false;
1180 ImGui::AlignTextToFramePadding();
1181 imgui_wrapper->text(_L("Relative")); // ORCA
1182 ImGui::SameLine(caption_max + index * space_size);
1183 ImGui::PushItemWidth(unit_size);
1184 if (ImGui::BBLInputDouble(label_values[1][0], &rotation[0], 0.0f, 0.0f, "%.2f")) {
1185 is_relative_input = true;
1186 }
1187 ImGui::SameLine(caption_max + unit_size + (++index) * space_size);
1188 ImGui::PushItemWidth(unit_size);
1189 if (ImGui::BBLInputDouble(label_values[1][1], &rotation[1], 0.0f, 0.0f, "%.2f")) {
1190 is_relative_input = true;
1191 }
1192 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
1193 ImGui::PushItemWidth(unit_size);
1194 if (ImGui::BBLInputDouble(label_values[1][2], &rotation[2], 0.0f, 0.0f, "%.2f")) {
1195 is_relative_input = true;
1196 }
1197 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
1198 imgui_wrapper->text("°");
1199 m_buffered_rotation = rotation;
1200 if (is_relative_input) {
1202 }
1204 bool is_valid = update(current_active_id, "rotation", this->m_new_rotation, m_buffered_rotation) >= 0;
1205 if (is_valid) {
1207 }
1208 }
1209
1210 ImGui::SameLine(caption_max + index_unit * unit_size + (++index) * space_size + end_text_size);
1211 if (reset_button(imgui_wrapper, m_show_clear_rotation)) // ORCA reserve icon space to prevent changes on layout
1213 if (m_show_clear_rotation && ImGui::IsItemHovered()) {
1214 float tooltip_size = imgui_wrapper->calc_text_size(_L("Reset current rotation to the value when open the rotation tool.")).x + 3 * space_size;
1215 imgui_wrapper->tooltip(_u8L("Reset current rotation to the value when open the rotation tool."), tooltip_size);
1216 }
1217
1218 // send focus to m_glcanvas
1219 bool focued_on_text = false;
1220 for (int j = 0; j < 3; j++) {
1221 unsigned int id = ImGui::GetID(label_values[1][j]);
1222 if (current_active_id == id) {
1223 m_glcanvas.handle_sidebar_focus_event(label_values[1][j] + 2, true);
1224 focued_on_text = true;
1225 break;
1226 }
1227 }
1228
1229 index = 1;
1230 index_unit = 1;
1231 ImGui::AlignTextToFramePadding();
1232 imgui_wrapper->text(_L("Absolute"));
1233 ImGui::SameLine(caption_max + index * space_size);
1234 ImGui::PushItemWidth(unit_size);
1235 bool is_absolute_input = false;
1236 if (ImGui::BBLInputDouble(label_values[2][0], &absolute_rotation[0], 0.0f, 0.0f, "%.2f")) {
1237 is_absolute_input = true;
1238 }
1239 ImGui::SameLine(caption_max + unit_size + (++index) * space_size);
1240 ImGui::PushItemWidth(unit_size);
1241 if (ImGui::BBLInputDouble(label_values[2][1], &absolute_rotation[1], 0.0f, 0.0f, "%.2f")) {
1242 is_absolute_input = true;
1243 }
1244 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
1245 ImGui::PushItemWidth(unit_size);
1246 if (ImGui::BBLInputDouble(label_values[2][2], &absolute_rotation[2], 0.0f, 0.0f, "%.2f")) {
1247 is_absolute_input = true;
1248 }
1249 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
1250 imgui_wrapper->text("°");
1251 m_buffered_absolute_rotation = absolute_rotation;
1252 if (is_absolute_input) {
1254 }
1256 bool is_valid = update(current_active_id, "absolute_rotation", this->m_new_absolute_rotation, m_buffered_absolute_rotation) >= 0;
1257 if (is_valid) {
1259 }
1260 }
1261
1262 ImGui::SameLine(caption_max + index_unit * unit_size + (++index) * space_size + end_text_size);
1263 if (reset_zero_button(imgui_wrapper, m_show_reset_0_rotation)) // ORCA reserve icon space to prevent changes on layout
1264 reset_rotation_value(false);
1265 if (m_show_reset_0_rotation && ImGui::IsItemHovered()) {
1266 float tooltip_size = imgui_wrapper->calc_text_size(_L("Reset current rotation to real zeros.")).x + 3 * space_size;
1267 imgui_wrapper->tooltip(_L("Reset current rotation to real zeros."), tooltip_size);
1268 }
1269 // send focus to m_glcanvas
1270 bool absolute_focued_on_text = false;
1271 for (int j = 0; j < 3; j++) {
1272 unsigned int id = ImGui::GetID(label_values[2][j]);
1273 if (current_active_id == id) {
1274 m_glcanvas.handle_sidebar_focus_event(label_values[2][j] + 2, true);
1275 absolute_focued_on_text = true;
1276 break;
1277 }
1278 }
1279 if (!focued_on_text && !absolute_focued_on_text)
1280 m_glcanvas.handle_sidebar_focus_event("", false);
1281
1282 ImGui::Spacing(); // needed after Text
1283 ImGui::Separator();
1284 ImGui::Spacing();
1285 float f_scale = m_glcanvas.get_gizmos_manager().get_layout_scale();
1286 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f * f_scale));
1287
1289
1290 ImGui::SameLine();
1292 if (imgui_wrapper->button(_L("Done"))) {
1293 m_glcanvas.reset_all_gizmos();
1294 }
1295
1296 m_last_active_item = current_active_id;
1297 last_rotate_input_window_width = ImGui::GetWindowWidth();
1298 ImGui::PopStyleVar();
1299 imgui_wrapper->end();
1300
1301 // BBS
1302 ImGui::PopStyleVar();
1304}
bool m_show_clear_rotation
Definition GizmoObjectManipulation.hpp:104
Vec3d m_buffered_absolute_rotation
Definition GizmoObjectManipulation.hpp:94
void reset_rotation_value(bool reset_relative)
Definition GizmoObjectManipulation.cpp:569
@ Relative
Definition GizmoObjectManipulation.hpp:107
@ None
Definition GizmoObjectManipulation.hpp:107
@ Absolute
Definition GizmoObjectManipulation.hpp:107
bool reset_zero_button(ImGuiWrapper *imgui_wrapper, bool enabled)
Definition GizmoObjectManipulation.cpp:680
RotateType m_last_rotate_type
Definition GizmoObjectManipulation.hpp:109
Vec3d m_new_absolute_rotation
Definition GizmoObjectManipulation.hpp:88
bool m_show_reset_0_rotation
Definition GizmoObjectManipulation.hpp:103
bool reset_button(ImGuiWrapper *imgui_wrapper, bool enabled)
Definition GizmoObjectManipulation.cpp:656
Vec3d m_buffered_rotation
Definition GizmoObjectManipulation.hpp:93
float last_rotate_input_window_width
Definition GizmoObjectManipulation.hpp:113
Vec3d m_new_rotation
Definition GizmoObjectManipulation.hpp:87
bool is_valid(const FontFile &font, unsigned int index)
Definition Emboss.cpp:284

References _L, _u8L, Absolute, Slic3r::GUI::ImGuiWrapper::begin(), Slic3r::GUI::GLGizmoUtils::begin_right_aligned_buttons(), Slic3r::GUI::ImGuiWrapper::button(), Slic3r::GUI::ImGuiWrapper::calc_text_size(), Slic3r::GUI::ImGuiWrapper::end(), Slic3r::GUI::ImGuiWrapper::get_style_scaling(), Slic3r::GUI::label_values, last_rotate_input_window_width, m_buffered_absolute_rotation, m_buffered_position, m_buffered_rotation, m_glcanvas, m_imperial_units, m_last_active_item, m_last_rotate_type, m_new_absolute_rotation, m_new_position, m_new_rotation, m_new_title_string, m_shortcuts_rotate, m_show_clear_rotation, m_show_reset_0_rotation, MAX_SIZE, mm_to_in, None, on_change(), Slic3r::GUI::ImGuiWrapper::pop_toolbar_style(), Slic3r::GUI::ImGuiWrapper::push_toolbar_style(), Relative, Slic3r::GUI::GLGizmoUtils::render_tooltip_button(), reset_button(), reset_rotation_value(), reset_zero_button(), Slic3r::GUI::ImGuiWrapper::set_next_window_pos(), Slic3r::GUI::ImGuiWrapper::text(), Slic3r::GUI::ImGuiWrapper::to_ImVec4(), Slic3r::GUI::ImGuiWrapper::TOOLBAR_WINDOW_FLAGS, Slic3r::GUI::ImGuiWrapper::tooltip(), Slic3r::ColorRGBA::X(), Slic3r::ColorRGBA::Y(), and Slic3r::ColorRGBA::Z().

Here is the call graph for this function:

◆ do_render_scale_input_window()

void Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window ( ImGuiWrapper * imgui_wrapper,
std::string window_name,
float x,
float y,
float bottom_limit )
1307{
1308 //BBS: GUI refactor: move gizmo to the right
1309 if (abs(last_scale_input_window_width) > 0.01f) {
1310 if (x + last_scale_input_window_width > m_glcanvas.get_canvas_size().get_width()) {
1311 if (last_scale_input_window_width > m_glcanvas.get_canvas_size().get_width())
1312 x = 0;
1313 else
1314 x = m_glcanvas.get_canvas_size().get_width() - last_scale_input_window_width;
1315 }
1316 }
1317#if BBS_TOOLBAR_ON_TOP
1318 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 0.f, 0.0f);
1319#else
1320 imgui_wrapper->set_next_window_pos(x, y, ImGuiCond_Always, 1.0f, 0.0f);
1321#endif
1322
1323 //BBS
1325 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0, 6.0));
1326
1327 std::string name = this->m_new_title_string + "##" + window_name;
1328 imgui_wrapper->begin(_L(name), ImGuiWrapper::TOOLBAR_WINDOW_FLAGS);
1329
1330 auto update = [this](unsigned int active_id, std::string opt_key, Vec3d original_value, Vec3d new_value)->int {
1331 for (int i = 0; i < 3; i++)
1332 {
1333 if (original_value[i] != new_value[i])
1334 {
1335 if (active_id != m_last_active_item)
1336 {
1337 on_change(opt_key, i, new_value[i]);
1338 return i;
1339 }
1340 }
1341 }
1342 return -1;
1343 };
1344
1345 float space_size = imgui_wrapper->get_style_scaling() * 8;
1346 // ORCA
1347 float coord_combo_width = std::max({
1348 imgui_wrapper->calc_text_size(_L("World")).x,
1349 imgui_wrapper->calc_text_size(_L("Object")).x,
1350 imgui_wrapper->calc_text_size(_L("Part")).x
1351 }) + imgui_wrapper->calc_text_size("xxx"sv).x + imgui_wrapper->scaled(3.5f);
1352 float label_max = std::max({
1353 imgui_wrapper->calc_text_size(_L_CONTEXT("Scale", "Noun")).x,
1354 imgui_wrapper->calc_text_size(_L("Size")).x
1355 });
1356 float caption_max = std::max(label_max, coord_combo_width - 3 * space_size);
1357 float end_text_size = imgui_wrapper->calc_text_size(this->m_new_unit_string).x;
1358 ImGui::AlignTextToFramePadding();
1359 unsigned int current_active_id = ImGui::GetActiveID();
1360
1362 Vec3d display_size = m_buffered_size;
1363
1364 Vec3d display_position = m_buffered_position;
1365
1366 float unit_size = imgui_wrapper->calc_text_size(MAX_SIZE).x + space_size;
1367 bool imperial_units = this->m_imperial_units;
1368
1369 int index = 2;
1370 int index_unit = 1;
1371
1372 Selection & selection = m_glcanvas.get_selection();
1373 std::vector<std::string> modes = {_u8L("World"), _u8L("Object"), _u8L("Part")}; // ORCA use shorter terms to make UI more compact
1374 if (selection.is_single_full_object()) { modes.pop_back(); }
1375 if (selection.is_multiple_full_object()) {
1376 modes.pop_back();
1377 modes.pop_back();
1378 }
1379 size_t selection_idx = (int) m_coordinates_type;
1380 if (selection_idx >= modes.size()) {
1382 selection_idx = 0;
1383 }
1384
1386 bool combox_changed = false;
1387 if (render_combo(imgui_wrapper, "", modes, selection_idx, 0, coord_combo_width)) {
1388 combox_changed = true;
1389 }
1391 // After pop_combo_style(): its light popup background would hide the tooltip's white text.
1392 if (ImGui::IsItemHovered()) {
1393 auto tooltip_str = _L("Coordinate system used for transform actions.");
1394 imgui_wrapper->tooltip(tooltip_str, imgui_wrapper->calc_text_size(tooltip_str).x + 3 * space_size);
1395 }
1396
1397 // ORCA use TextColored to match axes color
1398 float offset_to_center = (unit_size - ImGui::CalcTextSize("O").x) / 2;
1399 ImGui::SameLine(caption_max + space_size + offset_to_center);
1400 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X");
1401 ImGui::SameLine(caption_max + unit_size + index * space_size + offset_to_center);
1402 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y");
1403 ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size + offset_to_center);
1404 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z");
1405
1406 index = 2;
1407 index_unit = 1;
1408
1409 //ImGui::PushItemWidth(unit_size * 2);
1410 ImGui::AlignTextToFramePadding();
1411 imgui_wrapper->text(_L_CONTEXT("Scale", "Noun"));
1412 ImGui::SameLine(caption_max + space_size);
1413 ImGui::PushItemWidth(unit_size);
1414 ImGui::BBLInputDouble(label_scale_values[0][0], &scale[0], 0.0f, 0.0f, "%.2f");
1415 ImGui::SameLine(caption_max + unit_size + index * space_size);
1416 ImGui::PushItemWidth(unit_size);
1417 ImGui::BBLInputDouble(label_scale_values[0][1], &scale[1], 0.0f, 0.0f, "%.2f");
1418 ImGui::SameLine(caption_max + (++index_unit) *unit_size + (++index) * space_size);
1419 ImGui::PushItemWidth(unit_size);
1420 ImGui::BBLInputDouble(label_scale_values[0][2], &scale[2], 0.0f, 0.0f, "%.2f");
1421 ImGui::SameLine(caption_max + (++index_unit) *unit_size + (++index) * space_size);
1422 imgui_wrapper->text("%");
1423 if (scale.x() > 0 && scale.y() > 0 && scale.z() > 0) {
1425 }
1426
1427 ImGui::SameLine(caption_max + 3 * unit_size + 4 * space_size + end_text_size);
1428 if (reset_button(imgui_wrapper, m_show_clear_scale))
1430
1431 //Size
1432 Vec3d original_size;
1433 if (this->m_imperial_units)
1434 original_size = this->m_new_size * this->mm_to_in;
1435 else
1436 original_size = this->m_new_size;
1437
1438 index = 2;
1439 index_unit = 1;
1440 //ImGui::PushItemWidth(unit_size * 2);
1441 ImGui::AlignTextToFramePadding();
1442 imgui_wrapper->text(_L("Size"));
1443 ImGui::SameLine(caption_max + space_size);
1444 ImGui::PushItemWidth(unit_size);
1445 ImGui::BBLInputDouble(label_scale_values[1][0], &display_size[0], 0.0f, 0.0f, "%.2f");
1446 ImGui::SameLine(caption_max + unit_size + index * space_size);
1447 ImGui::PushItemWidth(unit_size);
1448 ImGui::BBLInputDouble(label_scale_values[1][1], &display_size[1], 0.0f, 0.0f, "%.2f");
1449 ImGui::SameLine(caption_max + (++index_unit) *unit_size + (++index) * space_size);
1450 ImGui::PushItemWidth(unit_size);
1451 ImGui::BBLInputDouble(label_scale_values[1][2], &display_size[2], 0.0f, 0.0f, "%.2f");
1452 ImGui::SameLine(caption_max + (++index_unit) *unit_size + (++index) * space_size);
1453 imgui_wrapper->text(this->m_new_unit_string);
1454 for (int i = 0; i < display_size.size(); i++) {
1455 if (std::abs(display_size[i]) > MAX_NUM) {
1456 display_size[i] = MAX_NUM;
1457 }
1458 }
1459 if (display_size.x() > 0 && display_size.y() > 0 && display_size.z() > 0) {
1460 m_buffered_size = display_size;
1461 }
1462
1463 ImGui::AlignTextToFramePadding();
1464 bool is_avoid_one_update{false};
1465 if (combox_changed) {
1466 combox_changed = false;
1467 set_coordinates_type((ECoordinatesType) selection_idx);
1468 UpdateAndShow(true);
1469 is_avoid_one_update = true;
1470 }
1471
1472 auto uniform_scale_size =imgui_wrapper->calc_text_size(_L("Uniform scale")).x;
1473 ImGui::PushItemWidth(uniform_scale_size);
1474 int size_sel{-1};
1475 if (!is_avoid_one_update) {
1476 size_sel = update(current_active_id, "size", original_size, m_buffered_size);
1477 }
1478 ImGui::PopStyleVar(1);
1479 bool uniform_scale = this->m_uniform_scale;
1480
1481 // BBS: when select multiple objects, uniform scale can be deselected
1482 //const Selection &selection = m_glcanvas.get_selection();
1483 //bool uniform_scale_only = selection.is_multiple_full_object() || selection.is_multiple_full_instance() || selection.is_mixed() || selection.is_multiple_volume() ||
1484 // selection.is_multiple_modifier();
1485
1486 //if (uniform_scale_only) {
1487 // imgui_wrapper->disabled_begin(true);
1488 // imgui_wrapper->bbl_checkbox(_L("Uniform scale"), uniform_scale_only);
1489 // imgui_wrapper->disabled_end();
1490 //} else {
1491 imgui_wrapper->bbl_checkbox(_L("Uniform scale"), uniform_scale);
1492 //}
1493 if (uniform_scale != this->m_uniform_scale) { this->set_uniform_scaling(uniform_scale); }
1494
1495 // for (int index = 0; index < 3; index++)
1496 // BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ",before_index="<<index <<boost::format(",scale %1%, buffered %2%, original_id %3%, new_id %4%\n") %
1497 // this->m_new_scale[index] % m_buffered_scale[index] % m_last_active_item % current_active_id;
1498 int scale_sel = update(current_active_id, "scale", this->m_new_scale, m_buffered_scale);
1499 if ((scale_sel >= 0)) {
1500 // for (int index = 0; index < 3; index++)
1501 // BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ",after_index="<<index <<boost::format(",scale %1%, buffered %2%, original_id %3%, new_id %4%\n") %
1502 // this->m_new_scale[index] % m_buffered_scale[index] % m_last_active_item % current_active_id;
1503 for (int i = 0; i < 3; ++i) {
1504 if (i != scale_sel) ImGui::ClearInputTextInitialData(label_scale_values[0][i], m_buffered_scale[i]);
1505 ImGui::ClearInputTextInitialData(label_scale_values[1][i], m_buffered_size[i]);
1506 }
1507 }
1508
1509 if ((size_sel >= 0)) {
1510 // for (int index = 0; index < 3; index++)
1511 // BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ",after_index="<<index <<boost::format(",scale %1%, buffered %2%, original_id %3%, new_id %4%\n") %
1512 // this->m_new_scale[index] % m_buffered_scale[index] % m_last_active_item % current_active_id;
1513 for (int i = 0; i < 3; ++i) {
1514 ImGui::ClearInputTextInitialData(label_scale_values[0][i], m_buffered_scale[i]);
1515 if (i != size_sel) ImGui::ClearInputTextInitialData(label_scale_values[1][i], m_buffered_size[i]);
1516 }
1517 }
1518
1519 //send focus to m_glcanvas
1520 bool focued_on_text = false;
1521 for (int i = 0; i < 2; i++)
1522 for (int j = 0; j < 3; j++)
1523 {
1524 unsigned int id = ImGui::GetID(label_scale_values[i][j]);
1525 if (current_active_id == id)
1526 {
1527 m_glcanvas.handle_sidebar_focus_event(label_scale_values[i][j] + 2, true);
1528 focued_on_text = true;
1529 break;
1530 }
1531 }
1532 if (!focued_on_text)
1533 m_glcanvas.handle_sidebar_focus_event("", false);
1534
1535 ImGui::Separator();
1536 float f_scale = m_glcanvas.get_gizmos_manager().get_layout_scale();
1537 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f * f_scale));
1538
1540
1541 ImGui::SameLine();
1543 if (imgui_wrapper->button(_L("Done"))) {
1544 m_glcanvas.reset_all_gizmos();
1545 }
1546
1547 m_last_active_item = current_active_id;
1548
1549 last_scale_input_window_width = ImGui::GetWindowWidth();
1550 imgui_wrapper->end();
1551
1552 //BBS
1553 ImGui::PopStyleVar(1);
1555}
Vec3d m_new_size
Definition GizmoObjectManipulation.hpp:90
float last_scale_input_window_width
Definition GizmoObjectManipulation.hpp:114
Vec3d m_new_scale
Definition GizmoObjectManipulation.hpp:89
Vec3d m_buffered_scale
Definition GizmoObjectManipulation.hpp:95
bool m_uniform_scale
Definition GizmoObjectManipulation.hpp:99
void reset_scale_value()
Definition GizmoObjectManipulation.cpp:609
void set_uniform_scaling(const bool uniform_scale)
Definition GizmoObjectManipulation.cpp:618
Vec3d m_buffered_size
Definition GizmoObjectManipulation.hpp:96
static const char * label_scale_values[2][3]
Definition GizmoObjectManipulation.cpp:651
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15

References _L, _L_CONTEXT, _u8L, Slic3r::GUI::ImGuiWrapper::bbl_checkbox(), Slic3r::GUI::ImGuiWrapper::begin(), Slic3r::GUI::GLGizmoUtils::begin_right_aligned_buttons(), Slic3r::GUI::ImGuiWrapper::button(), Slic3r::GUI::ImGuiWrapper::calc_text_size(), Slic3r::GUI::ImGuiWrapper::end(), Slic3r::GUI::ImGuiWrapper::get_style_scaling(), Slic3r::GUI::Selection::is_multiple_full_object(), Slic3r::GUI::Selection::is_single_full_object(), Slic3r::GUI::label_scale_values, last_scale_input_window_width, m_buffered_position, m_buffered_scale, m_buffered_size, m_coordinates_type, m_glcanvas, m_imperial_units, m_last_active_item, m_new_scale, m_new_size, m_new_title_string, m_new_unit_string, m_shortcuts_scale, m_show_clear_scale, m_uniform_scale, MAX_NUM, MAX_SIZE, mm_to_in, on_change(), Slic3r::GUI::ImGuiWrapper::pop_combo_style(), Slic3r::GUI::ImGuiWrapper::pop_toolbar_style(), Slic3r::GUI::ImGuiWrapper::push_combo_style(), Slic3r::GUI::ImGuiWrapper::push_toolbar_style(), render_combo(), Slic3r::GUI::GLGizmoUtils::render_tooltip_button(), reset_button(), reset_scale_value(), scale(), Slic3r::GUI::ImGuiWrapper::scaled(), set_coordinates_type(), Slic3r::GUI::ImGuiWrapper::set_next_window_pos(), set_uniform_scaling(), Slic3r::GUI::ImGuiWrapper::text(), Slic3r::GUI::ImGuiWrapper::to_ImVec4(), Slic3r::GUI::ImGuiWrapper::TOOLBAR_WINDOW_FLAGS, Slic3r::GUI::ImGuiWrapper::tooltip(), UpdateAndShow(), Slic3r::GUI::World, Slic3r::ColorRGBA::X(), Slic3r::ColorRGBA::Y(), and Slic3r::ColorRGBA::Z().

Here is the call graph for this function:

◆ do_scale()

void Slic3r::GUI::GizmoObjectManipulation::do_scale ( int axis,
const Vec3d & scale ) const
private
464{
465 Selection& selection = m_glcanvas.get_selection();
466
467 TransformationType transformation_type;
469 transformation_type.set_local();
470 else if (is_instance_coordinates())
471 transformation_type.set_instance();
472 if (selection.is_single_volume_or_modifier() && !is_local_coordinates())
473 transformation_type.set_relative();
474
475 Vec3d scaling_factor = m_uniform_scale ? scale(axis) * Vec3d::Ones() : scale;
476 limit_scaling_ratio(scaling_factor);
477
478 selection.setup_cache();
479 selection.scale(scaling_factor, transformation_type);
480 m_glcanvas.do_scale(L("Set scale"));
481}
void limit_scaling_ratio(Vec3d &scaling_factor) const
Definition GizmoObjectManipulation.cpp:484

References is_instance_coordinates(), is_local_coordinates(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), L, limit_scaling_ratio(), m_glcanvas, m_uniform_scale, scale(), Slic3r::GUI::Selection::scale(), Slic3r::GUI::TransformationType::set_instance(), Slic3r::GUI::TransformationType::set_local(), Slic3r::GUI::TransformationType::set_relative(), and Slic3r::GUI::Selection::setup_cache().

Referenced by change_scale_value(), and change_size_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_align_to_parent()

bool Slic3r::GUI::GizmoObjectManipulation::get_align_to_parent ( ) const
inline
158{ return m_align_to_parent; }

References m_align_to_parent.

◆ get_alignment_helper()

const GLGizmoAlignment & Slic3r::GUI::GizmoObjectManipulation::get_alignment_helper ( ) const
inline
156{ return m_alignment_helper; }

References m_alignment_helper.

◆ get_cache()

const Cache & Slic3r::GUI::GizmoObjectManipulation::get_cache ( )
inline
139{return m_cache; }

References m_cache.

◆ get_coordinates_type()

ECoordinatesType Slic3r::GUI::GizmoObjectManipulation::get_coordinates_type ( ) const
inline
134{ return m_coordinates_type; }

References m_coordinates_type.

◆ get_hovered_align_type()

GLGizmoAlignment::AlignType Slic3r::GUI::GizmoObjectManipulation::get_hovered_align_type ( ) const
inline
157{ return m_hovered_align_type; }

References m_hovered_align_type.

◆ get_uniform_scaling()

bool Slic3r::GUI::GizmoObjectManipulation::get_uniform_scaling ( ) const
inline
129{ return m_uniform_scale; }

References m_uniform_scale.

◆ get_use_object_cs()

bool Slic3r::GUI::GizmoObjectManipulation::get_use_object_cs ( )
inline
131{ return m_use_object_cs; }
bool m_use_object_cs
Definition GizmoObjectManipulation.hpp:69

References m_use_object_cs.

◆ is_instance_coordinates()

bool Slic3r::GUI::GizmoObjectManipulation::is_instance_coordinates ( ) const
inline

References Slic3r::GUI::Instance, and m_coordinates_type.

Referenced by change_absolute_rotation_value(), change_rotation_value(), do_render_move_window(), do_scale(), and update_settings_value().

Here is the caller graph for this function:

◆ is_local_coordinates()

bool Slic3r::GUI::GizmoObjectManipulation::is_local_coordinates ( ) const
inline

References Slic3r::GUI::Local, and m_coordinates_type.

Referenced by change_absolute_rotation_value(), change_rotation_value(), do_scale(), and update_settings_value().

Here is the caller graph for this function:

◆ is_world_coordinates()

bool Slic3r::GUI::GizmoObjectManipulation::is_world_coordinates ( ) const
inline

References m_coordinates_type, and Slic3r::GUI::World.

Referenced by change_size_value(), and update_settings_value().

Here is the caller graph for this function:

◆ IsShown()

bool Slic3r::GUI::GizmoObjectManipulation::IsShown ( )

◆ limit_scaling_ratio()

void Slic3r::GUI::GizmoObjectManipulation::limit_scaling_ratio ( Vec3d & scaling_factor) const
484 {
485 for (size_t i = 0; i < scaling_factor.size(); i++) { // range protect //scaling_factor too big has problem
486 if (scaling_factor[i] * m_unscale_size[i] > MAX_NUM) {
487 scaling_factor[i] = MAX_NUM / m_unscale_size[i];
488 }
489 }
490}
Vec3d m_unscale_size
Definition GizmoObjectManipulation.hpp:91

References m_unscale_size, and MAX_NUM.

Referenced by do_scale().

Here is the caller graph for this function:

◆ max_unit_size()

float Slic3r::GUI::GizmoObjectManipulation::max_unit_size ( int number,
Vec3d & vec1,
Vec3d & vec2,
std::string str )
705 {
706 if (number <= 1) return -1;
707 Vec3d vec[2] = {vec1, vec2};
708 float nuit_max[4] = {0};
709 float vec_max = 0, unit_size = 0;
710
711 for (int i = 0; i < number; i++)
712 {
713 char buf[3][64] = {};
714 float buf_size[3] = {0};
715 for (int j = 0; j < 3; j++) {
716 ImGui::DataTypeFormatString(buf[j], IM_ARRAYSIZE(buf[j]), ImGuiDataType_Double, (void *) &vec[i][j], "%.2f");
717 buf_size[j] = ImGui::CalcTextSize(buf[j]).x;
718 vec_max = std::max(buf_size[j], vec_max);
719 nuit_max[i] = vec_max;
720 }
721 unit_size = std::max(nuit_max[i], unit_size);
722 }
723
724 return unit_size + 8.0;
725 }

◆ on_change()

void Slic3r::GUI::GizmoObjectManipulation::on_change ( const std::string & opt_key,
int axis,
double new_value )
493{
494 if (!m_cache.is_valid())
495 return;
496
497 if (m_imperial_units && (opt_key == "position" || opt_key == "size"))
498 new_value *= in_to_mm;
499
500 if (opt_key == "position")
501 change_position_value(axis, new_value);
502 else if (opt_key == "rotation")
503 change_rotation_value(axis, new_value);
504 else if (opt_key == "absolute_rotation")
505 change_absolute_rotation_value(axis, new_value);
506 else if (opt_key == "scale")
507 change_scale_value(axis, new_value);
508 else if (opt_key == "size")
509 change_size_value(axis, new_value);
510}
void change_position_value(int axis, double value)
Definition GizmoObjectManipulation.cpp:317
void change_rotation_value(int axis, double value)
Definition GizmoObjectManipulation.cpp:351
void change_scale_value(int axis, double value)
Definition GizmoObjectManipulation.cpp:408
void change_size_value(int axis, double value)
Definition GizmoObjectManipulation.cpp:433
void change_absolute_rotation_value(int axis, double value)
Definition GizmoObjectManipulation.cpp:380
static const double in_to_mm
Definition GizmoObjectManipulation.hpp:30

References change_absolute_rotation_value(), change_position_value(), change_rotation_value(), change_scale_value(), change_size_value(), in_to_mm, m_cache, and m_imperial_units.

Referenced by do_render_move_window(), do_render_rotate_window(), and do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_combo()

bool Slic3r::GUI::GizmoObjectManipulation::render_combo ( ImGuiWrapper * imgui_wrapper,
const std::string & label,
const std::vector< std::string > & lines,
size_t & selection_idx,
float label_width,
float item_width )
514{
515 if(!label.empty()){
516 ImGui::AlignTextToFramePadding();
517 imgui_wrapper->text(label);
518 ImGui::SameLine(label_width);
519 }
520
521 ImGui::PushItemWidth(item_width);
522
523 size_t selection_out = selection_idx;
524
525 const char *selected_str = (selection_idx >= 0 && selection_idx < int(lines.size())) ? lines[selection_idx].c_str() : "";
526 if (ImGui::BBLBeginCombo(("##" + label).c_str(), selected_str, 0)) {
527 for (size_t line_idx = 0; line_idx < lines.size(); ++line_idx) {
528 ImGui::PushID(int(line_idx));
529 if (ImGui::Selectable("", line_idx == selection_idx)) selection_out = line_idx;
530
531 ImGui::SameLine();
532 ImGui::Text("%s", lines[line_idx].c_str());
533 ImGui::PopID();
534 }
535
536 ImGui::EndCombo();
537 }
538
539 bool is_changed = selection_idx != selection_out;
540 selection_idx = selection_out;
541
542 return is_changed;
543}

References Slic3r::GUI::ImGuiWrapper::text().

Referenced by do_render_move_window(), and do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_align_state()

◆ reset_button()

bool Slic3r::GUI::GizmoObjectManipulation::reset_button ( ImGuiWrapper * imgui_wrapper,
bool enabled )
657{
658 imgui_wrapper->disabled_begin(!enabled);
659 bool pressed = false;
660 ImTextureID normal_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_RESET);
661 ImTextureID hover_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_RESET_HOVER);
662
663 float scale = m_glcanvas.get_scale();
664 #ifdef WIN32
665 int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
666 scale *= (float) dpi / (float) DPI_DEFAULT;
667 #endif // WIN32
668 ImVec2 button_size = ImVec2(16 * scale, 16 * scale); // ORCA: Use exact resolution will prevent blur on icon
669
670 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
671
672 pressed = ImGui::ImageButton3(normal_id, hover_id, button_size, {0,0}, {1,1}, -1, {0,0,0,0}, {1,1,1, enabled ? 1.f : 0.f}); // ORCA make icon invisible to prevent changes on layout
673
674 ImGui::PopStyleVar(1);
675
676 imgui_wrapper->disabled_end();
677 return pressed;
678}
@ IC_TOOLBAR_RESET
Definition GLGizmosManager.hpp:180
@ IC_TOOLBAR_RESET_HOVER
Definition GLGizmosManager.hpp:181

References Slic3r::GUI::ImGuiWrapper::disabled_begin(), Slic3r::GUI::ImGuiWrapper::disabled_end(), Slic3r::GUI::DPI_DEFAULT, Slic3r::GUI::get_dpi_for_window(), Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_RESET, Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_RESET_HOVER, m_glcanvas, and scale().

Referenced by do_render_rotate_window(), and do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_cache()

void Slic3r::GUI::GizmoObjectManipulation::reset_cache ( )
inline
140{ m_cache.reset(); }

References m_cache.

◆ reset_position_value()

void Slic3r::GUI::GizmoObjectManipulation::reset_position_value ( )
private
546{
547 Selection& selection = m_glcanvas.get_selection();
548
549 if (selection.is_single_volume() || selection.is_single_modifier()) {
550 GLVolume* volume = const_cast<GLVolume*>(selection.get_first_volume());
551 volume->set_volume_offset(Vec3d::Zero());
552 }
553 else if (selection.is_single_full_instance()) {
554 for (unsigned int idx : selection.get_volume_idxs()) {
555 GLVolume* volume = const_cast<GLVolume*>(selection.get_volume(idx));
556 volume->set_instance_offset(Vec3d::Zero());
557 }
558 }
559 else
560 return;
561
562 // Copy position values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing.
563 wxGetApp().plater()->take_snapshot(_u8L("Reset position"), UndoRedo::SnapshotType::GizmoAction);
564 m_glcanvas.do_move("");
565
566 UpdateAndShow(true);
567}

References _u8L, Slic3r::GUI::Selection::get_first_volume(), Slic3r::GUI::Selection::get_volume(), Slic3r::GUI::Selection::get_volume_idxs(), Slic3r::UndoRedo::GizmoAction, Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_modifier(), Slic3r::GUI::Selection::is_single_volume(), m_glcanvas, Slic3r::GLVolume::set_instance_offset(), Slic3r::GLVolume::set_volume_offset(), and UpdateAndShow().

Here is the call graph for this function:

◆ reset_rotation_value()

void Slic3r::GUI::GizmoObjectManipulation::reset_rotation_value ( bool reset_relative)
private
570{
571 Selection &selection = m_glcanvas.get_selection();
572 selection.setup_cache();
573 if (selection.is_single_volume_or_modifier()) {
574 GLVolume * vol = const_cast<GLVolume *>(selection.get_first_volume());
575 Geometry::Transformation trafo = vol->get_volume_transformation();
576 if (reset_relative) {
577 auto offset = trafo.get_offset();
578 trafo.set_matrix(m_init_rotation_scale_tran);
579 trafo.set_offset(offset);
580 }
581 else {
582 trafo.reset_rotation();
583 }
584 vol->set_volume_transformation(trafo);
585 } else if (selection.is_single_full_instance()) {
586 Geometry::Transformation trafo = selection.get_first_volume()->get_instance_transformation();
587 if (reset_relative) {
588 auto offset = trafo.get_offset();
589 trafo.set_matrix(m_init_rotation_scale_tran);
590 trafo.set_offset(offset);
591 } else {
592 trafo.reset_rotation();
593 }
594 for (unsigned int idx : selection.get_volume_idxs()) {
595 const_cast<GLVolume *>(selection.get_volume(idx))->set_instance_transformation(trafo);
596 }
597 } else
598 return;
599 // Synchronize instances/volumes.
600
601 selection.synchronize_unselected_instances(Selection::SyncRotationType::RESET);
602 selection.synchronize_unselected_volumes();
603 // Copy rotation values from GLVolumes into Model (ModelInstance / ModelVolume), trigger background processing.
604 m_glcanvas.do_rotate(L("Reset rotation"));
605
606 UpdateAndShow(true);
607}
Transform3d m_init_rotation_scale_tran
Definition GizmoObjectManipulation.hpp:202
@ RESET
Definition Selection.hpp:461
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References Slic3r::GUI::Selection::get_first_volume(), Slic3r::GLVolume::get_instance_transformation(), Slic3r::Geometry::Transformation::get_offset(), Slic3r::GUI::Selection::get_volume(), Slic3r::GUI::Selection::get_volume_idxs(), Slic3r::GLVolume::get_volume_transformation(), Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), L, m_glcanvas, m_init_rotation_scale_tran, Slic3r::offset(), Slic3r::GUI::Selection::RESET, Slic3r::Geometry::Transformation::reset_rotation(), Slic3r::GLVolume::set_instance_transformation(), Slic3r::Geometry::Transformation::set_matrix(), Slic3r::Geometry::Transformation::set_offset(), Slic3r::GLVolume::set_volume_transformation(), Slic3r::GUI::Selection::setup_cache(), Slic3r::GUI::Selection::synchronize_unselected_instances(), Slic3r::GUI::Selection::synchronize_unselected_volumes(), and UpdateAndShow().

Referenced by do_render_rotate_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_scale_value()

void Slic3r::GUI::GizmoObjectManipulation::reset_scale_value ( )
private
610{
611 Plater::TakeSnapshot snapshot(wxGetApp().plater(), "Reset scale");
612
613 change_scale_value(0, 100.);
614 change_scale_value(1, 100.);
615 change_scale_value(2, 100.);
616}
static Plater * plater()
Definition GUI_Factories.cpp:400

References change_scale_value(), and Slic3r::GUI::plater().

Referenced by do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_settings_value()

void Slic3r::GUI::GizmoObjectManipulation::reset_settings_value ( )
private
305{
306 m_new_position = Vec3d::Zero();
307 m_new_rotation = Vec3d::Zero();
308 m_new_absolute_rotation = Vec3d::Zero();
309 m_new_scale = Vec3d::Ones() * 100.;
310 m_new_size = Vec3d::Zero();
311 m_new_enabled = false;
312 // no need to set the dirty flag here as this method is called from update_settings_value(),
313 // which is called from update_if_dirty(), which resets the dirty flag anyways.
314// m_dirty = true;
315}
bool m_new_enabled
Definition GizmoObjectManipulation.hpp:98

References m_new_absolute_rotation, m_new_enabled, m_new_position, m_new_rotation, m_new_scale, and m_new_size.

Referenced by update_settings_value().

Here is the caller graph for this function:

◆ reset_zero_button()

bool Slic3r::GUI::GizmoObjectManipulation::reset_zero_button ( ImGuiWrapper * imgui_wrapper,
bool enabled )
681{
682 imgui_wrapper->disabled_begin(!enabled);
683 bool pressed = false;
684 ImTextureID normal_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_RESET_ZERO);
685 ImTextureID hover_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_RESET_ZERO_HOVER);
686
687 float scale = m_glcanvas.get_scale();
688 #ifdef WIN32
689 int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
690 scale *= (float) dpi / (float) DPI_DEFAULT;
691 #endif // WIN32
692 ImVec2 button_size = ImVec2(16 * scale, 16 * scale); // ORCA: Use exact resolution will prevent blur on icon
693
694 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
695
696 pressed = ImGui::ImageButton3(normal_id, hover_id, button_size, {0,0}, {1,1}, -1, {0,0,0,0}, {1,1,1, enabled ? 1.f : 0.f}); // ORCA make icon invisible to prevent changes on layout
697
698 ImGui::PopStyleVar(1);
699
700 imgui_wrapper->disabled_end();
701 return pressed;
702}
@ IC_TOOLBAR_RESET_ZERO_HOVER
Definition GLGizmosManager.hpp:183
@ IC_TOOLBAR_RESET_ZERO
Definition GLGizmosManager.hpp:182

References Slic3r::GUI::ImGuiWrapper::disabled_begin(), Slic3r::GUI::ImGuiWrapper::disabled_end(), Slic3r::GUI::DPI_DEFAULT, Slic3r::GUI::get_dpi_for_window(), Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_RESET_ZERO, Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_RESET_ZERO_HOVER, m_glcanvas, and scale().

Referenced by do_render_rotate_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_coordinates_type()

void Slic3r::GUI::GizmoObjectManipulation::set_coordinates_type ( ECoordinatesType type)
629{
630 /*if (wxGetApp().get_mode() == comSimple)
631 type = ECoordinatesType::World;*/
632
633 if (m_coordinates_type == type) return;
634
635 m_coordinates_type = type;
636 //m_word_local_combo->SetSelection((int) m_coordinates_type);
637 this->UpdateAndShow(true);
638 GLCanvas3D *canvas = wxGetApp().plater()->canvas3D();
639 canvas->get_gizmos_manager().update_data();
640 canvas->set_as_dirty();
641 canvas->request_extra_frame();
642
643}

References Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), m_coordinates_type, Slic3r::GUI::GLCanvas3D::request_extra_frame(), Slic3r::GUI::GLCanvas3D::set_as_dirty(), Slic3r::GUI::GLGizmosManager::update_data(), and UpdateAndShow().

Referenced by do_render_move_window(), and do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_dirty()

void Slic3r::GUI::GizmoObjectManipulation::set_dirty ( )
inline
124{ m_dirty = true; }
bool m_dirty
Definition GizmoObjectManipulation.hpp:79

References m_dirty.

Referenced by set_uniform_scaling(), and UpdateAndShow().

Here is the caller graph for this function:

◆ set_init_rotation()

void Slic3r::GUI::GizmoObjectManipulation::set_init_rotation ( const Geometry::Transformation & value)
743 {
744 m_init_rotation_scale_tran = value.get_matrix_no_offset();
745 m_init_rotation = value.get_rotation();
746}
Vec3d m_init_rotation
Definition GizmoObjectManipulation.hpp:201

References Slic3r::Geometry::Transformation::get_matrix_no_offset(), Slic3r::Geometry::Transformation::get_rotation(), m_init_rotation, and m_init_rotation_scale_tran.

Here is the call graph for this function:

◆ set_uniform_scaling()

void Slic3r::GUI::GizmoObjectManipulation::set_uniform_scaling ( const bool uniform_scale)
619{
620 if (!use_uniform_scale)
621 // Recalculate cached values at this panel, refresh the screen.
622 this->UpdateAndShow(true);
623
624 m_uniform_scale = use_uniform_scale;
625 set_dirty();
626}
void set_dirty()
Definition GizmoObjectManipulation.hpp:124

References m_uniform_scale, set_dirty(), and UpdateAndShow().

Referenced by do_render_scale_input_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_use_object_cs()

void Slic3r::GUI::GizmoObjectManipulation::set_use_object_cs ( bool flag)
inline
130{ if (m_use_object_cs != flag) m_use_object_cs = flag; }

References m_use_object_cs.

◆ update_buffered_value()

void Slic3r::GUI::GizmoObjectManipulation::update_buffered_value ( )
private
205{
206 if (this->m_imperial_units)
208 else
210
214
215 if (this->m_imperial_units)
216 m_buffered_size = this->m_new_size * this->mm_to_in;
217 else
219}

References m_buffered_absolute_rotation, m_buffered_position, m_buffered_rotation, m_buffered_scale, m_buffered_size, m_imperial_units, m_new_absolute_rotation, m_new_position, m_new_rotation, m_new_scale, m_new_size, and mm_to_in.

Referenced by update_if_dirty(), and update_ui_from_settings().

Here is the caller graph for this function:

◆ update_if_dirty()

void Slic3r::GUI::GizmoObjectManipulation::update_if_dirty ( )
222{
223 if (! m_dirty)
224 return;
225
226 const Selection &selection = m_glcanvas.get_selection();
227 this->update_settings_value(selection);
228 this->update_buffered_value();
229
230 auto update_label = [](wxString &label_cache, const std::string &new_label) {
231 wxString new_label_localized = _(new_label) + ":";
232 if (label_cache != new_label_localized) {
233 label_cache = new_label_localized;
234 }
235 };
236 update_label(m_cache.move_label_string, m_new_move_label_string);
237 update_label(m_cache.rotate_label_string, m_new_rotate_label_string);
238 update_label(m_cache.rotate_label_string, m_new_rotate_label_string);
239 update_label(m_cache.scale_label_string, m_new_scale_label_string);
240
241 enum ManipulationEditorKey
242 {
243 mePosition = 0,
244 meRotation,
245 meScale,
246 meSize
247 };
248
249 for (int i = 0; i < 3; ++ i) {
250 auto update = [i](Vec3d &cached, Vec3d &cached_rounded, const Vec3d &new_value) {
251 //wxString new_text = double_to_string(new_value(i), 2);
252 double new_rounded = round(new_value(i)*100)/100.0;
253 //new_text.ToDouble(&new_rounded);
254 if (std::abs(cached_rounded(i) - new_rounded) > EPSILON) {
255 cached_rounded(i) = new_rounded;
256 //const int id = key_id*3+i;
257 //if (m_imperial_units && (key_id == mePosition || key_id == meSize))
258 // new_text = double_to_string(new_value(i)*mm_to_in, 2);
259 //if (id >= 0) m_editors[id]->set_value(new_text);
260 }
261 cached(i) = new_value(i);
262 };
263 update(m_cache.position, m_cache.position_rounded, m_new_position);
264 update(m_cache.scale, m_cache.scale_rounded, m_new_scale);
265 update(m_cache.size, m_cache.size_rounded, m_new_size);
266 update(m_cache.rotation, m_cache.rotation_rounded, m_new_rotation);
267 update(m_cache.absolute_rotation, m_cache.absolute_rotation_rounded, m_new_absolute_rotation);
268 }
269
271 //update_mirror_buttons_visibility();
272
273 m_dirty = false;
274}
#define _(s)
Definition 3mf.cpp:306
std::string m_new_rotate_label_string
Definition GizmoObjectManipulation.hpp:83
void update_reset_buttons_visibility()
Definition GizmoObjectManipulation.cpp:276
std::string m_new_move_label_string
Definition GizmoObjectManipulation.hpp:82
std::string m_new_scale_label_string
Definition GizmoObjectManipulation.hpp:84
void update_buffered_value()
Definition GizmoObjectManipulation.cpp:204
void update_settings_value(const Selection &selection)
Definition GizmoObjectManipulation.cpp:115

References _, EPSILON, m_cache, m_dirty, m_glcanvas, m_new_absolute_rotation, m_new_move_label_string, m_new_position, m_new_rotate_label_string, m_new_rotation, m_new_scale, m_new_scale_label_string, m_new_size, update_buffered_value(), update_reset_buttons_visibility(), and update_settings_value().

Referenced by UpdateAndShow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_reset_buttons_visibility()

void Slic3r::GUI::GizmoObjectManipulation::update_reset_buttons_visibility ( )
private
277{
278 const Selection& selection = m_glcanvas.get_selection();
279
280 // Assembly view has its own selection and transformations, which drop_selection() doesn't update
281 m_enable_drop_to_bed = m_glcanvas.get_canvas_type() == GLCanvas3D::ECanvasType::CanvasView3D && selection.can_drop();
282
283 if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) {
284 const GLVolume * volume = selection.get_first_volume();
285
286 Vec3d rotation;
287 Vec3d scale;
288
289 if (selection.is_single_full_instance()) {
290 rotation = volume->get_instance_rotation();
291 scale = volume->get_instance_scaling_factor();
292 }
293 else {
294 rotation = volume->get_volume_rotation();
295 scale = volume->get_volume_scaling_factor();
296 }
297 m_show_clear_rotation = !rotation.isApprox(m_init_rotation);
298 m_show_reset_0_rotation = !rotation.isApprox(Vec3d::Zero());
299 m_show_clear_scale = (m_cache.scale / 100.0f - Vec3d::Ones()).norm() > 0.001;
300 }
301}

References Slic3r::GUI::Selection::can_drop(), Slic3r::GUI::GLCanvas3D::CanvasView3D, Slic3r::GUI::Selection::get_first_volume(), Slic3r::GLVolume::get_instance_rotation(), Slic3r::GLVolume::get_instance_scaling_factor(), Slic3r::GLVolume::get_volume_rotation(), Slic3r::GLVolume::get_volume_scaling_factor(), Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), m_cache, m_enable_drop_to_bed, m_glcanvas, m_init_rotation, m_show_clear_rotation, m_show_clear_scale, m_show_reset_0_rotation, and scale().

Referenced by update_if_dirty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_settings_value()

void Slic3r::GUI::GizmoObjectManipulation::update_settings_value ( const Selection & selection)
private
116{
117 m_new_move_label_string = L("Position");
118 m_new_rotate_label_string = L("Rotate (relative)");
119 m_new_rotation = Vec3d::Zero();
120 m_new_absolute_rotation = Vec3d::Zero();
121 m_new_scale_label_string = L("Scale ratios");
122
123 ObjectList* obj_list = wxGetApp().obj_list();
124 if (selection.is_single_full_instance()) {
125 // all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one
126 const GLVolume* volume = selection.get_first_volume();
127 m_new_position = volume->get_instance_offset();
128 auto rotation = volume->get_instance_transformation().get_rotation_by_quaternion();
129 m_new_absolute_rotation = rotation * (180. / M_PI);
131 if (is_world_coordinates()) {//for move and rotate
132 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
133 m_unscale_size = selection.get_unscaled_instance_bounding_box().size();
134 m_new_scale = m_new_size.cwiseQuotient(m_unscale_size) * 100.0;
135 }
136 else {//if (is_local_coordinates()) {//for scale
137 auto tran = selection.get_first_volume()->get_instance_transformation();
138 m_new_position = tran.get_matrix().inverse() * cs_center;
140 m_new_position = Vec3d::Zero();
141 }
142 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
143 m_unscale_size = selection.get_full_unscaled_instance_local_bounding_box().size();
144 m_new_scale = m_new_size.cwiseQuotient(m_unscale_size) * 100.0;
145 }
146
147 m_new_enabled = true;
148 // BBS: change "Instance Operations" to "Object Operations"
149 m_new_title_string = L("Object operations");
150 }
151 else if (selection.is_single_full_object() && obj_list->is_selected(itObject)) {
152 const BoundingBoxf3& box = selection.get_bounding_box();
153 m_new_position = box.center();
154 m_new_scale = Vec3d(100., 100., 100.);
155 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
156 m_new_scale_label_string = L("Scale");
157 m_new_enabled = true;
158 m_new_title_string = L("Object operations");
159 } else if (selection.is_single_volume_or_modifier()) {
160 const GLVolume *volume = selection.get_first_volume();
161 auto rotation = volume->get_volume_transformation().get_rotation_by_quaternion();
162 m_new_absolute_rotation = rotation * (180. / M_PI);
164 if (is_world_coordinates()) {//for move and rotate
165 const Geometry::Transformation trafo(volume->world_matrix());
166 const Vec3d &offset = trafo.get_offset();
168 m_new_scale = Vec3d(100.0, 100.0, 100.0);
169 m_unscale_size = selection.get_bounding_box_in_current_reference_system().first.size();
170 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
171 } else if (is_local_coordinates()) {//for scale
172 m_new_position = Vec3d::Zero();
173 m_new_scale = volume->get_volume_scaling_factor() * 100.0;
174 m_unscale_size = selection.get_bounding_box_in_current_reference_system().first.size();
175 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
176 } else {
177 m_new_position = volume->get_volume_offset();
178 m_new_scale_label_string = L("Scale");
179 m_new_scale = Vec3d(100.0, 100.0, 100.0);
180 m_unscale_size = selection.get_bounding_box_in_current_reference_system().first.size();
181 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
182 }
183 m_new_enabled = true;
184 m_new_title_string = L("Volume operations");
187 m_new_move_label_string = L("Translate");
188 m_new_scale_label_string = L("Scale");
189 m_unscale_size = selection.get_bounding_box_in_current_reference_system().first.size();
190 m_new_size = selection.get_bounding_box_in_current_reference_system().first.size();
191 m_new_enabled = true;
192 m_new_title_string = L("Group operations");
193 } else if (selection.is_wipe_tower()) {
194 const BoundingBoxf3 &box = selection.get_bounding_box();
195 m_new_position = box.center();
196 }
197 else {
198 // No selection, reset the cache.
199// assert(selection.is_empty());
201 }
202}
Vec3d cs_center
Definition GizmoObjectManipulation.hpp:97
void reset_settings_value()
Definition GizmoObjectManipulation.cpp:304
bool is_selected(const ItemType type) const
Definition GUI_ObjectList.cpp:4891
bool is_connectors_item_selected() const
Definition GUI_ObjectList.cpp:4900
bool multiple_selection() const
Definition GUI_ObjectList.cpp:4886
void delete_negative_sign(Vec3d &value)
Definition GizmoObjectManipulation.cpp:108
static ObjectList * obj_list()
Definition GUI_Factories.cpp:405
@ itObject
Definition ObjectDataViewModel.hpp:37
@ itInstanceRoot
Definition ObjectDataViewModel.hpp:39
@ ObjectList
Definition Shortcuts.hpp:21

References Slic3r::BoundingBox3Base< PointType >::center(), cs_center, Slic3r::GUI::delete_negative_sign(), Slic3r::GUI::Selection::get_bounding_box(), Slic3r::GUI::Selection::get_bounding_box_in_current_reference_system(), Slic3r::GUI::Selection::get_first_volume(), Slic3r::GUI::Selection::get_full_unscaled_instance_local_bounding_box(), Slic3r::GLVolume::get_instance_offset(), Slic3r::GLVolume::get_instance_transformation(), Slic3r::Geometry::Transformation::get_offset(), Slic3r::Geometry::Transformation::get_rotation_by_quaternion(), Slic3r::GUI::Selection::get_unscaled_instance_bounding_box(), Slic3r::GLVolume::get_volume_offset(), Slic3r::GLVolume::get_volume_scaling_factor(), Slic3r::GLVolume::get_volume_transformation(), is_instance_coordinates(), is_local_coordinates(), Slic3r::GUI::Selection::is_single_full_instance(), Slic3r::GUI::Selection::is_single_full_object(), Slic3r::GUI::Selection::is_single_volume_or_modifier(), Slic3r::GUI::Selection::is_wipe_tower(), is_world_coordinates(), Slic3r::GUI::itInstanceRoot, Slic3r::GUI::itObject, L, m_new_absolute_rotation, m_new_enabled, m_new_move_label_string, m_new_position, m_new_rotate_label_string, m_new_rotation, m_new_scale, m_new_scale_label_string, m_new_size, m_new_title_string, M_PI, m_unscale_size, Slic3r::GUI::obj_list(), Slic3r::offset(), reset_settings_value(), Slic3r::BoundingBox3Base< PointType >::size(), and Slic3r::GLVolume::world_matrix().

Referenced by update_if_dirty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_ui_from_settings()

void Slic3r::GUI::GizmoObjectManipulation::update_ui_from_settings ( )
99{
100 if (m_imperial_units != (wxGetApp().app_config->get("use_inches") == "1")) {
101 m_imperial_units = wxGetApp().app_config->get("use_inches") == "1";
102
103 m_new_unit_string = m_imperial_units ? L_CONTEXT("in", "inches") : L("mm");
104
106 }
107}

References L, L_CONTEXT, m_imperial_units, m_new_unit_string, and update_buffered_value().

Here is the call graph for this function:

◆ UpdateAndShow()

void Slic3r::GUI::GizmoObjectManipulation::UpdateAndShow ( const bool show)
91{
92 if (show) {
93 this->set_dirty();
94 this->update_if_dirty();
95 }
96}
void update_if_dirty()
Definition GizmoObjectManipulation.cpp:221

References set_dirty(), and update_if_dirty().

Referenced by change_absolute_rotation_value(), change_position_value(), change_rotation_value(), change_scale_value(), change_size_value(), do_render_move_window(), do_render_scale_input_window(), reset_position_value(), reset_rotation_value(), set_coordinates_type(), and set_uniform_scaling().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cs_center

Vec3d Slic3r::GUI::GizmoObjectManipulation::cs_center

Referenced by update_settings_value().

◆ g_to_oz

const double Slic3r::GUI::GizmoObjectManipulation::g_to_oz = 0.035274
static

◆ in_to_mm

◆ last_move_input_window_width

float Slic3r::GUI::GizmoObjectManipulation::last_move_input_window_width = 0.0f
protected

Referenced by do_render_move_window().

◆ last_rotate_input_window_width

float Slic3r::GUI::GizmoObjectManipulation::last_rotate_input_window_width = 0.0f
protected

Referenced by do_render_rotate_window().

◆ last_scale_input_window_width

float Slic3r::GUI::GizmoObjectManipulation::last_scale_input_window_width = 0.0f
protected

◆ m_align_to_parent

bool Slic3r::GUI::GizmoObjectManipulation::m_align_to_parent {false}
private

◆ m_alignment_helper

GLGizmoAlignment Slic3r::GUI::GizmoObjectManipulation::m_alignment_helper
private

◆ m_buffered_absolute_rotation

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_buffered_absolute_rotation

◆ m_buffered_position

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_buffered_position

◆ m_buffered_rotation

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_buffered_rotation

◆ m_buffered_scale

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_buffered_scale

◆ m_buffered_size

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_buffered_size

◆ m_cache

◆ m_can_align_within

bool Slic3r::GUI::GizmoObjectManipulation::m_can_align_within {false}
private
192{false};

Referenced by do_render_move_window(), and reset_align_state().

◆ m_coordinates_type

◆ m_dirty

bool Slic3r::GUI::GizmoObjectManipulation::m_dirty = false

Referenced by set_dirty(), and update_if_dirty().

◆ m_enable_drop_to_bed

bool Slic3r::GUI::GizmoObjectManipulation::m_enable_drop_to_bed { false }

◆ m_glcanvas

◆ m_hovered_align_type

◆ m_imperial_units

bool Slic3r::GUI::GizmoObjectManipulation::m_imperial_units { false }

◆ m_init_rotation

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_init_rotation
private

◆ m_init_rotation_scale_tran

Transform3d Slic3r::GUI::GizmoObjectManipulation::m_init_rotation_scale_tran
private

◆ m_last_active_item

unsigned int Slic3r::GUI::GizmoObjectManipulation::m_last_active_item { 0 }
private

◆ m_last_rotate_type

RotateType Slic3r::GUI::GizmoObjectManipulation::m_last_rotate_type {RotateType::None}
109{RotateType::None}; // 0:no input 1:relative 2:absolute

Referenced by do_render_rotate_window().

◆ m_new_absolute_rotation

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_new_absolute_rotation

◆ m_new_enabled

bool Slic3r::GUI::GizmoObjectManipulation::m_new_enabled {true}
98{true};

Referenced by reset_settings_value(), and update_settings_value().

◆ m_new_move_label_string

std::string Slic3r::GUI::GizmoObjectManipulation::m_new_move_label_string

◆ m_new_position

◆ m_new_rotate_label_string

std::string Slic3r::GUI::GizmoObjectManipulation::m_new_rotate_label_string

◆ m_new_rotation

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_new_rotation

◆ m_new_scale

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_new_scale

◆ m_new_scale_label_string

std::string Slic3r::GUI::GizmoObjectManipulation::m_new_scale_label_string

◆ m_new_size

◆ m_new_title_string

std::string Slic3r::GUI::GizmoObjectManipulation::m_new_title_string

◆ m_new_unit_string

std::string Slic3r::GUI::GizmoObjectManipulation::m_new_unit_string

◆ m_shortcuts_move

std::vector<std::pair<wxString, wxString> > Slic3r::GUI::GizmoObjectManipulation::m_shortcuts_move
private

◆ m_shortcuts_rotate

std::vector<std::pair<wxString, wxString> > Slic3r::GUI::GizmoObjectManipulation::m_shortcuts_rotate
private

◆ m_shortcuts_scale

std::vector<std::pair<wxString, wxString> > Slic3r::GUI::GizmoObjectManipulation::m_shortcuts_scale
private

◆ m_show_clear_rotation

bool Slic3r::GUI::GizmoObjectManipulation::m_show_clear_rotation { false }

◆ m_show_clear_scale

bool Slic3r::GUI::GizmoObjectManipulation::m_show_clear_scale { false }

◆ m_show_reset_0_rotation

bool Slic3r::GUI::GizmoObjectManipulation::m_show_reset_0_rotation {false}

◆ m_uniform_scale

bool Slic3r::GUI::GizmoObjectManipulation::m_uniform_scale {true}

◆ m_unscale_size

Vec3d Slic3r::GUI::GizmoObjectManipulation::m_unscale_size

◆ m_use_object_cs

bool Slic3r::GUI::GizmoObjectManipulation::m_use_object_cs {false}
69{false};

Referenced by get_use_object_cs(), and set_use_object_cs().

◆ mm_to_in

◆ oz_to_g

const double Slic3r::GUI::GizmoObjectManipulation::oz_to_g = 28.34952
static

The documentation for this class was generated from the following files: