mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 07:45:53 +08:00
Clean up EmbossJob
This commit is contained in:
parent
6807615c75
commit
61fa3e8844
@ -7235,10 +7235,10 @@ const ModelVolume *get_model_volume(const GLVolume &v, const Model &model)
|
||||
return ret;
|
||||
}
|
||||
|
||||
const ModelVolume *get_model_volume(const ObjectID &volume_id, const ModelObjectPtrs &objects)
|
||||
ModelVolume *get_model_volume(const ObjectID &volume_id, const ModelObjectPtrs &objects)
|
||||
{
|
||||
for (const ModelObject *obj : objects)
|
||||
for (const ModelVolume *vol : obj->volumes)
|
||||
for (ModelVolume *vol : obj->volumes)
|
||||
if (vol->id() == volume_id)
|
||||
return vol;
|
||||
return nullptr;
|
||||
|
@ -1069,7 +1069,7 @@ private:
|
||||
};
|
||||
|
||||
const ModelVolume *get_model_volume(const GLVolume &v, const Model &model);
|
||||
const ModelVolume *get_model_volume(const ObjectID &volume_id, const ModelObjectPtrs &objects);
|
||||
ModelVolume *get_model_volume(const ObjectID &volume_id, const ModelObjectPtrs &objects);
|
||||
ModelVolume *get_model_volume(const GLVolume &v, const ModelObjectPtrs &objects);
|
||||
ModelVolume *get_model_volume(const GLVolume &v, const ModelObject &object);
|
||||
|
||||
|
@ -15,9 +15,7 @@
|
||||
#include "slic3r/Utils/WxFontUtils.hpp"
|
||||
#include "slic3r/Utils/UndoRedo.hpp"
|
||||
|
||||
// TODO: remove include
|
||||
#include "libslic3r/SVG.hpp" // debug store
|
||||
#include "libslic3r/Geometry.hpp" // covex hull 2d
|
||||
#include "libslic3r/Geometry.hpp" // to range pi pi
|
||||
#include "libslic3r/Timer.hpp"
|
||||
|
||||
#include "libslic3r/NSVGUtils.hpp"
|
||||
@ -92,16 +90,12 @@ using namespace priv;
|
||||
|
||||
GLGizmoEmboss::GLGizmoEmboss(GLCanvas3D &parent)
|
||||
: GLGizmoBase(parent, M_ICON_FILENAME, -2)
|
||||
, m_volume(nullptr)
|
||||
, m_is_unknown_font(false)
|
||||
, m_rotate_gizmo(parent, GLGizmoRotate::Axis::Z) // grab id = 2 (Z axis)
|
||||
, m_style_manager(m_imgui->get_glyph_ranges(), create_default_styles)
|
||||
, m_job_cancel(nullptr)
|
||||
, m_rotate_gizmo(parent, GLGizmoRotate::Axis::Z) // grab id = 2 (Z axis)
|
||||
{
|
||||
m_rotate_gizmo.set_group_id(0);
|
||||
m_rotate_gizmo.set_force_local_coordinate(true);
|
||||
// TODO: add suggestion to use https://fontawesome.com/
|
||||
// (copy & paste) unicode symbols from web
|
||||
// to use https://fontawesome.com/ (copy & paste) unicode symbols from web
|
||||
// paste HEX unicode into notepad move cursor after unicode press [alt] + [x]
|
||||
}
|
||||
|
||||
@ -160,14 +154,25 @@ const IconManager::Icon &get_icon(const IconManager::VIcons& icons, IconType typ
|
||||
static bool draw_button(const IconManager::VIcons& icons, IconType type, bool disable = false);
|
||||
} // namespace priv
|
||||
|
||||
CreateVolumeParams create_input(GLCanvas3D &canvas, StyleManager &styler, RaycastManager& raycaster, ModelVolumeType volume_type)
|
||||
{
|
||||
auto gizmo = static_cast<unsigned char>(GLGizmosManager::Emboss);
|
||||
const GLVolume *gl_volume = get_first_hovered_gl_volume(canvas);
|
||||
const FontProp &fp = styler.get_style().prop;
|
||||
Plater *plater = wxGetApp().plater();
|
||||
return CreateVolumeParams{canvas, plater->get_camera(), plater->build_volume(),
|
||||
plater->get_ui_job_worker(), volume_type, raycaster, gizmo, gl_volume, fp.distance, fp.angle};
|
||||
}
|
||||
|
||||
bool GLGizmoEmboss::create_volume(ModelVolumeType volume_type, const Vec2d& mouse_pos)
|
||||
{
|
||||
m_style_manager.discard_style_changes();
|
||||
set_default_text();
|
||||
|
||||
// NOTE: change style manager - be carefull with order changes
|
||||
DataBasePtr base = priv::create_emboss_data_base(m_text, m_style_manager, m_job_cancel);
|
||||
Plater *plater_ptr = wxGetApp().plater();
|
||||
const FontProp &fp = m_style_manager.get_style().prop;
|
||||
return start_create_volume(plater_ptr, std::move(base), volume_type, m_raycast_manager, GLGizmosManager::Emboss, mouse_pos, fp.distance, fp.angle);
|
||||
CreateVolumeParams input = create_input(m_parent, m_style_manager, m_raycast_manager, volume_type);
|
||||
return start_create_volume(input, std::move(base), mouse_pos);
|
||||
}
|
||||
|
||||
// Designed for create volume without information of mouse in scene
|
||||
@ -175,11 +180,11 @@ bool GLGizmoEmboss::create_volume(ModelVolumeType volume_type)
|
||||
{
|
||||
m_style_manager.discard_style_changes();
|
||||
set_default_text();
|
||||
std::unique_ptr<DataBase> emboss_data = priv::create_emboss_data_base(m_text, m_style_manager, m_job_cancel);
|
||||
Plater *plater_ptr = wxGetApp().plater();
|
||||
const FontProp &fp = m_style_manager.get_style().prop;
|
||||
return start_create_volume_without_position(plater_ptr, std::move(emboss_data),
|
||||
volume_type, m_raycast_manager, GLGizmosManager::Emboss, fp.distance, fp.angle);
|
||||
|
||||
// NOTE: change style manager - be carefull with order changes
|
||||
DataBasePtr base = priv::create_emboss_data_base(m_text, m_style_manager, m_job_cancel);
|
||||
CreateVolumeParams input = create_input(m_parent, m_style_manager, m_raycast_manager, volume_type);
|
||||
return start_create_volume_without_position(input, std::move(base));
|
||||
}
|
||||
|
||||
bool GLGizmoEmboss::on_mouse_for_rotation(const wxMouseEvent &mouse_event)
|
||||
|
@ -147,7 +147,7 @@ private:
|
||||
bool on_mouse_for_translate(const wxMouseEvent &mouse_event);
|
||||
|
||||
// When open text loaded from .3mf it could be written with unknown font
|
||||
bool m_is_unknown_font;
|
||||
bool m_is_unknown_font = false;
|
||||
void create_notification_not_valid_font(const TextConfiguration& tc);
|
||||
void remove_notification_not_valid_font();
|
||||
|
||||
@ -272,7 +272,8 @@ private:
|
||||
// filtration pattern
|
||||
std::string search = "";
|
||||
std::vector<bool> hide; // result of filtration
|
||||
} m_face_names;
|
||||
};
|
||||
Facenames m_face_names;
|
||||
static bool store(const Facenames &facenames);
|
||||
static bool load(Facenames &facenames);
|
||||
|
||||
@ -287,7 +288,7 @@ private:
|
||||
|
||||
// current selected volume
|
||||
// NOTE: Be carefull could be uninitialized (removed from Model)
|
||||
ModelVolume *m_volume;
|
||||
ModelVolume *m_volume = nullptr;
|
||||
|
||||
// When work with undo redo stack there could be situation that
|
||||
// m_volume point to unexisting volume so One need also objectID
|
||||
@ -297,7 +298,7 @@ private:
|
||||
bool m_text_contain_unknown_glyph = false;
|
||||
|
||||
// cancel for previous update of volume to cancel finalize part
|
||||
std::shared_ptr<std::atomic<bool>> m_job_cancel;
|
||||
std::shared_ptr<std::atomic<bool>> m_job_cancel = nullptr;
|
||||
|
||||
// Rotation gizmo
|
||||
GLGizmoRotate m_rotate_gizmo;
|
||||
|
@ -99,21 +99,30 @@ static std::string get_file_name(const std::string &file_path);
|
||||
/// <returns>Name for volume</returns>
|
||||
static std::string volume_name(const EmbossShape& shape);
|
||||
|
||||
static CreateVolumeParams create_input(GLCanvas3D &canvas, RaycastManager &raycaster, ModelVolumeType volume_type);
|
||||
} // namespace priv
|
||||
|
||||
CreateVolumeParams priv::create_input(GLCanvas3D &canvas, RaycastManager& raycaster, ModelVolumeType volume_type)
|
||||
{
|
||||
auto gizmo = static_cast<unsigned char>(GLGizmosManager::Svg);
|
||||
const GLVolume *gl_volume = get_first_hovered_gl_volume(canvas);
|
||||
Plater *plater = wxGetApp().plater();
|
||||
return CreateVolumeParams{canvas, plater->get_camera(), plater->build_volume(),
|
||||
plater->get_ui_job_worker(), volume_type, raycaster, gizmo, gl_volume};
|
||||
}
|
||||
|
||||
bool GLGizmoSVG::create_volume(ModelVolumeType volume_type, const Vec2d &mouse_pos)
|
||||
{
|
||||
CreateVolumeParams input = priv::create_input(m_parent, m_raycast_manager, volume_type);
|
||||
DataBasePtr base = priv::create_emboss_data_base(m_job_cancel);
|
||||
Plater *plater_ptr = wxGetApp().plater();
|
||||
return start_create_volume(plater_ptr, std::move(base), volume_type, m_raycast_manager, GLGizmosManager::Svg, mouse_pos);
|
||||
return start_create_volume(input, std::move(base), mouse_pos);
|
||||
}
|
||||
|
||||
bool GLGizmoSVG::create_volume(ModelVolumeType volume_type)
|
||||
{
|
||||
CreateVolumeParams input = priv::create_input(m_parent, m_raycast_manager, volume_type);
|
||||
DataBasePtr base = priv::create_emboss_data_base(m_job_cancel);
|
||||
Plater *plater_ptr = wxGetApp().plater();
|
||||
return start_create_volume_without_position(plater_ptr, std::move(base), volume_type, m_raycast_manager, GLGizmosManager::Svg);
|
||||
return start_create_volume_without_position(input, std::move(base));
|
||||
}
|
||||
|
||||
bool GLGizmoSVG::is_svg(const ModelVolume &volume) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,9 +19,12 @@ namespace Slic3r {
|
||||
class TriangleMesh;
|
||||
class ModelVolume;
|
||||
enum class ModelVolumeType : int;
|
||||
class BuildVolume;
|
||||
namespace GUI {
|
||||
class RaycastManager;
|
||||
class Plater;
|
||||
class GLCanvas3D;
|
||||
class Worker;
|
||||
}}
|
||||
|
||||
namespace Slic3r::GUI::Emboss {
|
||||
@ -160,6 +163,42 @@ public:
|
||||
/// <returns>Source data for cut surface from</returns>
|
||||
SurfaceVolumeData::ModelSources create_volume_sources(const ModelVolume &volume);
|
||||
|
||||
/// <summary>
|
||||
/// shorten params for start_crate_volume functions
|
||||
/// </summary>
|
||||
struct CreateVolumeParams
|
||||
{
|
||||
|
||||
GLCanvas3D &canvas;
|
||||
|
||||
// Direction of ray into scene
|
||||
const Camera &camera;
|
||||
|
||||
// To put new object on the build volume
|
||||
const BuildVolume &build_volume;
|
||||
|
||||
// used to emplace job for execution
|
||||
Worker &worker;
|
||||
|
||||
// New created volume type
|
||||
ModelVolumeType volume_type;
|
||||
|
||||
// Contain AABB trees from scene
|
||||
RaycastManager &raycaster;
|
||||
|
||||
// Define which gizmo open on the success
|
||||
unsigned char gizmo; // GLGizmosManager::EType
|
||||
|
||||
// Volume define object to add new volume
|
||||
const GLVolume *gl_volume;
|
||||
|
||||
// Wanted additionl move in Z(emboss) direction of new created volume
|
||||
std::optional<float> distance = {};
|
||||
|
||||
// Wanted additionl rotation around Z of new created volume
|
||||
std::optional<float> angle = {};
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Create new volume on position of mouse cursor
|
||||
/// </summary>
|
||||
@ -172,27 +211,13 @@ SurfaceVolumeData::ModelSources create_volume_sources(const ModelVolume &volume)
|
||||
/// <param name="distance">Wanted additionl move in Z(emboss) direction of new created volume</param>
|
||||
/// <param name="angle">Wanted additionl rotation around Z of new created volume</param>
|
||||
/// <returns>True on success otherwise False</returns>
|
||||
bool start_create_volume(Plater *plater_ptr,
|
||||
DataBasePtr data,
|
||||
ModelVolumeType volume_type,
|
||||
RaycastManager &raycaster,
|
||||
unsigned char gizmo,
|
||||
const Vec2d &mouse_pos,
|
||||
const std::optional<float> &distance = {},
|
||||
const std::optional<float> &angle = {});
|
||||
|
||||
bool start_create_volume(CreateVolumeParams &input, DataBasePtr data, const Vec2d &mouse_pos);
|
||||
|
||||
/// <summary>
|
||||
/// Same as previous function but without mouse position
|
||||
/// Need to suggest position or put near the selection
|
||||
/// </summary>
|
||||
bool start_create_volume_without_position(Plater *plater_ptr,
|
||||
DataBasePtr data,
|
||||
ModelVolumeType volume_type,
|
||||
RaycastManager &raycaster,
|
||||
unsigned char gizmo,
|
||||
const std::optional<float> &distance = {},
|
||||
const std::optional<float> &angle = {});
|
||||
bool start_create_volume_without_position(CreateVolumeParams &input, DataBasePtr data);
|
||||
} // namespace Slic3r::GUI
|
||||
|
||||
#endif // slic3r_EmbossJob_hpp_
|
||||
|
Loading…
x
Reference in New Issue
Block a user