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
5693545d15
71 changed files with 3265 additions and 2634 deletions
|
|
@ -104,33 +104,7 @@ endif ()
|
|||
# Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries.
|
||||
if (SLIC3R_GUI)
|
||||
# target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES})
|
||||
target_link_libraries(PrusaSlicer libslic3r_gui ${wxWidgets_LIBRARIES})
|
||||
|
||||
# Configure libcurl and its dependencies OpenSSL & zlib
|
||||
find_package(CURL REQUIRED)
|
||||
if (NOT WIN32)
|
||||
# Required by libcurl
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
target_include_directories(PrusaSlicer PRIVATE ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(PrusaSlicer ${CURL_LIBRARIES} ${ZLIB_LIBRARIES})
|
||||
if (SLIC3R_STATIC)
|
||||
if (NOT APPLE)
|
||||
# libcurl is always linked dynamically to the system libcurl on OSX.
|
||||
# On other systems, libcurl is linked statically if SLIC3R_STATIC is set.
|
||||
target_compile_definitions(PrusaSlicer PRIVATE CURL_STATICLIB)
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# As of now, our build system produces a statically linked libcurl,
|
||||
# which links the OpenSSL library dynamically.
|
||||
find_package(OpenSSL REQUIRED)
|
||||
message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
|
||||
message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
|
||||
target_include_directories(PrusaSlicer PRIVATE ${OPENSSL_INCLUDE_DIR})
|
||||
target_link_libraries(PrusaSlicer ${OPENSSL_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(PrusaSlicer libslic3r_gui)
|
||||
if (MSVC)
|
||||
# Generate debug symbols even in release mode.
|
||||
target_link_options(PrusaSlicer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
||||
|
|
|
|||
|
|
@ -632,8 +632,11 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
|
|||
// Negative support_contact_z is not taken into account, it can result in false positives in cases
|
||||
// where previous layer has object extrusions too (https://github.com/prusa3d/PrusaSlicer/issues/2752)
|
||||
|
||||
// Only check this layer in case it has some extrusions.
|
||||
bool has_extrusions = (layer_to_print.object_layer && layer_to_print.object_layer->has_extrusions())
|
||||
|| (layer_to_print.support_layer && layer_to_print.support_layer->has_extrusions());
|
||||
|
||||
if (layer_to_print.print_z() > maximal_print_z + 2. * EPSILON)
|
||||
if (has_extrusions && layer_to_print.print_z() > maximal_print_z + 2. * EPSILON)
|
||||
throw std::runtime_error(_(L("Empty layers detected, the output would not be printable.")) + "\n\n" +
|
||||
_(L("Object name")) + ": " + object.model_object()->name + "\n" + _(L("Print z")) + ": " +
|
||||
std::to_string(layers_to_print.back().print_z()) + "\n\n" + _(L("This is "
|
||||
|
|
|
|||
|
|
@ -212,10 +212,8 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
|||
if (m_print_config_ptr) { // in this case complete_objects is false (see ToolOrdering constructors)
|
||||
something_nonoverriddable = false;
|
||||
for (const auto& eec : layerm->perimeters.entities) // let's check if there are nonoverriddable entities
|
||||
if (!layer_tools.wiping_extrusions().is_overriddable_and_mark(dynamic_cast<const ExtrusionEntityCollection&>(*eec), *m_print_config_ptr, object, region)) {
|
||||
if (!layer_tools.wiping_extrusions().is_overriddable_and_mark(dynamic_cast<const ExtrusionEntityCollection&>(*eec), *m_print_config_ptr, object, region))
|
||||
something_nonoverriddable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (something_nonoverriddable)
|
||||
|
|
@ -237,7 +235,7 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
|||
has_infill = true;
|
||||
|
||||
if (m_print_config_ptr) {
|
||||
if (!something_nonoverriddable && !layer_tools.wiping_extrusions().is_overriddable_and_mark(*fill, *m_print_config_ptr, object, region))
|
||||
if (! layer_tools.wiping_extrusions().is_overriddable_and_mark(*fill, *m_print_config_ptr, object, region))
|
||||
something_nonoverriddable = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PRODUCTVERSION @SLIC3R_RC_VERSION@
|
|||
VALUE "ProductName", "@SLIC3R_APP_NAME@"
|
||||
VALUE "ProductVersion", "@SLIC3R_BUILD_ID@"
|
||||
VALUE "InternalName", "@SLIC3R_APP_NAME@"
|
||||
VALUE "LegalCopyright", "Copyright \251 2016-2019 Prusa Research, \251 2011-2018 Alessandro Ranelucci"
|
||||
VALUE "LegalCopyright", "Copyright \251 2016-2020 Prusa Research, \251 2011-2018 Alessandro Ranelucci"
|
||||
VALUE "OriginalFilename", "prusa-slicer.exe"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<key>CFBundleExecutable</key>
|
||||
<string>@SLIC3R_APP_KEY@</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>@SLIC3R_APP_NAME@ Copyright (C) 2011-2019 Alessandro Ranellucci, (C) 2016-2019 Prusa Reseach</string>
|
||||
<string>@SLIC3R_APP_NAME@ Copyright (C) 2011-2019 Alessandro Ranellucci, (C) 2016-2020 Prusa Reseach</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>PrusaSlicer.icns</string>
|
||||
<key>CFBundleName</key>
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES})
|
|||
|
||||
encoding_check(libslic3r_gui)
|
||||
|
||||
target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi)
|
||||
target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi libcurl ${wxWidgets_LIBRARIES})
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY})
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ AboutDialog::AboutDialog()
|
|||
"<html>"
|
||||
"<body bgcolor= %1% link= %2%>"
|
||||
"<font color=%3%>"
|
||||
"%4% © 2016-2019 Prusa Research. <br />"
|
||||
"%4% © 2016-2020 Prusa Research. <br />"
|
||||
"%5% © 2011-2018 Alessandro Ranellucci. <br />"
|
||||
"<a href=\"http://slic3r.org/\">Slic3r</a> %6% "
|
||||
"<a href=\"http://www.gnu.org/licenses/agpl-3.0.html\">%7%</a>."
|
||||
|
|
|
|||
|
|
@ -101,10 +101,9 @@ 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);
|
||||
GUI::RemovableDriveManager::get_instance().update();
|
||||
bool with_check = GUI::RemovableDriveManager::get_instance().is_path_on_removable_drive(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);
|
||||
switch (copy_ret_val){
|
||||
switch (copy_ret_val) {
|
||||
case SUCCESS: break; // no error
|
||||
case FAIL_COPY_FILE:
|
||||
throw std::runtime_error(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?")));
|
||||
|
|
@ -236,7 +235,7 @@ void BackgroundSlicingProcess::thread_proc()
|
|||
// Only post the canceled event, if canceled by user.
|
||||
// Don't post the canceled event, if canceled from Print::apply().
|
||||
wxCommandEvent evt(m_event_finished_id);
|
||||
evt.SetString(error);
|
||||
evt.SetString(GUI::from_u8(error));
|
||||
evt.SetInt(m_print->canceled() ? -1 : (error.empty() ? 1 : 0));
|
||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void Camera::debug_render() const
|
|||
imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
std::string type = get_type_as_string();
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||
type += "/free";
|
||||
else
|
||||
type += "/constrained";
|
||||
|
|
@ -537,6 +537,7 @@ void Camera::look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up
|
|||
Vec3d unit_y = unit_z.cross(unit_x).normalized();
|
||||
|
||||
m_target = target;
|
||||
m_distance = (position - target).norm();
|
||||
Vec3d new_position = m_target + m_distance * unit_z;
|
||||
|
||||
m_view_matrix(0, 0) = unit_x(0);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ public:
|
|||
// returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis
|
||||
bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }
|
||||
|
||||
void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up);
|
||||
|
||||
double max_zoom() const { return 100.0; }
|
||||
double min_zoom() const;
|
||||
|
||||
|
|
@ -137,7 +139,6 @@ private:
|
|||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||
void set_distance(double distance) const;
|
||||
|
||||
void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up);
|
||||
void set_default_orientation();
|
||||
Vec3d validate_target(const Vec3d& target) const;
|
||||
void update_zenit();
|
||||
|
|
|
|||
|
|
@ -42,16 +42,27 @@ using Config::SnapshotDB;
|
|||
|
||||
// Configuration data structures extensions needed for the wizard
|
||||
|
||||
Bundle::Bundle(fs::path source_path, bool is_in_resources, bool is_prusa_bundle)
|
||||
: preset_bundle(new PresetBundle)
|
||||
, vendor_profile(nullptr)
|
||||
, is_in_resources(is_in_resources)
|
||||
, is_prusa_bundle(is_prusa_bundle)
|
||||
bool Bundle::load(fs::path source_path, bool ais_in_resources, bool ais_prusa_bundle)
|
||||
{
|
||||
preset_bundle->load_configbundle(source_path.string(), PresetBundle::LOAD_CFGBNDLE_SYSTEM);
|
||||
this->preset_bundle = std::make_unique<PresetBundle>();
|
||||
this->is_in_resources = ais_in_resources;
|
||||
this->is_prusa_bundle = ais_prusa_bundle;
|
||||
|
||||
std::string path_string = source_path.string();
|
||||
size_t presets_loaded = preset_bundle->load_configbundle(path_string, PresetBundle::LOAD_CFGBNDLE_SYSTEM);
|
||||
auto first_vendor = preset_bundle->vendors.begin();
|
||||
wxCHECK_RET(first_vendor != preset_bundle->vendors.end(), "Failed to load preset bundle");
|
||||
vendor_profile = &first_vendor->second;
|
||||
if (first_vendor == preset_bundle->vendors.end()) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No vendor information defined, cannot install.") % path_string;
|
||||
return false;
|
||||
}
|
||||
if (presets_loaded == 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No profile loaded.") % path_string;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << boost::format("Vendor bundle: `%1%`: %2% profiles loaded.") % path_string % presets_loaded;
|
||||
this->vendor_profile = &first_vendor->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
Bundle::Bundle(Bundle &&other)
|
||||
|
|
@ -76,8 +87,11 @@ BundleMap BundleMap::load()
|
|||
prusa_bundle_path = (rsrc_vendor_dir / PresetBundle::PRUSA_BUNDLE).replace_extension(".ini");
|
||||
prusa_bundle_rsrc = true;
|
||||
}
|
||||
Bundle prusa_bundle(std::move(prusa_bundle_path), prusa_bundle_rsrc, true);
|
||||
res.emplace(PresetBundle::PRUSA_BUNDLE, std::move(prusa_bundle));
|
||||
{
|
||||
Bundle prusa_bundle;
|
||||
if (prusa_bundle.load(std::move(prusa_bundle_path), prusa_bundle_rsrc, true))
|
||||
res.emplace(PresetBundle::PRUSA_BUNDLE, std::move(prusa_bundle));
|
||||
}
|
||||
|
||||
// Load the other bundles in the datadir/vendor directory
|
||||
// and then additionally from resources/profiles.
|
||||
|
|
@ -90,8 +104,9 @@ BundleMap BundleMap::load()
|
|||
// Don't load this bundle if we've already loaded it.
|
||||
if (res.find(id) != res.end()) { continue; }
|
||||
|
||||
Bundle bundle(dir_entry.path(), is_in_resources);
|
||||
res.emplace(std::move(id), std::move(bundle));
|
||||
Bundle bundle;
|
||||
if (bundle.load(dir_entry.path(), is_in_resources))
|
||||
res.emplace(std::move(id), std::move(bundle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,13 +100,16 @@ struct Materials
|
|||
struct Bundle
|
||||
{
|
||||
std::unique_ptr<PresetBundle> preset_bundle;
|
||||
VendorProfile *vendor_profile;
|
||||
const bool is_in_resources;
|
||||
const bool is_prusa_bundle;
|
||||
VendorProfile *vendor_profile { nullptr };
|
||||
bool is_in_resources { false };
|
||||
bool is_prusa_bundle { false };
|
||||
|
||||
Bundle(fs::path source_path, bool is_in_resources, bool is_prusa_bundle = false);
|
||||
Bundle() = default;
|
||||
Bundle(Bundle &&other);
|
||||
|
||||
// Returns false if not loaded. Reason for that is logged as boost::log error.
|
||||
bool load(fs::path source_path, bool is_in_resources, bool is_prusa_bundle = false);
|
||||
|
||||
const std::string& vendor_id() const { return vendor_profile->id; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,19 @@ template<class T, size_t N> struct ArrayEvent : public wxEvent
|
|||
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
|
||||
}
|
||||
};
|
||||
template<class T> struct ArrayEvent<T, 1> : public wxEvent
|
||||
|
||||
template<class T> struct Event : public wxEvent
|
||||
{
|
||||
T data;
|
||||
|
||||
ArrayEvent(wxEventType type, T data, wxObject* origin = nullptr)
|
||||
Event(wxEventType type, const T &data, wxObject* origin = nullptr)
|
||||
: wxEvent(0, type), data(std::move(data))
|
||||
{
|
||||
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
||||
SetEventObject(origin);
|
||||
}
|
||||
|
||||
Event(wxEventType type, T&& data, wxObject* origin = nullptr)
|
||||
: wxEvent(0, type), data(std::move(data))
|
||||
{
|
||||
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
||||
|
|
@ -53,13 +61,10 @@ template<class T> struct ArrayEvent<T, 1> : public wxEvent
|
|||
|
||||
virtual wxEvent* Clone() const
|
||||
{
|
||||
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
|
||||
return new Event<T>(GetEventType(), data, GetEventObject());
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> using Event = ArrayEvent<T, 1>;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4088,12 +4088,6 @@ void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range
|
|||
|
||||
void GLCanvas3D::update_ui_from_settings()
|
||||
{
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
Camera& camera = wxGetApp().plater()->get_camera();
|
||||
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||
#else
|
||||
m_camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
m_dirty = true;
|
||||
|
||||
#if ENABLE_RETINA_GL
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ GUI_App::GUI_App()
|
|||
, m_em_unit(10)
|
||||
, m_imgui(new ImGuiWrapper())
|
||||
, m_wizard(nullptr)
|
||||
, m_removable_drive_manager(std::make_unique<RemovableDriveManager>())
|
||||
{}
|
||||
|
||||
GUI_App::~GUI_App()
|
||||
|
|
@ -279,7 +280,6 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
m_printhost_job_queue.reset(new PrintHostJobQueue(mainframe->printhost_queue_dlg()));
|
||||
|
||||
RemovableDriveManager::get_instance().init();
|
||||
|
||||
Bind(wxEVT_IDLE, [this](wxIdleEvent& event)
|
||||
{
|
||||
|
|
@ -291,10 +291,6 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
this->obj_manipul()->update_if_dirty();
|
||||
|
||||
#if !__APPLE__
|
||||
RemovableDriveManager::get_instance().update(wxGetLocalTime(), true);
|
||||
#endif
|
||||
|
||||
// Preset updating & Configwizard are done after the above initializations,
|
||||
// and after MainFrame is created & shown.
|
||||
// The extra CallAfter() is needed because of Mac, where this is the only way
|
||||
|
|
@ -454,46 +450,30 @@ float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
|
|||
|
||||
void GUI_App::recreate_GUI()
|
||||
{
|
||||
// Weird things happen as the Paint messages are floating around the windows being destructed.
|
||||
// Avoid the Paint messages by hiding the main window.
|
||||
// Also the application closes much faster without these unnecessary screen refreshes.
|
||||
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
|
||||
mainframe->Show(false);
|
||||
mainframe->shutdown();
|
||||
|
||||
const auto msg_name = _(L("Changing of an application language")) + dots;
|
||||
wxProgressDialog dlg(msg_name, msg_name);
|
||||
dlg.Pulse();
|
||||
|
||||
// to make sure nobody accesses data from the soon-to-be-destroyed widgets:
|
||||
tabs_list.clear();
|
||||
plater_ = nullptr;
|
||||
|
||||
dlg.Update(10, _(L("Recreating")) + dots);
|
||||
|
||||
MainFrame* topwindow = mainframe;
|
||||
MainFrame *old_main_frame = mainframe;
|
||||
mainframe = new MainFrame();
|
||||
sidebar().obj_list()->init_objects(); // propagate model objects to object list
|
||||
// Propagate model objects to object list.
|
||||
sidebar().obj_list()->init_objects();
|
||||
SetTopWindow(mainframe);
|
||||
|
||||
if (topwindow) {
|
||||
SetTopWindow(mainframe);
|
||||
|
||||
dlg.Update(30, _(L("Recreating")) + dots);
|
||||
topwindow->Destroy();
|
||||
|
||||
// For this moment ConfigWizard is deleted, invalidate it
|
||||
m_wizard = nullptr;
|
||||
}
|
||||
dlg.Update(30, _(L("Recreating")) + dots);
|
||||
old_main_frame->Destroy();
|
||||
// For this moment ConfigWizard is deleted, invalidate it.
|
||||
m_wizard = nullptr;
|
||||
|
||||
dlg.Update(80, _(L("Loading of current presets")) + dots);
|
||||
|
||||
m_printhost_job_queue.reset(new PrintHostJobQueue(mainframe->printhost_queue_dlg()));
|
||||
|
||||
load_current_presets();
|
||||
|
||||
mainframe->Show(true);
|
||||
|
||||
dlg.Update(90, _(L("Loading of a mode view")) + dots);
|
||||
|
||||
/* Temporary workaround for the correct behavior of the Scrolled sidebar panel:
|
||||
* change min hight of object list to the normal min value (15 * wxGetApp().em_unit())
|
||||
* after first whole Mainframe updating/layouting
|
||||
|
|
@ -501,7 +481,6 @@ void GUI_App::recreate_GUI()
|
|||
const int list_min_height = 15 * em_unit();
|
||||
if (obj_list()->GetMinSize().GetY() > list_min_height)
|
||||
obj_list()->SetMinSize(wxSize(-1, list_min_height));
|
||||
|
||||
update_mode();
|
||||
|
||||
// #ys_FIXME_delete_after_testing Do we still need this ?
|
||||
|
|
@ -596,9 +575,6 @@ void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
|
|||
bool GUI_App::switch_language()
|
||||
{
|
||||
if (select_language()) {
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
_3DScene::remove_all_canvases();
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
recreate_GUI();
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ class PresetUpdater;
|
|||
class ModelObject;
|
||||
class PrintHostJobQueue;
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
namespace GUI{
|
||||
class RemovableDriveManager;
|
||||
enum FileType
|
||||
{
|
||||
FT_STL,
|
||||
|
|
@ -102,6 +102,9 @@ class GUI_App : public wxApp
|
|||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
GLCanvas3DManager m_canvas_mgr;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;
|
||||
|
||||
std::unique_ptr<ImGuiWrapper> m_imgui;
|
||||
std::unique_ptr<PrintHostJobQueue> m_printhost_job_queue;
|
||||
ConfigWizard* m_wizard; // Managed by wxWindow tree
|
||||
|
|
@ -192,6 +195,8 @@ public:
|
|||
|
||||
std::vector<Tab *> tabs_list;
|
||||
|
||||
RemovableDriveManager* removable_drive_manager() { return m_removable_drive_manager.get(); }
|
||||
|
||||
ImGuiWrapper* imgui() { return m_imgui.get(); }
|
||||
|
||||
PrintHostJobQueue& printhost_job_queue() { return *m_printhost_job_queue.get(); }
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ void KBShortcutsDialog::fill_shortcuts()
|
|||
{ ctrl + "G", L("Export G-code") },
|
||||
{ ctrl + "Shift+" + "G", L("Send G-code") },
|
||||
{ ctrl + "E", L("Export config") },
|
||||
{ ctrl + "U", L("Export to SD card / Flash drive") },
|
||||
{ ctrl + "T", L("Eject SD card / Flash drive") },
|
||||
// Edit
|
||||
{ ctrl + "A", L("Select all objects") },
|
||||
{ "Esc", L("Deselect all") },
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "wxExtensions.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "Mouse3DController.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
|
@ -108,44 +109,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
event.Veto();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_plater)
|
||||
m_plater->stop_jobs();
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
// Unbinding of wxWidgets event handling in canvases needs to be done here because on MAC,
|
||||
// when closing the application using Command+Q, a mouse event is triggered after this lambda is completed,
|
||||
// causing a crash
|
||||
if (m_plater) m_plater->unbind_canvas_event_handlers();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
// Weird things happen as the Paint messages are floating around the windows being destructed.
|
||||
// Avoid the Paint messages by hiding the main window.
|
||||
// Also the application closes much faster without these unnecessary screen refreshes.
|
||||
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
|
||||
this->Show(false);
|
||||
|
||||
// Stop the background thread (Windows and Linux).
|
||||
// Disconnect from a 3DConnextion driver (OSX).
|
||||
m_plater->get_mouse3d_controller().shutdown();
|
||||
// Store the device parameter database back to appconfig.
|
||||
m_plater->get_mouse3d_controller().save_config(*wxGetApp().app_config);
|
||||
|
||||
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
|
||||
// but in rare cases it may not have been called yet.
|
||||
wxGetApp().app_config->save();
|
||||
// if (m_plater)
|
||||
// m_plater->print = undef;
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
_3DScene::remove_all_canvases();
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
// Slic3r::GUI::deregister_on_request_update_callback();
|
||||
|
||||
// set to null tabs and a plater
|
||||
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
|
||||
wxGetApp().tabs_list.clear();
|
||||
wxGetApp().plater_ = nullptr;
|
||||
|
||||
this->shutdown();
|
||||
// propagate event
|
||||
event.Skip();
|
||||
});
|
||||
|
|
@ -164,6 +128,50 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||
m_plater->show_action_buttons(true);
|
||||
}
|
||||
|
||||
// Called when closing the application and when switching the application language.
|
||||
void MainFrame::shutdown()
|
||||
{
|
||||
if (m_plater)
|
||||
m_plater->stop_jobs();
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
// Unbinding of wxWidgets event handling in canvases needs to be done here because on MAC,
|
||||
// when closing the application using Command+Q, a mouse event is triggered after this lambda is completed,
|
||||
// causing a crash
|
||||
if (m_plater) m_plater->unbind_canvas_event_handlers();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
// Weird things happen as the Paint messages are floating around the windows being destructed.
|
||||
// Avoid the Paint messages by hiding the main window.
|
||||
// Also the application closes much faster without these unnecessary screen refreshes.
|
||||
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
|
||||
this->Show(false);
|
||||
|
||||
// Stop the background thread (Windows and Linux).
|
||||
// Disconnect from a 3DConnextion driver (OSX).
|
||||
m_plater->get_mouse3d_controller().shutdown();
|
||||
// Store the device parameter database back to appconfig.
|
||||
m_plater->get_mouse3d_controller().save_config(*wxGetApp().app_config);
|
||||
|
||||
// Stop the background thread of the removable drive manager, so that no new updates will be sent to the Plater.
|
||||
wxGetApp().removable_drive_manager()->shutdown();
|
||||
|
||||
// Save the slic3r.ini.Usually the ini file is saved from "on idle" callback,
|
||||
// but in rare cases it may not have been called yet.
|
||||
wxGetApp().app_config->save();
|
||||
// if (m_plater)
|
||||
// m_plater->print = undef;
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
_3DScene::remove_all_canvases();
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
// Slic3r::GUI::deregister_on_request_update_callback();
|
||||
|
||||
// set to null tabs and a plater
|
||||
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
|
||||
wxGetApp().tabs_list.clear();
|
||||
wxGetApp().plater_ = nullptr;
|
||||
}
|
||||
|
||||
void MainFrame::update_title()
|
||||
{
|
||||
wxString title = wxEmptyString;
|
||||
|
|
@ -332,6 +340,27 @@ bool MainFrame::can_send_gcode() const
|
|||
return print_host_opt != nullptr && !print_host_opt->value.empty();
|
||||
}
|
||||
|
||||
bool MainFrame::can_export_gcode_sd() const
|
||||
{
|
||||
if (m_plater == nullptr)
|
||||
return false;
|
||||
|
||||
if (m_plater->model().objects.empty())
|
||||
return false;
|
||||
|
||||
if (m_plater->is_export_gcode_scheduled())
|
||||
return false;
|
||||
|
||||
// TODO:: add other filters
|
||||
|
||||
return wxGetApp().removable_drive_manager()->status().has_removable_drives;
|
||||
}
|
||||
|
||||
bool MainFrame::can_eject() const
|
||||
{
|
||||
return wxGetApp().removable_drive_manager()->status().has_eject;
|
||||
}
|
||||
|
||||
bool MainFrame::can_slice() const
|
||||
{
|
||||
bool bg_proc = wxGetApp().app_config->get("background_processing") == "1";
|
||||
|
|
@ -438,7 +467,7 @@ void MainFrame::init_menubar()
|
|||
m_plater->load_project(filename);
|
||||
else
|
||||
{
|
||||
wxMessageDialog msg(this, _(L("The selected project is no longer available.\nDo you want to remove it from the recent projects list ?")), _(L("Error")), wxYES_NO | wxYES_DEFAULT);
|
||||
wxMessageDialog msg(this, _(L("The selected project is no longer available.\nDo you want to remove it from the recent projects list?")), _(L("Error")), wxYES_NO | wxYES_DEFAULT);
|
||||
if (msg.ShowModal() == wxID_YES)
|
||||
{
|
||||
m_recent_projects.RemoveFileFromHistory(file_id);
|
||||
|
|
@ -502,6 +531,9 @@ void MainFrame::init_menubar()
|
|||
[this](wxCommandEvent&) { if (m_plater) m_plater->send_gcode(); }, "export_gcode", nullptr,
|
||||
[this](){return can_send_gcode(); }, this);
|
||||
m_changeable_menu_items.push_back(item_send_gcode);
|
||||
append_menu_item(export_menu, wxID_ANY, _(L("Export G-code to SD card / Flash drive")) + dots + "\tCtrl+U", _(L("Export current plate as G-code to SD card / Flash drive")),
|
||||
[this](wxCommandEvent&) { if (m_plater) m_plater->export_gcode(true); }, "export_to_sd", nullptr,
|
||||
[this]() {return can_export_gcode_sd(); }, this);
|
||||
export_menu->AppendSeparator();
|
||||
append_menu_item(export_menu, wxID_ANY, _(L("Export plate as &STL")) + dots, _(L("Export current plate as STL")),
|
||||
[this](wxCommandEvent&) { if (m_plater) m_plater->export_stl(); }, "export_plater", nullptr,
|
||||
|
|
@ -525,6 +557,10 @@ void MainFrame::init_menubar()
|
|||
[this]() {return true; }, this);
|
||||
append_submenu(fileMenu, export_menu, wxID_ANY, _(L("&Export")), "");
|
||||
|
||||
append_menu_item(fileMenu, wxID_ANY, _(L("Ejec&t SD card / Flash drive")) + dots + "\tCtrl+T", _(L("Eject SD card / Flash drive after the G-code was exported to it.")),
|
||||
[this](wxCommandEvent&) { if (m_plater) m_plater->eject_drive(); }, "eject_sd", nullptr,
|
||||
[this]() {return can_eject(); }, this);
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ class MainFrame : public DPIFrame
|
|||
bool can_export_supports() const;
|
||||
bool can_export_gcode() const;
|
||||
bool can_send_gcode() const;
|
||||
bool can_export_gcode_sd() const;
|
||||
bool can_eject() const;
|
||||
bool can_slice() const;
|
||||
bool can_change_view() const;
|
||||
bool can_select() const;
|
||||
|
|
@ -98,6 +100,9 @@ public:
|
|||
MainFrame();
|
||||
~MainFrame() = default;
|
||||
|
||||
// Called when closing the application and when switching the application language.
|
||||
void shutdown();
|
||||
|
||||
Plater* plater() { return m_plater; }
|
||||
|
||||
void update_title();
|
||||
|
|
|
|||
|
|
@ -368,6 +368,8 @@ void Mouse3DController::render_settings_dialog(GLCanvas3D& canvas) const
|
|||
|
||||
void Mouse3DController::connected(std::string device_name)
|
||||
{
|
||||
assert(! m_connected);
|
||||
assert(m_device_str.empty());
|
||||
m_device_str = device_name;
|
||||
// Copy the parameters for m_device_str into the current parameters.
|
||||
if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
|
||||
|
|
@ -380,13 +382,13 @@ void Mouse3DController::connected(std::string device_name)
|
|||
void Mouse3DController::disconnected()
|
||||
{
|
||||
// Copy the current parameters for m_device_str into the parameter database.
|
||||
assert(! m_device_str.empty());
|
||||
if (! m_device_str.empty()) {
|
||||
assert(m_connected == ! m_device_str.empty());
|
||||
if (m_connected) {
|
||||
tbb::mutex::scoped_lock lock(m_params_ui_mutex);
|
||||
m_params_by_device[m_device_str] = m_params_ui;
|
||||
m_device_str.clear();
|
||||
m_connected = false;
|
||||
}
|
||||
m_device_str.clear();
|
||||
m_connected = false;
|
||||
}
|
||||
|
||||
bool Mouse3DController::handle_input(const DataPacketAxis& packet)
|
||||
|
|
@ -451,12 +453,13 @@ void Mouse3DController::shutdown()
|
|||
// Stop the worker thread, if running.
|
||||
{
|
||||
// Notify the worker thread to cancel wait on detection polling.
|
||||
std::unique_lock<std::mutex> lock(m_stop_condition_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_stop_condition_mutex);
|
||||
m_stop = true;
|
||||
m_stop_condition.notify_all();
|
||||
}
|
||||
m_stop_condition.notify_all();
|
||||
// Wait for the worker thread to stop.
|
||||
m_thread.join();
|
||||
m_stop = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <thread>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <tbb/mutex.h>
|
||||
|
||||
|
|
@ -138,7 +139,7 @@ class Mouse3DController
|
|||
std::map<std::string, Params> m_params_by_device;
|
||||
|
||||
mutable State m_state;
|
||||
std::atomic<bool> m_connected;
|
||||
std::atomic<bool> m_connected { false };
|
||||
std::string m_device_str;
|
||||
|
||||
#if ! __APPLE__
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ static void DeviceAdded(uint32_t unused)
|
|||
static void DeviceRemoved(uint32_t unused)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "3dx device removed\n";
|
||||
assert(m_connected);
|
||||
assert(! m_device_str.empty());
|
||||
mouse_3d_controller->disconnected();
|
||||
}
|
||||
|
||||
|
|
@ -214,6 +216,8 @@ void Mouse3DController::shutdown()
|
|||
CleanupConnexionHandlers();
|
||||
unload_driver();
|
||||
}
|
||||
// Copy the current parameters to parameter database, mark the device as disconnected.
|
||||
this->disconnected();
|
||||
mouse_3d_controller = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg)
|
|||
html->SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
wxColour text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK); // wxSYS_COLOUR_WINDOW
|
||||
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
|
||||
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
|
||||
const int font_size = font.GetPointSize()-1;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,11 @@ void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& fiel
|
|||
}
|
||||
|
||||
void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = nullptr*/) {
|
||||
if ( (line.sizer != nullptr || line.widget != nullptr) && line.full_width) {
|
||||
if ( line.full_width && (
|
||||
line.sizer != nullptr ||
|
||||
line.widget != nullptr ||
|
||||
!line.get_extra_widgets().empty() )
|
||||
) {
|
||||
if (line.sizer != nullptr) {
|
||||
sizer->Add(line.sizer, 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||
return;
|
||||
|
|
@ -122,6 +126,17 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
|
|||
sizer->Add(line.widget(this->ctrl_parent()), 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||
return;
|
||||
}
|
||||
if (!line.get_extra_widgets().empty()) {
|
||||
const auto h_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(h_sizer, 1, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
||||
|
||||
bool is_first_item = true;
|
||||
for (auto extra_widget : line.get_extra_widgets()) {
|
||||
h_sizer->Add(extra_widget(this->ctrl_parent()), is_first_item ? 1 : 0, wxLEFT, 15);
|
||||
is_first_item = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto option_set = line.get_options();
|
||||
|
|
@ -412,7 +427,9 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
|
|||
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(config.option("nozzle_diameter"));
|
||||
value = int(nozzle_diameter->values.size());
|
||||
}
|
||||
else if (m_opt_map.find(opt_key) == m_opt_map.end() || opt_key == "bed_shape") {
|
||||
else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
|
||||
// This option don't have corresponded field
|
||||
opt_key == "bed_shape" || opt_key == "compatible_printers" || opt_key == "compatible_prints" ) {
|
||||
value = get_config_value(config, opt_key);
|
||||
change_opt_value(*m_config, opt_key, value);
|
||||
return;
|
||||
|
|
@ -629,7 +646,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
|||
ret = static_cast<wxString>(config.opt_string(opt_key));
|
||||
break;
|
||||
case coStrings:
|
||||
if (opt_key.compare("compatible_printers") == 0) {
|
||||
if (opt_key == "compatible_printers" || opt_key == "compatible_prints") {
|
||||
ret = config.option<ConfigOptionStrings>(opt_key)->values;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,15 +301,20 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
|
|||
if (preset_type == Slic3r::Preset::TYPE_FILAMENT)
|
||||
{
|
||||
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &event) {
|
||||
int shifl_Left = 0;
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
const Preset* selected_preset = preset_bundle->filaments.find_preset(preset_bundle->filament_presets[extruder_idx]);
|
||||
// Wide icons are shown if the currently selected preset is not compatible with the current printer,
|
||||
// and red flag is drown in front of the selected preset.
|
||||
bool wide_icons = selected_preset != nullptr && !selected_preset->is_compatible;
|
||||
float scale = m_em_unit*0.1f;
|
||||
|
||||
int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0;
|
||||
#if defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED)
|
||||
shifl_Left = int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image
|
||||
shifl_Left += int(scale * 4 + 0.5f); // IMAGE_SPACING_RIGHT = 4 for wxBitmapComboBox -> Space left of image
|
||||
#endif
|
||||
int icon_right_pos = int(scale * (24+4) + 0.5);
|
||||
int icon_right_pos = shifl_Left + int(scale * (24+4) + 0.5);
|
||||
int mouse_pos = event.GetLogicalPosition(wxClientDC(this)).x;
|
||||
// if (extruder_idx < 0 || event.GetLogicalPosition(wxClientDC(this)).x > 24) {
|
||||
if ( extruder_idx < 0 || mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) {
|
||||
if (mouse_pos < shifl_Left || mouse_pos > icon_right_pos ) {
|
||||
// Let the combo box process the mouse click.
|
||||
event.Skip();
|
||||
return;
|
||||
|
|
@ -338,7 +343,7 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
|
|||
cfg_new.set_key_value("extruder_colour", colors);
|
||||
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new);
|
||||
wxGetApp().preset_bundle->update_plater_filament_ui(extruder_idx, this);
|
||||
preset_bundle->update_plater_filament_ui(extruder_idx, this);
|
||||
wxGetApp().plater()->on_config_change(cfg_new);
|
||||
}
|
||||
});
|
||||
|
|
@ -881,8 +886,8 @@ Sidebar::Sidebar(Plater *parent)
|
|||
};
|
||||
|
||||
init_scalable_btn(&p->btn_send_gcode , "export_gcode", _(L("Send to printer")) + "\tCtrl+Shift+G");
|
||||
init_scalable_btn(&p->btn_remove_device, "eject_sd" , _(L("Remove device")));
|
||||
init_scalable_btn(&p->btn_export_gcode_removable, "export_to_sd", _(L("Export to SD card / Flash drive")));
|
||||
init_scalable_btn(&p->btn_remove_device, "eject_sd" , _(L("Remove device")) + "\tCtrl+T");
|
||||
init_scalable_btn(&p->btn_export_gcode_removable, "export_to_sd", _(L("Export to SD card / Flash drive")) + "\tCtrl+U");
|
||||
|
||||
// regular buttons "Slice now" and "Export G-code"
|
||||
|
||||
|
|
@ -1509,6 +1514,7 @@ struct Plater::priv
|
|||
ret.poly.contour = std::move(p);
|
||||
ret.translation = scaled(m_pos);
|
||||
ret.rotation = m_rotation;
|
||||
ret.priority++;
|
||||
return ret;
|
||||
}
|
||||
} wipetower;
|
||||
|
|
@ -1572,18 +1578,23 @@ struct Plater::priv
|
|||
// the current bed width.
|
||||
static const constexpr double LOGICAL_BED_GAP = 1. / 5.;
|
||||
|
||||
ArrangePolygons m_selected, m_unselected;
|
||||
ArrangePolygons m_selected, m_unselected, m_unprintable;
|
||||
|
||||
// clear m_selected and m_unselected, reserve space for next usage
|
||||
void clear_input() {
|
||||
const Model &model = plater().model;
|
||||
|
||||
size_t count = 0; // To know how much space to reserve
|
||||
for (auto obj : model.objects) count += obj->instances.size();
|
||||
size_t count = 0, cunprint = 0; // To know how much space to reserve
|
||||
for (auto obj : model.objects)
|
||||
for (auto mi : obj->instances)
|
||||
mi->printable ? count++ : cunprint++;
|
||||
|
||||
m_selected.clear();
|
||||
m_unselected.clear();
|
||||
m_unprintable.clear();
|
||||
m_selected.reserve(count + 1 /* for optional wti */);
|
||||
m_unselected.reserve(count + 1 /* for optional wti */);
|
||||
m_unprintable.reserve(cunprint /* for optional wti */);
|
||||
}
|
||||
|
||||
// Stride between logical beds
|
||||
|
|
@ -1612,8 +1623,10 @@ struct Plater::priv
|
|||
clear_input();
|
||||
|
||||
for (ModelObject *obj: plater().model.objects)
|
||||
for (ModelInstance *mi : obj->instances)
|
||||
m_selected.emplace_back(get_arrange_poly(mi));
|
||||
for (ModelInstance *mi : obj->instances) {
|
||||
ArrangePolygons & cont = mi->printable ? m_selected : m_unprintable;
|
||||
cont.emplace_back(get_arrange_poly(mi));
|
||||
}
|
||||
|
||||
auto& wti = plater().updated_wipe_tower();
|
||||
if (wti) m_selected.emplace_back(get_arrange_poly(&wti));
|
||||
|
|
@ -1648,9 +1661,12 @@ struct Plater::priv
|
|||
for (size_t i = 0; i < inst_sel.size(); ++i) {
|
||||
ArrangePolygon &&ap = get_arrange_poly(mo->instances[i]);
|
||||
|
||||
inst_sel[i] ?
|
||||
m_selected.emplace_back(std::move(ap)) :
|
||||
m_unselected.emplace_back(std::move(ap));
|
||||
ArrangePolygons &cont = mo->instances[i]->printable ?
|
||||
(inst_sel[i] ? m_selected :
|
||||
m_unselected) :
|
||||
m_unprintable;
|
||||
|
||||
cont.emplace_back(std::move(ap));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1682,16 +1698,35 @@ struct Plater::priv
|
|||
public:
|
||||
using PlaterJob::PlaterJob;
|
||||
|
||||
int status_range() const override { return int(m_selected.size()); }
|
||||
int status_range() const override
|
||||
{
|
||||
return int(m_selected.size() + m_unprintable.size());
|
||||
}
|
||||
|
||||
void process() override;
|
||||
|
||||
void finalize() override {
|
||||
// Ignore the arrange result if aborted.
|
||||
if (was_canceled()) return;
|
||||
|
||||
|
||||
// Unprintable items go to the last virtual bed
|
||||
int beds = 0;
|
||||
|
||||
// Apply the arrange result to all selected objects
|
||||
for (ArrangePolygon &ap : m_selected) ap.apply();
|
||||
for (ArrangePolygon &ap : m_selected) {
|
||||
beds = std::max(ap.bed_idx, beds);
|
||||
ap.apply();
|
||||
}
|
||||
|
||||
// Get the virtual beds from the unselected items
|
||||
for (ArrangePolygon &ap : m_unselected)
|
||||
beds = std::max(ap.bed_idx, beds);
|
||||
|
||||
// Move the unprintable items to the last virtual bed.
|
||||
for (ArrangePolygon &ap : m_unprintable) {
|
||||
ap.bed_idx += beds + 1;
|
||||
ap.apply();
|
||||
}
|
||||
|
||||
plater().update();
|
||||
}
|
||||
|
|
@ -1961,6 +1996,11 @@ struct Plater::priv
|
|||
wxString get_project_filename(const wxString& extension = wxEmptyString) const;
|
||||
void set_project_filename(const wxString& filename);
|
||||
|
||||
// Caching last value of show_action_buttons parameter for show_action_buttons(), so that a callback which does not know this state will not override it.
|
||||
mutable bool ready_to_slice = { false };
|
||||
// Flag indicating that the G-code export targets a removable device, therefore the show_action_buttons() needs to be called at any case when the background processing finishes.
|
||||
bool writing_to_removable_device = { false };
|
||||
|
||||
private:
|
||||
bool init_object_menu();
|
||||
bool init_common_menu(wxMenu* menu, const bool is_part = false);
|
||||
|
|
@ -1986,8 +2026,8 @@ private:
|
|||
* we should call tack_snapshot just ones
|
||||
* instead of calls for each action separately
|
||||
* */
|
||||
std::string m_last_fff_printer_profile_name;
|
||||
std::string m_last_sla_printer_profile_name;
|
||||
std::string m_last_fff_printer_profile_name;
|
||||
std::string m_last_sla_printer_profile_name;
|
||||
};
|
||||
|
||||
const std::regex Plater::priv::pattern_bundle(".*[.](amf|amf[.]xml|zip[.]amf|3mf|prusa)", std::regex::icase);
|
||||
|
|
@ -2171,11 +2211,17 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
// Connect to a 3DConnextion driver (OSX).
|
||||
mouse3d_controller.init();
|
||||
|
||||
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());
|
||||
});
|
||||
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);
|
||||
|
||||
// Initialize the Undo / Redo stack with a first snapshot.
|
||||
this->take_snapshot(_(L("New Project")));
|
||||
|
||||
//void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const
|
||||
RemovableDriveManager::get_instance().set_drive_count_changed_callback(std::bind(&Plater::priv::show_action_buttons, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
Plater::priv::~priv()
|
||||
|
|
@ -2249,6 +2295,14 @@ void Plater::priv::update_ui_from_settings()
|
|||
// $self->{buttons_sizer}->Layout;
|
||||
// }
|
||||
|
||||
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||
if (wxGetApp().app_config->get("use_free_camera") != "1")
|
||||
{
|
||||
// forces camera right vector to be parallel to XY plane
|
||||
if (std::abs(camera.get_dir_right()(2)) > EPSILON)
|
||||
camera.look_at(camera.get_position(), camera.get_target(), Vec3d::UnitZ());
|
||||
}
|
||||
|
||||
view3D->get_canvas3d()->update_ui_from_settings();
|
||||
preview->get_canvas3d()->update_ui_from_settings();
|
||||
}
|
||||
|
|
@ -2842,16 +2896,21 @@ void Plater::priv::ArrangeJob::process() {
|
|||
}
|
||||
|
||||
coord_t min_d = scaled(dist);
|
||||
auto count = unsigned(m_selected.size());
|
||||
auto count = unsigned(m_selected.size() + m_unprintable.size());
|
||||
arrangement::BedShapeHint bedshape = plater().get_bed_shape_hint();
|
||||
|
||||
|
||||
auto stopfn = [this]() { return was_canceled(); };
|
||||
|
||||
try {
|
||||
arrangement::arrange(m_selected, m_unselected, min_d, bedshape,
|
||||
[this, count](unsigned st) {
|
||||
if (st > 0) // will not finalize after last one
|
||||
update_status(int(count - st), arrangestr);
|
||||
},
|
||||
[this]() { return was_canceled(); });
|
||||
[this, count](unsigned st) {
|
||||
st += m_unprintable.size();
|
||||
if (st > 0) update_status(int(count - st), arrangestr);
|
||||
}, stopfn);
|
||||
arrangement::arrange(m_unprintable, {}, min_d, bedshape,
|
||||
[this, count](unsigned st) {
|
||||
if (st > 0) update_status(int(count - st), arrangestr);
|
||||
}, stopfn);
|
||||
} catch (std::exception & /*e*/) {
|
||||
GUI::show_error(plater().q,
|
||||
_(L("Could not arrange model objects! "
|
||||
|
|
@ -3717,14 +3776,9 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
|||
sidebar->set_btn_label(ActionButtonType::abReslice, "Slice now");
|
||||
show_action_buttons(true);
|
||||
}
|
||||
else if (wxGetApp().get_mode() == comSimple)
|
||||
show_action_buttons(false);
|
||||
|
||||
if(!canceled && RemovableDriveManager::get_instance().get_is_writing())
|
||||
{
|
||||
RemovableDriveManager::get_instance().set_is_writing(false);
|
||||
show_action_buttons(false);
|
||||
}
|
||||
else if (this->writing_to_removable_device || wxGetApp().get_mode() == comSimple)
|
||||
show_action_buttons(false);
|
||||
this->writing_to_removable_device = false;
|
||||
}
|
||||
|
||||
void Plater::priv::on_layer_editing_toggled(bool enable)
|
||||
|
|
@ -4295,32 +4349,36 @@ void Plater::priv::update_object_menu()
|
|||
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
|
||||
}
|
||||
|
||||
void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const
|
||||
void Plater::priv::show_action_buttons(const bool ready_to_slice) const
|
||||
{
|
||||
RemovableDriveManager::get_instance().set_plater_ready_to_slice(is_ready_to_slice);
|
||||
// Cache this value, so that the callbacks from the RemovableDriveManager may repeat that value when calling show_action_buttons().
|
||||
this->ready_to_slice = ready_to_slice;
|
||||
|
||||
wxWindowUpdateLocker noUpdater(sidebar);
|
||||
const auto prin_host_opt = config->option<ConfigOptionString>("print_host");
|
||||
const bool send_gcode_shown = prin_host_opt != nullptr && !prin_host_opt->value.empty();
|
||||
|
||||
bool disconnect_shown = !RemovableDriveManager::get_instance().is_last_drive_removed();
|
||||
bool export_removable_shown = RemovableDriveManager::get_instance().get_drives_count() > 0;
|
||||
// when a background processing is ON, export_btn and/or send_btn are showing
|
||||
if (wxGetApp().app_config->get("background_processing") == "1")
|
||||
{
|
||||
RemovableDriveManager::RemovableDrivesStatus removable_media_status = wxGetApp().removable_drive_manager()->status();
|
||||
if (sidebar->show_reslice(false) |
|
||||
sidebar->show_export(true) |
|
||||
sidebar->show_send(send_gcode_shown) |
|
||||
sidebar->show_export_removable(export_removable_shown) |
|
||||
sidebar->show_disconnect(disconnect_shown))
|
||||
sidebar->show_export_removable(removable_media_status.has_removable_drives) |
|
||||
sidebar->show_disconnect(removable_media_status.has_eject))
|
||||
sidebar->Layout();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sidebar->show_reslice(is_ready_to_slice) |
|
||||
sidebar->show_export(!is_ready_to_slice) |
|
||||
sidebar->show_send(send_gcode_shown && !is_ready_to_slice) |
|
||||
sidebar->show_export_removable(export_removable_shown && !is_ready_to_slice) |
|
||||
sidebar->show_disconnect(disconnect_shown && !is_ready_to_slice))
|
||||
RemovableDriveManager::RemovableDrivesStatus removable_media_status;
|
||||
if (! ready_to_slice)
|
||||
removable_media_status = wxGetApp().removable_drive_manager()->status();
|
||||
if (sidebar->show_reslice(ready_to_slice) |
|
||||
sidebar->show_export(!ready_to_slice) |
|
||||
sidebar->show_send(send_gcode_shown && !ready_to_slice) |
|
||||
sidebar->show_export_removable(!ready_to_slice && removable_media_status.has_removable_drives) |
|
||||
sidebar->show_disconnect(!ready_to_slice && removable_media_status.has_eject))
|
||||
sidebar->Layout();
|
||||
}
|
||||
}
|
||||
|
|
@ -4854,51 +4912,38 @@ void Plater::export_gcode(bool prefer_removable)
|
|||
return;
|
||||
}
|
||||
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
|
||||
auto start_dir = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string());
|
||||
bool removable_drives_connected = GUI::RemovableDriveManager::get_instance().update();
|
||||
if(prefer_removable)
|
||||
{
|
||||
if(removable_drives_connected)
|
||||
{
|
||||
auto start_dir_removable = wxGetApp().app_config->get_last_output_dir(default_output_file.parent_path().string(), true);
|
||||
if (RemovableDriveManager::get_instance().is_path_on_removable_drive(start_dir_removable))
|
||||
{
|
||||
start_dir = start_dir_removable;
|
||||
}else
|
||||
{
|
||||
start_dir = RemovableDriveManager::get_instance().get_drive_path();
|
||||
}
|
||||
}
|
||||
AppConfig &appconfig = *wxGetApp().app_config;
|
||||
RemovableDriveManager &removable_drive_manager = *wxGetApp().removable_drive_manager();
|
||||
// Get a last save path, either to removable media or to an internal media.
|
||||
std::string start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), prefer_removable);
|
||||
if (prefer_removable) {
|
||||
// Returns a path to a removable media if it exists, prefering start_dir. Update the internal removable drives database.
|
||||
start_dir = removable_drive_manager.get_removable_drive_path(start_dir);
|
||||
if (start_dir.empty())
|
||||
// Direct user to the last internal media.
|
||||
start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false);
|
||||
}
|
||||
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save SL1 file as:")),
|
||||
start_dir,
|
||||
from_path(default_output_file.filename()),
|
||||
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : FT_PNGZIP, default_output_file.extension().string()),
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||
);
|
||||
|
||||
fs::path output_path;
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
fs::path path = into_path(dlg.GetPath());
|
||||
wxGetApp().app_config->update_last_output_dir(path.parent_path().string(), RemovableDriveManager::get_instance().is_path_on_removable_drive(path.parent_path().string()));
|
||||
output_path = std::move(path);
|
||||
{
|
||||
wxFileDialog dlg(this, (printer_technology() == ptFFF) ? _(L("Save G-code file as:")) : _(L("Save SL1 file as:")),
|
||||
start_dir,
|
||||
from_path(default_output_file.filename()),
|
||||
GUI::file_wildcards((printer_technology() == ptFFF) ? FT_GCODE : FT_PNGZIP, default_output_file.extension().string()),
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
|
||||
);
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
output_path = into_path(dlg.GetPath());
|
||||
}
|
||||
if (! output_path.empty())
|
||||
{
|
||||
std::string path = output_path.string();
|
||||
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||
|
||||
RemovableDriveManager::get_instance().update(0, false);
|
||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||
RemovableDriveManager::get_instance().verify_last_save_path();
|
||||
|
||||
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||
{
|
||||
RemovableDriveManager::get_instance().set_is_writing(true);
|
||||
RemovableDriveManager::get_instance().erase_callbacks();
|
||||
RemovableDriveManager::get_instance().add_remove_callback(std::bind(&Plater::drive_ejected_callback, this));
|
||||
}
|
||||
|
||||
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());
|
||||
// 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.
|
||||
appconfig.update_last_output_dir(output_path.parent_path().string(), path_on_removable_media);
|
||||
p->writing_to_removable_device = path_on_removable_media;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5220,28 +5265,11 @@ void Plater::send_gcode()
|
|||
}
|
||||
}
|
||||
|
||||
// Called when the Eject button is pressed.
|
||||
void Plater::eject_drive()
|
||||
{
|
||||
RemovableDriveManager::get_instance().update(0, true);
|
||||
RemovableDriveManager::get_instance().erase_callbacks();
|
||||
RemovableDriveManager::get_instance().add_remove_callback(std::bind(&Plater::drive_ejected_callback, this));
|
||||
RemovableDriveManager::get_instance().eject_drive(RemovableDriveManager::get_instance().get_last_save_path());
|
||||
|
||||
wxGetApp().removable_drive_manager()->eject_drive();
|
||||
}
|
||||
void Plater::drive_ejected_callback()
|
||||
{
|
||||
if (RemovableDriveManager::get_instance().get_did_eject())
|
||||
{
|
||||
RemovableDriveManager::get_instance().set_did_eject(false);
|
||||
show_info(this,
|
||||
(boost::format(_utf8(L("Unmounting successful. The device %s(%s) can now be safely removed from the computer.")))
|
||||
% RemovableDriveManager::get_instance().get_ejected_name()
|
||||
% RemovableDriveManager::get_instance().get_ejected_path()).str());
|
||||
}
|
||||
p->show_action_buttons(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Plater::take_snapshot(const std::string &snapshot_name) { p->take_snapshot(snapshot_name); }
|
||||
void Plater::take_snapshot(const wxString &snapshot_name) { p->take_snapshot(snapshot_name); }
|
||||
|
|
@ -5631,7 +5659,7 @@ void Plater::suppress_background_process(const bool stop_background_process)
|
|||
void Plater::fix_through_netfabb(const int obj_idx, const int vol_idx/* = -1*/) { p->fix_through_netfabb(obj_idx, vol_idx); }
|
||||
|
||||
void Plater::update_object_menu() { p->update_object_menu(); }
|
||||
void Plater::show_action_buttons(const bool is_ready_to_slice) const { p->show_action_buttons(is_ready_to_slice); }
|
||||
void Plater::show_action_buttons(const bool ready_to_slice) const { p->show_action_buttons(ready_to_slice); }
|
||||
|
||||
void Plater::copy_selection_to_clipboard()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ public:
|
|||
void fix_through_netfabb(const int obj_idx, const int vol_idx = -1);
|
||||
void send_gcode();
|
||||
void eject_drive();
|
||||
void drive_ejected_callback();
|
||||
|
||||
void take_snapshot(const std::string &snapshot_name);
|
||||
void take_snapshot(const wxString &snapshot_name);
|
||||
|
|
|
|||
|
|
@ -851,7 +851,7 @@ Preset& PresetCollection::load_preset(const std::string &path, const std::string
|
|||
return preset;
|
||||
}
|
||||
|
||||
void PresetCollection::save_current_preset(const std::string &new_name)
|
||||
void PresetCollection::save_current_preset(const std::string &new_name, bool detach)
|
||||
{
|
||||
// 1) Find the preset with a new_name or create a new one,
|
||||
// initialize it with the edited config.
|
||||
|
|
@ -866,6 +866,13 @@ void PresetCollection::save_current_preset(const std::string &new_name)
|
|||
preset.config = std::move(m_edited_preset.config);
|
||||
// The newly saved preset will be activated -> make it visible.
|
||||
preset.is_visible = true;
|
||||
if (detach) {
|
||||
// Clear the link to the parent profile.
|
||||
preset.vendor = nullptr;
|
||||
preset.inherits().clear();
|
||||
preset.alias.clear();
|
||||
preset.renamed_from.clear();
|
||||
}
|
||||
} else {
|
||||
// Creating a new preset.
|
||||
Preset &preset = *m_presets.insert(it, m_edited_preset);
|
||||
|
|
@ -874,7 +881,12 @@ void PresetCollection::save_current_preset(const std::string &new_name)
|
|||
preset.name = new_name;
|
||||
preset.file = this->path_from_name(new_name);
|
||||
preset.vendor = nullptr;
|
||||
if (preset.is_system) {
|
||||
preset.alias.clear();
|
||||
preset.renamed_from.clear();
|
||||
if (detach) {
|
||||
// Clear the link to the parent profile.
|
||||
inherits.clear();
|
||||
} else if (preset.is_system) {
|
||||
// Inheriting from a system preset.
|
||||
inherits = /* preset.vendor->name + "/" + */ old_name;
|
||||
} else if (inherits.empty()) {
|
||||
|
|
@ -1061,6 +1073,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
|
|||
const ConfigOption *opt = active_printer.preset.config.option("nozzle_diameter");
|
||||
if (opt)
|
||||
config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast<const ConfigOptionFloats*>(opt)->values.size()));
|
||||
bool some_compatible = false;
|
||||
for (size_t idx_preset = m_num_default_presets; idx_preset < m_presets.size(); ++ idx_preset) {
|
||||
bool selected = idx_preset == m_idx_selected;
|
||||
Preset &preset_selected = m_presets[idx_preset];
|
||||
|
|
@ -1068,6 +1081,7 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
|
|||
const PresetWithVendorProfile this_preset_with_vendor_profile = this->get_preset_with_vendor_profile(preset_edited);
|
||||
bool was_compatible = preset_edited.is_compatible;
|
||||
preset_edited.is_compatible = is_compatible_with_printer(this_preset_with_vendor_profile, active_printer, &config);
|
||||
some_compatible |= preset_edited.is_compatible;
|
||||
if (active_print != nullptr)
|
||||
preset_edited.is_compatible &= is_compatible_with_print(this_preset_with_vendor_profile, *active_print, active_printer);
|
||||
if (! preset_edited.is_compatible && selected &&
|
||||
|
|
@ -1076,6 +1090,10 @@ size_t PresetCollection::update_compatible_internal(const PresetWithVendorProfil
|
|||
if (selected)
|
||||
preset_selected.is_compatible = preset_edited.is_compatible;
|
||||
}
|
||||
// Update visibility of the default profiles here if the defaults are suppressed, the current profile is not compatible and we don't want to select another compatible profile.
|
||||
if (m_idx_selected >= m_num_default_presets && m_default_suppressed)
|
||||
for (size_t i = 0; i < m_num_default_presets; ++ i)
|
||||
m_presets[i].is_visible = ! some_compatible;
|
||||
return m_idx_selected;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ public:
|
|||
// Save the preset under a new name. If the name is different from the old one,
|
||||
// a new preset is stored into the list of presets.
|
||||
// All presets are marked as not modified and the new preset is activated.
|
||||
void save_current_preset(const std::string &new_name);
|
||||
void save_current_preset(const std::string &new_name, bool detach = false);
|
||||
|
||||
// Delete the current preset, activate the first visible preset.
|
||||
// returns true if the preset was deleted successfully.
|
||||
|
|
|
|||
|
|
@ -703,7 +703,10 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
boost::nowide::ifstream ifs(path);
|
||||
boost::property_tree::read_ini(ifs, tree);
|
||||
} catch (const std::ifstream::failure &err) {
|
||||
throw std::runtime_error(std::string("The config file cannot be loaded: ") + path + "\n\tReason: " + err.what());
|
||||
throw std::runtime_error(std::string("The Config Bundle cannot be loaded: ") + path + "\n\tReason: " + err.what());
|
||||
} catch (const boost::property_tree::file_parser_error &err) {
|
||||
throw std::runtime_error((boost::format("Failed loading the Config Bundle \"%1%\": %2% at line %3%")
|
||||
% err.filename() % err.message() % err.line()).str());
|
||||
} catch (const std::runtime_error &err) {
|
||||
throw std::runtime_error(std::string("Failed loading the preset file: ") + path + "\n\tReason: " + err.what());
|
||||
}
|
||||
|
|
@ -1109,8 +1112,13 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
|
|||
const VendorProfile *vendor_profile = nullptr;
|
||||
if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) {
|
||||
auto vp = VendorProfile::from_ini(tree, path);
|
||||
if (vp.num_variants() == 0)
|
||||
if (vp.models.size() == 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer model defined.") % path;
|
||||
return 0;
|
||||
} else if (vp.num_variants() == 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer variant defined") % path;
|
||||
return 0;
|
||||
}
|
||||
vendor_profile = &this->vendors.insert({vp.id, vp}).first->second;
|
||||
}
|
||||
|
||||
|
|
@ -1599,21 +1607,23 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre
|
|||
|
||||
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
|
||||
// set a bitmap height to m_bitmapLock->GetHeight()
|
||||
// Note, under OSX we should use a ScaledHeight because of Retina scale
|
||||
//
|
||||
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size.
|
||||
// But for some display scaling (for example 125% or 175%) normal_icon_width differs from icon width.
|
||||
// So:
|
||||
// for nonsystem presets set a width of empty bitmap to m_bitmapLock->GetWidth()
|
||||
// for compatible presets set a width of empty bitmap to m_bitmapIncompatible->GetWidth()
|
||||
//
|
||||
// Note, under OSX we should use a Scaled Height/Width because of Retina scale
|
||||
#ifdef __APPLE__
|
||||
const int icon_height = m_bitmapLock->GetScaledHeight();
|
||||
const int lock_icon_width = m_bitmapLock->GetScaledWidth();
|
||||
const int flag_icon_width = m_bitmapIncompatible->GetScaledWidth();
|
||||
#else
|
||||
const int icon_height = m_bitmapLock->GetHeight();
|
||||
#endif
|
||||
|
||||
/* To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size.
|
||||
* But for some display scaling (for example 125% or 175%) normal_icon_width differs from icon width.
|
||||
* So:
|
||||
* for nonsystem presets set a width of empty bitmap to m_bitmapLock->GetWidth()
|
||||
* for compatible presets set a width of empty bitmap to m_bitmapIncompatible->GetWidth()
|
||||
**/
|
||||
const int lock_icon_width = m_bitmapLock->GetWidth();
|
||||
const int flag_icon_width = m_bitmapIncompatible->GetWidth();
|
||||
#endif
|
||||
|
||||
wxString tooltip = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "RemovableDriveManager.hpp"
|
||||
#include <iostream>
|
||||
#include "boost/nowide/convert.hpp"
|
||||
#include <libslic3r/libslic3r.h>
|
||||
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#if _WIN32
|
||||
#include <windows.h>
|
||||
|
|
@ -9,11 +11,9 @@
|
|||
#include <shlwapi.h>
|
||||
|
||||
#include <Dbt.h>
|
||||
GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72,
|
||||
0x8a,0x6d,0xb5,0x4c,0x2b,0x4f,0xc8,0x35 };
|
||||
|
||||
#else
|
||||
//linux includes
|
||||
// unix, linux & OSX includes
|
||||
#include <errno.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -26,124 +26,173 @@ GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72,
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_REMOVABLE_DRIVE_EJECTED, RemovableDriveEjectEvent);
|
||||
wxDEFINE_EVENT(EVT_REMOVABLE_DRIVES_CHANGED, RemovableDrivesChangedEvent);
|
||||
|
||||
#if _WIN32
|
||||
/* currently not used, left for possible future use
|
||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
*/
|
||||
void RemovableDriveManager::search_for_drives()
|
||||
std::vector<DriveData> RemovableDriveManager::search_for_removable_drives() const
|
||||
{
|
||||
m_current_drives.clear();
|
||||
//get logical drives flags by letter in alphabetical order
|
||||
DWORD drives_mask = GetLogicalDrives();
|
||||
for (size_t i = 0; i < 26; i++)
|
||||
{
|
||||
if(drives_mask & (1 << i))
|
||||
{
|
||||
std::string path (1,(char)('A' + i));
|
||||
path+=":";
|
||||
UINT drive_type = GetDriveTypeA(path.c_str());
|
||||
DWORD drives_mask = ::GetLogicalDrives();
|
||||
|
||||
// Allocate the buffers before the loop.
|
||||
std::wstring volume_name;
|
||||
std::wstring file_system_name;
|
||||
// Iterate the Windows drives from 'A' to 'Z'
|
||||
std::vector<DriveData> current_drives;
|
||||
for (size_t i = 0; i < 26; ++ i)
|
||||
if (drives_mask & (1 << i)) {
|
||||
std::string path { char('A' + i), ':' };
|
||||
UINT drive_type = ::GetDriveTypeA(path.c_str());
|
||||
// DRIVE_REMOVABLE on W are sd cards and usb thumbnails (not usb harddrives)
|
||||
if (drive_type == DRIVE_REMOVABLE)
|
||||
{
|
||||
if (drive_type == DRIVE_REMOVABLE) {
|
||||
// get name of drive
|
||||
std::wstring wpath = boost::nowide::widen(path);
|
||||
std::wstring volume_name;
|
||||
volume_name.resize(1024);
|
||||
std::wstring file_system_name;
|
||||
file_system_name.resize(1024);
|
||||
LPWSTR lp_volume_name_buffer = new wchar_t;
|
||||
BOOL error = GetVolumeInformationW(wpath.c_str(), &volume_name[0], sizeof(volume_name), NULL, NULL, NULL, &file_system_name[0], sizeof(file_system_name));
|
||||
if(error != 0)
|
||||
{
|
||||
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
||||
if (file_system_name != L"")
|
||||
{
|
||||
volume_name.resize(MAX_PATH + 1);
|
||||
file_system_name.resize(MAX_PATH + 1);
|
||||
BOOL error = ::GetVolumeInformationW(wpath.c_str(), volume_name.data(), sizeof(volume_name), nullptr, nullptr, nullptr, file_system_name.data(), sizeof(file_system_name));
|
||||
if (error != 0) {
|
||||
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, NULL, NULL);
|
||||
if (free_space.QuadPart > 0)
|
||||
{
|
||||
::GetDiskFreeSpaceExA(path.c_str(), &free_space, nullptr, nullptr);
|
||||
if (free_space.QuadPart > 0) {
|
||||
path += "\\";
|
||||
m_current_drives.push_back(DriveData(boost::nowide::narrow(volume_name), path));
|
||||
current_drives.emplace_back(DriveData{ boost::nowide::narrow(volume_name), path });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return current_drives;
|
||||
}
|
||||
|
||||
// Called from UI therefore it blocks the UI thread.
|
||||
// It also blocks updates at the worker thread.
|
||||
// Win32 implementation.
|
||||
void RemovableDriveManager::eject_drive()
|
||||
{
|
||||
if (m_last_save_path.empty())
|
||||
return;
|
||||
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
auto it_drive_data = this->find_last_save_path_drive_data();
|
||||
if (it_drive_data != m_current_drives.end()) {
|
||||
// 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);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
std::cerr << "Ejecting " << mpath << " failed " << GetLastError() << " \n";
|
||||
return;
|
||||
}
|
||||
DWORD deviceControlRetVal(0);
|
||||
//these 3 commands should eject device safely but they dont, the device does disappear from file explorer but the "device was safely remove" notification doesnt trigger.
|
||||
//sd cards does trigger WM_DEVICECHANGE messege, usb drives dont
|
||||
DeviceIoControl(handle, FSCTL_LOCK_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
DeviceIoControl(handle, FSCTL_DISMOUNT_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
// some implemenatations also calls IOCTL_STORAGE_MEDIA_REMOVAL here but it returns error to me
|
||||
BOOL error = DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
if (error == 0) {
|
||||
CloseHandle(handle);
|
||||
BOOST_LOG_TRIVIAL(error) << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n";
|
||||
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)));
|
||||
m_current_drives.erase(it_drive_data);
|
||||
}
|
||||
}
|
||||
void RemovableDriveManager::eject_drive(const std::string &path)
|
||||
|
||||
std::string RemovableDriveManager::get_removable_drive_path(const std::string &path)
|
||||
{
|
||||
if(m_current_drives.empty())
|
||||
return;
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
if (m_current_drives.empty())
|
||||
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());
|
||||
for (const DriveData &drive_data : m_current_drives) {
|
||||
char drive = drive_data.path[0];
|
||||
if (drive == 'A' + letter)
|
||||
return path;
|
||||
}
|
||||
return m_current_drives.front().path;
|
||||
}
|
||||
|
||||
std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path)
|
||||
{
|
||||
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());
|
||||
for (const DriveData &drive_data : m_current_drives) {
|
||||
assert(! drive_data.path.empty());
|
||||
if (drive_data.path.front() == 'A' + letter)
|
||||
return drive_data.path;
|
||||
}
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
if ((*it).path == path)
|
||||
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)
|
||||
{
|
||||
// get handle to device
|
||||
std::string mpath = "\\\\.\\" + 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);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
std::cerr << "Ejecting " << mpath << " failed " << GetLastError() << " \n";
|
||||
return;
|
||||
}
|
||||
DWORD deviceControlRetVal(0);
|
||||
//these 3 commands should eject device safely but they dont, the device does disappear from file explorer but the "device was safely remove" notification doesnt trigger.
|
||||
//sd cards does trigger WM_DEVICECHANGE messege, usb drives dont
|
||||
|
||||
DeviceIoControl(handle, FSCTL_LOCK_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
DeviceIoControl(handle, FSCTL_DISMOUNT_VOLUME, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
// some implemenatations also calls IOCTL_STORAGE_MEDIA_REMOVAL here but it returns error to me
|
||||
BOOL error = DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, nullptr, 0, nullptr, 0, &deviceControlRetVal, nullptr);
|
||||
if (error == 0)
|
||||
{
|
||||
CloseHandle(handle);
|
||||
std::cerr << "Ejecting " << mpath << " failed " << deviceControlRetVal << " " << GetLastError() << " \n";
|
||||
return;
|
||||
}
|
||||
CloseHandle(handle);
|
||||
m_did_eject = true;
|
||||
m_current_drives.erase(it);
|
||||
m_ejected_path = m_last_save_path;
|
||||
m_ejected_name = m_last_save_name;
|
||||
break;
|
||||
RemovableDriveManager::get_instance().update(0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
||||
{
|
||||
if (m_current_drives.empty())
|
||||
return false;
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
std::string new_path = path.substr(0, found);
|
||||
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
char drive = (*it).path[0];
|
||||
if (drive == ('A' + letter))
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Send all other messages on to the default windows handler.
|
||||
lRet = DefWindowProc(hWnd, message, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||
{
|
||||
std::size_t found = path.find_last_of("\\");
|
||||
std::string new_path = path.substr(0, found);
|
||||
int letter = PathGetDriveNumberA(new_path.c_str());
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
char drive = (*it).path[0];
|
||||
if (drive == ('A' + letter))
|
||||
return (*it).path;
|
||||
}
|
||||
return "";
|
||||
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
|
||||
// currently not used, left for possible future use
|
||||
WNDCLASSEX wndClass;
|
||||
wndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||
|
|
@ -179,432 +228,288 @@ void RemovableDriveManager::register_window()
|
|||
}
|
||||
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
||||
UpdateWindow(hWnd);
|
||||
*/
|
||||
}
|
||||
/* currently not used, left for possible future use
|
||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
namespace search_for_drives_internal
|
||||
{
|
||||
// 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;
|
||||
|
||||
switch (message)
|
||||
static bool compare_filesystem_id(const std::string &path_a, const std::string &path_b)
|
||||
{
|
||||
case WM_CREATE:
|
||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;
|
||||
struct stat buf;
|
||||
stat(path_a.c_str() ,&buf);
|
||||
dev_t id_a = buf.st_dev;
|
||||
stat(path_b.c_str() ,&buf);
|
||||
dev_t id_b = buf.st_dev;
|
||||
return id_a == id_b;
|
||||
}
|
||||
|
||||
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:
|
||||
void inspect_file(const std::string &path, const std::string &parent_path, std::vector<DriveData> &out)
|
||||
{
|
||||
// here is the important
|
||||
if(wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||
{
|
||||
- RemovableDriveManager::get_instance().update(0, true);
|
||||
//confirms if the file is removable drive and adds it to vector
|
||||
|
||||
//if not same file system - could be removable drive
|
||||
if (! compare_filesystem_id(path, parent_path)) {
|
||||
//free space
|
||||
boost::filesystem::space_info si = boost::filesystem::space(path);
|
||||
if (si.available != 0) {
|
||||
//user id
|
||||
struct stat buf;
|
||||
stat(path.c_str(), &buf);
|
||||
uid_t uid = buf.st_uid;
|
||||
std::string username(std::getenv("USER"));
|
||||
struct passwd *pw = getpwuid(uid);
|
||||
if (pw != 0 && pw->pw_name == username)
|
||||
out.emplace_back(DriveData{ boost::filesystem::basename(boost::filesystem::path(path)), path });
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Send all other messages on to the default windows handler.
|
||||
lRet = DefWindowProc(hWnd, message, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
return lRet;
|
||||
|
||||
}
|
||||
*/
|
||||
#else
|
||||
void RemovableDriveManager::search_for_drives()
|
||||
{
|
||||
|
||||
m_current_drives.clear();
|
||||
|
||||
#if __APPLE__
|
||||
// if on macos obj-c class will enumerate
|
||||
if(m_rdmmm)
|
||||
{
|
||||
m_rdmmm->list_devices();
|
||||
}
|
||||
#else
|
||||
|
||||
static void search_path(const std::string &path, const std::string &parent_path, std::vector<DriveData> &out)
|
||||
{
|
||||
glob_t globbuf;
|
||||
globbuf.gl_offs = 2;
|
||||
int error = glob(path.c_str(), GLOB_TILDE, NULL, &globbuf);
|
||||
if (error == 0) {
|
||||
for (size_t i = 0; i < globbuf.gl_pathc; ++ i)
|
||||
inspect_file(globbuf.gl_pathv[i], parent_path, out);
|
||||
} else {
|
||||
//if error - path probably doesnt exists so function just exits
|
||||
//std::cout<<"glob error "<< error<< "\n";
|
||||
}
|
||||
globfree(&globbuf);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DriveData> RemovableDriveManager::search_for_removable_drives() const
|
||||
{
|
||||
std::vector<DriveData> current_drives;
|
||||
|
||||
#if __APPLE__
|
||||
|
||||
this->list_devices(current_drives);
|
||||
|
||||
#else
|
||||
|
||||
//search /media/* folder
|
||||
search_path("/media/*", "/media");
|
||||
search_for_drives_internal::search_path("/media/*", "/media", current_drives);
|
||||
|
||||
//search_path("/Volumes/*", "/Volumes");
|
||||
std::string path(std::getenv("USER"));
|
||||
std::string pp(path);
|
||||
|
||||
{
|
||||
//search /media/USERNAME/* folder
|
||||
pp = "/media/"+pp;
|
||||
path = "/media/" + path + "/*";
|
||||
search_path(path, pp);
|
||||
//search /media/USERNAME/* folder
|
||||
pp = "/media/"+pp;
|
||||
path = "/media/" + path + "/*";
|
||||
search_for_drives_internal::search_path(path, pp, current_drives);
|
||||
|
||||
//search /run/media/USERNAME/* folder
|
||||
path = "/run" + path;
|
||||
pp = "/run"+pp;
|
||||
search_path(path, pp);
|
||||
|
||||
}
|
||||
//search /run/media/USERNAME/* folder
|
||||
path = "/run" + path;
|
||||
pp = "/run"+pp;
|
||||
search_for_drives_internal::search_path(path, pp, current_drives);
|
||||
#endif
|
||||
}
|
||||
void RemovableDriveManager::search_path(const std::string &path,const std::string &parent_path)
|
||||
{
|
||||
glob_t globbuf;
|
||||
globbuf.gl_offs = 2;
|
||||
int error = glob(path.c_str(), GLOB_TILDE, NULL, &globbuf);
|
||||
if(error == 0)
|
||||
{
|
||||
for(size_t i = 0; i < globbuf.gl_pathc; i++)
|
||||
{
|
||||
inspect_file(globbuf.gl_pathv[i], parent_path);
|
||||
}
|
||||
}else
|
||||
{
|
||||
//if error - path probably doesnt exists so function just exits
|
||||
//std::cout<<"glob error "<< error<< "\n";
|
||||
}
|
||||
|
||||
globfree(&globbuf);
|
||||
}
|
||||
void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path)
|
||||
{
|
||||
//confirms if the file is removable drive and adds it to vector
|
||||
|
||||
//if not same file system - could be removable drive
|
||||
if(!compare_filesystem_id(path, parent_path))
|
||||
{
|
||||
//free space
|
||||
boost::filesystem::space_info si = boost::filesystem::space(path);
|
||||
if(si.available != 0)
|
||||
{
|
||||
//user id
|
||||
struct stat buf;
|
||||
stat(path.c_str(), &buf);
|
||||
uid_t uid = buf.st_uid;
|
||||
std::string username(std::getenv("USER"));
|
||||
struct passwd *pw = getpwuid(uid);
|
||||
if (pw != 0 && pw->pw_name == username)
|
||||
m_current_drives.push_back(DriveData(boost::filesystem::basename(boost::filesystem::path(path)), path));
|
||||
}
|
||||
|
||||
}
|
||||
return current_drives;
|
||||
}
|
||||
bool RemovableDriveManager::compare_filesystem_id(const std::string &path_a, const std::string &path_b)
|
||||
|
||||
// Called from UI therefore it blocks the UI thread.
|
||||
// It also blocks updates at the worker thread.
|
||||
// Unix & OSX implementation.
|
||||
void RemovableDriveManager::eject_drive()
|
||||
{
|
||||
struct stat buf;
|
||||
stat(path_a.c_str() ,&buf);
|
||||
dev_t id_a = buf.st_dev;
|
||||
stat(path_b.c_str() ,&buf);
|
||||
dev_t id_b = buf.st_dev;
|
||||
return id_a == id_b;
|
||||
}
|
||||
void RemovableDriveManager::eject_drive(const std::string &path)
|
||||
{
|
||||
if (m_current_drives.empty())
|
||||
if (m_last_save_path.empty())
|
||||
return;
|
||||
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
if((*it).path == path)
|
||||
{
|
||||
|
||||
std::string correct_path(path);
|
||||
for (size_t i = 0; i < correct_path.size(); ++i)
|
||||
{
|
||||
if(correct_path[i]==' ')
|
||||
{
|
||||
correct_path = correct_path.insert(i,1,'\\');
|
||||
i++;
|
||||
}
|
||||
}
|
||||
//std::cout<<"Ejecting "<<(*it).name<<" from "<< correct_path<<"\n";
|
||||
// there is no usable command in c++ so terminal command is used instead
|
||||
// but neither triggers "succesful safe removal messege"
|
||||
std::string command = "";
|
||||
#if __APPLE__
|
||||
//m_rdmmm->eject_device(path);
|
||||
command = "diskutil unmount ";
|
||||
#else
|
||||
command = "umount ";
|
||||
#endif
|
||||
command += correct_path;
|
||||
int err = system(command.c_str());
|
||||
if(err)
|
||||
{
|
||||
std::cerr<<"Ejecting failed\n";
|
||||
return;
|
||||
}
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
m_did_eject = true;
|
||||
m_current_drives.erase(it);
|
||||
m_ejected_path = m_last_save_path;
|
||||
m_ejected_name = m_last_save_name;
|
||||
break;
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
auto it_drive_data = this->find_last_save_path_drive_data();
|
||||
if (it_drive_data != m_current_drives.end()) {
|
||||
std::string correct_path(m_last_save_path);
|
||||
for (size_t i = 0; i < correct_path.size(); ++i)
|
||||
if (correct_path[i]==' ') {
|
||||
correct_path = correct_path.insert(i,1,'\\');
|
||||
++ i;
|
||||
}
|
||||
//std::cout<<"Ejecting "<<(*it).name<<" from "<< correct_path<<"\n";
|
||||
// there is no usable command in c++ so terminal command is used instead
|
||||
// but neither triggers "succesful safe removal messege"
|
||||
std::string command =
|
||||
#if __APPLE__
|
||||
//this->eject_device(m_last_save_path);
|
||||
"diskutil unmount ";
|
||||
#else
|
||||
"umount ";
|
||||
#endif
|
||||
command += correct_path;
|
||||
int err = system(command.c_str());
|
||||
if (err) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Ejecting " << m_last_save_path << " failed";
|
||||
return;
|
||||
}
|
||||
|
||||
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)));
|
||||
m_current_drives.erase(it_drive_data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
||||
std::string RemovableDriveManager::get_removable_drive_path(const std::string &path)
|
||||
{
|
||||
if (m_current_drives.empty())
|
||||
return false;
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
std::size_t found = path.find_last_of("/");
|
||||
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
if(compare_filesystem_id(new_path, (*it).path))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
for (const DriveData &data : m_current_drives)
|
||||
if (search_for_drives_internal::compare_filesystem_id(new_path, data.path))
|
||||
return path;
|
||||
return m_current_drives.empty() ? std::string() : m_current_drives.front().path;
|
||||
}
|
||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||
|
||||
std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path)
|
||||
{
|
||||
std::size_t found = path.find_last_of("/");
|
||||
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
||||
|
||||
// trim the filename
|
||||
found = new_path.find_last_of("/");
|
||||
new_path = new_path.substr(0, found);
|
||||
|
||||
//check if same filesystem
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
if (compare_filesystem_id(new_path, (*it).path))
|
||||
return (*it).path;
|
||||
}
|
||||
return "";
|
||||
// check if same filesystem
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
for (const DriveData &drive_data : m_current_drives)
|
||||
if (search_for_drives_internal::compare_filesystem_id(new_path, drive_data.path))
|
||||
return drive_data.path;
|
||||
return std::string();
|
||||
}
|
||||
#endif
|
||||
|
||||
RemovableDriveManager::RemovableDriveManager():
|
||||
m_drives_count(0),
|
||||
m_last_update(0),
|
||||
m_last_save_path(""),
|
||||
m_last_save_name(""),
|
||||
m_last_save_path_verified(false),
|
||||
m_is_writing(false),
|
||||
m_did_eject(false),
|
||||
m_plater_ready_to_slice(true),
|
||||
m_ejected_path(""),
|
||||
m_ejected_name("")
|
||||
#if __APPLE__
|
||||
, m_rdmmm(new RDMMMWrapper())
|
||||
#endif
|
||||
{}
|
||||
RemovableDriveManager::~RemovableDriveManager()
|
||||
void RemovableDriveManager::init(wxEvtHandler *callback_evt_handler)
|
||||
{
|
||||
#if __APPLE__
|
||||
delete m_rdmmm;
|
||||
#endif
|
||||
}
|
||||
void RemovableDriveManager::init()
|
||||
{
|
||||
//add_callback([](void) { RemovableDriveManager::get_instance().print(); });
|
||||
assert(! m_initialized);
|
||||
assert(m_callback_evt_handler == nullptr);
|
||||
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
m_initialized = true;
|
||||
m_callback_evt_handler = callback_evt_handler;
|
||||
|
||||
#if _WIN32
|
||||
//register_window();
|
||||
//this->register_window_msw();
|
||||
#elif __APPLE__
|
||||
m_rdmmm->register_window();
|
||||
this->register_window_osx();
|
||||
#endif
|
||||
update(0, true);
|
||||
}
|
||||
bool RemovableDriveManager::update(const long time,const bool check)
|
||||
{
|
||||
if(time != 0) //time = 0 is forced update
|
||||
{
|
||||
long diff = m_last_update - time;
|
||||
if(diff <= -2)
|
||||
{
|
||||
m_last_update = time;
|
||||
}else
|
||||
{
|
||||
return false; // return value shouldnt matter if update didnt run
|
||||
}
|
||||
}
|
||||
search_for_drives();
|
||||
if (m_drives_count != m_current_drives.size())
|
||||
{
|
||||
if (check)
|
||||
{
|
||||
check_and_notify();
|
||||
}
|
||||
m_drives_count = m_current_drives.size();
|
||||
}
|
||||
return !m_current_drives.empty();
|
||||
|
||||
#ifdef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#else // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
// Don't call update() manually, as the UI triggered APIs call this->update() anyways.
|
||||
m_thread = boost::thread((boost::bind(&RemovableDriveManager::thread_proc, this)));
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
}
|
||||
|
||||
bool RemovableDriveManager::is_drive_mounted(const std::string &path) const
|
||||
void RemovableDriveManager::shutdown()
|
||||
{
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
if ((*it).path == path)
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
if (m_thread.joinable()) {
|
||||
// Stop the worker thread, if running.
|
||||
{
|
||||
return true;
|
||||
// Notify the worker thread to cancel wait on detection polling.
|
||||
std::lock_guard<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_stop = true;
|
||||
}
|
||||
m_thread_stop_condition.notify_all();
|
||||
// Wait for the worker thread to stop.
|
||||
m_thread.join();
|
||||
m_stop = false;
|
||||
}
|
||||
return false;
|
||||
#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;
|
||||
}
|
||||
std::string RemovableDriveManager::get_drive_path()
|
||||
|
||||
bool RemovableDriveManager::set_and_verify_last_save_path(const std::string &path)
|
||||
{
|
||||
if (m_current_drives.size() == 0)
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
m_last_save_path = this->get_removable_drive_from_path(path);
|
||||
return ! m_last_save_path.empty();
|
||||
}
|
||||
|
||||
RemovableDriveManager::RemovableDrivesStatus RemovableDriveManager::status()
|
||||
{
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
this->update();
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
RemovableDriveManager::RemovableDrivesStatus out;
|
||||
{
|
||||
reset_last_save_path();
|
||||
return "";
|
||||
tbb::mutex::scoped_lock lock(m_drives_mutex);
|
||||
out.has_eject = this->find_last_save_path_drive_data() != m_current_drives.end();
|
||||
out.has_removable_drives = ! m_current_drives.empty();
|
||||
}
|
||||
if (m_last_save_path_verified)
|
||||
return m_last_save_path;
|
||||
return m_current_drives.back().path;
|
||||
if (! out.has_eject)
|
||||
m_last_save_path.clear();
|
||||
return out;
|
||||
}
|
||||
std::string RemovableDriveManager::get_last_save_path() const
|
||||
|
||||
// Update is called from thread_proc() and from most of the public methods on demand.
|
||||
void RemovableDriveManager::update()
|
||||
{
|
||||
if (!m_last_save_path_verified)
|
||||
return "";
|
||||
return m_last_save_path;
|
||||
}
|
||||
std::string RemovableDriveManager::get_last_save_name() const
|
||||
{
|
||||
return m_last_save_name;
|
||||
}
|
||||
std::vector<DriveData> RemovableDriveManager::get_all_drives() const
|
||||
{
|
||||
return m_current_drives;
|
||||
}
|
||||
void RemovableDriveManager::check_and_notify()
|
||||
{
|
||||
if(m_drive_count_changed_callback)
|
||||
{
|
||||
m_drive_count_changed_callback(m_plater_ready_to_slice);
|
||||
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));
|
||||
}
|
||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && !is_drive_mounted(m_last_save_path))
|
||||
{
|
||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||
m_current_drives = std::move(current_drives);
|
||||
}
|
||||
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
void RemovableDriveManager::thread_proc()
|
||||
{
|
||||
for (;;) {
|
||||
// Wait for 2 seconds before running the disk enumeration.
|
||||
// Cancellable.
|
||||
{
|
||||
(*it)();
|
||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(2), [this]{ return m_stop; });
|
||||
}
|
||||
if (m_stop)
|
||||
// Stop the worker thread.
|
||||
break;
|
||||
// Update m_current drives and send out update events.
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
void RemovableDriveManager::add_remove_callback(std::function<void()> callback)
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
std::vector<DriveData>::const_iterator RemovableDriveManager::find_last_save_path_drive_data() const
|
||||
{
|
||||
m_callbacks.push_back(callback);
|
||||
return Slic3r::binary_find_by_predicate(m_current_drives.begin(), m_current_drives.end(),
|
||||
[this](const DriveData &data){ return data.path < m_last_save_path; },
|
||||
[this](const DriveData &data){ return data.path == m_last_save_path; });
|
||||
}
|
||||
void RemovableDriveManager::erase_callbacks()
|
||||
{
|
||||
m_callbacks.clear();
|
||||
}
|
||||
void RemovableDriveManager::set_drive_count_changed_callback(std::function<void(const bool)> callback)
|
||||
{
|
||||
m_drive_count_changed_callback = callback;
|
||||
}
|
||||
void RemovableDriveManager::set_plater_ready_to_slice(bool b)
|
||||
{
|
||||
m_plater_ready_to_slice = b;
|
||||
}
|
||||
void RemovableDriveManager::set_last_save_path(const std::string& path)
|
||||
{
|
||||
if(m_last_save_path_verified)// if old path is on drive
|
||||
{
|
||||
if(get_drive_from_path(path) != "") //and new is too, rewrite the path
|
||||
{
|
||||
m_last_save_path_verified = false;
|
||||
m_last_save_path = path;
|
||||
}//else do nothing
|
||||
}else
|
||||
{
|
||||
m_last_save_path = path;
|
||||
}
|
||||
}
|
||||
void RemovableDriveManager::verify_last_save_path()
|
||||
{
|
||||
std::string last_drive = get_drive_from_path(m_last_save_path);
|
||||
if (last_drive != "")
|
||||
{
|
||||
m_last_save_path_verified = true;
|
||||
m_last_save_path = last_drive;
|
||||
m_last_save_name = get_drive_name(last_drive);
|
||||
}else
|
||||
{
|
||||
reset_last_save_path();
|
||||
}
|
||||
}
|
||||
std::string RemovableDriveManager::get_drive_name(const std::string& path) const
|
||||
{
|
||||
if (m_current_drives.size() == 0)
|
||||
return "";
|
||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||
{
|
||||
if ((*it).path == path)
|
||||
{
|
||||
return (*it).name;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
bool RemovableDriveManager::is_last_drive_removed()
|
||||
{
|
||||
if(!m_last_save_path_verified)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool r = !is_drive_mounted(m_last_save_path);
|
||||
if (r)
|
||||
{
|
||||
reset_last_save_path();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
bool RemovableDriveManager::is_last_drive_removed_with_update(const long time)
|
||||
{
|
||||
update(time, false);
|
||||
return is_last_drive_removed();
|
||||
}
|
||||
void RemovableDriveManager::reset_last_save_path()
|
||||
{
|
||||
m_last_save_path_verified = false;
|
||||
m_last_save_path = "";
|
||||
m_last_save_name = "";
|
||||
}
|
||||
void RemovableDriveManager::set_is_writing(const bool b)
|
||||
{
|
||||
m_is_writing = b;
|
||||
if (b)
|
||||
{
|
||||
m_did_eject = false;
|
||||
}
|
||||
}
|
||||
bool RemovableDriveManager::get_is_writing() const
|
||||
{
|
||||
return m_is_writing;
|
||||
}
|
||||
bool RemovableDriveManager::get_did_eject() const
|
||||
{
|
||||
return m_did_eject;
|
||||
}
|
||||
void RemovableDriveManager::set_did_eject(const bool b)
|
||||
{
|
||||
m_did_eject = b;
|
||||
}
|
||||
size_t RemovableDriveManager::get_drives_count() const
|
||||
{
|
||||
return m_current_drives.size();
|
||||
}
|
||||
std::string RemovableDriveManager::get_ejected_path() const
|
||||
{
|
||||
return m_ejected_path;
|
||||
}
|
||||
std::string RemovableDriveManager::get_ejected_name() const
|
||||
{
|
||||
return m_ejected_name;
|
||||
}
|
||||
}}//namespace Slicer::Gui
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
|||
|
|
@ -3,119 +3,127 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <tbb/mutex.h>
|
||||
#include <condition_variable>
|
||||
|
||||
// Custom wxWidget events
|
||||
#include "Event.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
#if __APPLE__
|
||||
class RDMMMWrapper;
|
||||
#endif
|
||||
|
||||
|
||||
struct DriveData
|
||||
{
|
||||
std::string name;
|
||||
std::string path;
|
||||
DriveData(std::string n, std::string p):name(n),path(p){}
|
||||
|
||||
void clear() {
|
||||
name.clear();
|
||||
path.clear();
|
||||
}
|
||||
bool empty() const {
|
||||
return path.empty();
|
||||
}
|
||||
};
|
||||
|
||||
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; }
|
||||
inline bool operator==(const DriveData &lhs, const DriveData &rhs) { return lhs.path == rhs.path; }
|
||||
|
||||
using RemovableDriveEjectEvent = Event<DriveData>;
|
||||
wxDECLARE_EVENT(EVT_REMOVABLE_DRIVE_EJECTED, RemovableDriveEjectEvent);
|
||||
|
||||
using RemovableDrivesChangedEvent = SimpleEvent;
|
||||
wxDECLARE_EVENT(EVT_REMOVABLE_DRIVES_CHANGED, RemovableDrivesChangedEvent);
|
||||
|
||||
#if __APPLE__
|
||||
// Callbacks on device plug / unplug work reliably on OSX.
|
||||
#define REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
#endif // __APPLE__
|
||||
|
||||
class RemovableDriveManager
|
||||
{
|
||||
#if __APPLE__
|
||||
friend class RDMMMWrapper;
|
||||
#endif
|
||||
public:
|
||||
static RemovableDriveManager& get_instance()
|
||||
{
|
||||
static RemovableDriveManager instance;
|
||||
return instance;
|
||||
}
|
||||
RemovableDriveManager() = default;
|
||||
RemovableDriveManager(RemovableDriveManager const&) = delete;
|
||||
void operator=(RemovableDriveManager const&) = delete;
|
||||
~RemovableDriveManager();
|
||||
//call only once. on apple register for unmnount callbacks. on windows register for device notification is prepared but not called (eject usb drive on widnows doesnt trigger the callback, sdc ard does), also enumerates devices for first time so init shoud be called on linux too.
|
||||
void init();
|
||||
//update() searches for removable devices, returns false if empty. /time = 0 is forced update, time expects wxGetLocalTime()
|
||||
bool update(const long time = 0,const bool check = false);
|
||||
bool is_drive_mounted(const std::string &path) const;
|
||||
void eject_drive(const std::string &path);
|
||||
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
||||
std::string get_last_save_path() const;
|
||||
std::string get_last_save_name() const;
|
||||
//returns path to last drive which was used, if none was used, returns empty string
|
||||
std::string get_drive_path();
|
||||
std::vector<DriveData> get_all_drives() const;
|
||||
bool is_path_on_removable_drive(const std::string &path);
|
||||
// callback will notify only if device with last save path was removed
|
||||
void add_remove_callback(std::function<void()> callback);
|
||||
// erases all remove callbacks added by add_remove_callback()
|
||||
void erase_callbacks();
|
||||
//drive_count_changed callback is called on every added or removed device
|
||||
void set_drive_count_changed_callback(std::function<void(const bool)> callback);
|
||||
//thi serves to set correct value for drive_count_changed callback
|
||||
void set_plater_ready_to_slice(bool b);
|
||||
// marks one of the eveices in vector as last used
|
||||
void set_last_save_path(const std::string &path);
|
||||
void verify_last_save_path();
|
||||
bool is_last_drive_removed();
|
||||
// param as update()
|
||||
bool is_last_drive_removed_with_update(const long time = 0);
|
||||
void set_is_writing(const bool b);
|
||||
bool get_is_writing() const;
|
||||
bool get_did_eject() const;
|
||||
void set_did_eject(const bool b);
|
||||
std::string get_drive_name(const std::string& path) const;
|
||||
size_t get_drives_count() const;
|
||||
std::string get_ejected_path() const;
|
||||
std::string get_ejected_name() const;
|
||||
private:
|
||||
RemovableDriveManager();
|
||||
void search_for_drives();
|
||||
//triggers callbacks if last used drive was removed
|
||||
void check_and_notify();
|
||||
//returns drive path (same as path in DriveData) if exists otherwise empty string ""
|
||||
std::string get_drive_from_path(const std::string& path);
|
||||
void reset_last_save_path();
|
||||
~RemovableDriveManager() { assert(! m_initialized); }
|
||||
|
||||
// Start the background thread and register this window as a target for update events.
|
||||
// Register for OSX notifications.
|
||||
void init(wxEvtHandler *callback_evt_handler);
|
||||
// Stop the background thread of the removable drive manager, so that no new updates will be sent out.
|
||||
// Deregister OSX notifications.
|
||||
void shutdown();
|
||||
|
||||
// Returns path to a removable media if it exists, prefering the input path.
|
||||
std::string get_removable_drive_path(const std::string &path);
|
||||
bool is_path_on_removable_drive(const std::string &path) { return this->get_removable_drive_path(path) == path; }
|
||||
|
||||
// Verify whether the path provided is on removable media. If so, save the path for further eject and return true, otherwise return false.
|
||||
bool set_and_verify_last_save_path(const std::string &path);
|
||||
// Eject drive of a file set by set_and_verify_last_save_path().
|
||||
// On Unix / OSX, the function blocks and sends out the EVT_REMOVABLE_DRIVE_EJECTED event on success.
|
||||
// On Windows, the function does not block, and the eject is detected in the background thread.
|
||||
void eject_drive();
|
||||
|
||||
struct RemovableDrivesStatus {
|
||||
bool has_removable_drives { false };
|
||||
bool has_eject { false };
|
||||
};
|
||||
RemovableDrivesStatus status();
|
||||
|
||||
// Enumerates current drives and sends out wxWidget events on change or eject.
|
||||
// Called by each public method, by the background thread and from RemovableDriveManagerMM::on_device_unmount OSX notification handler.
|
||||
// Not to be called manually.
|
||||
// Public to be accessible from RemovableDriveManagerMM::on_device_unmount OSX notification handler.
|
||||
// It would be better to make this method private and friend to RemovableDriveManagerMM, but RemovableDriveManagerMM is an ObjectiveC class.
|
||||
void update();
|
||||
|
||||
private:
|
||||
bool m_initialized { false };
|
||||
wxEvtHandler* m_callback_evt_handler { nullptr };
|
||||
|
||||
#ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
// Worker thread, worker thread synchronization and callbacks to the UI thread.
|
||||
void thread_proc();
|
||||
boost::thread m_thread;
|
||||
std::condition_variable m_thread_stop_condition;
|
||||
mutable std::mutex m_thread_stop_mutex;
|
||||
bool m_stop { false };
|
||||
#endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
|
||||
|
||||
// Called from update() to enumerate removable drives.
|
||||
std::vector<DriveData> search_for_removable_drives() const;
|
||||
|
||||
// m_current_drives is guarded by m_drives_mutex
|
||||
// sorted ascending by path
|
||||
std::vector<DriveData> m_current_drives;
|
||||
mutable tbb::mutex m_drives_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);
|
||||
// Returns iterator to a drive in m_current_drives with path equal to m_last_save_path or end().
|
||||
std::vector<DriveData>::const_iterator find_last_save_path_drive_data() const;
|
||||
// Set with set_and_verify_last_save_path() to a removable drive path to be ejected.
|
||||
std::string m_last_save_path;
|
||||
|
||||
std::vector<DriveData> m_current_drives;
|
||||
std::vector<std::function<void()>> m_callbacks;
|
||||
std::function<void(const bool)> m_drive_count_changed_callback;
|
||||
size_t m_drives_count;
|
||||
long m_last_update;
|
||||
std::string m_last_save_path;
|
||||
bool m_last_save_path_verified;
|
||||
std::string m_last_save_name;
|
||||
bool m_is_writing;//on device
|
||||
bool m_did_eject;
|
||||
bool m_plater_ready_to_slice;
|
||||
std::string m_ejected_path;
|
||||
std::string m_ejected_name;
|
||||
#if _WIN32
|
||||
//registers for notifications by creating invisible window
|
||||
void register_window();
|
||||
#else
|
||||
#if __APPLE__
|
||||
RDMMMWrapper * m_rdmmm;
|
||||
#endif
|
||||
void search_path(const std::string &path, const std::string &parent_path);
|
||||
bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
|
||||
void inspect_file(const std::string &path, const std::string &parent_path);
|
||||
#endif
|
||||
};
|
||||
// apple wrapper for RemovableDriveManagerMM which searches for drives and/or ejects them
|
||||
#if __APPLE__
|
||||
class RDMMMWrapper
|
||||
{
|
||||
public:
|
||||
RDMMMWrapper();
|
||||
~RDMMMWrapper();
|
||||
void register_window();
|
||||
void list_devices();
|
||||
//void register_window_msw();
|
||||
#elif __APPLE__
|
||||
void register_window_osx();
|
||||
void unregister_window_osx();
|
||||
void list_devices(std::vector<DriveData> &out) const;
|
||||
// not used as of now
|
||||
void eject_device(const std::string &path);
|
||||
void log(const std::string &msg);
|
||||
protected:
|
||||
void *m_imp;
|
||||
//friend void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path);
|
||||
// Opaque pointer to RemovableDriveManagerMM
|
||||
void *m_impl_osx;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
}}
|
||||
#endif
|
||||
|
||||
}}
|
||||
|
||||
#endif // slic3r_GUI_RemovableDriveManager_hpp_
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#import "RemovableDriveManager.hpp"
|
||||
#import "RemovableDriveManagerMM.h"
|
||||
#import "GUI_App.hpp"
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <DiskArbitration/DiskArbitration.h>
|
||||
|
||||
|
|
@ -10,22 +11,23 @@
|
|||
-(instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if(self)
|
||||
{
|
||||
}
|
||||
//if(self){}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) on_device_unmount: (NSNotification*) notification
|
||||
{
|
||||
NSLog(@"on device change");
|
||||
Slic3r::GUI::RemovableDriveManager::get_instance().update(0,true);
|
||||
//NSLog(@"on device change");
|
||||
Slic3r::GUI::wxGetApp().removable_drive_manager()->update();
|
||||
}
|
||||
|
||||
-(void) add_unmount_observer
|
||||
{
|
||||
NSLog(@"add unmount observer");
|
||||
//NSLog(@"add unmount observer");
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidMountNotification object:nil];
|
||||
}
|
||||
|
||||
-(NSArray*) list_dev
|
||||
{
|
||||
// DEPRICATED:
|
||||
|
|
@ -40,118 +42,99 @@
|
|||
DADiskRef disk;
|
||||
DASessionRef session;
|
||||
CFDictionaryRef descDict;
|
||||
session = DASessionCreate(NULL);
|
||||
if (session == NULL) {
|
||||
session = DASessionCreate(nullptr);
|
||||
if (session == nullptr)
|
||||
err = EINVAL;
|
||||
}
|
||||
if (err == 0) {
|
||||
disk = DADiskCreateFromVolumePath(NULL,session,(CFURLRef)volURL);
|
||||
if (session == NULL) {
|
||||
disk = DADiskCreateFromVolumePath(nullptr,session,(CFURLRef)volURL);
|
||||
if (session == nullptr)
|
||||
err = EINVAL;
|
||||
}
|
||||
}
|
||||
if (err == 0) {
|
||||
descDict = DADiskCopyDescription(disk);
|
||||
if (descDict == NULL) {
|
||||
if (descDict == nullptr)
|
||||
err = EINVAL;
|
||||
}
|
||||
}
|
||||
if (err == 0) {
|
||||
CFTypeRef mediaEjectableKey = CFDictionaryGetValue(descDict,kDADiskDescriptionMediaEjectableKey);
|
||||
BOOL ejectable = [mediaEjectableKey boolValue];
|
||||
CFTypeRef deviceProtocolName = CFDictionaryGetValue(descDict,kDADiskDescriptionDeviceProtocolKey);
|
||||
CFTypeRef deviceModelKey = CFDictionaryGetValue(descDict, kDADiskDescriptionDeviceModelKey);
|
||||
if (mediaEjectableKey != NULL)
|
||||
{
|
||||
if (mediaEjectableKey != nullptr) {
|
||||
BOOL op = ejectable && (CFEqual(deviceProtocolName, CFSTR("USB")) || CFEqual(deviceModelKey, CFSTR("SD Card Reader")));
|
||||
//!CFEqual(deviceModelKey, CFSTR("Disk Image"));
|
||||
//
|
||||
if (op) {
|
||||
if (op)
|
||||
[result addObject:volURL.path];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (descDict != NULL) {
|
||||
if (descDict != nullptr)
|
||||
CFRelease(descDict);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//this eject drive is not used now
|
||||
-(void)eject_drive:(NSString *)path
|
||||
{
|
||||
DADiskRef disk;
|
||||
DASessionRef session;
|
||||
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
||||
int err = 0;
|
||||
session = DASessionCreate(NULL);
|
||||
if (session == NULL) {
|
||||
session = DASessionCreate(nullptr);
|
||||
if (session == nullptr)
|
||||
err = EINVAL;
|
||||
}
|
||||
if (err == 0) {
|
||||
disk = DADiskCreateFromVolumePath(NULL,session,(CFURLRef)url);
|
||||
}
|
||||
if (err == 0)
|
||||
disk = DADiskCreateFromVolumePath(nullptr,session,(CFURLRef)url);
|
||||
if( err == 0)
|
||||
{
|
||||
DADiskUnmount(disk, kDADiskUnmountOptionDefault,
|
||||
NULL, NULL);
|
||||
}
|
||||
if (disk != NULL) {
|
||||
DADiskUnmount(disk, kDADiskUnmountOptionDefault, nullptr, nullptr);
|
||||
if (disk != nullptr)
|
||||
CFRelease(disk);
|
||||
}
|
||||
if (session != NULL) {
|
||||
if (session != nullptr)
|
||||
CFRelease(session);
|
||||
}
|
||||
}
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
RDMMMWrapper::RDMMMWrapper():m_imp(nullptr){
|
||||
m_imp = [[RemovableDriveManagerMM alloc] init];
|
||||
}
|
||||
RDMMMWrapper::~RDMMMWrapper()
|
||||
{
|
||||
if(m_imp)
|
||||
{
|
||||
[m_imp release];
|
||||
}
|
||||
}
|
||||
void RDMMMWrapper::register_window()
|
||||
{
|
||||
if(m_imp)
|
||||
{
|
||||
[m_imp add_unmount_observer];
|
||||
}
|
||||
}
|
||||
void RDMMMWrapper::list_devices()
|
||||
{
|
||||
if(m_imp)
|
||||
{
|
||||
NSArray* devices = [m_imp list_dev];
|
||||
for (NSString* volumePath in devices)
|
||||
{
|
||||
NSLog(@"%@", volumePath);
|
||||
Slic3r::GUI::RemovableDriveManager::get_instance().inspect_file(std::string([volumePath UTF8String]), "/Volumes");
|
||||
}
|
||||
}
|
||||
}
|
||||
void RDMMMWrapper::log(const std::string &msg)
|
||||
{
|
||||
NSLog(@"%s", msg.c_str());
|
||||
}
|
||||
void RDMMMWrapper::eject_device(const std::string &path)
|
||||
{
|
||||
if(m_imp)
|
||||
{
|
||||
NSString * pth = [NSString stringWithCString:path.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
[m_imp eject_drive:pth];
|
||||
}
|
||||
}
|
||||
}}//namespace Slicer::GUI
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
void RemovableDriveManager::register_window_osx()
|
||||
{
|
||||
assert(m_impl_osx == nullptr);
|
||||
m_impl_osx = [[RemovableDriveManagerMM alloc] init];
|
||||
if (m_impl_osx)
|
||||
[m_impl_osx add_unmount_observer];
|
||||
}
|
||||
|
||||
void RemovableDriveManager::unregister_window_osx()
|
||||
{
|
||||
if (m_impl_osx)
|
||||
[m_impl_osx release];
|
||||
}
|
||||
|
||||
namespace search_for_drives_internal
|
||||
{
|
||||
void inspect_file(const std::string &path, const std::string &parent_path, std::vector<DriveData> &out);
|
||||
}
|
||||
|
||||
void RemovableDriveManager::list_devices(std::vector<DriveData> &out) const
|
||||
{
|
||||
assert(m_impl_osx != nullptr);
|
||||
if (m_impl_osx) {
|
||||
NSArray* devices = [m_impl_osx list_dev];
|
||||
for (NSString* volumePath in devices)
|
||||
search_for_drives_internal::inspect_file(std::string([volumePath UTF8String]), "/Volumes", out);
|
||||
}
|
||||
}
|
||||
|
||||
// not used as of now
|
||||
void RemovableDriveManager::eject_device(const std::string &path)
|
||||
{
|
||||
assert(m_impl_osx != nullptr);
|
||||
if (m_impl_osx) {
|
||||
NSString * pth = [NSString stringWithCString:path.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
[m_impl_osx eject_drive:pth];
|
||||
}
|
||||
}
|
||||
|
||||
}}//namespace Slicer::GUI
|
||||
|
|
|
|||
|
|
@ -359,9 +359,10 @@ void Tab::update_labels_colour()
|
|||
color = &m_modified_label_clr;
|
||||
}
|
||||
if (opt.first == "bed_shape" || opt.first == "compatible_prints" || opt.first == "compatible_printers") {
|
||||
if (m_colored_Label != nullptr) {
|
||||
m_colored_Label->SetForegroundColour(*color);
|
||||
m_colored_Label->Refresh(true);
|
||||
wxStaticText* label = (m_colored_Labels.find(opt.first) == m_colored_Labels.end()) ? nullptr : m_colored_Labels.at(opt.first);
|
||||
if (label) {
|
||||
label->SetForegroundColour(*color);
|
||||
label->Refresh(true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -449,9 +450,10 @@ void Tab::update_changed_ui()
|
|||
tt = &m_tt_white_bullet;
|
||||
}
|
||||
if (opt.first == "bed_shape" || opt.first == "compatible_prints" || opt.first == "compatible_printers") {
|
||||
if (m_colored_Label != nullptr) {
|
||||
m_colored_Label->SetForegroundColour(*color);
|
||||
m_colored_Label->Refresh(true);
|
||||
wxStaticText* label = (m_colored_Labels.find(opt.first) == m_colored_Labels.end()) ? nullptr : m_colored_Labels.at(opt.first);
|
||||
if (label) {
|
||||
label->SetForegroundColour(*color);
|
||||
label->Refresh(true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -668,7 +670,8 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
|||
|
||||
}
|
||||
if (group->title == _("Profile dependencies")) {
|
||||
if (m_type != Slic3r::Preset::TYPE_PRINTER && (m_options_list["compatible_printers"] & os) == 0) {
|
||||
// "compatible_printers" option doesn't exists in Printer Settimgs Tab
|
||||
if (m_type != Preset::TYPE_PRINTER && (m_options_list["compatible_printers"] & os) == 0) {
|
||||
to_sys ? group->back_to_sys_value("compatible_printers") : group->back_to_initial_value("compatible_printers");
|
||||
load_key_value("compatible_printers", true/*some value*/, true);
|
||||
|
||||
|
|
@ -676,7 +679,8 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
|||
m_compatible_printers.checkbox->SetValue(is_empty);
|
||||
is_empty ? m_compatible_printers.btn->Disable() : m_compatible_printers.btn->Enable();
|
||||
}
|
||||
if ((m_type == Slic3r::Preset::TYPE_PRINT || m_type == Slic3r::Preset::TYPE_SLA_PRINT) && (m_options_list["compatible_prints"] & os) == 0) {
|
||||
// "compatible_prints" option exists only in Filament Settimgs and Materials Tabs
|
||||
if ((m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) && (m_options_list["compatible_prints"] & os) == 0) {
|
||||
to_sys ? group->back_to_sys_value("compatible_prints") : group->back_to_initial_value("compatible_prints");
|
||||
load_key_value("compatible_prints", true/*some value*/, true);
|
||||
|
||||
|
|
@ -754,10 +758,17 @@ void Tab::update_visibility()
|
|||
{
|
||||
Freeze(); // There is needed Freeze/Thaw to avoid a flashing after Show/Layout
|
||||
|
||||
// m_detach_preset_btn will be shown always after call page->update_visibility()
|
||||
// So let save a "show state" of m_detach_preset_btn before update_visibility
|
||||
bool was_shown = m_detach_preset_btn->IsShown();
|
||||
|
||||
for (auto page : m_pages)
|
||||
page->update_visibility(m_mode);
|
||||
update_page_tree_visibility();
|
||||
|
||||
// update visibility for detach_preset_btn
|
||||
m_detach_preset_btn->Show(was_shown);
|
||||
|
||||
Layout();
|
||||
Thaw();
|
||||
}
|
||||
|
|
@ -942,6 +953,52 @@ void Tab::on_presets_changed()
|
|||
m_dependent_tabs.clear();
|
||||
}
|
||||
|
||||
void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
|
||||
{
|
||||
auto description_line = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
|
||||
auto detach_preset_btn = [this](wxWindow* parent) {
|
||||
add_scaled_button(parent, &m_detach_preset_btn, "lock_open_sys", _(L("Detach from system preset")), wxBU_LEFT | wxBU_EXACTFIT);
|
||||
ScalableButton* btn = m_detach_preset_btn;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent&)
|
||||
{
|
||||
bool system = m_presets->get_edited_preset().is_system;
|
||||
bool dirty = m_presets->get_edited_preset().is_dirty;
|
||||
wxString msg_text = system ?
|
||||
_(L("A copy of the current system preset will be created, which will be detached from the system preset.")) :
|
||||
_(L("The current custom preset will be detached from the parent system preset."));
|
||||
if (dirty) {
|
||||
msg_text += "\n\n";
|
||||
msg_text += _(L("Modifications to the current profile will be saved."));
|
||||
}
|
||||
msg_text += "\n\n";
|
||||
msg_text += _(L("This action is not revertable.\nDo you want to proceed?"));
|
||||
|
||||
wxMessageDialog dialog(parent, msg_text, _(L("Detach preset")), wxICON_WARNING | wxYES_NO | wxCANCEL);
|
||||
if (dialog.ShowModal() == wxID_YES)
|
||||
save_preset(m_presets->get_edited_preset().is_system ? std::string() : m_presets->get_edited_preset().name, true);
|
||||
});
|
||||
|
||||
btn->Hide();
|
||||
|
||||
return sizer;
|
||||
};
|
||||
|
||||
Line line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
|
||||
line.append_widget(description_line);
|
||||
line.append_widget(detach_preset_btn);
|
||||
optgroup->append_line(line);
|
||||
}
|
||||
|
||||
void Tab::update_preset_description_line()
|
||||
{
|
||||
const Preset* parent = m_presets->get_selected_preset_parent();
|
||||
|
|
@ -1007,14 +1064,18 @@ void Tab::update_preset_description_line()
|
|||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!preset.alias.empty())
|
||||
{
|
||||
description_line += "\n\n\t" + _(L("full profile name")) + ": \n\t\t" + parent->name;
|
||||
description_line += "\n\t" + _(L("symbolic profile name")) + ": \n\t\t" + parent->alias;
|
||||
description_line += "\n\n\t" + _(L("full profile name")) + ": \n\t\t" + preset.name;
|
||||
description_line += "\n\t" + _(L("symbolic profile name")) + ": \n\t\t" + preset.alias;
|
||||
}
|
||||
}
|
||||
|
||||
m_parent_preset_description_line->SetText(description_line, false);
|
||||
|
||||
if (m_detach_preset_btn)
|
||||
m_detach_preset_btn->Show(parent && parent->is_system && !preset.is_default);
|
||||
Layout();
|
||||
}
|
||||
|
||||
void Tab::update_frequently_changed_parameters()
|
||||
|
|
@ -1256,21 +1317,16 @@ void TabPrint::build()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
line = optgroup->create_single_option_line("compatible_printers");
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_printers);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_printers_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
build_preset_description_line(optgroup.get());
|
||||
}
|
||||
|
||||
// Reload current config (aka presets->edited_preset->config) into the UI fields.
|
||||
|
|
@ -1546,31 +1602,23 @@ void TabFilament::build()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
|
||||
line = optgroup->create_single_option_line("compatible_printers");
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_printers);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_printers_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = optgroup->create_single_option_line("compatible_prints");
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
create_line_with_widget(optgroup.get(), "compatible_prints", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_prints);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_prints_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
build_preset_description_line(optgroup.get());
|
||||
}
|
||||
|
||||
// Reload current config (aka presets->edited_preset->config) into the UI fields.
|
||||
|
|
@ -1798,38 +1846,10 @@ void TabPrinter::build_fff()
|
|||
auto page = add_options_page(_(L("General")), "printer");
|
||||
auto optgroup = page->new_optgroup(_(L("Size and coordinates")));
|
||||
|
||||
Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" };
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
ScalableButton* btn;
|
||||
add_scaled_button(parent, &btn, "printer_white", " " + _(L("Set")) + " " + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
create_line_with_widget(optgroup.get(), "bed_shape", [this](wxWindow* parent) {
|
||||
return create_bed_shape_widget(parent);
|
||||
});
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
|
||||
{
|
||||
BedShapeDialog dlg(this);
|
||||
dlg.build_dialog(*m_config->option<ConfigOptionPoints>("bed_shape"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_texture"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_model"));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
const std::vector<Vec2d>& shape = dlg.get_shape();
|
||||
const std::string& custom_texture = dlg.get_custom_texture();
|
||||
const std::string& custom_model = dlg.get_custom_model();
|
||||
if (!shape.empty())
|
||||
{
|
||||
load_key_value("bed_shape", shape);
|
||||
load_key_value("bed_custom_texture", custom_texture);
|
||||
load_key_value("bed_custom_model", custom_model);
|
||||
update_changed_ui();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return sizer;
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
optgroup->append_single_option_line("max_print_height");
|
||||
optgroup->append_single_option_line("z_offset");
|
||||
|
||||
|
|
@ -2020,12 +2040,8 @@ void TabPrinter::build_fff()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
|
||||
build_preset_description_line(optgroup.get());
|
||||
|
||||
build_unregular_pages();
|
||||
|
||||
|
|
@ -2042,39 +2058,9 @@ void TabPrinter::build_sla()
|
|||
auto page = add_options_page(_(L("General")), "printer");
|
||||
auto optgroup = page->new_optgroup(_(L("Size and coordinates")));
|
||||
|
||||
Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" };
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
ScalableButton* btn;
|
||||
add_scaled_button(parent, &btn, "printer_white", " " + _(L("Set")) + " " + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
|
||||
{
|
||||
BedShapeDialog dlg(this);
|
||||
dlg.build_dialog(*m_config->option<ConfigOptionPoints>("bed_shape"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_texture"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_model"));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
const std::vector<Vec2d>& shape = dlg.get_shape();
|
||||
const std::string& custom_texture = dlg.get_custom_texture();
|
||||
const std::string& custom_model = dlg.get_custom_model();
|
||||
if (!shape.empty())
|
||||
{
|
||||
load_key_value("bed_shape", shape);
|
||||
load_key_value("bed_custom_texture", custom_texture);
|
||||
load_key_value("bed_custom_model", custom_model);
|
||||
update_changed_ui();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return sizer;
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
create_line_with_widget(optgroup.get(), "bed_shape", [this](wxWindow* parent) {
|
||||
return create_bed_shape_widget(parent);
|
||||
});
|
||||
optgroup->append_single_option_line("max_print_height");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Display")));
|
||||
|
|
@ -2082,7 +2068,7 @@ void TabPrinter::build_sla()
|
|||
optgroup->append_single_option_line("display_height");
|
||||
|
||||
auto option = optgroup->get_option("display_pixels_x");
|
||||
line = { _(option.opt.full_label), "" };
|
||||
Line line = { _(option.opt.full_label), "" };
|
||||
line.append_option(option);
|
||||
line.append_option(optgroup->get_option("display_pixels_y"));
|
||||
optgroup->append_line(line);
|
||||
|
|
@ -2136,12 +2122,8 @@ void TabPrinter::build_sla()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
|
||||
build_preset_description_line(optgroup.get());
|
||||
}
|
||||
|
||||
void TabPrinter::update_serial_ports()
|
||||
|
|
@ -2604,6 +2586,15 @@ void TabPrinter::update_fff()
|
|||
void TabPrinter::update_sla()
|
||||
{ ; }
|
||||
|
||||
void Tab::update_ui_items_related_on_parent_preset(const Preset* selected_preset_parent)
|
||||
{
|
||||
m_is_default_preset = selected_preset_parent != nullptr && selected_preset_parent->is_default;
|
||||
|
||||
m_bmp_non_system = selected_preset_parent ? &m_bmp_value_unlock : &m_bmp_white_bullet;
|
||||
m_ttg_non_system = selected_preset_parent ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns;
|
||||
m_tt_non_system = selected_preset_parent ? &m_tt_value_unlock : &m_ttg_white_bullet_ns;
|
||||
}
|
||||
|
||||
// Initialize the UI from the current preset
|
||||
void Tab::load_current_preset()
|
||||
{
|
||||
|
|
@ -2622,12 +2613,7 @@ void Tab::load_current_preset()
|
|||
// Reload preset pages with the new configuration values.
|
||||
reload_config();
|
||||
|
||||
const Preset* selected_preset_parent = m_presets->get_selected_preset_parent();
|
||||
m_is_default_preset = selected_preset_parent != nullptr && selected_preset_parent->is_default;
|
||||
|
||||
m_bmp_non_system = selected_preset_parent ? &m_bmp_value_unlock : &m_bmp_white_bullet;
|
||||
m_ttg_non_system = selected_preset_parent ? &m_ttg_value_unlock : &m_ttg_white_bullet_ns;
|
||||
m_tt_non_system = selected_preset_parent ? &m_tt_value_unlock : &m_ttg_white_bullet_ns;
|
||||
update_ui_items_related_on_parent_preset(m_presets->get_selected_preset_parent());
|
||||
|
||||
// m_undo_to_sys_btn->Enable(!preset.is_default);
|
||||
|
||||
|
|
@ -2779,7 +2765,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current)
|
|||
bool printer_tab = m_presets->type() == Preset::TYPE_PRINTER;
|
||||
bool canceled = false;
|
||||
bool technology_changed = false;
|
||||
m_dependent_tabs = {};
|
||||
m_dependent_tabs.clear();
|
||||
if (current_dirty && ! may_discard_current_dirty_preset()) {
|
||||
canceled = true;
|
||||
} else if (print_tab) {
|
||||
|
|
@ -2875,10 +2861,10 @@ void Tab::select_preset(std::string preset_name, bool delete_current)
|
|||
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||
// The following method should not discard changes of current print or filament presets on change of a printer profile,
|
||||
// if they are compatible with the current printer.
|
||||
auto update_compatible_type = [](bool technology_changed, bool on_page, bool show_incompatible_presets) {
|
||||
return technology_changed ? PresetSelectCompatibleType::Always :
|
||||
on_page ? PresetSelectCompatibleType::Never :
|
||||
(show_incompatible_presets ? PresetSelectCompatibleType::OnlyIfWasCompatible : PresetSelectCompatibleType::Always);
|
||||
auto update_compatible_type = [delete_current](bool technology_changed, bool on_page, bool show_incompatible_presets) {
|
||||
return (delete_current || technology_changed) ? PresetSelectCompatibleType::Always :
|
||||
on_page ? PresetSelectCompatibleType::Never :
|
||||
show_incompatible_presets ? PresetSelectCompatibleType::OnlyIfWasCompatible : PresetSelectCompatibleType::Always;
|
||||
};
|
||||
if (current_dirty || delete_current || print_tab || printer_tab)
|
||||
m_preset_bundle->update_compatible(
|
||||
|
|
@ -3033,18 +3019,20 @@ void Tab::OnKeyDown(wxKeyEvent& event)
|
|||
// and activates the new preset.
|
||||
// Wizard calls save_preset with a name "My Settings", otherwise no name is provided and this method
|
||||
// opens a Slic3r::GUI::SavePresetWindow dialog.
|
||||
void Tab::save_preset(std::string name /*= ""*/)
|
||||
void Tab::save_preset(std::string name /*= ""*/, bool detach)
|
||||
{
|
||||
// since buttons(and choices too) don't get focus on Mac, we set focus manually
|
||||
// to the treectrl so that the EVT_* events are fired for the input field having
|
||||
// focus currently.is there anything better than this ?
|
||||
//! m_treectrl->OnSetFocus();
|
||||
|
||||
std::string suffix = detach ? _utf8(L("Detached")) : _CTX_utf8(L_CONTEXT("Copy", "PresetName"), "PresetName");
|
||||
|
||||
if (name.empty()) {
|
||||
const Preset &preset = m_presets->get_selected_preset();
|
||||
auto default_name = preset.is_default ? "Untitled" :
|
||||
// preset.is_system ? (boost::format(_utf8(L("%1% - Copy"))) % preset.name).str() :
|
||||
preset.is_system ? (boost::format(_CTX_utf8(L_CONTEXT("%1% - Copy", "PresetName"), "PresetName")) % preset.name).str() :
|
||||
// preset.is_system ? (boost::format(_CTX_utf8(L_CONTEXT("%1% - Copy", "PresetName"), "PresetName")) % preset.name).str() :
|
||||
preset.is_system ? (boost::format(("%1% - %2%")) % preset.name % suffix).str() :
|
||||
preset.name;
|
||||
|
||||
bool have_extention = boost::iends_with(default_name, ".ini");
|
||||
|
|
@ -3094,8 +3082,9 @@ void Tab::save_preset(std::string name /*= ""*/)
|
|||
}
|
||||
|
||||
// Save the preset into Slic3r::data_dir / presets / section_name / preset_name.ini
|
||||
m_presets->save_current_preset(name);
|
||||
m_presets->save_current_preset(name, detach);
|
||||
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||
// If saving the preset changes compatibility with other presets, keep the now incompatible dependent presets selected, however with a "red flag" icon showing that they are no more compatible.
|
||||
m_preset_bundle->update_compatible(PresetSelectCompatibleType::Never);
|
||||
// Add the new item into the UI component, remove dirty flags and activate the saved item.
|
||||
update_tab_ui();
|
||||
|
|
@ -3106,6 +3095,11 @@ void Tab::save_preset(std::string name /*= ""*/)
|
|||
|
||||
if (m_type == Preset::TYPE_PRINTER)
|
||||
static_cast<TabPrinter*>(this)->m_initial_extruders_count = static_cast<TabPrinter*>(this)->m_extruders_count;
|
||||
|
||||
// Parent preset is "default" after detaching, so we should to update UI values, related on parent preset
|
||||
if (detach)
|
||||
update_ui_items_related_on_parent_preset(m_presets->get_selected_preset_parent());
|
||||
|
||||
update_changed_ui();
|
||||
|
||||
/* If filament preset is saved for multi-material printer preset,
|
||||
|
|
@ -3113,6 +3107,30 @@ void Tab::save_preset(std::string name /*= ""*/)
|
|||
* but in full_config a filament_colors option aren't.*/
|
||||
if (m_type == Preset::TYPE_FILAMENT && wxGetApp().extruders_edited_cnt() > 1)
|
||||
wxGetApp().plater()->force_filament_colors_update();
|
||||
|
||||
{
|
||||
// Profile compatiblity is updated first when the profile is saved.
|
||||
// Update profile selection combo boxes at the depending tabs to reflect modifications in profile compatibility.
|
||||
std::vector<Preset::Type> dependent;
|
||||
switch (m_type) {
|
||||
case Preset::TYPE_PRINT:
|
||||
dependent = { Preset::TYPE_FILAMENT };
|
||||
break;
|
||||
case Preset::TYPE_SLA_PRINT:
|
||||
dependent = { Preset::TYPE_SLA_MATERIAL };
|
||||
break;
|
||||
case Preset::TYPE_PRINTER:
|
||||
if (static_cast<const TabPrinter*>(this)->m_printer_technology == ptFFF)
|
||||
dependent = { Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
|
||||
else
|
||||
dependent = { Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (Preset::Type preset_type : dependent)
|
||||
wxGetApp().get_tab(preset_type)->update_tab_ui();
|
||||
}
|
||||
}
|
||||
|
||||
// Called for a currently selected preset.
|
||||
|
|
@ -3170,6 +3188,15 @@ void Tab::update_ui_from_settings()
|
|||
}
|
||||
}
|
||||
|
||||
void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget)
|
||||
{
|
||||
Line line = optgroup->create_single_option_line(opt_key);
|
||||
line.widget = widget;
|
||||
|
||||
m_colored_Labels[opt_key] = nullptr;
|
||||
optgroup->append_line(line, &m_colored_Labels[opt_key]);
|
||||
}
|
||||
|
||||
// Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer.
|
||||
wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps)
|
||||
{
|
||||
|
|
@ -3241,6 +3268,39 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
|
|||
return sizer;
|
||||
}
|
||||
|
||||
// Return a callback to create a TabPrinter widget to edit bed shape
|
||||
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
||||
{
|
||||
ScalableButton* btn;
|
||||
add_scaled_button(parent, &btn, "printer_white", " " + _(L("Set")) + " " + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
|
||||
{
|
||||
BedShapeDialog dlg(this);
|
||||
dlg.build_dialog(*m_config->option<ConfigOptionPoints>("bed_shape"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_texture"),
|
||||
*m_config->option<ConfigOptionString>("bed_custom_model"));
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
const std::vector<Vec2d>& shape = dlg.get_shape();
|
||||
const std::string& custom_texture = dlg.get_custom_texture();
|
||||
const std::string& custom_model = dlg.get_custom_model();
|
||||
if (!shape.empty())
|
||||
{
|
||||
load_key_value("bed_shape", shape);
|
||||
load_key_value("bed_custom_texture", custom_texture);
|
||||
load_key_value("bed_custom_model", custom_model);
|
||||
update_changed_ui();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
return sizer;
|
||||
}
|
||||
|
||||
void Tab::compatible_widget_reload(PresetDependencies &deps)
|
||||
{
|
||||
bool has_any = ! m_config->option<ConfigOptionStrings>(deps.key_list)->values.empty();
|
||||
|
|
@ -3416,7 +3476,7 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
|
|||
void SavePresetWindow::build(const wxString& title, const std::string& default_name, std::vector<std::string> &values)
|
||||
{
|
||||
// TRN Preset
|
||||
auto text = new wxStaticText(this, wxID_ANY, from_u8((boost::format(_utf8(L("Save %s as:"))) % title).str()),
|
||||
auto text = new wxStaticText(this, wxID_ANY, from_u8((boost::format(_utf8(L("Save %s as:"))) % into_u8(title)).str()),
|
||||
wxDefaultPosition, wxDefaultSize);
|
||||
m_combo = new wxComboBox(this, wxID_ANY, from_u8(default_name),
|
||||
wxDefaultPosition, wxDefaultSize, 0, 0, wxTE_PROCESS_ENTER);
|
||||
|
|
@ -3544,30 +3604,24 @@ void TabSLAMaterial::build()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
Line line = optgroup->create_single_option_line("compatible_printers");
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_printers);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_printers_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = optgroup->create_single_option_line("compatible_prints");
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
create_line_with_widget(optgroup.get(), "compatible_prints", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_prints);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_prints_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
build_preset_description_line(optgroup.get());
|
||||
}
|
||||
|
||||
// Reload current config (aka presets->edited_preset->config) into the UI fields.
|
||||
|
|
@ -3674,22 +3728,16 @@ void TabSLAPrint::build()
|
|||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench");
|
||||
optgroup = page->new_optgroup(_(L("Profile dependencies")));
|
||||
Line line = optgroup->create_single_option_line("compatible_printers");//Line { _(L("Compatible printers")), "" };
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_printers);
|
||||
};
|
||||
optgroup->append_line(line, &m_colored_Label);
|
||||
});
|
||||
|
||||
option = optgroup->get_option("compatible_printers_condition");
|
||||
option.opt.full_width = true;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
line = Line{ "", "" };
|
||||
line.full_width = 1;
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
return description_line_widget(parent, &m_parent_preset_description_line);
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
build_preset_description_line(optgroup.get());
|
||||
}
|
||||
|
||||
// Reload current config (aka presets->edited_preset->config) into the UI fields.
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ protected:
|
|||
bool m_disable_tree_sel_changed_event;
|
||||
bool m_show_incompatible_presets;
|
||||
|
||||
std::vector<Preset::Type> m_dependent_tabs = {};
|
||||
std::vector<Preset::Type> m_dependent_tabs;
|
||||
enum OptStatus { osSystemValue = 1, osInitValue = 2 };
|
||||
std::map<std::string, int> m_options_list;
|
||||
int m_opt_status_value = 0;
|
||||
|
|
@ -227,7 +227,12 @@ public:
|
|||
PresetCollection* m_presets;
|
||||
DynamicPrintConfig* m_config;
|
||||
ogStaticText* m_parent_preset_description_line;
|
||||
wxStaticText* m_colored_Label = nullptr;
|
||||
ScalableButton* m_detach_preset_btn = nullptr;
|
||||
|
||||
// map of option name -> wxStaticText (colored label, associated with option)
|
||||
// Used for options which don't have corresponded field
|
||||
std::map<std::string, wxStaticText*> m_colored_Labels;
|
||||
|
||||
// Counter for the updating (because of an update() function can have a recursive behavior):
|
||||
// 1. increase value from the very beginning of an update() function
|
||||
// 2. decrease value at the end of an update() function
|
||||
|
|
@ -253,6 +258,7 @@ public:
|
|||
const wxString& label = wxEmptyString,
|
||||
long style = wxBU_EXACTFIT | wxNO_BORDER);
|
||||
void add_scaled_bitmap(wxWindow* parent, ScalableBitmap& btn, const std::string& icon_name);
|
||||
void update_ui_items_related_on_parent_preset(const Preset* selected_preset_parent);
|
||||
void load_current_preset();
|
||||
void rebuild_page_tree();
|
||||
void update_page_tree_visibility();
|
||||
|
|
@ -264,7 +270,7 @@ public:
|
|||
void OnTreeSelChange(wxTreeEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
|
||||
void save_preset(std::string name = "");
|
||||
void save_preset(std::string name = std::string(), bool detach = false);
|
||||
void delete_preset();
|
||||
void toggle_show_hide_incompatible();
|
||||
void update_show_hide_incompatible_button();
|
||||
|
|
@ -306,11 +312,13 @@ public:
|
|||
void update_wiping_button_visibility();
|
||||
|
||||
protected:
|
||||
void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget);
|
||||
wxSizer* compatible_widget_create(wxWindow* parent, PresetDependencies &deps);
|
||||
void compatible_widget_reload(PresetDependencies &deps);
|
||||
void load_key_value(const std::string& opt_key, const boost::any& value, bool saved_value = false);
|
||||
|
||||
void on_presets_changed();
|
||||
void build_preset_description_line(ConfigOptionsGroup* optgroup);
|
||||
void update_preset_description_line();
|
||||
void update_frequently_changed_parameters();
|
||||
void fill_icon_descriptions();
|
||||
|
|
@ -406,6 +414,8 @@ public:
|
|||
void init_options_list() override;
|
||||
void msw_rescale() override;
|
||||
bool supports_printer_technology(const PrinterTechnology /* tech */) override { return true; }
|
||||
|
||||
wxSizer* create_bed_shape_widget(wxWindow* parent);
|
||||
};
|
||||
|
||||
class TabSLAMaterial : public Tab
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue