Use a plain list instead of a tree to display object parts
This commit is contained in:
parent
cfc1c5037d
commit
bf307371f4
@ -20,9 +20,9 @@ sub new {
|
|||||||
my $object = $self->{model_object} = $params{model_object};
|
my $object = $self->{model_object} = $params{model_object};
|
||||||
|
|
||||||
# create TreeCtrl
|
# create TreeCtrl
|
||||||
my $tree = $self->{tree} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [200, 200],
|
my $tree = $self->{tree} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [300, 100],
|
||||||
wxTR_NO_BUTTONS | wxSUNKEN_BORDER | wxTR_HAS_VARIABLE_ROW_HEIGHT | wxTR_HIDE_ROOT
|
wxTR_NO_BUTTONS | wxSUNKEN_BORDER | wxTR_HAS_VARIABLE_ROW_HEIGHT | wxTR_HIDE_ROOT
|
||||||
| wxTR_MULTIPLE | wxTR_NO_BUTTONS);
|
| wxTR_MULTIPLE | wxTR_NO_BUTTONS | wxTR_NO_LINES);
|
||||||
{
|
{
|
||||||
$self->{tree_icons} = Wx::ImageList->new(16, 16, 1);
|
$self->{tree_icons} = Wx::ImageList->new(16, 16, 1);
|
||||||
$tree->AssignImageList($self->{tree_icons});
|
$tree->AssignImageList($self->{tree_icons});
|
||||||
@ -91,27 +91,21 @@ sub reload_tree {
|
|||||||
|
|
||||||
$tree->DeleteChildren($rootId);
|
$tree->DeleteChildren($rootId);
|
||||||
|
|
||||||
my %nodes = (); # material_id => nodeId
|
|
||||||
foreach my $volume_id (0..$#{$object->volumes}) {
|
foreach my $volume_id (0..$#{$object->volumes}) {
|
||||||
my $volume = $object->volumes->[$volume_id];
|
my $volume = $object->volumes->[$volume_id];
|
||||||
my $material_id = $volume->material_id;
|
|
||||||
$material_id //= '_';
|
|
||||||
|
|
||||||
if (!exists $nodes{$material_id}) {
|
my $material_id = $volume->material_id // '_';
|
||||||
my $material_name = $material_id eq '_'
|
my $material_name = $material_id eq '_'
|
||||||
? 'default'
|
? sprintf("Part #%d", $volume_id+1)
|
||||||
: $object->model->get_material_name($material_id);
|
: $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 $icon = $volume->modifier ? ICON_MODIFIERMESH : ICON_SOLIDMESH;
|
||||||
my $itemId = $tree->AppendItem($nodes{$material_id}, $name, $icon);
|
my $itemId = $tree->AppendItem($rootId, $material_name, $icon);
|
||||||
$tree->SetPlData($itemId, {
|
$tree->SetPlData($itemId, {
|
||||||
type => 'volume',
|
type => 'volume',
|
||||||
volume_id => $volume_id,
|
volume_id => $volume_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$tree->ExpandAll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_selection {
|
sub get_selection {
|
||||||
|
@ -10,7 +10,7 @@ use base 'Wx::Dialog';
|
|||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($parent, %params) = @_;
|
my ($parent, %params) = @_;
|
||||||
my $self = $class->SUPER::new($parent, -1, "Settings for " . $params{object}->name, wxDefaultPosition, [500,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
my $self = $class->SUPER::new($parent, -1, "Settings for " . $params{object}->name, wxDefaultPosition, [700,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||||
$self->{$_} = $params{$_} for keys %params;
|
$self->{$_} = $params{$_} for keys %params;
|
||||||
|
|
||||||
$self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
|
$self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
|
||||||
|
Loading…
Reference in New Issue
Block a user