Skip to content
Browse files

Completed parts visualization with highlighting

  • Loading branch information...
1 parent 3f4f27f commit b20caa4e31e1bf296162166a25a79cfda275f0ea @alexrj committed Jan 17, 2014
Showing with 20 additions and 11 deletions.
  1. +15 −8 lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
  2. +5 −1 lib/Slic3r/GUI/SkeinPanel.pm
  3. +0 −2 lib/Slic3r/Model.pm
View
23 lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
@@ -37,12 +37,15 @@ sub new {
$material_id //= '_';
if (!exists $nodes{$material_id}) {
- $nodes{$material_id} = $tree->AppendItem($rootId, $object->model->get_material_name($material_id), ICON_MATERIAL);
+ my $material_name = $material_id eq ''
+ ? 'default'
+ : $object->model->get_material_name($material_id);
+ $nodes{$material_id} = $tree->AppendItem($rootId, "Material: $material_name", ICON_MATERIAL);
}
my $name = $volume->modifier ? 'Modifier mesh' : 'Solid mesh';
my $icon = $volume->modifier ? ICON_MODIFIERMESH : ICON_SOLIDMESH;
my $itemId = $tree->AppendItem($nodes{$material_id}, $name, $icon);
- $tree->SetItemData($itemId, {
+ $tree->SetPlData($itemId, {
type => 'volume',
volume_id => $volume_id,
});
@@ -73,14 +76,18 @@ sub new {
EVT_TREE_SEL_CHANGED($self, $tree, sub {
my ($self, $event) = @_;
+ # deselect all meshes
+ $_->{selected} = 0 for @{$canvas->volumes};
+
my $nodeId = $tree->GetSelection;
- printf "nodeId = %s\n", $nodeId;
- my $itemData = $tree->GetItemData($nodeId);
- if ($itemData && $itemData->{type} eq 'volume') {
- $canvas->volumes->[ $itemData->{volume_id} ]{selected} = 1;
- } else {
- $_->{selected} = 0 for @{$canvas->volumes};
+ if ($nodeId->IsOk) {
+ my $itemData = $tree->GetPlData($nodeId);
+ if ($itemData && $itemData->{type} eq 'volume') {
+ $canvas->volumes->[ $itemData->{volume_id} ]{selected} = 1;
+ }
}
+
+ $canvas->Render;
});
View
6 lib/Slic3r/GUI/SkeinPanel.pm
@@ -355,7 +355,11 @@ sub combine_stls {
my $new_object = $new_model->add_object;
for my $m (0 .. $#models) {
my $model = $models[$m];
- $new_model->set_material($m, { Name => basename($input_files[$m]) });
+
+ my $material_name = basename($input_files[$m]);
+ $material_name =~ s/\.(stl|obj)$//i;
+
+ $new_model->set_material($m, { Name => $material_name });
$new_object->add_volume(
material_id => $m,
mesh => $model->objects->[0]->volumes->[0]->mesh,
View
2 lib/Slic3r/Model.pm
@@ -296,8 +296,6 @@ sub get_material_name {
my $name;
if (exists $self->materials->{$material_id}) {
$name //= $self->materials->{$material_id}->attributes->{$_} for qw(Name name);
- } elsif ($material_id eq '_') {
- $name = 'Default material';
}
$name //= $material_id;
return $name;

0 comments on commit b20caa4

Please sign in to comment.
Something went wrong with that request. Please try again.