SLAPrintOptions.pm 4.6 KB

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