SLAPrintOptions.pm 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package Slic3r::GUI::SLAPrintOptions;
  2. use Wx qw(:dialog :id :misc :sizer :systemsettings wxTheApp);
  3. use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
  4. use base qw(Wx::Dialog Class::Accessor);
  5. __PACKAGE__->mk_accessors(qw(config));
  6. sub new {
  7. my ($class, $parent) = @_;
  8. my $self = $class->SUPER::new($parent, -1, "SLA/DLP Print", wxDefaultPosition, wxDefaultSize);
  9. $self->config(Slic3r::Config::SLAPrint->new);
  10. $self->config->apply_dynamic(wxTheApp->{mainframe}->{plater}->config);
  11. # Set some defaults
  12. $self->config->set('infill_extrusion_width', 0.5) if $self->config->infill_extrusion_width == 0;
  13. $self->config->set('perimeter_extrusion_width', 1) if $self->config->perimeter_extrusion_width == 0;
  14. my $sizer = Wx::BoxSizer->new(wxVERTICAL);
  15. my $new_optgroup = sub {
  16. my ($title) = @_;
  17. my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new(
  18. parent => $self,
  19. title => $title,
  20. config => $self->config,
  21. label_width => 200,
  22. );
  23. $sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  24. return $optgroup;
  25. };
  26. {
  27. my $optgroup = $new_optgroup->('Layers');
  28. $optgroup->append_single_option_line('layer_height');
  29. $optgroup->append_single_option_line('first_layer_height');
  30. }
  31. {
  32. my $optgroup = $new_optgroup->('Infill');
  33. $optgroup->append_single_option_line('fill_density');
  34. $optgroup->append_single_option_line('fill_pattern');
  35. {
  36. my $line = $optgroup->create_single_option_line('perimeter_extrusion_width');
  37. $line->label('Shell thickness');
  38. my $opt = $line->get_options->[0];
  39. $opt->sidetext('mm');
  40. $opt->tooltip('Thickness of the external shell (both horizontal and vertical).');
  41. $optgroup->append_line($line);
  42. }
  43. {
  44. my $line = $optgroup->create_single_option_line('infill_extrusion_width');
  45. $line->label('Infill thickness');
  46. my $opt = $line->get_options->[0];
  47. $opt->sidetext('mm');
  48. $opt->tooltip('Thickness of the infill lines.');
  49. $optgroup->append_line($line);
  50. }
  51. $optgroup->append_single_option_line('fill_angle');
  52. }
  53. {
  54. my $optgroup = $new_optgroup->('Raft');
  55. $optgroup->append_single_option_line('raft_layers');
  56. $optgroup->append_single_option_line('raft_offset');
  57. }
  58. {
  59. my $optgroup = $new_optgroup->('Support Material');
  60. $optgroup->append_single_option_line('support_material');
  61. {
  62. my $line = $optgroup->create_single_option_line('support_material_spacing');
  63. $line->label('Pillars spacing');
  64. my $opt = $line->get_options->[0];
  65. $opt->tooltip('Max spacing between support material pillars.');
  66. $optgroup->append_line($line);
  67. }
  68. {
  69. my $line = $optgroup->create_single_option_line('support_material_extrusion_width');
  70. $line->label('Pillars diameter');
  71. my $opt = $line->get_options->[0];
  72. $opt->sidetext('mm');
  73. $opt->tooltip('Diameter of the cylindrical support pillars.');
  74. $optgroup->append_line($line);
  75. }
  76. }
  77. my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
  78. EVT_BUTTON($self, wxID_OK, sub { $self->_accept });
  79. $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
  80. $self->SetSizer($sizer);
  81. $sizer->SetSizeHints($self);
  82. return $self;
  83. }
  84. sub _accept {
  85. my $self = shift;
  86. # validate config
  87. eval {
  88. die "Invalid shell thickness (must be greater than 0).\n"
  89. if $self->config->fill_density < 100 && $self->config->perimeter_extrusion_width == 0;
  90. die "Invalid infill thickness (must be greater than 0).\n"
  91. if $self->config->fill_density < 100 && $self->config->infill_extrusion_width == 0;
  92. };
  93. if ($@) {
  94. Slic3r::GUI::show_error($self, $@);
  95. return;
  96. }
  97. $self->EndModal(wxID_OK);
  98. $self->Close; # needed on Linux
  99. my $projector = Slic3r::GUI::Projector->new($self->GetParent);
  100. # this double invocation is needed for properly hiding the MainFrame
  101. $projector->Show;
  102. $projector->ShowModal;
  103. # TODO: diff the new config with the selected presets and prompt the user for
  104. # applying the changes to them.
  105. }
  106. 1;