mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 15:21:09 +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.
86 lines
2.2 KiB
C++
86 lines
2.2 KiB
C++
#ifndef slic3r_CreateFontNameImageJob_hpp_
|
|
#define slic3r_CreateFontNameImageJob_hpp_
|
|
|
|
#include <cstddef>
|
|
#include <memory>
|
|
#include <atomic>
|
|
#include <exception>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <glad/gl.h>
|
|
#include <wx/string.h>
|
|
#include <wx/fontenc.h>
|
|
#include "Job.hpp"
|
|
#include "libslic3r/Point.hpp" // Vec2i32
|
|
|
|
namespace Slic3r::GUI {
|
|
|
|
/// <summary>
|
|
/// Keep data for rasterization of text by font face
|
|
/// </summary>
|
|
struct FontImageData
|
|
{
|
|
// Text to rasterize
|
|
std::string text;
|
|
// Define font face
|
|
wxString font_name;
|
|
wxFontEncoding encoding;
|
|
// texture for copy result to
|
|
// texture MUST BE initialized
|
|
GLuint texture_id;
|
|
// Index of face name, define place in texture
|
|
size_t index;
|
|
// Height of each text
|
|
// And Limit for width
|
|
Vec2i32 size; // in px
|
|
|
|
// bigger value create darker image
|
|
// divide value 255
|
|
unsigned char gray_level = 5;
|
|
|
|
// texture meta data
|
|
GLenum format = GL_ALPHA, type = GL_UNSIGNED_BYTE;
|
|
GLint level = 0;
|
|
|
|
// prevent opening too much files
|
|
// it is decreased in finalize phase
|
|
unsigned int *count_opened_font_files = nullptr;
|
|
|
|
std::shared_ptr<std::atomic<bool>> cancel = nullptr;
|
|
std::shared_ptr<bool> is_created = nullptr;
|
|
};
|
|
|
|
/// <summary>
|
|
/// Create image for face name
|
|
/// </summary>
|
|
class CreateFontImageJob : public Job
|
|
{
|
|
FontImageData m_input;
|
|
std::vector<unsigned char> m_result;
|
|
Point m_tex_size;
|
|
public:
|
|
CreateFontImageJob(FontImageData &&input);
|
|
/// <summary>
|
|
/// Rasterize text into image (result)
|
|
/// </summary>
|
|
/// <param name="ctl">Check for cancelation</param>
|
|
void process(Ctl &ctl) override;
|
|
|
|
/// <summary>
|
|
/// Copy image data into OpenGL texture
|
|
/// </summary>
|
|
/// <param name="canceled"></param>
|
|
/// <param name=""></param>
|
|
void finalize(bool canceled, std::exception_ptr &) override;
|
|
|
|
/// <summary>
|
|
/// Text used for generate preview for empty text
|
|
/// and when no glyph for given m_input.text
|
|
/// </summary>
|
|
static const std::string default_text;
|
|
};
|
|
|
|
} // namespace Slic3r::GUI
|
|
|
|
#endif // slic3r_CreateFontNameImageJob_hpp_
|