mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 10:11:10 -06:00
Fixed conflicts after merge with master
This commit is contained in:
commit
ac4d9ea172
86 changed files with 3385 additions and 2422 deletions
|
|
@ -278,6 +278,8 @@ template<class RawShape> class EdgeCache {
|
|||
|
||||
inline Vertex coords(const ContourCache& cache, double distance) const {
|
||||
assert(distance >= .0 && distance <= 1.0);
|
||||
if (cache.distances.empty() || cache.emap.empty()) return Vertex{};
|
||||
if (distance > 1.0) distance = std::fmod(distance, 1.0);
|
||||
|
||||
// distance is from 0.0 to 1.0, we scale it up to the full length of
|
||||
// the circumference
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
|||
if (surface.surface_type == stInternalVoid)
|
||||
has_internal_voids = true;
|
||||
else {
|
||||
FlowRole extrusion_role = (surface.surface_type == stTop) ? frTopSolidInfill : (surface.is_solid() ? frSolidInfill : frInfill);
|
||||
FlowRole extrusion_role = surface.is_top() ? frTopSolidInfill : (surface.is_solid() ? frSolidInfill : frInfill);
|
||||
bool is_bridge = layer.id() > 0 && surface.is_bridge();
|
||||
params.extruder = layerm.region()->extruder(extrusion_role);
|
||||
params.pattern = layerm.region()->config().fill_pattern.value;
|
||||
|
|
@ -132,7 +132,7 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
|||
is_bridge ?
|
||||
erBridgeInfill :
|
||||
(surface.is_solid() ?
|
||||
((surface.surface_type == stTop) ? erTopSolidInfill : erSolidInfill) :
|
||||
(surface.is_top() ? erTopSolidInfill : erSolidInfill) :
|
||||
erInternalInfill);
|
||||
params.bridge_angle = float(surface.bridge_angle);
|
||||
params.angle = float(Geometry::deg2rad(layerm.region()->config().fill_angle.value));
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ void GCodeAnalyzer::_processM106(const GCodeReader::GCodeLine& line)
|
|||
// The absence of P means the print cooling fan, so ignore anything else.
|
||||
float new_fan_speed;
|
||||
if (line.has_value('S', new_fan_speed))
|
||||
_set_fan_speed((100.0f / 256.0f) * new_fan_speed);
|
||||
_set_fan_speed((100.0f / 255.0f) * new_fan_speed);
|
||||
else
|
||||
_set_fan_speed(100.0f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
|
|||
// Voids are sparse infills if infill rate is zero.
|
||||
Polygons voids;
|
||||
for (const Surface &surface : this->fill_surfaces.surfaces) {
|
||||
if (surface.surface_type == stTop) {
|
||||
if (surface.is_top()) {
|
||||
// Collect the top surfaces, inflate them and trim them by the bottom surfaces.
|
||||
// This gives the priority to bottom surfaces.
|
||||
surfaces_append(top, offset_ex(surface.expolygon, margin, EXTERNAL_SURFACES_OFFSET_PARAMETERS), surface);
|
||||
|
|
@ -313,7 +313,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
|
|||
s2.clear();
|
||||
}
|
||||
}
|
||||
if (s1.surface_type == stTop)
|
||||
if (s1.is_top())
|
||||
// Trim the top surfaces by the bottom surfaces. This gives the priority to the bottom surfaces.
|
||||
polys = diff(polys, bottom_polygons);
|
||||
surfaces_append(
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
|
|||
} else if (
|
||||
opt_key == "skirts"
|
||||
|| opt_key == "skirt_height"
|
||||
|| opt_key == "draft_shield"
|
||||
|| opt_key == "skirt_distance"
|
||||
|| opt_key == "min_skirt_length"
|
||||
|| opt_key == "ooze_prevention"
|
||||
|
|
@ -1146,14 +1147,12 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
|||
|
||||
bool Print::has_infinite_skirt() const
|
||||
{
|
||||
return (m_config.skirt_height == -1 && m_config.skirts > 0)
|
||||
|| (m_config.ooze_prevention && this->extruders().size() > 1);
|
||||
return (m_config.draft_shield && m_config.skirts > 0) || (m_config.ooze_prevention && this->extruders().size() > 1);
|
||||
}
|
||||
|
||||
bool Print::has_skirt() const
|
||||
{
|
||||
return (m_config.skirt_height > 0 && m_config.skirts > 0)
|
||||
|| this->has_infinite_skirt();
|
||||
return (m_config.skirt_height > 0 && m_config.skirts > 0) || this->has_infinite_skirt();
|
||||
}
|
||||
|
||||
static inline bool sequential_print_horizontal_clearance_valid(const Print &print)
|
||||
|
|
|
|||
|
|
@ -1691,6 +1691,13 @@ void PrintConfigDef::init_fff_params()
|
|||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionInt(1));
|
||||
|
||||
def = this->add("draft_shield", coBool);
|
||||
def->label = L("Draft shield");
|
||||
def->tooltip = L("If enabled, the skirt will be as tall as a highest printed object. "
|
||||
"This is useful to protect an ABS or ASA print from warping and detaching from print bed due to wind draft.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("skirts", coInt);
|
||||
def->label = L("Loops (minimum)");
|
||||
def->full_label = L("Skirt Loops");
|
||||
|
|
@ -2998,6 +3005,11 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
} else if (opt_key == "support_material_pattern" && value == "pillars") {
|
||||
// Slic3r PE does not support the pillars. They never worked well.
|
||||
value = "rectilinear";
|
||||
} else if (opt_key == "skirt_height" && value == "-1") {
|
||||
// PrusaSlicer no more accepts skirt_height == -1 to print a draft shield to the top of the highest object.
|
||||
// A new "draft_shield" boolean config value is used instead.
|
||||
opt_key = "draft_shield";
|
||||
value = "1";
|
||||
} else if (opt_key == "octoprint_host") {
|
||||
opt_key = "print_host";
|
||||
} else if (opt_key == "octoprint_cafile") {
|
||||
|
|
@ -3206,7 +3218,7 @@ std::string FullPrintConfig::validate()
|
|||
return "Invalid value for --infill-every-layers";
|
||||
|
||||
// --skirt-height
|
||||
if (this->skirt_height < -1) // -1 means as tall as the object
|
||||
if (this->skirt_height < 0)
|
||||
return "Invalid value for --skirt-height";
|
||||
|
||||
// --bridge-flow-ratio
|
||||
|
|
|
|||
|
|
@ -800,6 +800,7 @@ public:
|
|||
ConfigOptionBools retract_layer_change;
|
||||
ConfigOptionFloat skirt_distance;
|
||||
ConfigOptionInt skirt_height;
|
||||
ConfigOptionBool draft_shield;
|
||||
ConfigOptionInt skirts;
|
||||
ConfigOptionInts slowdown_below_layer_time;
|
||||
ConfigOptionBool spiral_vase;
|
||||
|
|
@ -872,6 +873,7 @@ protected:
|
|||
OPT_PTR(retract_layer_change);
|
||||
OPT_PTR(skirt_distance);
|
||||
OPT_PTR(skirt_height);
|
||||
OPT_PTR(draft_shield);
|
||||
OPT_PTR(skirts);
|
||||
OPT_PTR(slowdown_below_layer_time);
|
||||
OPT_PTR(spiral_vase);
|
||||
|
|
|
|||
|
|
@ -817,11 +817,12 @@ void PrintObject::detect_surfaces_type()
|
|||
m_layers[idx_layer]->m_regions[idx_region]->slices.surfaces = std::move(surfaces_new[idx_layer]);
|
||||
}
|
||||
|
||||
if (spiral_vase && num_layers > 1) {
|
||||
// Turn the last bottom layer infill to a top infill, so it will be extruded with a proper pattern.
|
||||
Surfaces &surfaces = m_layers[num_layers - 1]->m_regions[idx_region]->slices.surfaces;
|
||||
for (Surface &surface : surfaces)
|
||||
surface.surface_type = stTop;
|
||||
if (spiral_vase) {
|
||||
if (num_layers > 1)
|
||||
// Turn the last bottom layer infill to a top infill, so it will be extruded with a proper pattern.
|
||||
m_layers[num_layers - 1]->m_regions[idx_region]->slices.set_type(stTop);
|
||||
for (size_t i = num_layers; i < m_layers.size(); ++ i)
|
||||
m_layers[i]->m_regions[idx_region]->slices.set_type(stInternal);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Detecting solid surfaces for region " << idx_region << " - clipping in parallel - start";
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ public:
|
|||
void remove_type(const SurfaceType type);
|
||||
void remove_types(const SurfaceType *types, int ntypes);
|
||||
void filter_by_type(SurfaceType type, Polygons* polygons);
|
||||
void set_type(SurfaceType type) {
|
||||
for (Surface &surface : this->surfaces)
|
||||
surface.surface_type = type;
|
||||
}
|
||||
|
||||
void clear() { surfaces.clear(); }
|
||||
bool empty() const { return surfaces.empty(); }
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@
|
|||
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG (0 && ENABLE_THUMBNAIL_GENERATOR)
|
||||
|
||||
|
||||
//==================
|
||||
//================
|
||||
// 2.2.0.rc1 techs
|
||||
//==================
|
||||
//================
|
||||
#define ENABLE_2_2_0_RC1 1
|
||||
|
||||
// Enable hack to remove crash when closing on OSX 10.9.5
|
||||
|
|
@ -56,6 +56,10 @@
|
|||
//============
|
||||
#define ENABLE_2_2_0 1
|
||||
|
||||
// Enable automatic switch to constrained camera when manipulating the scene using regular mouse
|
||||
// while 3D mouse is connected and free camera is not selected
|
||||
#define ENABLE_AUTO_CONSTRAINED_CAMERA (1 && ENABLE_2_2_0)
|
||||
|
||||
// Enable rendering of objects colored by facets' slope
|
||||
#define ENABLE_SLOPE_RENDERING (1 && ENABLE_2_2_0)
|
||||
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ void BackgroundSlicingProcess::process_fff()
|
|||
//FIXME localize the messages
|
||||
// Perform the final post-processing of the export path by applying the print statistics over the file name.
|
||||
std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path);
|
||||
bool with_check = GUI::wxGetApp().removable_drive_manager()->is_path_on_removable_drive(export_path);
|
||||
int copy_ret_val = copy_file(m_temp_output_path, export_path, with_check);
|
||||
int copy_ret_val = copy_file(m_temp_output_path, export_path, m_export_path_on_removable_media);
|
||||
switch (copy_ret_val) {
|
||||
case SUCCESS: break; // no error
|
||||
case FAIL_COPY_FILE:
|
||||
|
|
@ -402,7 +401,7 @@ void BackgroundSlicingProcess::set_task(const PrintBase::TaskParams ¶ms)
|
|||
}
|
||||
|
||||
// Set the output path of the G-code.
|
||||
void BackgroundSlicingProcess::schedule_export(const std::string &path)
|
||||
void BackgroundSlicingProcess::schedule_export(const std::string &path, bool export_path_on_removable_media)
|
||||
{
|
||||
assert(m_export_path.empty());
|
||||
if (! m_export_path.empty())
|
||||
|
|
@ -412,6 +411,7 @@ void BackgroundSlicingProcess::schedule_export(const std::string &path)
|
|||
tbb::mutex::scoped_lock lock(m_print->state_mutex());
|
||||
this->invalidate_step(bspsGCodeFinalize);
|
||||
m_export_path = path;
|
||||
m_export_path_on_removable_media = export_path_on_removable_media;
|
||||
}
|
||||
|
||||
void BackgroundSlicingProcess::schedule_upload(Slic3r::PrintHostJob upload_job)
|
||||
|
|
@ -432,6 +432,7 @@ void BackgroundSlicingProcess::reset_export()
|
|||
assert(! this->running());
|
||||
if (! this->running()) {
|
||||
m_export_path.clear();
|
||||
m_export_path_on_removable_media = false;
|
||||
// invalidate_step expects the mutex to be locked.
|
||||
tbb::mutex::scoped_lock lock(m_print->state_mutex());
|
||||
this->invalidate_step(bspsGCodeFinalize);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public:
|
|||
|
||||
// Set the export path of the G-code.
|
||||
// Once the path is set, the G-code
|
||||
void schedule_export(const std::string &path);
|
||||
void schedule_export(const std::string &path, bool export_path_on_removable_media);
|
||||
// Set print host upload job data to be enqueued to the PrintHostJobQueue
|
||||
// after current print slicing is complete
|
||||
void schedule_upload(Slic3r::PrintHostJob upload_job);
|
||||
|
|
@ -157,13 +157,14 @@ private:
|
|||
GCodePreviewData *m_gcode_preview_data = nullptr;
|
||||
#if ENABLE_THUMBNAIL_GENERATOR
|
||||
// Callback function, used to write thumbnails into gcode.
|
||||
ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr;
|
||||
ThumbnailsGeneratorCallback m_thumbnail_cb = nullptr;
|
||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
// Temporary G-code, there is one defined for the BackgroundSlicingProcess, differentiated from the other processes by a process ID.
|
||||
std::string m_temp_output_path;
|
||||
// Output path provided by the user. The output path may be set even if the slicing is running,
|
||||
// but once set, it cannot be re-set.
|
||||
std::string m_export_path;
|
||||
bool m_export_path_on_removable_media = false;
|
||||
// Print host upload job to schedule after slicing is complete, used by schedule_upload(),
|
||||
// empty by default (ie. no upload to schedule)
|
||||
PrintHostJob m_upload_job;
|
||||
|
|
|
|||
|
|
@ -268,8 +268,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
|
|||
"bridge_acceleration", "first_layer_acceleration" })
|
||||
toggle_field(el, have_default_acceleration);
|
||||
|
||||
bool have_skirt = config->opt_int("skirts") > 0 || config->opt_float("min_skirt_length") > 0;
|
||||
for (auto el : { "skirt_distance", "skirt_height" })
|
||||
bool have_skirt = config->opt_int("skirts") > 0;
|
||||
toggle_field("skirt_height", have_skirt && !config->opt_bool("draft_shield"));
|
||||
for (auto el : { "skirt_distance", "draft_shield", "min_skirt_length" })
|
||||
toggle_field(el, have_skirt);
|
||||
|
||||
bool have_brim = config->opt_float("brim_width") > 0;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
|
|||
|
||||
wxBitmap bitmap;
|
||||
int bitmap_width = 0;
|
||||
const wxString bitmap_file = GUI::from_u8(Slic3r::var((boost::format("printers/%1%_%2%.png") % vendor.id % model.id).str()));
|
||||
const wxString bitmap_file = GUI::from_u8(Slic3r::resources_dir() + "/profiles/" + vendor.id + "/" + model.id + "_thumbnail.png");
|
||||
if (wxFileExists(bitmap_file)) {
|
||||
bitmap.LoadFile(bitmap_file, wxBITMAP_TYPE_PNG);
|
||||
bitmap_width = bitmap.GetWidth();
|
||||
|
|
@ -450,7 +450,7 @@ PageWelcome::PageWelcome(ConfigWizard *parent)
|
|||
% _utf8(ConfigWizard::name())).str())
|
||||
))
|
||||
, cbox_reset(append(
|
||||
new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles - install from scratch (a snapshot will be taken beforehand)")))
|
||||
new wxCheckBox(this, wxID_ANY, _(L("Remove user profiles (a snapshot will be taken beforehand)")))
|
||||
))
|
||||
{
|
||||
welcome_text->Hide();
|
||||
|
|
@ -1473,12 +1473,41 @@ void ConfigWizard::priv::load_vendors()
|
|||
pair.second.preset_bundle->load_installed_printers(appconfig_new);
|
||||
}
|
||||
|
||||
if (app_config->has_section(AppConfig::SECTION_FILAMENTS)) {
|
||||
appconfig_new.set_section(AppConfig::SECTION_FILAMENTS, app_config->get_section(AppConfig::SECTION_FILAMENTS));
|
||||
}
|
||||
if (app_config->has_section(AppConfig::SECTION_MATERIALS)) {
|
||||
appconfig_new.set_section(AppConfig::SECTION_MATERIALS, app_config->get_section(AppConfig::SECTION_MATERIALS));
|
||||
}
|
||||
// Copy installed filaments and SLA material names from app_config to appconfig_new
|
||||
// while resolving current names of profiles, which were renamed in the meantime.
|
||||
for (PrinterTechnology technology : { ptFFF, ptSLA }) {
|
||||
const std::string §ion_name = (technology == ptFFF) ? AppConfig::SECTION_FILAMENTS : AppConfig::SECTION_MATERIALS;
|
||||
std::map<std::string, std::string> section_new;
|
||||
if (app_config->has_section(section_name)) {
|
||||
const std::map<std::string, std::string> §ion_old = app_config->get_section(section_name);
|
||||
for (const std::pair<std::string, std::string> &material_name_and_installed : section_old)
|
||||
if (material_name_and_installed.second == "1") {
|
||||
// Material is installed. Resolve it in bundles.
|
||||
size_t num_found = 0;
|
||||
const std::string &material_name = material_name_and_installed.first;
|
||||
for (auto &bundle : bundles) {
|
||||
const PresetCollection &materials = bundle.second.preset_bundle->materials(technology);
|
||||
const Preset *preset = materials.find_preset(material_name);
|
||||
if (preset == nullptr) {
|
||||
// Not found. Maybe the material preset is there, bu it was was renamed?
|
||||
const std::string *new_name = materials.get_preset_name_renamed(material_name);
|
||||
if (new_name != nullptr)
|
||||
preset = materials.find_preset(*new_name);
|
||||
}
|
||||
if (preset != nullptr) {
|
||||
// Materal preset was found, mark it as installed.
|
||||
section_new[preset->name] = "1";
|
||||
++ num_found;
|
||||
}
|
||||
}
|
||||
if (num_found == 0)
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Profile %1% was not found in installed vendor Preset Bundles.") % material_name;
|
||||
else if (num_found > 1)
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Profile %1% was found in %2% vendor Preset Bundles.") % material_name % num_found;
|
||||
}
|
||||
}
|
||||
appconfig_new.set_section(section_name, section_new);
|
||||
};
|
||||
}
|
||||
|
||||
void ConfigWizard::priv::add_page(ConfigWizardPage *page)
|
||||
|
|
@ -1642,9 +1671,9 @@ void ConfigWizard::priv::on_printer_pick(PagePrinters *page, const PrinterPicker
|
|||
}
|
||||
}
|
||||
|
||||
// if at list one printer is selected but there in no one selected material,
|
||||
// select materials which is default for selected printer(s)
|
||||
select_default_materials_if_needed(pair.second.vendor_profile, page->technology, evt.model_id);
|
||||
// When a printer model is picked, but there is no material installed compatible with this printer model,
|
||||
// install default materials for selected printer model silently.
|
||||
check_and_install_missing_materials(page->technology, evt.model_id);
|
||||
}
|
||||
|
||||
if (page->technology & T_FFF) {
|
||||
|
|
@ -1654,41 +1683,26 @@ void ConfigWizard::priv::on_printer_pick(PagePrinters *page, const PrinterPicker
|
|||
}
|
||||
}
|
||||
|
||||
void ConfigWizard::priv::select_default_materials_for_printer_model(const std::vector<VendorProfile::PrinterModel>& models, Technology technology, const std::string& model_id)
|
||||
void ConfigWizard::priv::select_default_materials_for_printer_model(const VendorProfile::PrinterModel &printer_model, Technology technology)
|
||||
{
|
||||
PageMaterials* page_materials = technology & T_FFF ? page_filaments : page_sla_materials;
|
||||
|
||||
auto it = std::find_if(models.begin(), models.end(), [model_id](VendorProfile::PrinterModel model) {return model_id == model.id; });
|
||||
if (it != models.end())
|
||||
for (const std::string& material : it->default_materials)
|
||||
appconfig_new.set(page_materials->materials->appconfig_section(), material, "1");
|
||||
for (const std::string& material : printer_model.default_materials)
|
||||
appconfig_new.set(page_materials->materials->appconfig_section(), material, "1");
|
||||
}
|
||||
|
||||
void ConfigWizard::priv::select_default_materials_if_needed(VendorProfile* vendor_profile, Technology technology, const std::string& model_id)
|
||||
void ConfigWizard::priv::select_default_materials_for_printer_models(Technology technology, const std::set<const VendorProfile::PrinterModel*> &printer_models)
|
||||
{
|
||||
if ((technology & T_FFF && !any_fff_selected) ||
|
||||
(technology & T_SLA && !any_sla_selected) ||
|
||||
check_materials_in_config(technology, false))
|
||||
return;
|
||||
PageMaterials *page_materials = technology & T_FFF ? page_filaments : page_sla_materials;
|
||||
const std::string &appconfig_section = page_materials->materials->appconfig_section();
|
||||
|
||||
select_default_materials_for_printer_model(vendor_profile->models, technology, model_id);
|
||||
}
|
||||
|
||||
void ConfigWizard::priv::selected_default_materials(Technology technology)
|
||||
{
|
||||
auto select_default_materials_for_printer_page = [this](PagePrinters * page_printers, Technology technology)
|
||||
auto select_default_materials_for_printer_page = [this, appconfig_section, printer_models](PagePrinters *page_printers, Technology technology)
|
||||
{
|
||||
std::set<std::string> selected_models = page_printers->get_selected_models();
|
||||
const std::string vendor_id = page_printers->get_vendor_id();
|
||||
|
||||
const std::string vendor_id = page_printers->get_vendor_id();
|
||||
for (auto& pair : bundles)
|
||||
{
|
||||
if (pair.first != vendor_id)
|
||||
continue;
|
||||
|
||||
for (const std::string& model_id : selected_models)
|
||||
select_default_materials_for_printer_model(pair.second.vendor_profile->models, technology, model_id);
|
||||
}
|
||||
if (pair.first == vendor_id)
|
||||
for (const VendorProfile::PrinterModel *printer_model : printer_models)
|
||||
for (const std::string &material : printer_model->default_materials)
|
||||
appconfig_new.set(appconfig_section, material, "1");
|
||||
};
|
||||
|
||||
PagePrinters* page_printers = technology & T_FFF ? page_fff : page_msla;
|
||||
|
|
@ -1702,7 +1716,7 @@ void ConfigWizard::priv::selected_default_materials(Technology technology)
|
|||
}
|
||||
|
||||
update_materials(technology);
|
||||
(technology& T_FFF ? page_filaments : page_sla_materials)->reload_presets();
|
||||
((technology & T_FFF) ? page_filaments : page_sla_materials)->reload_presets();
|
||||
}
|
||||
|
||||
void ConfigWizard::priv::on_3rdparty_install(const VendorProfile *vendor, bool install)
|
||||
|
|
@ -1743,51 +1757,105 @@ bool ConfigWizard::priv::on_bnt_finish()
|
|||
// theres no need to check that filament is selected if we have only custom printer
|
||||
if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true;
|
||||
// check, that there is selected at least one filament/material
|
||||
return check_materials_in_config(T_ANY);
|
||||
return check_and_install_missing_materials(T_ANY);
|
||||
}
|
||||
|
||||
bool ConfigWizard::priv::check_materials_in_config(Technology technology, bool show_info_msg)
|
||||
// This allmighty method verifies, whether there is at least a single compatible filament or SLA material installed
|
||||
// for each Printer preset of each Printer Model installed.
|
||||
//
|
||||
// In case only_for_model_id is set, then the test is done for that particular printer model only, and the default materials are installed silently.
|
||||
// Otherwise the user is quieried whether to install the missing default materials or not.
|
||||
//
|
||||
// Return true if the tested Printer Models already had materials installed.
|
||||
// Return false if there were some Printer Models with missing materials, independent from whether the defaults were installed for these
|
||||
// respective Printer Models or not.
|
||||
bool ConfigWizard::priv::check_and_install_missing_materials(Technology technology, const std::string &only_for_model_id)
|
||||
{
|
||||
const auto exist_preset = [this](const std::string& section, const Materials& materials)
|
||||
// Walk over all installed Printer presets and verify whether there is a filament or SLA material profile installed at the same PresetBundle,
|
||||
// which is compatible with it.
|
||||
const auto printer_models_missing_materials = [this, only_for_model_id](PrinterTechnology technology, const std::string §ion)
|
||||
{
|
||||
if (appconfig_new.has_section(section) &&
|
||||
!appconfig_new.get_section(section).empty())
|
||||
{
|
||||
const std::map<std::string, std::string>& appconfig_presets = appconfig_new.get_section(section);
|
||||
for (const auto& preset : appconfig_presets)
|
||||
if (materials.exist_preset(preset.first))
|
||||
return true;
|
||||
const std::map<std::string, std::string> &appconfig_presets = appconfig_new.has_section(section) ? appconfig_new.get_section(section) : std::map<std::string, std::string>();
|
||||
std::set<const VendorProfile::PrinterModel*> printer_models_without_material;
|
||||
for (const auto &pair : bundles) {
|
||||
const PresetCollection &materials = pair.second.preset_bundle->materials(technology);
|
||||
for (const auto &printer : pair.second.preset_bundle->printers) {
|
||||
if (printer.is_visible && printer.printer_technology() == technology) {
|
||||
const VendorProfile::PrinterModel *printer_model = PresetUtils::system_printer_model(printer);
|
||||
assert(printer_model != nullptr);
|
||||
if ((only_for_model_id.empty() || only_for_model_id == printer_model->id) &&
|
||||
printer_models_without_material.find(printer_model) == printer_models_without_material.end()) {
|
||||
bool has_material = false;
|
||||
for (const std::pair<std::string, std::string> &preset : appconfig_presets) {
|
||||
if (preset.second == "1") {
|
||||
const Preset *material = materials.find_preset(preset.first, false);
|
||||
if (material != nullptr && is_compatible_with_printer(PresetWithVendorProfile(*material, nullptr), PresetWithVendorProfile(printer, nullptr))) {
|
||||
has_material = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! has_material)
|
||||
printer_models_without_material.insert(printer_model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
assert(printer_models_without_material.empty() || only_for_model_id.empty() || only_for_model_id == (*printer_models_without_material.begin())->id);
|
||||
return printer_models_without_material;
|
||||
};
|
||||
|
||||
const auto ask_and_selected_default_materials = [this](wxString message, Technology technology)
|
||||
const auto ask_and_select_default_materials = [this](const wxString &message, const std::set<const VendorProfile::PrinterModel*> &printer_models, Technology technology)
|
||||
{
|
||||
wxMessageDialog msg(q, message, _(L("Notice")), wxYES_NO);
|
||||
if (msg.ShowModal() == wxID_YES)
|
||||
selected_default_materials(technology);
|
||||
select_default_materials_for_printer_models(technology, printer_models);
|
||||
};
|
||||
|
||||
if (any_fff_selected && technology & T_FFF && !exist_preset(AppConfig::SECTION_FILAMENTS, filaments))
|
||||
{
|
||||
if (show_info_msg)
|
||||
{
|
||||
wxString message = _(L("You have to select at least one filament for selected printers")) + "\n\n\t" +
|
||||
_(L("Do you want to automatic select default filaments?"));
|
||||
ask_and_selected_default_materials(message, T_FFF);
|
||||
const auto printer_model_list = [](const std::set<const VendorProfile::PrinterModel*> &printer_models) -> wxString {
|
||||
wxString out;
|
||||
for (const VendorProfile::PrinterModel *printer_model : printer_models) {
|
||||
out += "\t\t";
|
||||
out += from_u8(printer_model->name);
|
||||
out += "\n";
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
if (any_fff_selected && (technology & T_FFF)) {
|
||||
std::set<const VendorProfile::PrinterModel*> printer_models_without_material = printer_models_missing_materials(ptFFF, AppConfig::SECTION_FILAMENTS);
|
||||
if (! printer_models_without_material.empty()) {
|
||||
if (only_for_model_id.empty())
|
||||
ask_and_select_default_materials(
|
||||
_L("The following FFF printer models have no filament selected:") +
|
||||
"\n\n\t" +
|
||||
printer_model_list(printer_models_without_material) +
|
||||
"\n\n\t" +
|
||||
_L("Do you want to select default filaments for these FFF printer models?"),
|
||||
printer_models_without_material,
|
||||
T_FFF);
|
||||
else
|
||||
select_default_materials_for_printer_model(**printer_models_without_material.begin(), T_FFF);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (any_sla_selected && technology & T_SLA && !exist_preset(AppConfig::SECTION_MATERIALS, sla_materials))
|
||||
{
|
||||
if (show_info_msg)
|
||||
{
|
||||
wxString message = _(L("You have to select at least one material for selected printers")) + "\n\n\t" +
|
||||
_(L("Do you want to automatic select default materials?"));
|
||||
ask_and_selected_default_materials(message, T_SLA);
|
||||
}
|
||||
return false;
|
||||
if (any_sla_selected && (technology & T_SLA)) {
|
||||
std::set<const VendorProfile::PrinterModel*> printer_models_without_material = printer_models_missing_materials(ptSLA, AppConfig::SECTION_MATERIALS);
|
||||
if (! printer_models_without_material.empty()) {
|
||||
if (only_for_model_id.empty())
|
||||
ask_and_select_default_materials(
|
||||
_L("The following SLA printer models have no materials selected:") +
|
||||
"\n\n\t" +
|
||||
printer_model_list(printer_models_without_material) +
|
||||
"\n\n\t" +
|
||||
_L("Do you want to select default SLA materials for these printer models?"),
|
||||
printer_models_without_material,
|
||||
T_SLA);
|
||||
else
|
||||
select_default_materials_for_printer_model(**printer_models_without_material.begin(), T_SLA);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -2062,8 +2130,11 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
|
|||
{
|
||||
// check, that there is selected at least one filament/material
|
||||
ConfigWizardPage* active_page = this->p->index->active_page();
|
||||
if ( (active_page == p->page_filaments || active_page == p->page_sla_materials)
|
||||
&& !p->check_materials_in_config(dynamic_cast<PageMaterials*>(active_page)->materials->technology))
|
||||
if (// Leaving the filaments or SLA materials page and
|
||||
(active_page == p->page_filaments || active_page == p->page_sla_materials) &&
|
||||
// some Printer models had no filament or SLA material selected.
|
||||
! p->check_and_install_missing_materials(dynamic_cast<PageMaterials*>(active_page)->materials->technology))
|
||||
// In that case don't leave the page and the function above queried the user whether to install default materials.
|
||||
return;
|
||||
this->p->index->go_next();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -82,14 +82,6 @@ struct Materials
|
|||
}
|
||||
}
|
||||
|
||||
bool exist_preset(const std::string& preset_name) const
|
||||
{
|
||||
for (const Preset* preset : presets)
|
||||
if (preset->name == preset_name)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static const std::string UNKNOWN;
|
||||
static const std::string& get_filament_type(const Preset *preset);
|
||||
static const std::string& get_filament_vendor(const Preset *preset);
|
||||
|
|
@ -503,17 +495,12 @@ struct ConfigWizard::priv
|
|||
|
||||
void on_custom_setup(const bool custom_wanted);
|
||||
void on_printer_pick(PagePrinters *page, const PrinterPickerEvent &evt);
|
||||
void select_default_materials_for_printer_model(const std::vector<VendorProfile::PrinterModel> &models,
|
||||
Technology technology,
|
||||
const std::string & model_id);
|
||||
void select_default_materials_if_needed(VendorProfile* vendor_profile,
|
||||
Technology technology,
|
||||
const std::string &model_id);
|
||||
void selected_default_materials(Technology technology);
|
||||
void select_default_materials_for_printer_model(const VendorProfile::PrinterModel &printer_model, Technology technology);
|
||||
void select_default_materials_for_printer_models(Technology technology, const std::set<const VendorProfile::PrinterModel*> &printer_models);
|
||||
void on_3rdparty_install(const VendorProfile *vendor, bool install);
|
||||
|
||||
bool on_bnt_finish();
|
||||
bool check_materials_in_config(Technology technology, bool show_info_msg = true);
|
||||
bool check_and_install_missing_materials(Technology technology, const std::string &only_for_model_id = std::string());
|
||||
void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater);
|
||||
// #ys_FIXME_alise
|
||||
void update_presets_in_config(const std::string& section, const std::string& alias_key, bool add);
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
|
|||
if (it != m_warnings.end()) // this warning is already set to be shown
|
||||
return;
|
||||
|
||||
m_warnings.push_back(warning);
|
||||
m_warnings.emplace_back(warning);
|
||||
std::sort(m_warnings.begin(), m_warnings.end());
|
||||
}
|
||||
else {
|
||||
|
|
@ -1289,7 +1289,7 @@ void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_
|
|||
if (model_object->instances.size() > 1)
|
||||
owner.label += " (" + std::to_string(inst_idx + 1) + ")";
|
||||
owner.selected = volume->selected;
|
||||
owners.push_back(owner);
|
||||
owners.emplace_back(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2093,7 +2093,7 @@ std::vector<int> GLCanvas3D::load_object(const ModelObject& model_object, int ob
|
|||
{
|
||||
for (unsigned int i = 0; i < model_object.instances.size(); ++i)
|
||||
{
|
||||
instance_idxs.push_back(i);
|
||||
instance_idxs.emplace_back(i);
|
||||
}
|
||||
}
|
||||
return m_volumes.load_object(&model_object, obj_idx, instance_idxs, m_color_by, m_initialized);
|
||||
|
|
@ -2533,9 +2533,9 @@ static void load_gcode_retractions(const GCodePreviewData::Retraction& retractio
|
|||
|
||||
for (const GCodePreviewData::Retraction::Position& position : copy)
|
||||
{
|
||||
volume->print_zs.push_back(unscale<double>(position.position(2)));
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
volume->print_zs.emplace_back(unscale<double>(position.position(2)));
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::point3_to_verts(position.position, position.width, position.height, *volume);
|
||||
|
||||
|
|
@ -3541,11 +3541,26 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
if (m_hover_volume_idxs.empty() && m_mouse.is_start_position_3D_defined())
|
||||
{
|
||||
const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.);
|
||||
#if ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
if (wxGetApp().app_config->get("use_free_camera") == "1")
|
||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||
m_camera.rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
else
|
||||
{
|
||||
// Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation.
|
||||
// It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(),
|
||||
// which checks an atomics (flushes CPU caches).
|
||||
// See GH issue #3816.
|
||||
m_camera.recover_from_free_camera();
|
||||
m_camera.rotate_on_sphere(rot.x(), rot.y(), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
}
|
||||
#else
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
// Virtual track ball (similar to the 3DConnexion mouse).
|
||||
m_camera.rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.));
|
||||
else
|
||||
m_camera.rotate_on_sphere(rot.x(), rot.y(), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
|
||||
#endif // ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -3560,6 +3575,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
float z = 0.0f;
|
||||
const Vec3d& cur_pos = _mouse_to_3d(pos, &z);
|
||||
Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z);
|
||||
#if ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
if (wxGetApp().app_config->get("use_free_camera") != "1")
|
||||
// Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation.
|
||||
// It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(),
|
||||
// which checks an atomics (flushes CPU caches).
|
||||
// See GH issue #3816.
|
||||
m_camera.recover_from_free_camera();
|
||||
#endif // ENABLE_AUTO_CONSTRAINED_CAMERA
|
||||
|
||||
m_camera.set_target(m_camera.get_target() + orig - cur_pos);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -4184,7 +4208,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
|
|||
if (!vol->is_modifier && !vol->is_wipe_tower && (!parts_only || (vol->composite_id.volume_id >= 0)))
|
||||
{
|
||||
if (!printable_only || is_visible(*vol))
|
||||
visible_volumes.push_back(vol);
|
||||
visible_volumes.emplace_back(vol);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4888,7 +4912,7 @@ void GLCanvas3D::_picking_pass() const
|
|||
}
|
||||
if ((0 <= volume_id) && (volume_id < (int)m_volumes.volumes.size()))
|
||||
{
|
||||
m_hover_volume_idxs.push_back(volume_id);
|
||||
m_hover_volume_idxs.emplace_back(volume_id);
|
||||
m_gizmos.set_hover_id(-1);
|
||||
}
|
||||
else
|
||||
|
|
@ -5132,7 +5156,7 @@ void GLCanvas3D::_render_overlays() const
|
|||
if (sequential_print) {
|
||||
for (ModelObject* model_object : m_model->objects)
|
||||
for (ModelInstance* model_instance : model_object->instances) {
|
||||
sorted_instances.push_back(model_instance);
|
||||
sorted_instances.emplace_back(model_instance);
|
||||
}
|
||||
}
|
||||
m_labels.render(sorted_instances);
|
||||
|
|
@ -5594,29 +5618,26 @@ void GLCanvas3D::_load_print_toolpaths()
|
|||
if ((skirt_height == 0) && (print->config().brim_width.value > 0))
|
||||
skirt_height = 1;
|
||||
|
||||
// get first skirt_height layers (maybe this should be moved to a PrintObject method?)
|
||||
const PrintObject* object0 = print->objects().front();
|
||||
// Get first skirt_height layers.
|
||||
//FIXME This code is fishy. It may not work for multiple objects with different layering due to variable layer height feature.
|
||||
// This is not critical as this is just an initial preview.
|
||||
const PrintObject* highest_object = *std::max_element(print->objects().begin(), print->objects().end(), [](auto l, auto r){ return l->layers().size() < r->layers().size(); });
|
||||
std::vector<float> print_zs;
|
||||
print_zs.reserve(skirt_height * 2);
|
||||
for (size_t i = 0; i < std::min(skirt_height, object0->layers().size()); ++i)
|
||||
{
|
||||
print_zs.push_back(float(object0->layers()[i]->print_z));
|
||||
}
|
||||
//FIXME why there are support layers?
|
||||
for (size_t i = 0; i < std::min(skirt_height, object0->support_layers().size()); ++i)
|
||||
{
|
||||
print_zs.push_back(float(object0->support_layers()[i]->print_z));
|
||||
}
|
||||
for (size_t i = 0; i < std::min(skirt_height, highest_object->layers().size()); ++ i)
|
||||
print_zs.emplace_back(float(highest_object->layers()[i]->print_z));
|
||||
// Only add skirt for the raft layers.
|
||||
for (size_t i = 0; i < std::min(skirt_height, std::min(highest_object->slicing_parameters().raft_layers(), highest_object->support_layers().size())); ++ i)
|
||||
print_zs.emplace_back(float(highest_object->support_layers()[i]->print_z));
|
||||
sort_remove_duplicates(print_zs);
|
||||
if (print_zs.size() > skirt_height)
|
||||
print_zs.erase(print_zs.begin() + skirt_height, print_zs.end());
|
||||
|
||||
skirt_height = std::min(skirt_height, print_zs.size());
|
||||
print_zs.erase(print_zs.begin() + skirt_height, print_zs.end());
|
||||
|
||||
GLVolume *volume = m_volumes.new_toolpath_volume(color, VERTEX_BUFFER_RESERVE_SIZE);
|
||||
for (size_t i = 0; i < skirt_height; ++i) {
|
||||
volume->print_zs.push_back(print_zs[i]);
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.push_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
for (size_t i = 0; i < skirt_height; ++ i) {
|
||||
volume->print_zs.emplace_back(print_zs[i]);
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.quad_indices.size());
|
||||
volume->offsets.emplace_back(volume->indexed_vertex_array.triangle_indices.size());
|
||||
if (i == 0)
|
||||
_3DScene::extrusionentity_to_verts(print->brim(), print_zs[i], Point(0, 0), *volume);
|
||||
_3DScene::extrusionentity_to_verts(print->skirt(), print_zs[i], Point(0, 0), *volume);
|
||||
|
|
@ -5782,10 +5803,10 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
}
|
||||
if (ctxt.has_perimeters || ctxt.has_infill)
|
||||
for (const Layer *layer : print_object.layers())
|
||||
ctxt.layers.push_back(layer);
|
||||
ctxt.layers.emplace_back(layer);
|
||||
if (ctxt.has_support)
|
||||
for (const Layer *layer : print_object.support_layers())
|
||||
ctxt.layers.push_back(layer);
|
||||
ctxt.layers.emplace_back(layer);
|
||||
std::sort(ctxt.layers.begin(), ctxt.layers.end(), [](const Layer *l1, const Layer *l2) { return l1->print_z < l2->print_z; });
|
||||
|
||||
// Maximum size of an allocation block: 32MB / sizeof(float)
|
||||
|
|
@ -5854,9 +5875,9 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
|
|||
|
||||
for (GLVolume *vol : vols)
|
||||
if (vol->print_zs.empty() || vol->print_zs.back() != layer->print_z) {
|
||||
vol->print_zs.push_back(layer->print_z);
|
||||
vol->offsets.push_back(vol->indexed_vertex_array.quad_indices.size());
|
||||
vol->offsets.push_back(vol->indexed_vertex_array.triangle_indices.size());
|
||||
vol->print_zs.emplace_back(layer->print_z);
|
||||
vol->offsets.emplace_back(vol->indexed_vertex_array.quad_indices.size());
|
||||
vol->offsets.emplace_back(vol->indexed_vertex_array.triangle_indices.size());
|
||||
}
|
||||
for (const PrintInstance &instance : *ctxt.shifted_copies) {
|
||||
const Point © = instance.shift;
|
||||
|
|
@ -6012,9 +6033,9 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const std::vector<std::string>& str_
|
|||
for (size_t i = 0; i < vols.size(); ++i) {
|
||||
GLVolume &vol = *vols[i];
|
||||
if (vol.print_zs.empty() || vol.print_zs.back() != layer.front().print_z) {
|
||||
vol.print_zs.push_back(layer.front().print_z);
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(layer.front().print_z);
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
}
|
||||
}
|
||||
for (const WipeTower::ToolChangeResult &extrusions : layer) {
|
||||
|
|
@ -6227,9 +6248,9 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
|
|||
assert(it_filter != filters.end() && key.first == it_filter->first);
|
||||
|
||||
GLVolume& vol = *it_filter->second;
|
||||
vol.print_zs.push_back(layer.z);
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(layer.z);
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::extrusionentity_to_verts(path.polyline, path.width, path.height, layer.z, vol);
|
||||
}
|
||||
|
|
@ -6301,9 +6322,9 @@ inline void travel_paths_internal(
|
|||
assert(it != by_type.end() && it->first == func_value(polyline));
|
||||
|
||||
GLVolume& vol = *it->second;
|
||||
vol.print_zs.push_back(unscale<double>(polyline.polyline.bounding_box().min(2)));
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.push_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
vol.print_zs.emplace_back(unscale<double>(polyline.polyline.bounding_box().min(2)));
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.quad_indices.size());
|
||||
vol.offsets.emplace_back(vol.indexed_vertex_array.triangle_indices.size());
|
||||
|
||||
_3DScene::polyline3_to_verts(polyline.polyline, preview_data.travel.width, preview_data.travel.height, vol);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/nowide/convert.hpp>
|
||||
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/imagpng.h>
|
||||
|
|
@ -50,6 +51,7 @@
|
|||
|
||||
#ifdef __WXMSW__
|
||||
#include <Shlobj.h>
|
||||
#include <dbt.h>
|
||||
#endif // __WXMSW__
|
||||
|
||||
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG
|
||||
|
|
@ -60,6 +62,7 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class MainFrame;
|
||||
|
||||
wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
||||
{
|
||||
|
|
@ -96,9 +99,9 @@ wxString file_wildcards(FileType file_type, const std::string &custom_extension)
|
|||
|
||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str().data(); }
|
||||
|
||||
static void register_dpi_event()
|
||||
{
|
||||
#ifdef WIN32
|
||||
static void register_win32_dpi_event()
|
||||
{
|
||||
enum { WM_DPICHANGED_ = 0x02e0 };
|
||||
|
||||
wxWindow::MSWRegisterMessageHandler(WM_DPICHANGED_, [](wxWindow *win, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) {
|
||||
|
|
@ -111,9 +114,52 @@ static void register_dpi_event()
|
|||
|
||||
return true;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
|
||||
|
||||
static void register_win32_device_notification_event()
|
||||
{
|
||||
enum { WM_DPICHANGED_ = 0x02e0 };
|
||||
|
||||
wxWindow::MSWRegisterMessageHandler(WM_DEVICECHANGE, [](wxWindow *win, WXUINT /* nMsg */, WXWPARAM wParam, WXLPARAM lParam) {
|
||||
// Some messages are sent to top level windows by default, some messages are sent to only registered windows, and we explictely register on MainFrame only.
|
||||
auto main_frame = dynamic_cast<MainFrame*>(win);
|
||||
auto plater = (main_frame == nullptr) ? nullptr : main_frame->plater();
|
||||
if (plater == nullptr)
|
||||
// Maybe some other top level window like a dialog or maybe a pop-up menu?
|
||||
return true;
|
||||
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lParam;
|
||||
switch (wParam) {
|
||||
case DBT_DEVICEARRIVAL:
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
||||
plater->GetEventHandler()->AddPendingEvent(VolumeAttachedEvent(EVT_VOLUME_ATTACHED));
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
|
||||
PDEV_BROADCAST_DEVICEINTERFACE lpdbi = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;
|
||||
// if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_VOLUME) {
|
||||
// printf("DBT_DEVICEARRIVAL %d - Media has arrived: %ws\n", msg_count, lpdbi->dbcc_name);
|
||||
if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_HID)
|
||||
plater->GetEventHandler()->AddPendingEvent(HIDDeviceAttachedEvent(EVT_HID_DEVICE_ATTACHED, boost::nowide::narrow(lpdbi->dbcc_name)));
|
||||
}
|
||||
break;
|
||||
case DBT_DEVICEREMOVECOMPLETE:
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
||||
plater->GetEventHandler()->AddPendingEvent(VolumeDetachedEvent(EVT_VOLUME_DETACHED));
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
|
||||
PDEV_BROADCAST_DEVICEINTERFACE lpdbi = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;
|
||||
// if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_VOLUME)
|
||||
// printf("DBT_DEVICEARRIVAL %d - Media was removed: %ws\n", msg_count, lpdbi->dbcc_name);
|
||||
if (lpdbi->dbcc_classguid == GUID_DEVINTERFACE_HID)
|
||||
plater->GetEventHandler()->AddPendingEvent(HIDDeviceDetachedEvent(EVT_HID_DEVICE_DETACHED, boost::nowide::narrow(lpdbi->dbcc_name)));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
static void generic_exception_handle()
|
||||
{
|
||||
|
|
@ -248,7 +294,10 @@ bool GUI_App::on_init_inner()
|
|||
show_error(nullptr, ex.what());
|
||||
}
|
||||
|
||||
register_dpi_event();
|
||||
#ifdef WIN32
|
||||
register_win32_dpi_event();
|
||||
register_win32_device_notification_event();
|
||||
#endif // WIN32
|
||||
|
||||
// Let the libslic3r know the callback, which will translate messages on demand.
|
||||
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
||||
|
|
|
|||
|
|
@ -156,8 +156,11 @@ void ObjectLayers::create_layers_list()
|
|||
const t_layer_height_range& range = layer.first;
|
||||
auto del_btn = new PlusMinusButton(m_parent, m_bmp_delete, range);
|
||||
del_btn->SetToolTip(_(L("Remove layer range")));
|
||||
|
||||
auto add_btn = new PlusMinusButton(m_parent, m_bmp_add, range);
|
||||
add_btn->SetToolTip(_(L("Add layer range")));
|
||||
wxString tooltip = wxGetApp().obj_list()->can_add_new_range_after_current(range);
|
||||
add_btn->SetToolTip(tooltip.IsEmpty() ? _(L("Add layer range")) : tooltip);
|
||||
add_btn->Enable(tooltip.IsEmpty());
|
||||
|
||||
auto sizer = create_layer(range, del_btn, add_btn);
|
||||
sizer->Add(del_btn, 0, wxRIGHT | wxLEFT, em_unit(m_parent));
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
// detect the current mouse position here, to pass it to list_manipulation() method
|
||||
// if we detect it later, the user may have moved the mouse pointer while calculations are performed, and this would mess-up the HitTest() call performed into list_manipulation()
|
||||
// see: https://github.com/prusa3d/PrusaSlicer/issues/3802
|
||||
const wxPoint mouse_pos = get_mouse_position_in_control();
|
||||
const wxPoint mouse_pos = this->get_mouse_position_in_control();
|
||||
|
||||
#ifndef __APPLE__
|
||||
// On Windows and Linux, forces a kill focus emulation on the object manipulator fields because this event handler is called
|
||||
|
|
@ -155,7 +155,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
||||
wxDataViewItem item;
|
||||
wxDataViewColumn *col;
|
||||
this->HitTest(get_mouse_position_in_control(), item, col);
|
||||
this->HitTest(this->get_mouse_position_in_control(), item, col);
|
||||
new_selected_column = (col == nullptr) ? -1 : (int)col->GetModelColumn();
|
||||
if (new_selected_item == m_last_selected_item && m_last_selected_column != -1 && m_last_selected_column != new_selected_column) {
|
||||
// Mouse clicked on another column of the active row. Simulate keyboard enter to enter the editing mode of the current column.
|
||||
|
|
@ -171,7 +171,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
|
||||
selection_changed();
|
||||
#ifndef __WXMSW__
|
||||
set_tooltip_for_item(get_mouse_position_in_control());
|
||||
set_tooltip_for_item(this->get_mouse_position_in_control());
|
||||
#endif //__WXMSW__
|
||||
|
||||
#ifndef __WXOSX__
|
||||
|
|
@ -211,7 +211,7 @@ ObjectList::ObjectList(wxWindow* parent) :
|
|||
|
||||
#ifdef __WXMSW__
|
||||
GetMainWindow()->Bind(wxEVT_MOTION, [this](wxMouseEvent& event) {
|
||||
set_tooltip_for_item(get_mouse_position_in_control());
|
||||
set_tooltip_for_item(this->get_mouse_position_in_control());
|
||||
event.Skip();
|
||||
});
|
||||
#endif //__WXMSW__
|
||||
|
|
@ -419,14 +419,6 @@ void ObjectList::set_tooltip_for_item(const wxPoint& pt)
|
|||
GetMainWindow()->SetToolTip(tooltip);
|
||||
}
|
||||
|
||||
wxPoint ObjectList::get_mouse_position_in_control()
|
||||
{
|
||||
const wxPoint& pt = wxGetMousePosition();
|
||||
// wxWindow* win = GetMainWindow();
|
||||
// wxPoint screen_pos = win->GetScreenPosition();
|
||||
return wxPoint(pt.x - /*win->*/GetScreenPosition().x, pt.y - /*win->*/GetScreenPosition().y);
|
||||
}
|
||||
|
||||
int ObjectList::get_selected_obj_idx() const
|
||||
{
|
||||
if (GetSelectedItemsCount() == 1)
|
||||
|
|
@ -792,13 +784,7 @@ void ObjectList::OnChar(wxKeyEvent& event)
|
|||
void ObjectList::OnContextMenu(wxDataViewEvent& evt)
|
||||
{
|
||||
// The mouse position returned by get_mouse_position_in_control() here is the one at the time the mouse button is released (mouse up event)
|
||||
wxPoint mouse_pos = get_mouse_position_in_control();
|
||||
|
||||
// We check if the mouse down event was over the "Editing" column, if not, we change the mouse position so that the following call to list_simulation() does not show any context menu
|
||||
// see: https://github.com/prusa3d/PrusaSlicer/issues/3802
|
||||
wxDataViewColumn* column = evt.GetDataViewColumn();
|
||||
if (column == nullptr || column->GetTitle() != _("Editing"))
|
||||
mouse_pos.x = 0;
|
||||
wxPoint mouse_pos = this->get_mouse_position_in_control();
|
||||
|
||||
// Do not show the context menu if the user pressed the right mouse button on the 3D scene and released it on the objects list
|
||||
GLCanvas3D* canvas = wxGetApp().plater()->canvas3D();
|
||||
|
|
@ -811,6 +797,12 @@ void ObjectList::OnContextMenu(wxDataViewEvent& evt)
|
|||
|
||||
void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_menu/* = false*/)
|
||||
{
|
||||
// Interesting fact: when mouse_pos.x < 0, HitTest(mouse_pos, item, col) returns item = null, but column = last column.
|
||||
// So, when mouse was moved to scene immediately after clicking in ObjectList, in the scene will be shown context menu for the Editing column.
|
||||
// see: https://github.com/prusa3d/PrusaSlicer/issues/3802
|
||||
if (mouse_pos.x < 0)
|
||||
return;
|
||||
|
||||
wxDataViewItem item;
|
||||
wxDataViewColumn* col = nullptr;
|
||||
HitTest(mouse_pos, item, col);
|
||||
|
|
@ -925,7 +917,7 @@ void ObjectList::extruder_editing()
|
|||
|
||||
const int column_width = GetColumn(colExtruder)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
|
||||
|
||||
wxPoint pos = get_mouse_position_in_control();
|
||||
wxPoint pos = this->get_mouse_position_in_control();
|
||||
wxSize size = wxSize(column_width, -1);
|
||||
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
|
||||
pos.y -= GetTextExtent("m").y;
|
||||
|
|
@ -2880,13 +2872,13 @@ void ObjectList::del_layer_range(const t_layer_height_range& range)
|
|||
static double get_min_layer_height(const int extruder_idx)
|
||||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
return config.opt_float("min_layer_height", extruder_idx <= 0 ? 0 : extruder_idx-1);
|
||||
return config.opt_float("min_layer_height", std::max(0, extruder_idx - 1));
|
||||
}
|
||||
|
||||
static double get_max_layer_height(const int extruder_idx)
|
||||
{
|
||||
const DynamicPrintConfig& config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
int extruder_idx_zero_based = extruder_idx <= 0 ? 0 : extruder_idx-1;
|
||||
int extruder_idx_zero_based = std::max(0, extruder_idx - 1);
|
||||
double max_layer_height = config.opt_float("max_layer_height", extruder_idx_zero_based);
|
||||
|
||||
// In case max_layer_height is set to zero, it should default to 75 % of nozzle diameter:
|
||||
|
|
@ -2896,9 +2888,11 @@ static double get_max_layer_height(const int extruder_idx)
|
|||
return max_layer_height;
|
||||
}
|
||||
|
||||
// When editing this function, please synchronize the conditions with can_add_new_range_after_current().
|
||||
void ObjectList::add_layer_range_after_current(const t_layer_height_range current_range)
|
||||
{
|
||||
const int obj_idx = get_selected_obj_idx();
|
||||
assert(obj_idx >= 0);
|
||||
if (obj_idx < 0)
|
||||
// This should not happen.
|
||||
return;
|
||||
|
|
@ -2932,12 +2926,18 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
{
|
||||
if (current_range.second == next_range.first)
|
||||
{
|
||||
// Splitting the currnet layer heigth range to two.
|
||||
// Splitting the next layer height range to two.
|
||||
const auto old_config = ranges.at(next_range);
|
||||
const coordf_t delta = (next_range.second - next_range.first);
|
||||
if (delta >= get_min_layer_height(old_config.opt_int("extruder"))/*0.05f*/) {
|
||||
const coordf_t midl_layer = next_range.first + 0.5 * delta;
|
||||
t_layer_height_range new_range = { midl_layer, next_range.second };
|
||||
const coordf_t delta = next_range.second - next_range.first;
|
||||
// Layer height of the current layer.
|
||||
const coordf_t old_min_layer_height = get_min_layer_height(old_config.opt_int("extruder"));
|
||||
// Layer height of the layer to be inserted.
|
||||
const coordf_t new_min_layer_height = get_min_layer_height(0);
|
||||
if (delta >= old_min_layer_height + new_min_layer_height - EPSILON) {
|
||||
const coordf_t middle_layer_z = (new_min_layer_height > 0.5 * delta) ?
|
||||
next_range.second - new_min_layer_height :
|
||||
next_range.first + std::max(old_min_layer_height, 0.5 * delta);
|
||||
t_layer_height_range new_range = { middle_layer_z, next_range.second };
|
||||
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Add Height Range")));
|
||||
changed = true;
|
||||
|
|
@ -2951,12 +2951,12 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
ranges[new_range] = old_config;
|
||||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
|
||||
new_range = { current_range.second, midl_layer };
|
||||
new_range = { current_range.second, middle_layer_z };
|
||||
ranges[new_range] = get_default_layer_config(obj_idx);
|
||||
add_layer_item(new_range, layers_item, layer_idx);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (next_range.first - current_range.second >= get_min_layer_height(0) - EPSILON)
|
||||
{
|
||||
// Filling in a gap between the current and a new layer height range with a new one.
|
||||
take_snapshot(_(L("Add Height Range")));
|
||||
|
|
@ -2978,6 +2978,49 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range curren
|
|||
select_item(layers_item);
|
||||
}
|
||||
|
||||
// Returning an empty string means that the layer could be added after the current layer.
|
||||
// Otherwise an error tooltip is returned.
|
||||
// When editing this function, please synchronize the conditions with add_layer_range_after_current().
|
||||
wxString ObjectList::can_add_new_range_after_current(const t_layer_height_range current_range)
|
||||
{
|
||||
const int obj_idx = get_selected_obj_idx();
|
||||
assert(obj_idx >= 0);
|
||||
if (obj_idx < 0)
|
||||
// This should not happen.
|
||||
return "ObjectList assert";
|
||||
|
||||
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
|
||||
auto it_range = ranges.find(current_range);
|
||||
assert(it_range != ranges.end());
|
||||
if (it_range == ranges.end())
|
||||
// This shoudl not happen.
|
||||
return "ObjectList assert";
|
||||
|
||||
auto it_next_range = it_range;
|
||||
if (++ it_next_range == ranges.end())
|
||||
// Adding a layer after the last layer is always possible.
|
||||
return "";
|
||||
|
||||
if (const std::pair<coordf_t, coordf_t>& next_range = it_next_range->first; current_range.second <= next_range.first)
|
||||
{
|
||||
if (current_range.second == next_range.first) {
|
||||
if (next_range.second - next_range.first < get_min_layer_height(it_next_range->second.opt_int("extruder")) + get_min_layer_height(0) - EPSILON)
|
||||
return _(L("Cannot insert a new layer range after the current layer range.\n"
|
||||
"The next layer range is too thin to be split to two\n"
|
||||
"without violating the minimum layer height."));
|
||||
} else if (next_range.first - current_range.second < get_min_layer_height(0) - EPSILON) {
|
||||
return _(L("Cannot insert a new layer range between the current and the next layer range.\n"
|
||||
"The gap between the current layer range and the next layer range\n"
|
||||
"is thinner than the minimum layer height allowed."));
|
||||
}
|
||||
} else
|
||||
return _(L("Cannot insert a new layer range after the current layer range.\n"
|
||||
"Current layer range overlaps with the next layer range."));
|
||||
|
||||
// All right, new layer height range could be inserted.
|
||||
return "";
|
||||
}
|
||||
|
||||
void ObjectList::add_layer_item(const t_layer_height_range& range,
|
||||
const wxDataViewItem layers_item,
|
||||
const int layer_idx /* = -1*/)
|
||||
|
|
@ -3048,12 +3091,10 @@ bool ObjectList::edit_layer_range(const t_layer_height_range& range, const t_lay
|
|||
add_layer_item(r.first, root_item);
|
||||
}
|
||||
|
||||
if (dont_update_ui)
|
||||
return true;
|
||||
if (!dont_update_ui)
|
||||
select_item(sel_type&itLayer ? m_objects_model->GetItemByLayerRange(obj_idx, new_range) : root_item);
|
||||
|
||||
select_item(sel_type&itLayer ? m_objects_model->GetItemByLayerRange(obj_idx, new_range) : root_item);
|
||||
Expand(root_item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ public:
|
|||
bool selected_instances_of_same_object();
|
||||
bool can_split_instances();
|
||||
|
||||
wxPoint get_mouse_position_in_control();
|
||||
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
|
||||
wxBoxSizer* get_sizer() {return m_sizer;}
|
||||
int get_selected_obj_idx() const;
|
||||
DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const;
|
||||
|
|
@ -327,6 +327,7 @@ public:
|
|||
// may have been postponed from the "kill focus" event of a text field, if the focus was lost for the "add layer" button.
|
||||
// Rather providing the range by a value than by a reference, so that the memory referenced cannot be invalidated.
|
||||
void add_layer_range_after_current(const t_layer_height_range current_range);
|
||||
wxString can_add_new_range_after_current( t_layer_height_range current_range);
|
||||
void add_layer_item (const t_layer_height_range& range,
|
||||
const wxDataViewItem layers_item,
|
||||
const int layer_idx = -1);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#ifdef _WIN32
|
||||
wxDEFINE_EVENT(EVT_HID_DEVICE_ATTACHED, HIDDeviceAttachedEvent);
|
||||
wxDEFINE_EVENT(EVT_HID_DEVICE_DETACHED, HIDDeviceDetachedEvent);
|
||||
wxDEFINE_EVENT(EVT_VOLUME_ATTACHED, VolumeAttachedEvent);
|
||||
wxDEFINE_EVENT(EVT_VOLUME_DETACHED, VolumeDetachedEvent);
|
||||
#endif // _WIN32
|
||||
|
||||
wxTopLevelWindow* find_toplevel_parent(wxWindow *window)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include <wx/debug.h>
|
||||
#include <wx/settings.h>
|
||||
|
||||
#include "Event.hpp"
|
||||
|
||||
class wxCheckBox;
|
||||
class wxTopLevelWindow;
|
||||
class wxRect;
|
||||
|
|
@ -26,6 +28,19 @@ class wxRect;
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#ifdef _WIN32
|
||||
// USB HID attach / detach events from Windows OS.
|
||||
using HIDDeviceAttachedEvent = Event<std::string>;
|
||||
using HIDDeviceDetachedEvent = Event<std::string>;
|
||||
wxDECLARE_EVENT(EVT_HID_DEVICE_ATTACHED, HIDDeviceAttachedEvent);
|
||||
wxDECLARE_EVENT(EVT_HID_DEVICE_DETACHED, HIDDeviceDetachedEvent);
|
||||
|
||||
// Disk aka Volume attach / detach events from Windows OS.
|
||||
using VolumeAttachedEvent = SimpleEvent;
|
||||
using VolumeDetachedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_VOLUME_ATTACHED, VolumeAttachedEvent);
|
||||
wxDECLARE_EVENT(EVT_VOLUME_DETACHED, VolumeDetachedEvent);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
wxTopLevelWindow* find_toplevel_parent(wxWindow *window);
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ void GLGizmosManager::update_data()
|
|||
set_scale(Vec3d::Ones());
|
||||
set_rotation(Vec3d::Zero());
|
||||
set_flattening_data(selection.is_from_single_object() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
|
||||
set_sla_support_data(nullptr);
|
||||
set_sla_support_data(selection.is_from_single_instance() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef _
|
||||
#define _(s) Slic3r::GUI::I18N::translate((s))
|
||||
#define _(s) Slic3r::GUI::I18N::translate((s))
|
||||
#define _L(s) Slic3r::GUI::I18N::translate((s))
|
||||
#define _utf8(s) Slic3r::GUI::I18N::translate_utf8((s))
|
||||
#define _u8L(s) Slic3r::GUI::I18N::translate_utf8((s))
|
||||
#endif /* _ */
|
||||
|
||||
#ifndef _CTX
|
||||
#define _CTX(s, ctx) Slic3r::GUI::I18N::translate((s), (ctx))
|
||||
#define _CTX(s, ctx) Slic3r::GUI::I18N::translate((s), (ctx))
|
||||
#define _CTX_utf8(s, ctx) Slic3r::GUI::I18N::translate_utf8((s), (ctx))
|
||||
#endif /* _ */
|
||||
|
||||
|
|
|
|||
|
|
@ -144,9 +144,7 @@ void KBShortcutsDialog::fill_shortcuts()
|
|||
{ ctrl + "J", L("Print host upload queue") },
|
||||
// View
|
||||
{ "0-6", L("Camera view") },
|
||||
#if ENABLE_SHOW_SCENE_LABELS
|
||||
{ "E", L("Show/Hide object/instance labels") },
|
||||
#endif // ENABLE_SHOW_SCENE_LABELS
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
{ "D", L("Turn On/Off facets' slope rendering") },
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@
|
|||
#include <fstream>
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbt.h>
|
||||
#endif // _WIN32
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
|
@ -104,6 +108,31 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
update_title();
|
||||
|
||||
// declare events
|
||||
Bind(wxEVT_CREATE, [this](wxWindowCreateEvent& event) {
|
||||
|
||||
#ifdef _WIN32
|
||||
//static GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED };
|
||||
//static GUID GUID_DEVINTERFACE_DISK = { 0x53f56307, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b };
|
||||
//static GUID GUID_DEVINTERFACE_VOLUME = { 0x71a27cdd, 0x812a, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f };
|
||||
static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 };
|
||||
|
||||
// Register USB HID (Human Interface Devices) notifications to trigger the 3DConnexion enumeration.
|
||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter = { 0 };
|
||||
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
||||
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||
NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_HID;
|
||||
m_hDeviceNotify = ::RegisterDeviceNotification(this->GetHWND(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
// or register for file handle change?
|
||||
// DEV_BROADCAST_HANDLE NotificationFilter = { 0 };
|
||||
// NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HANDLE);
|
||||
// NotificationFilter.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
||||
#endif // _WIN32
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
|
||||
if (event.CanVeto() && !wxGetApp().check_unsaved_changes()) {
|
||||
event.Veto();
|
||||
|
|
@ -131,6 +160,11 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
// Called when closing the application and when switching the application language.
|
||||
void MainFrame::shutdown()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
::UnregisterDeviceNotification(HDEVNOTIFY(m_hDeviceNotify));
|
||||
m_hDeviceNotify = nullptr;
|
||||
#endif // _WIN32
|
||||
|
||||
if (m_plater)
|
||||
m_plater->stop_jobs();
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ public:
|
|||
wxNotebook* m_tabpanel { nullptr };
|
||||
wxProgressDialog* m_progress_dialog { nullptr };
|
||||
std::shared_ptr<ProgressStatusBar> m_statusbar;
|
||||
|
||||
#ifdef _WIN32
|
||||
void* m_hDeviceNotify { nullptr };
|
||||
#endif // _WIN32
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
|||
|
|
@ -99,6 +99,25 @@ void Mouse3DController::State::append_button(unsigned int id, size_t /* input_qu
|
|||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// Called by Win32 HID enumeration callback.
|
||||
void Mouse3DController::device_attached(const std::string &device)
|
||||
{
|
||||
int vid = 0;
|
||||
int pid = 0;
|
||||
if (sscanf(device.c_str(), "\\\\?\\HID#VID_%x&PID_%x&", &vid, &pid) == 2) {
|
||||
// BOOST_LOG_TRIVIAL(trace) << boost::format("Mouse3DController::device_attached(VID_%04xxPID_%04x)") % vid % pid;
|
||||
// BOOST_LOG_TRIVIAL(trace) << "Mouse3DController::device_attached: " << device;
|
||||
if (std::find(_3DCONNEXION_VENDORS.begin(), _3DCONNEXION_VENDORS.end(), vid) != _3DCONNEXION_VENDORS.end()) {
|
||||
// Signal the worker thread to wake up and enumerate HID devices, if not connected at the moment.
|
||||
// The message may come multiple times per each USB device. For example, some USB wireless dongles register as multiple HID sockets
|
||||
// for multiple devices to connect to.
|
||||
// Never mind, enumeration will be performed until connected.
|
||||
m_wakeup = true;
|
||||
m_stop_condition.notify_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out mouse scroll events produced by the 3DConnexion driver.
|
||||
bool Mouse3DController::State::process_mouse_wheel()
|
||||
{
|
||||
|
|
@ -388,9 +407,13 @@ void Mouse3DController::disconnected()
|
|||
m_params_by_device[m_device_str] = m_params_ui;
|
||||
m_device_str.clear();
|
||||
m_connected = false;
|
||||
wxGetApp().plater()->get_camera().recover_from_free_camera();
|
||||
wxGetApp().plater()->set_current_canvas_as_dirty();
|
||||
wxWakeUpIdle();
|
||||
wxGetApp().plater()->CallAfter([]() {
|
||||
Plater *plater = wxGetApp().plater();
|
||||
if (plater != nullptr) {
|
||||
plater->get_camera().recover_from_free_camera();
|
||||
plater->set_current_canvas_as_dirty();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -486,6 +509,11 @@ void Mouse3DController::run()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Enumerate once just after thread start.
|
||||
m_wakeup = true;
|
||||
#endif // _WIN32
|
||||
|
||||
for (;;) {
|
||||
{
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
|
|
@ -518,7 +546,13 @@ bool Mouse3DController::connect_device()
|
|||
{
|
||||
// Wait for 2 seconds, but cancellable by m_stop.
|
||||
std::unique_lock<std::mutex> lock(m_stop_condition_mutex);
|
||||
m_stop_condition.wait_for(lock, std::chrono::seconds(2), [this]{ return this->m_stop; });
|
||||
#ifdef _WIN32
|
||||
// Wait indifinetely for the stop signal.
|
||||
m_stop_condition.wait(lock, [this]{ return m_stop || m_wakeup; });
|
||||
m_wakeup = false;
|
||||
#else
|
||||
m_stop_condition.wait_for(lock, std::chrono::seconds(2), [this]{ return m_stop; });
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_stop)
|
||||
|
|
@ -528,10 +562,14 @@ bool Mouse3DController::connect_device()
|
|||
hid_device_info* devices = hid_enumerate(0, 0);
|
||||
if (devices == nullptr)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(error) << "Unable to enumerate HID devices";
|
||||
BOOST_LOG_TRIVIAL(trace) << "Mouse3DController::connect_device() - no HID device enumerated.";
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOST_LOG_TRIVIAL(trace) << "Mouse3DController::connect_device() - enumerating HID devices.";
|
||||
#endif // _WIN32
|
||||
|
||||
// Searches for 1st connected 3Dconnexion device
|
||||
struct DeviceData
|
||||
{
|
||||
|
|
@ -785,9 +823,17 @@ void Mouse3DController::disconnect_device()
|
|||
}
|
||||
m_device_str.clear();
|
||||
m_connected = false;
|
||||
wxGetApp().plater()->get_camera().recover_from_free_camera();
|
||||
wxGetApp().plater()->set_current_canvas_as_dirty();
|
||||
wxWakeUpIdle();
|
||||
#ifdef _WIN32
|
||||
// Enumerate once immediately after disconnect.
|
||||
m_wakeup = true;
|
||||
#endif // _WIN32
|
||||
wxGetApp().plater()->CallAfter([]() {
|
||||
Plater *plater = wxGetApp().plater();
|
||||
if (plater != nullptr) {
|
||||
plater->get_camera().recover_from_free_camera();
|
||||
plater->set_current_canvas_as_dirty();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ class Mouse3DController
|
|||
hid_device* m_device { nullptr };
|
||||
// Using m_stop_condition_mutex to synchronize m_stop.
|
||||
bool m_stop { false };
|
||||
#ifdef _WIN32
|
||||
std::atomic<bool> m_wakeup { false };
|
||||
#endif /* _WIN32 */
|
||||
// Mutex and condition variable for sleeping during the detection of 3DConnexion devices by polling while allowing
|
||||
// cancellation before the end of the polling interval.
|
||||
std::mutex m_stop_condition_mutex;
|
||||
|
|
@ -185,6 +188,9 @@ public:
|
|||
#endif // __APPLE__
|
||||
|
||||
#ifdef WIN32
|
||||
// Called by Win32 HID enumeration callback.
|
||||
void device_attached(const std::string &device);
|
||||
|
||||
// On Windows, the 3DConnexion driver sends out mouse wheel rotation events to an active application
|
||||
// if the application does not register at the driver. This is a workaround to ignore these superfluous
|
||||
// mouse wheel events.
|
||||
|
|
|
|||
|
|
@ -1936,7 +1936,7 @@ struct Plater::priv
|
|||
GUI::show_error(this->q, msg);
|
||||
}
|
||||
}
|
||||
void export_gcode(fs::path output_path, PrintHostJob upload_job);
|
||||
void export_gcode(fs::path output_path, bool output_path_on_removable_media, PrintHostJob upload_job);
|
||||
void reload_from_disk();
|
||||
void reload_all_from_disk();
|
||||
void fix_through_netfabb(const int obj_idx, const int vol_idx = -1);
|
||||
|
|
@ -2195,17 +2195,34 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
// Load the 3DConnexion device database.
|
||||
mouse3d_controller.load_config(*wxGetApp().app_config);
|
||||
// Start the background thread to detect and connect to a HID device (Windows and Linux).
|
||||
// Connect to a 3DConnextion driver (OSX).
|
||||
// Connect to a 3DConnextion driver (OSX).
|
||||
mouse3d_controller.init();
|
||||
#ifdef _WIN32
|
||||
// Register an USB HID (Human Interface Device) attach event. evt contains Win32 path to the USB device containing VID, PID and other info.
|
||||
// This event wakes up the Mouse3DController's background thread to enumerate HID devices, if the VID of the callback event
|
||||
// is one of the 3D Mouse vendors (3DConnexion or Logitech).
|
||||
this->q->Bind(EVT_HID_DEVICE_ATTACHED, [this](HIDDeviceAttachedEvent &evt) {
|
||||
mouse3d_controller.device_attached(evt.data);
|
||||
});
|
||||
#endif /* _WIN32 */
|
||||
|
||||
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this](RemovableDriveEjectEvent &evt) {
|
||||
this->show_action_buttons(this->ready_to_slice);
|
||||
Slic3r::GUI::show_info(this->q, (boost::format(_utf8(L("Unmounting successful. The device %s(%s) can now be safely removed from the computer.")))
|
||||
% evt.data.name % evt.data.path).str());
|
||||
if (evt.data.second) {
|
||||
this->show_action_buttons(this->ready_to_slice);
|
||||
Slic3r::GUI::show_info(this->q, (boost::format(_utf8(L("Unmounting successful. The device %s(%s) can now be safely removed from the computer.")))
|
||||
% evt.data.first.name % evt.data.first.path).str());
|
||||
} else
|
||||
Slic3r::GUI::show_info(this->q, (boost::format(_utf8(L("Ejecting of device %s(%s) has failed.")))
|
||||
% evt.data.first.name % evt.data.first.path).str());
|
||||
});
|
||||
this->q->Bind(EVT_REMOVABLE_DRIVES_CHANGED, [this](RemovableDrivesChangedEvent &) { this->show_action_buttons(this->ready_to_slice); });
|
||||
// Start the background thread and register this window as a target for update events.
|
||||
wxGetApp().removable_drive_manager()->init(this->q);
|
||||
#ifdef _WIN32
|
||||
// Trigger enumeration of removable media on Win32 notification.
|
||||
this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
|
||||
#endif /* _WIN32 */
|
||||
|
||||
// Initialize the Undo / Redo stack with a first snapshot.
|
||||
this->take_snapshot(_(L("New Project")));
|
||||
|
|
@ -2275,13 +2292,6 @@ void Plater::priv::reset_all_gizmos()
|
|||
// Update the UI based on the current preferences.
|
||||
void Plater::priv::update_ui_from_settings()
|
||||
{
|
||||
// TODO: (?)
|
||||
// my ($self) = @_;
|
||||
// if (defined($self->{btn_reslice}) && $self->{buttons_sizer}->IsShown($self->{btn_reslice}) != (! wxTheApp->{app_config}->get("background_processing"))) {
|
||||
// $self->{buttons_sizer}->Show($self->{btn_reslice}, ! wxTheApp->{app_config}->get("background_processing"));
|
||||
// $self->{buttons_sizer}->Layout;
|
||||
// }
|
||||
|
||||
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||
if (wxGetApp().app_config->get("use_free_camera") != "1")
|
||||
camera.recover_from_free_camera();
|
||||
|
|
@ -2498,7 +2508,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
|||
selection.add_object((unsigned int)idx, false);
|
||||
}
|
||||
|
||||
if (view3D->get_canvas3d()->get_gizmos_manager().is_running())
|
||||
if (view3D->get_canvas3d()->get_gizmos_manager().is_enabled())
|
||||
// this is required because the selected object changed and the flatten on face an sla support gizmos need to be updated accordingly
|
||||
view3D->get_canvas3d()->update_gizmos_on_off_state();
|
||||
}
|
||||
|
|
@ -3223,7 +3233,7 @@ bool Plater::priv::restart_background_process(unsigned int state)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Plater::priv::export_gcode(fs::path output_path, PrintHostJob upload_job)
|
||||
void Plater::priv::export_gcode(fs::path output_path, bool output_path_on_removable_media, PrintHostJob upload_job)
|
||||
{
|
||||
wxCHECK_RET(!(output_path.empty() && upload_job.empty()), "export_gcode: output_path and upload_job empty");
|
||||
|
||||
|
|
@ -3244,7 +3254,7 @@ void Plater::priv::export_gcode(fs::path output_path, PrintHostJob upload_job)
|
|||
return;
|
||||
|
||||
if (! output_path.empty()) {
|
||||
background_process.schedule_export(output_path.string());
|
||||
background_process.schedule_export(output_path.string(), output_path_on_removable_media);
|
||||
} else {
|
||||
background_process.schedule_upload(std::move(upload_job));
|
||||
}
|
||||
|
|
@ -3726,7 +3736,12 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
|||
wxString message = evt.GetString();
|
||||
if (message.IsEmpty())
|
||||
message = _(L("Export failed"));
|
||||
show_error(q, message);
|
||||
if (q->m_tracking_popup_menu)
|
||||
// We don't want to pop-up a message box when tracking a pop-up menu.
|
||||
// We postpone the error message instead.
|
||||
q->m_tracking_popup_menu_error_message = message;
|
||||
else
|
||||
show_error(q, message);
|
||||
this->statusbar()->set_status_text(message);
|
||||
}
|
||||
if (canceled)
|
||||
|
|
@ -4915,8 +4930,8 @@ void Plater::export_gcode(bool prefer_removable)
|
|||
}
|
||||
|
||||
if (! output_path.empty()) {
|
||||
p->export_gcode(output_path, PrintHostJob());
|
||||
bool path_on_removable_media = removable_drive_manager.set_and_verify_last_save_path(output_path.string());
|
||||
p->export_gcode(output_path, path_on_removable_media, PrintHostJob());
|
||||
// Storing a path to AppConfig either as path to removable media or a path to internal media.
|
||||
// is_path_on_removable_drive() is called with the "true" parameter to update its internal database as the user may have shuffled the external drives
|
||||
// while the dialog was open.
|
||||
|
|
@ -5239,7 +5254,7 @@ void Plater::send_gcode()
|
|||
upload_job.upload_data.upload_path = dlg.filename();
|
||||
upload_job.upload_data.start_print = dlg.start_print();
|
||||
|
||||
p->export_gcode(fs::path(), std::move(upload_job));
|
||||
p->export_gcode(fs::path(), false, std::move(upload_job));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5615,7 +5630,7 @@ void Plater::schedule_background_process(bool schedule/* = true*/)
|
|||
this->p->suppressed_backround_processing_update = false;
|
||||
}
|
||||
|
||||
bool Plater::is_background_process_running() const
|
||||
bool Plater::is_background_process_update_scheduled() const
|
||||
{
|
||||
return this->p->background_process_timer.IsRunning();
|
||||
}
|
||||
|
|
@ -5737,15 +5752,34 @@ const UndoRedo::Stack& Plater::undo_redo_stack_main() const { return p->undo_red
|
|||
void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); }
|
||||
void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); }
|
||||
|
||||
SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() :
|
||||
m_was_running(wxGetApp().plater()->is_background_process_running())
|
||||
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
|
||||
bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos)
|
||||
{
|
||||
wxGetApp().plater()->suppress_background_process(m_was_running);
|
||||
// Don't want to wake up and trigger reslicing while tracking the pop-up menu.
|
||||
SuppressBackgroundProcessingUpdate sbpu;
|
||||
// When tracking a pop-up menu, postpone error messages from the slicing result.
|
||||
m_tracking_popup_menu = true;
|
||||
bool out = this->wxPanel::PopupMenu(menu, pos);
|
||||
m_tracking_popup_menu = false;
|
||||
if (! m_tracking_popup_menu_error_message.empty()) {
|
||||
// Don't know whether the CallAfter is necessary, but it should not hurt.
|
||||
// The menus likely sends out some commands, so we may be safer if the dialog is shown after the menu command is processed.
|
||||
wxString message = std::move(m_tracking_popup_menu_error_message);
|
||||
wxTheApp->CallAfter([message, this]() { show_error(this, message); });
|
||||
m_tracking_popup_menu_error_message.clear();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() :
|
||||
m_was_scheduled(wxGetApp().plater()->is_background_process_update_scheduled())
|
||||
{
|
||||
wxGetApp().plater()->suppress_background_process(m_was_scheduled);
|
||||
}
|
||||
|
||||
SuppressBackgroundProcessingUpdate::~SuppressBackgroundProcessingUpdate()
|
||||
{
|
||||
wxGetApp().plater()->schedule_background_process(m_was_running);
|
||||
wxGetApp().plater()->schedule_background_process(m_was_scheduled);
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public:
|
|||
void changed_object(int obj_idx);
|
||||
void changed_objects(const std::vector<size_t>& object_idxs);
|
||||
void schedule_background_process(bool schedule = true);
|
||||
bool is_background_process_running() const;
|
||||
bool is_background_process_update_scheduled() const;
|
||||
void suppress_background_process(const bool stop_background_process) ;
|
||||
void fix_through_netfabb(const int obj_idx, const int vol_idx = -1);
|
||||
void send_gcode();
|
||||
|
|
@ -326,10 +326,20 @@ public:
|
|||
Plater *m_plater;
|
||||
};
|
||||
|
||||
// Wrapper around wxWindow::PopupMenu to suppress error messages popping out while tracking the popup menu.
|
||||
bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition);
|
||||
bool PopupMenu(wxMenu *menu, int x, int y) { return this->PopupMenu(menu, wxPoint(x, y)); }
|
||||
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
||||
// Set true during PopupMenu() tracking to suppress immediate error message boxes.
|
||||
// The error messages are collected to m_tracking_popup_menu_error_message instead and these error messages
|
||||
// are shown after the pop-up dialog closes.
|
||||
bool m_tracking_popup_menu = false;
|
||||
wxString m_tracking_popup_menu_error_message;
|
||||
|
||||
void suppress_snapshots();
|
||||
void allow_snapshots();
|
||||
|
||||
|
|
@ -342,7 +352,7 @@ public:
|
|||
SuppressBackgroundProcessingUpdate();
|
||||
~SuppressBackgroundProcessingUpdate();
|
||||
private:
|
||||
bool m_was_running;
|
||||
bool m_was_scheduled;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
|
|||
return;
|
||||
is_visible = app_config.get_variant(vendor->id, model, variant);
|
||||
} else if (type == TYPE_FILAMENT || type == TYPE_SLA_MATERIAL) {
|
||||
const char *section_name = (type == TYPE_FILAMENT) ? "filaments" : "sla_materials";
|
||||
const std::string §ion_name = (type == TYPE_FILAMENT) ? AppConfig::SECTION_FILAMENTS : AppConfig::SECTION_MATERIALS;
|
||||
if (app_config.has_section(section_name)) {
|
||||
// Check whether this profile is marked as "installed" in PrusaSlicer.ini,
|
||||
// or whether a profile is marked as "installed", which this profile may have been renamed from.
|
||||
|
|
@ -413,7 +413,7 @@ const std::vector<std::string>& Preset::print_options()
|
|||
"perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed",
|
||||
"top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed",
|
||||
"bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration",
|
||||
"bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height",
|
||||
"bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "draft_shield",
|
||||
"min_skirt_length", "brim_width", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers",
|
||||
"raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing",
|
||||
"support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers",
|
||||
|
|
@ -1032,6 +1032,14 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string&
|
|||
return alias;
|
||||
}
|
||||
|
||||
const std::string* PresetCollection::get_preset_name_renamed(const std::string &old_name) const
|
||||
{
|
||||
auto it_renamed = m_map_system_profile_renamed.find(old_name);
|
||||
if (it_renamed != m_map_system_profile_renamed.end())
|
||||
return &it_renamed->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string& PresetCollection::get_suffix_modified() {
|
||||
return g_suffix_modified;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,7 +361,8 @@ public:
|
|||
PresetWithVendorProfile get_preset_with_vendor_profile(const Preset &preset) const;
|
||||
PresetWithVendorProfile get_edited_preset_with_vendor_profile() const { return this->get_preset_with_vendor_profile(this->get_edited_preset()); }
|
||||
|
||||
const std::string& get_preset_name_by_alias(const std::string& alias) const;
|
||||
const std::string& get_preset_name_by_alias(const std::string& alias) const;
|
||||
const std::string* get_preset_name_renamed(const std::string &old_name) const;
|
||||
|
||||
// used to update preset_choice from Tab
|
||||
const std::deque<Preset>& get_presets() const { return m_presets; }
|
||||
|
|
|
|||
|
|
@ -289,17 +289,7 @@ std::string PresetBundle::load_system_presets()
|
|||
this->reset(false);
|
||||
}
|
||||
|
||||
this->prints .update_map_system_profile_renamed();
|
||||
this->sla_prints .update_map_system_profile_renamed();
|
||||
this->filaments .update_map_system_profile_renamed();
|
||||
this->sla_materials.update_map_system_profile_renamed();
|
||||
this->printers .update_map_system_profile_renamed();
|
||||
|
||||
this->prints .update_map_alias_to_profile_name();
|
||||
this->sla_prints .update_map_alias_to_profile_name();
|
||||
this->filaments .update_map_alias_to_profile_name();
|
||||
this->sla_materials.update_map_alias_to_profile_name();
|
||||
|
||||
this->update_system_maps();
|
||||
return errors_cummulative;
|
||||
}
|
||||
|
||||
|
|
@ -324,6 +314,20 @@ std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
|
|||
return duplicate_prints;
|
||||
}
|
||||
|
||||
void PresetBundle::update_system_maps()
|
||||
{
|
||||
this->prints .update_map_system_profile_renamed();
|
||||
this->sla_prints .update_map_system_profile_renamed();
|
||||
this->filaments .update_map_system_profile_renamed();
|
||||
this->sla_materials.update_map_system_profile_renamed();
|
||||
this->printers .update_map_system_profile_renamed();
|
||||
|
||||
this->prints .update_map_alias_to_profile_name();
|
||||
this->sla_prints .update_map_alias_to_profile_name();
|
||||
this->filaments .update_map_alias_to_profile_name();
|
||||
this->sla_materials.update_map_alias_to_profile_name();
|
||||
}
|
||||
|
||||
static inline std::string remove_ini_suffix(const std::string &name)
|
||||
{
|
||||
std::string out = name;
|
||||
|
|
@ -337,9 +341,9 @@ static inline std::string remove_ini_suffix(const std::string &name)
|
|||
// If the "vendor" section is missing, enable all models and variants of the particular vendor.
|
||||
void PresetBundle::load_installed_printers(const AppConfig &config)
|
||||
{
|
||||
for (auto &preset : printers) {
|
||||
this->update_system_maps();
|
||||
for (auto &preset : printers)
|
||||
preset.set_visible_from_appconfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& preset_type, const std::string& alias) const
|
||||
|
|
@ -367,7 +371,7 @@ void PresetBundle::load_installed_filaments(AppConfig &config)
|
|||
if (printer.is_visible && printer.printer_technology() == ptFFF) {
|
||||
const PresetWithVendorProfile printer_with_vendor_profile = printers.get_preset_with_vendor_profile(printer);
|
||||
for (const Preset &filament : filaments)
|
||||
if (is_compatible_with_printer(filaments.get_preset_with_vendor_profile(filament), printer_with_vendor_profile))
|
||||
if (filament.is_system && is_compatible_with_printer(filaments.get_preset_with_vendor_profile(filament), printer_with_vendor_profile))
|
||||
compatible_filaments.insert(&filament);
|
||||
}
|
||||
// and mark these filaments as installed, therefore this code will not be executed at the next start of the application.
|
||||
|
|
@ -390,7 +394,7 @@ void PresetBundle::load_installed_sla_materials(AppConfig &config)
|
|||
if (printer.is_visible && printer.printer_technology() == ptSLA) {
|
||||
const PresetWithVendorProfile printer_with_vendor_profile = printers.get_preset_with_vendor_profile(printer);
|
||||
for (const Preset &material : sla_materials)
|
||||
if (is_compatible_with_printer(sla_materials.get_preset_with_vendor_profile(material), printer_with_vendor_profile))
|
||||
if (material.is_system && is_compatible_with_printer(sla_materials.get_preset_with_vendor_profile(material), printer_with_vendor_profile))
|
||||
comp_sla_materials.insert(&material);
|
||||
}
|
||||
// and mark these SLA materials as installed, therefore this code will not be executed at the next start of the application.
|
||||
|
|
@ -1069,7 +1073,11 @@ static void flatten_configbundle_hierarchy(boost::property_tree::ptree &tree, co
|
|||
// Iterate in a reverse order, so the last change will be placed first in merged.
|
||||
for (auto it_inherits = prst->inherits.rbegin(); it_inherits != prst->inherits.rend(); ++ it_inherits)
|
||||
for (auto it = (*it_inherits)->node->begin(); it != (*it_inherits)->node->end(); ++ it)
|
||||
if (prst->node->find(it->first) == prst->node->not_found())
|
||||
if (it->first == "renamed_from") {
|
||||
// Don't inherit "renamed_from" flag, it does not make sense. The "renamed_from" flag only makes sense for a concrete preset.
|
||||
if (boost::starts_with((*it_inherits)->name, "*"))
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Nonpublic intermediate preset %1% contains a \"renamed_from\" field, which is ignored") % (*it_inherits)->name;
|
||||
} else if (prst->node->find(it->first) == prst->node->not_found())
|
||||
prst->node->add_child(it->first, it->second);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ public:
|
|||
PresetCollection sla_prints;
|
||||
PresetCollection filaments;
|
||||
PresetCollection sla_materials;
|
||||
PresetCollection& materials(PrinterTechnology pt) { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
||||
const PresetCollection& materials(PrinterTechnology pt) const { return pt == ptFFF ? this->filaments : this->sla_materials; }
|
||||
PrinterPresetCollection printers;
|
||||
// Filament preset names for a multi-extruder or multi-material print.
|
||||
// extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size()
|
||||
|
|
@ -144,6 +146,8 @@ private:
|
|||
std::string load_system_presets();
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
std::vector<std::string> merge_presets(PresetBundle &&other);
|
||||
// Update renamed_from and alias maps of system profiles.
|
||||
void update_system_maps();
|
||||
|
||||
// Set the is_visible flag for filaments and sla materials,
|
||||
// apply defaults based on enabled printers when no filaments/materials are installed.
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ std::vector<DriveData> RemovableDriveManager::search_for_removable_drives() cons
|
|||
volume_name.erase(volume_name.begin() + wcslen(volume_name.c_str()), volume_name.end());
|
||||
if (! file_system_name.empty()) {
|
||||
ULARGE_INTEGER free_space;
|
||||
::GetDiskFreeSpaceExA(path.c_str(), &free_space, nullptr, nullptr);
|
||||
::GetDiskFreeSpaceExW(wpath.c_str(), &free_space, nullptr, nullptr);
|
||||
if (free_space.QuadPart > 0) {
|
||||
path += "\\";
|
||||
current_drives.emplace_back(DriveData{ boost::nowide::narrow(volume_name), path });
|
||||
|
|
@ -86,9 +86,12 @@ void RemovableDriveManager::eject_drive()
|
|||
// get handle to device
|
||||
std::string mpath = "\\\\.\\" + m_last_save_path;
|
||||
mpath = mpath.substr(0, mpath.size() - 1);
|
||||
HANDLE handle = CreateFileA(mpath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
HANDLE handle = CreateFileW(boost::nowide::widen(mpath).c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
std::cerr << "Ejecting " << mpath << " failed " << GetLastError() << " \n";
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::pair<DriveData, bool>(*it_drive_data, false)));
|
||||
return;
|
||||
}
|
||||
DWORD deviceControlRetVal(0);
|
||||
|
|
@ -101,12 +104,15 @@ void RemovableDriveManager::eject_drive()
|
|||
if (error == 0) {
|
||||
CloseHandle(handle);
|
||||
BOOST_LOG_TRIVIAL(error) << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n";
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::pair<DriveData, bool>(*it_drive_data, false)));
|
||||
return;
|
||||
}
|
||||
CloseHandle(handle);
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::move(*it_drive_data)));
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::pair< DriveData, bool >(std::move(*it_drive_data), true)));
|
||||
m_current_drives.erase(it_drive_data);
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +128,7 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p
|
|||
return std::string();
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
std::string new_path = path.substr(0, found);
|
||||
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||
int letter = PathGetDriveNumberW(boost::nowide::widen(new_path).c_str());
|
||||
for (const DriveData &drive_data : m_current_drives) {
|
||||
char drive = drive_data.path[0];
|
||||
if (drive == 'A' + letter)
|
||||
|
|
@ -136,7 +142,7 @@ std::string RemovableDriveManager::get_removable_drive_from_path(const std::stri
|
|||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
std::string new_path = path.substr(0, found);
|
||||
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||
int letter = PathGetDriveNumberW(boost::nowide::widen(new_path).c_str());
|
||||
for (const DriveData &drive_data : m_current_drives) {
|
||||
assert(! drive_data.path.empty());
|
||||
if (drive_data.path.front() == 'A' + letter)
|
||||
|
|
@ -145,93 +151,16 @@ std::string RemovableDriveManager::get_removable_drive_from_path(const std::stri
|
|||
return std::string();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// currently not used, left for possible future use
|
||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
// Called by Win32 Volume arrived / detached callback.
|
||||
void RemovableDriveManager::volumes_changed()
|
||||
{
|
||||
// here we need to catch messeges about device removal
|
||||
// problem is that when ejecting usb (how is it implemented above) there is no messege dispached. Only after physical removal of the device.
|
||||
//uncomment register_window() in init() to register and comment update() in GUI_App.cpp (only for windows!) to stop recieving periodical updates
|
||||
|
||||
LRESULT lRet = 1;
|
||||
static HDEVNOTIFY hDeviceNotify;
|
||||
static constexpr GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, 0x8a,0x6d,0xb5,0x4c,0x2b,0x4f,0xc8,0x35 };
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
|
||||
|
||||
ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
|
||||
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
||||
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||
NotificationFilter.dbcc_classguid = WceusbshGUID;
|
||||
|
||||
hDeviceNotify = RegisterDeviceNotification(hWnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
break;
|
||||
|
||||
case WM_DEVICECHANGE:
|
||||
{
|
||||
// here is the important
|
||||
if(wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||
{
|
||||
RemovableDriveManager::get_instance().update(0, true);
|
||||
}
|
||||
if (m_initialized) {
|
||||
// Signal the worker thread to wake up and enumerate removable drives.
|
||||
m_wakeup = true;
|
||||
m_thread_stop_condition.notify_all();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Send all other messages on to the default windows handler.
|
||||
lRet = DefWindowProc(hWnd, message, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
return lRet;
|
||||
|
||||
}
|
||||
|
||||
void RemovableDriveManager::register_window()
|
||||
{
|
||||
//creates new unvisible window that is recieving callbacks from system
|
||||
// structure to register
|
||||
// currently not used, left for possible future use
|
||||
WNDCLASSEX wndClass;
|
||||
wndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||
wndClass.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(0));
|
||||
wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>(WinProcCallback);//this is callback
|
||||
wndClass.cbClsExtra = 0;
|
||||
wndClass.cbWndExtra = 0;
|
||||
wndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
|
||||
wndClass.hbrBackground = CreateSolidBrush(RGB(192, 192, 192));
|
||||
wndClass.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wndClass.lpszClassName = L"PrusaSlicer_aux_class";
|
||||
wndClass.lpszMenuName = NULL;
|
||||
wndClass.hIconSm = wndClass.hIcon;
|
||||
if(!RegisterClassEx(&wndClass))
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
return;
|
||||
}
|
||||
|
||||
HWND hWnd = CreateWindowEx(
|
||||
WS_EX_NOACTIVATE,
|
||||
L"PrusaSlicer_aux_class",
|
||||
L"PrusaSlicer_aux_wnd",
|
||||
WS_DISABLED, // style
|
||||
CW_USEDEFAULT, 0,
|
||||
640, 480,
|
||||
NULL, NULL,
|
||||
GetModuleHandle(NULL),
|
||||
NULL);
|
||||
if(hWnd == NULL)
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
}
|
||||
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
||||
UpdateWindow(hWnd);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
namespace search_for_drives_internal
|
||||
|
|
@ -358,16 +287,18 @@ void RemovableDriveManager::eject_drive()
|
|||
// wait for command to finnish (blocks ui thread)
|
||||
child.wait();
|
||||
int err = child.exit_code();
|
||||
if(err)
|
||||
{
|
||||
if (err) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Ejecting failed";
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::pair<DriveData, bool>(*it_drive_data, false)));
|
||||
return;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "Ejecting finished";
|
||||
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::move(*it_drive_data)));
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDriveEjectEvent(EVT_REMOVABLE_DRIVE_EJECTED, std::pair<DriveData, bool>(std::move(*it_drive_data), true)));
|
||||
m_current_drives.erase(it_drive_data);
|
||||
}
|
||||
}
|
||||
|
|
@ -416,9 +347,7 @@ void RemovableDriveManager::init(wxEvtHandler *callback_evt_handler)
|
|||
m_initialized = true;
|
||||
m_callback_evt_handler = callback_evt_handler;
|
||||
|
||||
#if _WIN32
|
||||
//this->register_window_msw();
|
||||
#elif __APPLE__
|
||||
#if __APPLE__
|
||||
this->register_window_osx();
|
||||
#endif
|
||||
|
||||
|
|
@ -432,6 +361,10 @@ void RemovableDriveManager::init(wxEvtHandler *callback_evt_handler)
|
|||
|
||||
void RemovableDriveManager::shutdown()
|
||||
{
|
||||
#if __APPLE__
|
||||
this->unregister_window_osx();
|
||||
#endif
|
||||
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
if (m_thread.joinable()) {
|
||||
// Stop the worker thread, if running.
|
||||
|
|
@ -447,12 +380,6 @@ void RemovableDriveManager::shutdown()
|
|||
}
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
#if _WIN32
|
||||
//this->unregister_window_msw();
|
||||
#elif __APPLE__
|
||||
this->unregister_window_osx();
|
||||
#endif
|
||||
|
||||
m_initialized = false;
|
||||
m_callback_evt_handler = nullptr;
|
||||
}
|
||||
|
|
@ -469,9 +396,6 @@ bool RemovableDriveManager::set_and_verify_last_save_path(const std::string &pat
|
|||
|
||||
RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
||||
{
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
RemovableDriveManager::RemovableDrivesStatus out;
|
||||
{
|
||||
|
|
@ -487,28 +411,56 @@ RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
|||
// Update is called from thread_proc() and from most of the public methods on demand.
|
||||
void RemovableDriveManager::update()
|
||||
{
|
||||
std::vector<DriveData> current_drives = this->search_for_removable_drives();
|
||||
|
||||
// Post update events.
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::sort(current_drives.begin(), current_drives.end());
|
||||
if (current_drives != m_current_drives) {
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDrivesChangedEvent(EVT_REMOVABLE_DRIVES_CHANGED));
|
||||
tbb::mutex::scoped_lock inside_update_lock;
|
||||
#ifdef _WIN32
|
||||
// All wake up calls up to now are now consumed when the drive enumeration starts.
|
||||
m_wakeup = false;
|
||||
#endif // _WIN32
|
||||
if (inside_update_lock.try_acquire(m_inside_update_mutex)) {
|
||||
// Got the lock without waiting. That means, the update was not running.
|
||||
// Run the update.
|
||||
std::vector<DriveData> current_drives = this->search_for_removable_drives();
|
||||
// Post update events.
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
std::sort(current_drives.begin(), current_drives.end());
|
||||
if (current_drives != m_current_drives) {
|
||||
assert(m_callback_evt_handler);
|
||||
if (m_callback_evt_handler)
|
||||
wxPostEvent(m_callback_evt_handler, RemovableDrivesChangedEvent(EVT_REMOVABLE_DRIVES_CHANGED));
|
||||
}
|
||||
m_current_drives = std::move(current_drives);
|
||||
} else {
|
||||
// Acquiring the m_iniside_update lock failed, therefore another update is running.
|
||||
// Just block until the other instance of update() finishes.
|
||||
inside_update_lock.acquire(m_inside_update_mutex);
|
||||
}
|
||||
m_current_drives = std::move(current_drives);
|
||||
}
|
||||
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
void RemovableDriveManager::thread_proc()
|
||||
{
|
||||
// Signal the worker thread to update initially.
|
||||
#ifdef _WIN32
|
||||
m_wakeup = true;
|
||||
#endif // _WIN32
|
||||
|
||||
for (;;) {
|
||||
// Wait for 2 seconds before running the disk enumeration.
|
||||
// Cancellable.
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
||||
#ifdef _WIN32
|
||||
// Windows do not send an update on insert / eject of an SD card into an external SD card reader.
|
||||
// Windows also do not send an update on software eject of a FLASH drive.
|
||||
// We can likely use the Windows WMI API, but it will be quite time consuming to implement.
|
||||
// https://www.codeproject.com/Articles/10539/Making-WMI-Queries-In-C
|
||||
// https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page
|
||||
// https://docs.microsoft.com/en-us/windows/win32/wmisdk/com-api-for-wmi
|
||||
// https://docs.microsoft.com/en-us/windows/win32/wmisdk/example--receiving-event-notifications-through-wmi-
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop || m_wakeup; });
|
||||
#else
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop; });
|
||||
#endif
|
||||
}
|
||||
if (m_stop)
|
||||
// Stop the worker thread.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ inline bool operator< (const DriveData &lhs, const DriveData &rhs) { return lhs.
|
|||
inline bool operator> (const DriveData &lhs, const DriveData &rhs) { return lhs.path > rhs.path; }
|
||||
inline bool operator==(const DriveData &lhs, const DriveData &rhs) { return lhs.path == rhs.path; }
|
||||
|
||||
using RemovableDriveEjectEvent = Event<DriveData>;
|
||||
using RemovableDriveEjectEvent = Event<std::pair<DriveData, bool>>;
|
||||
wxDECLARE_EVENT(EVT_REMOVABLE_DRIVE_EJECTED, RemovableDriveEjectEvent);
|
||||
|
||||
using RemovableDrivesChangedEvent = SimpleEvent;
|
||||
|
|
@ -69,6 +69,8 @@ public:
|
|||
// On Windows, the function does not block, and the eject is detected in the background thread.
|
||||
void eject_drive();
|
||||
|
||||
// Status is used to retrieve info for showing UI buttons.
|
||||
// Status is called every time when change of UI buttons is possible therefore should not perform update.
|
||||
struct RemovableDrivesStatus {
|
||||
bool has_removable_drives { false };
|
||||
bool has_eject { false };
|
||||
|
|
@ -82,6 +84,11 @@ public:
|
|||
// It would be better to make this method private and friend to RemovableDriveManagerMM, but RemovableDriveManagerMM is an ObjectiveC class.
|
||||
void update();
|
||||
|
||||
#ifdef _WIN32
|
||||
// Called by Win32 Volume arrived / detached callback.
|
||||
void volumes_changed();
|
||||
#endif // _WIN32
|
||||
|
||||
private:
|
||||
bool m_initialized { false };
|
||||
wxEvtHandler* m_callback_evt_handler { nullptr };
|
||||
|
|
@ -93,6 +100,9 @@ private:
|
|||
std::condition_variable m_thread_stop_condition;
|
||||
mutable std::mutex m_thread_stop_mutex;
|
||||
bool m_stop { false };
|
||||
#ifdef _WIN32
|
||||
std::atomic<bool> m_wakeup { false };
|
||||
#endif /* _WIN32 */
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
// Called from update() to enumerate removable drives.
|
||||
|
|
@ -102,6 +112,8 @@ private:
|
|||
// sorted ascending by path
|
||||
std::vector<DriveData> m_current_drives;
|
||||
mutable tbb::mutex m_drives_mutex;
|
||||
// Locking the update() function to avoid that the function is executed multiple times.
|
||||
mutable tbb::mutex m_inside_update_mutex;
|
||||
|
||||
// Returns drive path (same as path in DriveData) if exists otherwise empty string.
|
||||
std::string get_removable_drive_from_path(const std::string& path);
|
||||
|
|
@ -110,10 +122,7 @@ private:
|
|||
// Set with set_and_verify_last_save_path() to a removable drive path to be ejected.
|
||||
std::string m_last_save_path;
|
||||
|
||||
#if _WIN32
|
||||
//registers for notifications by creating invisible window
|
||||
//void register_window_msw();
|
||||
#elif __APPLE__
|
||||
#if __APPLE__
|
||||
void register_window_osx();
|
||||
void unregister_window_osx();
|
||||
void list_devices(std::vector<DriveData> &out) const;
|
||||
|
|
|
|||
|
|
@ -1172,6 +1172,7 @@ void TabPrint::build()
|
|||
optgroup->append_single_option_line("skirts");
|
||||
optgroup->append_single_option_line("skirt_distance");
|
||||
optgroup->append_single_option_line("skirt_height");
|
||||
optgroup->append_single_option_line("draft_shield");
|
||||
optgroup->append_single_option_line("min_skirt_length");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Brim")));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue