diff --git a/MANIFEST b/MANIFEST index 181a9db4..4081339c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -32,6 +32,7 @@ lib/Slic3r/GUI/AboutDialog.pm lib/Slic3r/GUI/ConfigWizard.pm lib/Slic3r/GUI/OptionsGroup.pm lib/Slic3r/GUI/Plater.pm +lib/Slic3r/GUI/Plater/ObjectDialog.pm lib/Slic3r/GUI/Preferences.pm lib/Slic3r/GUI/SkeinPanel.pm lib/Slic3r/GUI/SimpleTab.pm diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 6e49302c..ceb6adbb 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -7,6 +7,7 @@ use FindBin; use Slic3r::GUI::AboutDialog; use Slic3r::GUI::ConfigWizard; use Slic3r::GUI::Plater; +use Slic3r::GUI::Plater::ObjectDialog; use Slic3r::GUI::Preferences; use Slic3r::GUI::OptionsGroup; use Slic3r::GUI::SkeinPanel; diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d52298ea..58f30d65 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -975,7 +975,7 @@ sub list_item_activated { my ($self, $event, $obj_idx) = @_; $obj_idx //= $event->GetIndex; - my $dlg = Slic3r::GUI::Plater::ObjectInfoDialog->new($self, + my $dlg = Slic3r::GUI::Plater::ObjectDialog->new($self, object => $self->{objects}[$obj_idx], ); $dlg->ShowModal; @@ -1173,59 +1173,4 @@ sub set_scale { $self->scale($scale); } -package Slic3r::GUI::Plater::ObjectInfoDialog; -use Wx qw(:dialog :id :misc :sizer :systemsettings); -use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER); -use base 'Wx::Dialog'; - -sub new { - my $class = shift; - my ($parent, %params) = @_; - my $self = $class->SUPER::new($parent, -1, "Object Info", wxDefaultPosition, wxDefaultSize); - $self->{object} = $params{object}; - - my $properties_box = Wx::StaticBox->new($self, -1, "Info", wxDefaultPosition, [400,200]); - my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 10, 5); - $properties_box->SetSizer($grid_sizer); - $grid_sizer->SetFlexibleDirection(wxHORIZONTAL); - $grid_sizer->AddGrowableCol(1); - - my $label_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - $label_font->SetPointSize(10); - - my $properties = $self->get_properties; - foreach my $property (@$properties) { - my $label = Wx::StaticText->new($properties_box, -1, $property->[0] . ":"); - my $value = Wx::StaticText->new($properties_box, -1, $property->[1]); - $label->SetFont($label_font); - $grid_sizer->Add($label, 1, wxALIGN_BOTTOM); - $grid_sizer->Add($value, 0); - } - - my $buttons = $self->CreateStdDialogButtonSizer(wxOK); - EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); }); - - my $sizer = Wx::BoxSizer->new(wxVERTICAL); - $sizer->Add($properties_box, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10); - $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); - - $self->SetSizer($sizer); - $sizer->SetSizeHints($self); - - return $self; -} - -sub get_properties { - my $self = shift; - - return [ - ['Name' => $self->{object}->name], - ['Size' => sprintf "%.2f x %.2f x %.2f", @{$self->{object}->size}], - ['Facets' => $self->{object}->facets], - ['Vertices' => $self->{object}->vertices], - ['Materials' => $self->{object}->materials], - ['Two-Manifold' => $self->{object}->is_manifold ? 'Yes' : 'No'], - ]; -} - 1; diff --git a/lib/Slic3r/GUI/Plater/ObjectDialog.pm b/lib/Slic3r/GUI/Plater/ObjectDialog.pm new file mode 100644 index 00000000..d55b36a8 --- /dev/null +++ b/lib/Slic3r/GUI/Plater/ObjectDialog.pm @@ -0,0 +1,56 @@ +package Slic3r::GUI::Plater::ObjectDialog; +use Wx qw(:dialog :id :misc :sizer :systemsettings); +use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER); +use base 'Wx::Dialog'; + +sub new { + my $class = shift; + my ($parent, %params) = @_; + my $self = $class->SUPER::new($parent, -1, "Object Info", wxDefaultPosition, wxDefaultSize); + $self->{object} = $params{object}; + + my $properties_box = Wx::StaticBox->new($self, -1, "Info", wxDefaultPosition, [400,200]); + my $grid_sizer = Wx::FlexGridSizer->new(3, 2, 10, 5); + $properties_box->SetSizer($grid_sizer); + $grid_sizer->SetFlexibleDirection(wxHORIZONTAL); + $grid_sizer->AddGrowableCol(1); + + my $label_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + $label_font->SetPointSize(10); + + my $properties = $self->get_properties; + foreach my $property (@$properties) { + my $label = Wx::StaticText->new($properties_box, -1, $property->[0] . ":"); + my $value = Wx::StaticText->new($properties_box, -1, $property->[1]); + $label->SetFont($label_font); + $grid_sizer->Add($label, 1, wxALIGN_BOTTOM); + $grid_sizer->Add($value, 0); + } + + my $buttons = $self->CreateStdDialogButtonSizer(wxOK); + EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); }); + + my $sizer = Wx::BoxSizer->new(wxVERTICAL); + $sizer->Add($properties_box, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10); + $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); + + $self->SetSizer($sizer); + $sizer->SetSizeHints($self); + + return $self; +} + +sub get_properties { + my $self = shift; + + return [ + ['Name' => $self->{object}->name], + ['Size' => sprintf "%.2f x %.2f x %.2f", @{$self->{object}->size}], + ['Facets' => $self->{object}->facets], + ['Vertices' => $self->{object}->vertices], + ['Materials' => $self->{object}->materials], + ['Two-Manifold' => $self->{object}->is_manifold ? 'Yes' : 'No'], + ]; +} + +1;