Prepare integration for arbitrary shaped print beds.

This commit is contained in:
tamasmeszaros 2018-07-30 16:41:35 +02:00
commit 6cdec7ac9a
12 changed files with 555 additions and 549 deletions

View file

@ -8,6 +8,7 @@
#include <unordered_map>
#include <slic3r/GUI/GUI.hpp>
#include <ModelArrange.hpp>
#include <slic3r/GUI/PresetBundle.hpp>
#include <Geometry.hpp>
@ -310,12 +311,13 @@ void AppController::arrange_model()
auto dist = print_ctl()->config().min_object_distance();
BoundingBoxf bb(print_ctl()->config().bed_shape.values);
if(pind) pind->update(0, _(L("Arranging objects...")));
try {
model_->arrange_objects(dist, &bb, [pind, count](unsigned rem){
arr::arrange(*model_, dist, &bb, false, [pind, count](unsigned rem){
if(pind) pind->update(count - rem, _(L("Arranging objects...")));
});
} catch(std::exception& e) {

View file

@ -2697,9 +2697,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
else if (evt.Leaving())
{
// to remove hover when mouse goes out of this canvas
m_mouse.position = Pointf((coordf_t)pos.x, (coordf_t)pos.y);
render();
// to remove hover on objects when the mouse goes out of this canvas
m_mouse.position = Pointf(-1.0, -1.0);
m_dirty = true;
}
else if (evt.LeftDClick() && (m_hover_volume_id != -1))
m_on_double_click_callback.call();
@ -3403,20 +3403,22 @@ void GLCanvas3D::_picking_pass() const
if (m_multisample_allowed)
::glEnable(GL_MULTISAMPLE);
const Size& cnv_size = get_canvas_size();
GLubyte color[4];
::glReadPixels(pos.x, cnv_size.get_height() - pos.y - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color);
int volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256;
m_hover_volume_id = -1;
int volume_id = -1;
for (GLVolume* vol : m_volumes.volumes)
{
vol->hover = false;
}
if (volume_id < (int)m_volumes.volumes.size())
GLubyte color[4] = { 0, 0, 0, 0 };
const Size& cnv_size = get_canvas_size();
bool inside = (0 <= pos.x) && (pos.x < cnv_size.get_width()) && (0 <= pos.y) && (pos.y < cnv_size.get_height());
if (inside)
{
::glReadPixels(pos.x, cnv_size.get_height() - pos.y - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)color);
volume_id = color[0] + color[1] * 256 + color[2] * 256 * 256;
}
if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size()))
{
m_hover_volume_id = volume_id;
m_volumes.volumes[volume_id]->hover = true;
@ -3432,7 +3434,10 @@ void GLCanvas3D::_picking_pass() const
m_gizmos.set_hover_id(-1);
}
else
m_gizmos.set_hover_id(254 - (int)color[2]);
{
m_hover_volume_id = -1;
m_gizmos.set_hover_id(inside ? (254 - (int)color[2]) : -1);
}
// updates gizmos overlay
if (_get_first_selected_object_id() != -1)