Fixed conflicts after merge with master

This commit is contained in:
Enrico Turri 2019-03-20 16:09:14 +01:00
commit 3a923b7121
11 changed files with 117 additions and 79 deletions

View file

@ -58,11 +58,20 @@ Note that Slic3r PE is tested with wxWidgets 3.0 somewhat sporadically and so th
### Build variant
By default Scli3r builds the release variant.
By default Slic3r builds the release variant.
To create a debug build, use the following CMake flag:
-DCMAKE_BUILD_TYPE=Debug
### Enabling address sanitizer
If you're using GCC/Clang compiler, it is possible to build Slic3r with the built-in address sanitizer enabled to help detect memory-corruption issues.
To enable it, simply use the following CMake flag:
-DSLIC3R_ASAN=1
This requires GCC>4.8 or Clang>3.1.
### Installation
At runtime, Slic3r needs a way to access its resource files. By default, it looks for a `resources` directory relative to its binary.

View file

@ -249,6 +249,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
, is_wipe_tower(false)
, is_extrusion_path(false)
, force_transparent(false)
, force_native_color(false)
, tverts_range(0, size_t(-1))
, qverts_range(0, size_t(-1))
{
@ -280,16 +281,20 @@ void GLVolume::set_render_color(const float* rgba, unsigned int size)
void GLVolume::set_render_color()
{
if (selected)
set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
else if (hover)
set_render_color(HOVER_COLOR, 4);
else if (disabled)
set_render_color(DISABLED_COLOR, 4);
else if (is_outside && shader_outside_printer_detection_enabled)
set_render_color(OUTSIDE_COLOR, 4);
else
if (force_native_color)
set_render_color(color, 4);
else {
if (selected)
set_render_color(is_outside ? SELECTED_OUTSIDE_COLOR : SELECTED_COLOR, 4);
else if (hover)
set_render_color(HOVER_COLOR, 4);
else if (disabled)
set_render_color(DISABLED_COLOR, 4);
else if (is_outside && shader_outside_printer_detection_enabled)
set_render_color(OUTSIDE_COLOR, 4);
else
set_render_color(color, 4);
}
if (force_transparent)
render_color[3] = color[3];

View file

@ -302,6 +302,8 @@ public:
bool is_extrusion_path;
// Wheter or not to always render this volume using its own alpha
bool force_transparent;
// Whether or not always use the volume's own color (not using SELECTED/HOVER/DISABLED/OUTSIDE)
bool force_native_color;
// Interleaved triangles & normals with indexed triangles & quads.
GLIndexedVertexArray indexed_vertex_array;

View file

@ -1300,8 +1300,10 @@ void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject
{
for (GLVolume* vol : m_volumes.volumes) {
if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo)
&& (instance_idx == -1 || vol->composite_id.instance_id == instance_idx))
&& (instance_idx == -1 || vol->composite_id.instance_id == instance_idx)) {
vol->is_active = visible;
vol->force_native_color = (instance_idx != -1);
}
}
if (visible && !mo)
toggle_sla_auxiliaries_visibility(true);
@ -2169,7 +2171,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'a':
case 'A':
case WXK_CONTROL_A:
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.mouse_event(SLAGizmoEventType::SelectAll)) // Sla gizmo selects all support points
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::SelectAll)) // Sla gizmo selects all support points
m_dirty = true;
else
post_event(SimpleEvent(EVT_GLCANVAS_SELECT_ALL));
@ -2189,14 +2191,14 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
{
// key ESC
case WXK_ESCAPE: {
if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports || !m_gizmos.mouse_event(SLAGizmoEventType::DiscardChanges))
if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports || !m_gizmos.gizmo_event(SLAGizmoEventType::DiscardChanges))
m_gizmos.reset_all_states();
m_dirty = true;
break;
}
case WXK_RETURN: {
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.mouse_event(SLAGizmoEventType::ApplyChanges))
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::ApplyChanges))
m_dirty = true;
break;
}
@ -2206,7 +2208,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
#else /* __APPLE__ */
case WXK_DELETE:
#endif /* __APPLE__ */
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.mouse_event(SLAGizmoEventType::Delete))
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::Delete))
m_dirty = true;
else
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE));
@ -2225,7 +2227,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'A':
case 'a': {
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports) {
if (m_gizmos.mouse_event(SLAGizmoEventType::AutomaticGeneration))
if (m_gizmos.gizmo_event(SLAGizmoEventType::AutomaticGeneration))
m_dirty = true;
}
else
@ -2242,7 +2244,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'z': { m_selection.is_empty() ? zoom_to_volumes() : zoom_to_selection(); break; }
case 'M':
case 'm': {
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.mouse_event(SLAGizmoEventType::ManualEditing)) {
if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::ManualEditing)) {
m_dirty = true;
break;
}
@ -2276,7 +2278,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
// Enable switching between 3D and Preview with Tab
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
} else if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.mouse_event(SLAGizmoEventType::ShiftUp)) {
} else if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.gizmo_event(SLAGizmoEventType::ShiftUp)) {
// shift has been just released - SLA gizmo might want to close rectangular selection.
m_dirty = true;
}
@ -2512,10 +2514,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
_update_gizmos_data();
m_dirty = true;
}
else if (evt.LeftDown() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && evt.ShiftDown() && m_gizmos.mouse_event(SLAGizmoEventType::LeftDown, Vec2d(pos(0), pos(1)), evt.ShiftDown()))
{
// the gizmo got the event and took some action, there is no need to do anything more
}
else if (evt.LeftDown() && !m_selection.is_empty() && m_gizmos.grabber_contains_mouse())
{
_update_gizmos_data();
@ -2531,7 +2529,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_dirty = true;
}
else if ((selected_object_idx != -1) && evt.RightDown() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.mouse_event(SLAGizmoEventType::RightDown))
else if (evt.LeftDown() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::LeftDown, Vec2d(pos(0), pos(1)), evt.ShiftDown()))
{
// the gizmo got the event and took some action, there is no need to do anything more
}
else if ((selected_object_idx != -1) && evt.RightDown() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::RightDown))
{
// event was taken care of by the SlaSupports gizmo
}
@ -2688,7 +2690,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_dirty = true;
}
else if (evt.Dragging() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && evt.ShiftDown() && m_gizmos.mouse_event(SLAGizmoEventType::Dragging, Vec2d(pos(0), pos(1)), evt.ShiftDown()))
else if (evt.Dragging() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && m_gizmos.gizmo_event(SLAGizmoEventType::Dragging, Vec2d(pos(0), pos(1)), evt.ShiftDown()))
{
// the gizmo got the event and took some action, no need to do anything more here
m_dirty = true;
@ -2741,11 +2743,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_layers_editing.accept_changes(*this);
}
else if (evt.LeftUp() && m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && !m_gizmos.is_dragging()
&& !m_mouse.dragging && m_gizmos.mouse_event(SLAGizmoEventType::LeftUp, Vec2d(pos(0), pos(1)), evt.ShiftDown()))
&& !m_mouse.dragging)
{
// the gizmo got the event and took some action, no need to do anything more
// in case SLA gizmo is selected, we just pass the LeftUp event and stop processing - neither
// object moving or selecting is suppressed in that case
m_gizmos.gizmo_event(SLAGizmoEventType::LeftUp, Vec2d(pos(0), pos(1)), evt.ShiftDown());
}
else if ((m_mouse.drag.move_volume_idx != -1) && m_mouse.dragging && m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)
else if ((m_mouse.drag.move_volume_idx != -1) && m_mouse.dragging)
{
m_regenerate_volumes = false;
do_move();
@ -2755,11 +2759,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
}
else if (evt.LeftUp() && !m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.is_dragging()
&& !is_layers_editing_enabled() && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports || !m_gizmos.mouse_event(SLAGizmoEventType::LeftUp, Vec2d(pos(0), pos(1)), evt.ShiftDown())))
&& !is_layers_editing_enabled())
{
// SLA gizmo cannot be deselected by clicking in canvas area to avoid inadvertent unselection and losing manual changes
// that's why the mouse_event function was called so that the gizmo can refuse the deselection in manual editing mode
// deselect and propagate event through callback
if (!evt.ShiftDown() && m_picking_enabled && !m_mouse.ignore_up_event)
{

View file

@ -157,7 +157,7 @@ GLToolbar::GLToolbar(GLToolbar::EType type)
#if ENABLE_SVG_ICONS
, m_icons_texture_dirty(true)
#endif // ENABLE_SVG_ICONS
, m_mouse_capture({false, false, false})
, m_mouse_capture({ false, false, false, nullptr })
, m_tooltip("")
{
}
@ -418,8 +418,17 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
m_mouse_capture.middle = false;
else if (evt.RightUp())
m_mouse_capture.right = false;
else if (m_mouse_capture.any() && evt.Dragging())
processed = true;
else if (m_mouse_capture.any())
{
if (evt.Dragging())
processed = true;
else if (evt.Entering() && (m_mouse_capture.parent == &parent))
// Resets the mouse capture state to avoid setting the dragging event as processed when, for example,
// the item action opens a modal dialog
// Keeps the mouse capture state if the entering event happens on different parent from the one
// who received the button down event, to prevent, for example, dragging when switching between scene views
m_mouse_capture.reset();
}
int item_id = contains_mouse(mouse_pos, parent);
if (item_id == -1)
@ -429,10 +438,11 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
}
else
{
// mouse inside toolbar only
// mouse inside toolbar
if (evt.LeftDown() || evt.LeftDClick())
{
m_mouse_capture.left = true;
m_mouse_capture.parent = &parent;
if ((item_id != -2) && !m_items[item_id]->is_separator())
{
// mouse is inside an icon
@ -441,9 +451,15 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
}
}
else if (evt.MiddleDown())
{
m_mouse_capture.middle = true;
m_mouse_capture.parent = &parent;
}
else if (evt.RightDown())
{
m_mouse_capture.right = true;
m_mouse_capture.parent = &parent;
}
else if (evt.LeftUp())
processed = true;
}

View file

@ -237,8 +237,10 @@ private:
bool left;
bool middle;
bool right;
GLCanvas3D* parent;
bool any() const { return left || middle || right; }
void reset() { left = middle = right = false; parent = nullptr; }
};
MouseCapture m_mouse_capture;

