This commit is contained in:
bubnikv 2019-01-31 15:09:23 +01:00
commit f4243c694f
12 changed files with 191 additions and 69 deletions

View File

@ -56,3 +56,12 @@
#define ENABLE_ANISOTROPIC_FILTER_ON_BED_TEXTURES (1 && ENABLE_1_42_0_ALPHA4)
// Bunch of fixes related to volumes centering
#define ENABLE_VOLUMES_CENTERING_FIXES (1 && ENABLE_1_42_0_ALPHA4)
//====================
// 1.42.0.alpha5 techs
//====================
#define ENABLE_1_42_0_ALPHA5 1
// Toolbar items hidden/shown in dependence of the user mode
#define ENABLE_MODE_AWARE_TOOLBAR_ITEMS (1 && ENABLE_1_42_0_ALPHA5)

View File

@ -252,6 +252,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
, is_modifier(false)
, is_wipe_tower(false)
, is_extrusion_path(false)
, force_transparent(false)
, tverts_range(0, size_t(-1))
, qverts_range(0, size_t(-1))
{
@ -293,6 +294,9 @@ void GLVolume::set_render_color()
set_render_color(OUTSIDE_COLOR, 4);
else
set_render_color(color, 4);
if (force_transparent)
render_color[3] = color[3];
}
void GLVolume::set_color_from_model_volume(const ModelVolume *model_volume)

View File

@ -295,6 +295,8 @@ public:
bool is_wipe_tower;
// Wheter or not this volume has been generated from an extrusion path
bool is_extrusion_path;
// Wheter or not to always render this volume using its own alpha
bool force_transparent;
// Interleaved triangles & normals with indexed triangles & quads.
GLIndexedVertexArray indexed_vertex_array;

View File

@ -4286,6 +4286,13 @@ bool GLCanvas3D::is_reload_delayed() const
void GLCanvas3D::enable_layers_editing(bool enable)
{
m_layers_editing.set_enabled(enable);
const Selection::IndicesList& idxs = m_selection.get_volume_idxs();
for (unsigned int idx : idxs)
{
GLVolume* v = m_volumes.volumes[idx];
if (v->is_modifier)
v->force_transparent = enable;
}
}
void GLCanvas3D::enable_warning_texture(bool enable)
@ -4414,6 +4421,16 @@ void GLCanvas3D::update_volumes_colors_by_extruder()
m_volumes.update_colors_by_extruder(m_config);
}
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void GLCanvas3D::update_toolbar_items_visibility()
{
ConfigOptionMode mode = wxGetApp().get_mode();
m_toolbar.set_item_visible("more", mode != comSimple);
m_toolbar.set_item_visible("fewer", mode != comSimple);
m_dirty = true;
}
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
// Returns a Rect object denoting size and position of the Reset button used by a gizmo.
// Returns in either screen or viewport coords.
#if !ENABLE_IMGUI
@ -6169,6 +6186,10 @@ bool GLCanvas3D::_init_toolbar()
enable_toolbar_item("add", true);
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
update_toolbar_items_visibility();
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
return true;
}

View File

@ -1004,6 +1004,10 @@ public:
void update_volumes_colors_by_extruder();
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void update_toolbar_items_visibility();
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
#if !ENABLE_IMGUI
Rect get_gizmo_reset_rect(const GLCanvas3D& canvas, bool viewport) const;
bool gizmo_reset_rect_contains(const GLCanvas3D& canvas, float x, float y) const;

View File

@ -35,6 +35,9 @@ GLToolbarItem::Data::Data()
, tooltip("")
, sprite_id(-1)
, is_toggable(false)
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
, visible(true)
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
{
}
@ -45,61 +48,11 @@ GLToolbarItem::GLToolbarItem(GLToolbarItem::EType type, const GLToolbarItem::Dat
{
}
GLToolbarItem::EState GLToolbarItem::get_state() const
{
return m_state;
}
void GLToolbarItem::set_state(GLToolbarItem::EState state)
{
m_state = state;
}
const std::string& GLToolbarItem::get_name() const
{
return m_data.name;
}
const std::string& GLToolbarItem::get_tooltip() const
{
return m_data.tooltip;
}
void GLToolbarItem::do_action(wxEvtHandler *target)
{
wxPostEvent(target, SimpleEvent(m_data.action_event));
}
bool GLToolbarItem::is_enabled() const
{
return m_state != Disabled;
}
bool GLToolbarItem::is_disabled() const
{
return m_state == Disabled;
}
bool GLToolbarItem::is_hovered() const
{
return (m_state == Hover) || (m_state == HoverPressed);
}
bool GLToolbarItem::is_pressed() const
{
return (m_state == Pressed) || (m_state == HoverPressed);
}
bool GLToolbarItem::is_toggable() const
{
return m_data.is_toggable;
}
bool GLToolbarItem::is_separator() const
{
return m_type == Separator;
}
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const
{
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, get_uvs(texture_size, border_size, icon_size, gap_size));
@ -355,6 +308,46 @@ bool GLToolbar::is_item_disabled(const std::string& name) const
return false;
}
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
bool GLToolbar::is_item_visible(const std::string& name) const
{
for (GLToolbarItem* item : m_items)
{
if (item->get_name() == name)
return item->is_visible();
}
return false;
}
void GLToolbar::set_item_visible(const std::string& name, bool visible)
{
for (GLToolbarItem* item : m_items)
{
if ((item->get_name() == name) && (item->is_visible() != visible))
{
item->set_visible(visible);
m_layout.dirty = true;
break;
}
}
// updates separators visibility to avoid having two consecutive
bool any_item_visible = false;
for (GLToolbarItem* item : m_items)
{
if (!item->is_separator())
any_item_visible |= item->is_visible();
else
{
item->set_visible(any_item_visible);
any_item_visible = false;
}
}
}
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
{
if (!m_enabled)
@ -486,6 +479,11 @@ float GLToolbar::get_main_size() const
float size = 2.0f * m_layout.border * m_layout.icons_scale;
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
{
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!m_items[i]->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (m_items[i]->is_separator())
size += m_layout.separator_size * m_layout.icons_scale;
else
@ -524,6 +522,11 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
for (GLToolbarItem* item : m_items)
{
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
left += separator_stride;
else
@ -618,6 +621,11 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
for (GLToolbarItem* item : m_items)
{
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
top -= separator_stride;
else
@ -714,6 +722,11 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
{
++id;
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
left += separator_stride;
else
@ -759,6 +772,11 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
{
++id;
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
top -= separator_stride;
else
@ -892,6 +910,11 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
// renders icons
for (const GLToolbarItem* item : m_items)
{
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
left += separator_stride;
else
@ -1018,6 +1041,11 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
// renders icons
for (const GLToolbarItem* item : m_items)
{
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (!item->is_visible())
continue;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (item->is_separator())
top -= separator_stride;
else

View File

@ -8,7 +8,6 @@
#include "GLTexture.hpp"
#include "Event.hpp"
class wxEvtHandler;
namespace Slic3r {
@ -56,6 +55,9 @@ public:
unsigned int sprite_id;
bool is_toggable;
wxEventType action_event;
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
bool visible;
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
Data();
};
@ -68,21 +70,25 @@ private:
public:
GLToolbarItem(EType type, const Data& data);
EState get_state() const;
void set_state(EState state);
EState get_state() const { return m_state; }
void set_state(EState state) { m_state = state; }
const std::string& get_name() const;
const std::string& get_tooltip() const;
const std::string& get_name() const { return m_data.name; }
const std::string& get_tooltip() const { return m_data.tooltip; }
void do_action(wxEvtHandler *target);
bool is_enabled() const;
bool is_disabled() const;
bool is_hovered() const;
bool is_pressed() const;
bool is_enabled() const { return m_state != Disabled; }
bool is_disabled() const { return m_state == Disabled; }
bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed); }
bool is_pressed() const { return (m_state == Pressed) || (m_state == HoverPressed); }
bool is_toggable() const;
bool is_separator() const;
bool is_toggable() const { return m_data.is_toggable; }
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
bool is_visible() const { return m_data.visible; }
void set_visible(bool visible) { m_data.visible = visible; }
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
bool is_separator() const { return m_type == Separator; }
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const;
@ -223,6 +229,10 @@ public:
bool is_item_pressed(const std::string& name) const;
bool is_item_disabled(const std::string& name) const;
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
bool is_item_visible(const std::string& name) const;
void set_item_visible(const std::string& name, bool visible);
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent);

View File

@ -139,6 +139,14 @@ void View3D::mirror_selection(Axis axis)
m_canvas->mirror_selection(axis);
}
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void View3D::update_toolbar_items_visibility()
{
if (m_canvas != nullptr)
m_canvas->update_toolbar_items_visibility();
}
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void View3D::enable_toolbar_item(const std::string& name, bool enable)
{
if (m_canvas != nullptr)

View File

@ -58,6 +58,9 @@ public:
void delete_selected();
void mirror_selection(Axis axis);
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void update_toolbar_items_visibility();
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
void enable_toolbar_item(const std::string& name, bool enable);
int check_volumes_outside_state() const;

View File

@ -44,7 +44,8 @@ KBShortcutsDialog::KBShortcutsDialog()
for (auto& sc : m_full_shortcuts)
{
auto sizer = sc.first == _(L("Main Shortcuts")) ? l_sizer : r_sizer;
// auto sizer = sc.first == _(L("Main Shortcuts")) ? l_sizer : r_sizer;
auto sizer = sc.second.second == 0 ? l_sizer : r_sizer;
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(hsizer, 0, wxEXPAND | wxTOP | wxBOTTOM, 10);
@ -61,7 +62,7 @@ KBShortcutsDialog::KBShortcutsDialog()
auto grid_sizer = new wxFlexGridSizer(2, 5, 15);
sizer->Add(grid_sizer, 0, wxEXPAND | wxLEFT| wxRIGHT, 15);
for (auto pair : sc.second)
for (auto pair : sc.second.first)
{
auto shortcut = new wxStaticText(panel, wxID_ANY, _(pair.first));
shortcut->SetFont(bold_font);
@ -95,6 +96,8 @@ void KBShortcutsDialog::fill_shortcuts()
const std::string alt = "Alt+";
#endif // __WXOSX__
m_full_shortcuts.reserve(4);
Shortcuts main_shortcuts;
main_shortcuts.reserve(25);
@ -122,7 +125,7 @@ void KBShortcutsDialog::fill_shortcuts()
main_shortcuts.push_back(Shortcut("?" ,L("Show keyboard shortcuts list")));
main_shortcuts.push_back(Shortcut("Shift+LeftMouse", L("Select multiple object/Move multiple object")));
m_full_shortcuts.emplace(_(L("Main Shortcuts")), main_shortcuts);
m_full_shortcuts.push_back(std::make_pair( _(L("Main Shortcuts")), std::make_pair(main_shortcuts, 0) ));
Shortcuts plater_shortcuts;
@ -138,6 +141,8 @@ void KBShortcutsDialog::fill_shortcuts()
plater_shortcuts.push_back(Shortcut("C", L("Gizmo cut")));
plater_shortcuts.push_back(Shortcut("F", L("Gizmo Place face on bed")));
plater_shortcuts.push_back(Shortcut("L", L("Gizmo SLA support points")));
plater_shortcuts.push_back(Shortcut("Shift+", L("Press to snap by 5% in Gizmo scale\nor by 1mm in Gizmo move")));
plater_shortcuts.push_back(Shortcut(alt, L("Press to scale or rotate selected objects\naround their own center")));
plater_shortcuts.push_back(Shortcut("B", L("Zoom to Bed")));
plater_shortcuts.push_back(Shortcut("Z", L("Zoom to all objects in scene, if none selected")));
plater_shortcuts.push_back(Shortcut("Z", L("Zoom to selected object")));
@ -145,16 +150,40 @@ void KBShortcutsDialog::fill_shortcuts()
plater_shortcuts.push_back(Shortcut("O", L("Zoom out")));
plater_shortcuts.push_back(Shortcut("ESC", L("Unselect gizmo, keep object selection")));
m_full_shortcuts.emplace(_(L("Plater Shortcuts")), plater_shortcuts);
m_full_shortcuts.push_back(std::make_pair(_(L("Plater Shortcuts")), std::make_pair(plater_shortcuts, 1)));
// Shortcuts gizmo_shortcuts;
// gizmo_shortcuts.reserve(2);
//
// gizmo_shortcuts.push_back(Shortcut("Shift+", L("Press to snap by 5% in Gizmo Scale\n or by 1mm in Gizmo Move")));
// gizmo_shortcuts.push_back(Shortcut(alt, L("Press to scale or rotate selected objects around their own center")));
//
// m_full_shortcuts.push_back(std::make_pair(_(L("Gizmo Shortcuts")), std::make_pair(gizmo_shortcuts, 1)));
Shortcuts preview_shortcuts;
preview_shortcuts.reserve(2);
preview_shortcuts.reserve(4);
preview_shortcuts.push_back(Shortcut(L("Arrow Up"), L("Upper Layer")));
preview_shortcuts.push_back(Shortcut(L("Arrow Down"), L("Lower Layer")));
preview_shortcuts.push_back(Shortcut("U", L("Upper Layer")));
preview_shortcuts.push_back(Shortcut("D", L("Lower Layer")));
m_full_shortcuts.emplace(_(L("Preview Shortcuts")), preview_shortcuts);
m_full_shortcuts.push_back(std::make_pair( _(L("Preview Shortcuts")), std::make_pair(preview_shortcuts, 0) ));
Shortcuts layers_slider_shortcuts;
layers_slider_shortcuts.reserve(6);
layers_slider_shortcuts.push_back(Shortcut(L("Arrow Up"), L("Move current slider thump Up")));
layers_slider_shortcuts.push_back(Shortcut(L("Arrow Down"), L("Move current slider thump Down")));
layers_slider_shortcuts.push_back(Shortcut(L("Arrow Left"), L("Set upper thumb to current slider thumb")));
layers_slider_shortcuts.push_back(Shortcut(L("Arrow Right"),L("Set lower thumb to current slider thumb")));
layers_slider_shortcuts.push_back(Shortcut("+", L("Add color change marker for current layer")));
layers_slider_shortcuts.push_back(Shortcut("-", L("Delete color change marker for current layer")));
m_full_shortcuts.push_back(std::make_pair( _(L("Layers Slider Shortcuts")), std::make_pair(layers_slider_shortcuts, 1) ));
}
void KBShortcutsDialog::onCloseDialog(wxEvent &)

View File

@ -11,11 +11,11 @@ class KBShortcutsDialog : public wxDialog
{
typedef std::pair<std::string, std::string> Shortcut;
typedef std::vector< Shortcut > Shortcuts;
typedef std::map<wxString, Shortcuts> ShortcutsMap;
typedef std::vector< std::pair<wxString, std::pair<Shortcuts, int>> > ShortcutsVec;
wxString text_info {wxEmptyString};
ShortcutsMap m_full_shortcuts;
ShortcutsVec m_full_shortcuts;
public:
KBShortcutsDialog();

View File

@ -2648,6 +2648,10 @@ bool Plater::priv::can_mirror() const
void Plater::priv::update_object_menu()
{
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
#if ENABLE_MODE_AWARE_TOOLBAR_ITEMS
if (view3D != nullptr)
view3D->update_toolbar_items_visibility();
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
}
// Plater / Public