forked from slic3r/Slic3r
/
Tab.pm
1670 lines (1447 loc) · 64.7 KB
/
Tab.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# The "Expert" tab at the right of the main tabbed window.
# The "Expert" is enabled by File->Preferences dialog.
package Slic3r::GUI::Tab;
use strict;
use warnings;
use utf8;
use File::Basename qw(basename);
use List::Util qw(first);
use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :treectrl :window
:button wxTheApp);
use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN EVT_TREE_SEL_CHANGED);
use base qw(Wx::Panel Class::Accessor);
__PACKAGE__->mk_accessors(qw(current_preset));
sub new {
my $class = shift;
my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
# horizontal sizer
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
$self->{sizer}->SetSizeHints($self);
$self->SetSizer($self->{sizer});
# left vertical sizer
my $left_sizer = Wx::BoxSizer->new(wxVERTICAL);
$self->{sizer}->Add($left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
my $left_col_width = 150;
# preset chooser
{
# choice menu
$self->{presets_choice} = Wx::Choice->new($self, -1, wxDefaultPosition, [$left_col_width, -1], []);
$self->{presets_choice}->SetFont($Slic3r::GUI::small_font);
# buttons
$self->{btn_save_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new($Slic3r::var->("disk.png"), wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
$self->{btn_delete_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
$self->{btn_save_preset}->SetToolTipString("Save current " . lc($self->title));
$self->{btn_delete_preset}->SetToolTipString("Delete this preset");
$self->{btn_delete_preset}->Disable;
### These cause GTK warnings:
###my $box = Wx::StaticBox->new($self, -1, "Presets:", wxDefaultPosition, [$left_col_width, 50]);
###my $hsizer = Wx::StaticBoxSizer->new($box, wxHORIZONTAL);
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
$left_sizer->Add($hsizer, 0, wxEXPAND | wxBOTTOM, 5);
$hsizer->Add($self->{presets_choice}, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 3);
$hsizer->Add($self->{btn_save_preset}, 0, wxALIGN_CENTER_VERTICAL);
$hsizer->Add($self->{btn_delete_preset}, 0, wxALIGN_CENTER_VERTICAL);
}
# tree
$self->{treectrl} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [$left_col_width, -1], wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
$left_sizer->Add($self->{treectrl}, 1, wxEXPAND);
$self->{icons} = Wx::ImageList->new(16, 16, 1);
$self->{treectrl}->AssignImageList($self->{icons});
$self->{iconcount} = -1;
$self->{treectrl}->AddRoot("root");
$self->{pages} = [];
$self->{treectrl}->SetIndent(0);
$self->{disable_tree_sel_changed_event} = 0;
EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
return if $self->{disable_tree_sel_changed_event};
my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
or return;
$_->Hide for @{$self->{pages}};
$page->Show;
$self->{sizer}->Layout;
$self->Refresh;
});
EVT_KEY_DOWN($self->{treectrl}, sub {
my ($treectrl, $event) = @_;
if ($event->GetKeyCode == WXK_TAB) {
$treectrl->Navigate($event->ShiftDown ? &Wx::wxNavigateBackward : &Wx::wxNavigateForward);
} else {
$event->Skip;
}
});
EVT_CHOICE($parent, $self->{presets_choice}, sub {
$self->on_select_preset;
$self->_on_presets_changed;
});
EVT_BUTTON($self, $self->{btn_save_preset}, sub { $self->save_preset });
EVT_BUTTON($self, $self->{btn_delete_preset}, sub {
my $i = $self->current_preset;
return if $i == 0; # this shouldn't happen but let's trap it anyway
my $res = Wx::MessageDialog->new($self, "Are you sure you want to delete the selected preset?", 'Delete Preset', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION)->ShowModal;
return unless $res == wxID_YES;
if (-e $self->{presets}[$i]->file) {
unlink $self->{presets}[$i]->file;
}
splice @{$self->{presets}}, $i, 1;
$self->{presets_choice}->Delete($i);
$self->current_preset(undef);
$self->select_preset(0);
$self->_on_presets_changed;
});
# C++ instance DynamicPrintConfig
$self->{config} = Slic3r::Config->new;
# Initialize the DynamicPrintConfig by default keys/values.
# Possible %params keys: no_controller
$self->build(%params);
$self->update_tree;
$self->_update;
if ($self->hidden_options) {
$self->{config}->apply(Slic3r::Config->new_from_defaults($self->hidden_options));
}
return $self;
}
sub get_current_preset {
my $self = shift;
return $self->get_preset($self->current_preset);
}
sub get_preset {
my ($self, $i) = @_;
return $self->{presets}[$i];
}
sub save_preset {
my ($self, $name) = @_;
# since buttons (and choices too) don't get focus on Mac, we set focus manually
# to the treectrl so that the EVT_* events are fired for the input field having
# focus currently. is there anything better than this?
$self->{treectrl}->SetFocus;
if (!defined $name) {
my $preset = $self->get_current_preset;
my $default_name = $preset->default ? 'Untitled' : $preset->name;
$default_name =~ s/\.ini$//i;
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
title => lc($self->title),
default => $default_name,
values => [ map $_->name, grep !$_->default && !$_->external, @{$self->{presets}} ],
);
return unless $dlg->ShowModal == wxID_OK;
$name = $dlg->get_name;
}
$self->config->save(sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $self->name, $name);
$self->load_presets;
$self->select_preset_by_name($name);
$self->_on_presets_changed;
}
sub on_value_change {
my ($self, $cb) = @_;
$self->{on_value_change} = $cb;
}
sub on_presets_changed {
my ($self, $cb) = @_;
$self->{on_presets_changed} = $cb;
}
# This method is supposed to be called whenever new values are loaded
# or changed by user (so also when a preset is loaded).
# propagate event to the parent
sub _on_value_change {
my $self = shift;
$self->{on_value_change}->(@_) if $self->{on_value_change};
$self->_update;
}
sub _update {}
sub _on_presets_changed {
my $self = shift;
$self->{on_presets_changed}->(
$self->{presets},
scalar($self->{presets_choice}->GetSelection),
$self->is_dirty,
) if $self->{on_presets_changed};
}
sub on_preset_loaded {}
sub hidden_options {}
sub config { $_[0]->{config}->clone }
sub select_default_preset {
my $self = shift;
$self->select_preset(0);
}
sub select_preset {
my $self = shift;
$self->{presets_choice}->SetSelection($_[0]);
$self->on_select_preset;
}
sub select_preset_by_name {
my ($self, $name) = @_;
$name = Unicode::Normalize::NFC($name);
$self->select_preset(first { $self->{presets}[$_]->name eq $name } 0 .. $#{$self->{presets}});
}
sub on_select_preset {
my $self = shift;
if ($self->is_dirty) {
my $old_preset = $self->get_current_preset;
my $name = $old_preset->default ? 'Default preset' : "Preset \"" . $old_preset->name . "\"";
my @option_names = ();
foreach my $opt_key (@{$self->dirty_options}) {
my $opt = $Slic3r::Config::Options->{$opt_key};
my $name = $opt->{full_label} // $opt->{label};
if ($opt->{category}) {
$name = $opt->{category} . " > $name";
}
push @option_names, $name;
}
my $changes = join "\n", map "- $_", @option_names;
my $confirm = Wx::MessageDialog->new($self, "$name has unsaved changes:\n$changes\n\nDiscard changes and continue anyway?",
'Unsaved Changes', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
if ($confirm->ShowModal == wxID_NO) {
$self->{presets_choice}->SetSelection($self->current_preset);
# trigger the on_presets_changed event so that we also restore the previous value
# in the plater selector
$self->_on_presets_changed;
return;
}
}
$self->current_preset($self->{presets_choice}->GetSelection);
my $preset = $self->get_current_preset;
my $preset_config = $self->get_preset_config($preset);
eval {
local $SIG{__WARN__} = Slic3r::GUI::warning_catcher($self);
foreach my $opt_key (@{$self->{config}->get_keys}) {
$self->{config}->set($opt_key, $preset_config->get($opt_key))
if $preset_config->has($opt_key);
}
($preset->default || $preset->external)
? $self->{btn_delete_preset}->Disable
: $self->{btn_delete_preset}->Enable;
$self->_update;
$self->on_preset_loaded;
$self->reload_config;
$Slic3r::GUI::Settings->{presets}{$self->name} = $preset->file ? basename($preset->file) : '';
};
if ($@) {
$@ = "I was unable to load the selected config file: $@";
Slic3r::GUI::catch_error($self);
$self->select_default_preset;
}
# use CallAfter because some field triggers schedule on_change calls using CallAfter,
# and we don't want them to be called after this update_dirty() as they would mark the
# preset dirty again
# (not sure this is true anymore now that update_dirty is idempotent)
wxTheApp->CallAfter(sub {
$self->_on_presets_changed;
$self->update_dirty;
});
wxTheApp->save_settings;
}
sub init_config_options {
my ($self, @opt_keys) = @_;
$self->{config}->apply(Slic3r::Config->new_from_defaults(@opt_keys));
}
sub add_options_page {
my $self = shift;
my ($title, $icon, %params) = @_;
if ($icon) {
my $bitmap = Wx::Bitmap->new($Slic3r::var->($icon), wxBITMAP_TYPE_PNG);
$self->{icons}->Add($bitmap);
$self->{iconcount}++;
}
my $page = Slic3r::GUI::Tab::Page->new($self, $title, $self->{iconcount});
$page->Hide;
$self->{sizer}->Add($page, 1, wxEXPAND | wxLEFT, 5);
push @{$self->{pages}}, $page;
return $page;
}
sub reload_config {
my $self = shift;
$_->reload_config for @{$self->{pages}};
}
sub update_tree {
my ($self) = @_;
# get label of the currently selected item
my $selected = $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection);
my $rootItem = $self->{treectrl}->GetRootItem;
$self->{treectrl}->DeleteChildren($rootItem);
my $have_selection = 0;
foreach my $page (@{$self->{pages}}) {
my $itemId = $self->{treectrl}->AppendItem($rootItem, $page->{title}, $page->{iconID});
if ($page->{title} eq $selected) {
$self->{disable_tree_sel_changed_event} = 1;
$self->{treectrl}->SelectItem($itemId);
$self->{disable_tree_sel_changed_event} = 0;
$have_selection = 1;
}
}
if (!$have_selection) {
# this is triggered on first load, so we don't disable the sel change event
$self->{treectrl}->SelectItem($self->{treectrl}->GetFirstChild($rootItem));
}
}
sub update_dirty {
my $self = shift;
foreach my $i (0..$#{$self->{presets}}) {
my $preset = $self->get_preset($i);
if ($i == $self->current_preset && $self->is_dirty) {
$self->{presets_choice}->SetString($i, $preset->name . " (modified)");
} else {
$self->{presets_choice}->SetString($i, $preset->name);
}
}
$self->{presets_choice}->SetSelection($self->current_preset); # http://trac.wxwidgets.org/ticket/13769
$self->_on_presets_changed;
}
sub is_dirty {
my $self = shift;
return @{$self->dirty_options} > 0;
}
sub dirty_options {
my $self = shift;
return [] if !defined $self->current_preset; # happens during initialization
return $self->get_preset_config($self->get_current_preset)->diff($self->{config});
}
sub load_presets {
my $self = shift;
$self->{presets} = [
Slic3r::GUI::Tab::Preset->new(
default => 1,
name => '- default -',
),
];
my %presets = wxTheApp->presets($self->name);
foreach my $preset_name (sort keys %presets) {
push @{$self->{presets}}, Slic3r::GUI::Tab::Preset->new(
name => $preset_name,
file => $presets{$preset_name},
);
}
$self->current_preset(undef);
$self->{presets_choice}->Clear;
$self->{presets_choice}->Append($_->name) for @{$self->{presets}};
{
# load last used preset
my $i = first { basename($self->{presets}[$_]->file) eq ($Slic3r::GUI::Settings->{presets}{$self->name} || '') } 1 .. $#{$self->{presets}};
$self->select_preset($i || 0);
}
$self->_on_presets_changed;
}
sub load_config_file {
my $self = shift;
my ($file) = @_;
# look for the loaded config among the existing menu items
my $i = first { $self->{presets}[$_]{file} eq $file && $self->{presets}[$_]{external} } 1..$#{$self->{presets}};
if (!$i) {
my $preset_name = basename($file); # keep the .ini suffix
push @{$self->{presets}}, Slic3r::GUI::Tab::Preset->new(
file => $file,
name => $preset_name,
external => 1,
);
$self->{presets_choice}->Append($preset_name);
$i = $#{$self->{presets}};
}
$self->{presets_choice}->SetSelection($i);
$self->on_select_preset;
$self->_on_presets_changed;
}
sub load_config {
my $self = shift;
my ($config) = @_;
foreach my $opt_key (@{$self->{config}->diff($config)}) {
$self->{config}->set($opt_key, $config->get($opt_key));
$self->update_dirty;
}
$self->reload_config;
$self->_update;
}
sub get_preset_config {
my ($self, $preset) = @_;
return $preset->config($self->{config}->get_keys);
}
sub get_field {
my ($self, $opt_key, $opt_index) = @_;
foreach my $page (@{ $self->{pages} }) {
my $field = $page->get_field($opt_key, $opt_index);
return $field if defined $field;
}
return undef;
}
sub set_value {
my $self = shift;
my ($opt_key, $value) = @_;
my $changed = 0;
foreach my $page (@{ $self->{pages} }) {
$changed = 1 if $page->set_value($opt_key, $value);
}
return $changed;
}
package Slic3r::GUI::Tab::Print;
use base 'Slic3r::GUI::Tab';
use List::Util qw(first any);
use Wx qw(:icon :dialog :id);
sub name { 'print' }
sub title { 'Print Settings' }
sub build {
my $self = shift;
$self->init_config_options(qw(
layer_height first_layer_height
perimeters spiral_vase
top_solid_layers bottom_solid_layers
extra_perimeters avoid_crossing_perimeters thin_walls overhangs
seam_position external_perimeters_first
fill_density fill_pattern external_fill_pattern fill_gaps
infill_every_layers infill_only_where_needed
solid_infill_every_layers fill_angle solid_infill_below_area
only_retract_when_crossing_perimeters infill_first
max_print_speed max_volumetric_speed
perimeter_speed small_perimeter_speed external_perimeter_speed infill_speed
solid_infill_speed top_solid_infill_speed support_material_speed
support_material_interface_speed bridge_speed gap_fill_speed
travel_speed
first_layer_speed
perimeter_acceleration infill_acceleration bridge_acceleration
first_layer_acceleration default_acceleration
skirts skirt_distance skirt_height min_skirt_length
brim_connections_width brim_width
support_material support_material_threshold support_material_enforce_layers
raft_layers
support_material_pattern support_material_spacing support_material_angle
support_material_interface_layers support_material_interface_spacing
support_material_contact_distance dont_support_bridges
notes
complete_objects extruder_clearance_radius extruder_clearance_height
gcode_comments output_filename_format
post_process
perimeter_extruder infill_extruder solid_infill_extruder
support_material_extruder support_material_interface_extruder
ooze_prevention standby_temperature_delta
interface_shells
extrusion_width first_layer_extrusion_width perimeter_extrusion_width
external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width
top_infill_extrusion_width support_material_extrusion_width
infill_overlap bridge_flow_ratio
xy_size_compensation threads resolution
));
$self->{config}->set('print_settings_id', '');
{
my $page = $self->add_options_page('Layers and perimeters', 'layers.png');
{
my $optgroup = $page->new_optgroup('Layer height');
$optgroup->append_single_option_line('layer_height');
$optgroup->append_single_option_line('first_layer_height');
}
{
my $optgroup = $page->new_optgroup('Vertical shells');
$optgroup->append_single_option_line('perimeters');
$optgroup->append_single_option_line('spiral_vase');
}
{
my $optgroup = $page->new_optgroup('Horizontal shells');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Solid layers',
);
$line->append_option($optgroup->get_option('top_solid_layers'));
$line->append_option($optgroup->get_option('bottom_solid_layers'));
$optgroup->append_line($line);
}
{
my $optgroup = $page->new_optgroup('Quality (slower slicing)');
$optgroup->append_single_option_line('extra_perimeters');
$optgroup->append_single_option_line('avoid_crossing_perimeters');
$optgroup->append_single_option_line('thin_walls');
$optgroup->append_single_option_line('overhangs');
}
{
my $optgroup = $page->new_optgroup('Advanced');
$optgroup->append_single_option_line('seam_position');
$optgroup->append_single_option_line('external_perimeters_first');
}
}
{
my $page = $self->add_options_page('Infill', 'infill.png');
{
my $optgroup = $page->new_optgroup('Infill');
$optgroup->append_single_option_line('fill_density');
$optgroup->append_single_option_line('fill_pattern');
$optgroup->append_single_option_line('external_fill_pattern');
}
{
my $optgroup = $page->new_optgroup('Reducing printing time');
$optgroup->append_single_option_line('infill_every_layers');
$optgroup->append_single_option_line('infill_only_where_needed');
}
{
my $optgroup = $page->new_optgroup('Advanced');
$optgroup->append_single_option_line('fill_gaps');
$optgroup->append_single_option_line('solid_infill_every_layers');
$optgroup->append_single_option_line('fill_angle');
$optgroup->append_single_option_line('solid_infill_below_area');
$optgroup->append_single_option_line('only_retract_when_crossing_perimeters');
$optgroup->append_single_option_line('infill_first');
}
}
{
my $page = $self->add_options_page('Skirt and brim', 'box.png');
{
my $optgroup = $page->new_optgroup('Skirt');
$optgroup->append_single_option_line('skirts');
$optgroup->append_single_option_line('skirt_distance');
$optgroup->append_single_option_line('skirt_height');
$optgroup->append_single_option_line('min_skirt_length');
}
{
my $optgroup = $page->new_optgroup('Brim');
$optgroup->append_single_option_line('brim_width');
$optgroup->append_single_option_line('brim_connections_width');
}
}
{
my $page = $self->add_options_page('Support material', 'building.png');
{
my $optgroup = $page->new_optgroup('Support material');
$optgroup->append_single_option_line('support_material');
$optgroup->append_single_option_line('support_material_threshold');
$optgroup->append_single_option_line('support_material_enforce_layers');
}
{
my $optgroup = $page->new_optgroup('Raft');
$optgroup->append_single_option_line('raft_layers');
}
{
my $optgroup = $page->new_optgroup('Options for support material and raft');
$optgroup->append_single_option_line('support_material_contact_distance');
$optgroup->append_single_option_line('support_material_pattern');
$optgroup->append_single_option_line('support_material_spacing');
$optgroup->append_single_option_line('support_material_angle');
$optgroup->append_single_option_line('support_material_interface_layers');
$optgroup->append_single_option_line('support_material_interface_spacing');
$optgroup->append_single_option_line('dont_support_bridges');
}
}
{
my $page = $self->add_options_page('Speed', 'time.png');
{
my $optgroup = $page->new_optgroup('Speed for print moves');
$optgroup->append_single_option_line('perimeter_speed');
$optgroup->append_single_option_line('small_perimeter_speed');
$optgroup->append_single_option_line('external_perimeter_speed');
$optgroup->append_single_option_line('infill_speed');
$optgroup->append_single_option_line('solid_infill_speed');
$optgroup->append_single_option_line('top_solid_infill_speed');
$optgroup->append_single_option_line('gap_fill_speed');
$optgroup->append_single_option_line('support_material_speed');
$optgroup->append_single_option_line('support_material_interface_speed');
$optgroup->append_single_option_line('bridge_speed');
}
{
my $optgroup = $page->new_optgroup('Speed for non-print moves');
$optgroup->append_single_option_line('travel_speed');
}
{
my $optgroup = $page->new_optgroup('Modifiers');
$optgroup->append_single_option_line('first_layer_speed');
}
{
my $optgroup = $page->new_optgroup('Acceleration control (advanced)');
$optgroup->append_single_option_line('perimeter_acceleration');
$optgroup->append_single_option_line('infill_acceleration');
$optgroup->append_single_option_line('bridge_acceleration');
$optgroup->append_single_option_line('first_layer_acceleration');
$optgroup->append_single_option_line('default_acceleration');
}
{
my $optgroup = $page->new_optgroup('Autospeed (advanced)');
$optgroup->append_single_option_line('max_print_speed');
$optgroup->append_single_option_line('max_volumetric_speed');
}
}
{
my $page = $self->add_options_page('Multiple Extruders', 'funnel.png');
{
my $optgroup = $page->new_optgroup('Extruders');
$optgroup->append_single_option_line('perimeter_extruder');
$optgroup->append_single_option_line('infill_extruder');
$optgroup->append_single_option_line('solid_infill_extruder');
$optgroup->append_single_option_line('support_material_extruder');
$optgroup->append_single_option_line('support_material_interface_extruder');
}
{
my $optgroup = $page->new_optgroup('Ooze prevention');
$optgroup->append_single_option_line('ooze_prevention');
$optgroup->append_single_option_line('standby_temperature_delta');
}
{
my $optgroup = $page->new_optgroup('Advanced');
$optgroup->append_single_option_line('interface_shells');
}
}
{
my $page = $self->add_options_page('Advanced', 'wrench.png');
{
my $optgroup = $page->new_optgroup('Extrusion width',
label_width => 180,
);
$optgroup->append_single_option_line('extrusion_width');
$optgroup->append_single_option_line('first_layer_extrusion_width');
$optgroup->append_single_option_line('perimeter_extrusion_width');
$optgroup->append_single_option_line('external_perimeter_extrusion_width');
$optgroup->append_single_option_line('infill_extrusion_width');
$optgroup->append_single_option_line('solid_infill_extrusion_width');
$optgroup->append_single_option_line('top_infill_extrusion_width');
$optgroup->append_single_option_line('support_material_extrusion_width');
}
{
my $optgroup = $page->new_optgroup('Overlap');
$optgroup->append_single_option_line('infill_overlap');
}
{
my $optgroup = $page->new_optgroup('Flow');
$optgroup->append_single_option_line('bridge_flow_ratio');
}
{
my $optgroup = $page->new_optgroup('Other');
$optgroup->append_single_option_line('xy_size_compensation');
$optgroup->append_single_option_line('threads') if $Slic3r::have_threads;
$optgroup->append_single_option_line('resolution');
}
}
{
my $page = $self->add_options_page('Output options', 'page_white_go.png');
{
my $optgroup = $page->new_optgroup('Sequential printing');
$optgroup->append_single_option_line('complete_objects');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Extruder clearance (mm)',
);
foreach my $opt_key (qw(extruder_clearance_radius extruder_clearance_height)) {
my $option = $optgroup->get_option($opt_key);
$option->width(60);
$line->append_option($option);
}
$optgroup->append_line($line);
}
{
my $optgroup = $page->new_optgroup('Output file');
$optgroup->append_single_option_line('gcode_comments');
{
my $option = $optgroup->get_option('output_filename_format');
$option->full_width(1);
$optgroup->append_single_option_line($option);
}
}
{
my $optgroup = $page->new_optgroup('Post-processing scripts',
label_width => 0,
);
my $option = $optgroup->get_option('post_process');
$option->full_width(1);
$option->height(50);
$optgroup->append_single_option_line($option);
}
}
{
my $page = $self->add_options_page('Notes', 'note.png');
{
my $optgroup = $page->new_optgroup('Notes',
label_width => 0,
);
my $option = $optgroup->get_option('notes');
$option->full_width(1);
$option->height(250);
$optgroup->append_single_option_line($option);
}
}
}
sub _update {
my ($self) = @_;
my $config = $self->{config};
if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->infill_only_where_needed == 0 && $config->support_material == 0)) {
my $dialog = Wx::MessageDialog->new($self,
"The Spiral Vase mode requires:\n"
. "- one perimeter\n"
. "- no top solid layers\n"
. "- 0% fill density\n"
. "- no support material\n"
. "- no infill where necessary\n"
. "\nShall I adjust those settings in order to enable Spiral Vase?",
'Spiral Vase', wxICON_WARNING | wxYES | wxNO);
if ($dialog->ShowModal() == wxID_YES) {
my $new_conf = Slic3r::Config->new;
$new_conf->set("perimeters", 1);
$new_conf->set("top_solid_layers", 0);
$new_conf->set("fill_density", 0);
$new_conf->set("support_material", 0);
$new_conf->set("infill_only_where_needed", 0);
$self->load_config($new_conf);
} else {
my $new_conf = Slic3r::Config->new;
$new_conf->set("spiral_vase", 0);
$self->load_config($new_conf);
}
}
if ($config->support_material) {
# Ask only once.
if (! $self->{support_material_overhangs_queried}) {
$self->{support_material_overhangs_queried} = 1;
if ($config->overhangs != 1) {
my $dialog = Wx::MessageDialog->new($self,
"Supports work better, if the following feature is enabled:\n"
. "- Detect bridging perimeters\n"
. "\nShall I adjust those settings for supports?",
'Support Generator', wxICON_WARNING | wxYES | wxNO | wxCANCEL);
my $answer = $dialog->ShowModal();
my $new_conf = Slic3r::Config->new;
if ($answer == wxID_YES) {
# Enable "detect bridging perimeters".
$new_conf->set("overhangs", 1);
} elsif ($answer == wxID_NO) {
# Do nothing, leave supports on and "detect bridging perimeters" off.
} elsif ($answer == wxID_CANCEL) {
# Disable supports.
$new_conf->set("support_material", 0);
$self->{support_material_overhangs_queried} = 0;
}
$self->load_config($new_conf);
}
}
} else {
$self->{support_material_overhangs_queried} = 0;
}
if ($config->fill_density == 100
&& !first { $_ eq $config->fill_pattern } @{$Slic3r::Config::Options->{external_fill_pattern}{values}}) {
my $dialog = Wx::MessageDialog->new($self,
"The " . $config->fill_pattern . " infill pattern is not supposed to work at 100% density.\n"
. "\nShall I switch to rectilinear fill pattern?",
'Infill', wxICON_WARNING | wxYES | wxNO);
my $new_conf = Slic3r::Config->new;
if ($dialog->ShowModal() == wxID_YES) {
$new_conf->set("fill_pattern", 'rectilinear');
} else {
$new_conf->set("fill_density", 40);
}
$self->load_config($new_conf);
}
my $have_perimeters = $config->perimeters > 0;
$self->get_field($_)->toggle($have_perimeters)
for qw(extra_perimeters thin_walls overhangs seam_position external_perimeters_first
external_perimeter_extrusion_width
perimeter_speed small_perimeter_speed external_perimeter_speed);
my $have_infill = $config->fill_density > 0;
# infill_extruder uses the same logic as in Print::extruders()
$self->get_field($_)->toggle($have_infill)
for qw(fill_pattern infill_every_layers infill_only_where_needed solid_infill_every_layers
solid_infill_below_area infill_extruder);
my $have_solid_infill = ($config->top_solid_layers > 0) || ($config->bottom_solid_layers > 0);
# solid_infill_extruder uses the same logic as in Print::extruders()
$self->get_field($_)->toggle($have_solid_infill)
for qw(external_fill_pattern infill_first solid_infill_extruder solid_infill_extrusion_width
solid_infill_speed);
$self->get_field($_)->toggle($have_infill || $have_solid_infill)
for qw(fill_angle infill_extrusion_width infill_speed bridge_speed);
$self->get_field('fill_gaps')->toggle($have_perimeters && $have_infill);
$self->get_field('gap_fill_speed')->toggle($have_perimeters && $have_infill && $config->fill_gaps);
my $have_top_solid_infill = $config->top_solid_layers > 0;
$self->get_field($_)->toggle($have_top_solid_infill)
for qw(top_infill_extrusion_width top_solid_infill_speed);
my $have_autospeed = any { $config->get("${_}_speed") eq '0' }
qw(perimeter external_perimeter small_perimeter
infill solid_infill top_solid_infill gap_fill support_material
support_material_interface);
$self->get_field('max_print_speed')->toggle($have_autospeed);
my $have_default_acceleration = $config->default_acceleration > 0;
$self->get_field($_)->toggle($have_default_acceleration)
for qw(perimeter_acceleration infill_acceleration bridge_acceleration first_layer_acceleration);
my $have_skirt = $config->skirts > 0 || $config->min_skirt_length > 0;
$self->get_field($_)->toggle($have_skirt)
for qw(skirt_distance skirt_height);
my $have_brim = $config->brim_width > 0 || $config->brim_connections_width;
# perimeter_extruder uses the same logic as in Print::extruders()
$self->get_field('perimeter_extruder')->toggle($have_perimeters || $have_brim);
my $have_support_material = $config->support_material || $config->raft_layers > 0;
my $have_support_interface = $config->support_material_interface_layers > 0;
$self->get_field($_)->toggle($have_support_material)
for qw(support_material_threshold support_material_pattern
support_material_spacing support_material_angle
support_material_interface_layers dont_support_bridges
support_material_extrusion_width support_material_contact_distance);
$self->get_field($_)->toggle($have_support_material && $have_support_interface)
for qw(support_material_interface_spacing support_material_interface_extruder
support_material_interface_speed);
$self->get_field('perimeter_extrusion_width')->toggle($have_perimeters || $have_skirt || $have_brim);
$self->get_field('support_material_extruder')->toggle($have_support_material || $have_skirt);
$self->get_field('support_material_speed')->toggle($have_support_material || $have_brim || $have_skirt);
my $have_sequential_printing = $config->complete_objects;
$self->get_field($_)->toggle($have_sequential_printing)
for qw(extruder_clearance_radius extruder_clearance_height);
my $have_ooze_prevention = $config->ooze_prevention;
$self->get_field($_)->toggle($have_ooze_prevention)
for qw(standby_temperature_delta);
}
sub hidden_options { !$Slic3r::have_threads ? qw(threads) : () }
package Slic3r::GUI::Tab::Filament;
use base 'Slic3r::GUI::Tab';
sub name { 'filament' }
sub title { 'Filament Settings' }
sub build {
my $self = shift;
$self->init_config_options(qw(
filament_colour filament_diameter filament_notes filament_max_volumetric_speed extrusion_multiplier filament_density filament_cost
temperature first_layer_temperature bed_temperature first_layer_bed_temperature
fan_always_on cooling
min_fan_speed max_fan_speed bridge_fan_speed disable_fan_first_layers
fan_below_layer_time slowdown_below_layer_time min_print_speed
));
$self->{config}->set('filament_settings_id', '');
{
my $page = $self->add_options_page('Filament', 'spool.png');
{
my $optgroup = $page->new_optgroup('Filament');
$optgroup->append_single_option_line('filament_colour', 0);
$optgroup->append_single_option_line('filament_diameter', 0);
$optgroup->append_single_option_line('extrusion_multiplier', 0);
$optgroup->append_single_option_line('filament_density', 0);
$optgroup->append_single_option_line('filament_cost', 0);
}
{
my $optgroup = $page->new_optgroup('Temperature (°C)');
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Extruder',
);
$line->append_option($optgroup->get_option('first_layer_temperature', 0));
$line->append_option($optgroup->get_option('temperature', 0));
$optgroup->append_line($line);
}
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Bed',
);
$line->append_option($optgroup->get_option('first_layer_bed_temperature'));
$line->append_option($optgroup->get_option('bed_temperature'));
$optgroup->append_line($line);
}
}
}
{
my $page = $self->add_options_page('Cooling', 'hourglass.png');
{
my $optgroup = $page->new_optgroup('Enable');
$optgroup->append_single_option_line('fan_always_on');
$optgroup->append_single_option_line('cooling');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => '',
full_width => 1,
widget => sub {
my ($parent) = @_;
return $self->{description_line} = Slic3r::GUI::OptionsGroup::StaticText->new($parent);
},
);
$optgroup->append_line($line);
}
{
my $optgroup = $page->new_optgroup('Fan settings');
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Fan speed',
);
$line->append_option($optgroup->get_option('min_fan_speed'));
$line->append_option($optgroup->get_option('max_fan_speed'));
$optgroup->append_line($line);
}
$optgroup->append_single_option_line('bridge_fan_speed');
$optgroup->append_single_option_line('disable_fan_first_layers');
}
{
my $optgroup = $page->new_optgroup('Cooling thresholds',
label_width => 250,
);
$optgroup->append_single_option_line('fan_below_layer_time');
$optgroup->append_single_option_line('slowdown_below_layer_time');
$optgroup->append_single_option_line('min_print_speed');
}
}
{
my $page = $self->add_options_page('Advanced', 'wrench.png');
{
my $optgroup = $page->new_optgroup('Print speed override');
$optgroup->append_single_option_line('filament_max_volumetric_speed', 0);
}
}
{
my $page = $self->add_options_page('Notes', 'note.png');
{
my $optgroup = $page->new_optgroup('Notes',
label_width => 0,
);
my $option = $optgroup->get_option('filament_notes', 0);
$option->full_width(1);
$option->height(250);