Welcome to mirror list, hosted at ThFree Co, Russian Federation.

3D.pm « Plater « GUI « Slic3r « lib - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f83e0f577ca14042867e230a01d7db780eacb41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package Slic3r::GUI::Plater::3D;
use strict;
use warnings;
use utf8;

use List::Util qw();
use Wx qw(:misc :pen :brush :sizer :font :cursor :keycode wxTAB_TRAVERSAL);
#==============================================================================================================================
#use Wx::Event qw(EVT_KEY_DOWN EVT_CHAR);
#==============================================================================================================================
use base qw(Slic3r::GUI::3DScene Class::Accessor);

#==============================================================================================================================
#use Wx::Locale gettext => 'L';
#
#__PACKAGE__->mk_accessors(qw(
#    on_arrange on_rotate_object_left on_rotate_object_right on_scale_object_uniformly
#    on_remove_object on_increase_objects on_decrease_objects on_enable_action_buttons));
#==============================================================================================================================

sub new {
    my $class = shift;
    my ($parent, $objects, $model, $print, $config) = @_;
    
    my $self = $class->SUPER::new($parent);
#==============================================================================================================================
    Slic3r::GUI::_3DScene::enable_picking($self, 1);
    Slic3r::GUI::_3DScene::enable_moving($self, 1);
    Slic3r::GUI::_3DScene::set_select_by($self, 'object');
    Slic3r::GUI::_3DScene::set_drag_by($self, 'instance');
    Slic3r::GUI::_3DScene::set_model($self, $model);
    Slic3r::GUI::_3DScene::set_print($self, $print);
    Slic3r::GUI::_3DScene::set_config($self, $config);
#    $self->enable_picking(1);
#    $self->enable_moving(1);
#    $self->select_by('object');
#    $self->drag_by('instance');
#    
#    $self->{objects}            = $objects;
#    $self->{model}              = $model;
#    $self->{print}              = $print;
#    $self->{config}             = $config;
#    $self->{on_select_object}   = sub {};
#    $self->{on_instances_moved} = sub {};
#    $self->{on_wipe_tower_moved} = sub {};
#
#    $self->{objects_volumes_idxs} = [];
#
#    $self->on_select(sub {
#        my ($volume_idx) = @_;
#        $self->{on_select_object}->(($volume_idx == -1) ? undef : $self->volumes->[$volume_idx]->object_idx)
#            if ($self->{on_select_object});
#    });
#
#    $self->on_move(sub {
#        my @volume_idxs = @_;
#        my %done = ();  # prevent moving instances twice
#        my $object_moved;
#        my $wipe_tower_moved;
#        foreach my $volume_idx (@volume_idxs) {
#            my $volume = $self->volumes->[$volume_idx];
#            my $obj_idx = $volume->object_idx;
#            my $instance_idx = $volume->instance_idx;
#            next if $done{"${obj_idx}_${instance_idx}"};
#            $done{"${obj_idx}_${instance_idx}"} = 1;
#            if ($obj_idx < 1000) {
#                # Move a regular object.
#                my $model_object = $self->{model}->get_object($obj_idx);
#                $model_object
#                    ->instances->[$instance_idx]
#                    ->offset
#                    ->translate($volume->origin->x, $volume->origin->y); #))
#                $model_object->invalidate_bounding_box;
#                $object_moved = 1;
#            } elsif ($obj_idx == 1000) {
#                # Move a wipe tower proxy.
#                $wipe_tower_moved = $volume->origin;
#            }
#        }
#        
#        $self->{on_instances_moved}->()
#            if $object_moved && $self->{on_instances_moved};
#        $self->{on_wipe_tower_moved}->($wipe_tower_moved)
#            if $wipe_tower_moved && $self->{on_wipe_tower_moved};
#    });
#
#    EVT_KEY_DOWN($self, sub {
#        my ($s, $event) = @_;
#        if ($event->HasModifiers) {
#            $event->Skip;
#        } else {
#            my $key = $event->GetKeyCode;
#            if ($key == WXK_DELETE) {
#                $self->on_remove_object->() if $self->on_remove_object;
#            } else {
#                $event->Skip;
#            }
#        }
#    });
#
#    EVT_CHAR($self, sub {
#        my ($s, $event) = @_;
#        if ($event->HasModifiers) {
#            $event->Skip;
#        } else {
#            my $key = $event->GetKeyCode;
#            if ($key == ord('a')) {
#                $self->on_arrange->() if $self->on_arrange;
#            } elsif ($key == ord('l')) {
#                $self->on_rotate_object_left->() if $self->on_rotate_object_left;
#            } elsif ($key == ord('r')) {
#                $self->on_rotate_object_right->() if $self->on_rotate_object_right;
#            } elsif ($key == ord('s')) {
#                $self->on_scale_object_uniformly->() if $self->on_scale_object_uniformly;
#            } elsif ($key == ord('+')) {
#                $self->on_increase_objects->() if $self->on_increase_objects;
#            } elsif ($key == ord('-')) {
#                $self->on_decrease_objects->() if $self->on_decrease_objects;
#            } else {
#                $event->Skip;
#            }
#        }
#    });
#==============================================================================================================================
    
    return $self;
}

#==============================================================================================================================
#sub set_on_select_object {
#    my ($self, $cb) = @_;
#    $self->{on_select_object} = $cb;
#}
#
#sub set_on_double_click {
#    my ($self, $cb) = @_;
#    $self->on_double_click($cb);
#}
#
#sub set_on_right_click {
#    my ($self, $cb) = @_;
#    $self->on_right_click($cb);
#}
#
#sub set_on_arrange {
#    my ($self, $cb) = @_;
#    $self->on_arrange($cb);
#}
#
#sub set_on_rotate_object_left {
#    my ($self, $cb) = @_;
#    $self->on_rotate_object_left($cb);
#}
#
#sub set_on_rotate_object_right {
#    my ($self, $cb) = @_;
#    $self->on_rotate_object_right($cb);
#}
#
#sub set_on_scale_object_uniformly {
#    my ($self, $cb) = @_;
#    $self->on_scale_object_uniformly($cb);
#}
#
#sub set_on_increase_objects {
#    my ($self, $cb) = @_;
#    $self->on_increase_objects($cb);
#}
#
#sub set_on_decrease_objects {
#    my ($self, $cb) = @_;
#    $self->on_decrease_objects($cb);
#}
#
#sub set_on_remove_object {
#    my ($self, $cb) = @_;
#    $self->on_remove_object($cb);
#}
#
#sub set_on_instances_moved {
#    my ($self, $cb) = @_;
#    $self->{on_instances_moved} = $cb;
#}
#
#sub set_on_wipe_tower_moved {
#    my ($self, $cb) = @_;
#    $self->{on_wipe_tower_moved} = $cb;
#}
#
#sub set_on_model_update {
#    my ($self, $cb) = @_;
#    $self->on_model_update($cb);
#}
#
#sub set_on_enable_action_buttons {
#    my ($self, $cb) = @_;
#    $self->on_enable_action_buttons($cb);
#}
#
#sub update_volumes_selection {
#    my ($self) = @_;
#
#    foreach my $obj_idx (0..$#{$self->{model}->objects}) {
#        if ($self->{objects}[$obj_idx]->selected) {
#            my $volume_idxs = $self->{objects_volumes_idxs}->[$obj_idx];
#            $self->select_volume($_) for @{$volume_idxs};
#        }
#    }
#}
#
#sub reload_scene {
#    my ($self, $force) = @_;
#
#    $self->reset_objects;
#    $self->update_bed_size;
#
#    if (! $self->IsShown && ! $force) {
#        $self->{reload_delayed} = 1;
#        return;
#    }
#
#    $self->{reload_delayed} = 0;
#
#    $self->{objects_volumes_idxs} = [];    
#    foreach my $obj_idx (0..$#{$self->{model}->objects}) {
#        my @volume_idxs = $self->load_object($self->{model}, $self->{print}, $obj_idx);
#        push(@{$self->{objects_volumes_idxs}}, \@volume_idxs);
#    }
#    
#    $self->update_volumes_selection;
#        
#    if (defined $self->{config}->nozzle_diameter) {
#        # Should the wipe tower be visualized?
#        my $extruders_count = scalar @{ $self->{config}->nozzle_diameter };
#        # Height of a print.
#        my $height = $self->{model}->bounding_box->z_max;
#        # Show at least a slab.
#        $height = 10 if $height < 10;
#        if ($extruders_count > 1 && $self->{config}->single_extruder_multi_material && $self->{config}->wipe_tower &&
#            ! $self->{config}->complete_objects) {
#            $self->volumes->load_wipe_tower_preview(1000, 
#                $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, $self->{config}->wipe_tower_width,
#		#$self->{config}->wipe_tower_per_color_wipe# 15 * ($extruders_count - 1), # this is just a hack when the config parameter became obsolete
#		15 * ($extruders_count - 1),
#                $self->{model}->bounding_box->z_max, $self->{config}->wipe_tower_rotation_angle, $self->UseVBOs);
#        }
#    }
#
#    $self->update_volumes_colors_by_extruder($self->{config});
#    
#    # checks for geometry outside the print volume to render it accordingly
#    if (scalar @{$self->volumes} > 0)
#    {
#        my $contained = $self->volumes->check_outside_state($self->{config});
#        if (!$contained) {
#            $self->set_warning_enabled(1);
#            Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume"));
#            $self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons);
#        } else {
#            $self->set_warning_enabled(0);
#            $self->volumes->reset_outside_state();
#            Slic3r::GUI::_3DScene::reset_warning_texture();
#            $self->on_enable_action_buttons->(scalar @{$self->{model}->objects} > 0) if ($self->on_enable_action_buttons);
#        }
#    } else {
#        $self->set_warning_enabled(0);
#        Slic3r::GUI::_3DScene::reset_warning_texture();
#    }
#}
#
#sub update_bed_size {
#    my ($self) = @_;
#    $self->set_bed_shape($self->{config}->bed_shape);
#}
#
## Called by the Platter wxNotebook when this page is activated.
#sub OnActivate {
#    my ($self) = @_;
#    $self->reload_scene(1) if ($self->{reload_delayed});
#}
#==============================================================================================================================

1;