mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 02:07:54 -06:00
Revert incorrect checkins.
This commit is contained in:
parent
ed83ff37f8
commit
3ba625da22
10 changed files with 22 additions and 122 deletions
|
@ -5,9 +5,6 @@ package Slic3r::GUI::Plater::2DToolpaths;
|
|||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use Data::Dumper qw(Dumper);
|
||||
#use Carp qw(confess);
|
||||
use Carp;
|
||||
|
||||
use Slic3r::Print::State ':steps';
|
||||
use Wx qw(:misc :sizer :slider :statictext :keycode wxWHITE wxWANTS_CHARS);
|
||||
|
@ -54,10 +51,6 @@ sub new {
|
|||
});
|
||||
EVT_KEY_DOWN($canvas, sub {
|
||||
my ($s, $event) = @_;
|
||||
|
||||
print "Slic3r::GUI::Plater::2DToolpaths: Getting key ", $event->GetKeyCode, "\n";
|
||||
# print Dumper(\$event);
|
||||
|
||||
my $key = $event->GetKeyCode;
|
||||
if ($key == 85 || $key == WXK_LEFT) {
|
||||
# Keys: 'D' or WXK_LEFT
|
||||
|
@ -130,10 +123,8 @@ sub set_z {
|
|||
|
||||
package Slic3r::GUI::Plater::2DToolpaths::Canvas;
|
||||
|
||||
use Wx qw(:misc wxWANTS_CHARS);
|
||||
use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS EVT_KEY_DOWN);
|
||||
use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS);
|
||||
use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
|
||||
use OpenGL::Shader;
|
||||
use base qw(Wx::GLCanvas Class::Accessor);
|
||||
use Wx::GLCanvas qw(:all);
|
||||
use List::Util qw(min max first);
|
||||
|
@ -163,20 +154,17 @@ __PACKAGE__->mk_accessors(qw(
|
|||
sub new {
|
||||
my ($class, $parent, $print) = @_;
|
||||
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
||||
my $self = $class->SUPER::new($parent);
|
||||
$self->print($print);
|
||||
$self->_zoom(1);
|
||||
|
||||
# 2D point in model space
|
||||
$self->_camera_target(Slic3r::Pointf->new(0,0));
|
||||
|
||||
# Texture for the extrusion simulator. The texture will be allocated / reallocated on Resize.
|
||||
# print "new\n";
|
||||
$self->_texture_name(0);
|
||||
$self->_texture_size(Slic3r::Point->new(0,0));
|
||||
$self->_extrusion_simulator(Slic3r::ExtrusionSimulator->new());
|
||||
$self->_simulation_mode(0);
|
||||
# print "new end\n";
|
||||
|
||||
EVT_PAINT($self, sub {
|
||||
my $dc = Wx::PaintDC->new($self);
|
||||
|
@ -228,17 +216,6 @@ sub new {
|
|||
$self->Refresh;
|
||||
});
|
||||
EVT_MOUSE_EVENTS($self, \&mouse_event);
|
||||
EVT_KEY_DOWN($self, sub {
|
||||
my ($s, $event) = @_;
|
||||
|
||||
print "Slic3r::GUI::Plater::2DToolpaths::Canvas: Getting key $event\n";
|
||||
|
||||
my $key = $event->GetKeyCode;
|
||||
if ($key > 45 && $key <= 50) {
|
||||
# Keys: '1' to '3'
|
||||
$self->set_simulation_mode($key - 45);
|
||||
}
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -267,7 +244,6 @@ sub mouse_event {
|
|||
if ($e->Entering && &Wx::wxMSW) {
|
||||
# wxMSW needs focus in order to catch mouse wheel events
|
||||
$self->SetFocus;
|
||||
print "Slic3r::GUI::Plater::2DToolpaths::Canvas SetFocus\n";
|
||||
} elsif ($e->Dragging) {
|
||||
if ($e->LeftIsDown || $e->MiddleIsDown || $e->RightIsDown) {
|
||||
# if dragging, translate view
|
||||
|
@ -343,14 +319,6 @@ sub Render {
|
|||
return unless my $context = $self->GetContext;
|
||||
$self->SetCurrent($context);
|
||||
$self->InitGL;
|
||||
|
||||
#print glGetString(GL_VERSION), "\n";
|
||||
#print glGetString(GL_VENDOR), "\n";
|
||||
#print glGetString(GL_RENDERER), "\n";
|
||||
# my $nExtensions = glGetInteger(GL_NUM_EXTENSIONS);
|
||||
# for (my $i = 0; $i < $nExtensions; ++ $i) {
|
||||
# print glGetStringi(GL_EXTENSIONS, $i);
|
||||
# }
|
||||
|
||||
glClearColor(1, 1, 1, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -366,12 +334,10 @@ sub Render {
|
|||
glLoadIdentity();
|
||||
|
||||
if ($self->_simulation_mode and $self->_texture_name and $self->_texture_size->x() > 0 and $self->_texture_size->y() > 0) {
|
||||
#print "draw\n";
|
||||
$self->_simulate_extrusion();
|
||||
my ($x, $y) = $self->GetSizeWH;
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_REPLACE);
|
||||
#print "Texture name ", $self->_texture_name, "\n";
|
||||
glBindTexture(GL_TEXTURE_2D, $self->_texture_name);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
@ -401,7 +367,6 @@ sub Render {
|
|||
glEnd();
|
||||
glPopMatrix();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#print "draw end\n";
|
||||
}
|
||||
|
||||
# anti-alias
|
||||
|
@ -440,7 +405,7 @@ sub Render {
|
|||
glTranslatef(@$copy, 0);
|
||||
|
||||
foreach my $slice (@{$layer->slices}) {
|
||||
glColor3f(0.75, 0.75, 0.75);
|
||||
glColor3f(0.95, 0.95, 0.95);
|
||||
|
||||
if ($tess) {
|
||||
gluTessBeginPolygon($tess);
|
||||
|
@ -540,66 +505,43 @@ sub _draw_path {
|
|||
glPushMatrix();
|
||||
glTranslatef(@$copy, 0);
|
||||
foreach my $line (@{$path->polyline->lines}) {
|
||||
if (1) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
glEnd();
|
||||
} else {
|
||||
my @c = $self->color;
|
||||
$self->line($line->a->x, $line->a->y, $line->b->x, $line->b->y, $path->width, $c[0], $c[1], $c[2], 0.5, 0, 0, 1);
|
||||
}
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
glEnd();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
} else {
|
||||
foreach my $line (@{$path->polyline->lines}) {
|
||||
if (1) {
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
glEnd();
|
||||
} else {
|
||||
my @c = $self->color;
|
||||
$self->line($line->a->x, $line->a->y, $line->b->x, $line->b->y, $path->width, $c[0], $c[1], $c[2], 0.5, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(@{$line->a});
|
||||
glVertex2f(@{$line->b});
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub _simulate_extrusion {
|
||||
#print "_simulate_extrusion";
|
||||
my ($self) = @_;
|
||||
$self->_extrusion_simulator->reset_accumulator();
|
||||
foreach my $layer (@{$self->layers}) {
|
||||
if (abs($layer->print_z - $self->z) < epsilon) {
|
||||
#print "_simulate_extrusion - print_z ", $layer->print_z, "\n";
|
||||
my $object = $layer->object;
|
||||
# print Dumper($object);
|
||||
my @shifts = (defined $object) ? @{$object->_shifted_copies} : (Slic3r::Point->new(0, 0));
|
||||
foreach my $layerm (@{$layer->regions}) {
|
||||
# print Dumper($layerm);
|
||||
my @extrusions = ();
|
||||
if ($object->step_done(STEP_PERIMETERS)) {
|
||||
#print "Perimeters: ", @{$layerm->perimeters}, "\n";
|
||||
# print Dumper(\@{$layerm->perimeters});
|
||||
push @extrusions, @$_ for @{$layerm->perimeters};
|
||||
}
|
||||
if ($object->step_done(STEP_INFILL)) {
|
||||
#print "Fills: ", @{$layerm->fills}, "\n";
|
||||
# print Dumper(\@{$layerm->fills});
|
||||
push @extrusions, @$_ for @{$layerm->fills};
|
||||
}
|
||||
# print Dumper(\@extrusions);
|
||||
foreach my $extrusion_entity (@extrusions) {
|
||||
#print "simulating an extrusion entity\n";
|
||||
my @paths = $extrusion_entity->isa('Slic3r::ExtrusionLoop')
|
||||
? @$extrusion_entity
|
||||
: ($extrusion_entity);
|
||||
foreach my $path (@paths) {
|
||||
#print "simulating a path\n";
|
||||
#print Data::Dumper->Dump([$path, @paths], [qw(foo *ary)]);
|
||||
# print Data::Dumper(\$path);
|
||||
print "width: ", $path->width,
|
||||
" height: ", $path->height,
|
||||
" mm3_per_mm: ", $path->mm3_per_mm,
|
||||
|
@ -620,13 +562,9 @@ sub InitGL {
|
|||
return if $self->init;
|
||||
return unless $self->GetContext;
|
||||
|
||||
#Vojtech: Create an OpenGL texture?
|
||||
#print "initgl\n";
|
||||
my $texture_id = 0;
|
||||
($texture_id) = glGenTextures_p(1);
|
||||
$self->_texture_name($texture_id);
|
||||
#print "initgl end\n";
|
||||
|
||||
$self->init(1);
|
||||
}
|
||||
|
||||
|
@ -660,7 +598,6 @@ sub Resize {
|
|||
$self->SetCurrent($self->GetContext);
|
||||
my ($x, $y) = $self->GetSizeWH;
|
||||
|
||||
#print "resize\n";
|
||||
if ($self->_texture_size->x() < $x or $self->_texture_size->y() < $y) {
|
||||
# Allocate a large enough OpenGL texture with power of 2 dimensions.
|
||||
$self->_texture_size->set_x(1) if ($self->_texture_size->x() == 0);
|
||||
|
@ -682,16 +619,12 @@ sub Resize {
|
|||
0); # ptr to texture data
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#print "resize - setimagesize\n";
|
||||
$self->_extrusion_simulator->set_image_size($self->_texture_size);
|
||||
}
|
||||
$self->_extrusion_simulator->set_viewport(Slic3r::Geometry::BoundingBox->new_from_points(
|
||||
[Slic3r::Point->new(0, 0), Slic3r::Point->new($x, $y)]));
|
||||
#print "resize end\n";
|
||||
|
||||
glViewport(0, 0, $x, $y);
|
||||
|
||||
Slic3r::Point->new(0,0);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
@ -767,8 +700,6 @@ sub line {
|
|||
# Br=alpha of color when alphablend=true
|
||||
$alphablend, # use alpha blend or not
|
||||
) = @_;
|
||||
|
||||
#die 'Inside 2DToolpaths::line(). This was not expected to be called.';
|
||||
|
||||
my $t;
|
||||
my $R;
|
||||
|
@ -937,8 +868,6 @@ sub line {
|
|||
}
|
||||
|
||||
|
||||
# What is the purpose of this dialog? Testing? A stand-alone application?
|
||||
# Currently this dialog is not instantiated.
|
||||
package Slic3r::GUI::Plater::2DToolpaths::Dialog;
|
||||
|
||||
use Wx qw(:dialog :id :misc :sizer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue