Completed parts visualization with highlighting

This commit is contained in:
Alessandro Ranellucci 2014-01-17 20:16:54 +01:00
parent 3f4f27fa5d
commit b20caa4e31
3 changed files with 20 additions and 11 deletions

View File

@ -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 ($nodeId->IsOk) {
my $itemData = $tree->GetPlData($nodeId);
if ($itemData && $itemData->{type} eq 'volume') {
$canvas->volumes->[ $itemData->{volume_id} ]{selected} = 1;
} else {
$_->{selected} = 0 for @{$canvas->volumes};
}
}
$canvas->Render;
});

View File

@ -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 File

@ -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;