OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::TexturePreviewCanvas Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/TextureImportDialog.hpp>

Inheritance diagram for Slic3r::GUI::TexturePreviewCanvas:
Collaboration diagram for Slic3r::GUI::TexturePreviewCanvas:

Public Types

enum class  RenderMode { Original , MultiColor , FilamentMap }

Public Member Functions

 TexturePreviewCanvas (wxWindow *parent, const wxGLAttributes &attrs)
 ~TexturePreviewCanvas ()
void set_mesh_data (const std::vector< std::array< float, 3 > > &vertices, const std::vector< std::array< int, 3 > > &indices)
void set_texture_data (const std::vector< std::array< float, 2 > > &uvs, const unsigned char *tex_data, int tex_w, int tex_h, int tex_channels)
void set_texture_render_data (const std::vector< std::vector< unsigned char > > &tex_pixels_rgb, const std::vector< int > &tex_widths, const std::vector< int > &tex_heights, const std::vector< std::array< std::array< float, 2 >, 3 > > &face_uvs, const std::vector< int > &face_tex_ids)
void set_painted_mesh_data (const std::vector< std::array< float, 3 > > &vertices, const std::vector< std::array< int, 3 > > &indices)
void set_face_colors (const std::vector< std::array< std::size_t, 3 > > &face_colors)
void set_original_face_colors (const std::vector< std::array< std::size_t, 3 > > &face_colors)
void set_filament_color_map (const std::map< std::array< std::size_t, 3 >, std::array< float, 3 > > &color_map)
void set_render_mode (RenderMode mode)
RenderMode get_render_mode () const
void set_computing_overlay (bool show)
void reset_view ()

Private Types

enum class  DragMode { None , Rotate , Pan }

Private Member Functions

void on_paint (wxPaintEvent &evt)
void on_size (wxSizeEvent &evt)
void on_mouse (wxMouseEvent &evt)
void ensure_gl_ready ()
void render ()
void render_mesh ()
void render_textured_original ()
void render_reset_overlay (const wxSize &logical_size, const wxSize &viewport_size)
void upload_reset_icon_textures ()
unsigned int upload_reset_icon_texture (const std::string &icon_name)
wxRect reset_overlay_rect () const
bool handle_reset_overlay_mouse (wxMouseEvent &evt)
void upload_textures ()
void compute_smooth_normals ()
void update_bounding_box ()

Private Attributes

wxGLContext * m_context = nullptr
bool m_gl_initialized = false
RenderMode m_mode = RenderMode::Original
float m_zoom = 1.0f
float m_rot_x = -30.0f
float m_rot_y = 30.0f
float m_pan_x = 0.0f
float m_pan_y = 0.0f
wxPoint m_last_mouse_pos
DragMode m_drag_mode = DragMode::None
std::vector< std::array< float, 3 > > m_vertices
std::vector< std::array< int, 3 > > m_indices
std::vector< std::array< float, 2 > > m_uvs
std::vector< std::array< float, 3 > > m_painted_vertices
std::vector< std::array< int, 3 > > m_painted_indices
std::vector< std::array< float, 3 > > m_face_colors_rgb
std::vector< std::array< float, 3 > > m_original_face_colors_rgb
std::vector< std::array< float, 3 > > m_filament_colors_rgb
std::map< std::array< std::size_t, 3 >, std::array< float, 3 > > m_color_map
unsigned int m_tex_id = 0
int m_tex_w = 0
int m_tex_h = 0
int m_tex_channels = 3
bool m_tex_dirty = false
std::vector< unsigned char > m_tex_data
std::vector< unsigned int > m_gl_tex_ids
std::vector< std::vector< unsigned char > > m_tex_pixels_rgb
std::vector< int > m_tex_widths
std::vector< int > m_tex_heights
std::vector< std::array< std::array< float, 2 >, 3 > > m_face_uvs
std::vector< int > m_face_tex_ids
bool m_multi_tex_dirty = false
std::vector< std::array< float, 3 > > m_vertex_normals
std::array< float, 3 > m_center = {0, 0, 0}
float m_radius = 1.0f
unsigned int m_reset_icon_tex = 0
unsigned int m_reset_icon_hover_tex = 0
unsigned int m_reset_icon_dark_tex = 0
unsigned int m_reset_icon_dark_hover_tex = 0
bool m_reset_overlay_hovered = false
bool m_reset_overlay_pressed = false

Detailed Description

Member Enumeration Documentation

◆ DragMode

Enumerator
None 
Rotate 
Pan 
155{ None, Rotate, Pan };
@ None
Definition SketchEngine.hpp:180

◆ RenderMode

Enumerator
Original 
MultiColor 
FilamentMap 
96{ Original, MultiColor, FilamentMap };

Constructor & Destructor Documentation

◆ TexturePreviewCanvas()

