Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bubnikv committed Sep 23, 2021
2 parents b6d7601 + 8f6386c commit 04e4aee
Show file tree
Hide file tree
Showing 15 changed files with 422 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/BlacklistedLibraryCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Slic3r {
#ifdef WIN32

//only dll name with .dll suffix - currently case sensitive
const std::vector<std::wstring> BlacklistedLibraryCheck::blacklist({ L"NahimicOSD.dll", L"SS2OSD.dll" });
const std::vector<std::wstring> BlacklistedLibraryCheck::blacklist({ L"NahimicOSD.dll", L"SS2OSD.dll", L"amhook.dll", L"AMHook.dll" });

bool BlacklistedLibraryCheck::get_blacklisted(std::vector<std::wstring>& names)
{
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Technologies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define ENABLE_FIX_PREVIEW_OPTIONS_Z (1 && ENABLE_SEAMS_USING_MODELS && ENABLE_2_4_0_ALPHA2)
// Enable replacing a missing file during reload from disk command
#define ENABLE_RELOAD_FROM_DISK_REPLACE_FILE (1 && ENABLE_2_4_0_ALPHA2)
// Enable fixing the synchronization of seams with the horizontal slider in preview
#define ENABLE_FIX_SEAMS_SYNCH (1 && ENABLE_2_4_0_ALPHA2)


#endif // _prusaslicer_technologies_h_
5 changes: 3 additions & 2 deletions src/slic3r/GUI/DoubleSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,8 @@ void Control::OnChar(wxKeyEvent& event)

void Control::OnRightDown(wxMouseEvent& event)
{
if (HasCapture()) return;
if (HasCapture() || m_is_left_down)
return;
this->CaptureMouse();

const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
Expand Down Expand Up @@ -2097,7 +2098,7 @@ void Control::auto_color_change()

void Control::OnRightUp(wxMouseEvent& event)
{
if (!HasCapture())
if (!HasCapture() || m_is_left_down)
return;
this->ReleaseMouse();
m_is_right_down = m_is_one_layer = false;
Expand Down
158 changes: 156 additions & 2 deletions src/slic3r/GUI/GCodeViewer.cpp

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/slic3r/GUI/GCodeViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class GCodeViewer
using InstanceBuffer = std::vector<float>;
using InstanceIdBuffer = std::vector<size_t>;
#endif // ENABLE_SEAMS_USING_MODELS
#if ENABLE_FIX_SEAMS_SYNCH
using InstancesOffsets = std::vector<Vec3f>;
#endif // ENABLE_FIX_SEAMS_SYNCH

static const std::vector<Color> Extrusion_Role_Colors;
static const std::vector<Color> Options_Colors;
Expand Down Expand Up @@ -151,6 +154,10 @@ class GCodeViewer
InstanceBuffer buffer;
// indices of the moves for all instances
std::vector<size_t> s_ids;
#if ENABLE_FIX_SEAMS_SYNCH
// position offsets, used to show the correct value of the tool position
InstancesOffsets offsets;
#endif // ENABLE_FIX_SEAMS_SYNCH
Ranges render_ranges;

size_t data_size_bytes() const { return s_ids.size() * instance_size_bytes(); }
Expand Down Expand Up @@ -665,6 +672,12 @@ class GCodeViewer
GLModel m_model;
Vec3f m_world_position;
Transform3f m_world_transform;
#if ENABLE_FIX_SEAMS_SYNCH
// for seams, the position of the marker is on the last endpoint of the toolpath containing it
// the offset is used to show the correct value of tool position in the "ToolPosition" window
// see implementation of render() method
Vec3f m_world_offset;
#endif // ENABLE_FIX_SEAMS_SYNCH
float m_z_offset{ 0.5f };
bool m_visible{ true };

Expand All @@ -674,6 +687,9 @@ class GCodeViewer
const BoundingBoxf3& get_bounding_box() const { return m_model.get_bounding_box(); }

void set_world_position(const Vec3f& position);
#if ENABLE_FIX_SEAMS_SYNCH
void set_world_offset(const Vec3f& offset) { m_world_offset = offset; }
#endif // ENABLE_FIX_SEAMS_SYNCH

bool is_visible() const { return m_visible; }
void set_visible(bool visible) { m_visible = visible; }
Expand Down Expand Up @@ -731,6 +747,9 @@ class GCodeViewer
Endpoints global;
#endif // ENABLE_SEAMS_USING_MODELS
Vec3f current_position{ Vec3f::Zero() };
#if ENABLE_FIX_SEAMS_SYNCH
Vec3f current_offset{ Vec3f::Zero() };
#endif // ENABLE_FIX_SEAMS_SYNCH
Marker marker;
GCodeWindow gcode_window;
std::vector<unsigned int> gcode_ids;
Expand Down
19 changes: 17 additions & 2 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4427,12 +4427,11 @@ bool GLCanvas3D::_init_main_toolbar()
arrow_data.top = 0;
arrow_data.right = 0;
arrow_data.bottom = 0;

if (!m_main_toolbar.init_arrow(arrow_data))
{
BOOST_LOG_TRIVIAL(error) << "Main toolbar failed to load arrow texture.";
}

// m_gizmos is created at constructor, thus we can init arrow here.
if (!m_gizmos.init_arrow(arrow_data))
{
BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture.";
Expand Down Expand Up @@ -4643,6 +4642,18 @@ bool GLCanvas3D::_init_undoredo_toolbar()
return true;
}

// init arrow
BackgroundTexture::Metadata arrow_data;
arrow_data.filename = "toolbar_arrow.svg";
arrow_data.left = 0;
arrow_data.top = 0;
arrow_data.right = 0;
arrow_data.bottom = 0;
if (!m_undoredo_toolbar.init_arrow(arrow_data))
{
BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture.";
}

// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
m_undoredo_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
Expand Down Expand Up @@ -5376,6 +5387,10 @@ void GLCanvas3D::_render_undoredo_toolbar()

m_undoredo_toolbar.set_position(top, left);
m_undoredo_toolbar.render(*this);
if (m_toolbar_highlighter.m_render_arrow)
{
m_undoredo_toolbar.render_arrow(*this, m_toolbar_highlighter.m_toolbar_item);
}
}

void GLCanvas3D::_render_collapse_toolbar() const
Expand Down
11 changes: 10 additions & 1 deletion src/slic3r/GUI/GLToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,10 @@ void GLToolbar::render_background(float left, float top, float right, float bott

void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item)
{
// arrow texture not initialized
if (m_arrow_texture.texture.get_id() == 0)
return;

float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
float factor = inv_zoom * m_layout.scale;

Expand All @@ -1157,18 +1161,23 @@ void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighte
float left = m_layout.left;
float top = m_layout.top - icon_stride;

bool found = false;
for (const GLToolbarItem* item : m_items) {
if (!item->is_visible())
continue;

if (item->is_separator())
left += separator_stride;
else {
if (item->get_name() == highlighted_item->get_name())
if (item->get_name() == highlighted_item->get_name()) {
found = true;
break;
}
left += icon_stride;
}
}
if (!found)
return;

left += border;
top -= separator_stride;
Expand Down
86 changes: 86 additions & 0 deletions src/slic3r/GUI/Notebook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class Notebook: public wxBookCtrlBase
if (int page_idx = evt.GetId(); page_idx >= 0)
SetSelection(page_idx);
});

this->Bind(wxEVT_NAVIGATION_KEY, &Notebook::OnNavigationKey, this);

return true;
}

Expand Down Expand Up @@ -242,6 +245,89 @@ class Notebook: public wxBookCtrlBase
GetBtnsListCtrl()->Rescale();
}

