Commit Graph

14 Commits

Author SHA1 Message Date
Ian Bassi
f8b0bcc725 Add Kinematics (Jerk & Accel) visualization support (#13169)
* Acceleration preview

Co-Authored-By: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>

* Jerk visualization

* JD

---------

Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
2026-04-24 14:20:47 +08:00
Rodrigo Faselli
b742068426 fix seams glitch linux (#13233)
Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
Co-authored-by: yw4z <yw4z@outlook.com>
2026-04-19 18:47:19 -03:00
SoftFever
3e4af2c723 WIP: Add native Wayland support for Linux (#13197)
* Add runtime display backend detection for Wayland support

Add LinuxDisplayBackend utility to detect X11 vs Wayland at runtime
using GDK_IS_X11_DISPLAY / GDK_IS_WAYLAND_DISPLAY macros. This is
the foundation for removing the forced GDK_BACKEND=x11 and enabling
native Wayland support.

- New files: LinuxDisplayBackend.hpp/.cpp with get_linux_display_backend(),
  is_running_on_wayland(), and is_running_on_x11()
- Propagate wxHAVE_GDK_X11 / wxHAVE_GDK_WAYLAND from FindGTK3.cmake
  as compile definitions to libslic3r_gui
- No-op on non-Linux platforms (returns Unknown / false)

* Fix Phase 1 code quality: pragma once, source ordering, static cache

* Make X11 initialization conditional for Wayland support

Remove the unconditional GDK_BACKEND=x11 force that blocked native
Wayland. Replace with conditional logic:

- EGL safety fallback: re-force X11 only when wxUSE_GLCANVAS_EGL is
  off and WAYLAND_DISPLAY is set, with a warning log
- XInitThreads() only called when DISPLAY is set (X11 in use)
- __GLX_VENDOR_LIBRARY_NAME only set when DISPLAY is present (GLX-specific)
- WEBKIT_DISABLE_COMPOSITING_MODE only set under XWayland (both
  DISPLAY and WAYLAND_DISPLAY present)
- Guard X11/Xlib.h include with __has_include for robustness
- Restore display validation to accept either DISPLAY or WAYLAND_DISPLAY

This is Phase 2 of the Wayland support plan.

* Fix Phase 2: safer EGL macro check, add clarifying comments

* Add GLAD2 library and replace GLEW linkage in build system

Set up GLAD2 as a static library to replace GLEW for OpenGL loading.
GLAD2 supports both GLX and EGL, which is required for Wayland support.

- Create src/glad/ with pre-generated GLAD2 sources (GL 4.6 compat)
- Add src/glad/CMakeLists.txt building glad as a static library
- Wire glad into src/CMakeLists.txt before libvgcode
- Modify libvgcode to use shared glad for GL path (keeps local copy
  only for GLES2/Emscripten) to avoid duplicate symbol conflicts
- Replace GLEW::GLEW with glad in libslic3r_gui link libraries

Note: GLEW is kept in deps for OpenCSG. Code migration from GL/glew.h
to glad/gl.h headers will follow in Phase 3B+3C.

* Fix Phase 3A+3D: libvgcode GLAD include, dead files, dlopen dep, OpenGL link var

* Migrate from GLEW to GLAD: replace headers and API calls across codebase

Replace all #include <GL/glew.h> with <glad/gl.h> across 49 source files.
Migrate GLEW API calls to GLAD equivalents:
- glewInit/glewExperimental -> gladLoaderLoadGL()
- GLEW_EXT_* / GLEW_ARB_* extension checks -> GLAD_GL_EXT_* / GLAD_GL_ARB_*
- Remove GLEW-specific EGL/GLX mismatch #error guards (not needed with GLAD)
- Replace unavailable EXT symbols with core GL equivalents in
  GLCanvas3D.cpp (GL_MAX_SAMPLES, glRenderbufferStorageMultisample,
  glBlitFramebuffer, GL_READ/DRAW_FRAMEBUFFER)
- Update log messages from glewInit to gladLoadGL

* Fix Phase 3B+3C: remove GLEW find, clean EXT symbols, update attribution

- Remove find_package(GLEW) block from root CMakeLists.txt since GLEW
  is no longer linked by any main application code
- Remove "glew" from SLIC3R_STATIC option description
- Replace all remaining EXT framebuffer symbols with core equivalents
  in render_thumbnail_framebuffer_ext and _rectangular_selection_picking_pass
- Update AboutDialog credits from GLEW to GLAD

* Enable EGL in wxWidgets and add runtime GLX/EGL selection for Wayland

- Set wxUSE_GLCANVAS_EGL=ON in wxWidgets build and Flatpak manifest
- Add PreferGLX() call on X11 sessions for driver compatibility
- Remove Phase 2 safety fallback (EGL is now always compiled in)
- Guard SwapBuffers against hidden canvases to prevent Wayland stalls

* Fix Phase 4: move PreferGLX to app startup, fix FPS counter guard

Move wxGLCanvas::PreferGLX() from OpenGLManager::create_wxglcanvas()
(static initializer) to GUI_App::on_init_inner() before any wxGLCanvas
is constructed. This prevents a race where SkipPartCanvas could trigger
wxGLBackend::Init() before the GLX preference is set. The new location
also adds explicit is_running_on_wayland() detection with a warning for
unknown backends.

Move increment_fps_counter() inside the IsShownOnScreen() guard so FPS
is only counted when a frame is actually swapped.

* Update GLFW from 3.3.7 to 3.4 for runtime Wayland/X11 backend selection

Replace the compile-time GLFW_USE_WAYLAND flag (which locked to a single
backend) with GLFW 3.4's GLFW_BUILD_WAYLAND + GLFW_BUILD_X11 flags that
build both backends and auto-select at runtime based on the available
display server. This enables the CLI thumbnail renderer to work on both
Wayland and X11 sessions without separate builds.

* wayland: Fix UI call sites that rely on global screen coordinates

On Wayland, wxGetMousePosition() returns (0,0) and SetPosition() is a
no-op for top-level windows. Fix the highest-impact call sites:

- GLCanvas3D: Use cached m_mouse.position from event handlers instead
  of wxGetMousePosition() + ScreenToClient() in get_local_mouse_position()
- Plater: Use event-relative coords via ClientToScreen(e.GetPosition())
  instead of wxGetMousePosition() in 3 leave-window handlers
- BBLTopbar: Use event.GetPosition() and FindToolByPosition() directly
  in mouse handlers instead of wxGetMousePosition()/FindToolByCurrentPosition()
- Search: Use focus-based dismiss logic on Wayland instead of
  wxGetMousePosition()-based rect checks in SearchDialog and
  SearchObjectDialog
- GUI_App: Skip SetPosition() in window_pos_restore() on Wayland where
  it is a no-op; still restore size and maximize state
- Button: Position tooltip relative to button widget via ClientToScreen
  instead of wxGetMousePosition()

* Fix SearchDialog Wayland dismiss: guard against search_line focus

* flatpak: Add Wayland socket permission for native Wayland support

* spec

* Fix crash on Wayland when wxWidgets lacks EGL support

Restore the safety fallback that forces GDK_BACKEND=x11 when wxWidgets
was not built with wxUSE_GLCANVAS_EGL=ON. Without this, the GLX backend
tries to access a non-existent X11 display on native Wayland, crashing
in wxGLCanvas::IsDisplaySupported() with SIGSEGV at offset 0xe4.

Also add a defense-in-depth guard in detect_multisample() that skips
the IsDisplaySupported call entirely on Wayland without EGL.

Root cause: deps/wxWidgets must be rebuilt after enabling EGL. The
compile-time check in OrcaSlicer.cpp detects the mismatch and falls
back safely.

* Fix EGL detection: use wxHAS_EGL instead of wxUSE_GLCANVAS_EGL

wxUSE_GLCANVAS_EGL is a CMake build option, NOT a C++ preprocessor
macro. The actual macro defined in wxWidgets setup.h is wxHAS_EGL.
All compile-time EGL checks were using the wrong macro, causing
the safety fallback to always trigger even with a properly built
EGL-enabled wxWidgets.

* Fix GL function pointers invalidated on Wayland/EGL

gladLoaderLoadGL() dlopen's libGL.so.1 to resolve GL function pointers
via dlsym, then immediately dlclose's the handle. On X11/GLX this is
fine because the GLX context keeps libGL.so mapped. On Wayland/EGL,
nothing else holds libGL.so open, so dlclose unmaps it and all function
pointers become dangling — causing SIGSEGV on the first GL call.

Fix: on Wayland, use gladLoadGL(eglGetProcAddress) which resolves
function pointers through the EGL loader without opening/closing
libGL.so.

* fix crash on start and various rendering issues

* fix crash on close

* small refactor

* move GPU selection to desktop file

* clean up a bit

* clean up more

* fix appimage error
2026-04-13 19:45:39 +08:00
tome9111991
97da125d62 FIX: hidden Line Type Linux (#12364)
Fix(GCodeViewer): Resolve z-fighting for wipe, seam, and retract markers using shader depth bias

Co-authored-by: SoftFever <softfeverever@gmail.com>
2026-03-10 15:28:21 +08:00
minicx
7e1b2d99d3 Add Pressure Advance visualization support (#11673)
* Add Pressure Advance visualization support

Signed-off-by: minicx <minicx@disroot.org>

* Port Pressure Advance visualization to libvgcode architecture

Adapt PA visualization (originally in commit e3a77259) to work with
the new libvgcode library introduced by upstream PR #10735.

Changes across the libvgcode stack:
- PathVertex: add pressure_advance field
- Types.hpp: add PressureAdvance to EViewType enum
- ViewerImpl: add ColorRange, color mapping, range updates for PA
- LibVGCodeWrapper: pass pressure_advance from MoveVertex to PathVertex

GCodeViewer UI integration:
- Add "Pressure Advance" to view type dropdown
- Add PA color range in legend (3 decimal places)
- Add PA value display in sequential view marker tooltip
- Add PA row in position properties table

The GCodeProcessor PA parsing (M900, M572, SET_PRESSURE_ADVANCE)
is preserved from the original implementation.

* Tag Pressure Advance visualization changes with ORCA comments

Signed-off-by: minicx <minicx@disroot.org>

---------

Signed-off-by: minicx <minicx@disroot.org>
Co-authored-by: Ioannis Giannakas <59056762+igiannakas@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-21 13:10:08 +00:00
SoftFever
779f4a890d QoL: improve gcode marker (#11881)
QoL: Improve gcode marker
2026-01-09 11:52:30 +08:00
SoftFever
3b4600d65b fix some minor issues 2026-01-06 18:19:50 +08:00
Kiss Lorand
a87df7f0b5 Bugfixes (#2)
* Bugfixes

* Reduce size of diff

to avoid merge conflicts when we cherry-pick from upstream :)

* remove extraneous space

---------

Co-authored-by: Andrew Sun <as-com@users.noreply.github.com>
2025-11-18 19:50:48 -05:00
Andrew Sun
32ce7494c0 Adjust shaders to increase shadows/contrast between layers 2025-11-16 11:34:56 -05:00
Morton Jonuschat
8a1e0ee9bb feat: Reduce size of option marker in G-Code preview 2025-11-16 11:22:39 -05:00
Andrew Sun
7814605906 Merge remote-tracking branch 'upstream/main' into libvgcode
# Conflicts:
#	src/libslic3r/GCode/GCodeProcessor.cpp
#	src/libslic3r/GCode/GCodeProcessor.hpp
#	src/slic3r/CMakeLists.txt
#	src/slic3r/GUI/GCodeViewer.cpp
#	src/slic3r/GUI/GCodeViewer.hpp
#	src/slic3r/GUI/GLCanvas3D.cpp
#	src/slic3r/GUI/GLCanvas3D.hpp
#	src/slic3r/GUI/GUI_Preview.cpp
2025-11-15 11:11:20 -05:00
Andrew Sun
25c19c94b5 Enable seam visibility by default 2025-09-24 22:49:14 -04:00
Andrew Sun
d539540a65 Add support for Orca-specific extrusion roles 2025-09-24 22:49:14 -04:00
Andrew Sun
c92328c9cc Port libvgcode from PrusaSlicer 2.8.0
Includes (but is not limited to) the following commits:

SPE-2218 - libvgcode - Fixed color of wipe moves for speed range view
SPE-2218 - libvgcode - Fixed detection of fan speed range
SPE-2218 - libvgcode - Fixed detection of temperature range
SPE-2218 - libvgcode - Fixed colors for Actual volumetric flow rate view
SPE-2214 - Fixed detection of toolpaths bounding box in GCodeViewer
SPE-2206 - Modified LibBGCode.cmake to get latest version of libbgcode which fixed parsing of gcode lines G4
libvgcode - Fixed potential out of bound access in ViewerImpl::update_view_full_range()
Tech ENABLE_GL_CORE_PROFILE set as default
Tech ENABLE_OPENGL_ES replaced by build option SLIC3R_OPENGL_ES
libvgcode - Precompiler definition of ENABLE_OPENGL_ES moved into CMakeLists.txt
Added missing include
libvgcode - Textures setup modified to work when building using emscripten
libvgcode - small optimization
libvgcode - fixed OpenGLWrapper::unload_opengl()
libvgcode - CMakeLists.txt modified to work with emscripten
libvgcode - Replace 'glVertexAttribIPointer()' with 'glVertexAttribPointer()' in SegmentTemplate::init() for OpenGL ES
libvgcode - Replace 'xor' with '^' Bitset.hpp
libvgcode - Newer glad library for OpenGL 4.6 and OpenGL ES 3.0
libvgcode - Alternate fix in method ViewerImpl::update_heights_widths() for OpenGL ES
libvgcode - Fixes in glAssertRecentCallImpl()
libvgcode - Fixes in method ViewerImpl::update_heights_widths() for OpenGL ES
Fixed ES shaders so they work with OpenGL ES 3.0
libvgcode - Use multiple plain textures in place of texture buffers for OpenGL ES
libvgcode - Use plain textures in place of texture buffers for OpenGL ES (partial implementation using one texture per buffer)
libvgcode - refactoring of class OpenGLWrapper
libvgcode - small refactoring in shaders
libvgcode - replacement of glMapBuffer() call for OpenGL ES
Fixed warning
libvgcode - Changes into CMakeLists.txt
Fixed debug export of gcode data to be configuration indipendent
Disabled tech ENABLE_NEW_GCODE_VIEWER_DEBUG
Removed obsolete tech ENABLE_GCODE_VIEWER_DATA_CHECKING
Code cleanup and techs removal - completed
Code cleanup and techs removal - step 1
SPE-1872: Implemented G2/G3 lines discretization for gcfMarlinFirmware firmware flavour
SPE-1872: Corrections into GCodeProcessor::process_G2_G3() to match firmware code
SPE-1872: Actual speed profile - Further enhancements of imgui debug window
SPE-1872: Actual speed profile - Rework in its calculation + enhanced imgui debug window
SPE-1872: New imgui widget to show actual speed profile
SPE-1872: Fixed actual speed for seam moves and at extrusion/travel/wipe start
SPE-1872: Fixed rendering of wipe moves when actual speed view is selected
SPE-1872: Actual speed profile extended to travel and wipe moves
SPE-1872: Fixes in function recalculate_trapezoids() and method GCodeProcessor::TimeMachine::calculate_time() to smooth actual speed profile
SPE-1872: Added debug graphic to show move actual speed profile
SPE-1872: libvgcode library: replace volumetric flow rate data with mm3_per_mm to reduce memory usage
SPE-1872: Added visualization of actual volumetric flow rate
SPE-1872: Fixes in calculating actual speed
SPE-1872: Added visualization of actual speed in gcode preview
SPE-2124: Added command line option 'opengl-aa' to allow the user to turn on the automatic selection of max number of supported samples for OpenGL antialising
#12117: Reduced moire patterns by using the highest number of samples available for multisampling
New gcode visualization integration - Partially enabled imgui debug window
New gcode visualization integration - Fixed center of gravity calculation and rendering
New gcode visualization library - Interface for estimated times
New gcode visualization library - Tool marker rendering
New gcode visualization library - Axes aligned bounding boxes calculation
Removed obsolete debug code
New gcode visualization library - Added statistic of used memory
New gcode visualization library - Separation of tool colors and color changes colors to simplify client code
Added missing include
New gcode visualization library - Added print color changes detection
New gcode visualization library - Modified OpenGL ES context detection
New gcode visualization library - Another makefile cleanup
New gcode visualization library - Makefiles cleanup
New gcode visualization library - Added suppression of error 'This function or variable may be unsafe' in VS2022
New gcode visualization library - Compatibility with OpenGL ES
New gcode visualization library - Interface cleanup and documentation
New gcode visualization library - Extended interface to give access to estimated times
New gcode visualization integration - Toggling of top layer only view state
New gcode visualization integration - Removed imperial units from tool position data
Small refactoring
New gcode visualization library - Custom values for travel and wipe moves radius
New gcode visualization library - Allow customization of range colors
New gcode visualization library - Partial update of interface comments/documentation
New gcode visualization integration - Follow-up of 35ee55e29bb231fd01a2eb71ae293832a37ca65d - Better fix for toolpaths visible range when toggling options' visibility
New gcode visualization integration - Fixed toolpaths reset
New gcode visualization library - Fixed method set_option_color()
New gcode visualization library - Fixed method ViewerImpl::set_extrusion_role_color()
New gcode visualization library - Added methods to release gpu resources on demand.
New gcode visualization library - Travel and wipe moves as options
New gcode visualization integration - Fixed toolpaths visible range when toggling options' visibility
New gcode visualization integration - Fixed management of gcode preview view type
New gcode visualization - Fixed wrong include
New gcode visualization - Added missing headers
New gcode visualization - Refactoring + added missing headers
New gcode visualization - New code set as standalone library + embed glad library to load OpenGL functions
New gcode visualization - Fixed errors and warnings when building the new code as a standalone library
New gcode visualization integration - Fixed layers ordering in pre-gcode preview
New gcode visualization integration - Fixed objects' tool colors in pre-gcode preview
Code cleanup
New gcode visualization integration - Tool position properties data window
New gcode visualization integration - Fixed in export toolpaths to obj
New gcode visualization - Inlining in source code
Refactoring
New gcode visualization integration - Export toolpaths to obj
Some refactoring and warning fix
New gcode visualization integration - Customizable travel moves colors
New gcode visualization integration - Customizable options colors
New gcode visualization integration - Customizable extrusion roles colors
New gcode visualization integration - Fixed pre-gcode preview layers times
New gcode visualization integration - Modify pre-gcode preview to use the new toolpaths renderer, objects WIP
New gcode visualization - Modify pre-gcode preview to use the new toolpaths renderer, WIP (brim/skirt/wipe tower)
New gcode visualization integration - Do not reset visible range when toggling options/roles visibility
New gcode visualization - Fixed color of first vertex of top layer (when top layer only option is enabled)
New gcode visualization - Customizable travels and wipes segment radius
New gcode visualization integration - Removed tech ENABLE_GCODE_VIEWER_STATISTICS
New gcode visualization integration - Added check of OpenGL version
New gcode visualization integration - Removed GCodeProcessorResult::spiral_vase_layers
Another bunch of warnings fixes
Fixed warnings
New gcode visualization integration - Removal of old visualization
Fixed includes
New gcode visualization integration - File structure of new code separated in api + src
New gcode visualization integration - View ranges management moved to new visualizer
New gcode visualization integration - Fixed top layer only visualization for MMU printers
New gcode visualization integration - Removed dependency on imgui from new visualizer
Some refactoring
New gcode visualization integration - Removed dependency on Slic3r::GCodeProcessorResult from new visualizer
New gcode visualization integration - Moves' data conversion moved to client side
New gcode visualization: layers times refactoring
A bunch of fixes for the new gcode visualization
New gcode visualization: render in gray color layers containing pause print or custom gcode options when in Color Print view
New gcode visualization integration - Tool colors
New gcode visualization integration - Layers times
New gcode visualization integration - Travels and Extrusion roles times
Fixed detection of start/end of contiguous extrusion paths
New gcode visualization integration - Extrusion roles
New gcode visualization integration - Colors
New gcode visualization integration - Tool position
Center of gravity and tool marker may both be rendered with fixed screen size and a scaling factor
Fixed rendering of options in new gcode visualization
Tool marker NOT rendered by the new visualization code
Center of gravity marker NOT rendered by the new visualization code
Fixed toolpaths_cog shaders
Tool position window for new gcode visualization
Top layer only coloring for neww gcode visualization
Refactoring in preview's new visualization
Hidden imgui debug dialog for new visualization in preview
Synchronization of moves between old and new visualization
Fixed missing gcode window in new visualization
Rendering of debug imgui dialog moved from class libvgcode::Viewer to class libvgcode::Toolpaths + warnings fixing
Some functionality moved from class libvgcode::Viewer to class libvgcode::Toolpaths
Some refactoring and cleanup
Refatoring of PathVertex and Toolpaths::load()
SPE-1982: Tech ENABLE_NEW_GCODE_VIEWER - 1st installment of new toolpaths rendering code (WIP)
2025-09-24 22:49:14 -04:00