Slic3r::GUI::TexturePreviewCanvas::TexturePreviewCanvas ( wxWindow * parent,
const wxGLAttributes & attrs )
1037 : wxGLCanvas(parent, attrs, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
1038{
1039 m_context = new wxGLContext(this);
1040
1041 Bind(wxEVT_PAINT, &TexturePreviewCanvas::on_paint, this);
1042 Bind(wxEVT_SIZE, &TexturePreviewCanvas::on_size, this);
1043 Bind(wxEVT_MOUSEWHEEL, &TexturePreviewCanvas::on_mouse, this);
1044 Bind(wxEVT_LEFT_DOWN, &TexturePreviewCanvas::on_mouse, this);
1045 Bind(wxEVT_LEFT_UP, &TexturePreviewCanvas::on_mouse, this);
1046 Bind(wxEVT_RIGHT_DOWN, &TexturePreviewCanvas::on_mouse, this);
1047 Bind(wxEVT_RIGHT_UP, &TexturePreviewCanvas::on_mouse, this);
1048 Bind(wxEVT_MIDDLE_DOWN, &TexturePreviewCanvas::on_mouse, this);
1049 Bind(wxEVT_MIDDLE_UP, &TexturePreviewCanvas::on_mouse, this);
1050 Bind(wxEVT_MOTION, &TexturePreviewCanvas::on_mouse, this);
1051 Bind(wxEVT_MOUSE_CAPTURE_LOST, [this](wxMouseCaptureLostEvent&) {
1054 });
1055 Bind(wxEVT_LEAVE_WINDOW, &TexturePreviewCanvas::on_mouse, this);
1056}
bool m_reset_overlay_pressed
Definition TextureImportDialog.hpp:193
void on_mouse(wxMouseEvent &evt)
Definition TextureImportDialog.cpp:1430
void on_paint(wxPaintEvent &evt)
Definition TextureImportDialog.cpp:1415
wxGLContext * m_context
Definition TextureImportDialog.hpp:145
DragMode m_drag_mode
Definition TextureImportDialog.hpp:156
@ None
Definition TextureImportDialog.hpp:155
void on_size(wxSizeEvent &evt)
Definition TextureImportDialog.cpp:1425

References m_context, m_drag_mode, m_reset_overlay_pressed, None, on_mouse(), on_paint(), and on_size().

Here is the call graph for this function:

◆ ~TexturePreviewCanvas()

Slic3r::GUI::TexturePreviewCanvas::~TexturePreviewCanvas ( )
1059{
1060 // See MixedFilamentDialog::~MixedFilamentDialog: a widget destroyed while it
1061 // still holds the capture wedges mouse input for the whole application.
1062 if (HasCapture())
1063 ReleaseMouse();
1064
1065 if (m_context) {
1066 SetCurrent(*m_context);
1067 if (m_tex_id)
1069 for (unsigned int id : m_gl_tex_ids)
1070 if (id) glDeleteTextures(1, &id);
1071 for (unsigned int id : {m_reset_icon_tex, m_reset_icon_hover_tex,
1073 if (id) glDeleteTextures(1, &id);
1074 delete m_context;
1075 }
1076}
unsigned int m_reset_icon_hover_tex
Definition TextureImportDialog.hpp:189
unsigned int m_reset_icon_tex
Definition TextureImportDialog.hpp:188
unsigned int m_tex_id
Definition TextureImportDialog.hpp:168
unsigned int m_reset_icon_dark_hover_tex
Definition TextureImportDialog.hpp:191
std::vector< unsigned int > m_gl_tex_ids
Definition TextureImportDialog.hpp:175
unsigned int m_reset_icon_dark_tex
Definition TextureImportDialog.hpp:190
#define glDeleteTextures
Definition gl.h:3587

References glDeleteTextures, m_context, m_gl_tex_ids, m_reset_icon_dark_hover_tex, m_reset_icon_dark_tex, m_reset_icon_hover_tex, m_reset_icon_tex, and m_tex_id.

Member Function Documentation

◆ compute_smooth_normals()

void Slic3r::GUI::TexturePreviewCanvas::compute_smooth_normals ( )
private
1090{
1091 m_vertex_normals.clear();
1092 if (m_vertices.empty() || m_indices.empty()) return;
1093
1094 m_vertex_normals.resize(m_vertices.size(), {0.f, 0.f, 0.f});
1095
1096 for (const auto& face : m_indices) {
1097 int i0 = face[0], i1 = face[1], i2 = face[2];
1098 if (i0 < 0 || i0 >= (int)m_vertices.size() ||
1099 i1 < 0 || i1 >= (int)m_vertices.size() ||
1100 i2 < 0 || i2 >= (int)m_vertices.size())
1101 continue;
1102
1103 const auto& v0 = m_vertices[i0];
1104 const auto& v1 = m_vertices[i1];
1105 const auto& v2 = m_vertices[i2];
1106
1107 float nx = (v1[1]-v0[1])*(v2[2]-v0[2]) - (v1[2]-v0[2])*(v2[1]-v0[1]);
1108 float ny = (v1[2]-v0[2])*(v2[0]-v0[0]) - (v1[0]-v0[0])*(v2[2]-v0[2]);
1109 float nz = (v1[0]-v0[0])*(v2[1]-v0[1]) - (v1[1]-v0[1])*(v2[0]-v0[0]);
1110
1111 m_vertex_normals[i0][0] += nx; m_vertex_normals[i0][1] += ny; m_vertex_normals[i0][2] += nz;
1112 m_vertex_normals[i1][0] += nx; m_vertex_normals[i1][1] += ny; m_vertex_normals[i1][2] += nz;
1113 m_vertex_normals[i2][0] += nx; m_vertex_normals[i2][1] += ny; m_vertex_normals[i2][2] += nz;
1114 }
1115
1116 for (auto& n : m_vertex_normals) {
1117 float len = std::sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
1118 if (len > 1e-8f) { n[0] /= len; n[1] /= len; n[2] /= len; }
1119 }
1120}
std::vector< std::array< float, 3 > > m_vertex_normals
Definition TextureImportDialog.hpp:183
std::vector< std::array< float, 3 > > m_vertices
Definition TextureImportDialog.hpp:158
std::vector< std::array< int, 3 > > m_indices
Definition TextureImportDialog.hpp:159

References m_indices, m_vertex_normals, and m_vertices.

Referenced by set_mesh_data().

Here is the caller graph for this function:

◆ ensure_gl_ready()

void Slic3r::GUI::TexturePreviewCanvas::ensure_gl_ready ( )
private
1387{
1388 if (m_gl_initialized) return;
1389
1390 // BBS loads the GL entry points here with GLEW; Orca loads them centrally in
1391 // OpenGLManager, so only check that this has already happened (glad leaves unresolved
1392 // entry points null) and drain any stale error state.
1393 if (glGetString == nullptr) {
1394 BOOST_LOG_TRIVIAL(error) << "TexturePreviewCanvas: OpenGL functions are not loaded yet";
1395 return;
1396 }
1397 while (glGetError() != GL_NO_ERROR) {}
1398
1399 m_gl_initialized = true;
1400
1406
1407 GLfloat light_pos[] = { 0.5f, 1.0f, 1.0f, 0.0f };
1408 GLfloat light_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f };
1409 GLfloat light_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
1410 glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
1411 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
1412 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
1413}
bool m_gl_initialized
Definition TextureImportDialog.hpp:146
#define GL_DIFFUSE
Definition gl.h:577
#define glGetError
Definition gl.h:3849
#define GL_POSITION
Definition gl.h:1327
#define glColorMaterial
Definition gl.h:3475
#define GL_AMBIENT_AND_DIFFUSE
Definition gl.h:232
#define GL_FRONT_AND_BACK
Definition gl.h:761
#define glEnable
Definition gl.h:3667
#define GL_DEPTH_TEST
Definition gl.h:574
#define GL_AMBIENT
Definition gl.h:231
#define glGetString
Definition gl.h:3987
khronos_float_t GLfloat
Definition gl.h:2066
#define GL_NO_ERROR
Definition gl.h:1217
#define GL_COLOR_MATERIAL
Definition gl.h:415
#define glLightfv
Definition gl.h:4207
#define GL_LIGHT0
Definition gl.h:915
#define GL_LIGHTING
Definition gl.h:923

References GL_AMBIENT, GL_AMBIENT_AND_DIFFUSE, GL_COLOR_MATERIAL, GL_DEPTH_TEST, GL_DIFFUSE, GL_FRONT_AND_BACK, GL_LIGHT0, GL_LIGHTING, GL_NO_ERROR, GL_POSITION, glColorMaterial, glEnable, glGetError, glGetString, glLightfv, and m_gl_initialized.

Referenced by on_paint().

Here is the caller graph for this function:

◆ get_render_mode()

RenderMode Slic3r::GUI::TexturePreviewCanvas::get_render_mode ( ) const
inline
124{ return m_mode; }
RenderMode m_mode
Definition TextureImportDialog.hpp:147

References m_mode.

◆ handle_reset_overlay_mouse()

bool Slic3r::GUI::TexturePreviewCanvas::handle_reset_overlay_mouse ( wxMouseEvent & evt)
private
1318{
1319 if (evt.Leaving()) {
1323 SetCursor(wxCursor(wxCURSOR_ARROW));
1324 if (HasCapture())
1325 ReleaseMouse();
1326 Refresh();
1327 return true;
1328 }
1331 SetCursor(wxCursor(wxCURSOR_ARROW));
1332 Refresh();
1333 }
1334 return false;
1335 }
1336
1337 const bool over = reset_overlay_rect().Contains(evt.GetPosition());
1338 if (over != m_reset_overlay_hovered) {
1340 SetCursor(wxCursor(over ? wxCURSOR_HAND : wxCURSOR_ARROW));
1341 Refresh();
1342 }
1343
1345 return false;
1346
1347 if (evt.LeftDown() && over) {
1349 if (!HasCapture())
1350 CaptureMouse();
1351 Refresh();
1352 return true;
1353 }
1354
1355 if (evt.LeftUp() && m_reset_overlay_pressed) {
1356 const bool activate = over;
1358 if (HasCapture())
1359 ReleaseMouse();
1360 if (activate)
1361 reset_view();
1362 else
1363 Refresh();
1364 return true;
1365 }
1366
1367 return over;
1368}
wxRect reset_overlay_rect() const
Definition TextureImportDialog.cpp:1252
bool m_reset_overlay_hovered
Definition TextureImportDialog.hpp:192
void reset_view()
Definition TextureImportDialog.cpp:1242

