mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Merge remote-tracking branch 'remotes/origin/vk-bugfixes'
This commit is contained in:
commit
241283d956
14 changed files with 530 additions and 131 deletions
|
@ -169,6 +169,11 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE
|
||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new")
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Where all the bundled libraries reside?
|
# Where all the bundled libraries reside?
|
||||||
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src)
|
set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
|
|
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
include(PrecompiledHeader)
|
include(PrecompiledHeader)
|
||||||
|
|
||||||
add_library(libslic3r_gui STATIC
|
set(SLIC3R_GUI_SOURCES
|
||||||
pchheader.cpp
|
pchheader.cpp
|
||||||
pchheader.hpp
|
pchheader.hpp
|
||||||
GUI/AboutDialog.cpp
|
GUI/AboutDialog.cpp
|
||||||
|
@ -127,6 +127,12 @@ add_library(libslic3r_gui STATIC
|
||||||
Utils/HexFile.hpp
|
Utils/HexFile.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND SLIC3R_GUI_SOURCES Utils/RetinaHelperImpl.mm)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(libslic3r_gui libslic3r avrdude imgui)
|
target_link_libraries(libslic3r_gui libslic3r avrdude imgui)
|
||||||
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
|
||||||
add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
|
add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
|
||||||
|
|
|
@ -59,6 +59,11 @@ void AppConfig::set_defaults()
|
||||||
if (get("use_legacy_opengl").empty())
|
if (get("use_legacy_opengl").empty())
|
||||||
set("use_legacy_opengl", "0");
|
set("use_legacy_opengl", "0");
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
if (get("use_retina_opengl").empty())
|
||||||
|
set("use_retina_opengl", "1");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (get("remember_output_path").empty())
|
if (get("remember_output_path").empty())
|
||||||
set("remember_output_path", "1");
|
set("remember_output_path", "1");
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "libslic3r/GCode/PreviewData.hpp"
|
#include "libslic3r/GCode/PreviewData.hpp"
|
||||||
#include "libslic3r/Geometry.hpp"
|
#include "libslic3r/Geometry.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
|
#include "libslic3r/Technologies.hpp"
|
||||||
#include "slic3r/GUI/3DScene.hpp"
|
#include "slic3r/GUI/3DScene.hpp"
|
||||||
#include "slic3r/GUI/BackgroundSlicingProcess.hpp"
|
#include "slic3r/GUI/BackgroundSlicingProcess.hpp"
|
||||||
#include "slic3r/GUI/GLShader.hpp"
|
#include "slic3r/GUI/GLShader.hpp"
|
||||||
|
@ -20,6 +21,10 @@
|
||||||
#include "GUI_ObjectManipulation.hpp"
|
#include "GUI_ObjectManipulation.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
|
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
#include "slic3r/Utils/RetinaHelper.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#include <wx/glcanvas.h>
|
#include <wx/glcanvas.h>
|
||||||
|
@ -45,6 +50,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
static const float TRACKBALLSIZE = 0.8f;
|
static const float TRACKBALLSIZE = 0.8f;
|
||||||
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
||||||
|
@ -59,8 +65,6 @@ static const float VIEW_BOTTOM[2] = { 0.0f, 180.0f };
|
||||||
static const float VIEW_FRONT[2] = { 0.0f, 90.0f };
|
static const float VIEW_FRONT[2] = { 0.0f, 90.0f };
|
||||||
static const float VIEW_REAR[2] = { 180.0f, 90.0f };
|
static const float VIEW_REAR[2] = { 180.0f, 90.0f };
|
||||||
|
|
||||||
static const float VARIABLE_LAYER_THICKNESS_BAR_WIDTH = 70.0f;
|
|
||||||
static const float VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT = 22.0f;
|
|
||||||
static const float GIZMO_RESET_BUTTON_HEIGHT = 22.0f;
|
static const float GIZMO_RESET_BUTTON_HEIGHT = 22.0f;
|
||||||
static const float GIZMO_RESET_BUTTON_WIDTH = 70.f;
|
static const float GIZMO_RESET_BUTTON_WIDTH = 70.f;
|
||||||
|
|
||||||
|
@ -191,9 +195,10 @@ Size::Size()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Size::Size(int width, int height)
|
Size::Size(int width, int height, float scale_factor)
|
||||||
: m_width(width)
|
: m_width(width)
|
||||||
, m_height(height)
|
, m_height(height)
|
||||||
|
, m_scale_factor(scale_factor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,6 +222,16 @@ void Size::set_height(int height)
|
||||||
m_height = height;
|
m_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Size::get_scale_factor() const
|
||||||
|
{
|
||||||
|
return m_scale_factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Size::set_scale_factor(int scale_factor)
|
||||||
|
{
|
||||||
|
m_scale_factor = scale_factor;
|
||||||
|
}
|
||||||
|
|
||||||
Rect::Rect()
|
Rect::Rect()
|
||||||
: m_left(0.0f)
|
: m_left(0.0f)
|
||||||
, m_top(0.0f)
|
, m_top(0.0f)
|
||||||
|
@ -330,6 +345,7 @@ void GLCanvas3D::Camera::set_scene_box(const BoundingBoxf3& box, GLCanvas3D& can
|
||||||
|
|
||||||
GLCanvas3D::Bed::Bed()
|
GLCanvas3D::Bed::Bed()
|
||||||
: m_type(Custom)
|
: m_type(Custom)
|
||||||
|
, m_scale_factor(1.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,8 +408,10 @@ Point GLCanvas3D::Bed::point_projection(const Point& point) const
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_PRINT_BED_MODELS
|
#if ENABLE_PRINT_BED_MODELS
|
||||||
void GLCanvas3D::Bed::render(float theta, bool useVBOs) const
|
void GLCanvas3D::Bed::render(float theta, bool useVBOs, float scale_factor) const
|
||||||
{
|
{
|
||||||
|
m_scale_factor = scale_factor;
|
||||||
|
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case MK2:
|
case MK2:
|
||||||
|
@ -420,8 +438,10 @@ void GLCanvas3D::Bed::render(float theta, bool useVBOs) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void GLCanvas3D::Bed::render(float theta) const
|
void GLCanvas3D::Bed::render(float theta, float scale_factor) const
|
||||||
{
|
{
|
||||||
|
m_scale_factor = scale_factor;
|
||||||
|
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case MK2:
|
case MK2:
|
||||||
|
@ -675,7 +695,7 @@ void GLCanvas3D::Bed::_render_custom() const
|
||||||
|
|
||||||
// we need depth test for grid, otherwise it would disappear when looking the object from below
|
// we need depth test for grid, otherwise it would disappear when looking the object from below
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
::glLineWidth(3.0f);
|
::glLineWidth(3.0f * m_scale_factor);
|
||||||
::glColor4f(0.2f, 0.2f, 0.2f, 0.4f);
|
::glColor4f(0.2f, 0.2f, 0.2f, 0.4f);
|
||||||
::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_gridlines.get_vertices());
|
::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_gridlines.get_vertices());
|
||||||
::glDrawArrays(GL_LINES, 0, (GLsizei)gridlines_vcount);
|
::glDrawArrays(GL_LINES, 0, (GLsizei)gridlines_vcount);
|
||||||
|
@ -873,6 +893,9 @@ GLCanvas3D::LayersEditing::~LayersEditing()
|
||||||
delete m_slicing_parameters;
|
delete m_slicing_parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float GLCanvas3D::LayersEditing::THICKNESS_BAR_WIDTH = 70.0f;
|
||||||
|
const float GLCanvas3D::LayersEditing::THICKNESS_RESET_BUTTON_HEIGHT = 22.0f;
|
||||||
|
|
||||||
bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
|
bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
|
||||||
{
|
{
|
||||||
if (!m_shader.init(vertex_shader_filename, fragment_shader_filename))
|
if (!m_shader.init(vertex_shader_filename, fragment_shader_filename))
|
||||||
|
@ -993,7 +1016,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
|
||||||
float w = (float)cnv_size.get_width();
|
float w = (float)cnv_size.get_width();
|
||||||
float h = (float)cnv_size.get_height();
|
float h = (float)cnv_size.get_height();
|
||||||
|
|
||||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, 0.0f, w, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT);
|
return Rect(w - thickness_bar_width(canvas), 0.0f, w, h - reset_button_height(canvas));
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::get_reset_rect_screen(const GLCanvas3D& canvas)
|
Rect GLCanvas3D::LayersEditing::get_reset_rect_screen(const GLCanvas3D& canvas)
|
||||||
|
@ -1002,7 +1025,7 @@ Rect GLCanvas3D::LayersEditing::get_reset_rect_screen(const GLCanvas3D& canvas)
|
||||||
float w = (float)cnv_size.get_width();
|
float w = (float)cnv_size.get_width();
|
||||||
float h = (float)cnv_size.get_height();
|
float h = (float)cnv_size.get_height();
|
||||||
|
|
||||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT, w, h);
|
return Rect(w - thickness_bar_width(canvas), h - reset_button_height(canvas), w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||||
|
@ -1014,7 +1037,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||||
float zoom = canvas.get_camera_zoom();
|
float zoom = canvas.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
|
||||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom);
|
return Rect((half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + reset_button_height(canvas)) * inv_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GLCanvas3D::LayersEditing::get_reset_rect_viewport(const GLCanvas3D& canvas)
|
Rect GLCanvas3D::LayersEditing::get_reset_rect_viewport(const GLCanvas3D& canvas)
|
||||||
|
@ -1026,7 +1049,7 @@ Rect GLCanvas3D::LayersEditing::get_reset_rect_viewport(const GLCanvas3D& canvas
|
||||||
float zoom = canvas.get_camera_zoom();
|
float zoom = canvas.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
|
||||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
return Rect((half_w - thickness_bar_width(canvas)) * inv_zoom, (-half_h + reset_button_height(canvas)) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1037,6 +1060,8 @@ bool GLCanvas3D::LayersEditing::_is_initialized() const
|
||||||
|
|
||||||
void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas, const Rect& bar_rect, const Rect& reset_rect) const
|
void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas, const Rect& bar_rect, const Rect& reset_rect) const
|
||||||
{
|
{
|
||||||
|
// TODO: do this with ImGui
|
||||||
|
|
||||||
if (m_tooltip_texture.get_id() == 0)
|
if (m_tooltip_texture.get_id() == 0)
|
||||||
{
|
{
|
||||||
std::string filename = resources_dir() + "/icons/variable_layer_height_tooltip.png";
|
std::string filename = resources_dir() + "/icons/variable_layer_height_tooltip.png";
|
||||||
|
@ -1044,6 +1069,15 @@ void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
const float scale = canvas.get_canvas_size().get_scale_factor();
|
||||||
|
const float width = (float)m_tooltip_texture.get_width() * scale;
|
||||||
|
const float height = (float)m_tooltip_texture.get_height() * scale;
|
||||||
|
#else
|
||||||
|
const float width = (float)m_tooltip_texture.get_width();
|
||||||
|
const float height = (float)m_tooltip_texture.get_height();
|
||||||
|
#endif
|
||||||
|
|
||||||
float zoom = canvas.get_camera_zoom();
|
float zoom = canvas.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
float gap = 10.0f * inv_zoom;
|
float gap = 10.0f * inv_zoom;
|
||||||
|
@ -1051,9 +1085,9 @@ void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas
|
||||||
float bar_left = bar_rect.get_left();
|
float bar_left = bar_rect.get_left();
|
||||||
float reset_bottom = reset_rect.get_bottom();
|
float reset_bottom = reset_rect.get_bottom();
|
||||||
|
|
||||||
float l = bar_left - (float)m_tooltip_texture.get_width() * inv_zoom - gap;
|
float l = bar_left - width * inv_zoom - gap;
|
||||||
float r = bar_left - gap;
|
float r = bar_left - gap;
|
||||||
float t = reset_bottom + (float)m_tooltip_texture.get_height() * inv_zoom + gap;
|
float t = reset_bottom + height * inv_zoom + gap;
|
||||||
float b = reset_bottom + gap;
|
float b = reset_bottom + gap;
|
||||||
|
|
||||||
GLTexture::render_texture(m_tooltip_texture.get_id(), l, r, b, t);
|
GLTexture::render_texture(m_tooltip_texture.get_id(), l, r, b, t);
|
||||||
|
@ -1082,11 +1116,6 @@ void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas
|
||||||
// The shader requires the original model coordinates when rendering to the texture, so we pass it the unit matrix
|
// The shader requires the original model coordinates when rendering to the texture, so we pass it the unit matrix
|
||||||
m_shader.set_uniform("volume_world_matrix", UNIT_MATRIX);
|
m_shader.set_uniform("volume_world_matrix", UNIT_MATRIX);
|
||||||
|
|
||||||
GLsizei w = (GLsizei)m_layers_texture.width;
|
|
||||||
GLsizei h = (GLsizei)m_layers_texture.height;
|
|
||||||
GLsizei half_w = w / 2;
|
|
||||||
GLsizei half_h = h / 2;
|
|
||||||
|
|
||||||
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
::glBindTexture(GL_TEXTURE_2D, m_z_texture_id);
|
::glBindTexture(GL_TEXTURE_2D, m_z_texture_id);
|
||||||
|
|
||||||
|
@ -1267,6 +1296,25 @@ void GLCanvas3D::LayersEditing::update_slicing_parameters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GLCanvas3D::LayersEditing::thickness_bar_width(const GLCanvas3D &canvas)
|
||||||
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
return canvas.get_canvas_size().get_scale_factor() * THICKNESS_BAR_WIDTH;
|
||||||
|
#else
|
||||||
|
return THICKNESS_BAR_WIDTH;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
float GLCanvas3D::LayersEditing::reset_button_height(const GLCanvas3D &canvas)
|
||||||
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
return canvas.get_canvas_size().get_scale_factor() * THICKNESS_RESET_BUTTON_HEIGHT;
|
||||||
|
#else
|
||||||
|
return THICKNESS_RESET_BUTTON_HEIGHT;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Point GLCanvas3D::Mouse::Drag::Invalid_2D_Point(INT_MAX, INT_MAX);
|
const Point GLCanvas3D::Mouse::Drag::Invalid_2D_Point(INT_MAX, INT_MAX);
|
||||||
const Vec3d GLCanvas3D::Mouse::Drag::Invalid_3D_Point(DBL_MAX, DBL_MAX, DBL_MAX);
|
const Vec3d GLCanvas3D::Mouse::Drag::Invalid_3D_Point(DBL_MAX, DBL_MAX, DBL_MAX);
|
||||||
#if ENABLE_MOVE_MIN_THRESHOLD
|
#if ENABLE_MOVE_MIN_THRESHOLD
|
||||||
|
@ -1329,6 +1377,7 @@ GLCanvas3D::Selection::Selection()
|
||||||
, m_valid(false)
|
, m_valid(false)
|
||||||
, m_bounding_box_dirty(true)
|
, m_bounding_box_dirty(true)
|
||||||
, m_curved_arrow(16)
|
, m_curved_arrow(16)
|
||||||
|
, m_scale_factor(1.0f)
|
||||||
{
|
{
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
m_quadric = ::gluNewQuadric();
|
m_quadric = ::gluNewQuadric();
|
||||||
|
@ -2115,11 +2164,13 @@ void GLCanvas3D::Selection::erase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Selection::render() const
|
void GLCanvas3D::Selection::render(float scale_factor) const
|
||||||
{
|
{
|
||||||
if (!m_valid || is_empty())
|
if (!m_valid || is_empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_scale_factor = scale_factor;
|
||||||
|
|
||||||
// render cumulative bounding box of selected volumes
|
// render cumulative bounding box of selected volumes
|
||||||
_render_selected_volumes();
|
_render_selected_volumes();
|
||||||
_render_synchronized_volumes();
|
_render_synchronized_volumes();
|
||||||
|
@ -2564,7 +2615,7 @@ void GLCanvas3D::Selection::_render_bounding_box(const BoundingBoxf3& box, float
|
||||||
::glEnable(GL_DEPTH_TEST);
|
::glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
::glColor3fv(color);
|
::glColor3fv(color);
|
||||||
::glLineWidth(2.0f);
|
::glLineWidth(2.0f * m_scale_factor);
|
||||||
|
|
||||||
::glBegin(GL_LINES);
|
::glBegin(GL_LINES);
|
||||||
|
|
||||||
|
@ -2815,14 +2866,11 @@ void GLCanvas3D::Selection::_ensure_on_bed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const float GLCanvas3D::Gizmos::OverlayIconsScale = 1.0f;
|
|
||||||
const float GLCanvas3D::Gizmos::OverlayBorder = 5.0f;
|
|
||||||
const float GLCanvas3D::Gizmos::OverlayGapY = 5.0f * OverlayIconsScale;
|
|
||||||
|
|
||||||
GLCanvas3D::Gizmos::Gizmos()
|
GLCanvas3D::Gizmos::Gizmos()
|
||||||
: m_enabled(false)
|
: m_enabled(false)
|
||||||
, m_current(Undefined)
|
, m_current(Undefined)
|
||||||
{
|
{
|
||||||
|
set_overlay_scale(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::Gizmos::~Gizmos()
|
GLCanvas3D::Gizmos::~Gizmos()
|
||||||
|
@ -2926,6 +2974,13 @@ void GLCanvas3D::Gizmos::set_enabled(bool enable)
|
||||||
m_enabled = enable;
|
m_enabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::Gizmos::set_overlay_scale(float scale)
|
||||||
|
{
|
||||||
|
m_overlay_icons_scale = scale;
|
||||||
|
m_overlay_border = 5.0f * scale;
|
||||||
|
m_overlay_gap_y = 5.0f * scale;
|
||||||
|
}
|
||||||
|
|
||||||
std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const GLCanvas3D::Selection& selection)
|
std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const GLCanvas3D::Selection& selection)
|
||||||
{
|
{
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
@ -2935,22 +2990,22 @@ std::string GLCanvas3D::Gizmos::update_hover_state(const GLCanvas3D& canvas, con
|
||||||
|
|
||||||
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
||||||
float height = _get_total_overlay_height();
|
float height = _get_total_overlay_height();
|
||||||
float top_y = 0.5f * (cnv_h - height) + OverlayBorder;
|
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
|
||||||
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float icon_size = (float)it->second->get_textures_size() * OverlayIconsScale;
|
float icon_size = (float)it->second->get_textures_size() * m_overlay_icons_scale;
|
||||||
|
|
||||||
bool inside = (OverlayBorder <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= OverlayBorder + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
|
bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
|
||||||
if (inside)
|
if (inside)
|
||||||
name = it->second->get_name();
|
name = it->second->get_name();
|
||||||
|
|
||||||
if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On))
|
if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On))
|
||||||
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
|
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
|
||||||
|
|
||||||
top_y += (icon_size + OverlayGapY);
|
top_y += (icon_size + m_overlay_gap_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -2963,15 +3018,15 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec
|
||||||
|
|
||||||
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
||||||
float height = _get_total_overlay_height();
|
float height = _get_total_overlay_height();
|
||||||
float top_y = 0.5f * (cnv_h - height) + OverlayBorder;
|
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
|
||||||
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float icon_size = (float)it->second->get_textures_size() * OverlayIconsScale;
|
float icon_size = (float)it->second->get_textures_size() * m_overlay_icons_scale;
|
||||||
|
|
||||||
bool inside = (OverlayBorder <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= OverlayBorder + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
|
bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size);
|
||||||
if (it->second->is_activable(selection) && inside)
|
if (it->second->is_activable(selection) && inside)
|
||||||
{
|
{
|
||||||
if ((it->second->get_state() == GLGizmoBase::On))
|
if ((it->second->get_state() == GLGizmoBase::On))
|
||||||
|
@ -2988,7 +3043,7 @@ void GLCanvas3D::Gizmos::update_on_off_state(const GLCanvas3D& canvas, const Vec
|
||||||
else
|
else
|
||||||
it->second->set_state(GLGizmoBase::Off);
|
it->second->set_state(GLGizmoBase::Off);
|
||||||
|
|
||||||
top_y += (icon_size + OverlayGapY);
|
top_y += (icon_size + m_overlay_gap_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
GizmosMap::iterator it = m_gizmos.find(m_current);
|
GizmosMap::iterator it = m_gizmos.find(m_current);
|
||||||
|
@ -3060,18 +3115,18 @@ bool GLCanvas3D::Gizmos::overlay_contains_mouse(const GLCanvas3D& canvas, const
|
||||||
|
|
||||||
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
float cnv_h = (float)canvas.get_canvas_size().get_height();
|
||||||
float height = _get_total_overlay_height();
|
float height = _get_total_overlay_height();
|
||||||
float top_y = 0.5f * (cnv_h - height) + OverlayBorder;
|
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
|
||||||
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float icon_size = (float)it->second->get_textures_size() * OverlayIconsScale;
|
float icon_size = (float)it->second->get_textures_size() * m_overlay_icons_scale;
|
||||||
|
|
||||||
if ((OverlayBorder <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= OverlayBorder + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size))
|
if ((m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + icon_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + icon_size))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
top_y += (icon_size + OverlayGapY);
|
top_y += (icon_size + m_overlay_gap_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -3344,7 +3399,7 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
|
||||||
float height = _get_total_overlay_height();
|
float height = _get_total_overlay_height();
|
||||||
float scaled_border = OverlayBorder * inv_zoom;
|
float scaled_border = m_overlay_border * inv_zoom;
|
||||||
|
|
||||||
float top_x = (-0.5f * cnv_w) * inv_zoom;
|
float top_x = (-0.5f * cnv_w) * inv_zoom;
|
||||||
float top_y = (0.5f * height) * inv_zoom;
|
float top_y = (0.5f * height) * inv_zoom;
|
||||||
|
@ -3389,7 +3444,7 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva
|
||||||
bg_uv_left = bg_uv_i_left;
|
bg_uv_left = bg_uv_i_left;
|
||||||
bg_i_left = bg_left;
|
bg_i_left = bg_left;
|
||||||
|
|
||||||
if ((OverlayBorder > 0) && (bg_uv_top != bg_uv_i_top))
|
if ((m_overlay_border > 0) && (bg_uv_top != bg_uv_i_top))
|
||||||
{
|
{
|
||||||
if (bg_uv_left != bg_uv_i_left)
|
if (bg_uv_left != bg_uv_i_left)
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_top, bg_top, { { bg_uv_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_top }, { bg_uv_left, bg_uv_top } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_top, bg_top, { { bg_uv_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_top }, { bg_uv_left, bg_uv_top } });
|
||||||
|
@ -3400,15 +3455,15 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_top, bg_top, { { bg_uv_i_right, bg_uv_i_top }, { bg_uv_right, bg_uv_i_top }, { bg_uv_right, bg_uv_top }, { bg_uv_i_right, bg_uv_top } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_top, bg_top, { { bg_uv_i_right, bg_uv_i_top }, { bg_uv_right, bg_uv_i_top }, { bg_uv_right, bg_uv_top }, { bg_uv_i_right, bg_uv_top } });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((OverlayBorder > 0) && (bg_uv_left != bg_uv_i_left))
|
if ((m_overlay_border > 0) && (bg_uv_left != bg_uv_i_left))
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_bottom, bg_i_top, { { bg_uv_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_left, bg_uv_i_top } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_bottom, bg_i_top, { { bg_uv_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_left, bg_uv_i_top } });
|
||||||
|
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_bottom, bg_i_top, { { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_bottom, bg_i_top, { { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top } });
|
||||||
|
|
||||||
if ((OverlayBorder > 0) && (bg_uv_right != bg_uv_i_right))
|
if ((m_overlay_border > 0) && (bg_uv_right != bg_uv_i_right))
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_bottom, bg_i_top, { { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_bottom, bg_i_top, { { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top } });
|
||||||
|
|
||||||
if ((OverlayBorder > 0) && (bg_uv_bottom != bg_uv_i_bottom))
|
if ((m_overlay_border > 0) && (bg_uv_bottom != bg_uv_i_bottom))
|
||||||
{
|
{
|
||||||
if (bg_uv_left != bg_uv_i_left)
|
if (bg_uv_left != bg_uv_i_left)
|
||||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_bottom, bg_i_bottom, { { bg_uv_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_left, bg_uv_i_bottom } });
|
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_bottom, bg_i_bottom, { { bg_uv_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_left, bg_uv_i_bottom } });
|
||||||
|
@ -3420,19 +3475,19 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
top_x += OverlayBorder * inv_zoom;
|
top_x += m_overlay_border * inv_zoom;
|
||||||
top_y -= OverlayBorder * inv_zoom;
|
top_y -= m_overlay_border * inv_zoom;
|
||||||
float scaled_gap_y = OverlayGapY * inv_zoom;
|
float scaled_gap_y = m_overlay_gap_y * inv_zoom;
|
||||||
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float icon_size = (float)it->second->get_textures_size() * OverlayIconsScale * inv_zoom;
|
float icon_size = (float)it->second->get_textures_size() * m_overlay_icons_scale * inv_zoom;
|
||||||
GLTexture::render_texture(it->second->get_texture_id(), top_x, top_x + icon_size, top_y - icon_size, top_y);
|
GLTexture::render_texture(it->second->get_texture_id(), top_x, top_x + icon_size, top_y - icon_size, top_y);
|
||||||
#if ENABLE_IMGUI
|
#if ENABLE_IMGUI
|
||||||
if (it->second->get_state() == GLGizmoBase::On)
|
if (it->second->get_state() == GLGizmoBase::On)
|
||||||
it->second->render_input_window(2.0f * OverlayBorder + icon_size * zoom, 0.5f * cnv_h - top_y * zoom, selection);
|
it->second->render_input_window(2.0f * m_overlay_border + icon_size * zoom, 0.5f * cnv_h - top_y * zoom, selection);
|
||||||
#endif // ENABLE_IMGUI
|
#endif // ENABLE_IMGUI
|
||||||
top_y -= (icon_size + scaled_gap_y);
|
top_y -= (icon_size + scaled_gap_y);
|
||||||
}
|
}
|
||||||
|
@ -3447,17 +3502,17 @@ void GLCanvas3D::Gizmos::_render_current_gizmo(const GLCanvas3D::Selection& sele
|
||||||
|
|
||||||
float GLCanvas3D::Gizmos::_get_total_overlay_height() const
|
float GLCanvas3D::Gizmos::_get_total_overlay_height() const
|
||||||
{
|
{
|
||||||
float height = 2.0f * OverlayBorder;
|
float height = 2.0f * m_overlay_border;
|
||||||
|
|
||||||
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
height += (float)it->second->get_textures_size() * OverlayIconsScale + OverlayGapY;
|
height += (float)it->second->get_textures_size() * m_overlay_icons_scale + m_overlay_gap_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return height - OverlayGapY;
|
return height - m_overlay_gap_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLCanvas3D::Gizmos::_get_total_overlay_width() const
|
float GLCanvas3D::Gizmos::_get_total_overlay_width() const
|
||||||
|
@ -3468,10 +3523,10 @@ float GLCanvas3D::Gizmos::_get_total_overlay_width() const
|
||||||
if ((it->second == nullptr) || !it->second->is_selectable())
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
max_icon_width = std::max(max_icon_width, (float)it->second->get_textures_size() * OverlayIconsScale);
|
max_icon_width = std::max(max_icon_width, (float)it->second->get_textures_size() * m_overlay_icons_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return max_icon_width + 2.0f * OverlayBorder;
|
return max_icon_width + 2.0f * m_overlay_border;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
|
GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const
|
||||||
|
@ -3490,7 +3545,7 @@ GLCanvas3D::WarningTexture::WarningTexture()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
bool GLCanvas3D::WarningTexture::generate(const std::string& msg, const GLCanvas3D& canvas)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
@ -3499,7 +3554,8 @@ bool GLCanvas3D::WarningTexture::generate(const std::string& msg)
|
||||||
|
|
||||||
wxMemoryDC memDC;
|
wxMemoryDC memDC;
|
||||||
// select default font
|
// select default font
|
||||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
const float scale = canvas.get_canvas_size().get_scale_factor();
|
||||||
|
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale);
|
||||||
font.MakeLarger();
|
font.MakeLarger();
|
||||||
font.MakeBold();
|
font.MakeBold();
|
||||||
memDC.SetFont(font);
|
memDC.SetFont(font);
|
||||||
|
@ -3647,9 +3703,18 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
wxMemoryDC memDC;
|
wxMemoryDC memDC;
|
||||||
wxMemoryDC mask_memDC;
|
wxMemoryDC mask_memDC;
|
||||||
|
|
||||||
|
// calculate scaling
|
||||||
|
const float scale = canvas.get_canvas_size().get_scale_factor();
|
||||||
|
const int scaled_square = std::floor((float)Px_Square * scale);
|
||||||
|
const int scaled_title_offset = Px_Title_Offset * scale;
|
||||||
|
const int scaled_text_offset = Px_Text_Offset * scale;
|
||||||
|
const int scaled_square_contour = Px_Square_Contour * scale;
|
||||||
|
const int scaled_border = Px_Border * scale;
|
||||||
|
|
||||||
// select default font
|
// select default font
|
||||||
memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
const wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale);
|
||||||
mask_memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
memDC.SetFont(font);
|
||||||
|
mask_memDC.SetFont(font);
|
||||||
|
|
||||||
// calculates texture size
|
// calculates texture size
|
||||||
wxCoord w, h;
|
wxCoord w, h;
|
||||||
|
@ -3666,10 +3731,10 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
max_text_height = std::max(max_text_height, (int)h);
|
max_text_height = std::max(max_text_height, (int)h);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_original_width = std::max(2 * Px_Border + title_width, 2 * (Px_Border + Px_Square_Contour) + Px_Square + Px_Text_Offset + max_text_width);
|
m_original_width = std::max(2 * scaled_border + title_width, 2 * (scaled_border + scaled_square_contour) + scaled_square + scaled_text_offset + max_text_width);
|
||||||
m_original_height = 2 * (Px_Border + Px_Square_Contour) + title_height + Px_Title_Offset + items_count * Px_Square;
|
m_original_height = 2 * (scaled_border + scaled_square_contour) + title_height + scaled_title_offset + items_count * scaled_square;
|
||||||
if (items_count > 1)
|
if (items_count > 1)
|
||||||
m_original_height += (items_count - 1) * Px_Square_Contour;
|
m_original_height += (items_count - 1) * scaled_square_contour;
|
||||||
|
|
||||||
int pow_of_two_size = (int)next_highest_power_of_2(std::max<uint32_t>(m_original_width, m_original_height));
|
int pow_of_two_size = (int)next_highest_power_of_2(std::max<uint32_t>(m_original_width, m_original_height));
|
||||||
|
|
||||||
|
@ -3693,8 +3758,8 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
memDC.SetTextForeground(use_error_colors ? *wxWHITE : *wxBLACK);
|
memDC.SetTextForeground(use_error_colors ? *wxWHITE : *wxBLACK);
|
||||||
mask_memDC.SetTextForeground(*wxWHITE);
|
mask_memDC.SetTextForeground(*wxWHITE);
|
||||||
|
|
||||||
int title_x = Px_Border;
|
int title_x = scaled_border;
|
||||||
int title_y = Px_Border;
|
int title_y = scaled_border;
|
||||||
memDC.DrawText(title, title_x, title_y);
|
memDC.DrawText(title, title_x, title_y);
|
||||||
mask_memDC.DrawText(title, title_x, title_y);
|
mask_memDC.DrawText(title, title_x, title_y);
|
||||||
|
|
||||||
|
@ -3702,12 +3767,12 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
mask_memDC.SetBrush(wxBrush(*wxWHITE));
|
mask_memDC.SetBrush(wxBrush(*wxWHITE));
|
||||||
|
|
||||||
// draw icons contours as background
|
// draw icons contours as background
|
||||||
int squares_contour_x = Px_Border;
|
int squares_contour_x = scaled_border;
|
||||||
int squares_contour_y = Px_Border + title_height + Px_Title_Offset;
|
int squares_contour_y = scaled_border + title_height + scaled_title_offset;
|
||||||
int squares_contour_width = Px_Square + 2 * Px_Square_Contour;
|
int squares_contour_width = scaled_square + 2 * scaled_square_contour;
|
||||||
int squares_contour_height = items_count * Px_Square + 2 * Px_Square_Contour;
|
int squares_contour_height = items_count * scaled_square + 2 * scaled_square_contour;
|
||||||
if (items_count > 1)
|
if (items_count > 1)
|
||||||
squares_contour_height += (items_count - 1) * Px_Square_Contour;
|
squares_contour_height += (items_count - 1) * scaled_square_contour;
|
||||||
|
|
||||||
wxColour color(Squares_Border_Color[0], Squares_Border_Color[1], Squares_Border_Color[2]);
|
wxColour color(Squares_Border_Color[0], Squares_Border_Color[1], Squares_Border_Color[2]);
|
||||||
wxPen pen(color);
|
wxPen pen(color);
|
||||||
|
@ -3718,15 +3783,15 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
mask_memDC.DrawRectangle(wxRect(squares_contour_x, squares_contour_y, squares_contour_width, squares_contour_height));
|
mask_memDC.DrawRectangle(wxRect(squares_contour_x, squares_contour_y, squares_contour_width, squares_contour_height));
|
||||||
|
|
||||||
// draw items (colored icon + text)
|
// draw items (colored icon + text)
|
||||||
int icon_x = squares_contour_x + Px_Square_Contour;
|
int icon_x = squares_contour_x + scaled_square_contour;
|
||||||
int icon_x_inner = icon_x + 1;
|
int icon_x_inner = icon_x + 1;
|
||||||
int icon_y = squares_contour_y + Px_Square_Contour;
|
int icon_y = squares_contour_y + scaled_square_contour;
|
||||||
int icon_y_step = Px_Square + Px_Square_Contour;
|
int icon_y_step = scaled_square + scaled_square_contour;
|
||||||
|
|
||||||
int text_x = icon_x + Px_Square + Px_Text_Offset;
|
int text_x = icon_x + scaled_square + scaled_text_offset;
|
||||||
int text_y_offset = (Px_Square - max_text_height) / 2;
|
int text_y_offset = (scaled_square - max_text_height) / 2;
|
||||||
|
|
||||||
int px_inner_square = Px_Square - 2;
|
int px_inner_square = scaled_square - 2;
|
||||||
|
|
||||||
for (const GCodePreviewData::LegendItem& item : items)
|
for (const GCodePreviewData::LegendItem& item : items)
|
||||||
{
|
{
|
||||||
|
@ -3740,7 +3805,7 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||||
brush.SetColour(color);
|
brush.SetColour(color);
|
||||||
memDC.SetPen(pen);
|
memDC.SetPen(pen);
|
||||||
memDC.SetBrush(brush);
|
memDC.SetBrush(brush);
|
||||||
memDC.DrawRectangle(wxRect(icon_x, icon_y, Px_Square, Px_Square));
|
memDC.DrawRectangle(wxRect(icon_x, icon_y, scaled_square, scaled_square));
|
||||||
|
|
||||||
// draw icon interior
|
// draw icon interior
|
||||||
color.Set(item_color_bytes[0], item_color_bytes[1], item_color_bytes[2], item_color_bytes[3]);
|
color.Set(item_color_bytes[0], item_color_bytes[1], item_color_bytes[2], item_color_bytes[3]);
|
||||||
|
@ -3849,6 +3914,9 @@ wxDEFINE_EVENT(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED, SimpleEvent);
|
||||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
: m_canvas(canvas)
|
: m_canvas(canvas)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
, m_retina_helper(nullptr)
|
||||||
|
#endif
|
||||||
, m_in_render(false)
|
, m_in_render(false)
|
||||||
, m_toolbar(GLToolbar::Normal)
|
, m_toolbar(GLToolbar::Normal)
|
||||||
, m_view_toolbar(nullptr)
|
, m_view_toolbar(nullptr)
|
||||||
|
@ -3882,8 +3950,12 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
|
||||||
, m_external_gizmo_widgets_parent(nullptr)
|
, m_external_gizmo_widgets_parent(nullptr)
|
||||||
#endif // not ENABLE_IMGUI
|
#endif // not ENABLE_IMGUI
|
||||||
{
|
{
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr) {
|
||||||
m_timer.SetOwner(m_canvas);
|
m_timer.SetOwner(m_canvas);
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_retina_helper.reset(new RetinaHelper(canvas));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
m_selection.set_volumes(&m_volumes.volumes);
|
m_selection.set_volumes(&m_volumes.volumes);
|
||||||
}
|
}
|
||||||
|
@ -5010,6 +5082,12 @@ void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
||||||
|
|
||||||
void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
const float scale = m_retina_helper->get_scale_factor();
|
||||||
|
evt.SetX(evt.GetX() * scale);
|
||||||
|
evt.SetY(evt.GetY() * scale);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLE_IMGUI
|
#if ENABLE_IMGUI
|
||||||
auto imgui = wxGetApp().imgui();
|
auto imgui = wxGetApp().imgui();
|
||||||
if (imgui->update_mouse_data(evt)) {
|
if (imgui->update_mouse_data(evt)) {
|
||||||
|
@ -5232,7 +5310,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||||
// forces a frame render to update the view before the context menu is shown
|
// forces a frame render to update the view before the context menu is shown
|
||||||
render();
|
render();
|
||||||
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, pos.cast<double>()));
|
|
||||||
|
Vec2d logical_pos = pos.cast<double>();
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
const float factor = m_retina_helper->get_scale_factor();
|
||||||
|
logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor));
|
||||||
|
#endif
|
||||||
|
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5498,7 +5582,15 @@ Size GLCanvas3D::get_canvas_size() const
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
m_canvas->GetSize(&w, &h);
|
m_canvas->GetSize(&w, &h);
|
||||||
|
|
||||||
return Size(w, h);
|
#if ENABLE_RETINA_GL
|
||||||
|
const float factor = m_retina_helper->get_scale_factor();
|
||||||
|
w *= factor;
|
||||||
|
h *= factor;
|
||||||
|
#else
|
||||||
|
const float factor = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return Size(w, h, factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point GLCanvas3D::get_local_mouse_position() const
|
Point GLCanvas3D::get_local_mouse_position() const
|
||||||
|
@ -5805,6 +5897,26 @@ void GLCanvas3D::handle_sidebar_focus_event(const std::string& opt_key, bool foc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas3D::update_ui_from_settings()
|
||||||
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
const float orig_scaling = m_retina_helper->get_scale_factor();
|
||||||
|
|
||||||
|
const bool use_retina = wxGetApp().app_config->get("use_retina_opengl") == "1";
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Use Retina OpenGL: " << use_retina;
|
||||||
|
m_retina_helper->set_use_retina(use_retina);
|
||||||
|
const float new_scaling = m_retina_helper->get_scale_factor();
|
||||||
|
|
||||||
|
if (new_scaling != orig_scaling) {
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "GLCanvas3D: Scaling factor: " << new_scaling;
|
||||||
|
|
||||||
|
m_camera.zoom /= orig_scaling;
|
||||||
|
m_camera.zoom *= new_scaling;
|
||||||
|
_refresh_if_shown_on_screen();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool GLCanvas3D::_is_shown_on_screen() const
|
bool GLCanvas3D::_is_shown_on_screen() const
|
||||||
{
|
{
|
||||||
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
|
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
|
||||||
|
@ -5958,6 +6070,9 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
|
|
||||||
#if ENABLE_IMGUI
|
#if ENABLE_IMGUI
|
||||||
wxGetApp().imgui()->set_display_size((float)w, (float)h);
|
wxGetApp().imgui()->set_display_size((float)w, (float)h);
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
wxGetApp().imgui()->set_style_scaling(m_retina_helper->get_scale_factor());
|
||||||
|
#endif // ENABLE_RETINA_GL
|
||||||
#endif // ENABLE_IMGUI
|
#endif // ENABLE_IMGUI
|
||||||
|
|
||||||
// ensures that this canvas is current
|
// ensures that this canvas is current
|
||||||
|
@ -6238,10 +6353,15 @@ void GLCanvas3D::_render_background() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_bed(float theta) const
|
void GLCanvas3D::_render_bed(float theta) const
|
||||||
{
|
{
|
||||||
|
float scale_factor = 1.0;
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
scale_factor = m_retina_helper->get_scale_factor();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLE_PRINT_BED_MODELS
|
#if ENABLE_PRINT_BED_MODELS
|
||||||
m_bed.render(theta, m_use_VBOs);
|
m_bed.render(theta, m_use_VBOs, scale_factor);
|
||||||
#else
|
#else
|
||||||
m_bed.render(theta);
|
m_bed.render(theta, scale_factor);
|
||||||
#endif // ENABLE_PRINT_BED_MODELS
|
#endif // ENABLE_PRINT_BED_MODELS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6320,8 +6440,13 @@ void GLCanvas3D::_render_objects() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_selection() const
|
void GLCanvas3D::_render_selection() const
|
||||||
{
|
{
|
||||||
|
float scale_factor = 1.0;
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
scale_factor = m_retina_helper->get_scale_factor();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!m_gizmos.is_running())
|
if (!m_gizmos.is_running())
|
||||||
m_selection.render();
|
m_selection.render(scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
|
@ -6404,19 +6529,29 @@ void GLCanvas3D::_render_current_gizmo() const
|
||||||
|
|
||||||
void GLCanvas3D::_render_gizmos_overlay() const
|
void GLCanvas3D::_render_gizmos_overlay() const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
|
||||||
|
#endif
|
||||||
m_gizmos.render_overlay(*this, m_selection);
|
m_gizmos.render_overlay(*this, m_selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_toolbar() const
|
void GLCanvas3D::_render_toolbar() const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
|
#endif
|
||||||
m_toolbar.render(*this);
|
m_toolbar.render(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_view_toolbar() const
|
void GLCanvas3D::_render_view_toolbar() const
|
||||||
{
|
{
|
||||||
if (m_view_toolbar != nullptr)
|
if (m_view_toolbar != nullptr) {
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
|
#endif
|
||||||
m_view_toolbar->render(*this);
|
m_view_toolbar->render(*this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_SHOW_CAMERA_TARGET
|
#if ENABLE_SHOW_CAMERA_TARGET
|
||||||
void GLCanvas3D::_render_camera_target() const
|
void GLCanvas3D::_render_camera_target() const
|
||||||
|
@ -8116,7 +8251,7 @@ void GLCanvas3D::_generate_legend_texture(const GCodePreviewData& preview_data,
|
||||||
|
|
||||||
void GLCanvas3D::_generate_warning_texture(const std::string& msg)
|
void GLCanvas3D::_generate_warning_texture(const std::string& msg)
|
||||||
{
|
{
|
||||||
m_warning_texture.generate(msg);
|
m_warning_texture.generate(msg, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_reset_warning_texture()
|
void GLCanvas3D::_reset_warning_texture()
|
||||||
|
@ -8141,6 +8276,10 @@ void GLCanvas3D::_resize_toolbars() const
|
||||||
float zoom = get_camera_zoom();
|
float zoom = get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
|
#endif
|
||||||
|
|
||||||
GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation();
|
GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation();
|
||||||
|
|
||||||
switch (m_toolbar.get_layout_type())
|
switch (m_toolbar.get_layout_type())
|
||||||
|
@ -8184,6 +8323,10 @@ void GLCanvas3D::_resize_toolbars() const
|
||||||
|
|
||||||
if (m_view_toolbar != nullptr)
|
if (m_view_toolbar != nullptr)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
m_view_toolbar->set_icons_scale(m_retina_helper->get_scale_factor());
|
||||||
|
#endif
|
||||||
|
|
||||||
// places the toolbar on the bottom-left corner of the 3d scene
|
// places the toolbar on the bottom-left corner of the 3d scene
|
||||||
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom;
|
||||||
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#define slic3r_GLCanvas3D_hpp_
|
#define slic3r_GLCanvas3D_hpp_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "libslic3r/Technologies.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
#include "GLToolbar.hpp"
|
#include "GLToolbar.hpp"
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
|
@ -20,6 +22,9 @@ class wxTimerEvent;
|
||||||
class wxPaintEvent;
|
class wxPaintEvent;
|
||||||
class wxGLCanvas;
|
class wxGLCanvas;
|
||||||
|
|
||||||
|
// Support for Retina OpenGL on Mac OS
|
||||||
|
#define ENABLE_RETINA_GL __APPLE__
|
||||||
|
|
||||||
class GLUquadric;
|
class GLUquadric;
|
||||||
typedef class GLUquadric GLUquadricObj;
|
typedef class GLUquadric GLUquadricObj;
|
||||||
|
|
||||||
|
@ -36,6 +41,10 @@ namespace GUI {
|
||||||
|
|
||||||
class GLGizmoBase;
|
class GLGizmoBase;
|
||||||
|
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
class RetinaHelper;
|
||||||
|
#endif
|
||||||
|
|
||||||
class GeometryBuffer
|
class GeometryBuffer
|
||||||
{
|
{
|
||||||
std::vector<float> m_vertices;
|
std::vector<float> m_vertices;
|
||||||
|
@ -55,16 +64,20 @@ class Size
|
||||||
{
|
{
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
float m_scale_factor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Size();
|
Size();
|
||||||
Size(int width, int height);
|
Size(int width, int height, float scale_factor = 1.0);
|
||||||
|
|
||||||
int get_width() const;
|
int get_width() const;
|
||||||
void set_width(int width);
|
void set_width(int width);
|
||||||
|
|
||||||
int get_height() const;
|
int get_height() const;
|
||||||
void set_height(int height);
|
void set_height(int height);
|
||||||
|
|
||||||
|
int get_scale_factor() const;
|
||||||
|
void set_scale_factor(int height);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Rect
|
class Rect
|
||||||
|
@ -209,6 +222,8 @@ class GLCanvas3D
|
||||||
mutable GLBed m_model;
|
mutable GLBed m_model;
|
||||||
#endif // ENABLE_PRINT_BED_MODELS
|
#endif // ENABLE_PRINT_BED_MODELS
|
||||||
|
|
||||||
|
mutable float m_scale_factor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Bed();
|
Bed();
|
||||||
|
|
||||||
|
@ -224,9 +239,9 @@ class GLCanvas3D
|
||||||
Point point_projection(const Point& point) const;
|
Point point_projection(const Point& point) const;
|
||||||
|
|
||||||
#if ENABLE_PRINT_BED_MODELS
|
#if ENABLE_PRINT_BED_MODELS
|
||||||
void render(float theta, bool useVBOs) const;
|
void render(float theta, bool useVBOs, float scale_factor) const;
|
||||||
#else
|
#else
|
||||||
void render(float theta) const;
|
void render(float theta, float scale_factor) const;
|
||||||
#endif // ENABLE_PRINT_BED_MODELS
|
#endif // ENABLE_PRINT_BED_MODELS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -297,6 +312,9 @@ class GLCanvas3D
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const float THICKNESS_BAR_WIDTH;
|
||||||
|
static const float THICKNESS_RESET_BUTTON_HEIGHT;
|
||||||
|
|
||||||
bool m_use_legacy_opengl;
|
bool m_use_legacy_opengl;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
Shader m_shader;
|
Shader m_shader;
|
||||||
|
@ -380,6 +398,9 @@ class GLCanvas3D
|
||||||
void _render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) const;
|
void _render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) const;
|
||||||
void _render_profile(const Rect& bar_rect) const;
|
void _render_profile(const Rect& bar_rect) const;
|
||||||
void update_slicing_parameters();
|
void update_slicing_parameters();
|
||||||
|
|
||||||
|
static float thickness_bar_width(const GLCanvas3D &canvas);
|
||||||
|
static float reset_button_height(const GLCanvas3D &canvas);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mouse
|
struct Mouse
|
||||||
|
@ -536,6 +557,8 @@ public:
|
||||||
mutable GLArrow m_arrow;
|
mutable GLArrow m_arrow;
|
||||||
mutable GLCurvedArrow m_curved_arrow;
|
mutable GLCurvedArrow m_curved_arrow;
|
||||||
|
|
||||||
|
mutable float m_scale_factor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Selection();
|
Selection();
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
|
@ -617,7 +640,7 @@ public:
|
||||||
|
|
||||||
void erase();
|
void erase();
|
||||||
|
|
||||||
void render() const;
|
void render(float scale_factor = 1.0) const;
|
||||||
#if ENABLE_RENDER_SELECTION_CENTER
|
#if ENABLE_RENDER_SELECTION_CENTER
|
||||||
void render_center() const;
|
void render_center() const;
|
||||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||||
|
@ -680,10 +703,6 @@ public:
|
||||||
private:
|
private:
|
||||||
class Gizmos
|
class Gizmos
|
||||||
{
|
{
|
||||||
static const float OverlayIconsScale;
|
|
||||||
static const float OverlayBorder;
|
|
||||||
static const float OverlayGapY;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum EType : unsigned char
|
enum EType : unsigned char
|
||||||
{
|
{
|
||||||
|
@ -704,6 +723,10 @@ private:
|
||||||
BackgroundTexture m_background_texture;
|
BackgroundTexture m_background_texture;
|
||||||
EType m_current;
|
EType m_current;
|
||||||
|
|
||||||
|
float m_overlay_icons_scale;
|
||||||
|
float m_overlay_border;
|
||||||
|
float m_overlay_gap_y;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Gizmos();
|
Gizmos();
|
||||||
~Gizmos();
|
~Gizmos();
|
||||||
|
@ -713,6 +736,8 @@ private:
|
||||||
bool is_enabled() const;
|
bool is_enabled() const;
|
||||||
void set_enabled(bool enable);
|
void set_enabled(bool enable);
|
||||||
|
|
||||||
|
void set_overlay_scale(float scale);
|
||||||
|
|
||||||
std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
|
||||||
void update_on_off_state(const Selection& selection);
|
void update_on_off_state(const Selection& selection);
|
||||||
|
@ -802,7 +827,7 @@ private:
|
||||||
public:
|
public:
|
||||||
WarningTexture();
|
WarningTexture();
|
||||||
|
|
||||||
bool generate(const std::string& msg);
|
bool generate(const std::string& msg, const GLCanvas3D& canvas);
|
||||||
|
|
||||||
void render(const GLCanvas3D& canvas) const;
|
void render(const GLCanvas3D& canvas) const;
|
||||||
};
|
};
|
||||||
|
@ -832,6 +857,9 @@ private:
|
||||||
|
|
||||||
wxGLCanvas* m_canvas;
|
wxGLCanvas* m_canvas;
|
||||||
wxGLContext* m_context;
|
wxGLContext* m_context;
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
std::unique_ptr<RetinaHelper> m_retina_helper;
|
||||||
|
#endif
|
||||||
bool m_in_render;
|
bool m_in_render;
|
||||||
LegendTexture m_legend_texture;
|
LegendTexture m_legend_texture;
|
||||||
WarningTexture m_warning_texture;
|
WarningTexture m_warning_texture;
|
||||||
|
@ -1030,6 +1058,8 @@ public:
|
||||||
|
|
||||||
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);
|
void handle_sidebar_focus_event(const std::string& opt_key, bool focus_on);
|
||||||
|
|
||||||
|
void update_ui_from_settings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_shown_on_screen() const;
|
bool _is_shown_on_screen() const;
|
||||||
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
#if !ENABLE_REWORKED_BED_SHAPE_CHANGE
|
||||||
|
|
|
@ -468,12 +468,12 @@ float GLToolbar::get_width_horizontal() const
|
||||||
|
|
||||||
float GLToolbar::get_width_vertical() const
|
float GLToolbar::get_width_vertical() const
|
||||||
{
|
{
|
||||||
return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
return 2.0f * m_layout.border * m_layout.icons_scale + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::get_height_horizontal() const
|
float GLToolbar::get_height_horizontal() const
|
||||||
{
|
{
|
||||||
return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
return 2.0f * m_layout.border * m_layout.icons_scale + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::get_height_vertical() const
|
float GLToolbar::get_height_vertical() const
|
||||||
|
@ -483,33 +483,36 @@ float GLToolbar::get_height_vertical() const
|
||||||
|
|
||||||
float GLToolbar::get_main_size() const
|
float GLToolbar::get_main_size() const
|
||||||
{
|
{
|
||||||
float size = 2.0f * m_layout.border;
|
float size = 2.0f * m_layout.border * m_layout.icons_scale;
|
||||||
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
|
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
|
||||||
{
|
{
|
||||||
if (m_items[i]->is_separator())
|
if (m_items[i]->is_separator())
|
||||||
size += m_layout.separator_size;
|
size += m_layout.separator_size * m_layout.icons_scale;
|
||||||
else
|
else
|
||||||
size += (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
size += (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_items.size() > 1)
|
if (m_items.size() > 1)
|
||||||
size += ((float)m_items.size() - 1.0f) * m_layout.gap_size;
|
size += ((float)m_items.size() - 1.0f) * m_layout.gap_size * m_layout.icons_scale;
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
{
|
{
|
||||||
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = m_layout.icons_scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
|
|
||||||
float separator_stride = scaled_separator_size + scaled_gap_size;
|
float separator_stride = scaled_separator_size + scaled_gap_size;
|
||||||
float icon_stride = scaled_icons_size + scaled_gap_size;
|
float icon_stride = scaled_icons_size + scaled_gap_size;
|
||||||
|
@ -591,16 +594,19 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
|
|
||||||
std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
{
|
{
|
||||||
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = m_layout.icons_scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
|
|
||||||
float separator_stride = scaled_separator_size + scaled_gap_size;
|
float separator_stride = scaled_separator_size + scaled_gap_size;
|
||||||
float icon_stride = scaled_icons_size + scaled_gap_size;
|
float icon_stride = scaled_icons_size + scaled_gap_size;
|
||||||
|
@ -682,16 +688,19 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
|
|
||||||
int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
||||||
{
|
{
|
||||||
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = m_layout.icons_scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
|
|
||||||
float separator_stride = scaled_separator_size + scaled_gap_size;
|
float separator_stride = scaled_separator_size + scaled_gap_size;
|
||||||
float icon_stride = scaled_icons_size + scaled_gap_size;
|
float icon_stride = scaled_icons_size + scaled_gap_size;
|
||||||
|
@ -724,16 +733,19 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
|
||||||
|
|
||||||
int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
||||||
{
|
{
|
||||||
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = m_layout.icons_scale * inv_zoom;
|
||||||
|
|
||||||
Size cnv_size = parent.get_canvas_size();
|
Size cnv_size = parent.get_canvas_size();
|
||||||
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
|
|
||||||
float separator_stride = scaled_separator_size + scaled_gap_size;
|
float separator_stride = scaled_separator_size + scaled_gap_size;
|
||||||
float icon_stride = scaled_icons_size + scaled_gap_size;
|
float icon_stride = scaled_icons_size + scaled_gap_size;
|
||||||
|
@ -774,11 +786,12 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = inv_zoom * m_layout.icons_scale;
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
float scaled_width = get_width() * inv_zoom;
|
float scaled_width = get_width() * inv_zoom;
|
||||||
float scaled_height = get_height() * inv_zoom;
|
float scaled_height = get_height() * inv_zoom;
|
||||||
|
|
||||||
|
@ -899,11 +912,12 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||||
|
|
||||||
float zoom = parent.get_camera_zoom();
|
float zoom = parent.get_camera_zoom();
|
||||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||||
|
float factor = inv_zoom * m_layout.icons_scale;
|
||||||
|
|
||||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom;
|
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * factor;
|
||||||
float scaled_separator_size = m_layout.separator_size * inv_zoom;
|
float scaled_separator_size = m_layout.separator_size * factor;
|
||||||
float scaled_gap_size = m_layout.gap_size * inv_zoom;
|
float scaled_gap_size = m_layout.gap_size * factor;
|
||||||
float scaled_border = m_layout.border * inv_zoom;
|
float scaled_border = m_layout.border * factor;
|
||||||
float scaled_width = get_width() * inv_zoom;
|
float scaled_width = get_width() * inv_zoom;
|
||||||
float scaled_height = get_height() * inv_zoom;
|
float scaled_height = get_height() * inv_zoom;
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ public:
|
||||||
virtual ~Preview();
|
virtual ~Preview();
|
||||||
|
|
||||||
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
|
||||||
|
GLCanvas3D* get_canvas3d() { return m_canvas; }
|
||||||
|
|
||||||
void set_view_toolbar(GLToolbar* toolbar);
|
void set_view_toolbar(GLToolbar* toolbar);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
@ -24,6 +26,7 @@ namespace GUI {
|
||||||
|
|
||||||
ImGuiWrapper::ImGuiWrapper()
|
ImGuiWrapper::ImGuiWrapper()
|
||||||
: m_font_texture(0)
|
: m_font_texture(0)
|
||||||
|
, m_style_scaling(1.0)
|
||||||
, m_mouse_buttons(0)
|
, m_mouse_buttons(0)
|
||||||
, m_disabled(false)
|
, m_disabled(false)
|
||||||
{
|
{
|
||||||
|
@ -39,18 +42,9 @@ bool ImGuiWrapper::init()
|
||||||
{
|
{
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
init_default_font(m_style_scaling);
|
||||||
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), 18.0f);
|
|
||||||
if (font == nullptr) {
|
|
||||||
font = io.Fonts->AddFontDefault();
|
|
||||||
if (font == nullptr)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_fonts.insert(FontsMap::value_type("Noto Sans Regular 18", font));
|
|
||||||
}
|
|
||||||
|
|
||||||
io.IniFilename = nullptr;
|
ImGui::GetIO().IniFilename = nullptr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +56,15 @@ void ImGuiWrapper::set_display_size(float w, float h)
|
||||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGuiWrapper::set_style_scaling(float scaling)
|
||||||
|
{
|
||||||
|
if (!std::isnan(scaling) && !std::isinf(scaling) && scaling != m_style_scaling) {
|
||||||
|
ImGui::GetStyle().ScaleAllSizes(scaling / m_style_scaling);
|
||||||
|
init_default_font(scaling);
|
||||||
|
m_style_scaling = scaling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
|
bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
@ -93,6 +96,7 @@ void ImGuiWrapper::render()
|
||||||
void ImGuiWrapper::set_next_window_pos(float x, float y, int flag)
|
void ImGuiWrapper::set_next_window_pos(float x, float y, int flag)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(x, y), (ImGuiCond)flag);
|
ImGui::SetNextWindowPos(ImVec2(x, y), (ImGuiCond)flag);
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(0.0, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiWrapper::set_next_window_bg_alpha(float alpha)
|
void ImGuiWrapper::set_next_window_bg_alpha(float alpha)
|
||||||
|
@ -198,6 +202,23 @@ bool ImGuiWrapper::want_any_input() const
|
||||||
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
|
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGuiWrapper::init_default_font(float scaling)
|
||||||
|
{
|
||||||
|
static const float font_size = 18.0f;
|
||||||
|
|
||||||
|
destroy_fonts_texture();
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.Fonts->Clear();
|
||||||
|
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size * scaling);
|
||||||
|
if (font == nullptr) {
|
||||||
|
font = io.Fonts->AddFontDefault();
|
||||||
|
if (font == nullptr) {
|
||||||
|
throw std::runtime_error("ImGui: Could not load deafult font");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImGuiWrapper::create_device_objects()
|
void ImGuiWrapper::create_device_objects()
|
||||||
{
|
{
|
||||||
create_fonts_texture();
|
create_fonts_texture();
|
||||||
|
|
|
@ -21,6 +21,7 @@ class ImGuiWrapper
|
||||||
|
|
||||||
FontsMap m_fonts;
|
FontsMap m_fonts;
|
||||||
unsigned m_font_texture;
|
unsigned m_font_texture;
|
||||||
|
float m_style_scaling;
|
||||||
unsigned m_mouse_buttons;
|
unsigned m_mouse_buttons;
|
||||||
bool m_disabled;
|
bool m_disabled;
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ public:
|
||||||
void read_glsl_version();
|
void read_glsl_version();
|
||||||
|
|
||||||
void set_display_size(float w, float h);
|
void set_display_size(float w, float h);
|
||||||
|
void set_style_scaling(float scaling);
|
||||||
bool update_mouse_data(wxMouseEvent &evt);
|
bool update_mouse_data(wxMouseEvent &evt);
|
||||||
|
|
||||||
void new_frame();
|
void new_frame();
|
||||||
|
@ -58,6 +60,7 @@ public:
|
||||||
bool want_text_input() const;
|
bool want_text_input() const;
|
||||||
bool want_any_input() const;
|
bool want_any_input() const;
|
||||||
private:
|
private:
|
||||||
|
void init_default_font(float scaling);
|
||||||
void create_device_objects();
|
void create_device_objects();
|
||||||
void create_fonts_texture();
|
void create_fonts_texture();
|
||||||
void render_draw_data(ImDrawData *draw_data);
|
void render_draw_data(ImDrawData *draw_data);
|
||||||
|
|
|
@ -1272,6 +1272,11 @@ void Plater::priv::update_ui_from_settings()
|
||||||
// $self->{buttons_sizer}->Show($self->{btn_reslice}, ! wxTheApp->{app_config}->get("background_processing"));
|
// $self->{buttons_sizer}->Show($self->{btn_reslice}, ! wxTheApp->{app_config}->get("background_processing"));
|
||||||
// $self->{buttons_sizer}->Layout;
|
// $self->{buttons_sizer}->Layout;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
view3D->get_canvas3d()->update_ui_from_settings();
|
||||||
|
preview->get_canvas3d()->update_ui_from_settings();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressStatusBar* Plater::priv::statusbar()
|
ProgressStatusBar* Plater::priv::statusbar()
|
||||||
|
|
|
@ -87,6 +87,7 @@ void PreferencesDialog::build()
|
||||||
option = Option (def,"show_incompatible_presets");
|
option = Option (def,"show_incompatible_presets");
|
||||||
m_optgroup->append_single_option_line(option);
|
m_optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
|
// TODO: remove?
|
||||||
def.label = L("Use legacy OpenGL 1.1 rendering");
|
def.label = L("Use legacy OpenGL 1.1 rendering");
|
||||||
def.type = coBool;
|
def.type = coBool;
|
||||||
def.tooltip = L("If you have rendering issues caused by a buggy OpenGL 2.0 driver, "
|
def.tooltip = L("If you have rendering issues caused by a buggy OpenGL 2.0 driver, "
|
||||||
|
@ -96,6 +97,16 @@ void PreferencesDialog::build()
|
||||||
option = Option (def,"use_legacy_opengl");
|
option = Option (def,"use_legacy_opengl");
|
||||||
m_optgroup->append_single_option_line(option);
|
m_optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
def.label = L("Use Retina resolution for the 3D scene");
|
||||||
|
def.type = coBool;
|
||||||
|
def.tooltip = L("If enabled, the 3D scene will be rendered in Retina resolution. "
|
||||||
|
"If you are experiencing 3D performance problems, disabling this option may help.");
|
||||||
|
def.default_value = new ConfigOptionBool{ app_config->get("use_retina_opengl") == "1" };
|
||||||
|
option = Option (def, "use_retina_opengl");
|
||||||
|
m_optgroup->append_single_option_line(option);
|
||||||
|
#endif
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||||
|
|
||||||
|
|
29
src/slic3r/Utils/RetinaHelper.hpp
Normal file
29
src/slic3r/Utils/RetinaHelper.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef slic3r_RetinaHelper_hpp_
|
||||||
|
#define slic3r_RetinaHelper_hpp_
|
||||||
|
|
||||||
|
class wxWindow;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
class RetinaHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RetinaHelper(wxWindow* window);
|
||||||
|
~RetinaHelper();
|
||||||
|
|
||||||
|
void set_use_retina(bool value);
|
||||||
|
bool get_use_retina();
|
||||||
|
float get_scale_factor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow* m_window;
|
||||||
|
void* m_self;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace GUI
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
#endif // RetinaHelper_h
|
15
src/slic3r/Utils/RetinaHelperImpl.hmm
Normal file
15
src/slic3r/Utils/RetinaHelperImpl.hmm
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
class wxEvtHandler;
|
||||||
|
|
||||||
|
@interface RetinaHelperImpl : NSObject
|
||||||
|
{
|
||||||
|
NSView *view;
|
||||||
|
wxEvtHandler* handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(id)initWithView:(NSView *)view handler:(wxEvtHandler *)handler;
|
||||||
|
-(void)setViewWantsBestResolutionOpenGLSurface:(BOOL)value;
|
||||||
|
-(BOOL)getViewWantsBestResolutionOpenGLSurface;
|
||||||
|
-(float)getBackingScaleFactor;
|
||||||
|
@end
|
111
src/slic3r/Utils/RetinaHelperImpl.mm
Normal file
111
src/slic3r/Utils/RetinaHelperImpl.mm
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
// The RetinaHelper was originally written by Andreas Stahl, 2013
|
||||||
|
|
||||||
|
#import "RetinaHelper.hpp"
|
||||||
|
#import "RetinaHelperImpl.hmm"
|
||||||
|
#import <OpenGL/OpenGL.h>
|
||||||
|
|
||||||
|
#import "wx/window.h"
|
||||||
|
|
||||||
|
@implementation RetinaHelperImpl
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
|
RetinaHelper::RetinaHelper(wxWindow* window) :
|
||||||
|
m_window(window)
|
||||||
|
{
|
||||||
|
m_self = nullptr;
|
||||||
|
m_self = [[RetinaHelperImpl alloc] initWithView:window->GetHandle() handler:window->GetEventHandler()];
|
||||||
|
}
|
||||||
|
|
||||||
|
RetinaHelper::~RetinaHelper()
|
||||||
|
{
|
||||||
|
[m_self release];
|
||||||
|
}
|
||||||
|
|
||||||
|
void RetinaHelper::set_use_retina(bool aValue)
|
||||||
|
{
|
||||||
|
[(id)m_self setViewWantsBestResolutionOpenGLSurface:aValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RetinaHelper::get_use_retina()
|
||||||
|
{
|
||||||
|
return [(id)m_self getViewWantsBestResolutionOpenGLSurface];
|
||||||
|
}
|
||||||
|
|
||||||
|
float RetinaHelper::get_scale_factor()
|
||||||
|
{
|
||||||
|
return [(id)m_self getViewWantsBestResolutionOpenGLSurface] ? [(id)m_self getBackingScaleFactor] : 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace GUI
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
|
||||||
|
-(id)initWithView:(NSView *)aView handler:(wxEvtHandler *)aHandler
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
handler = aHandler;
|
||||||
|
view = aView;
|
||||||
|
// register for backing change notifications
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
if (nc) {
|
||||||
|
[nc addObserver:self selector:@selector(windowDidChangeBackingProperties:)
|
||||||
|
name:NSWindowDidChangeBackingPropertiesNotification object:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) dealloc
|
||||||
|
{
|
||||||
|
// unregister from all notifications
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
if (nc) {
|
||||||
|
[nc removeObserver:self];
|
||||||
|
}
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)setViewWantsBestResolutionOpenGLSurface:(BOOL)value
|
||||||
|
{
|
||||||
|
[view setWantsBestResolutionOpenGLSurface:value];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)getViewWantsBestResolutionOpenGLSurface
|
||||||
|
{
|
||||||
|
return [view wantsBestResolutionOpenGLSurface];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(float)getBackingScaleFactor
|
||||||
|
{
|
||||||
|
return [[view window] backingScaleFactor];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)windowDidChangeBackingProperties:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
NSWindow *theWindow = (NSWindow *)[notification object];
|
||||||
|
|
||||||
|
if (theWindow == [view window]) {
|
||||||
|
CGFloat newBackingScaleFactor = [theWindow backingScaleFactor];
|
||||||
|
CGFloat oldBackingScaleFactor = [[[notification userInfo]
|
||||||
|
objectForKey:@"NSBackingPropertyOldScaleFactorKey"]
|
||||||
|
doubleValue];
|
||||||
|
|
||||||
|
if (newBackingScaleFactor != oldBackingScaleFactor) {
|
||||||
|
// generate a wx resize event and pass it to the handler's queue
|
||||||
|
wxSizeEvent *event = new wxSizeEvent();
|
||||||
|
// use the following line if this resize event should have the physical pixel resolution
|
||||||
|
// but that is not recommended, because ordinary resize events won't do so either
|
||||||
|
// which would necessitate a case-by-case switch in the resize handler method.
|
||||||
|
// NSRect nsrect = [view convertRectToBacking:[view bounds]];
|
||||||
|
NSRect nsrect = [view bounds];
|
||||||
|
wxRect rect = wxRect(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height);
|
||||||
|
event->SetRect(rect);
|
||||||
|
event->SetSize(rect.GetSize());
|
||||||
|
handler->QueueEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@end
|
Loading…
Add table
Add a link
Reference in a new issue