Code cleanup
This commit is contained in:
parent
b6f6200bd5
commit
bb07100a4f
9 changed files with 2 additions and 164 deletions
|
@ -160,7 +160,6 @@ sub new {
|
|||
}
|
||||
};
|
||||
|
||||
#======================================================================================================================================================
|
||||
# callbacks for toolbar
|
||||
my $on_action_add = sub {
|
||||
$self->add;
|
||||
|
@ -214,7 +213,6 @@ sub new {
|
|||
my $state = Slic3r::GUI::_3DScene::is_toolbar_item_pressed($self->{canvas3D}, "layersediting");
|
||||
$self->on_layer_editing_toggled($state);
|
||||
};
|
||||
#======================================================================================================================================================
|
||||
|
||||
# Initialize 3D plater
|
||||
if ($Slic3r::GUI::have_OpenGL) {
|
||||
|
@ -235,7 +233,6 @@ sub new {
|
|||
Slic3r::GUI::_3DScene::register_on_gizmo_scale_uniformly_callback($self->{canvas3D}, $on_gizmo_scale_uniformly);
|
||||
Slic3r::GUI::_3DScene::register_on_gizmo_rotate_callback($self->{canvas3D}, $on_gizmo_rotate);
|
||||
Slic3r::GUI::_3DScene::register_on_update_geometry_info_callback($self->{canvas3D}, $on_update_geometry_info);
|
||||
#======================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::register_action_add_callback($self->{canvas3D}, $on_action_add);
|
||||
Slic3r::GUI::_3DScene::register_action_delete_callback($self->{canvas3D}, $on_action_delete);
|
||||
Slic3r::GUI::_3DScene::register_action_deleteall_callback($self->{canvas3D}, $on_action_deleteall);
|
||||
|
@ -249,11 +246,8 @@ sub new {
|
|||
Slic3r::GUI::_3DScene::register_action_cut_callback($self->{canvas3D}, $on_action_cut);
|
||||
Slic3r::GUI::_3DScene::register_action_settings_callback($self->{canvas3D}, $on_action_settings);
|
||||
Slic3r::GUI::_3DScene::register_action_layersediting_callback($self->{canvas3D}, $on_action_layersediting);
|
||||
#======================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_gizmos($self->{canvas3D}, 1);
|
||||
#======================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_toolbar($self->{canvas3D}, 1);
|
||||
#======================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_shader($self->{canvas3D}, 1);
|
||||
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($self->{canvas3D}, 1);
|
||||
|
||||
|
@ -710,9 +704,7 @@ sub on_layer_editing_toggled {
|
|||
$self->{"btn_layer_editing"}->Disable;
|
||||
$self->{"btn_layer_editing"}->SetValue(0);
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, "layersediting", 0);
|
||||
#===================================================================================================================================================
|
||||
}
|
||||
$self->{canvas3D}->Refresh;
|
||||
$self->{canvas3D}->Update;
|
||||
|
@ -1028,9 +1020,7 @@ sub increase {
|
|||
$self->update;
|
||||
}
|
||||
|
||||
#========================================================================================================================
|
||||
$self->selection_changed; # refresh info (size, volume etc.)
|
||||
#========================================================================================================================
|
||||
$self->schedule_background_process;
|
||||
}
|
||||
|
||||
|
@ -2007,9 +1997,7 @@ sub on_config_change {
|
|||
$self->{"btn_layer_editing"}->Disable;
|
||||
$self->{"btn_layer_editing"}->SetValue(0);
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, "layersediting", 0);
|
||||
#===================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_layers_editing($self->{canvas3D}, 0);
|
||||
$self->{canvas3D}->Refresh;
|
||||
$self->{canvas3D}->Update;
|
||||
|
@ -2020,9 +2008,7 @@ sub on_config_change {
|
|||
} else {
|
||||
$self->{"btn_layer_editing"}->Enable;
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, "layersediting", 1);
|
||||
#===================================================================================================================================================
|
||||
}
|
||||
} elsif ($opt_key eq 'extruder_colour') {
|
||||
$update_scheduled = 1;
|
||||
|
@ -2190,33 +2176,20 @@ sub object_list_changed {
|
|||
|
||||
# Enable/disable buttons depending on whether there are any objects on the platter.
|
||||
my $have_objects = @{$self->{objects}} ? 1 : 0;
|
||||
#===================================================================================================================================================
|
||||
# my $variable_layer_height_allowed = $self->{config}->variable_layer_height && Slic3r::GUI::_3DScene::is_layers_editing_allowed($self->{canvas3D});
|
||||
#===================================================================================================================================================
|
||||
if ($self->{htoolbar}) {
|
||||
# On OSX or Linux
|
||||
$self->{htoolbar}->EnableTool($_, $have_objects)
|
||||
#===================================================================================================================================================
|
||||
for (TB_RESET, TB_ARRANGE);
|
||||
# for (TB_RESET, TB_ARRANGE, TB_LAYER_EDITING);
|
||||
# $self->{htoolbar}->EnableTool(TB_LAYER_EDITING, 0) if (! $variable_layer_height_allowed);
|
||||
#===================================================================================================================================================
|
||||
} else {
|
||||
# On MSW
|
||||
my $method = $have_objects ? 'Enable' : 'Disable';
|
||||
$self->{"btn_$_"}->$method
|
||||
#===================================================================================================================================================
|
||||
for grep $self->{"btn_$_"}, qw(reset arrange reslice export_gcode export_stl print send_gcode);
|
||||
# for grep $self->{"btn_$_"}, qw(reset arrange reslice export_gcode export_stl print send_gcode layer_editing);
|
||||
# $self->{"btn_layer_editing"}->Disable if (! $variable_layer_height_allowed);
|
||||
#===================================================================================================================================================
|
||||
}
|
||||
|
||||
#===================================================================================================================================================
|
||||
for my $toolbar_item (qw(deleteall arrange)) {
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, $toolbar_item, $have_objects);
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
|
||||
my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file};
|
||||
my $model_fits = $self->{canvas3D} ? Slic3r::GUI::_3DScene::check_volumes_outside_state($self->{canvas3D}, $self->{config}) : 1;
|
||||
|
@ -2231,20 +2204,14 @@ sub selection_changed {
|
|||
my ($self) = @_;
|
||||
my ($obj_idx, $object) = $self->selected_object;
|
||||
my $have_sel = defined $obj_idx;
|
||||
#===================================================================================================================================================
|
||||
my $layers_height_allowed = $self->{config}->variable_layer_height && Slic3r::GUI::_3DScene::is_layers_editing_allowed($self->{canvas3D}) && $have_sel;
|
||||
#===================================================================================================================================================
|
||||
|
||||
$self->{right_panel}->Freeze;
|
||||
if ($self->{htoolbar}) {
|
||||
# On OSX or Linux
|
||||
$self->{htoolbar}->EnableTool($_, $have_sel)
|
||||
#===================================================================================================================================================
|
||||
for (TB_REMOVE, TB_MORE, TB_45CW, TB_45CCW, TB_SCALE, TB_SPLIT, TB_CUT, TB_SETTINGS);
|
||||
# for (TB_REMOVE, TB_MORE, TB_FEWER, TB_45CW, TB_45CCW, TB_SCALE, TB_SPLIT, TB_CUT, TB_SETTINGS);
|
||||
#===================================================================================================================================================
|
||||
|
||||
#===================================================================================================================================================
|
||||
|
||||
$self->{htoolbar}->EnableTool(TB_LAYER_EDITING, $layers_height_allowed);
|
||||
|
||||
if ($have_sel) {
|
||||
|
@ -2253,18 +2220,13 @@ sub selection_changed {
|
|||
} else {
|
||||
$self->{htoolbar}->EnableTool(TB_FEWER, 0);
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
|
||||
} else {
|
||||
# On MSW
|
||||
my $method = $have_sel ? 'Enable' : 'Disable';
|
||||
$self->{"btn_$_"}->$method
|
||||
#===================================================================================================================================================
|
||||
for grep $self->{"btn_$_"}, qw(remove increase rotate45cw rotate45ccw changescale split cut settings);
|
||||
# for grep $self->{"btn_$_"}, qw(remove increase decrease rotate45cw rotate45ccw changescale split cut settings);
|
||||
#===================================================================================================================================================
|
||||
|
||||
#===================================================================================================================================================
|
||||
|
||||
if ($layers_height_allowed) {
|
||||
$self->{"btn_layer_editing"}->Enable;
|
||||
} else {
|
||||
|
@ -2281,10 +2243,8 @@ sub selection_changed {
|
|||
} else {
|
||||
$self->{"btn_decrease"}->Disable;
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
}
|
||||
|
||||
#===================================================================================================================================================
|
||||
for my $toolbar_item (qw(delete more fewer ccw45 cw45 scale split cut settings)) {
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, $toolbar_item, $have_sel);
|
||||
}
|
||||
|
@ -2295,7 +2255,6 @@ sub selection_changed {
|
|||
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
Slic3r::GUI::_3DScene::enable_toolbar_item($self->{canvas3D}, "fewer", $model_object->instances_count > 1);
|
||||
}
|
||||
#===================================================================================================================================================
|
||||
|
||||
if ($self->{object_info_size}) { # have we already loaded the info pane?
|
||||
if ($have_sel) {
|
||||
|
|
|
@ -1820,12 +1820,10 @@ void _3DScene::enable_gizmos(wxGLCanvas* canvas, bool enable)
|
|||
s_canvas_mgr.enable_gizmos(canvas, enable);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void _3DScene::enable_toolbar(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
s_canvas_mgr.enable_toolbar(canvas, enable);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void _3DScene::enable_shader(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
|
@ -1847,7 +1845,6 @@ void _3DScene::allow_multisample(wxGLCanvas* canvas, bool allow)
|
|||
s_canvas_mgr.allow_multisample(canvas, allow);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void _3DScene::enable_toolbar_item(wxGLCanvas* canvas, const std::string& name, bool enable)
|
||||
{
|
||||
s_canvas_mgr.enable_toolbar_item(canvas, name, enable);
|
||||
|
@ -1857,7 +1854,6 @@ bool _3DScene::is_toolbar_item_pressed(wxGLCanvas* canvas, const std::string& na
|
|||
{
|
||||
return s_canvas_mgr.is_toolbar_item_pressed(canvas, name);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
|
@ -1994,7 +1990,6 @@ void _3DScene::register_on_update_geometry_info_callback(wxGLCanvas* canvas, voi
|
|||
s_canvas_mgr.register_on_update_geometry_info_callback(canvas, callback);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void _3DScene::register_action_add_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_action_add_callback(canvas, callback);
|
||||
|
@ -2059,7 +2054,6 @@ void _3DScene::register_action_layersediting_callback(wxGLCanvas* canvas, void*
|
|||
{
|
||||
s_canvas_mgr.register_action_layersediting_callback(canvas, callback);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
static inline int hex_digit_to_int(const char c)
|
||||
{
|
||||
|
|
|
@ -497,18 +497,14 @@ public:
|
|||
static void enable_picking(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_moving(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_gizmos(wxGLCanvas* canvas, bool enable);
|
||||
//###################################################################################################################################
|
||||
static void enable_toolbar(wxGLCanvas* canvas, bool enable);
|
||||
//###################################################################################################################################
|
||||
static void enable_shader(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_dynamic_background(wxGLCanvas* canvas, bool enable);
|
||||
static void allow_multisample(wxGLCanvas* canvas, bool allow);
|
||||
|
||||
//###################################################################################################################################
|
||||
static void enable_toolbar_item(wxGLCanvas* canvas, const std::string& name, bool enable);
|
||||
static bool is_toolbar_item_pressed(wxGLCanvas* canvas, const std::string& name);
|
||||
//###################################################################################################################################
|
||||
|
||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||
static void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
|
@ -542,7 +538,6 @@ public:
|
|||
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
//###################################################################################################################################
|
||||
static void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_delete_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_deleteall_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
@ -556,7 +551,6 @@ public:
|
|||
static void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
||||
//###################################################################################################################################
|
||||
|
||||
static std::vector<int> load_object(wxGLCanvas* canvas, const ModelObject* model_object, int obj_idx, std::vector<int> instance_idxs);
|
||||
static std::vector<int> load_object(wxGLCanvas* canvas, const Model* model, int obj_idx);
|
||||
|
|
|
@ -1793,9 +1793,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
|||
: m_canvas(canvas)
|
||||
, m_context(nullptr)
|
||||
, m_timer(nullptr)
|
||||
//###################################################################################################################################
|
||||
, m_toolbar(*this)
|
||||
//###################################################################################################################################
|
||||
, m_config(nullptr)
|
||||
, m_print(nullptr)
|
||||
, m_model(nullptr)
|
||||
|
@ -1805,9 +1803,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
|||
, m_force_zoom_to_bed_enabled(false)
|
||||
, m_apply_zoom_to_volumes_filter(false)
|
||||
, m_hover_volume_id(-1)
|
||||
//###################################################################################################################################
|
||||
, m_toolbar_action_running(false)
|
||||
//###################################################################################################################################
|
||||
, m_warning_texture_enabled(false)
|
||||
, m_legend_texture_enabled(false)
|
||||
, m_picking_enabled(false)
|
||||
|
@ -1914,10 +1910,8 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
|||
if (m_gizmos.is_enabled() && !m_gizmos.init())
|
||||
return false;
|
||||
|
||||
//###################################################################################################################################
|
||||
if (!_init_toolbar())
|
||||
return false;
|
||||
//###################################################################################################################################
|
||||
|
||||
m_initialized = true;
|
||||
|
||||
|
@ -2182,12 +2176,10 @@ void GLCanvas3D::enable_gizmos(bool enable)
|
|||
m_gizmos.set_enabled(enable);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::enable_toolbar(bool enable)
|
||||
{
|
||||
m_toolbar.set_enabled(enable);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3D::enable_shader(bool enable)
|
||||
{
|
||||
|
@ -2209,7 +2201,6 @@ void GLCanvas3D::allow_multisample(bool allow)
|
|||
m_multisample_allowed = allow;
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::enable_toolbar_item(const std::string& name, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
|
@ -2222,7 +2213,6 @@ bool GLCanvas3D::is_toolbar_item_pressed(const std::string& name) const
|
|||
{
|
||||
return m_toolbar.is_item_pressed(name);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3D::zoom_to_bed()
|
||||
{
|
||||
|
@ -2353,9 +2343,7 @@ void GLCanvas3D::render()
|
|||
_render_warning_texture();
|
||||
_render_legend_texture();
|
||||
_render_gizmo();
|
||||
//###################################################################################################################################
|
||||
_render_toolbar();
|
||||
//###################################################################################################################################
|
||||
_render_layer_editing_overlay();
|
||||
|
||||
m_canvas->SwapBuffers();
|
||||
|
@ -2658,7 +2646,6 @@ void GLCanvas3D::register_on_update_geometry_info_callback(void* callback)
|
|||
m_on_update_geometry_info_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::register_action_add_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
|
@ -2736,7 +2723,6 @@ void GLCanvas3D::register_action_layersediting_callback(void* callback)
|
|||
if (callback != nullptr)
|
||||
m_action_layersediting_callback.register_callback(callback);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3D::bind_event_handlers()
|
||||
{
|
||||
|
@ -2915,9 +2901,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1;
|
||||
m_layers_editing.last_object_id = layer_editing_object_idx;
|
||||
bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position);
|
||||
//###################################################################################################################################
|
||||
int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position);
|
||||
//###################################################################################################################################
|
||||
|
||||
if (evt.Entering())
|
||||
{
|
||||
|
@ -2937,13 +2921,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1))
|
||||
m_on_double_click_callback.call();
|
||||
//###################################################################################################################################
|
||||
else if (evt.LeftDClick() && (toolbar_contains_mouse != -1))
|
||||
{
|
||||
m_toolbar_action_running = true;
|
||||
m_toolbar.do_action((unsigned int)toolbar_contains_mouse);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
else if (evt.LeftDown() || evt.RightDown())
|
||||
{
|
||||
// If user pressed left or right button we first check whether this happened
|
||||
|
@ -2982,13 +2964,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.drag.gizmo_volume_idx = _get_first_selected_volume_id(selected_object_idx);
|
||||
m_dirty = true;
|
||||
}
|
||||
//###################################################################################################################################
|
||||
else if (toolbar_contains_mouse != -1)
|
||||
{
|
||||
m_toolbar_action_running = true;
|
||||
m_toolbar.do_action((unsigned int)toolbar_contains_mouse);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
else
|
||||
{
|
||||
// Select volume in this 3D canvas.
|
||||
|
@ -3045,20 +3025,16 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
}
|
||||
else if (evt.RightDown())
|
||||
{
|
||||
//###################################################################################################################################
|
||||
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
|
||||
// the context menu is already shown, ensuring it to disappear if the mouse is outside any volume
|
||||
m_mouse.position = Pointf((coordf_t)pos.x, (coordf_t)pos.y);
|
||||
render();
|
||||
if (m_hover_volume_id != -1)
|
||||
{
|
||||
//###################################################################################################################################
|
||||
// if right clicking on volume, propagate event through callback (shows context menu)
|
||||
if (m_volumes.volumes[volume_idx]->hover)
|
||||
m_on_right_click_callback.call(pos.x, pos.y);
|
||||
//###################################################################################################################################
|
||||
}
|
||||
//###################################################################################################################################
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3257,16 +3233,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
_on_move(volume_idxs);
|
||||
}
|
||||
//#############################################################################################################################################################################
|
||||
else if (evt.LeftUp() && !m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.is_dragging() && !is_layers_editing_enabled())
|
||||
// else if (!m_mouse.dragging && (m_hover_volume_id == -1) && !gizmos_overlay_contains_mouse && !m_gizmos.is_dragging() && !is_layers_editing_enabled())
|
||||
//#############################################################################################################################################################################
|
||||
{
|
||||
// deselect and propagate event through callback
|
||||
//###################################################################################################################################
|
||||
if (m_picking_enabled && !m_toolbar_action_running)
|
||||
// if (m_picking_enabled)
|
||||
//###################################################################################################################################
|
||||
{
|
||||
deselect_volumes();
|
||||
_on_select(-1);
|
||||
|
@ -3298,9 +3268,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse.set_start_position_3D_as_invalid();
|
||||
m_mouse.set_start_position_2D_as_invalid();
|
||||
m_mouse.dragging = false;
|
||||
//###################################################################################################################################
|
||||
m_toolbar_action_running = false;
|
||||
//###################################################################################################################################
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.Moving())
|
||||
|
@ -3367,13 +3335,11 @@ void GLCanvas3D::reset_legend_texture()
|
|||
m_legend_texture.reset();
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::set_tooltip(const std::string& tooltip)
|
||||
{
|
||||
if (m_canvas != nullptr)
|
||||
m_canvas->SetToolTip(tooltip);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
bool GLCanvas3D::_is_shown_on_screen() const
|
||||
{
|
||||
|
@ -3386,7 +3352,6 @@ void GLCanvas3D::_force_zoom_to_bed()
|
|||
m_force_zoom_to_bed_enabled = false;
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
bool GLCanvas3D::_init_toolbar()
|
||||
{
|
||||
if (!m_toolbar.is_enabled())
|
||||
|
@ -3523,7 +3488,6 @@ bool GLCanvas3D::_init_toolbar()
|
|||
|
||||
return true;
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||
{
|
||||
|
@ -3749,7 +3713,6 @@ void GLCanvas3D::_deregister_callbacks()
|
|||
m_on_gizmo_rotate_callback.deregister_callback();
|
||||
m_on_update_geometry_info_callback.deregister_callback();
|
||||
|
||||
//###################################################################################################################################
|
||||
m_action_add_callback.deregister_callback();
|
||||
m_action_delete_callback.deregister_callback();
|
||||
m_action_deleteall_callback.deregister_callback();
|
||||
|
@ -3763,7 +3726,6 @@ void GLCanvas3D::_deregister_callbacks()
|
|||
m_action_cut_callback.deregister_callback();
|
||||
m_action_settings_callback.deregister_callback();
|
||||
m_action_layersediting_callback.deregister_callback();
|
||||
//###################################################################################################################################
|
||||
}
|
||||
|
||||
void GLCanvas3D::_mark_volumes_for_layer_height() const
|
||||
|
@ -3876,9 +3838,7 @@ void GLCanvas3D::_picking_pass() const
|
|||
else
|
||||
m_gizmos.reset_all_states();
|
||||
|
||||
//###################################################################################################################################
|
||||
m_toolbar.update_hover_state(pos);
|
||||
//###################################################################################################################################
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4078,13 +4038,11 @@ void GLCanvas3D::_render_gizmo() const
|
|||
m_gizmos.render(*this, _selected_volumes_bounding_box());
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::_render_toolbar() const
|
||||
{
|
||||
_resize_toolbar();
|
||||
m_toolbar.render();
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
float GLCanvas3D::_get_layers_editing_cursor_z_relative() const
|
||||
{
|
||||
|
@ -5337,7 +5295,6 @@ bool GLCanvas3D::_is_any_volume_outside() const
|
|||
return false;
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3D::_resize_toolbar() const
|
||||
{
|
||||
Size cnv_size = get_canvas_size();
|
||||
|
@ -5368,7 +5325,6 @@ void GLCanvas3D::_resize_toolbar() const
|
|||
}
|
||||
}
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
#define slic3r_GLCanvas3D_hpp_
|
||||
|
||||
#include "../../slic3r/GUI/3DScene.hpp"
|
||||
//###################################################################################################################################
|
||||
#include "../../slic3r/GUI/GLToolbar.hpp"
|
||||
//#include "../../slic3r/GUI/GLTexture.hpp"
|
||||
//###################################################################################################################################
|
||||
|
||||
class wxTimer;
|
||||
class wxSizeEvent;
|
||||
|
@ -450,9 +447,7 @@ private:
|
|||
Shader m_shader;
|
||||
Mouse m_mouse;
|
||||
mutable Gizmos m_gizmos;
|
||||
//###################################################################################################################################
|
||||
mutable GLToolbar m_toolbar;
|
||||
//###################################################################################################################################
|
||||
|
||||
mutable GLVolumeCollection m_volumes;
|
||||
DynamicPrintConfig* m_config;
|
||||
|
@ -465,9 +460,7 @@ private:
|
|||
bool m_force_zoom_to_bed_enabled;
|
||||
bool m_apply_zoom_to_volumes_filter;
|
||||
mutable int m_hover_volume_id;
|
||||
//###################################################################################################################################
|
||||
bool m_toolbar_action_running;
|
||||
//###################################################################################################################################
|
||||
bool m_warning_texture_enabled;
|
||||
bool m_legend_texture_enabled;
|
||||
bool m_picking_enabled;
|
||||
|
@ -505,7 +498,6 @@ private:
|
|||
PerlCallback m_on_gizmo_rotate_callback;
|
||||
PerlCallback m_on_update_geometry_info_callback;
|
||||
|
||||
//###################################################################################################################################
|
||||
PerlCallback m_action_add_callback;
|
||||
PerlCallback m_action_delete_callback;
|
||||
PerlCallback m_action_deleteall_callback;
|
||||
|
@ -519,7 +511,6 @@ private:
|
|||
PerlCallback m_action_cut_callback;
|
||||
PerlCallback m_action_settings_callback;
|
||||
PerlCallback m_action_layersediting_callback;
|
||||
//###################################################################################################################################
|
||||
|
||||
public:
|
||||
GLCanvas3D(wxGLCanvas* canvas);
|
||||
|
@ -578,18 +569,14 @@ public:
|
|||
void enable_picking(bool enable);
|
||||
void enable_moving(bool enable);
|
||||
void enable_gizmos(bool enable);
|
||||
//###################################################################################################################################
|
||||
void enable_toolbar(bool enable);
|
||||
//###################################################################################################################################
|
||||
void enable_shader(bool enable);
|
||||
void enable_force_zoom_to_bed(bool enable);
|
||||
void enable_dynamic_background(bool enable);
|
||||
void allow_multisample(bool allow);
|
||||
|
||||
//###################################################################################################################################
|
||||
void enable_toolbar_item(const std::string& name, bool enable);
|
||||
bool is_toolbar_item_pressed(const std::string& name) const;
|
||||
//###################################################################################################################################
|
||||
|
||||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
|
@ -631,7 +618,6 @@ public:
|
|||
void register_on_gizmo_rotate_callback(void* callback);
|
||||
void register_on_update_geometry_info_callback(void* callback);
|
||||
|
||||
//###################################################################################################################################
|
||||
void register_action_add_callback(void* callback);
|
||||
void register_action_delete_callback(void* callback);
|
||||
void register_action_deleteall_callback(void* callback);
|
||||
|
@ -645,7 +631,6 @@ public:
|
|||
void register_action_cut_callback(void* callback);
|
||||
void register_action_settings_callback(void* callback);
|
||||
void register_action_layersediting_callback(void* callback);
|
||||
//###################################################################################################################################
|
||||
|
||||
void bind_event_handlers();
|
||||
void unbind_event_handlers();
|
||||
|
@ -664,17 +649,13 @@ public:
|
|||
|
||||
void reset_legend_texture();
|
||||
|
||||
//###################################################################################################################################
|
||||
void set_tooltip(const std::string& tooltip);
|
||||
//###################################################################################################################################
|
||||
|
||||
private:
|
||||
bool _is_shown_on_screen() const;
|
||||
void _force_zoom_to_bed();
|
||||
|
||||
//###################################################################################################################################
|
||||
bool _init_toolbar();
|
||||
//###################################################################################################################################
|
||||
|
||||
void _resize(unsigned int w, unsigned int h);
|
||||
|
||||
|
@ -701,9 +682,7 @@ private:
|
|||
void _render_layer_editing_overlay() const;
|
||||
void _render_volumes(bool fake_colors) const;
|
||||
void _render_gizmo() const;
|
||||
//###################################################################################################################################
|
||||
void _render_toolbar() const;
|
||||
//###################################################################################################################################
|
||||
|
||||
float _get_layers_editing_cursor_z_relative() const;
|
||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||
|
@ -761,9 +740,7 @@ private:
|
|||
|
||||
bool _is_any_volume_outside() const;
|
||||
|
||||
//###################################################################################################################################
|
||||
void _resize_toolbar() const;
|
||||
//###################################################################################################################################
|
||||
|
||||
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
||||
};
|
||||
|
|
|
@ -404,14 +404,12 @@ void GLCanvas3DManager::enable_gizmos(wxGLCanvas* canvas, bool enable)
|
|||
it->second->enable_gizmos(enable);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3DManager::enable_toolbar(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->enable_toolbar(enable);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3DManager::enable_shader(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
|
@ -441,7 +439,6 @@ void GLCanvas3DManager::allow_multisample(wxGLCanvas* canvas, bool allow)
|
|||
it->second->allow_multisample(allow);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3DManager::enable_toolbar_item(wxGLCanvas* canvas, const std::string& name, bool enable)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -454,7 +451,6 @@ bool GLCanvas3DManager::is_toolbar_item_pressed(wxGLCanvas* canvas, const std::s
|
|||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->is_toolbar_item_pressed(name) : false;
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
|
@ -699,7 +695,6 @@ void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* ca
|
|||
it->second->register_on_update_geometry_info_callback(callback);
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLCanvas3DManager::register_action_add_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -790,7 +785,6 @@ void GLCanvas3DManager::register_action_layersediting_callback(wxGLCanvas* canva
|
|||
if (it != m_canvases.end())
|
||||
it->second->register_action_layersediting_callback(callback);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
GLCanvas3DManager::CanvasesMap::iterator GLCanvas3DManager::_get_canvas(wxGLCanvas* canvas)
|
||||
{
|
||||
|
|
|
@ -110,18 +110,14 @@ public:
|
|||
void enable_picking(wxGLCanvas* canvas, bool enable);
|
||||
void enable_moving(wxGLCanvas* canvas, bool enable);
|
||||
void enable_gizmos(wxGLCanvas* canvas, bool enable);
|
||||
//###################################################################################################################################
|
||||
void enable_toolbar(wxGLCanvas* canvas, bool enable);
|
||||
//###################################################################################################################################
|
||||
void enable_shader(wxGLCanvas* canvas, bool enable);
|
||||
void enable_force_zoom_to_bed(wxGLCanvas* canvas, bool enable);
|
||||
void enable_dynamic_background(wxGLCanvas* canvas, bool enable);
|
||||
void allow_multisample(wxGLCanvas* canvas, bool allow);
|
||||
|
||||
//###################################################################################################################################
|
||||
void enable_toolbar_item(wxGLCanvas* canvas, const std::string& name, bool enable);
|
||||
bool is_toolbar_item_pressed(wxGLCanvas* canvas, const std::string& name) const;
|
||||
//###################################################################################################################################
|
||||
|
||||
void zoom_to_bed(wxGLCanvas* canvas);
|
||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
|
@ -165,7 +161,6 @@ public:
|
|||
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
//###################################################################################################################################
|
||||
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_delete_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_deleteall_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
@ -179,7 +174,6 @@ public:
|
|||
void register_action_cut_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_settings_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_action_layersediting_callback(wxGLCanvas* canvas, void* callback);
|
||||
//###################################################################################################################################
|
||||
|
||||
private:
|
||||
CanvasesMap::iterator _get_canvas(wxGLCanvas* canvas);
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
//###################################################################################################################################
|
||||
GLTexture::Quad_UVs GLTexture::FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
|
||||
//###################################################################################################################################
|
||||
|
||||
GLTexture::GLTexture()
|
||||
: m_id(0)
|
||||
|
@ -133,32 +131,9 @@ const std::string& GLTexture::get_source() const
|
|||
|
||||
void GLTexture::render_texture(unsigned int tex_id, float left, float right, float bottom, float top)
|
||||
{
|
||||
//###################################################################################################################################
|
||||
render_sub_texture(tex_id, left, right, bottom, top, FullTextureUVs);
|
||||
|
||||
// ::glEnable(GL_BLEND);
|
||||
// ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//
|
||||
// ::glEnable(GL_TEXTURE_2D);
|
||||
// ::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
//
|
||||
// ::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id);
|
||||
//
|
||||
// ::glBegin(GL_QUADS);
|
||||
// ::glTexCoord2f(0.0f, 1.0f); ::glVertex2f(left, bottom);
|
||||
// ::glTexCoord2f(1.0f, 1.0f); ::glVertex2f(right, bottom);
|
||||
// ::glTexCoord2f(1.0f, 0.0f); ::glVertex2f(right, top);
|
||||
// ::glTexCoord2f(0.0f, 0.0f); ::glVertex2f(left, top);
|
||||
// ::glEnd();
|
||||
//
|
||||
// ::glBindTexture(GL_TEXTURE_2D, 0);
|
||||
//
|
||||
// ::glDisable(GL_TEXTURE_2D);
|
||||
// ::glDisable(GL_BLEND);
|
||||
//###################################################################################################################################
|
||||
}
|
||||
|
||||
//###################################################################################################################################
|
||||
void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const GLTexture::Quad_UVs& uvs)
|
||||
{
|
||||
::glEnable(GL_BLEND);
|
||||
|
@ -181,7 +156,6 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
|
|||
::glDisable(GL_TEXTURE_2D);
|
||||
::glDisable(GL_BLEND);
|
||||
}
|
||||
//###################################################################################################################################
|
||||
|
||||
unsigned int GLTexture::_generate_mipmaps(wxImage& image)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace GUI {
|
|||
|
||||
class GLTexture
|
||||
{
|
||||
//###################################################################################################################################
|
||||
public:
|
||||
struct UV
|
||||
{
|
||||
|
@ -27,7 +26,6 @@ namespace GUI {
|
|||
};
|
||||
|
||||
static Quad_UVs FullTextureUVs;
|
||||
//###################################################################################################################################
|
||||
|
||||
protected:
|
||||
unsigned int m_id;
|
||||
|
@ -49,9 +47,7 @@ namespace GUI {
|
|||
const std::string& get_source() const;
|
||||
|
||||
static void render_texture(unsigned int tex_id, float left, float right, float bottom, float top);
|
||||
//###################################################################################################################################
|
||||
static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs& uvs);
|
||||
//###################################################################################################################################
|
||||
|
||||
protected:
|
||||
unsigned int _generate_mipmaps(wxImage& image);
|
||||
|
|
Loading…
Add table
Reference in a new issue