References m_drag_mode, m_reset_overlay_hovered, m_reset_overlay_pressed, None, reset_overlay_rect(), reset_view(), and Slic3r::GUI::wxMouseEvent.

Referenced by on_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_mouse()

void Slic3r::GUI::TexturePreviewCanvas::on_mouse ( wxMouseEvent & evt)
private
1431{
1433 return;
1434
1435 if (evt.LeftDown()) {
1437 m_last_mouse_pos = evt.GetPosition();
1438 if (!HasCapture()) CaptureMouse();
1439 }
1440 else if (evt.LeftUp()) {
1443 if (HasCapture()) ReleaseMouse();
1444 }
1445 }
1446 else if (evt.RightDown()) {
1448 m_last_mouse_pos = evt.GetPosition();
1449 if (!HasCapture()) CaptureMouse();
1450 }
1451 else if (evt.MiddleDown()) {
1453 m_last_mouse_pos = evt.GetPosition();
1454 if (!HasCapture()) CaptureMouse();
1455 }
1456 else if (evt.RightUp() || evt.MiddleUp()) {
1457 if (m_drag_mode == DragMode::Pan) {
1459 if (HasCapture()) ReleaseMouse();
1460 }
1461 }
1462 else if (evt.Dragging() && m_drag_mode != DragMode::None) {
1463 wxPoint pos = evt.GetPosition();
1464 float dx = (float)(pos.x - m_last_mouse_pos.x);
1465 float dy = (float)(pos.y - m_last_mouse_pos.y);
1466
1468 m_rot_y += dx * 0.5f;
1469 m_rot_x += dy * 0.5f;
1470 m_rot_x = std::max(-89.0f, std::min(89.0f, m_rot_x));
1471 } else if (m_drag_mode == DragMode::Pan) {
1472 wxSize sz = GetClientSize();
1473 if (sz.x > 0)
1474 m_pan_x += dx / (float)sz.x * m_radius * 2.0f / m_zoom;
1475 if (sz.y > 0)
1476 m_pan_y -= dy / (float)sz.y * m_radius * 2.0f / m_zoom;
1477 }
1478
1480 Refresh();
1481 }
1482 else if (evt.GetWheelRotation() != 0) {
1483 float delta = evt.GetWheelRotation() > 0 ? 1.1f : 0.9f;
1484 m_zoom *= delta;
1485 m_zoom = std::max(0.1f, std::min(20.0f, m_zoom));
1486 Refresh();
1487 }
1488}
float m_pan_y
Definition TextureImportDialog.hpp:153
float m_radius
Definition TextureImportDialog.hpp:186
float m_zoom
Definition TextureImportDialog.hpp:149
float m_rot_y
Definition TextureImportDialog.hpp:151
bool handle_reset_overlay_mouse(wxMouseEvent &evt)
Definition TextureImportDialog.cpp:1317
@ Rotate
Definition TextureImportDialog.hpp:155
@ Pan
Definition TextureImportDialog.hpp:155
float m_pan_x
Definition TextureImportDialog.hpp:152
wxPoint m_last_mouse_pos
Definition TextureImportDialog.hpp:154
float m_rot_x
Definition TextureImportDialog.hpp:150
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References handle_reset_overlay_mouse(), m_drag_mode, m_last_mouse_pos, m_pan_x, m_pan_y, m_radius, m_rot_x, m_rot_y, m_zoom, None, Pan, Rotate, and Slic3r::GUI::wxMouseEvent.

Referenced by TexturePreviewCanvas().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_paint()

void Slic3r::GUI::TexturePreviewCanvas::on_paint ( wxPaintEvent & evt)
private
1416{
1417 wxPaintDC dc(this);
1418 if (!m_context) return;
1419 SetCurrent(*m_context);
1421 render();
1422 SwapBuffers();
1423}
void ensure_gl_ready()
Definition TextureImportDialog.cpp:1386
void render()
Definition TextureImportDialog.cpp:1490

References ensure_gl_ready(), m_context, and render().

Referenced by TexturePreviewCanvas().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_size()

void Slic3r::GUI::TexturePreviewCanvas::on_size ( wxSizeEvent & evt)
private
1426{
1427 Refresh();
1428}

Referenced by TexturePreviewCanvas().

Here is the caller graph for this function:

◆ render()

void Slic3r::GUI::TexturePreviewCanvas::render ( )
private
1491{
1492 wxSize sz = GetClientSize();
1493 if (sz.x <= 0 || sz.y <= 0) return;
1494
1495 wxSize viewport_sz = gl_viewport_size(this, sz);
1496 glViewport(0, 0, viewport_sz.x, viewport_sz.y);
1497 // Same palette key as the preview container, so canvas and frame cannot drift apart.
1498 const wxColour clear_clr = StateColor::darkModeColorFor(wxColour("#EEEEEE"));
1499 glClearColor(clear_clr.Red() / 255.f, clear_clr.Green() / 255.f, clear_clr.Blue() / 255.f, 1.0f);
1501
1504 float aspect = (float)viewport_sz.x / (float)viewport_sz.y;
1505 float dist = m_radius * 3.0f / m_zoom;
1506 float near_plane = dist * 0.01f;
1507 float far_plane = dist * 10.0f;
1508 float fov_rad = 45.0f * static_cast<float>(M_PI) / 180.0f;
1509 float f = 1.0f / std::tan(fov_rad / 2.0f);
1510 float proj[16] = {};
1511 proj[0] = f / aspect;
1512 proj[5] = f;
1513 proj[10] = (far_plane + near_plane) / (near_plane - far_plane);
1514 proj[11] = -1.0f;
1515 proj[14] = (2.0f * far_plane * near_plane) / (near_plane - far_plane);
1516 glMultMatrixf(proj);
1517
1520 glTranslatef(0.0f, 0.0f, -dist);
1522 glRotatef(m_rot_x, 1.0f, 0.0f, 0.0f);
1523 glRotatef(m_rot_y, 0.0f, 1.0f, 0.0f);
1524 glTranslatef(-m_center[0], -m_center[1], -m_center[2]);
1525
1526 render_mesh();
1527 render_reset_overlay(sz, viewport_sz);
1528}
#define M_PI
Definition ExtrusionSimulator.cpp:31
static wxSize gl_viewport_size(wxWindow *win, const wxSize &logical_size)
Definition TextureImportDialog.cpp:113
std::array< float, 3 > m_center
Definition TextureImportDialog.hpp:185
void render_mesh()
Definition TextureImportDialog.cpp:1659
void render_reset_overlay(const wxSize &logical_size, const wxSize &viewport_size)
Definition TextureImportDialog.cpp:1530
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
#define glClearColor
Definition gl.h:3373
#define glTranslatef
Definition gl.h:4975
#define glMultMatrixf
Definition gl.h:4277
#define GL_PROJECTION
Definition gl.h:1348
#define GL_MODELVIEW
Definition gl.h:1189
#define GL_COLOR_BUFFER_BIT
Definition gl.h:408
#define glMatrixMode
Definition gl.h:4267
#define glRotatef
Definition gl.h:4695
#define glViewport
Definition gl.h:5333
#define glLoadIdentity
Definition gl.h:4221
#define GL_DEPTH_BUFFER_BIT
Definition gl.h:558
#define glClear
Definition gl.h:3357
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:298
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124

References StateColor::darkModeColorFor(), Slic3r::Geometry::dist(), Slic3r::f(), GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_MODELVIEW, GL_PROJECTION, gl_viewport_size(), glClear, glClearColor, glLoadIdentity, glMatrixMode, glMultMatrixf, glRotatef, glTranslatef, glViewport, m_center, m_pan_x, m_pan_y, M_PI, m_radius, m_rot_x, m_rot_y, m_zoom, render_mesh(), and render_reset_overlay().

Referenced by on_paint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_mesh()

void Slic3r::GUI::TexturePreviewCanvas::render_mesh ( )
private
1660{
1661 if (m_vertices.empty() || m_indices.empty()) return;
1662
1663 // Original mode with texture data: use proper texture mapping
1664 if (m_mode == RenderMode::Original && !m_face_uvs.empty()) {
1666 return;
1667 }
1668
1669 // For Multi-Color / FilamentMap, use the painted (remeshed) geometry if available;
1670 // the face color arrays match the painted mesh, not the original mesh.
1671 const bool use_painted = (m_mode != RenderMode::Original)
1672 && !m_painted_vertices.empty()
1673 && !m_painted_indices.empty();
1674
1675 const auto& verts = use_painted ? m_painted_vertices : m_vertices;
1676 const auto& faces = use_painted ? m_painted_indices : m_indices;
1677
1678 const std::vector<std::array<float, 3>>* colors_ptr = nullptr;
1680 && m_original_face_colors_rgb.size() == m_indices.size()) {
1681 colors_ptr = &m_original_face_colors_rgb;
1682 } else if (m_mode == RenderMode::FilamentMap && !m_filament_colors_rgb.empty()
1683 && m_filament_colors_rgb.size() == faces.size()) {
1684 colors_ptr = &m_filament_colors_rgb;
1685 } else if (!m_face_colors_rgb.empty() && m_face_colors_rgb.size() == faces.size()) {
1686 colors_ptr = &m_face_colors_rgb;
1687 }
1688
1689 // Use smooth normals for the original mesh when available
1690 const bool has_smooth = !use_painted
1691 && (m_vertex_normals.size() == m_vertices.size());
1692
1695
1697 for (size_t fi = 0; fi < faces.size(); ++fi) {
1698 if (colors_ptr)
1699 glColor3fv((*colors_ptr)[fi].data());
1700 else
1701 glColor3f(0.7f, 0.7f, 0.7f);
1702
1703 const auto& face = faces[fi];
1704 for (int vi = 0; vi < 3; ++vi) {
1705 int idx = face[vi];
1706 if (idx < 0 || idx >= (int)verts.size()) continue;
1707
1708 if (has_smooth && idx < (int)m_vertex_normals.size()) {
1709 glNormal3fv(m_vertex_normals[idx].data());
1710 } else if (vi == 0) {
1711 const auto& v0 = verts[face[0]];
1712 const auto& v1 = verts[face[1]];
1713 const auto& v2 = verts[face[2]];
1714 float nx = (v1[1]-v0[1])*(v2[2]-v0[2]) - (v1[2]-v0[2])*(v2[1]-v0[1]);
1715 float ny = (v1[2]-v0[2])*(v2[0]-v0[0]) - (v1[0]-v0[0])*(v2[2]-v0[2]);
1716 float nz = (v1[0]-v0[0])*(v2[1]-v0[1]) - (v1[1]-v0[1])*(v2[0]-v0[0]);
1717 float len = std::sqrt(nx*nx + ny*ny + nz*nz);
1718 if (len > 1e-8f) { nx /= len; ny /= len; nz /= len; }
1719 glNormal3f(nx, ny, nz);
1720 }
1721
1722 glVertex3fv(verts[idx].data());
1723 }
1724 }
1725 glEnd();
1726}
std::vector< std::array< float, 3 > > m_original_face_colors_rgb
Definition TextureImportDialog.hpp:164
std::vector< std::array< float, 3 > > m_painted_vertices
Definition TextureImportDialog.hpp:161
void render_textured_original()
Definition TextureImportDialog.cpp:1587
std::vector< std::array< std::array< float, 2 >, 3 > > m_face_uvs
Definition TextureImportDialog.hpp:179
std::vector< std::array< float, 3 > > m_face_colors_rgb
Definition TextureImportDialog.hpp:163
std::vector< std::array< float, 3 > > m_filament_colors_rgb
Definition TextureImportDialog.hpp:165
std::vector< std::array< int, 3 > > m_painted_indices
Definition TextureImportDialog.hpp:162
@ Original
Definition TextureImportDialog.hpp:96
@ FilamentMap
Definition TextureImportDialog.hpp:96
#define glColor3f
Definition gl.h:3415
#define glBegin
Definition gl.h:3255
#define GL_TRIANGLES
Definition gl.h:1887
#define glNormal3f
Definition gl.h:4411
#define glColor3fv
Definition gl.h:3417
#define glEnd
Definition gl.h:3677
#define glVertex3fv
Definition gl.h:5115
#define GL_TEXTURE_2D
Definition gl.h:1739
#define glNormal3fv
Definition gl.h:4413
#define glDisable
Definition gl.h:3607

References FilamentMap, GL_LIGHTING, GL_TEXTURE_2D, GL_TRIANGLES, glBegin, glColor3f, glColor3fv, glDisable, glEnable, glEnd, glNormal3f, glNormal3fv, glVertex3fv, m_face_colors_rgb, m_face_uvs, m_filament_colors_rgb, m_indices, m_mode, m_original_face_colors_rgb, m_painted_indices, m_painted_vertices, m_vertex_normals, m_vertices, Original, and render_textured_original().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_reset_overlay()

void Slic3r::GUI::TexturePreviewCanvas::render_reset_overlay ( const wxSize & logical_size,
const wxSize & viewport_size )
private
1531{
1532 if (logical_size.x <= 0 || logical_size.y <= 0 || viewport_size.x <= 0 || viewport_size.y <= 0)
1533 return;
1534
1536
1537 const unsigned int tex_id = is_dark()
1540 if (!tex_id)
1541 return;
1542
1543 wxRect rc = reset_overlay_rect();
1544 const float sx = (float)viewport_size.x / (float)logical_size.x;
1545 const float sy = (float)viewport_size.y / (float)logical_size.y;
1546 const float x0 = rc.GetLeft() * sx;
1547 const float y0 = rc.GetTop() * sy;
1548 const float x1 = (rc.GetLeft() + rc.GetWidth()) * sx;
1549 const float y1 = (rc.GetTop() + rc.GetHeight()) * sy;
1550 const float alpha = m_reset_overlay_hovered ? 1.0f : 0.78f;
1551
1560
1562 glPushMatrix();
1564 glOrtho(0.0, viewport_size.x, viewport_size.y, 0.0, -1.0, 1.0);
1565
1567 glPushMatrix();
1569
1570 glColor4f(1.0f, 1.0f, 1.0f, alpha);
1572 glTexCoord2f(0.0f, 0.0f); glVertex2f(x0, y0);
1573 glTexCoord2f(1.0f, 0.0f); glVertex2f(x1, y0);
1574 glTexCoord2f(1.0f, 1.0f); glVertex2f(x1, y1);
1575 glTexCoord2f(0.0f, 1.0f); glVertex2f(x0, y1);
1576 glEnd();
1577
1578 glPopMatrix();
1580 glPopMatrix();
1582
1584 glPopAttrib();
1585}
static bool is_dark()
Definition TextureImportDialog.cpp:85
void upload_reset_icon_textures()
Definition TextureImportDialog.cpp:1302
#define glVertex2f
Definition gl.h:5097
#define GL_TEXTURE_BIT
Definition gl.h:1758
#define GL_QUADS
Definition gl.h:1368
#define glColor4f
Definition gl.h:3447
#define glPopMatrix
Definition gl.h:4483
#define GL_SRC_ALPHA
Definition gl.h:1621
#define glTexEnvi
Definition gl.h:4877
#define GL_ENABLE_BIT
Definition gl.h:639
#define GL_TEXTURE_ENV
Definition gl.h:1796
#define glOrtho
Definition gl.h:4433
#define GL_TEXTURE_ENV_MODE
Definition gl.h:1798
#define glBindTexture
Definition gl.h:3299
#define glPopAttrib
Definition gl.h:4477
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define GL_MODULATE
Definition gl.h:1192
#define glTexCoord2f
Definition gl.h:4811
#define glPushMatrix
Definition gl.h:4603
#define glPushAttrib
Definition gl.h:4597
#define glBlendFunc
Definition gl.h:3325

References GL_BLEND, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_DEPTH_TEST, GL_ENABLE_BIT, GL_LIGHTING, GL_MODELVIEW, GL_MODULATE, GL_ONE_MINUS_SRC_ALPHA, GL_PROJECTION, GL_QUADS, GL_SRC_ALPHA, GL_TEXTURE_2D, GL_TEXTURE_BIT, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glBegin, glBindTexture, glBlendFunc, glColor4f, glDisable, glEnable, glEnd, glLoadIdentity, glMatrixMode, glOrtho, glPopAttrib, glPopMatrix, glPushAttrib, glPushMatrix, glTexCoord2f, glTexEnvi, glVertex2f, is_dark(), m_reset_icon_dark_hover_tex, m_reset_icon_dark_tex, m_reset_icon_hover_tex, m_reset_icon_tex, m_reset_overlay_hovered, reset_overlay_rect(), and upload_reset_icon_textures().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_textured_original()

void Slic3r::GUI::TexturePreviewCanvas::render_textured_original ( )
private
1588{
1589 if (m_vertices.empty() || m_indices.empty()) return;
1590 if (m_face_uvs.empty() || m_face_tex_ids.empty()) return;
1591 if (m_face_uvs.size() != m_indices.size()) return;
1592
1594
1595 const bool has_smooth = (m_vertex_normals.size() == m_vertices.size());
1596
1597 // Group faces by texture id for batch rendering
1598 std::map<int, std::vector<size_t>> tex_groups;
1599 for (size_t fi = 0; fi < m_indices.size(); ++fi) {
1600 int tid = (fi < m_face_tex_ids.size()) ? m_face_tex_ids[fi] : -1;
1601 tex_groups[tid].push_back(fi);
1602 }
1603
1605 glColor3f(1.0f, 1.0f, 1.0f);
1606
1607 for (const auto& [tid, face_list] : tex_groups) {
1608 bool tex_bound = false;
1609 if (tid >= 0 && tid < (int)m_gl_tex_ids.size() && m_gl_tex_ids[tid] != 0) {
1612 tex_bound = true;
1613 } else {
1615 }
1616
1618 for (size_t fi : face_list) {
1619 const auto& face = m_indices[fi];
1620 const auto& uvs = m_face_uvs[fi];
1621
1622 if (!tex_bound) {
1623 if (fi < m_original_face_colors_rgb.size())
1625 else
1626 glColor3f(0.7f, 0.7f, 0.7f);
1627 }
1628
1629 for (int vi = 0; vi < 3; ++vi) {
1630 int idx = face[vi];
1631 if (idx < 0 || idx >= (int)m_vertices.size()) continue;
1632
1633 if (has_smooth) {
1634 glNormal3fv(m_vertex_normals[idx].data());
1635 } else if (vi == 0) {
1636 const auto& v0 = m_vertices[face[0]];
1637 const auto& v1 = m_vertices[face[1]];
1638 const auto& v2 = m_vertices[face[2]];
1639 float nx = (v1[1]-v0[1])*(v2[2]-v0[2]) - (v1[2]-v0[2])*(v2[1]-v0[1]);
1640 float ny = (v1[2]-v0[2])*(v2[0]-v0[0]) - (v1[0]-v0[0])*(v2[2]-v0[2]);
1641 float nz = (v1[0]-v0[0])*(v2[1]-v0[1]) - (v1[1]-v0[1])*(v2[0]-v0[0]);
1642 float len = std::sqrt(nx*nx + ny*ny + nz*nz);
1643 if (len > 1e-8f) { nx /= len; ny /= len; nz /= len; }
1644 glNormal3f(nx, ny, nz);
1645 }
1646
1647 if (tex_bound)
1648 glTexCoord2fv(uvs[vi].data());
1649 glVertex3fv(m_vertices[idx].data());
1650 }
1651 }
1652 glEnd();
1653 }
1654
1657}
void upload_textures()
Definition TextureImportDialog.cpp:1153
std::vector< int > m_face_tex_ids
Definition TextureImportDialog.hpp:180
#define glTexCoord2fv
Definition gl.h:4813

