mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
ENABLE_GCODE_VIEWER -> More general drag and drop for .gcode files
This commit is contained in:
parent
5a0e048079
commit
4ca026d4b6
3 changed files with 34 additions and 14 deletions
|
@ -1362,25 +1362,43 @@ const std::regex PlaterDropTarget::pattern_gcode_drop(".*[.](gcode)", std::regex
|
|||
bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
|
||||
{
|
||||
std::vector<fs::path> paths;
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
||||
for (const auto& filename : filenames) {
|
||||
fs::path path(into_path(filename));
|
||||
if (std::regex_match(path.string(), pattern_gcode_drop))
|
||||
paths.push_back(std::move(path));
|
||||
}
|
||||
|
||||
if (paths.size() > 1) {
|
||||
wxMessageDialog((wxWindow*)plater, _L("Only one gcode file at a time can be opened."), wxString(SLIC3R_APP_NAME) + " - " + _L("Open G-code file"), wxCLOSE | wxICON_WARNING | wxCENTRE).ShowModal();
|
||||
return false;
|
||||
}
|
||||
else if (paths.size() == 1) {
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
// gcode section
|
||||
for (const auto& filename : filenames) {
|
||||
fs::path path(into_path(filename));
|
||||
if (std::regex_match(path.string(), pattern_gcode_drop))
|
||||
paths.push_back(std::move(path));
|
||||
}
|
||||
|
||||
if (paths.size() > 1) {
|
||||
wxMessageDialog((wxWindow*)plater, _L("You can open only one .gcode file at a time."),
|
||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Open G-code file"), wxCLOSE | wxICON_WARNING | wxCENTRE).ShowModal();
|
||||
return false;
|
||||
}
|
||||
else if (paths.size() == 1) {
|
||||
if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) {
|
||||
plater->load_gcode(from_path(paths.front()));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (wxMessageDialog((wxWindow*)plater, _L("Do you want to switch to G-code preview ?"),
|
||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Open G-code file"), wxYES_NO | wxCANCEL | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
||||
|
||||
if (plater->model().objects.empty() ||
|
||||
wxMessageDialog((wxWindow*)plater, _L("Switching to G-code preview mode will remove all objects, continue?"),
|
||||
wxString(SLIC3R_APP_NAME) + " - " + _L("Switch to G-code preview mode"), wxYES_NO | wxCANCEL | wxICON_QUESTION | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_YES) {
|
||||
wxGetApp().mainframe->set_mode(MainFrame::EMode::GCodeViewer);
|
||||
plater->load_gcode(from_path(paths.front()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// model section
|
||||
for (const auto &filename : filenames) {
|
||||
fs::path path(into_path(filename));
|
||||
if (std::regex_match(path.string(), pattern_drop))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue