Open G-code viewer on drag & drop to the slicer window.

This commit is contained in:
Vojtech Bubnik 2020-10-06 08:50:42 +02:00
parent f47ad1fd94
commit 67d0072bc8

View File

@ -79,6 +79,7 @@
#include "../Utils/FixModelByWin10.hpp" #include "../Utils/FixModelByWin10.hpp"
#include "../Utils/UndoRedo.hpp" #include "../Utils/UndoRedo.hpp"
#include "../Utils/PresetUpdater.hpp" #include "../Utils/PresetUpdater.hpp"
#include "../Utils/Process.hpp"
#include "RemovableDriveManager.hpp" #include "RemovableDriveManager.hpp"
#include "InstanceCheck.hpp" #include "InstanceCheck.hpp"
#include "NotificationManager.hpp" #include "NotificationManager.hpp"
@ -1376,7 +1377,7 @@ private:
const std::regex PlaterDropTarget::pattern_drop(".*[.](stl|obj|amf|3mf|prusa)", std::regex::icase); const std::regex PlaterDropTarget::pattern_drop(".*[.](stl|obj|amf|3mf|prusa)", std::regex::icase);
#if ENABLE_GCODE_VIEWER #if ENABLE_GCODE_VIEWER
const std::regex PlaterDropTarget::pattern_gcode_drop(".*[.](gcode)", std::regex::icase); const std::regex PlaterDropTarget::pattern_gcode_drop(".*[.](gcode|g)", std::regex::icase);
#endif // ENABLE_GCODE_VIEWER #endif // ENABLE_GCODE_VIEWER
bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames)
@ -1415,9 +1416,14 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
fs::path path(into_path(filename)); fs::path path(into_path(filename));
if (std::regex_match(path.string(), pattern_drop)) if (std::regex_match(path.string(), pattern_drop))
paths.push_back(std::move(path)); paths.push_back(std::move(path));
else if (std::regex_match(path.string(), pattern_gcode_drop))
start_new_gcodeviewer(&filename);
else else
return false; return false;
} }
if (paths.empty())
// Likely all paths processed were gcodes, for which a G-code viewer instance has hopefully been started.
return false;
wxString snapshot_label; wxString snapshot_label;
assert(! paths.empty()); assert(! paths.empty());