mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 09:11:23 -06:00
Right mouse reaction to arrange button
Working arrange settings popup
This commit is contained in:
parent
d9f845d0b3
commit
d5bdaceff2
5 changed files with 69 additions and 23 deletions
|
|
@ -170,7 +170,7 @@ void GLCanvas3D::LayersEditing::init()
|
|||
}
|
||||
|
||||
void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config)
|
||||
{
|
||||
{
|
||||
m_config = config;
|
||||
delete m_slicing_parameters;
|
||||
m_slicing_parameters = nullptr;
|
||||
|
|
@ -1325,6 +1325,9 @@ void GLCanvas3D::update_instance_printable_state_for_objects(std::vector<size_t>
|
|||
|
||||
void GLCanvas3D::set_config(const DynamicPrintConfig* config)
|
||||
{
|
||||
if (!m_config)
|
||||
m_arrange_settings.distance = min_object_distance(*config);
|
||||
|
||||
m_config = config;
|
||||
m_layers_editing.set_config(config);
|
||||
}
|
||||
|
|
@ -3847,6 +3850,30 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
return action_taken;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_render_arrange_popup()
|
||||
{
|
||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||
|
||||
float x = 0.5f * (float)get_canvas_size().get_width();
|
||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
|
||||
imgui->begin(_(L("Arrange options")), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
ArrangeSettings settings = m_arrange_settings;
|
||||
|
||||
if (imgui->slider_float(_(L("Gap size")), &settings.distance, 0.f, 100.f))
|
||||
m_arrange_settings.distance = settings.distance;
|
||||
|
||||
if (imgui->slider_float(_(L("Accuracy")), &settings.accuracy, 0.f, 1.f))
|
||||
m_arrange_settings.accuracy = settings.accuracy;
|
||||
|
||||
if (imgui->checkbox(_(L("Enable rotations")), settings.enable_rotation))
|
||||
m_arrange_settings.enable_rotation = settings.enable_rotation;
|
||||
|
||||
imgui->end();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT 0
|
||||
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
|
||||
static void debug_output_thumbnail(const ThumbnailData& thumbnail_data)
|
||||
|
|
@ -4263,6 +4290,13 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
item.sprite_id = 3;
|
||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); };
|
||||
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); };
|
||||
item.right.toggable = true;
|
||||
item.right.render_callback = [this](float left, float right, float, float) {
|
||||
if (m_canvas != nullptr)
|
||||
{
|
||||
_render_arrange_popup();
|
||||
}
|
||||
};
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -381,6 +381,13 @@ public:
|
|||
Cross
|
||||
};
|
||||
|
||||
struct ArrangeSettings
|
||||
{
|
||||
float distance = 6.;
|
||||
float accuracy = 0.65f;
|
||||
bool enable_rotation = false;
|
||||
};
|
||||
|
||||
private:
|
||||
wxGLCanvas* m_canvas;
|
||||
wxGLContext* m_context;
|
||||
|
|
@ -452,6 +459,8 @@ private:
|
|||
mutable bool m_tooltip_enabled{ true };
|
||||
Slope m_slope;
|
||||
|
||||
ArrangeSettings m_arrange_settings;
|
||||
|
||||
public:
|
||||
explicit GLCanvas3D(wxGLCanvas* canvas);
|
||||
~GLCanvas3D();
|
||||
|
|
@ -671,6 +680,8 @@ public:
|
|||
void use_slope(bool use) { m_slope.use(use); }
|
||||
void set_slope_normal_angle(float angle_in_deg) { m_slope.set_normal_angle(angle_in_deg); }
|
||||
|
||||
const ArrangeSettings& get_arrange_settings() const { return m_arrange_settings; }
|
||||
|
||||
private:
|
||||
bool _is_shown_on_screen() const;
|
||||
|
||||
|
|
@ -717,6 +728,7 @@ private:
|
|||
void _render_selection_sidebar_hints() const;
|
||||
bool _render_undo_redo_stack(const bool is_undo, float pos_x) const;
|
||||
bool _render_search_list(float pos_x) const;
|
||||
bool _render_arrange_popup();
|
||||
void _render_thumbnail_internal(ThumbnailData& thumbnail_data, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
||||
// render thumbnail using an off-screen framebuffer
|
||||
void _render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const;
|
||||
|
|
|
|||
|
|
@ -147,11 +147,13 @@ void ArrangeJob::prepare()
|
|||
void ArrangeJob::process()
|
||||
{
|
||||
static const auto arrangestr = _(L("Arranging"));
|
||||
|
||||
double dist = min_object_distance(*m_plater->config());
|
||||
|
||||
GLCanvas3D::ArrangeSettings settings =
|
||||
m_plater->canvas3D()->get_arrange_settings();
|
||||
|
||||
arrangement::ArrangeParams params;
|
||||
params.min_obj_distance = scaled(dist);
|
||||
params.min_obj_distance = scaled(settings.distance);
|
||||
params.allow_rotations = settings.enable_rotation;
|
||||
|
||||
auto count = unsigned(m_selected.size() + m_unprintable.size());
|
||||
Points bedpts = get_bed_shape(*m_plater->config());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue