2011-10-03 09:55:32 +00:00
|
|
|
package Slic3r::GUI;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2012-03-11 18:59:09 +00:00
|
|
|
use utf8;
|
2011-10-03 09:55:32 +00:00
|
|
|
|
2012-04-07 18:45:02 +00:00
|
|
|
use FindBin;
|
2012-04-30 12:56:01 +00:00
|
|
|
use Slic3r::GUI::Dashboard;
|
2011-10-03 09:55:32 +00:00
|
|
|
use Slic3r::GUI::OptionsGroup;
|
|
|
|
use Slic3r::GUI::SkeinPanel;
|
|
|
|
|
2011-11-05 17:19:35 +00:00
|
|
|
use Wx 0.9901 qw(:sizer :frame wxID_EXIT wxID_ABOUT);
|
2011-10-03 09:55:32 +00:00
|
|
|
use Wx::Event qw(EVT_MENU);
|
|
|
|
use base 'Wx::App';
|
|
|
|
|
|
|
|
sub OnInit {
|
|
|
|
my $self = shift;
|
|
|
|
|
2012-02-23 20:51:45 +00:00
|
|
|
$self->SetAppName('Slic3r');
|
2011-10-03 09:55:32 +00:00
|
|
|
|
|
|
|
my $frame = Wx::Frame->new( undef, -1, 'Slic3r', [-1, -1], Wx::wxDefaultSize,
|
|
|
|
wxDEFAULT_FRAME_STYLE ^ (wxRESIZE_BORDER | wxMAXIMIZE_BOX) );
|
2012-04-16 18:28:29 +00:00
|
|
|
#$frame->SetIcon(Wx::Icon->new("$FindBin::Bin/var/Slic3r.png", &Wx::wxBITMAP_TYPE_ANY) );
|
2011-10-03 09:55:32 +00:00
|
|
|
|
2011-12-22 16:38:37 +00:00
|
|
|
my $panel = Slic3r::GUI::SkeinPanel->new($frame);
|
|
|
|
my $box = Wx::BoxSizer->new(wxVERTICAL);
|
|
|
|
$box->Add($panel, 0);
|
|
|
|
|
2011-10-03 09:55:32 +00:00
|
|
|
# menubar
|
|
|
|
my $menubar = Wx::MenuBar->new;
|
|
|
|
$frame->SetMenuBar($menubar);
|
|
|
|
EVT_MENU($frame, wxID_EXIT, sub {$_[0]->Close(1)});
|
|
|
|
EVT_MENU($frame, wxID_ABOUT, \&About);
|
|
|
|
|
2011-12-22 16:38:37 +00:00
|
|
|
# File menu
|
|
|
|
my $fileMenu = Wx::Menu->new;
|
2012-03-03 21:53:12 +00:00
|
|
|
$fileMenu->Append(1, "Save Config…");
|
|
|
|
$fileMenu->Append(2, "Open Config…");
|
|
|
|
$fileMenu->AppendSeparator();
|
|
|
|
$fileMenu->Append(3, "Slice…");
|
2012-03-12 17:52:23 +00:00
|
|
|
$fileMenu->Append(4, "Reslice");
|
|
|
|
$fileMenu->Append(5, "Slice and Save As…");
|
2012-03-26 15:57:54 +00:00
|
|
|
$fileMenu->Append(6, "Export SVG…");
|
2012-04-30 20:23:43 +00:00
|
|
|
$fileMenu->AppendSeparator();
|
|
|
|
$fileMenu->Append(&Wx::wxID_EXIT, "&Quit");
|
2011-12-22 16:38:37 +00:00
|
|
|
$menubar->Append($fileMenu, "&File");
|
2012-03-03 21:53:12 +00:00
|
|
|
EVT_MENU($frame, 1, sub { $panel->save_config });
|
|
|
|
EVT_MENU($frame, 2, sub { $panel->load_config });
|
|
|
|
EVT_MENU($frame, 3, sub { $panel->do_slice });
|
2012-03-12 17:52:23 +00:00
|
|
|
EVT_MENU($frame, 4, sub { $panel->do_slice(reslice => 1) });
|
|
|
|
EVT_MENU($frame, 5, sub { $panel->do_slice(save_as => 1) });
|
2012-03-26 15:57:54 +00:00
|
|
|
EVT_MENU($frame, 6, sub { $panel->do_slice(save_as => 1, export_svg => 1) });
|
2011-10-03 09:55:32 +00:00
|
|
|
|
2011-10-03 11:08:43 +00:00
|
|
|
$box->SetSizeHints($frame);
|
|
|
|
$frame->SetSizer($box);
|
2011-10-03 09:55:32 +00:00
|
|
|
$frame->Show;
|
2011-10-03 11:08:43 +00:00
|
|
|
$frame->Layout;
|
|
|
|
|
|
|
|
return 1;
|
2011-10-03 09:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub About {
|
|
|
|
my $frame = shift;
|
|
|
|
|
|
|
|
my $info = Wx::AboutDialogInfo->new;
|
|
|
|
$info->SetName('Slic3r');
|
|
|
|
$info->AddDeveloper('Alessandro Ranellucci');
|
|
|
|
|
|
|
|
Wx::AboutBox($info);
|
|
|
|
}
|
|
|
|
|
2012-04-30 12:56:01 +00:00
|
|
|
sub catch_error {
|
|
|
|
my ($self, $cb) = @_;
|
|
|
|
if (my $err = $@) {
|
|
|
|
$cb->() if $cb;
|
|
|
|
Wx::MessageDialog->new($self, $err, 'Error', &Wx::wxOK | &Wx::wxICON_ERROR)->ShowModal;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub warning_catcher {
|
|
|
|
my ($self) = @_;
|
|
|
|
return sub {
|
|
|
|
my $message = shift;
|
|
|
|
Wx::MessageDialog->new($self, $message, 'Warning', &Wx::wxOK | &Wx::wxICON_WARNING)->ShowModal;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-10-03 09:55:32 +00:00
|
|
|
1;
|