Remove const_cast<> introduced with 4da8de5f49
This commit is contained in:
parent
39fd8065a1
commit
90edccf772
@ -3882,7 +3882,7 @@ static bool string_getter(const bool is_undo, int idx, const char** out_text)
|
||||
return wxGetApp().plater()->undo_redo_string_getter(is_undo, idx, out_text);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) const
|
||||
bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
||||
{
|
||||
bool action_taken = false;
|
||||
|
||||
@ -3924,7 +3924,7 @@ static bool search_string_getter(int idx, const char** label, const char** toolt
|
||||
return wxGetApp().plater()->search_string_getter(idx, label, tooltip);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_render_search_list(float pos_x) const
|
||||
bool GLCanvas3D::_render_search_list(float pos_x)
|
||||
{
|
||||
bool action_taken = false;
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
@ -5148,7 +5148,7 @@ void GLCanvas3D::_render_selection_center() const
|
||||
}
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
||||
void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
|
||||
void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
||||
{
|
||||
// Don't update a toolbar scale, when we are on a Preview
|
||||
if (wxGetApp().plater()->is_preview_shown())
|
||||
@ -5163,13 +5163,13 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
#if ENABLE_RETINA_GL
|
||||
const float sc = m_retina_helper->get_scale_factor() * scale;
|
||||
const_cast<GLToolbar*>(&m_main_toolbar)->set_scale(sc);
|
||||
const_cast<GLToolbar*>(&m_undoredo_toolbar)->set_scale(sc);
|
||||
m_main_toolbar.set_scale(sc);
|
||||
m_undoredo_toolbar.set_scale(sc);
|
||||
collapse_toolbar.set_scale(sc);
|
||||
size *= m_retina_helper->get_scale_factor();
|
||||
#else
|
||||
const_cast<GLToolbar*>(&m_main_toolbar)->set_icons_size(size);
|
||||
const_cast<GLToolbar*>(&m_undoredo_toolbar)->set_icons_size(size);
|
||||
m_main_toolbar.set_icons_size(size);
|
||||
m_undoredo_toolbar.set_icons_size(size);
|
||||
collapse_toolbar.set_icons_size(size);
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
@ -5194,7 +5194,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const
|
||||
wxGetApp().set_auto_toolbar_icon_scale(new_scale);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_overlays() const
|
||||
void GLCanvas3D::_render_overlays()
|
||||
{
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
glsafe(::glPushMatrix());
|
||||
@ -5214,13 +5214,13 @@ void GLCanvas3D::_render_overlays() const
|
||||
// to correctly place them
|
||||
#if ENABLE_RETINA_GL
|
||||
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(/*true*/);
|
||||
const_cast<GLToolbar*>(&m_main_toolbar)->set_scale(scale);
|
||||
const_cast<GLToolbar*>(&m_undoredo_toolbar)->set_scale(scale);
|
||||
m_main_toolbar.set_scale(scale);
|
||||
m_undoredo_toolbar.set_scale(scale);
|
||||
wxGetApp().plater()->get_collapse_toolbar().set_scale(scale);
|
||||
#else
|
||||
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(/*true*/));
|
||||
const_cast<GLToolbar*>(&m_main_toolbar)->set_icons_size(size);
|
||||
const_cast<GLToolbar*>(&m_undoredo_toolbar)->set_icons_size(size);
|
||||
m_main_toolbar.set_icons_size(size);
|
||||
m_undoredo_toolbar.set_icons_size(size);
|
||||
wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size);
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
@ -5299,7 +5299,7 @@ void GLCanvas3D::_render_gizmos_overlay() const
|
||||
m_gizmos.render_overlay();
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_main_toolbar() const
|
||||
void GLCanvas3D::_render_main_toolbar()
|
||||
{
|
||||
if (!m_main_toolbar.is_enabled())
|
||||
return;
|
||||
@ -5308,16 +5308,15 @@ void GLCanvas3D::_render_main_toolbar() const
|
||||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
|
||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
const GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
|
||||
|
||||
GLToolbar* main_toolbar = const_cast<GLToolbar*>(&m_main_toolbar);
|
||||
main_toolbar->set_position(top, left);
|
||||
main_toolbar->render(*this);
|
||||
m_main_toolbar.set_position(top, left);
|
||||
m_main_toolbar.render(*this);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_undoredo_toolbar() const
|
||||
void GLCanvas3D::_render_undoredo_toolbar()
|
||||
{
|
||||
if (!m_undoredo_toolbar.is_enabled())
|
||||
return;
|
||||
@ -5326,13 +5325,12 @@ void GLCanvas3D::_render_undoredo_toolbar() const
|
||||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
|
||||
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
const GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width)) * inv_zoom;
|
||||
|
||||
GLToolbar* undoredo_toolbar = const_cast<GLToolbar*>(&m_undoredo_toolbar);
|
||||
undoredo_toolbar->set_position(top, left);
|
||||
undoredo_toolbar->render(*this);
|
||||
m_undoredo_toolbar.set_position(top, left);
|
||||
m_undoredo_toolbar.render(*this);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_collapse_toolbar() const
|
||||
|
@ -824,13 +824,13 @@ private:
|
||||
#if ENABLE_RENDER_SELECTION_CENTER
|
||||
void _render_selection_center() const;
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
void _check_and_update_toolbar_icon_scale() const;
|
||||
void _render_overlays() const;
|
||||
void _check_and_update_toolbar_icon_scale();
|
||||
void _render_overlays();
|
||||
void _render_volumes_for_picking() const;
|
||||
void _render_current_gizmo() const;
|
||||
void _render_gizmos_overlay() const;
|
||||
void _render_main_toolbar() const;
|
||||
void _render_undoredo_toolbar() const;
|
||||
void _render_main_toolbar();
|
||||
void _render_undoredo_toolbar();
|
||||
void _render_collapse_toolbar() const;
|
||||
void _render_view_toolbar() const;
|
||||
#if ENABLE_SHOW_CAMERA_TARGET
|
||||
@ -838,8 +838,8 @@ private:
|
||||
#endif // ENABLE_SHOW_CAMERA_TARGET
|
||||
void _render_sla_slices() const;
|
||||
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_undo_redo_stack(const bool is_undo, float pos_x);
|
||||
bool _render_search_list(float pos_x);
|
||||
bool _render_arrange_menu(float pos_x);
|
||||
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
|
||||
|
@ -260,7 +260,7 @@ bool GLToolbar::add_separator()
|
||||
return true;
|
||||
}
|
||||
|
||||
float GLToolbar::get_width() const
|
||||
float GLToolbar::get_width()
|
||||
{
|
||||
if (m_layout.dirty)
|
||||
calc_layout();
|
||||
@ -268,7 +268,7 @@ float GLToolbar::get_width() const
|
||||
return m_layout.width;
|
||||
}
|
||||
|
||||
float GLToolbar::get_height() const
|
||||
float GLToolbar::get_height()
|
||||
{
|
||||
if (m_layout.dirty)
|
||||
calc_layout();
|
||||
@ -403,7 +403,7 @@ bool GLToolbar::update_items_state()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GLToolbar::render(const GLCanvas3D& parent) const
|
||||
void GLToolbar::render(const GLCanvas3D& parent)
|
||||
{
|
||||
if (!m_enabled || m_items.empty())
|
||||
return;
|
||||
@ -506,28 +506,26 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
|
||||
return processed;
|
||||
}
|
||||
|
||||
void GLToolbar::calc_layout() const
|
||||
void GLToolbar::calc_layout()
|
||||
{
|
||||
Layout* layout = const_cast<Layout*>(&m_layout);
|
||||
|
||||
switch (layout->type)
|
||||
switch (m_layout.type)
|
||||
{
|
||||
default:
|
||||
case Layout::Horizontal:
|
||||
{
|
||||
layout->width = get_width_horizontal();
|
||||
layout->height = get_height_horizontal();
|
||||
m_layout.width = get_width_horizontal();
|
||||
m_layout.height = get_height_horizontal();
|
||||
break;
|
||||
}
|
||||
case Layout::Vertical:
|
||||
{
|
||||
layout->width = get_width_vertical();
|
||||
layout->height = get_height_vertical();
|
||||
m_layout.width = get_width_vertical();
|
||||
m_layout.height = get_height_vertical();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
layout->dirty = false;
|
||||
m_layout.dirty = false;
|
||||
}
|
||||
|
||||
float GLToolbar::get_width_horizontal() const
|
||||
@ -1107,7 +1105,7 @@ void GLToolbar::render_background(float left, float top, float right, float bott
|
||||
}
|
||||
}
|
||||
|
||||
void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
void GLToolbar::render_horizontal(const GLCanvas3D& parent)
|
||||
{
|
||||
unsigned int tex_id = m_icons_texture.get_id();
|
||||
int tex_width = m_icons_texture.get_width();
|
||||
@ -1155,7 +1153,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
}
|
||||
}
|
||||
|
||||
void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
void GLToolbar::render_vertical(const GLCanvas3D& parent)
|
||||
{
|
||||
unsigned int tex_id = m_icons_texture.get_id();
|
||||
int tex_width = m_icons_texture.get_width();
|
||||
@ -1201,7 +1199,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
}
|
||||
}
|
||||
|
||||
bool GLToolbar::generate_icons_texture() const
|
||||
bool GLToolbar::generate_icons_texture()
|
||||
{
|
||||
std::string path = resources_dir() + "/icons/";
|
||||
std::vector<std::string> filenames;
|
||||
@ -1234,9 +1232,9 @@ bool GLToolbar::generate_icons_texture() const
|
||||
// if (sprite_size_px % 2 != 0)
|
||||
// sprite_size_px += 1;
|
||||
|
||||
bool res = const_cast<GLTexture*>(&m_icons_texture)->load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false);
|
||||
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false);
|
||||
if (res)
|
||||
*const_cast<bool*>(&m_icons_texture_dirty) = false;
|
||||
m_icons_texture_dirty = false;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -282,8 +282,8 @@ public:
|
||||
bool add_item(const GLToolbarItem::Data& data);
|
||||
bool add_separator();
|
||||
|
||||
float get_width() const;
|
||||
float get_height() const;
|
||||
float get_width();
|
||||
float get_height();
|
||||
|
||||
void select_item(const std::string& name);
|
||||
|
||||
@ -309,12 +309,12 @@ public:
|
||||
// returns true if any item changed its state
|
||||
bool update_items_state();
|
||||
|
||||
void render(const GLCanvas3D& parent) const;
|
||||
void render(const GLCanvas3D& parent);
|
||||
|
||||
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& parent);
|
||||
|
||||
private:
|
||||
void calc_layout() const;
|
||||
void calc_layout();
|
||||
float get_width_horizontal() const;
|
||||
float get_width_vertical() const;
|
||||
float get_height_horizontal() const;
|
||||
@ -330,10 +330,10 @@ private:
|
||||
int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||
|
||||
void render_background(float left, float top, float right, float bottom, float border) const;
|
||||
void render_horizontal(const GLCanvas3D& parent) const;
|
||||
void render_vertical(const GLCanvas3D& parent) const;
|
||||
void render_horizontal(const GLCanvas3D& parent);
|
||||
void render_vertical(const GLCanvas3D& parent);
|
||||
|
||||
bool generate_icons_texture() const;
|
||||
bool generate_icons_texture();
|
||||
|
||||
// returns true if any item changed its state
|
||||
bool update_items_visibility();
|
||||
|
Loading…
Reference in New Issue
Block a user