2012-06-17 20:27:05 +00:00
package Slic3r::GUI::Tab ;
use strict ;
use warnings ;
use utf8 ;
2012-06-19 12:47:02 +00:00
use File::Basename qw( basename ) ;
2012-06-18 20:27:57 +00:00
use List::Util qw( first ) ;
2012-06-17 20:27:05 +00:00
use Wx qw( :sizer :progressdialog ) ;
2012-06-18 20:27:57 +00:00
use Wx::Event qw( EVT_TREE_SEL_CHANGED EVT_CHOICE EVT_BUTTON ) ;
2012-06-18 14:46:43 +00:00
use base 'Wx::Panel' ;
2012-06-17 20:27:05 +00:00
sub new {
my $ class = shift ;
2012-06-19 15:23:10 +00:00
my ( $ parent , % params ) = @ _ ;
2012-06-17 20:27:05 +00:00
my $ self = $ class - > SUPER:: new ( $ parent , - 1 , [ - 1 , - 1 ] , [ - 1 , - 1 ] , & Wx:: wxBK_LEFT ) ;
2012-06-17 20:54:08 +00:00
2012-06-19 15:23:10 +00:00
$ self - > { sync_presets_with } = $ params { sync_presets_with } ;
EVT_CHOICE ( $ parent , $ self - > { sync_presets_with } , sub {
$ self - > { presets_choice } - > SetSelection ( $ self - > { sync_presets_with } - > GetSelection ) ;
$ self - > on_select_preset ;
} ) ;
2012-06-18 20:27:57 +00:00
# horizontal sizer
2012-06-18 14:46:43 +00:00
$ self - > { sizer } = Wx::BoxSizer - > new ( & Wx:: wxHORIZONTAL ) ;
$ self - > { sizer } - > SetSizeHints ( $ self ) ;
$ self - > SetSizer ( $ self - > { sizer } ) ;
2012-06-18 20:27:57 +00:00
# left vertical sizer
my $ left_sizer = Wx::BoxSizer - > new ( & Wx:: wxVERTICAL ) ;
$ self - > { sizer } - > Add ( $ left_sizer , 0 , & Wx:: wxEXPAND ) ;
my $ left_col_width = 200 ;
# preset chooser
{
my $ box = Wx::StaticBox - > new ( $ self , - 1 , "Presets:" , [ - 1 , - 1 ] , [ $ left_col_width , 50 ] ) ;
$ left_sizer - > Add ( $ box , 0 , & Wx:: wxEXPAND | & Wx:: wxBOTTOM , 5 ) ;
# choice menu
$ self - > { presets_choice } = Wx::Choice - > new ( $ box , - 1 , [ - 1 , - 1 ] , [ - 1 , - 1 ] , [] ) ;
2012-06-19 15:23:10 +00:00
$ self - > { presets_choice } - > SetFont ( $ Slic3r:: GUI:: small_font ) ;
2012-06-18 20:27:57 +00:00
# buttons
$ self - > { btn_save_preset } = Wx::BitmapButton - > new ( $ box , - 1 , Wx::Bitmap - > new ( "$Slic3r::var/disk.png" , & Wx:: wxBITMAP_TYPE_PNG ) ) ;
$ self - > { btn_delete_preset } = Wx::BitmapButton - > new ( $ box , - 1 , Wx::Bitmap - > new ( "$Slic3r::var/delete.png" , & Wx:: wxBITMAP_TYPE_PNG ) ) ;
$ self - > { btn_save_preset } - > SetToolTipString ( "Save current settings" ) ;
$ self - > { btn_delete_preset } - > SetToolTipString ( "Delete this preset" ) ;
$ self - > { btn_save_preset } - > Disable ;
$ self - > { btn_delete_preset } - > Disable ;
my $ hsizer = Wx::BoxSizer - > new ( & Wx:: wxHORIZONTAL ) ;
$ box - > SetSizer ( $ hsizer ) ;
$ hsizer - > Add ( $ self - > { presets_choice } , 1 , & Wx:: wxRIGHT | & Wx:: wxALIGN_CENTER_VERTICAL , 3 ) ;
$ hsizer - > Add ( $ self - > { btn_save_preset } , 0 , & Wx:: wxALIGN_CENTER_VERTICAL ) ;
$ hsizer - > Add ( $ self - > { btn_delete_preset } , 0 , & Wx:: wxALIGN_CENTER_VERTICAL ) ;
}
2012-06-18 14:46:43 +00:00
2012-06-18 20:27:57 +00:00
# tree
$ self - > { treectrl } = Wx::TreeCtrl - > new ( $ self , - 1 , [ - 1 , - 1 ] , [ $ left_col_width , - 1 ] , & Wx:: wxTR_NO_BUTTONS | & Wx:: wxTR_HIDE_ROOT | & Wx:: wxTR_SINGLE | & Wx:: wxTR_NO_LINES ) ;
$ left_sizer - > Add ( $ self - > { treectrl } , 1 , & Wx:: wxEXPAND ) ;
2012-06-18 14:46:43 +00:00
$ 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 ) ;
EVT_TREE_SEL_CHANGED ( $ parent , $ self - > { treectrl } , sub {
$ _ - > Hide for values % { $ self - > { pages } } ;
$ self - > { sizer } - > Remove ( 1 ) ;
my $ page = $ self - > { pages } - > { $ self - > { treectrl } - > GetItemText ( $ self - > { treectrl } - > GetSelection ) } ;
$ page - > Show ;
$ self - > { sizer } - > Add ( $ page , 1 , & Wx:: wxEXPAND | & Wx:: wxLEFT , 5 ) ;
$ self - > { sizer } - > Layout ;
} ) ;
2012-06-17 20:54:08 +00:00
2012-06-18 20:27:57 +00:00
EVT_CHOICE ( $ parent , $ self - > { presets_choice } , sub {
2012-06-19 15:23:10 +00:00
$ self - > on_select_preset ;
$ self - > sync_presets ;
2012-06-18 20:27:57 +00:00
} ) ;
EVT_BUTTON ( $ self , $ self - > { btn_save_preset } , sub {
my $ i = $ self - > { presets_choice } - > GetSelection ;
2012-06-19 12:47:02 +00:00
my $ default = $ i == 0 ? 'Untitled' : basename ( $ self - > { presets } [ $ i - 1 ] ) ;
2012-06-18 20:27:57 +00:00
$ default =~ s/\.ini$//i ;
my $ dlg = Slic3r::GUI::SavePresetWindow - > new ( $ self ,
default = > $ default ,
2012-06-19 12:47:02 +00:00
values = > [ map { my $ filename = basename ( $ _ ) ; $ filename =~ /^(.*?)\.ini$/i ; $ 1 } @ { $ self - > { presets } } ] ,
2012-06-18 20:27:57 +00:00
) ;
2012-06-19 12:47:02 +00:00
return unless $ dlg - > ShowModal == & Wx:: wxID_OK ;
2012-06-18 20:27:57 +00:00
my $ file = sprintf "$Slic3r::GUI::datadir/$self->{presets_group}/%s.ini" , $ dlg - > get_name ;
Slic3r::Config - > save ( $ file , $ self - > { presets_group } ) ;
$ self - > set_dirty ( 0 ) ;
$ self - > load_presets ;
2012-06-19 12:47:02 +00:00
$ self - > { presets_choice } - > SetSelection ( 1 + first { basename ( $ self - > { presets } [ $ _ ] ) eq $ dlg - > get_name . ".ini" } 0 .. $# { $ self - > { presets } } ) ;
2012-06-19 16:11:51 +00:00
$ self - > on_select_preset ;
2012-06-19 15:23:10 +00:00
$ self - > sync_presets ;
2012-06-18 20:27:57 +00:00
} ) ;
2012-06-19 15:47:48 +00:00
EVT_BUTTON ( $ self , $ self - > { btn_delete_preset } , sub {
my $ i = $ self - > { presets_choice } - > GetSelection ;
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' , & Wx:: wxYES_NO | & Wx:: wxNO_DEFAULT | & Wx:: wxICON_QUESTION ) - > ShowModal ;
return unless $ res == & Wx:: wxID_YES ;
if ( - e $ self - > { presets } [ $ i - 1 ] ) {
unlink $ self - > { presets } [ $ i - 1 ] ;
}
splice @ { $ self - > { presets } } , $ i - 1 , 1 ;
$ self - > { presets_choice } - > Delete ( $ i ) ;
$ self - > { presets_choice } - > SetSelection ( 0 ) ;
$ self - > on_select_preset ;
$ self - > sync_presets ;
} ) ;
2012-06-17 20:27:05 +00:00
return $ self ;
}
2012-06-19 15:23:10 +00:00
sub on_select_preset {
my $ self = shift ;
if ( defined $ self - > { dirty } ) {
# TODO: prompt user?
$ self - > set_dirty ( 0 ) ;
}
my $ i = $ self - > { presets_choice } - > GetSelection ;
2012-06-19 16:11:51 +00:00
my $ file ;
2012-06-19 15:23:10 +00:00
if ( $ i == 0 ) {
Slic3r::Config - > load_hash ( $ Slic3r:: Defaults , $ self - > { presets_group } , 1 ) ;
$ self - > { btn_delete_preset } - > Disable ;
} else {
2012-06-19 16:11:51 +00:00
$ file = $ self - > { presets } [ $ i - 1 ] ;
2012-06-19 15:23:10 +00:00
if ( ! - e $ file ) {
Slic3r::GUI:: show_error ( $ self , "The selected preset does not exist anymore ($file)." ) ;
return ;
}
Slic3r::Config - > load ( $ file , $ self - > { presets_group } ) ;
$ self - > { btn_delete_preset } - > Enable ;
}
$ _ - > ( ) for @ Slic3r:: GUI:: OptionsGroup:: reload_callbacks { @ { $ Slic3r:: Config:: Groups { $ self - > { presets_group } } } } ;
$ self - > set_dirty ( 0 ) ;
2012-06-19 16:11:51 +00:00
$ Slic3r:: Settings - > { presets } { $ self - > { presets_group } } = $ file ? basename ( $ file ) : '' ;
Slic3r::Config - > save_settings ( "$Slic3r::GUI::datadir/slic3r.ini" ) ;
2012-06-19 15:23:10 +00:00
}
2012-06-18 20:27:57 +00:00
sub add_options_page {
2012-06-17 20:27:05 +00:00
my $ self = shift ;
my $ title = shift ;
2012-06-18 14:46:43 +00:00
my $ icon = ( ref $ _ [ 1 ] ) ? undef : shift ;
2012-06-18 20:27:57 +00:00
my $ page = Slic3r::GUI::Tab::Page - > new ( $ self , @ _ , on_change = > sub {
$ self - > set_dirty ( 1 ) ;
2012-06-19 15:23:10 +00:00
$ self - > sync_presets ;
2012-06-18 20:27:57 +00:00
} ) ;
2012-06-17 20:54:08 +00:00
2012-06-18 14:46:43 +00:00
my $ bitmap = $ icon
? Wx::Bitmap - > new ( "$Slic3r::var/$icon" , & Wx:: wxBITMAP_TYPE_PNG )
2012-06-17 20:54:08 +00:00
: undef ;
if ( $ bitmap ) {
2012-06-18 14:46:43 +00:00
$ self - > { icons } - > Add ( $ bitmap ) ;
$ self - > { iconcount } + + ;
2012-06-17 20:54:08 +00:00
}
2012-06-18 14:46:43 +00:00
$ page - > Hide ;
2012-06-18 20:27:57 +00:00
my $ itemId = $ self - > { treectrl } - > AppendItem ( $ self - > { treectrl } - > GetRootItem , $ title , $ self - > { iconcount } ) ;
2012-06-18 14:46:43 +00:00
$ self - > { pages } { $ title } = $ page ;
2012-06-18 20:27:57 +00:00
if ( keys % { $ self - > { pages } } == 1 ) {
$ self - > { treectrl } - > SelectItem ( $ itemId ) ;
}
2012-06-17 20:27:05 +00:00
}
2012-06-18 20:27:57 +00:00
sub set_dirty {
my $ self = shift ;
my ( $ dirty ) = @ _ ;
my $ i = $ self - > { dirty } // $ self - > { presets_choice } - > GetSelection ; #/
my $ text = $ self - > { presets_choice } - > GetString ( $ i ) ;
if ( $ dirty ) {
$ self - > { dirty } = $ i ;
$ self - > { btn_save_preset } - > Enable ;
if ( $ text !~ / \(modified\)$/ ) {
$ self - > { presets_choice } - > SetString ( $ i , "$text (modified)" ) ;
}
} else {
$ self - > { dirty } = undef ;
$ self - > { btn_save_preset } - > Disable ;
$ text =~ s/ \(modified\)$// ;
$ self - > { presets_choice } - > SetString ( $ i , $ text ) ;
}
2012-06-19 15:23:10 +00:00
$ self - > sync_presets ;
2012-06-18 20:27:57 +00:00
}
sub load_presets {
my $ self = shift ;
my ( $ group ) = @ _ ;
$ self - > { presets_group } || = $ group ;
$ self - > { presets } = [] ;
opendir my $ dh , "$Slic3r::GUI::datadir/$self->{presets_group}" or die "Failed to read directory $Slic3r::GUI::datadir/$self->{presets_group} (errno: $!)\n" ;
my @ presets = sort grep /\.ini$/i , readdir $ dh ;
closedir $ dh ;
$ self - > { presets_choice } - > Clear ;
$ self - > { presets_choice } - > Append ( "- default -" ) ;
foreach my $ preset ( @ presets ) {
2012-06-19 12:47:02 +00:00
push @ { $ self - > { presets } } , "$Slic3r::GUI::datadir/$self->{presets_group}/$preset" ;
2012-06-18 20:27:57 +00:00
$ preset =~ s/\.ini$//i ;
$ self - > { presets_choice } - > Append ( $ preset ) ;
}
2012-06-19 16:11:51 +00:00
{
my $ i = first { basename ( $ self - > { presets } [ $ _ ] ) eq ( $ Slic3r:: Settings - > { presets } { $ self - > { presets_group } } || '' ) } 0 .. $# { $ self - > { presets } } ;
if ( defined $ i ) {
$ self - > { presets_choice } - > SetSelection ( $ i + 1 ) ;
$ self - > on_select_preset ;
}
}
2012-06-19 15:23:10 +00:00
$ self - > sync_presets ;
2012-06-18 20:27:57 +00:00
}
2012-06-17 20:27:05 +00:00
2012-06-19 12:47:02 +00:00
sub external_config_loaded {
my $ self = shift ;
my ( $ file ) = @ _ ;
# look for the loaded config among the existing menu items
my $ i = first { $ self - > { presets } [ $ _ ] eq $ file } 0 .. $# { $ self - > { presets } } ;
if ( ! $ i ) {
push @ { $ self - > { presets } } , $ file ;
my $ preset_name = basename ( $ file ) ; # leave the .ini suffix
$ self - > { presets_choice } - > Append ( $ preset_name ) ;
$ i = $# { $ self - > { presets } } ;
}
$ self - > { presets_choice } - > SetSelection ( 1 + $ i ) ;
$ self - > set_dirty ( 0 ) ;
$ self - > { btn_save_preset } - > Enable ;
$ self - > { btn_delete_preset } - > Disable ;
2012-06-19 15:23:10 +00:00
$ self - > sync_presets ;
}
sub sync_presets {
my $ self = shift ;
return unless $ self - > { sync_presets_with } ;
$ self - > { sync_presets_with } - > Clear ;
foreach my $ item ( $ self - > { presets_choice } - > GetStrings ) {
$ self - > { sync_presets_with } - > Append ( $ item ) ;
}
$ self - > { sync_presets_with } - > SetSelection ( $ self - > { presets_choice } - > GetSelection ) ;
2012-06-19 12:47:02 +00:00
}
2012-06-18 20:27:57 +00:00
package Slic3r::GUI::Tab::Print ;
2012-06-17 20:27:05 +00:00
use Wx qw( :sizer :progressdialog ) ;
use Wx::Event qw( ) ;
use base 'Slic3r::GUI::Tab' ;
sub new {
my $ class = shift ;
2012-06-19 15:23:10 +00:00
my ( $ parent , % params ) = @ _ ;
my $ self = $ class - > SUPER:: new ( $ parent , % params ) ;
2012-06-17 20:27:05 +00:00
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Layers and perimeters' , 'layers.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Layer height' ,
options = > [ qw( layer_height first_layer_height ) ] ,
} ,
{
title = > 'Vertical shells' ,
options = > [ qw( perimeters randomize_start ) ] ,
} ,
{
title = > 'Horizontal shells' ,
options = > [ qw( solid_layers ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Infill' , 'shading.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Infill' ,
2012-06-18 08:19:24 +00:00
options = > [ qw( fill_density fill_angle fill_pattern solid_fill_pattern infill_every_layers ) ] ,
2012-06-17 20:27:05 +00:00
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Speed' , 'time.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Speed for print moves' ,
options = > [ qw( perimeter_speed small_perimeter_speed infill_speed solid_infill_speed top_solid_infill_speed bridge_speed ) ] ,
} ,
{
title = > 'Speed for non-print moves' ,
options = > [ qw( travel_speed ) ] ,
} ,
{
2012-06-18 08:19:24 +00:00
title = > 'Modifiers' ,
2012-06-17 20:27:05 +00:00
options = > [ qw( first_layer_speed ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Skirt' , 'box.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Skirt' ,
options = > [ qw( skirts skirt_distance skirt_height ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Support material' , 'building.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Support material' ,
options = > [ qw( support_material support_material_tool ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Notes' , 'note.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Notes' ,
2012-06-17 21:24:10 +00:00
no_labels = > 1 ,
2012-06-17 20:27:05 +00:00
options = > [ qw( notes ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Output options' , 'page_white_go.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Sequential printing' ,
options = > [ qw( complete_objects extruder_clearance_radius extruder_clearance_height ) ] ,
} ,
{
title = > 'Output file' ,
options = > [ qw( gcode_comments output_filename_format ) ] ,
} ,
{
2012-06-17 21:24:10 +00:00
title = > 'Post-processing scripts' ,
no_labels = > 1 ,
2012-06-18 09:26:21 +00:00
options = > [ qw( post_process ) ] ,
2012-06-17 20:27:05 +00:00
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Advanced' , 'wrench.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Extrusion width' ,
2012-06-18 12:29:47 +00:00
label_width = > 180 ,
2012-06-17 20:27:05 +00:00
options = > [ qw( extrusion_width first_layer_extrusion_width perimeters_extrusion_width infill_extrusion_width ) ] ,
} ,
{
title = > 'Flow' ,
options = > [ qw( bridge_flow_ratio ) ] ,
} ,
2012-06-18 09:26:21 +00:00
{
title = > 'Other' ,
options = > [ qw( duplicate_distance ) ] ,
} ,
2012-06-17 20:27:05 +00:00
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > load_presets ( 'print' ) ;
2012-06-17 20:27:05 +00:00
return $ self ;
}
2012-06-18 12:29:47 +00:00
package Slic3r::GUI::Tab::Filament ;
use Wx qw( :sizer :progressdialog ) ;
use Wx::Event qw( ) ;
use base 'Slic3r::GUI::Tab' ;
sub new {
my $ class = shift ;
2012-06-19 15:23:10 +00:00
my ( $ parent , % params ) = @ _ ;
my $ self = $ class - > SUPER:: new ( $ parent , % params ) ;
2012-06-18 12:29:47 +00:00
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Filament' , 'spool.png' , optgroups = > [
2012-06-18 12:29:47 +00:00
{
title = > 'Filament' ,
options = > [ qw( filament_diameter extrusion_multiplier ) ] ,
} ,
{
title = > 'Temperature' ,
options = > [ qw( temperature first_layer_temperature bed_temperature first_layer_bed_temperature ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Cooling' , 'hourglass.png' , optgroups = > [
2012-06-18 12:29:47 +00:00
{
title = > 'Enable' ,
options = > [ qw( cooling ) ] ,
} ,
{
title = > 'Fan settings' ,
options = > [ qw( min_fan_speed max_fan_speed bridge_fan_speed disable_fan_first_layers fan_always_on ) ] ,
} ,
{
title = > 'Cooling thresholds' ,
label_width = > 250 ,
options = > [ qw( fan_below_layer_time slowdown_below_layer_time min_print_speed ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > load_presets ( 'filament' ) ;
2012-06-18 12:29:47 +00:00
return $ self ;
}
2012-06-17 20:27:05 +00:00
package Slic3r::GUI::Tab::Printer ;
use Wx qw( :sizer :progressdialog ) ;
use Wx::Event qw( ) ;
use base 'Slic3r::GUI::Tab' ;
sub new {
my $ class = shift ;
2012-06-19 15:23:10 +00:00
my ( $ parent , % params ) = @ _ ;
my $ self = $ class - > SUPER:: new ( $ parent , % params ) ;
2012-06-17 20:27:05 +00:00
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'General' , 'printer_empty.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Size and coordinates' ,
options = > [ qw( bed_size print_center z_offset ) ] ,
} ,
{
title = > 'Firmware' ,
options = > [ qw( gcode_flavor use_relative_e_distances ) ] ,
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Extruder 1' , 'funnel.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
title = > 'Size' ,
options = > [ qw( nozzle_diameter ) ] ,
} ,
{
2012-06-18 12:29:47 +00:00
title = > 'Retraction' ,
options = > [ qw( retract_length retract_lift retract_speed retract_restart_extra retract_before_travel ) ] ,
2012-06-17 20:27:05 +00:00
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > add_options_page ( 'Custom G-code' , 'cog.png' , optgroups = > [
2012-06-17 20:27:05 +00:00
{
2012-06-17 21:24:10 +00:00
title = > 'Start G-code' ,
no_labels = > 1 ,
options = > [ qw( start_gcode ) ] ,
} ,
{
title = > 'End G-code' ,
no_labels = > 1 ,
options = > [ qw( end_gcode ) ] ,
} ,
{
title = > 'Layer change G-code' ,
no_labels = > 1 ,
options = > [ qw( layer_gcode ) ] ,
2012-06-17 20:27:05 +00:00
} ,
] ) ;
2012-06-18 20:27:57 +00:00
$ self - > load_presets ( 'printer' ) ;
2012-06-17 20:27:05 +00:00
return $ self ;
}
package Slic3r::GUI::Tab::Page ;
use Wx qw( :sizer :progressdialog ) ;
use Wx::Event qw( ) ;
2012-06-18 09:26:21 +00:00
use base 'Wx::ScrolledWindow' ;
2012-06-17 20:27:05 +00:00
sub new {
my $ class = shift ;
my ( $ parent , % params ) = @ _ ;
my $ self = $ class - > SUPER:: new ( $ parent , - 1 ) ;
2012-06-18 09:26:21 +00:00
$ self - > SetScrollbars ( 1 , 1 , 1 , 1 ) ;
2012-06-17 20:27:05 +00:00
$ self - > { vsizer } = Wx::BoxSizer - > new ( & Wx:: wxVERTICAL ) ;
$ self - > SetSizer ( $ self - > { vsizer } ) ;
if ( $ params { optgroups } ) {
2012-06-18 20:27:57 +00:00
$ self - > append_optgroup ( %$ _ , on_change = > $ params { on_change } ) for @ { $ params { optgroups } } ;
2012-06-17 20:27:05 +00:00
}
return $ self ;
}
sub append_optgroup {
my $ self = shift ;
2012-06-18 09:26:21 +00:00
my $ optgroup = Slic3r::GUI::OptionsGroup - > new ( $ self , label_width = > 200 , @ _ ) ;
2012-06-17 20:27:05 +00:00
$ self - > { vsizer } - > Add ( $ optgroup , 0 , wxEXPAND | wxALL , 5 ) ;
}
2012-06-18 20:27:57 +00:00
package Slic3r::GUI::SavePresetWindow ;
use Wx qw( :sizer ) ;
use Wx::Event qw( EVT_BUTTON ) ;
use base 'Wx::Dialog' ;
sub new {
my $ class = shift ;
my ( $ parent , % params ) = @ _ ;
my $ self = $ class - > SUPER:: new ( $ parent , - 1 , "Save preset" , [ - 1 , - 1 ] , [ - 1 , - 1 ] ) ;
my $ text = Wx::StaticText - > new ( $ self , - 1 , "Save settings as:" , [ - 1 , - 1 ] , [ - 1 , - 1 ] ) ;
my $ combo = Wx::ComboBox - > new ( $ self , - 1 , $ params { default } , [ - 1 , - 1 ] , [ - 1 , - 1 ] , $ params { values } ) ;
my $ buttons = $ self - > CreateStdDialogButtonSizer ( & Wx:: wxOK | & Wx:: wxCANCEL ) ;
my $ sizer = Wx::BoxSizer - > new ( wxVERTICAL ) ;
$ sizer - > Add ( $ text , 0 , wxEXPAND | wxTOP | wxLEFT | wxRIGHT , 10 ) ;
$ sizer - > Add ( $ combo , 0 , wxEXPAND | wxLEFT | wxRIGHT , 10 ) ;
$ sizer - > Add ( $ buttons , 0 , wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT , 10 ) ;
EVT_BUTTON ( $ self , & Wx:: wxID_OK , sub {
if ( ( $ self - > { chosen_name } = $ combo - > GetValue ) && $ self - > { chosen_name } =~ /^[a-z0-9 _-]+$/i ) {
2012-06-19 12:47:02 +00:00
$ self - > EndModal ( & Wx:: wxID_OK ) ;
2012-06-18 20:27:57 +00:00
}
} ) ;
$ self - > SetSizer ( $ sizer ) ;
$ sizer - > SetSizeHints ( $ self ) ;
return $ self ;
}
sub get_name {
my $ self = shift ;
return $ self - > { chosen_name } ;
}
2012-06-17 20:27:05 +00:00
1 ;