void Notebook::OnNavigationKey(wxNavigationKeyEvent& event)
{
if (event.IsWindowChange()) {
// change pages
AdvanceSelection(event.GetDirection());
}
else {
// we get this event in 3 cases
//
// a) one of our pages might have generated it because the user TABbed
// out from it in which case we should propagate the event upwards and
// our parent will take care of setting the focus to prev/next sibling
//
// or
//
// b) the parent panel wants to give the focus to us so that we
// forward it to our selected page. We can't deal with this in
// OnSetFocus() because we don't know which direction the focus came
// from in this case and so can't choose between setting the focus to
// first or last panel child
//
// or
//
// c) we ourselves (see MSWTranslateMessage) generated the event
//
wxWindow* const parent = GetParent();

// the wxObject* casts are required to avoid MinGW GCC 2.95.3 ICE
const bool isFromParent = event.GetEventObject() == (wxObject*)parent;
const bool isFromSelf = event.GetEventObject() == (wxObject*)this;
const bool isForward = event.GetDirection();

if (isFromSelf && !isForward)
{
// focus is currently on notebook tab and should leave
// it backwards (Shift-TAB)
event.SetCurrentFocus(this);
parent->HandleWindowEvent(event);
}
else if (isFromParent || isFromSelf)
{
// no, it doesn't come from child, case (b) or (c): forward to a
// page but only if entering notebook page (i.e. direction is
// backwards (Shift-TAB) comething from out-of-notebook, or
// direction is forward (TAB) from ourselves),
if (m_selection != wxNOT_FOUND &&
(!event.GetDirection() || isFromSelf))
{
// so that the page knows that the event comes from it's parent
// and is being propagated downwards
event.SetEventObject(this);

wxWindow* page = m_pages[m_selection];
if (!page->HandleWindowEvent(event))
{
page->SetFocus();
}
//else: page manages focus inside it itself
}
else // otherwise set the focus to the notebook itself
{
SetFocus();
}
}
else
{
// it comes from our child, case (a), pass to the parent, but only
// if the direction is forwards. Otherwise set the focus to the
// notebook itself. The notebook is always the 'first' control of a
// page.
if (!isForward)
{
SetFocus();
}
else if (parent)
{
event.SetCurrentFocus(this);
parent->HandleWindowEvent(event);
}
}
}
}

protected:
virtual void UpdateSelectedPage(size_t WXUNUSED(newsel)) override
{
Expand Down
Loading

0 comments on commit 04e4aee

Please sign in to comment.