Skip to content

Commit

Permalink
Completed parts visualization with highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Jan 22, 2014
1 parent 3f4f27f commit b20caa4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
23 changes: 15 additions & 8 deletions lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -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;
});


Expand Down
6 changes: 5 additions & 1 deletion lib/Slic3r/GUI/SkeinPanel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions lib/Slic3r/Model.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b20caa4

Please sign in to comment.