diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 9c61fa7294..8555fb0155 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -192,6 +192,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/PresetHints.hpp ${LIBDIR}/slic3r/GUI/GUI.cpp ${LIBDIR}/slic3r/GUI/GUI.hpp + ${LIBDIR}/slic3r/GUI/GUI_ObjectParts.cpp + ${LIBDIR}/slic3r/GUI/GUI_ObjectParts.hpp ${LIBDIR}/slic3r/GUI/Tab.cpp ${LIBDIR}/slic3r/GUI/Tab.hpp ${LIBDIR}/slic3r/GUI/TabIface.cpp diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index d897b6d298..dec2c7d7cd 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -55,6 +55,7 @@ #include "PresetBundle.hpp" #include "UpdateDialogs.hpp" #include "FirmwareDialog.hpp" +#include "GUI_ObjectParts.hpp" #include "../Utils/PresetUpdater.hpp" #include "../Config/Snapshot.hpp" @@ -495,6 +496,27 @@ void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_languag add_config_menu(menu, event_preferences_changed, event_language_change); } +wxArrayString* open_model(wxWindow *parent){ + t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card(); + std::vector file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" }; + wxString MODEL_WILDCARD; + for (auto file_type : file_types) + MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|"; + + auto dlg_title = _(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")); + auto dialog = new wxFileDialog(parent /*? parent : GetTopWindow(g_wxMainFrame)*/, dlg_title, + g_AppConfig->get_last_dir(), "", + MODEL_WILDCARD, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST); + if (dialog->ShowModal() != wxID_OK) { + dialog->Destroy(); + return nullptr; + } + wxArrayString input_files; + dialog->GetPaths(input_files); + dialog->Destroy(); + return &input_files; +} + // This is called when closing the application, when loading a config file or when starting the config wizard // to notify the user whether he is aware that some preset changes will be lost. bool check_unsaved_changes() @@ -985,6 +1007,18 @@ wxBoxSizer* content_edit_object_buttons(wxWindow* win) m_objects_ctrl->Select(m_objects_model->AddChild(item, name)); }); + btn_load_modifier->Bind(wxEVT_BUTTON, [win](wxEvent&) + { + on_btn_load(win, true); +// auto item = m_objects_ctrl->GetSelection(); +// if (!item) return; +// if (m_objects_model->GetParent(item) != wxDataViewItem(0)) +// item = m_objects_model->GetParent(item); +// if (!item) return; +// wxString name = "Part"; +// m_objects_ctrl->Select(m_objects_model->AddChild(item, name)); + }); + btn_delete->Bind(wxEVT_BUTTON, [](wxEvent&) { auto item = m_objects_ctrl->GetSelection(); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 6e975f953a..22b41fb201 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -124,6 +124,8 @@ void set_label_clr_sys(const wxColour& clr); const wxFont& small_font(); const wxFont& bold_font(); +wxArrayString* open_model(wxWindow *parent); + extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_language_change); // This is called when closing the application, when loading a config file or when starting the config wizard diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp new file mode 100644 index 0000000000..a5abf2af60 --- /dev/null +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -0,0 +1,43 @@ +#include "GUI.hpp" +#include "GUI_ObjectParts.hpp" + +#include + +namespace Slic3r +{ +namespace GUI +{ +void on_btn_load(wxWindow* parent, bool is_modifier /*= false*/) +{ + auto input_files = open_model(parent); +// for(auto input_file : input_files) { +// my $model = eval{ Slic3r::Model->read_from_file($input_file) }; +// if ($@) { +// Slic3r::GUI::show_error($self, $@); +// next; +// } + +// foreach my $object(@{$model->objects}) { +// foreach my $volume(@{$object->volumes}) { +// my $new_volume = $self->{model_object}->add_volume($volume); +// $new_volume->set_modifier($is_modifier); +// $new_volume->set_name(basename($input_file)); +// +// # apply the same translation we applied to the object +// $new_volume->mesh->translate(@{$self->{model_object}->origin_translation}); +// +// # set a default extruder value, since user can't add it manually +// $new_volume->config->set_ifndef('extruder', 0); +// +// $self->{parts_changed} = 1; +// } +// } +// } + + parts_changed(); +} + +void parts_changed(){ ; } + +} //namespace GUI +} //namespace Slic3r \ No newline at end of file diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp new file mode 100644 index 0000000000..ffbda35bfa --- /dev/null +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -0,0 +1,12 @@ +#ifndef slic3r_GUI_ObjectParts_hpp_ +#define slic3r_GUI_ObjectParts_hpp_ + +namespace Slic3r +{ +namespace GUI +{ +void on_btn_load(wxWindow* parent, bool is_modifier = false); +void parts_changed(); +} //namespace GUI +} //namespace Slic3r +#endif //slic3r_GUI_ObjectParts_hpp_ \ No newline at end of file