References GL_LIGHTING, GL_TEXTURE_2D, GL_TRIANGLES, glBegin, glBindTexture, glColor3f, glColor3fv, glDisable, glEnable, glEnd, glNormal3f, glNormal3fv, glTexCoord2fv, glVertex3fv, m_face_tex_ids, m_face_uvs, m_gl_tex_ids, m_indices, m_original_face_colors_rgb, m_vertex_normals, m_vertices, and upload_textures().

Referenced by render_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_overlay_rect()

wxRect Slic3r::GUI::TexturePreviewCanvas::reset_overlay_rect ( ) const
private
1253{
1254 wxSize sz = GetClientSize();
1255 const int button_size = FromDIP(40);
1256 const int margin = FromDIP(20);
1257 return wxRect(
1258 std::max(margin, sz.x - button_size - margin),
1259 std::max(margin, sz.y - button_size - margin),
1260 button_size,
1261 button_size);
1262}

Referenced by handle_reset_overlay_mouse(), and render_reset_overlay().

Here is the caller graph for this function:

◆ reset_view()

void Slic3r::GUI::TexturePreviewCanvas::reset_view ( )
1243{
1244 m_zoom = 1.0f;
1245 m_rot_x = -30.0f;
1246 m_rot_y = 30.0f;
1247 m_pan_x = 0.0f;
1248 m_pan_y = 0.0f;
1249 Refresh();
1250}

References m_pan_x, m_pan_y, m_rot_x, m_rot_y, and m_zoom.

Referenced by handle_reset_overlay_mouse().

Here is the caller graph for this function:

◆ set_computing_overlay()

void Slic3r::GUI::TexturePreviewCanvas::set_computing_overlay ( bool show)
1238{
1239 Refresh();
1240}

◆ set_face_colors()

void Slic3r::GUI::TexturePreviewCanvas::set_face_colors ( const std::vector< std::array< std::size_t, 3 > > & face_colors)
1198{
1200 Refresh();
1201}
static void convert_face_colors(const std::vector< std::array< std::size_t, 3 > > &src, std::vector< std::array< float, 3 > > &dst)
Definition TextureImportDialog.cpp:1189

References Slic3r::GUI::convert_face_colors(), and m_face_colors_rgb.

Here is the call graph for this function:

◆ set_filament_color_map()

void Slic3r::GUI::TexturePreviewCanvas::set_filament_color_map ( const std::map< std::array< std::size_t, 3 >, std::array< float, 3 > > & color_map)
1211{
1212 m_color_map = color_map;
1214 for (size_t i = 0; i < m_face_colors_rgb.size(); ++i) {
1215 std::array<std::size_t, 3> key = {
1216 (std::size_t)(m_face_colors_rgb[i][0] * 255.f + 0.5f),
1217 (std::size_t)(m_face_colors_rgb[i][1] * 255.f + 0.5f),
1218 (std::size_t)(m_face_colors_rgb[i][2] * 255.f + 0.5f)
1219 };
1220 auto it = color_map.find(key);
1221 if (it != color_map.end())
1222 m_filament_colors_rgb[i] = it->second;
1223 else
1225 }
1226 Refresh();
1227}
std::map< std::array< std::size_t, 3 >, std::array< float, 3 > > m_color_map
Definition TextureImportDialog.hpp:166

References m_color_map, m_face_colors_rgb, and m_filament_colors_rgb.

◆ set_mesh_data()

void Slic3r::GUI::TexturePreviewCanvas::set_mesh_data ( const std::vector< std::array< float, 3 > > & vertices,
const std::vector< std::array< int, 3 > > & indices )
1081{
1082 m_vertices = vertices;
1083 m_indices = indices;
1086 Refresh();
1087}
void compute_smooth_normals()
Definition TextureImportDialog.cpp:1089
void update_bounding_box()
Definition TextureImportDialog.cpp:1370

References compute_smooth_normals(), m_indices, m_vertices, and update_bounding_box().

Here is the call graph for this function:

◆ set_original_face_colors()

void Slic3r::GUI::TexturePreviewCanvas::set_original_face_colors ( const std::vector< std::array< std::size_t, 3 > > & face_colors)
1204{
1206 Refresh();
1207}

References Slic3r::GUI::convert_face_colors(), and m_original_face_colors_rgb.

Here is the call graph for this function:

◆ set_painted_mesh_data()

void Slic3r::GUI::TexturePreviewCanvas::set_painted_mesh_data ( const std::vector< std::array< float, 3 > > & vertices,
const std::vector< std::array< int, 3 > > & indices )
1183{
1184 m_painted_vertices = vertices;
1185 m_painted_indices = indices;
1186 Refresh();
1187}

References m_painted_indices, and m_painted_vertices.

◆ set_render_mode()

void Slic3r::GUI::TexturePreviewCanvas::set_render_mode ( RenderMode mode)
1230{
1231 if (m_mode != mode) {
1232 m_mode = mode;
1233 Refresh();
1234 }
1235}

References m_mode.

◆ set_texture_data()

