NEW:add "set grabber size" imgui
jira: STUDIO-7395 Change-Id: I87aeb683cf29e004d6b285810c5135f2b45ae4b9
This commit is contained in:
parent
7b7801b825
commit
56f628dac1
|
@ -172,8 +172,10 @@ void AppConfig::set_defaults()
|
|||
|
||||
if (get("zoom_to_mouse").empty())
|
||||
set_bool("zoom_to_mouse", false);
|
||||
if (get("user_bed_type").empty())
|
||||
if (get("user_bed_type").empty())
|
||||
set_bool("user_bed_type", true);
|
||||
if (get("grabber_size_factor").empty())
|
||||
set("grabber_size_factor", "1.0");
|
||||
//#ifdef SUPPORT_SHOW_HINTS
|
||||
if (get("show_hints").empty())
|
||||
set_bool("show_hints", true);
|
||||
|
|
|
@ -18,6 +18,7 @@ const float GLGizmoBase::Grabber::SizeFactor = 0.05f;
|
|||
const float GLGizmoBase::Grabber::MinHalfSize = 4.0f;
|
||||
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
|
||||
const float GLGizmoBase::Grabber::FixedGrabberSize = 16.0f;
|
||||
float GLGizmoBase::Grabber::GrabberSizeFactor = 1.0f;
|
||||
const float GLGizmoBase::Grabber::FixedRadiusSize = 80.0f;
|
||||
|
||||
|
||||
|
@ -130,7 +131,7 @@ void GLGizmoBase::Grabber::render(float size, const std::array<float, 4>& render
|
|||
if (GLGizmoBase::INV_ZOOM > 0) {
|
||||
fullsize = FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
||||
}
|
||||
|
||||
fullsize = fullsize * Grabber::GrabberSizeFactor;
|
||||
|
||||
const_cast<GLModel*>(&cube)->set_color(-1, render_color);
|
||||
|
||||
|
|
|
@ -61,13 +61,14 @@ public:
|
|||
static void update_render_colors();
|
||||
static void load_render_colors();
|
||||
|
||||
protected:
|
||||
|
||||
struct Grabber
|
||||
{
|
||||
static const float SizeFactor;
|
||||
static const float MinHalfSize;
|
||||
static const float DraggingScaleFactor;
|
||||
static const float FixedGrabberSize;
|
||||
static float GrabberSizeFactor;
|
||||
static const float FixedRadiusSize;
|
||||
|
||||
Vec3d center;
|
||||
|
|
|
@ -32,6 +32,12 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filenam
|
|||
, m_object_manipulation(obj_manipulation)
|
||||
{
|
||||
m_vbo_cone.init_from(its_make_cone(1., 1., 2*PI/36));
|
||||
try {
|
||||
float value = std::stof(wxGetApp().app_config->get("grabber_size_factor"));
|
||||
GLGizmoBase::Grabber::GrabberSizeFactor = value;
|
||||
} catch (const std::invalid_argument &e) {
|
||||
GLGizmoBase::Grabber::GrabberSizeFactor = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GLGizmoMove3D::get_tooltip() const
|
||||
|
@ -131,7 +137,7 @@ void GLGizmoMove3D::on_render()
|
|||
}
|
||||
m_orient_matrix = box_trafo;
|
||||
float space_size = 20.f *INV_ZOOM;
|
||||
|
||||
space_size *= GLGizmoBase::Grabber::GrabberSizeFactor;
|
||||
#if ENABLE_FIXED_GRABBER
|
||||
// x axis
|
||||
m_grabbers[0].center = {m_bounding_box.max.x() + space_size, 0, 0};
|
||||
|
@ -183,7 +189,7 @@ void GLGizmoMove3D::on_render()
|
|||
}
|
||||
glsafe(::glPopMatrix());
|
||||
|
||||
if (!selection.is_multiple_full_object()) {
|
||||
if (m_object_manipulation->is_instance_coordinates()) {
|
||||
glsafe(::glPushMatrix());
|
||||
Geometry::Transformation cur_tran;
|
||||
if (auto mi = m_parent.get_selection().get_selected_single_intance()) {
|
||||
|
@ -256,14 +262,8 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const
|
|||
|
||||
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const
|
||||
{
|
||||
#if ENABLE_FIXED_GRABBER
|
||||
float mean_size = (float)(GLGizmoBase::Grabber::FixedGrabberSize);
|
||||
#else
|
||||
float mean_size = (float)((box.size().x() + box.size().y() + box.size().z()) / 3.0);
|
||||
#endif
|
||||
|
||||
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
||||
|
||||
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
|
||||
std::array<float, 4> color = m_grabbers[axis].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
if (m_hover_id == axis) {
|
||||
|
|
|
@ -315,8 +315,7 @@ void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const
|
|||
void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool picking) const
|
||||
{
|
||||
double size = 0.75 * GLGizmoBase::Grabber::FixedGrabberSize * GLGizmoBase::INV_ZOOM;
|
||||
//float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
//double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
||||
size = size * GLGizmoBase::Grabber::GrabberSizeFactor;
|
||||
|
||||
std::array<float, 4> color = m_grabbers[0].color;
|
||||
if (!picking && m_hover_id != -1) {
|
||||
|
|
|
@ -426,6 +426,36 @@ void GizmoObjectManipulation::on_change(const std::string& opt_key, int axis, do
|
|||
change_size_value(axis, new_value);
|
||||
}
|
||||
|
||||
bool 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)
|
||||
{
|
||||
ImGui::AlignTextToFramePadding();
|
||||
imgui_wrapper->text(label);
|
||||
ImGui::SameLine(label_width);
|
||||
ImGui::PushItemWidth(item_width);
|
||||
|
||||
size_t selection_out = selection_idx;
|
||||
|
||||
const char *selected_str = (selection_idx >= 0 && selection_idx < int(lines.size())) ? lines[selection_idx].c_str() : "";
|
||||
if (ImGui::BBLBeginCombo(("##" + label).c_str(), selected_str, 0)) {
|
||||
for (size_t line_idx = 0; line_idx < lines.size(); ++line_idx) {
|
||||
ImGui::PushID(int(line_idx));
|
||||
if (ImGui::Selectable("", line_idx == selection_idx)) selection_out = line_idx;
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", lines[line_idx].c_str());
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
bool is_changed = selection_idx != selection_out;
|
||||
selection_idx = selection_out;
|
||||
|
||||
return is_changed;
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::reset_position_value()
|
||||
{
|
||||
Selection& selection = m_glcanvas.get_selection();
|
||||
|
@ -701,8 +731,8 @@ void GizmoObjectManipulation::show_scale_tooltip_information(ImGuiWrapper *imgui
|
|||
|
||||
float space_size = imgui_wrapper->get_style_scaling() * 8;
|
||||
float position_size = imgui_wrapper->calc_text_size(_L("Position")).x + space_size;
|
||||
float World_size = imgui_wrapper->calc_text_size(_L("World coordinates")).x + space_size;
|
||||
float caption_max = std::max(position_size, World_size) + 2 * space_size;
|
||||
float object_cs_size = imgui_wrapper->calc_text_size(_L("Object coordinates")).x + imgui_wrapper->calc_text_size(" ").x + space_size;
|
||||
float caption_max = std::max(position_size, object_cs_size) + 2 * space_size;
|
||||
float end_text_size = imgui_wrapper->calc_text_size(this->m_new_unit_string).x;
|
||||
|
||||
// position
|
||||
|
@ -722,12 +752,25 @@ void GizmoObjectManipulation::show_scale_tooltip_information(ImGuiWrapper *imgui
|
|||
ImGui::AlignTextToFramePadding();
|
||||
unsigned int current_active_id = ImGui::GetActiveID();
|
||||
ImGui::PushItemWidth(caption_max);
|
||||
if (!m_glcanvas.get_selection().is_multiple_full_instance() && m_use_object_cs) {
|
||||
imgui_wrapper->text(_L("Object coordinates"));
|
||||
Selection & selection = m_glcanvas.get_selection();
|
||||
std::vector<std::string> modes = {_u8L("World coordinates"), _u8L("Object coordinates")};//_u8L("Part coordinates")
|
||||
if (selection.is_multiple_full_object()) {
|
||||
modes.pop_back();
|
||||
}
|
||||
else {
|
||||
imgui_wrapper->text(_L("World coordinates"));
|
||||
size_t selection_idx = (int) m_coordinates_type;
|
||||
if (selection_idx >= modes.size()) {
|
||||
set_coordinates_type(ECoordinatesType::World);
|
||||
selection_idx = 0;
|
||||
}
|
||||
float caption_cs_size = imgui_wrapper->calc_text_size("").x;
|
||||
float combox_content_size = imgui_wrapper->calc_text_size(_L("Object coordinates")).x * 1.1 + ImGui::GetStyle().FramePadding.x * 18.0f;
|
||||
float caption_size = caption_cs_size + 2 * space_size;
|
||||
ImGuiWrapper::push_combo_style(m_glcanvas.get_scale());
|
||||
bool combox_changed = false;
|
||||
if (render_combo(imgui_wrapper, "", modes, selection_idx, caption_size, combox_content_size)) {
|
||||
combox_changed = true;
|
||||
}
|
||||
ImGuiWrapper::pop_combo_style();
|
||||
ImGui::SameLine(caption_max + index * space_size);
|
||||
ImGui::PushItemWidth(unit_size);
|
||||
ImGui::TextAlignCenter("X");
|
||||
|
@ -754,16 +797,11 @@ void GizmoObjectManipulation::show_scale_tooltip_information(ImGuiWrapper *imgui
|
|||
ImGui::SameLine(caption_max + (++index_unit) * unit_size + (++index) * space_size);
|
||||
imgui_wrapper->text(this->m_new_unit_string);
|
||||
bool is_avoid_one_update{false};
|
||||
if (!m_glcanvas.get_selection().is_multiple_full_object()) {
|
||||
if (bbl_checkbox(_L("Object coordinates"), m_use_object_cs)) {
|
||||
if (m_use_object_cs) {
|
||||
set_coordinates_type(ECoordinatesType::Instance);
|
||||
} else {
|
||||
set_coordinates_type(ECoordinatesType::World);
|
||||
}
|
||||
UpdateAndShow(true);
|
||||
is_avoid_one_update = true; // avoid update(current_active_id, "position", original_position
|
||||
}
|
||||
if (combox_changed) {
|
||||
combox_changed = false;
|
||||
set_coordinates_type((ECoordinatesType) selection_idx);
|
||||
UpdateAndShow(true);
|
||||
is_avoid_one_update = true; // avoid update(current_active_id, "position", original_position
|
||||
}
|
||||
|
||||
if (!is_avoid_one_update) {
|
||||
|
|
|
@ -119,6 +119,7 @@ public:
|
|||
void reset_cache() { m_cache.reset(); }
|
||||
|
||||
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);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "Widgets/TextInput.hpp"
|
||||
#include <wx/listimpl.cpp>
|
||||
#include <map>
|
||||
|
||||
#include "Gizmos/GLGizmoBase.hpp"
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef _MSW_DARK_MODE
|
||||
#include "dark_mode.hpp"
|
||||
|
@ -472,6 +472,63 @@ wxBoxSizer *PreferencesDialog::create_item_input(wxString title, wxString title2
|
|||
return sizer_input;
|
||||
}
|
||||
|
||||
wxBoxSizer *PreferencesDialog::create_item_range_input(
|
||||
wxString title, wxWindow *parent, wxString tooltip, std::string param, float range_min, float range_max, int keep_digital, std::function<void(wxString)> onchange)
|
||||
{
|
||||
wxBoxSizer *sizer_input = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto input_title = new wxStaticText(parent, wxID_ANY, title);
|
||||
input_title->SetForegroundColour(DESIGN_GRAY900_COLOR);
|
||||
input_title->SetFont(::Label::Body_13);
|
||||
input_title->SetToolTip(tooltip);
|
||||
input_title->Wrap(-1);
|
||||
|
||||
auto float_value = std::atof(app_config->get(param).c_str());
|
||||
if (float_value < range_min || float_value > range_max) {
|
||||
float_value = range_min;
|
||||
app_config->set(param, std::to_string(range_min));
|
||||
app_config->save();
|
||||
}
|
||||
auto input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, DESIGN_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled), std::pair<wxColour, int>(*wxWHITE, StateColor::Enabled));
|
||||
input->SetBackgroundColor(input_bg);
|
||||
input->GetTextCtrl()->SetValue(app_config->get(param));
|
||||
wxTextValidator validator(wxFILTER_NUMERIC);
|
||||
input->GetTextCtrl()->SetValidator(validator);
|
||||
|
||||
sizer_input->Add(0, 0, 0, wxEXPAND | wxLEFT, 23);
|
||||
sizer_input->Add(input_title, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3);
|
||||
sizer_input->Add(input, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
auto format_str=[](int keep_digital,float val){
|
||||
std::stringstream ss;
|
||||
ss << std::fixed << std::setprecision(keep_digital) << val;
|
||||
return ss.str();
|
||||
};
|
||||
auto set_value_to_app = [this, param, onchange, input, range_min, range_max, format_str, keep_digital](float value, bool update_slider) {
|
||||
if (value < range_min) { value = range_min; }
|
||||
if (value > range_max) { value = range_max; }
|
||||
auto str = format_str(keep_digital, value);
|
||||
app_config->set(param, str);
|
||||
app_config->save();
|
||||
if (onchange) {
|
||||
onchange(str);
|
||||
}
|
||||
input->GetTextCtrl()->SetValue(str);
|
||||
};
|
||||
input->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [this, set_value_to_app, input](wxCommandEvent &e) {
|
||||
auto value = std::atof(input->GetTextCtrl()->GetValue().c_str());
|
||||
set_value_to_app(value,true);
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, [this, set_value_to_app, input](wxFocusEvent &e) {
|
||||
auto value = std::atof(input->GetTextCtrl()->GetValue().c_str());
|
||||
set_value_to_app(value, true);
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
return sizer_input;
|
||||
}
|
||||
|
||||
wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param)
|
||||
{
|
||||
wxBoxSizer *m_sizer_input = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -1039,7 +1096,6 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
#endif
|
||||
50, "single_instance");
|
||||
|
||||
auto item_mouse_zoom_settings = create_item_checkbox(_L("Zoom to mouse position"), page, _L("Zoom in towards the mouse pointer's position in the 3D view, rather than the 2D window center."), 50, "zoom_to_mouse");
|
||||
auto item_bed_type_follow_preset = create_item_checkbox(_L("Auto plate type"), page,
|
||||
_L("Studio will remember build plate selected last time for certain printer model."), 50,
|
||||
"user_bed_type");
|
||||
|
@ -1047,6 +1103,21 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
auto item_calc_mode = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time when the color is changed."), page, _L("If enabled, auto-calculate every time when the color is changed."), 50, "auto_calculate");
|
||||
auto item_calc_in_long_retract = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time when the filament is changed."), page, _L("If enabled, auto-calculate every time when filament is changed"), 50, "auto_calculate_when_filament_change");
|
||||
auto item_multi_machine = create_item_checkbox(_L("Multi-device Management(Take effect after restarting Studio)."), page, _L("With this option enabled, you can send a task to multiple devices at the same time and manage multiple devices."), 50, "enable_multi_machine");
|
||||
auto _3d_settings = create_item_title(_L("3D Settings"), page, _L("3D Settings"));
|
||||
auto item_mouse_zoom_settings = create_item_checkbox(_L("Zoom to mouse position"), page,
|
||||
_L("Zoom in towards the mouse pointer's position in the 3D view, rather than the 2D window center."), 50,
|
||||
"zoom_to_mouse");
|
||||
float range_min = 1.0, range_max = 2.5;
|
||||
auto item_grabber_size_settings = create_item_range_input(_L("Grabber scale"), page,
|
||||
_L("Set grabber size for move,rotate,scale tool.") + _L("Value range") + ":[" + std::to_string(range_min) + "," +
|
||||
std::to_string(range_max) +
|
||||
"]","grabber_size_factor", range_min, range_max, 1,
|
||||
[](wxString value) {
|
||||
double d_value = 0;
|
||||
if (value.ToDouble(&d_value)) {
|
||||
GLGizmoBase::Grabber::GrabberSizeFactor = d_value;
|
||||
}
|
||||
});
|
||||
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
|
||||
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
|
||||
auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), page, _L("System Sync"), 50, "sync_system_preset");
|
||||
|
@ -1110,12 +1181,14 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
sizer_page->Add(item_region, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_currency, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_single_instance, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_bed_type_follow_preset, 0, wxTOP, FromDIP(3));
|
||||
//sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_calc_mode, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_calc_in_long_retract, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_multi_machine, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(_3d_settings, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_mouse_zoom_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_grabber_size_settings, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));
|
||||
|
|
|
@ -114,6 +114,8 @@ public:
|
|||
wxBoxSizer *create_item_button(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::function<void()> onclick);
|
||||
wxWindow* create_item_downloads(wxWindow* parent, int padding_left, std::string param);
|
||||
wxBoxSizer *create_item_input(wxString title, wxString title2, wxWindow *parent, wxString tooltip, std::string param, std::function<void(wxString)> onchange = {});
|
||||
wxBoxSizer *create_item_range_input(
|
||||
wxString title, wxWindow *parent, wxString tooltip, std::string param, float range_min, float range_max, int keep_digital,std::function<void(wxString)> onchange = {});
|
||||
wxBoxSizer *create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param);
|
||||
wxBoxSizer *create_item_multiple_combobox(
|
||||
wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string parama, std::vector<wxString> vlista, std::vector<wxString> vlistb);
|
||||
|
|
Loading…
Reference in New Issue