OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
GLGizmoEmboss.cpp File Reference
#include "GLGizmoEmboss.hpp"
#include "EmbossStyleManager.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Shortcuts.hpp"
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/GUI/NotificationManager.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/MsgDialog.hpp"
#include "slic3r/GUI/format.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/CameraUtils.hpp"
#include "slic3r/GUI/Jobs/EmbossJob.hpp"
#include "slic3r/GUI/Jobs/CreateFontNameImageJob.hpp"
#include "slic3r/Utils/WxFontUtils.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "GLGizmoUtils.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/Timer.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Preset.hpp"
#include "libslic3r/AppConfig.hpp"
#include "imgui/imgui_stdlib.h"
#include <string>
#include "libslic3r/Point.hpp"
#include <memory>
#include "slic3r/GUI/TextLines.hpp"
#include <atomic>
#include <imgui.h>
#include "libslic3r/Emboss.hpp"
#include "libslic3r/TextConfiguration.hpp"
#include "libslic3r/EmbossShape.hpp"
#include "slic3r/GUI/IconManager.hpp"
#include <cstddef>
#include <vector>
#include <wx/fontenc.h>
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
#include <utility>
#include <cassert>
#include <optional>
#include "libslic3r/libslic3r.h"
#include "slic3r/GUI/SurfaceDrag.hpp"
#include <Eigen/Geometry>
#include "slic3r/GUI/Selection.hpp"
#include "slic3r/GUI/3DScene.hpp"
#include "libslic3r/Color.hpp"
#include <algorithm>
#include <wx/gdicmn.h>
#include "libslic3r/Utils.hpp"
#include <wx/settings.h>
#include <cmath>
#include <string_view>
#include "libslic3r/Config.hpp"
#include <wx/dataview.h>
#include <limits>
#include <wx/intl.h>
#include <math.h>
#include <boost/container_hash/hash.hpp>
#include <cstdint>
#include <boost/nowide/convert.hpp>
#include "libslic3r/Polygon.hpp"
#include <sstream>
#include <boost/filesystem/path.hpp>
#include <ios>
#include <exception>
#include <boost/filesystem/operations.hpp>
#include "slic3r/GUI/Jobs/Worker.hpp"
#include <cfloat>
#include <wx/string.h>
#include <imgui/imgui_internal.h>
#include <wx/font.h>
#include <wx/fontutil.h>
#include <wx/fontdlg.h>
#include <wx/fontenum.h>
#include <wx/display.h>
#include <wx/hashmap.h>
#include <boost/log/trivial.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/functional/hash.hpp>
#include <boost/filesystem.hpp>
#include <cereal/cereal.hpp>
#include <cereal/types/vector.hpp>
#include <cereal/types/string.hpp>
#include <cereal/archives/binary.hpp>
#include <glad/gl.h>
#include <chrono>
#include "libslic3r/CutUtils.hpp"
#include "libslic3r/ObjectID.hpp"
#include "slic3r/GUI/GUI_Geometry.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoRotate.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosManager.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "slic3r/Utils/RaycastManager.hpp"

Go to the source code of this file.

Classes

struct  anonymous_namespace{GLGizmoEmboss.cpp}::Limit< T >
struct  anonymous_namespace{GLGizmoEmboss.cpp}::Limits
struct  anonymous_namespace{GLGizmoEmboss.cpp}::TextDataBase
struct  anonymous_namespace{GLGizmoEmboss.cpp}::FaceName
struct  anonymous_namespace{GLGizmoEmboss.cpp}::Facenames
struct  anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg
struct  anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations
struct  Slic3r::GUI::GLGizmoEmboss::Facenames
struct  Slic3r::GUI::GLGizmoEmboss::GuiCfg
struct  FacenamesSerializer

Namespaces

namespace  anonymous_namespace{GLGizmoEmboss.cpp}
namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/
namespace  Slic3r::GUI

Macros

#define IMGUI_DEFINE_MATH_OPERATORS

Enumerations