void Slic3r::GUI::TexturePreviewCanvas::set_texture_data ( const std::vector< std::array< float, 2 > > & uvs,
const unsigned char * tex_data,
int tex_w,
int tex_h,
int tex_channels )
1125{
1126 m_uvs = uvs;
1127 m_tex_w = tex_w;
1128 m_tex_h = tex_h;
1129 m_tex_channels = tex_channels;
1130 m_tex_dirty = true;
1131
1132 size_t sz = (size_t)tex_w * tex_h * tex_channels;
1133 m_tex_data.assign(tex_data, tex_data + sz);
1134 Refresh();
1135}
int m_tex_h
Definition TextureImportDialog.hpp:170
std::vector< std::array< float, 2 > > m_uvs
Definition TextureImportDialog.hpp:160
int m_tex_w
Definition TextureImportDialog.hpp:169
std::vector< unsigned char > m_tex_data
Definition TextureImportDialog.hpp:173
bool m_tex_dirty
Definition TextureImportDialog.hpp:172
int m_tex_channels
Definition TextureImportDialog.hpp:171

References m_tex_channels, m_tex_data, m_tex_dirty, m_tex_h, m_tex_w, and m_uvs.

◆ set_texture_render_data()

void Slic3r::GUI::TexturePreviewCanvas::set_texture_render_data ( const std::vector< std::vector< unsigned char > > & tex_pixels_rgb,
const std::vector< int > & tex_widths,
const std::vector< int > & tex_heights,
const std::vector< std::array< std::array< float, 2 >, 3 > > & face_uvs,
const std::vector< int > & face_tex_ids )
1143{
1144 m_tex_pixels_rgb = tex_pixels_rgb;
1145 m_tex_widths = tex_widths;
1146 m_tex_heights = tex_heights;
1147 m_face_uvs = face_uvs;
1148 m_face_tex_ids = face_tex_ids;
1149 m_multi_tex_dirty = true;
1150 Refresh();
1151}
bool m_multi_tex_dirty
Definition TextureImportDialog.hpp:181
std::vector< int > m_tex_heights
Definition TextureImportDialog.hpp:178
std::vector< int > m_tex_widths
Definition TextureImportDialog.hpp:177
std::vector< std::vector< unsigned char > > m_tex_pixels_rgb
Definition TextureImportDialog.hpp:176

References m_face_tex_ids, m_face_uvs, m_multi_tex_dirty, m_tex_heights, m_tex_pixels_rgb, and m_tex_widths.

◆ update_bounding_box()

void Slic3r::GUI::TexturePreviewCanvas::update_bounding_box ( )
private
1371{
1372 if (m_vertices.empty()) return;
1373 std::array<float, 3> mn = m_vertices[0], mx = m_vertices[0];
1374 for (const auto& v : m_vertices) {
1375 for (int i = 0; i < 3; ++i) {
1376 mn[i] = std::min(mn[i], v[i]);
1377 mx[i] = std::max(mx[i], v[i]);
1378 }
1379 }
1380 m_center = { (mn[0]+mx[0])/2, (mn[1]+mx[1])/2, (mn[2]+mx[2])/2 };
1381 float dx = mx[0]-mn[0], dy = mx[1]-mn[1], dz = mx[2]-mn[2];
1382 m_radius = std::sqrt(dx*dx + dy*dy + dz*dz) / 2.0f;
1383 if (m_radius < 1e-6f) m_radius = 1.0f;
1384}

References m_center, m_radius, and m_vertices.

Referenced by set_mesh_data().

Here is the caller graph for this function:

◆ upload_reset_icon_texture()

unsigned int Slic3r::GUI::TexturePreviewCanvas::upload_reset_icon_texture ( const std::string & icon_name)
private
1265{
1266 wxBitmap bmp = create_scaled_bitmap(icon_name, this, 40);
1267 if (!bmp.IsOk())
1268 return 0;
1269
1270 wxImage image = bmp.ConvertToImage();
1271 if (!image.IsOk())
1272 return 0;
1273
1274 const int w = image.GetWidth();
1275 const int h = image.GetHeight();
1276 const unsigned char* rgb = image.GetData();
1277 const unsigned char* alpha = image.HasAlpha() ? image.GetAlpha() : nullptr;
1278 if (!rgb || w <= 0 || h <= 0)
1279 return 0;
1280
1281 std::vector<unsigned char> rgba((size_t)w * h * 4);
1282 for (int i = 0; i < w * h; ++i) {
1283 rgba[(size_t)i * 4 + 0] = rgb[i * 3 + 0];
1284 rgba[(size_t)i * 4 + 1] = rgb[i * 3 + 1];
1285 rgba[(size_t)i * 4 + 2] = rgb[i * 3 + 2];
1286 rgba[(size_t)i * 4 + 3] = alpha ? alpha[i] : 255;
1287 }
1288
1289 GLuint tex_id = 0;
1290 glGenTextures(1, &tex_id);
1297 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba.data());
1299 return tex_id;
1300}
#define GL_TEXTURE_MIN_FILTER
Definition gl.h:1828
#define GL_TEXTURE_WRAP_S
Definition gl.h:1854
#define glPixelStorei
Definition gl.h:4451
#define GL_LINEAR
Definition gl.h:930
#define glTexParameteri
Definition gl.h:4911
#define glTexImage2D
Definition gl.h:4895
#define GL_UNSIGNED_BYTE
Definition gl.h:1937
#define glGenTextures
Definition gl.h:3787
#define GL_UNPACK_ALIGNMENT
Definition gl.h:1924
#define GL_RGBA
Definition gl.h:1493
unsigned int GLuint
Definition gl.h:2063
#define GL_TEXTURE_WRAP_T
Definition gl.h:1855
#define GL_TEXTURE_MAG_FILTER
Definition gl.h:1822
#define GL_CLAMP_TO_EDGE
Definition gl.h:322
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References create_scaled_bitmap(), GL_CLAMP_TO_EDGE, GL_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glTexImage2D, and glTexParameteri.

Referenced by upload_reset_icon_textures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upload_reset_icon_textures()

void Slic3r::GUI::TexturePreviewCanvas::upload_reset_icon_textures ( )
private
1303{
1305 return;
1306
1307 if (!m_reset_icon_tex)
1314 m_reset_icon_dark_hover_tex = upload_reset_icon_texture("canvas_zoom_dark_hover");
1315}
unsigned int upload_reset_icon_texture(const std::string &icon_name)
Definition TextureImportDialog.cpp:1264

References m_reset_icon_dark_hover_tex, m_reset_icon_dark_tex, m_reset_icon_hover_tex, m_reset_icon_tex, and upload_reset_icon_texture().

Referenced by render_reset_overlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upload_textures()

