mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 07:11:10 +00:00
* Add Missing Includes Across src/slic3r/GUI Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained. * Drop the OS-Specific Includes Added Outside Their Platform Guards GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build. * Add the clang-tidy Configuration That Generated These Includes Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly. * Match Windows Paths in the clang-tidy Ignore List Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
107 lines
3.0 KiB
C++
107 lines
3.0 KiB
C++
#include "IMToolbar.hpp"
|
|
|
|
#include "3DScene.hpp"
|
|
#include <cstdint>
|
|
#include <glad/gl.h>
|
|
#include <imgui/imgui_internal.h>
|
|
#include <imgui/imgui.h>
|
|
#include <string>
|
|
#include "libslic3r/Utils.hpp"
|
|
|
|
#include "nanosvg/nanosvg.h"
|
|
#include "nanosvg/nanosvgrast.h"
|
|
#include "libslic3r/GCode/ThumbnailData.hpp"
|
|
#include "ImGuiWrapper.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
IMToolbarItem::~IMToolbarItem()
|
|
{
|
|
GLuint id = (GLuint)(int64_t)texture_id;
|
|
if (id != 0)
|
|
glsafe(::glDeleteTextures(1, &id));
|
|
}
|
|
|
|
|
|
bool IMToolbarItem::generate_texture()
|
|
{
|
|
GLint last_texture;
|
|
unsigned m_image_texture{ 0 };
|
|
unsigned char* pixels = (unsigned char*)(&image_data[0]);
|
|
|
|
glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
|
glsafe(::glGenTextures(1, &m_image_texture));
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, m_image_texture));
|
|
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
|
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
|
glsafe(::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
|
|
// Store our identifier
|
|
texture_id = (ImTextureID)(intptr_t)m_image_texture;
|
|
|
|
// Restore state
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
|
|
|
|
return true;
|
|
}
|
|
|
|
void IMToolbar::del_all_item()
|
|
{
|
|
for (int i = 0; i < m_items.size(); i++) {
|
|
delete m_items[i];
|
|
m_items[i] = nullptr;
|
|
}
|
|
m_items.clear();
|
|
}
|
|
|
|
void IMToolbar::del_stats_item()
|
|
{
|
|
delete m_all_plates_stats_item;
|
|
m_all_plates_stats_item = nullptr;
|
|
}
|
|
|
|
void IMToolbar::set_enabled(bool enable)
|
|
{
|
|
m_enabled = enable;
|
|
}
|
|
|
|
bool IMReturnToolbar::init()
|
|
{
|
|
bool compress = false;
|
|
GLint last_texture;
|
|
unsigned m_image_texture{ 0 };
|
|
|
|
std::string path = resources_dir() + "/images/";
|
|
std::string file_name;
|
|
|
|
file_name = path + "assemble_return.svg";
|
|
|
|
ThumbnailData data;
|
|
if (!get_data_from_svg(file_name, 20, data))
|
|
return false;
|
|
|
|
unsigned char* pixels = (unsigned char*)(&data.pixels[0]);
|
|
glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
|
glsafe(::glGenTextures(1, &m_image_texture));
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, m_image_texture));
|
|
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
|
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
|
glsafe(::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
|
if (compress && GLAD_GL_EXT_texture_compression_s3tc)
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
else
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
|
|
// Store our identifier
|
|
texture_id = (ImTextureID)(intptr_t)m_image_texture;
|
|
|
|
// Restore state
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|