GCode.xsp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. %module{Slic3r::XS};
  2. %{
  3. #include <xsinit.h>
  4. #include "libslic3r/GCode.hpp"
  5. #include "libslic3r/GCode/CoolingBuffer.hpp"
  6. #include "libslic3r/GCode/PreviewData.hpp"
  7. %}
  8. %name{Slic3r::GCode::CoolingBuffer} class CoolingBuffer {
  9. CoolingBuffer(GCode* gcode)
  10. %code{% RETVAL = new CoolingBuffer(*gcode); %};
  11. ~CoolingBuffer();
  12. Ref<GCode> gcodegen();
  13. std::string process_layer(std::string gcode, size_t layer_id);
  14. };
  15. %name{Slic3r::GCode} class GCode {
  16. GCode();
  17. ~GCode();
  18. void do_export(Print *print, const char *path)
  19. %code%{
  20. try {
  21. THIS->do_export(print, path);
  22. } catch (std::exception& e) {
  23. croak("%s\n", e.what());
  24. }
  25. %};
  26. void do_export_w_preview(Print *print, const char *path, GCodePreviewData *preview_data)
  27. %code%{
  28. try {
  29. THIS->do_export(print, path, preview_data);
  30. } catch (std::exception& e) {
  31. croak("%s\n", e.what());
  32. }
  33. %};
  34. Ref<Vec2d> origin()
  35. %code{% RETVAL = &(THIS->origin()); %};
  36. void set_origin(Vec2d* pointf)
  37. %code{% THIS->set_origin(*pointf); %};
  38. Ref<Point> last_pos()
  39. %code{% RETVAL = &(THIS->last_pos()); %};
  40. unsigned int layer_count() const;
  41. void set_layer_count(unsigned int value);
  42. void set_extruders(std::vector<unsigned int> extruders)
  43. %code{% THIS->writer().set_extruders(extruders); THIS->writer().set_extruder(0); %};
  44. void apply_print_config(StaticPrintConfig* print_config)
  45. %code{%
  46. if (const PrintConfig* config = dynamic_cast<PrintConfig*>(print_config)) {
  47. THIS->apply_print_config(*config);
  48. } else {
  49. CONFESS("A PrintConfig object was not supplied to apply_print_config()");
  50. }
  51. %};
  52. Ref<StaticPrintConfig> config()
  53. %code{% RETVAL = const_cast<StaticPrintConfig*>(static_cast<const StaticPrintConfig*>(static_cast<const PrintObjectConfig*>(&THIS->config()))); %};
  54. };
  55. %name{Slic3r::GCode::PreviewData} class GCodePreviewData {
  56. GCodePreviewData();
  57. ~GCodePreviewData();
  58. void reset();
  59. bool empty() const;
  60. void set_type(int type)
  61. %code%{
  62. if ((0 <= type) && (type < GCodePreviewData::Extrusion::Num_View_Types))
  63. THIS->extrusion.view_type = (GCodePreviewData::Extrusion::EViewType)type;
  64. %};
  65. int type() %code%{ RETVAL = (int)THIS->extrusion.view_type; %};
  66. void set_extrusion_flags(int flags)
  67. %code%{ THIS->extrusion.role_flags = (unsigned int)flags; %};
  68. void set_travel_visible(bool visible)
  69. %code%{ THIS->travel.is_visible = visible; %};
  70. void set_retractions_visible(bool visible)
  71. %code%{ THIS->retraction.is_visible = visible; %};
  72. void set_unretractions_visible(bool visible)
  73. %code%{ THIS->unretraction.is_visible = visible; %};
  74. void set_shells_visible(bool visible)
  75. %code%{ THIS->shell.is_visible = visible; %};
  76. void set_extrusion_paths_colors(std::vector<std::string> colors);
  77. };