mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge remote-tracking branch 'origin/master' into ys_search
This commit is contained in:
commit
45d064d4cb
82 changed files with 12211 additions and 6689 deletions
|
@ -33,9 +33,7 @@
|
|||
#include "libslic3r/Format/AMF.hpp"
|
||||
#include "libslic3r/Format/3mf.hpp"
|
||||
#include "libslic3r/GCode/PreviewData.hpp"
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
#include "libslic3r/GCode/ThumbnailData.hpp"
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/SLA/Hollowing.hpp"
|
||||
#include "libslic3r/SLA/Rotfinder.hpp"
|
||||
|
@ -80,7 +78,6 @@
|
|||
#include "../Utils/PrintHost.hpp"
|
||||
#include "../Utils/FixModelByWin10.hpp"
|
||||
#include "../Utils/UndoRedo.hpp"
|
||||
#include "../Utils/Thread.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "SearchComboBox.hpp"
|
||||
|
||||
|
@ -94,9 +91,7 @@ using Slic3r::_3DScene;
|
|||
using Slic3r::Preset;
|
||||
using Slic3r::PrintHostJob;
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
static const std::pair<unsigned int, unsigned int> THUMBNAIL_SIZE_3MF = { 256, 256 };
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -269,7 +264,7 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
|
|||
EnableTextChangedEvents(false);
|
||||
#endif /* _WIN32 */
|
||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
||||
auto selected_item = this->GetSelection();
|
||||
auto selected_item = evt.GetSelection();
|
||||
|
||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
|
||||
|
@ -389,9 +384,9 @@ void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
|
|||
this->SetClientData(item, (void*)label_item_type);
|
||||
}
|
||||
|
||||
void PresetComboBox::check_selection()
|
||||
void PresetComboBox::check_selection(int selection)
|
||||
{
|
||||
this->last_selected = GetSelection();
|
||||
this->last_selected = selection;
|
||||
}
|
||||
|
||||
void PresetComboBox::msw_rescale()
|
||||
|
@ -1598,8 +1593,7 @@ struct Plater::priv
|
|||
|
||||
enum class Jobs : size_t {
|
||||
Arrange,
|
||||
Rotoptimize,
|
||||
Hollow
|
||||
Rotoptimize
|
||||
};
|
||||
|
||||
class ArrangeJob : public PlaterJob
|
||||
|
@ -1772,22 +1766,6 @@ struct Plater::priv
|
|||
void process() override;
|
||||
};
|
||||
|
||||
class HollowJob : public PlaterJob
|
||||
{
|
||||
public:
|
||||
using PlaterJob::PlaterJob;
|
||||
void prepare() override;
|
||||
void process() override;
|
||||
void finalize() override;
|
||||
private:
|
||||
GLGizmoHollow * get_gizmo();
|
||||
const GLGizmoHollow * get_gizmo() const;
|
||||
|
||||
std::unique_ptr<TriangleMesh> m_output_mesh;
|
||||
std::unique_ptr<MeshRaycaster> m_output_raycaster;
|
||||
const TriangleMesh* m_object_mesh = nullptr;
|
||||
sla::HollowingConfig m_cfg;
|
||||
};
|
||||
|
||||
// Jobs defined inside the group class will be managed so that only one can
|
||||
// run at a time. Also, the background process will be stopped if a job is
|
||||
|
@ -1800,7 +1778,6 @@ struct Plater::priv
|
|||
|
||||
ArrangeJob arrange_job{m_plater};
|
||||
RotoptimizeJob rotoptimize_job{m_plater};
|
||||
HollowJob hollow_job{m_plater};
|
||||
|
||||
// To create a new job, just define a new subclass of Job, implement
|
||||
// the process and the optional prepare() and finalize() methods
|
||||
|
@ -1808,8 +1785,7 @@ struct Plater::priv
|
|||
// if it cannot run concurrently with other jobs in this group
|
||||
|
||||
std::vector<std::reference_wrapper<Job>> m_jobs{arrange_job,
|
||||
rotoptimize_job,
|
||||
hollow_job};
|
||||
rotoptimize_job};
|
||||
|
||||
public:
|
||||
ExclusiveJobGroup(priv *_plater) : m_plater(_plater) {}
|
||||
|
@ -1912,7 +1888,6 @@ struct Plater::priv
|
|||
void reset();
|
||||
void mirror(Axis axis);
|
||||
void arrange();
|
||||
void hollow();
|
||||
void sla_optimize_rotation();
|
||||
void split_object();
|
||||
void split_volume();
|
||||
|
@ -2014,10 +1989,8 @@ struct Plater::priv
|
|||
bool can_mirror() const;
|
||||
bool can_reload_from_disk() const;
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
void generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background);
|
||||
void generate_thumbnails(ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background);
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
void msw_rescale_object_menu();
|
||||
|
||||
|
@ -2091,7 +2064,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
background_process.set_fff_print(&fff_print);
|
||||
background_process.set_sla_print(&sla_print);
|
||||
background_process.set_gcode_preview_data(&gcode_preview_data);
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
background_process.set_thumbnail_cb([this](ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background)
|
||||
{
|
||||
std::packaged_task<void(ThumbnailsList&, const Vec2ds&, bool, bool, bool, bool)> task([this](ThumbnailsList& thumbnails, const Vec2ds& sizes, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) {
|
||||
|
@ -2101,7 +2073,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
wxTheApp->CallAfter([&]() { task(thumbnails, sizes, printable_only, parts_only, show_bed, transparent_background); });
|
||||
result.wait();
|
||||
});
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
background_process.set_slicing_completed_event(EVT_SLICING_COMPLETED);
|
||||
background_process.set_finished_event(EVT_PROCESS_COMPLETED);
|
||||
// Default printer technology for default config.
|
||||
|
@ -2856,11 +2827,6 @@ void Plater::priv::arrange()
|
|||
m_ui_jobs.start(Jobs::Arrange);
|
||||
}
|
||||
|
||||
void Plater::priv::hollow()
|
||||
{
|
||||
this->take_snapshot(_(L("Hollow")));
|
||||
m_ui_jobs.start(Jobs::Hollow);
|
||||
}
|
||||
|
||||
// This method will find an optimal orientation for the currently selected item
|
||||
// Very similar in nature to the arrange method above...
|
||||
|
@ -2998,67 +2964,6 @@ void Plater::priv::RotoptimizeJob::process()
|
|||
: _(L("Orientation found.")));
|
||||
}
|
||||
|
||||
void Plater::priv::HollowJob::prepare()
|
||||
{
|
||||
const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager();
|
||||
const GLGizmoHollow* gizmo_hollow = dynamic_cast<const GLGizmoHollow*>(gizmo_manager.get_current());
|
||||
assert(gizmo_hollow);
|
||||
auto hlw_data = gizmo_hollow->get_hollowing_parameters();
|
||||
m_object_mesh = hlw_data.first;
|
||||
m_cfg = hlw_data.second;
|
||||
m_output_mesh.reset();
|
||||
}
|
||||
|
||||
void Plater::priv::HollowJob::process()
|
||||
{
|
||||
sla::JobController ctl;
|
||||
ctl.stopcondition = [this]{ return was_canceled(); };
|
||||
ctl.statuscb = [this](unsigned st, const std::string &s) {
|
||||
if (st < 100) update_status(int(st), s);
|
||||
};
|
||||
|
||||
std::unique_ptr<TriangleMesh> omesh =
|
||||
sla::generate_interior(*m_object_mesh, m_cfg, ctl);
|
||||
|
||||
if (omesh && !omesh->empty()) {
|
||||
m_output_mesh.reset(new TriangleMesh{*m_object_mesh});
|
||||
m_output_mesh->merge(*omesh);
|
||||
m_output_mesh->require_shared_vertices();
|
||||
|
||||
update_status(90, _(L("Indexing hollowed object")));
|
||||
|
||||
m_output_raycaster.reset(new MeshRaycaster(*m_output_mesh));
|
||||
|
||||
update_status(100, was_canceled() ? _(L("Hollowing cancelled.")) :
|
||||
_(L("Hollowing done.")));
|
||||
} else {
|
||||
update_status(100, _(L("Hollowing failed.")));
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::priv::HollowJob::finalize()
|
||||
{
|
||||
if (auto gizmo = get_gizmo()) {
|
||||
gizmo->update_mesh_raycaster(std::move(m_output_raycaster));
|
||||
gizmo->update_hollowed_mesh(std::move(m_output_mesh));
|
||||
}
|
||||
}
|
||||
|
||||
GLGizmoHollow *Plater::priv::HollowJob::get_gizmo()
|
||||
{
|
||||
const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager();
|
||||
auto ret = dynamic_cast<GLGizmoHollow*>(gizmo_manager.get_current());
|
||||
assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const GLGizmoHollow *Plater::priv::HollowJob::get_gizmo() const
|
||||
{
|
||||
const GLGizmosManager& gizmo_manager = plater().q->canvas3D()->get_gizmos_manager();
|
||||
auto ret = dynamic_cast<const GLGizmoHollow*>(gizmo_manager.get_current());
|
||||
assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Plater::priv::split_object()
|
||||
{
|
||||
|
@ -3665,6 +3570,14 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
auto preset_type = static_cast<Preset::Type>(evt.GetInt());
|
||||
auto *combo = static_cast<PresetComboBox*>(evt.GetEventObject());
|
||||
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender"),
|
||||
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
|
||||
// So, use GetSelection() from event parameter
|
||||
// But in this function we couldn't use evt.GetSelection(), because m_commandInt is used for preset_type
|
||||
// Thus, get selection in this way:
|
||||
int selection = combo->FindString(evt.GetString(), true);
|
||||
|
||||
auto idx = combo->get_extruder_idx();
|
||||
|
||||
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
||||
|
@ -3675,7 +3588,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
//! combo->GetStringSelection().ToUTF8().data());
|
||||
|
||||
const std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
||||
Preset::remove_suffix_modified(combo->GetString(combo->GetSelection()).ToUTF8().data()));
|
||||
Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data()));
|
||||
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||
|
@ -3981,7 +3894,6 @@ bool Plater::priv::init_object_menu()
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
void Plater::priv::generate_thumbnail(ThumbnailData& data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background)
|
||||
{
|
||||
view3D->get_canvas3d()->render_thumbnail(data, w, h, printable_only, parts_only, show_bed, transparent_background);
|
||||
|
@ -3999,7 +3911,6 @@ void Plater::priv::generate_thumbnails(ThumbnailsList& thumbnails, const Vec2ds&
|
|||
thumbnails.pop_back();
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
|
||||
void Plater::priv::msw_rescale_object_menu()
|
||||
{
|
||||
|
@ -5128,13 +5039,9 @@ void Plater::export_3mf(const boost::filesystem::path& output_path)
|
|||
const std::string path_u8 = into_u8(path);
|
||||
wxBusyCursor wait;
|
||||
bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1";
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
ThumbnailData thumbnail_data;
|
||||
p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, false, true, true, true);
|
||||
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data)) {
|
||||
#else
|
||||
if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) {
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
// Success
|
||||
p->statusbar()->set_status_text(from_u8((boost::format(_utf8(L("3MF file exported to %s"))) % path).str()));
|
||||
p->set_project_filename(path);
|
||||
|
@ -5173,10 +5080,6 @@ void Plater::export_toolpaths_to_obj() const
|
|||
p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str());
|
||||
}
|
||||
|
||||
void Plater::hollow()
|
||||
{
|
||||
p->hollow();
|
||||
}
|
||||
|
||||
void Plater::reslice()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue