partially implemented open_model as a free function in misc_ui. Initial dir and the file patterns are not implemented yet.

This commit is contained in:
Joseph Lenox 2018-05-01 22:50:10 -05:00
parent a998324962
commit 3b17844fba
2 changed files with 23 additions and 0 deletions

View File

@ -1,10 +1,12 @@
#include "misc_ui.hpp"
#include <wx/stdpaths.h>
#include <wx/msgdlg.h>
#include <wx/arrstr.h>
#include <exception>
#include <stdexcept>
namespace Slic3r { namespace GUI {
@ -110,5 +112,22 @@ sub show_error {
}
*/
std::vector<wxString> open_model(wxWindow* parent, const Settings& settings, wxWindow* top) {
auto dialog {new wxFileDialog((parent != nullptr ? parent : top), _("Choose one or more files") + wxString(" (STL/OBJ/AMF/3MF):"), ".", "",
"", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST)};
if (dialog->ShowModal() != wxID_OK) {
dialog->Destroy();
return std::vector<wxString>();
}
std::vector<wxString> tmp;
wxArrayString tmpout;
dialog->GetPaths(tmpout);
for (const auto& i : tmpout) {
tmp.push_back(i);
}
dialog->Destroy();
return tmp;
}
}} // namespace Slic3r::GUI

View File

@ -9,6 +9,8 @@
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include "Settings.hpp"
#include "Log.hpp"
/// Common static (that is, free-standing) functions, not part of an object hierarchy.
@ -98,6 +100,8 @@ sub CallAfter {
wxString decode_path(const wxString& in);
wxString encode_path(const wxString& in);
std::vector<wxString> open_model(wxWindow* parent, const Settings& settings, wxWindow* top);
}} // namespace Slic3r::GUI
#endif // MISC_UI_HPP