View file

@ -202,12 +202,12 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
const float cone_height = 0.75f;
::glPushMatrix();
::glTranslatef(0.f, 0.f, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale);
::gluCylinder(m_quadric, 0.f, cone_radius, cone_height, 36, 1);
::gluCylinder(m_quadric, 0.f, cone_radius, cone_height, 24, 1);
::glTranslatef(0.f, 0.f, cone_height);
::gluDisk(m_quadric, 0.0, cone_radius, 36, 1);
::gluDisk(m_quadric, 0.0, cone_radius, 24, 1);
::glPopMatrix();
}
::gluSphere(m_quadric, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale, 64, 36);
::gluSphere(m_quadric, m_editing_mode_cache[i].support_point.head_front_radius * RenderPointScale, 24, 12);
::glPopMatrix();
}
@ -308,7 +308,7 @@ std::pair<Vec3f, Vec3f> GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse
// The gizmo has an opportunity to react - if it does, it should return true so that the Canvas3D is
// aware that the event was reacted to and stops trying to make different sense of it. If the gizmo
// concludes that the event was not intended for it, it should return false.
bool GLGizmoSlaSupports::mouse_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down)
bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down)
{
if (m_editing_mode) {
@ -327,39 +327,19 @@ bool GLGizmoSlaSupports::mouse_event(SLAGizmoEventType action, const Vec2d& mous
return true;
}
// dragging the selection rectangle:
if (action == SLAGizmoEventType::Dragging && m_selection_rectangle_active) {
m_selection_rectangle_end_corner = mouse_position;
return true;
}
// mouse up without selection rectangle - place point on the mesh:
if (action == SLAGizmoEventType::LeftUp && !m_selection_rectangle_active && !shift_down) {
if (m_ignore_up_event) {
m_ignore_up_event = false;
return false;
}
int instance_id = m_parent.get_selection().get_instance_idx();
if (m_old_instance_id != instance_id)
{
bool something_selected = (m_old_instance_id != -1);
m_old_instance_id = instance_id;
if (something_selected)
return false;
}
if (instance_id == -1)
return false;
// left down without selection rectangle - place point on the mesh:
if (action == SLAGizmoEventType::LeftDown && !m_selection_rectangle_active && !shift_down) {
// If there is some selection, don't add new point and deselect everything instead.
if (m_selection_empty) {
try {
std::pair<Vec3f, Vec3f> pos_and_normal = unproject_on_mesh(mouse_position); // don't create anything if this throws
m_editing_mode_cache.emplace_back(sla::SupportPoint(pos_and_normal.first, m_new_point_head_diameter/2.f, false), false, pos_and_normal.second);
m_unsaved_changes = true;
m_parent.set_as_dirty();
m_wait_for_up_event = true;
}
catch (...) { // not clicked on object
return true; // prevents deselection of the gizmo by GLCanvas3D
catch (...) { // not clicked on object
return false;
}
}
else
@ -369,10 +349,7 @@ bool GLGizmoSlaSupports::mouse_event(SLAGizmoEventType action, const Vec2d& mous
}
// left up with selection rectangle - select points inside the rectangle:
if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp)
&& m_selection_rectangle_active) {
if (action == SLAGizmoEventType::ShiftUp)
m_ignore_up_event = true;
if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::ShiftUp) && m_selection_rectangle_active) {
const Transform3d& instance_matrix = m_model_object->instances[m_active_instance]->get_transformation().get_matrix();
GLint viewport[4];
::glGetIntegerv(GL_VIEWPORT, viewport);
@ -422,6 +399,28 @@ bool GLGizmoSlaSupports::mouse_event(SLAGizmoEventType action, const Vec2d& mous
return true;
}
// left up with no selection rectangle
if (action == SLAGizmoEventType::LeftUp) {
if (m_wait_for_up_event) {
m_wait_for_up_event = false;
return true;
}
}
// dragging the selection rectangle:
if (action == SLAGizmoEventType::Dragging) {
if (m_wait_for_up_event)
return true; // point has been placed and the button not released yet
// this prevents GLCanvas from starting scene rotation
if (m_selection_rectangle_active) {
m_selection_rectangle_end_corner = mouse_position;
return true;
}
return false;
}
if (action == SLAGizmoEventType::Delete) {
// delete key pressed
delete_selected_points();
@ -693,10 +692,10 @@ bool GLGizmoSlaSupports::on_is_activable(const Selection& selection) const
|| !selection.is_from_single_instance())
return false;
// Check that none of the selected volumes is outside.
// Check that none of the selected volumes is outside. Only SLA auxiliaries (supports) are allowed outside.
const Selection::IndicesList& list = selection.get_volume_idxs();
for (const auto& idx : list)
if (selection.get_volume(idx)->is_outside)
if (selection.get_volume(idx)->is_outside && selection.get_volume(idx)->composite_id.volume_id >= 0)
return false;
return true;

View file

@ -60,7 +60,7 @@ public:
#endif // ENABLE_SVG_ICONS
virtual ~GLGizmoSlaSupports();
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool mouse_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down);
void delete_selected_points(bool force = false);
std::pair<float, float> get_sla_clipping_plane() const;
@ -88,8 +88,7 @@ private:
bool m_selection_rectangle_active = false;
Vec2d m_selection_rectangle_start_corner;
Vec2d m_selection_rectangle_end_corner;
bool m_ignore_up_event = false;
bool m_combo_box_open = false; // To ensure proper rendering of the imgui combobox.
bool m_wait_for_up_event = false;
bool m_unsaved_changes = false; // Are there unsaved changes in manual mode?
bool m_selection_empty = true;
EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state)

View file

@ -562,14 +562,14 @@ void GLGizmosManager::set_sla_support_data(ModelObject* model_object, const Sele
}
// Returns true if the gizmo used the event to do something, false otherwise.
bool GLGizmosManager::mouse_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down)
bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down)
{
if (!m_enabled)
return false;
GizmosMap::const_iterator it = m_gizmos.find(SlaSupports);
if (it != m_gizmos.end())
return reinterpret_cast<GLGizmoSlaSupports*>(it->second)->mouse_event(action, mouse_position, shift_down);
return reinterpret_cast<GLGizmoSlaSupports*>(it->second)->gizmo_event(action, mouse_position, shift_down);
return false;
}

View file

@ -131,8 +131,7 @@ public:
void set_flattening_data(const ModelObject* model_object);
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool mouse_event(SLAGizmoEventType action, const Vec2d& mouse_position = Vec2d::Zero(), bool shift_down = false);
void delete_current_grabber(bool delete_all = false);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position = Vec2d::Zero(), bool shift_down = false);
void render_current_gizmo(const Selection& selection) const;
void render_current_gizmo_for_picking_pass(const Selection& selection) const;

View file

@ -5,8 +5,11 @@
#include <wx/button.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
#include "GUI_App.hpp"
#include "I18N.hpp"
#include <iostream>
namespace Slic3r {
@ -22,7 +25,7 @@ ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id):
wxDefaultSize)),
m_cancelbutton(new wxButton(self,
-1,
"Cancel",
_(L("Cancel")),
wxDefaultPosition,
wxDefaultSize))
{
@ -33,6 +36,9 @@ ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id):
int w[] = {-1, 150, 155};
self->SetStatusWidths(3, w);
wxSize s = m_cancelbutton->GetTextExtent(m_cancelbutton->GetLabel());
self->SetMinHeight(int(2 * self->GetBorderY() + 1.2 * s.GetHeight()));
self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) {
if (m_prog->IsShown()) m_timer->Stop();
if(is_busy()) m_prog->Pulse();