Code cleanup
This commit is contained in:
parent
9daae9413a
commit
e79b0a2f25
@ -296,20 +296,17 @@ sub new {
|
||||
}
|
||||
});
|
||||
|
||||
#======================================================================================================================================
|
||||
Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D},
|
||||
sub {
|
||||
$self->{preview_iface}->set_viewport_from_scene($self->{canvas3D});
|
||||
});
|
||||
# Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D}, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D}); });
|
||||
#======================================================================================================================================
|
||||
}
|
||||
|
||||
Slic3r::GUI::register_on_request_update_callback(sub { $self->schedule_background_process; });
|
||||
|
||||
# Initialize 3D toolpaths preview
|
||||
if ($Slic3r::GUI::have_OpenGL) {
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface} = Slic3r::GUI::create_preview_iface($self->{preview_notebook}, $self->{config}, $self->{print}, $self->{gcode_preview_data});
|
||||
$self->{preview_page_idx} = $self->{preview_notebook}->GetPageCount-1;
|
||||
$self->{preview_iface}->register_on_viewport_changed_callback(sub { $self->{preview_iface}->set_viewport_into_scene($self->{canvas3D}); });
|
||||
@ -318,19 +315,15 @@ sub new {
|
||||
# Slic3r::GUI::_3DScene::enable_dynamic_background($self->{preview3D}->canvas, 1);
|
||||
# Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{preview3D}->canvas, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas); });
|
||||
# $self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview'));
|
||||
#======================================================================================================================================
|
||||
$self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1;
|
||||
}
|
||||
|
||||
EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub {
|
||||
my $preview = $self->{preview_notebook}->GetCurrentPage;
|
||||
#======================================================================================================================================
|
||||
my $page_id = $self->{preview_notebook}->GetSelection;
|
||||
if (($preview != $self->{canvas3D}) && ($page_id != $self->{preview_page_idx})) {
|
||||
# if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D})) {
|
||||
#======================================================================================================================================
|
||||
$preview->OnActivate if $preview->can('OnActivate');
|
||||
#======================================================================================================================================
|
||||
} elsif ($page_id == $self->{preview_page_idx}) {
|
||||
$self->{preview_iface}->reload_print;
|
||||
# sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
||||
@ -339,7 +332,6 @@ sub new {
|
||||
# $self->{preview3D}->reload_print;
|
||||
# # sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
||||
# Slic3r::GUI::_3DScene::set_as_dirty($self->{preview3D}->canvas);
|
||||
#======================================================================================================================================
|
||||
} elsif ($preview == $self->{canvas3D}) {
|
||||
if (Slic3r::GUI::_3DScene::is_reload_delayed($self->{canvas3D})) {
|
||||
my $selections = $self->collect_selections;
|
||||
@ -482,10 +474,8 @@ sub new {
|
||||
|
||||
$_->SetDropTarget(Slic3r::GUI::Plater::DropTarget->new($self))
|
||||
for grep defined($_),
|
||||
#======================================================================================================================================
|
||||
$self, $self->{canvas3D}, $self->{preview_iface}, $self->{list};
|
||||
# $self, $self->{canvas3D}, $self->{preview3D}, $self->{list};
|
||||
#======================================================================================================================================
|
||||
# $self, $self->{canvas}, $self->{canvas3D}, $self->{preview3D};
|
||||
|
||||
EVT_COMMAND($self, -1, $SLICING_COMPLETED_EVENT, sub {
|
||||
@ -512,12 +502,10 @@ sub new {
|
||||
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape);
|
||||
Slic3r::GUI::_3DScene::zoom_to_bed($self->{canvas3D});
|
||||
}
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
|
||||
# if ($self->{preview3D}) {
|
||||
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape);
|
||||
# }
|
||||
#======================================================================================================================================
|
||||
$self->update;
|
||||
|
||||
{
|
||||
@ -1032,10 +1020,8 @@ sub remove {
|
||||
$self->stop_background_process;
|
||||
|
||||
# Prevent toolpaths preview from rendering while we modify the Print object
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_enabled(0) if $self->{preview_iface};
|
||||
# $self->{preview3D}->enabled(0) if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
|
||||
# If no object index is supplied, remove the selected one.
|
||||
if (! defined $obj_idx) {
|
||||
@ -1060,10 +1046,8 @@ sub reset {
|
||||
$self->stop_background_process;
|
||||
|
||||
# Prevent toolpaths preview from rendering while we modify the Print object
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_enabled(0) if $self->{preview_iface};
|
||||
# $self->{preview3D}->enabled(0) if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
|
||||
@{$self->{objects}} = ();
|
||||
$self->{model}->clear_objects;
|
||||
@ -1424,10 +1408,8 @@ sub async_apply_config {
|
||||
# Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
|
||||
# Otherwise they will be just refreshed.
|
||||
$self->{gcode_preview_data}->reset;
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->reload_print if $self->{preview_iface};
|
||||
# $self->{preview3D}->reload_print if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
# We also need to reload 3D scene because of the wipe tower preview box
|
||||
if ($self->{config}->wipe_tower) {
|
||||
my $selections = $self->collect_selections;
|
||||
@ -1462,10 +1444,8 @@ sub start_background_process {
|
||||
sub stop_background_process {
|
||||
my ($self) = @_;
|
||||
$self->{background_slicing_process}->stop();
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->reload_print if $self->{preview_iface};
|
||||
# $self->{preview3D}->reload_print if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
}
|
||||
|
||||
# Called by the "Slice now" button, which is visible only if the background processing is disabled.
|
||||
@ -1571,10 +1551,8 @@ sub export_gcode {
|
||||
# This message should be called by the background process synchronously.
|
||||
sub on_update_print_preview {
|
||||
my ($self) = @_;
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->reload_print if $self->{preview_iface};
|
||||
# $self->{preview3D}->reload_print if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
|
||||
# in case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
|
||||
my $selections = $self->collect_selections;
|
||||
@ -1655,10 +1633,8 @@ sub on_process_completed {
|
||||
$self->object_list_changed;
|
||||
|
||||
# refresh preview
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->reload_print if $self->{preview_iface};
|
||||
# $self->{preview3D}->reload_print if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
}
|
||||
|
||||
# Fill in the "Sliced info" box with the result of the G-code generator.
|
||||
@ -1926,12 +1902,10 @@ sub update {
|
||||
my $selections = $self->collect_selections;
|
||||
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
|
||||
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 0);
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->reset_gcode_preview_data if $self->{preview_iface};
|
||||
$self->{preview_iface}->reload_print if $self->{preview_iface};
|
||||
# $self->{preview3D}->reset_gcode_preview_data if $self->{preview3D};
|
||||
# $self->{preview3D}->reload_print if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
$self->schedule_background_process;
|
||||
$self->Thaw;
|
||||
}
|
||||
@ -2007,10 +1981,8 @@ sub on_config_change {
|
||||
if ($opt_key eq 'bed_shape') {
|
||||
# $self->{canvas}->update_bed_size;
|
||||
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape) if $self->{canvas3D};
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
|
||||
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
$update_scheduled = 1;
|
||||
} elsif ($opt_key =~ '^wipe_tower' || $opt_key eq 'single_extruder_multi_material') {
|
||||
$update_scheduled = 1;
|
||||
@ -2045,19 +2017,15 @@ sub on_config_change {
|
||||
} elsif ($opt_key eq 'extruder_colour') {
|
||||
$update_scheduled = 1;
|
||||
my $extruder_colors = $config->get('extruder_colour');
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_number_extruders(scalar(@{$extruder_colors}));
|
||||
# $self->{preview3D}->set_number_extruders(scalar(@{$extruder_colors}));
|
||||
#======================================================================================================================================
|
||||
} elsif ($opt_key eq 'max_print_height') {
|
||||
$update_scheduled = 1;
|
||||
} elsif ($opt_key eq 'printer_model') {
|
||||
# update to force bed selection (for texturing)
|
||||
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape) if $self->{canvas3D};
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
|
||||
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
|
||||
#======================================================================================================================================
|
||||
$update_scheduled = 1;
|
||||
}
|
||||
}
|
||||
@ -2509,18 +2477,14 @@ sub select_view {
|
||||
my $idx_page = $self->{preview_notebook}->GetSelection;
|
||||
my $page = ($idx_page == &Wx::wxNOT_FOUND) ? L('3D') : $self->{preview_notebook}->GetPageText($idx_page);
|
||||
if ($page eq L('Preview')) {
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->select_view($direction);
|
||||
$self->{preview_iface}->set_viewport_into_scene($self->{canvas3D});
|
||||
# Slic3r::GUI::_3DScene::select_view($self->{preview3D}->canvas, $direction);
|
||||
# Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas);
|
||||
#======================================================================================================================================
|
||||
} else {
|
||||
Slic3r::GUI::_3DScene::select_view($self->{canvas3D}, $direction);
|
||||
#======================================================================================================================================
|
||||
$self->{preview_iface}->set_viewport_from_scene($self->{canvas3D});
|
||||
# Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D});
|
||||
#======================================================================================================================================
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,8 @@
|
||||
|
||||
#include "Tab.hpp"
|
||||
#include "TabIface.hpp"
|
||||
//##############################################################################################################################################################
|
||||
#include "GUI_Preview.hpp"
|
||||
#include "GUI_PreviewIface.hpp"
|
||||
//##############################################################################################################################################################
|
||||
#include "AboutDialog.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "ConfigSnapshotDialog.hpp"
|
||||
@ -152,9 +150,7 @@ wxStaticBitmap *g_manifold_warning_icon = nullptr;
|
||||
bool g_show_print_info = false;
|
||||
bool g_show_manifold_warning_icon = false;
|
||||
|
||||
//##############################################################################################################################################################
|
||||
PreviewIface* g_preview = nullptr; // <<< FIXME ENRICO -> add code to delete the pointer when the application closes
|
||||
//##############################################################################################################################################################
|
||||
PreviewIface* g_preview = nullptr;
|
||||
|
||||
static void init_label_colours()
|
||||
{
|
||||
@ -673,7 +669,6 @@ TabIface* get_preset_tab_iface(char *name)
|
||||
return new TabIface(nullptr);
|
||||
}
|
||||
|
||||
//##############################################################################################################################################################
|
||||
PreviewIface* create_preview_iface(wxNotebook* parent, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data)
|
||||
{
|
||||
if (g_preview == nullptr)
|
||||
@ -684,7 +679,6 @@ PreviewIface* create_preview_iface(wxNotebook* parent, DynamicPrintConfig* confi
|
||||
|
||||
return g_preview;
|
||||
}
|
||||
//##############################################################################################################################################################
|
||||
|
||||
// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
|
||||
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/)
|
||||
|
@ -39,11 +39,9 @@ class AppConfig;
|
||||
class PresetUpdater;
|
||||
class DynamicPrintConfig;
|
||||
class TabIface;
|
||||
//##############################################################################################################################################################
|
||||
class PreviewIface;
|
||||
class Print;
|
||||
class GCodePreviewData;
|
||||
//##############################################################################################################################################################
|
||||
|
||||
#define _(s) Slic3r::GUI::I18N::translate((s))
|
||||
|
||||
@ -170,9 +168,7 @@ extern void open_preferences_dialog(int event_preferences);
|
||||
void create_preset_tabs(int event_value_change, int event_presets_changed);
|
||||
TabIface* get_preset_tab_iface(char *name);
|
||||
|
||||
//##############################################################################################################################################################
|
||||
PreviewIface* create_preview_iface(wxNotebook* notebook, DynamicPrintConfig* config, Print* print, GCodePreviewData* gcode_preview_data);
|
||||
//##############################################################################################################################################################
|
||||
|
||||
// add it at the end of the tab panel.
|
||||
void add_created_tab(Tab* panel, int event_value_change, int event_presets_changed);
|
||||
|
@ -57,14 +57,15 @@ bool Preview::init(wxNotebook* notebook, DynamicPrintConfig* config, Print* prin
|
||||
if (!Create(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize))
|
||||
return false;
|
||||
|
||||
int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_SAMPLE_BUFFERS, 1, WX_GL_SAMPLES, 4, 0 };
|
||||
int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_SAMPLE_BUFFERS, GL_TRUE, WX_GL_SAMPLES, 4, 0 };
|
||||
|
||||
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
||||
const AppConfig* app_config = GUI::get_app_config();
|
||||
bool enable_multisample = (app_config != nullptr) && (app_config->get("use_legacy_opengl") != "1") && (wxVersion >= 30003);
|
||||
|
||||
// if multisample is not enabled or supported by the graphic card, remove it from the attributes list
|
||||
bool can_multisample = enable_multisample && wxGLCanvas::IsDisplaySupported(attribList); // <<< FIXME ENRICO IsDisplaySupported() seems not to work
|
||||
bool can_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
||||
// bool can_multisample = enable_multisample && wxGLCanvas::IsDisplaySupported(attribList); // <<< Alternative method: but IsDisplaySupported() seems not to work
|
||||
if (!can_multisample)
|
||||
attribList[4] = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user