Open dinther opened 3 years ago
Just to continue the discussion, a quick search yielded at least two C++ libraries that perform cross-platform file watching with the appropriate platform-specific API:
https://github.com/SpartanJ/efsw https://github.com/apetrone/simplefilewatcher
Of course another option would be to directly implement each OS' file system watching API in PrusaSlicer. Having used the FSEvents API on macOS before (and if I remember well), it's not much code if you know what you're watching (say, a specific file). At least on that platform. Inspiration could be taken from the mentioned libraries. There are also probably OS-specific open source libraries that simplify file watching and that could be integrated instead of re-implementing this in PrusaSlicer.
On the other side, polling, while not optimal, is not very resource intensive if performed less often for a single file or only a couple of files (say, once per second or every few seconds) and for performance's sake only the file modification date could be read. It would be better than nothing and would have quite literally no impact on the app's performance. No need to watch a whole tree of files recursively like an IDE needs to; we know exactly what files we're interested in.
Having PrusaSlicer pop a small banner (similar to the "slicing" and "eject" ones) with a suggestion to reload the model when it detects a change on disk would be great to avoid slicing an outdated model by accident.
Version
2.3.0
Operating system type + version
Windows 10 Pro
3D printer brand / version + firmware version (if known)
Prusa i3 MK3+ xyz !@#fras6 or something like that. ;-)
Behavior
in issue #5360 you implemented reload by pressing F5. This all works fine. However, it is not clear if the viewer monitors the file messages such as filesave. I am hand writing GCode in VS Code on one half of the screen while I watch the results in the Prusa GCode viewer on the other half. When I CTRL S (Save) in the VS Code editor I expect or wish to see the viewer automatically reload the file. Also when a reload takes place, the viewer should restore the last view set by the user so I don't have to keep zooming in.
open any valid gcode in VS Code, open it in the Prusa GCode viewer as well, modify the GCode in VS Code and save.
GCode viewer should know via windows messages that the file changed and re-load the gcode file while retaining the current view.
Nothing. currently I am forced to shift focus to the gcode viewer then press F5 and shift focus back to my code editor.
This is most likely a new feature request.
Motivation:
Hand-coding GCODE allows me and other makers to push boundaries of what is possible. In my case the next step up from manually writing gcode is to write software that generates gcode while skipping the 3D mesh phase. But I really need a more streamlined dev process. This feature would be an enormous help.
Example:
Have a look at openSCAD, you can choose to use their build-in editor but you can also edit the SCAD code in your own editor and the openSCAD program re-renders the code upon saving in VS Code.