Merge branch 'master' into wipe_tower_improvements
This commit is contained in:
commit
fe0f0fe6af
@ -49,6 +49,7 @@ my \$defines = ' ' . Alien::wxWidgets->defines;
|
||||
my \$cflags = Alien::wxWidgets->c_flags;
|
||||
my \$linkflags = Alien::wxWidgets->link_flags;
|
||||
my \$libraries = ' ' . Alien::wxWidgets->libraries(@components);
|
||||
my \$gui_toolkit = Alien::wxWidgets->config->{toolkit};
|
||||
#my @libraries = Alien::wxWidgets->link_libraries(@components);
|
||||
#my @implib = Alien::wxWidgets->import_libraries(@components);
|
||||
#my @shrlib = Alien::wxWidgets->shared_libraries(@components);
|
||||
@ -82,6 +83,7 @@ cmake_set_var('LIBRARIES', \$libraries);
|
||||
cmake_set_var('DEFINITIONS', \$defines);
|
||||
#cmake_set_var('DEFINITIONS_DEBUG', );
|
||||
cmake_set_var('CXX_FLAGS', \$cflags);
|
||||
cmake_set_var('GUI_TOOLKIT', \$gui_toolkit);
|
||||
close \$fh;
|
||||
")
|
||||
include(${AlienWx_TEMP_INCLUDE})
|
||||
@ -96,6 +98,7 @@ if (AlienWx_DEBUG)
|
||||
message(STATUS " AlienWx_DEFINITIONS = ${AlienWx_DEFINITIONS}")
|
||||
message(STATUS " AlienWx_DEFINITIONS_DEBUG = ${AlienWx_DEFINITIONS_DEBUG}")
|
||||
message(STATUS " AlienWx_CXX_FLAGS = ${AlienWx_CXX_FLAGS}")
|
||||
message(STATUS " AlienWx_GUI_TOOLKIT = ${AlienWx_GUI_TOOLKIT}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
@ -187,6 +187,7 @@ sub new {
|
||||
if ($Slic3r::GUI::have_OpenGL) {
|
||||
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
||||
Slic3r::GUI::_3DScene::enable_legend_texture($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;
|
||||
@ -200,17 +201,18 @@ sub new {
|
||||
|
||||
EVT_NOTEBOOK_PAGE_CHANGED($self, $self->{preview_notebook}, sub {
|
||||
my $preview = $self->{preview_notebook}->GetCurrentPage;
|
||||
if ($preview == $self->{preview3D})
|
||||
{
|
||||
if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D})) {
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
||||
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 0);
|
||||
Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
$preview->OnActivate if $preview->can('OnActivate');
|
||||
} elsif ($preview == $self->{preview3D}) {
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 1);
|
||||
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 0);
|
||||
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1);
|
||||
$self->{preview3D}->load_print(1);
|
||||
} else {
|
||||
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 0);
|
||||
}
|
||||
|
||||
if ($preview == $self->{canvas3D}) {
|
||||
$self->{preview3D}->load_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}) {
|
||||
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 1);
|
||||
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
|
||||
if (Slic3r::GUI::_3DScene::is_reload_delayed($self->{canvas3D})) {
|
||||
@ -218,8 +220,8 @@ sub new {
|
||||
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
|
||||
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 1);
|
||||
}
|
||||
} else {
|
||||
$preview->OnActivate if $preview->can('OnActivate');
|
||||
# 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->{canvas3D});
|
||||
}
|
||||
});
|
||||
|
||||
@ -1888,6 +1890,8 @@ sub on_config_change {
|
||||
$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};
|
||||
Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
|
||||
$update_scheduled = 1;
|
||||
}
|
||||
}
|
||||
|
@ -231,8 +231,9 @@ sub mouse_event {
|
||||
}
|
||||
$self->Refresh;
|
||||
} elsif ($event->LeftUp) {
|
||||
$self->{on_instances_moved}->()
|
||||
if $self->{drag_object};
|
||||
if ($self->{drag_object}) {
|
||||
$self->{on_instances_moved}->();
|
||||
}
|
||||
$self->{drag_start_pos} = undef;
|
||||
$self->{drag_object} = undef;
|
||||
$self->SetCursor(wxSTANDARD_CURSOR);
|
||||
|
@ -199,11 +199,11 @@ sub new {
|
||||
my $old_zoom = $self->_zoom;
|
||||
|
||||
# Calculate the zoom delta and apply it to the current zoom factor
|
||||
my $zoom = $e->GetWheelRotation() / $e->GetWheelDelta();
|
||||
my $zoom = -$e->GetWheelRotation() / $e->GetWheelDelta();
|
||||
$zoom = max(min($zoom, 4), -4);
|
||||
$zoom /= 10;
|
||||
$self->_zoom($self->_zoom / (1-$zoom));
|
||||
$self->_zoom(1) if $self->_zoom > 1; # prevent from zooming out too much
|
||||
$self->_zoom(1.25) if $self->_zoom > 1.25; # prevent from zooming out too much
|
||||
|
||||
{
|
||||
# In order to zoom around the mouse point we need to translate
|
||||
@ -227,7 +227,6 @@ sub new {
|
||||
}
|
||||
|
||||
$self->_dirty(1);
|
||||
$self->Refresh;
|
||||
});
|
||||
EVT_MOUSE_EVENTS($self, \&mouse_event);
|
||||
|
||||
@ -255,8 +254,8 @@ sub mouse_event {
|
||||
return if !$self->GetParent->enabled;
|
||||
|
||||
my $pos = Slic3r::Pointf->new($e->GetPositionXY);
|
||||
if ($e->Entering && &Wx::wxMSW) {
|
||||
# wxMSW needs focus in order to catch mouse wheel events
|
||||
if ($e->Entering && (&Wx::wxMSW || $^O eq 'linux')) {
|
||||
# wxMSW and Linux needs focus in order to catch key events
|
||||
$self->SetFocus;
|
||||
} elsif ($e->Dragging) {
|
||||
if ($e->LeftIsDown || $e->MiddleIsDown || $e->RightIsDown) {
|
||||
@ -276,7 +275,6 @@ sub mouse_event {
|
||||
);
|
||||
|
||||
$self->_dirty(1);
|
||||
$self->Refresh;
|
||||
}
|
||||
$self->_drag_start_xy($pos);
|
||||
}
|
||||
@ -631,6 +629,27 @@ sub Resize {
|
||||
glLoadIdentity();
|
||||
|
||||
my $bb = $self->bb->clone;
|
||||
|
||||
# rescale in dependence of window aspect ratio
|
||||
my $bb_size = $bb->size;
|
||||
my $ratio_x = ($x != 0.0) ? $bb_size->x / $x : 1.0;
|
||||
my $ratio_y = ($y != 0.0) ? $bb_size->y / $y : 1.0;
|
||||
|
||||
if ($ratio_y < $ratio_x) {
|
||||
if ($ratio_y != 0.0) {
|
||||
my $new_size_y = $bb_size->y * $ratio_x / $ratio_y;
|
||||
my $half_delta_size_y = 0.5 * ($new_size_y - $bb_size->y);
|
||||
$bb->set_y_min($bb->y_min - $half_delta_size_y);
|
||||
$bb->set_y_max($bb->y_max + $half_delta_size_y);
|
||||
}
|
||||
} elsif ($ratio_x < $ratio_y) {
|
||||
if ($ratio_x != 0.0) {
|
||||
my $new_size_x = $bb_size->x * $ratio_y / $ratio_x;
|
||||
my $half_delta_size_x = 0.5 * ($new_size_x - $bb_size->x);
|
||||
$bb->set_x_min($bb->x_min - $half_delta_size_x);
|
||||
$bb->set_x_max($bb->x_max + $half_delta_size_x);
|
||||
}
|
||||
}
|
||||
|
||||
# center bounding box around origin before scaling it
|
||||
my $bb_center = $bb->center;
|
||||
@ -645,25 +664,25 @@ sub Resize {
|
||||
# translate camera
|
||||
$bb->translate(@{$self->_camera_target});
|
||||
|
||||
# keep camera_bb within total bb
|
||||
# (i.e. prevent user from panning outside the bounding box)
|
||||
{
|
||||
my @translate = (0,0);
|
||||
if ($bb->x_min < $self->bb->x_min) {
|
||||
$translate[X] += $self->bb->x_min - $bb->x_min;
|
||||
}
|
||||
if ($bb->y_min < $self->bb->y_min) {
|
||||
$translate[Y] += $self->bb->y_min - $bb->y_min;
|
||||
}
|
||||
if ($bb->x_max > $self->bb->x_max) {
|
||||
$translate[X] -= $bb->x_max - $self->bb->x_max;
|
||||
}
|
||||
if ($bb->y_max > $self->bb->y_max) {
|
||||
$translate[Y] -= $bb->y_max - $self->bb->y_max;
|
||||
}
|
||||
$self->_camera_target->translate(@translate);
|
||||
$bb->translate(@translate);
|
||||
}
|
||||
# # keep camera_bb within total bb
|
||||
# # (i.e. prevent user from panning outside the bounding box)
|
||||
# {
|
||||
# my @translate = (0,0);
|
||||
# if ($bb->x_min < $self->bb->x_min) {
|
||||
# $translate[X] += $self->bb->x_min - $bb->x_min;
|
||||
# }
|
||||
# if ($bb->y_min < $self->bb->y_min) {
|
||||
# $translate[Y] += $self->bb->y_min - $bb->y_min;
|
||||
# }
|
||||
# if ($bb->x_max > $self->bb->x_max) {
|
||||
# $translate[X] -= $bb->x_max - $self->bb->x_max;
|
||||
# }
|
||||
# if ($bb->y_max > $self->bb->y_max) {
|
||||
# $translate[Y] -= $bb->y_max - $self->bb->y_max;
|
||||
# }
|
||||
# $self->_camera_target->translate(@translate);
|
||||
# $bb->translate(@translate);
|
||||
# }
|
||||
|
||||
# save camera
|
||||
$self->_camera_bb($bb);
|
||||
|
@ -279,6 +279,7 @@ sub reload_print {
|
||||
my ($self, $force) = @_;
|
||||
|
||||
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
|
||||
Slic3r::GUI::_3DScene::reset_current_canvas();
|
||||
$self->_loaded(0);
|
||||
|
||||
if (! $self->IsShown && ! $force) {
|
||||
|
@ -101,7 +101,12 @@ sub export_gcode {
|
||||
die "The configured post-processing script is not executable: check permissions. ($script)\n";
|
||||
}
|
||||
if ($^O eq 'MSWin32' && $script =~ /\.[pP][lL]/) {
|
||||
system($^X, $script, $output_file);
|
||||
# The current process (^X) may be slic3r.exe or slic3r-console.exe.
|
||||
# Replace it with the current perl interpreter.
|
||||
my($filename, $directories, $suffix) = fileparse($^X);
|
||||
$filename =~ s/^slic3r.*$/perl5\.24\.0\.exe/;
|
||||
my $interpreter = $directories . $filename;
|
||||
system($interpreter, $script, $output_file);
|
||||
} else {
|
||||
system($script, $output_file);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@ xs/src/slic3r/GUI/ButtonsDescription.cpp
|
||||
xs/src/slic3r/GUI/ConfigSnapshotDialog.cpp
|
||||
xs/src/slic3r/GUI/ConfigWizard.cpp
|
||||
xs/src/slic3r/GUI/FirmwareDialog.cpp
|
||||
xs/src/slic3r/GUI/GLCanvas3D.cpp
|
||||
xs/src/slic3r/GUI/GUI.cpp
|
||||
xs/src/slic3r/GUI/MsgDialog.cpp
|
||||
xs/src/slic3r/GUI/Tab.cpp
|
||||
|
@ -8,6 +8,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall" )
|
||||
find_package(PkgConfig REQUIRED)
|
||||
endif()
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
|
||||
@ -579,6 +580,15 @@ if (SLIC3R_PRUSACONTROL)
|
||||
#add_compile_options(${AlienWx_CXX_FLAGS})
|
||||
add_definitions(${AlienWx_DEFINITIONS})
|
||||
set(wxWidgets_LIBRARIES ${AlienWx_LIBRARIES})
|
||||
# On Linux / gtk, we need to have a direct access to gtk+ for some workarounds.
|
||||
if (AlienWx_GUI_TOOLKIT STREQUAL "gtk2")
|
||||
pkg_check_modules(GTK2 gtk+-2.0)
|
||||
include_directories(${GTK2_INCLUDE_DIRS})
|
||||
endif()
|
||||
if (AlienWx_GUI_TOOLKIT STREQUAL "gtk3")
|
||||
pkg_check_modules(GTK3 gtk+-3.0)
|
||||
include_directories(${GTK3_INCLUDE_DIRS})
|
||||
endif()
|
||||
else ()
|
||||
find_package(wxWidgets REQUIRED COMPONENTS base core adv html gl)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
|
@ -433,6 +433,7 @@ std::vector<int> GLVolumeCollection::load_object(
|
||||
v.extruder_id = extruder_id;
|
||||
}
|
||||
v.is_modifier = model_volume->modifier;
|
||||
v.outside_printer_detection_enabled = !model_volume->modifier;
|
||||
}
|
||||
}
|
||||
|
||||
@ -663,7 +664,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config)
|
||||
bool contained = true;
|
||||
for (GLVolume* volume : this->volumes)
|
||||
{
|
||||
if (volume != nullptr)
|
||||
if ((volume != nullptr) && !volume->is_modifier)
|
||||
{
|
||||
bool state = print_volume.contains(volume->transformed_bounding_box());
|
||||
contained &= state;
|
||||
@ -1753,11 +1754,26 @@ bool _3DScene::init(wxGLCanvas* canvas)
|
||||
return s_canvas_mgr.init(canvas);
|
||||
}
|
||||
|
||||
bool _3DScene::set_current(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
return s_canvas_mgr.set_current(canvas, force);
|
||||
}
|
||||
|
||||
void _3DScene::reset_current_canvas()
|
||||
{
|
||||
s_canvas_mgr.set_current(nullptr, false);
|
||||
}
|
||||
|
||||
void _3DScene::set_active(wxGLCanvas* canvas, bool active)
|
||||
{
|
||||
s_canvas_mgr.set_active(canvas, active);
|
||||
}
|
||||
|
||||
void _3DScene::set_as_dirty(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.set_as_dirty(canvas);
|
||||
}
|
||||
|
||||
unsigned int _3DScene::get_volumes_count(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_volumes_count(canvas);
|
||||
|
@ -516,7 +516,11 @@ public:
|
||||
|
||||
static bool init(wxGLCanvas* canvas);
|
||||
|
||||
static bool set_current(wxGLCanvas* canvas, bool force);
|
||||
static void reset_current_canvas();
|
||||
|
||||
static void set_active(wxGLCanvas* canvas, bool active);
|
||||
static void set_as_dirty(wxGLCanvas* canvas);
|
||||
|
||||
static unsigned int get_volumes_count(wxGLCanvas* canvas);
|
||||
static void reset_volumes(wxGLCanvas* canvas);
|
||||
|
@ -12,10 +12,20 @@ namespace Slic3r { namespace GUI {
|
||||
|
||||
wxString double_to_string(double const value)
|
||||
{
|
||||
int precision = 10 * value - int(10 * value) == 0 ? 1 : 2;
|
||||
return value - int(value) == 0 ?
|
||||
wxString::Format(_T("%i"), int(value)) :
|
||||
wxNumberFormatter::ToString(value, precision, wxNumberFormatter::Style_None);
|
||||
if (value - int(value) == 0)
|
||||
return wxString::Format(_T("%i"), int(value));
|
||||
else {
|
||||
int precision = 4;
|
||||
for (size_t p = 1; p < 4; p++)
|
||||
{
|
||||
double cur_val = pow(10, p)*value;
|
||||
if (cur_val - int(cur_val) == 0) {
|
||||
precision = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return wxNumberFormatter::ToString(value, precision, wxNumberFormatter::Style_None);
|
||||
}
|
||||
}
|
||||
|
||||
void Field::PostInitialize(){
|
||||
|
@ -1520,13 +1520,10 @@ bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::set_current()
|
||||
bool GLCanvas3D::set_current(bool force)
|
||||
{
|
||||
if ((m_canvas != nullptr) && (m_context != nullptr))
|
||||
{
|
||||
m_canvas->SetCurrent(*m_context);
|
||||
return true;
|
||||
}
|
||||
if ((force || m_active) && (m_canvas != nullptr) && (m_context != nullptr))
|
||||
return m_canvas->SetCurrent(*m_context);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1536,6 +1533,11 @@ void GLCanvas3D::set_active(bool active)
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_as_dirty()
|
||||
{
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3D::get_volumes_count() const
|
||||
{
|
||||
return (unsigned int)m_volumes.volumes.size();
|
||||
@ -1543,8 +1545,13 @@ unsigned int GLCanvas3D::get_volumes_count() const
|
||||
|
||||
void GLCanvas3D::reset_volumes()
|
||||
{
|
||||
if (set_current())
|
||||
|
||||
if (!m_volumes.empty())
|
||||
{
|
||||
// ensures this canvas is current
|
||||
if ((m_canvas == nullptr) || !_3DScene::set_current(m_canvas, true))
|
||||
return;
|
||||
|
||||
m_volumes.release_geometry();
|
||||
m_volumes.clear();
|
||||
m_dirty = true;
|
||||
@ -1842,8 +1849,8 @@ void GLCanvas3D::render()
|
||||
if (!_is_shown_on_screen())
|
||||
return;
|
||||
|
||||
// ensures that the proper context is selected and that this canvas is initialized
|
||||
if (!set_current() || !_3DScene::init(m_canvas))
|
||||
// ensures this canvas is current and initialized
|
||||
if (!_3DScene::set_current(m_canvas, false) || !_3DScene::init(m_canvas))
|
||||
return;
|
||||
|
||||
if (m_force_zoom_to_bed_enabled)
|
||||
@ -1924,6 +1931,11 @@ void GLCanvas3D::reload_scene(bool force)
|
||||
return;
|
||||
|
||||
reset_volumes();
|
||||
|
||||
// ensures this canvas is current
|
||||
if (!_3DScene::set_current(m_canvas, true))
|
||||
return;
|
||||
|
||||
set_bed_shape(dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape"))->values);
|
||||
|
||||
if (!m_canvas->IsShown() && !force)
|
||||
@ -1995,6 +2007,10 @@ void GLCanvas3D::reload_scene(bool force)
|
||||
|
||||
void GLCanvas3D::load_print_toolpaths()
|
||||
{
|
||||
// ensures this canvas is current
|
||||
if (!_3DScene::set_current(m_canvas, true))
|
||||
return;
|
||||
|
||||
if (m_print == nullptr)
|
||||
return;
|
||||
|
||||
@ -2359,8 +2375,8 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const
|
||||
{
|
||||
if ((m_canvas != nullptr) && (m_print != nullptr))
|
||||
{
|
||||
// ensures that the proper context is selected
|
||||
if (!set_current())
|
||||
// ensures that this canvas is current
|
||||
if (!_3DScene::set_current(m_canvas, true))
|
||||
return;
|
||||
|
||||
if (m_volumes.empty())
|
||||
@ -2677,7 +2693,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
#endif
|
||||
}
|
||||
else if (evt.LeftDClick() && (m_hover_volume_id != -1))
|
||||
{
|
||||
m_active = false;
|
||||
m_on_double_click_callback.call();
|
||||
m_active = true;
|
||||
}
|
||||
else if (evt.LeftDown() || evt.RightDown())
|
||||
{
|
||||
// If user pressed left or right button we first check whether this happened
|
||||
@ -2773,7 +2793,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
{
|
||||
// if right clicking on volume, propagate event through callback
|
||||
if (m_volumes.volumes[volume_idx]->hover)
|
||||
{
|
||||
m_active = false;
|
||||
m_on_right_click_callback.call(pos.x, pos.y);
|
||||
m_active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2991,10 +3015,11 @@ void GLCanvas3D::_force_zoom_to_bed()
|
||||
|
||||
void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||
{
|
||||
if (m_context == nullptr)
|
||||
if ((m_canvas == nullptr) && (m_context == nullptr))
|
||||
return;
|
||||
|
||||
set_current();
|
||||
// ensures that this canvas is current
|
||||
_3DScene::set_current(m_canvas, false);
|
||||
::glViewport(0, 0, w, h);
|
||||
|
||||
::glMatrixMode(GL_PROJECTION);
|
||||
@ -3580,9 +3605,11 @@ void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt)
|
||||
|
||||
Pointf3 GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, float* z)
|
||||
{
|
||||
if (!set_current())
|
||||
if (m_canvas == nullptr)
|
||||
return Pointf3(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||
|
||||
_camera_tranform();
|
||||
|
||||
GLint viewport[4];
|
||||
::glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
GLdouble modelview_matrix[16];
|
||||
|
@ -449,9 +449,10 @@ public:
|
||||
|
||||
bool init(bool useVBOs, bool use_legacy_opengl);
|
||||
|
||||
bool set_current();
|
||||
bool set_current(bool force);
|
||||
|
||||
void set_active(bool active);
|
||||
void set_as_dirty();
|
||||
|
||||
unsigned int get_volumes_count() const;
|
||||
void reset_volumes();
|
||||
|
@ -115,6 +115,7 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
|
||||
|
||||
GLCanvas3DManager::GLCanvas3DManager()
|
||||
: m_context(nullptr)
|
||||
, m_current(nullptr)
|
||||
, m_gl_initialized(false)
|
||||
, m_use_legacy_opengl(false)
|
||||
, m_use_VBOs(false)
|
||||
@ -212,6 +213,34 @@ bool GLCanvas3DManager::init(wxGLCanvas* canvas)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::set_current(wxGLCanvas* canvas, bool force)
|
||||
{
|
||||
// given canvas is already current, return
|
||||
if (m_current == canvas)
|
||||
return true;
|
||||
|
||||
if (canvas == nullptr)
|
||||
{
|
||||
m_current = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
// set given canvas as current
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
{
|
||||
bool res = it->second->set_current(force);
|
||||
if (res)
|
||||
{
|
||||
m_current = canvas;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
m_current = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_active(wxGLCanvas* canvas, bool active)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
@ -219,6 +248,13 @@ void GLCanvas3DManager::set_active(wxGLCanvas* canvas, bool active)
|
||||
it->second->set_active(active);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_as_dirty(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_as_dirty();
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3DManager::get_volumes_count(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
|
@ -45,6 +45,7 @@ class GLCanvas3DManager
|
||||
|
||||
wxGLContext* m_context;
|
||||
CanvasesMap m_canvases;
|
||||
wxGLCanvas* m_current;
|
||||
GLInfo m_gl_info;
|
||||
bool m_gl_initialized;
|
||||
bool m_use_legacy_opengl;
|
||||
@ -69,7 +70,9 @@ public:
|
||||
|
||||
bool init(wxGLCanvas* canvas);
|
||||
|
||||
bool set_current(wxGLCanvas* canvas, bool force);
|
||||
void set_active(wxGLCanvas* canvas, bool active);
|
||||
void set_as_dirty(wxGLCanvas* canvas);
|
||||
|
||||
unsigned int get_volumes_count(wxGLCanvas* canvas) const;
|
||||
void reset_volumes(wxGLCanvas* canvas);
|
||||
|
@ -56,6 +56,7 @@
|
||||
|
||||
#include "../Utils/PresetUpdater.hpp"
|
||||
#include "../Config/Snapshot.hpp"
|
||||
#include "3DScene.hpp"
|
||||
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
@ -378,6 +379,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
|
||||
save_language();
|
||||
show_info(g_wxTabPanel, _(L("Application will be restarted")), _(L("Attention!")));
|
||||
if (event_language_change > 0) {
|
||||
_3DScene::remove_all_canvases();// remove all canvas before recreate GUI
|
||||
wxCommandEvent event(event_language_change);
|
||||
g_wxApp->ProcessEvent(event);
|
||||
}
|
||||
|
@ -150,8 +150,15 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
// Build a label if we have it
|
||||
wxStaticText* label=nullptr;
|
||||
if (label_width != 0) {
|
||||
long label_style = staticbox ? 0 : wxALIGN_RIGHT;
|
||||
#ifdef __WXGTK__
|
||||
// workaround for correct text align of the StaticBox on Linux
|
||||
// flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given.
|
||||
// Text is properly aligned only when Ellipsize is checked.
|
||||
label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
|
||||
#endif /* __WXGTK__ */
|
||||
label = new wxStaticText(parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ":"),
|
||||
wxDefaultPosition, wxSize(label_width, -1), staticbox ? 0 : wxALIGN_RIGHT);
|
||||
wxDefaultPosition, wxSize(label_width, -1), label_style);
|
||||
label->SetFont(label_font);
|
||||
label->Wrap(label_width); // avoid a Linux/GTK bug
|
||||
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5);
|
||||
|
@ -2625,14 +2625,24 @@ void SavePresetWindow::accept()
|
||||
if (!m_chosen_name.empty()) {
|
||||
const char* unusable_symbols = "<>:/\\|?*\"";
|
||||
bool is_unusable_symbol = false;
|
||||
bool is_unusable_postfix = false;
|
||||
const std::string unusable_postfix = "(modified)";
|
||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++){
|
||||
if (m_chosen_name.find_first_of(unusable_symbols[i]) != std::string::npos){
|
||||
is_unusable_symbol = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_chosen_name.find(unusable_postfix) != std::string::npos)
|
||||
is_unusable_postfix = true;
|
||||
|
||||
if (is_unusable_symbol) {
|
||||
show_error(this, _(L("The supplied name is not valid; the following characters are not allowed:"))+" <>:/\\|?*\"");
|
||||
show_error(this,_(L("The supplied name is not valid;")) + "\n" +
|
||||
_(L("the following characters are not allowed:")) + " <>:/\\|?*\"");
|
||||
}
|
||||
else if (is_unusable_postfix){
|
||||
show_error(this, _(L("The supplied name is not valid;")) + "\n" +
|
||||
_(L("the following postfix are not allowed:")) + "\n\t" + unusable_postfix);
|
||||
}
|
||||
else if (m_chosen_name.compare("- default -") == 0) {
|
||||
show_error(this, _(L("The supplied name is not available.")));
|
||||
|
@ -29,6 +29,10 @@
|
||||
int x_max() %code{% RETVAL = THIS->max.x; %};
|
||||
int y_min() %code{% RETVAL = THIS->min.y; %};
|
||||
int y_max() %code{% RETVAL = THIS->max.y; %};
|
||||
void set_x_min(double val) %code{% THIS->min.x = val; %};
|
||||
void set_x_max(double val) %code{% THIS->max.x = val; %};
|
||||
void set_y_min(double val) %code{% THIS->min.y = val; %};
|
||||
void set_y_max(double val) %code{% THIS->max.y = val; %};
|
||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
||||
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||
|
||||
|
@ -190,6 +190,11 @@ remove_all_canvases()
|
||||
CODE:
|
||||
_3DScene::remove_all_canvases();
|
||||
|
||||
void
|
||||
reset_current_canvas()
|
||||
CODE:
|
||||
_3DScene::reset_current_canvas();
|
||||
|
||||
void
|
||||
set_active(canvas, active)
|
||||
SV *canvas;
|
||||
@ -197,6 +202,12 @@ set_active(canvas, active)
|
||||
CODE:
|
||||
_3DScene::set_active((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), active);
|
||||
|
||||
void
|
||||
set_as_dirty(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
_3DScene::set_as_dirty((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
|
||||
unsigned int
|
||||
get_volumes_count(canvas)
|
||||
SV *canvas;
|
||||
|
Loading…
Reference in New Issue
Block a user