enum class  anonymous_namespace{GLGizmoEmboss.cpp}::IconType : unsigned {
  anonymous_namespace{GLGizmoEmboss.cpp}::rename = 0 , anonymous_namespace{GLGizmoEmboss.cpp}::erase , anonymous_namespace{GLGizmoEmboss.cpp}::add , anonymous_namespace{GLGizmoEmboss.cpp}::save ,
  anonymous_namespace{GLGizmoEmboss.cpp}::undo , anonymous_namespace{GLGizmoEmboss.cpp}::italic , anonymous_namespace{GLGizmoEmboss.cpp}::unitalic , anonymous_namespace{GLGizmoEmboss.cpp}::bold ,
  anonymous_namespace{GLGizmoEmboss.cpp}::unbold , anonymous_namespace{GLGizmoEmboss.cpp}::system_selector , anonymous_namespace{GLGizmoEmboss.cpp}::open_file , anonymous_namespace{GLGizmoEmboss.cpp}::exclamation ,
  anonymous_namespace{GLGizmoEmboss.cpp}::lock , anonymous_namespace{GLGizmoEmboss.cpp}::lock_bold , anonymous_namespace{GLGizmoEmboss.cpp}::unlock , anonymous_namespace{GLGizmoEmboss.cpp}::unlock_bold ,
  anonymous_namespace{GLGizmoEmboss.cpp}::align_horizontal_left , anonymous_namespace{GLGizmoEmboss.cpp}::align_horizontal_center , anonymous_namespace{GLGizmoEmboss.cpp}::align_horizontal_right , anonymous_namespace{GLGizmoEmboss.cpp}::align_vertical_top ,
  anonymous_namespace{GLGizmoEmboss.cpp}::align_vertical_center , anonymous_namespace{GLGizmoEmboss.cpp}::align_vertical_bottom , anonymous_namespace{GLGizmoEmboss.cpp}::_count
}
enum class  anonymous_namespace{GLGizmoEmboss.cpp}::IconState : unsigned { anonymous_namespace{GLGizmoEmboss.cpp}::activable = 0 , anonymous_namespace{GLGizmoEmboss.cpp}::hovered , anonymous_namespace{GLGizmoEmboss.cpp}::disabled }

Functions

std::unique_ptr< DataBase > anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base (const std::string &text, StyleManager &style_manager, TextLinesModel &text_lines, const Selection &selection, ModelVolumeType type, std::shared_ptr< std::atomic< bool > > &cancel)
 Prepare data for emboss.
CreateVolumeParams anonymous_namespace{GLGizmoEmboss.cpp}::create_input (GLCanvas3D &canvas, const StyleManager::Style &style, RaycastManager &raycaster, ModelVolumeType volume_type)
ImVec2 anonymous_namespace{GLGizmoEmboss.cpp}::calc_fine_position (const Selection &selection, const ImVec2 &windows_size, const Size &canvas_size)
 Move window for edit emboss text near to embossed object NOTE: embossed object must be selected.
const IconManager::Icon & anonymous_namespace{GLGizmoEmboss.cpp}::get_icon (const IconManager::VIcons &icons, IconType type, IconState state)
bool anonymous_namespace{GLGizmoEmboss.cpp}::draw_button (const IconManager::VIcons &icons, IconType type, bool disable=false)
bool anonymous_namespace{GLGizmoEmboss.cpp}::store (const Facenames &facenames)
bool anonymous_namespace{GLGizmoEmboss.cpp}::load (Facenames &facenames)
void anonymous_namespace{GLGizmoEmboss.cpp}::init_face_names (Facenames &facenames)
void anonymous_namespace{GLGizmoEmboss.cpp}::init_truncated_names (Facenames &face_names, float max_width)
GuiCfg anonymous_namespace{GLGizmoEmboss.cpp}::create_gui_configuration ()
void anonymous_namespace{GLGizmoEmboss.cpp}::draw_font_preview (FaceName &face, const std::string &text, Facenames &faces, const GuiCfg &cfg, bool is_visible)
void anonymous_namespace{GLGizmoEmboss.cpp}::init_text_lines (TextLinesModel &text_lines, const Selection &selection, StyleManager &style_manager, unsigned count_lines=0)
ModelVolumePtrs anonymous_namespace{GLGizmoEmboss.cpp}::prepare_volumes_to_slice (const ModelVolume &mv)
bool anonymous_namespace{GLGizmoEmboss.cpp}::check (ModelVolumeType volume_type)
bool anonymous_namespace{GLGizmoEmboss.cpp}::can_write (StyleManager &style_manager, const std::string &text)
bool anonymous_namespace{GLGizmoEmboss.cpp}::can_write (const EmbossStyle &style, const std::string &text)
void anonymous_namespace{GLGizmoEmboss.cpp}::add_style_for_default_text (EmbossStyles &styles)
std::optional< wxString > anonymous_namespace{GLGizmoEmboss.cpp}::get_installed_face_name (const std::optional< std::string > &face_name_opt, ::Facenames &face_names)
 Check installed fonts whether optional face name exist in installed fonts.
void anonymous_namespace{GLGizmoEmboss.cpp}::fix_transformation (const StyleManager::Style &from, const StyleManager::Style &to, GLCanvas3D &canvas)
bool anonymous_namespace{GLGizmoEmboss.cpp}::is_text_empty (std::string_view text)
template<typename T>
bool exist_change (const T &value, const T *default_value)
template<>
bool exist_change (const std::optional< float > &value, const std::optional< float > *default_value)
template<>
bool exist_change (const float &value, const float *default_value)
template<typename T>
bool imgui_input (const char *label, T *v, T step, T step_fast, const char *format, ImGuiInputTextFlags flags)
template<>
bool imgui_input (const char *label, float *v, float step, float step_fast, const char *format, ImGuiInputTextFlags flags)
template<>
bool imgui_input (const char *label, double *v, double step, double step_fast, const char *format, ImGuiInputTextFlags flags)
static std::size_t hash_value (wxString const &s)
template<class Archive>
void save (Archive &archive, wxString const &d)
template<class Archive>
void load (Archive &archive, wxString &d)
template<class Archive>
void serialize (Archive &ar, FacenamesSerializer &t, const std::uint32_t version)
 CEREAL_CLASS_VERSION (::FacenamesSerializer, FACENAMES_VERSION)
std::string anonymous_namespace{GLGizmoEmboss.cpp}::concat (std::vector< wxString > data)
boost::filesystem::path anonymous_namespace{GLGizmoEmboss.cpp}::get_fontlist_cache_path ()

Variables

const std::string anonymous_namespace{GLGizmoEmboss.cpp}::rotation_snapshot_name = L("Text rotate")
const std::string anonymous_namespace{GLGizmoEmboss.cpp}::move_snapshot_name = L("Text move")
static const struct anonymous_namespace{GLGizmoEmboss.cpp}::Limits anonymous_namespace{GLGizmoEmboss.cpp}::limits
static const float anonymous_namespace{GLGizmoEmboss.cpp}::SELECTABLE_INNER_OFFSET = 8.0f
const char *const anonymous_namespace{GLGizmoEmboss.cpp}::default_text = L("Embossed text")
constexpr std::uint32_t FACENAMES_VERSION = 1

Class Documentation

◆ anonymous_namespace{GLGizmoEmboss.cpp}::Limit

struct anonymous_namespace{GLGizmoEmboss.cpp}::Limit
template<typename T>
struct anonymous_namespace{GLGizmoEmboss.cpp}::Limit< T >
Inheritance diagram for anonymous_namespace{GLGizmoEmboss.cpp}::Limit< T >:
Class Members
MinMax< T > gui
MinMax< T > values

◆ anonymous_namespace{GLGizmoEmboss.cpp}::Limits

struct anonymous_namespace{GLGizmoEmboss.cpp}::Limits
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::Limits:
Class Members
MinMax< float > angle {-180.f, 180.f}
Limit< float > boldness {{-.5f, .5f}, {-5e5f, 5e5f}}
MinMax< int > char_gap {-20000, 20000}
MinMax< double > emboss {0.01, 1e4}
MinMax< int > line_gap {-20000, 20000}
MinMax< float > size_in_mm {0.1f, 1000.f}
Limit< float > skew {{-1.f, 1.f}, {-100.f, 100.f}}

◆ anonymous_namespace{GLGizmoEmboss.cpp}::FaceName

struct anonymous_namespace{GLGizmoEmboss.cpp}::FaceName
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::FaceName:
Class Members
shared_ptr< atomic< bool > > cancel = nullptr
shared_ptr< bool > is_created = nullptr
string name_truncated = ""
size_t texture_index = 0
wxString wx_name

◆ anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg

struct anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg:
Class Members
float advanced_input_offset = 0.f
bool dark_mode = false
float delete_pos_x = 0.f
Vec2i32 face_name_size = Vec2i32(0, 0)
float face_name_texture_offset_x = 0.f
float height_of_volume_type_selector = 0.f
unsigned int icon_width = 0
float indent = 0.f
float input_offset = 0.f
float input_width = 0.f
float lock_offset = 0.f
unsigned int max_count_opened_font_files = 10
Vec2i32 max_style_image_size = Vec2i32(0, 0)
float max_style_name_width = 0.f
float max_tooltip_width = 0.f
double screen_scale
ImVec2 text_size
Translations translations

◆ anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations

struct anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations
Collaboration diagram for anonymous_namespace{GLGizmoEmboss.cpp}::GuiCfg::Translations:
Class Members
string alignment
string boldness
string char_gap
string collection
string depth
string font
string from_surface
string height
string keep_up
string line_gap
string per_glyph
string rotation
string skew_ration
string use_surface

◆ FacenamesSerializer

struct FacenamesSerializer
Collaboration diagram for FacenamesSerializer:
Class Members
vector< wxString > bad
vector< wxString > good
size_t hash = 0

Macro Definition Documentation

◆ IMGUI_DEFINE_MATH_OPERATORS

#define IMGUI_DEFINE_MATH_OPERATORS

Function Documentation

◆ CEREAL_CLASS_VERSION()

CEREAL_CLASS_VERSION ( ::FacenamesSerializer ,
FACENAMES_VERSION  )

References FACENAMES_VERSION.

◆ exist_change() [1/3]

template<>
bool exist_change ( const float & value,
const float * default_value )
2581 {
2582 if (default_value == nullptr) return false;
2583 return !is_approx(value, *default_value);
2584}
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320

References Slic3r::is_approx().

Here is the call graph for this function:

◆ exist_change() [2/3]

template<>
bool exist_change ( const std::optional< float > & value,
const std::optional< float > * default_value )
2576 {
2577 if (default_value == nullptr) return false;
2578 return !is_approx(value, *default_value);
2579}

References Slic3r::is_approx().

Here is the call graph for this function:

◆ exist_change() [3/3]

template<typename T>
bool exist_change ( const T & value,
const T * default_value )
2571 {
2572 if (default_value == nullptr) return false;
2573 return (value != *default_value);
2574}

Referenced by Slic3r::GUI::GLGizmoEmboss::calculate_scale(), Slic3r::GUI::GLGizmoEmboss::draw_advanced(), Slic3r::GUI::GLGizmoEmboss::draw_delete_style_button(), Slic3r::GUI::GLGizmoEmboss::draw_font_list_line(), and Slic3r::GUI::GLGizmoEmboss::revertible().

Here is the caller graph for this function:

◆ hash_value()

std::size_t hash_value ( wxString const & s)
static
3386 {
3387 boost::hash<std::string> hasher;
3388 return hasher(s.ToStdString());
3389}

◆ imgui_input() [1/3]

template<>
bool imgui_input ( const char * label,
double * v,
double step,
double step_fast,
const char * format,
ImGuiInputTextFlags flags )
2638{ return ImGui::InputDouble(label, v, step, step_fast, format, flags); }
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45

References Slic3r::format().

Here is the call graph for this function:

◆ imgui_input() [2/3]

template<>
bool imgui_input ( const char * label,
float * v,
float step,
float step_fast,
const char * format,
ImGuiInputTextFlags flags )
2636{ return ImGui::InputFloat(label, v, step, step_fast, format, flags); }

References Slic3r::format().

Here is the call graph for this function:

◆ imgui_input() [3/3]

template<typename T>
bool imgui_input ( const char * label,
T * v,
T step,
T step_fast,
const char * format,
ImGuiInputTextFlags flags )

References Slic3r::format().

Referenced by Slic3r::GUI::GLGizmoEmboss::rev_input().

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

◆ load()

template<class Archive>
void load ( Archive & archive,
wxString & d )
3406{ std::string s; archive(s); d = s;}

Referenced by Slic3r::MachineObject::command_ams_change_filament(), glad_gl_load_GL_ARB_framebuffer_object(), glad_gl_load_GL_ES_VERSION_2_0(), glad_gl_load_GL_ES_VERSION_3_0(), glad_gl_load_GL_EXT_framebuffer_blit(), glad_gl_load_GL_EXT_framebuffer_multisample(), glad_gl_load_GL_EXT_framebuffer_object(), glad_gl_load_GL_VERSION_1_0(), glad_gl_load_GL_VERSION_1_1(), glad_gl_load_GL_VERSION_1_2(), glad_gl_load_GL_VERSION_1_3(), glad_gl_load_GL_VERSION_1_4(), glad_gl_load_GL_VERSION_1_5(), glad_gl_load_GL_VERSION_2_0(), glad_gl_load_GL_VERSION_2_1(), glad_gl_load_GL_VERSION_3_0(), glad_gl_load_GL_VERSION_3_1(), glad_gl_load_GL_VERSION_3_2(), glad_gl_load_GL_VERSION_3_3(), glad_gl_load_GL_VERSION_4_0(), glad_gl_load_GL_VERSION_4_1(), glad_gl_load_GL_VERSION_4_2(), glad_gl_load_GL_VERSION_4_3(), glad_gl_load_GL_VERSION_4_4(), glad_gl_load_GL_VERSION_4_5(), glad_gl_load_GL_VERSION_4_6(), gladLoadGL(), gladLoadGLES2(), gladLoadGLES2UserPtr(), gladLoadGLUserPtr(), Slic3r::GUI::DesignRowList::load_icons(), Slic3r::PresetBundle::load_vendors(), Slic3r::GUI::AMSextruder::OnAmsLoading(), Slic3r::GUI::AMSextruderImage::OnAmsLoading(), Slic3r::GUI::AMSextruder::OnVamsLoading(), Slic3r::GUI::AMSRoad::OnVamsLoading(), Slic3r::GUI::AMSRoadDownPart::OnVamsLoading(), Slic3r::GUI::AMSRoadUpPart::OnVamsLoading(), and Slic3r::GUI::GuideFrame::SetStartPage().

Here is the caller graph for this function:

◆ save()

template<class Archive>
void save ( Archive & archive,
wxString const & d )
3404{ std::string s(d.ToUTF8().data()); archive(s);}

Referenced by QuadricEdgeCollapse::change_neighbors(), Slic3r::MachineObject::command_set_save_remote_print_file_to_storage(), and Slic3r::PhysicalPrinterCollection::load_printer().

Here is the caller graph for this function:

◆ serialize()

template<class Archive>
void serialize ( Archive & ar,
FacenamesSerializer & t,
const std::uint32_t version )
3408{
3409 // When performing a load, the version associated with the class
3410 // is whatever it was when that data was originally serialized
3411 // When we save, we'll use the version that is defined in the macro
3412 if (version != FACENAMES_VERSION) return;
3413 ar(t.hash, t.good, t.bad);
3414}
size_t hash
Definition GLGizmoEmboss.cpp:3396
std::vector< wxString > bad
Definition GLGizmoEmboss.cpp:3400
constexpr std::uint32_t FACENAMES_VERSION
Definition GLGizmoEmboss.cpp:3392
std::vector< wxString > good
Definition GLGizmoEmboss.cpp:3398

References FacenamesSerializer::bad, FACENAMES_VERSION, FacenamesSerializer::good, and FacenamesSerializer::hash.

Referenced by Slic3r::GUI::get_string_value(), Slic3r::CLI::run(), and Slic3r::TriangleSelector::serialize().

Here is the caller graph for this function:

Variable Documentation

◆ FACENAMES_VERSION

std::uint32_t FACENAMES_VERSION = 1
constexpr

Referenced by CEREAL_CLASS_VERSION(), and serialize().