Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenricoturri1966 <enricoturri@seznam.cz>2020-08-11 15:23:47 +0300
committerenricoturri1966 <enricoturri@seznam.cz>2020-08-11 15:23:47 +0300
commit5a0e04807965d8443da7793e2c6cacc461718a65 (patch)
tree4ec714e6dd0622048723abfbe598baa5ffd89df5 /src/slic3r
parent5882c121cc2aca8fc85f1106a624d85330b3b968 (diff)
ENABLE_GCODE_VIEWER -> Drag and drop .gcode files into gcode viewer
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/GUI/Plater.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index dac3f6fae..79f8b5ad5 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -1349,20 +1349,44 @@ private:
Plater *plater;
static const std::regex pattern_drop;
+#if ENABLE_GCODE_VIEWER
+ static const std::regex pattern_gcode_drop;
+#endif // ENABLE_GCODE_VIEWER
};
const std::regex PlaterDropTarget::pattern_drop(".*[.](stl|obj|amf|3mf|prusa)", std::regex::icase);
+#if ENABLE_GCODE_VIEWER
+const std::regex PlaterDropTarget::pattern_gcode_drop(".*[.](gcode)", std::regex::icase);
+#endif // ENABLE_GCODE_VIEWER
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) {
+ plater->load_gcode(from_path(paths.front()));
+ return true;
+ }
+ }
+#endif // ENABLE_GCODE_VIEWER
+
for (const auto &filename : filenames) {
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));
- } else {
+ else
return false;
- }
}
wxString snapshot_label;
@@ -1390,13 +1414,10 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi
// because right now the plater is not cleared, we set the project file (from the latest imported .3mf or .amf file)
// only if not set yet
// if res is empty no data has been loaded
- if (!res.empty() && plater->get_project_filename().empty())
- {
- for (std::vector<fs::path>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it)
- {
+ if (!res.empty() && plater->get_project_filename().empty()) {
+ for (std::vector<fs::path>::const_reverse_iterator it = paths.rbegin(); it != paths.rend(); ++it) {
std::string filename = (*it).filename().string();
- if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf"))
- {
+ if (boost::algorithm::iends_with(filename, ".3mf") || boost::algorithm::iends_with(filename, ".amf")) {
plater->set_project_filename(from_path(*it));
break;
}