void Slic3r::GUI::TexturePreviewCanvas::upload_textures ( )
private
1154{
1155 if (!m_multi_tex_dirty) return;
1156 m_multi_tex_dirty = false;
1157
1158 for (unsigned int id : m_gl_tex_ids)
1159 if (id) glDeleteTextures(1, &id);
1160 m_gl_tex_ids.clear();
1161
1162 m_gl_tex_ids.resize(m_tex_pixels_rgb.size(), 0);
1163 for (size_t i = 0; i < m_tex_pixels_rgb.size(); ++i) {
1164 if (m_tex_pixels_rgb[i].empty() || m_tex_widths[i] <= 0 || m_tex_heights[i] <= 0)
1165 continue;
1166 GLuint tex_id = 0;
1167 glGenTextures(1, &tex_id);
1175 m_gl_tex_ids[i] = tex_id;
1176 }
1178}
#define GL_RGB
Definition gl.h:1471
#define GL_REPEAT
Definition gl.h:1453
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References Slic3r::empty(), GL_LINEAR, GL_REPEAT, GL_RGB, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_UNSIGNED_BYTE, glBindTexture, glDeleteTextures, glGenTextures, glTexImage2D, glTexParameteri, m_gl_tex_ids, m_multi_tex_dirty, m_tex_heights, m_tex_pixels_rgb, and m_tex_widths.

Referenced by render_textured_original().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_center

std::array<float, 3> Slic3r::GUI::TexturePreviewCanvas::m_center = {0, 0, 0}
private
185{0, 0, 0};

Referenced by render(), and update_bounding_box().

◆ m_color_map

std::map<std::array<std::size_t, 3>, std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_color_map
private

Referenced by set_filament_color_map().

◆ m_context

wxGLContext* Slic3r::GUI::TexturePreviewCanvas::m_context = nullptr
private

◆ m_drag_mode

DragMode Slic3r::GUI::TexturePreviewCanvas::m_drag_mode = DragMode::None
private

◆ m_face_colors_rgb

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_face_colors_rgb
private

◆ m_face_tex_ids

std::vector<int> Slic3r::GUI::TexturePreviewCanvas::m_face_tex_ids
private

◆ m_face_uvs

std::vector<std::array<std::array<float,2>, 3> > Slic3r::GUI::TexturePreviewCanvas::m_face_uvs
private

◆ m_filament_colors_rgb

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_filament_colors_rgb
private

◆ m_gl_initialized

bool Slic3r::GUI::TexturePreviewCanvas::m_gl_initialized = false
private

Referenced by ensure_gl_ready().

◆ m_gl_tex_ids

std::vector<unsigned int> Slic3r::GUI::TexturePreviewCanvas::m_gl_tex_ids
private

◆ m_indices

std::vector<std::array<int, 3> > Slic3r::GUI::TexturePreviewCanvas::m_indices
private

◆ m_last_mouse_pos

wxPoint Slic3r::GUI::TexturePreviewCanvas::m_last_mouse_pos
private

Referenced by on_mouse().

◆ m_mode

RenderMode Slic3r::GUI::TexturePreviewCanvas::m_mode = RenderMode::Original
private

◆ m_multi_tex_dirty

bool Slic3r::GUI::TexturePreviewCanvas::m_multi_tex_dirty = false
private

◆ m_original_face_colors_rgb

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_original_face_colors_rgb
private

◆ m_painted_indices

std::vector<std::array<int, 3> > Slic3r::GUI::TexturePreviewCanvas::m_painted_indices
private

◆ m_painted_vertices

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_painted_vertices
private

◆ m_pan_x

float Slic3r::GUI::TexturePreviewCanvas::m_pan_x = 0.0f
private

Referenced by on_mouse(), render(), and reset_view().

◆ m_pan_y

float Slic3r::GUI::TexturePreviewCanvas::m_pan_y = 0.0f
private

Referenced by on_mouse(), render(), and reset_view().

◆ m_radius

float Slic3r::GUI::TexturePreviewCanvas::m_radius = 1.0f
private

◆ m_reset_icon_dark_hover_tex

unsigned int Slic3r::GUI::TexturePreviewCanvas::m_reset_icon_dark_hover_tex = 0
private

◆ m_reset_icon_dark_tex

unsigned int Slic3r::GUI::TexturePreviewCanvas::m_reset_icon_dark_tex = 0
private

◆ m_reset_icon_hover_tex

unsigned int Slic3r::GUI::TexturePreviewCanvas::m_reset_icon_hover_tex = 0
private

◆ m_reset_icon_tex

unsigned int Slic3r::GUI::TexturePreviewCanvas::m_reset_icon_tex = 0
private

◆ m_reset_overlay_hovered

bool Slic3r::GUI::TexturePreviewCanvas::m_reset_overlay_hovered = false
private

◆ m_reset_overlay_pressed

bool Slic3r::GUI::TexturePreviewCanvas::m_reset_overlay_pressed = false
private

◆ m_rot_x

float Slic3r::GUI::TexturePreviewCanvas::m_rot_x = -30.0f
private

Referenced by on_mouse(), render(), and reset_view().

◆ m_rot_y

float Slic3r::GUI::TexturePreviewCanvas::m_rot_y = 30.0f
private

Referenced by on_mouse(), render(), and reset_view().

◆ m_tex_channels

int Slic3r::GUI::TexturePreviewCanvas::m_tex_channels = 3
private

Referenced by set_texture_data().

◆ m_tex_data

std::vector<unsigned char> Slic3r::GUI::TexturePreviewCanvas::m_tex_data
private

Referenced by set_texture_data().

◆ m_tex_dirty

bool Slic3r::GUI::TexturePreviewCanvas::m_tex_dirty = false
private

Referenced by set_texture_data().

◆ m_tex_h

int Slic3r::GUI::TexturePreviewCanvas::m_tex_h = 0
private

Referenced by set_texture_data().

◆ m_tex_heights

std::vector<int> Slic3r::GUI::TexturePreviewCanvas::m_tex_heights
private

◆ m_tex_id

unsigned int Slic3r::GUI::TexturePreviewCanvas::m_tex_id = 0
private

Referenced by ~TexturePreviewCanvas().

◆ m_tex_pixels_rgb

std::vector<std::vector<unsigned char> > Slic3r::GUI::TexturePreviewCanvas::m_tex_pixels_rgb
private

◆ m_tex_w

int Slic3r::GUI::TexturePreviewCanvas::m_tex_w = 0
private

Referenced by set_texture_data().

◆ m_tex_widths

std::vector<int> Slic3r::GUI::TexturePreviewCanvas::m_tex_widths
private

◆ m_uvs

std::vector<std::array<float, 2> > Slic3r::GUI::TexturePreviewCanvas::m_uvs
private

Referenced by set_texture_data().

◆ m_vertex_normals

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_vertex_normals
private

◆ m_vertices

std::vector<std::array<float, 3> > Slic3r::GUI::TexturePreviewCanvas::m_vertices
private

◆ m_zoom

float Slic3r::GUI::TexturePreviewCanvas::m_zoom = 1.0f
private

Referenced by on_mouse(), render(), and reset_view().


The documentation for this class was generated from the following files: