2DToolpaths.pm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. package Slic3r::GUI::Plater::2DToolpaths;
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use Slic3r::Print::State ':steps';
  6. use Wx qw(:misc :sizer :slider :statictext wxWHITE);
  7. use Wx::Event qw(EVT_SLIDER EVT_KEY_DOWN);
  8. use base qw(Wx::Panel Class::Accessor);
  9. __PACKAGE__->mk_accessors(qw(print enabled));
  10. sub new {
  11. my $class = shift;
  12. my ($parent, $print) = @_;
  13. my $self = $class->SUPER::new($parent, -1, wxDefaultPosition);
  14. $self->SetBackgroundColour(wxWHITE);
  15. # init GUI elements
  16. my $canvas = $self->{canvas} = Slic3r::GUI::Plater::2DToolpaths::Canvas->new($self, $print);
  17. my $slider = $self->{slider} = Wx::Slider->new(
  18. $self, -1,
  19. 0, # default
  20. 0, # min
  21. # we set max to a bogus non-zero value because the MSW implementation of wxSlider
  22. # will skip drawing the slider if max <= min:
  23. 1, # max
  24. wxDefaultPosition,
  25. wxDefaultSize,
  26. wxVERTICAL | wxSL_INVERSE,
  27. );
  28. my $z_label = $self->{z_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
  29. [40,-1], wxALIGN_CENTRE_HORIZONTAL);
  30. $z_label->SetFont($Slic3r::GUI::small_font);
  31. my $vsizer = Wx::BoxSizer->new(wxVERTICAL);
  32. $vsizer->Add($slider, 1, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
  33. $vsizer->Add($z_label, 0, wxALL | wxEXPAND | wxALIGN_CENTER, 3);
  34. my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
  35. $sizer->Add($canvas, 1, wxALL | wxEXPAND, 0);
  36. $sizer->Add($vsizer, 0, wxTOP | wxBOTTOM | wxEXPAND, 5);
  37. EVT_SLIDER($self, $slider, sub {
  38. $self->set_z($self->{layers_z}[$slider->GetValue])
  39. if $self->enabled;
  40. });
  41. EVT_KEY_DOWN($canvas, sub {
  42. my ($s, $event) = @_;
  43. my $key = $event->GetKeyCode;
  44. if ($key == 85 || $key == 315) {
  45. $slider->SetValue($slider->GetValue + 1);
  46. $self->set_z($self->{layers_z}[$slider->GetValue]);
  47. } elsif ($key == 68 || $key == 317) {
  48. $slider->SetValue($slider->GetValue - 1);
  49. $self->set_z($self->{layers_z}[$slider->GetValue]);
  50. }
  51. });
  52. $self->SetSizer($sizer);
  53. $self->SetMinSize($self->GetSize);
  54. $sizer->SetSizeHints($self);
  55. # init print
  56. $self->{print} = $print;
  57. $self->reload_print;
  58. return $self;
  59. }
  60. sub reload_print {
  61. my ($self) = @_;
  62. # we require that there's at least one object and the posSlice step
  63. # is performed on all of them (this ensures that _shifted_copies was
  64. # populated and we know the number of layers)
  65. if (!$self->print->object_step_done(STEP_SLICE)) {
  66. $self->enabled(0);
  67. $self->{slider}->Hide;
  68. $self->{canvas}->Refresh; # clears canvas
  69. return;
  70. }
  71. $self->{canvas}->bb($self->print->total_bounding_box);
  72. my %z = (); # z => 1
  73. foreach my $object (@{$self->{print}->objects}) {
  74. foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
  75. $z{$layer->print_z} = 1;
  76. }
  77. }
  78. $self->enabled(1);
  79. $self->{layers_z} = [ sort { $a <=> $b } keys %z ];
  80. $self->{slider}->SetRange(0, scalar(@{$self->{layers_z}})-1);
  81. if ((my $z_idx = $self->{slider}->GetValue) <= $#{$self->{layers_z}}) {
  82. $self->set_z($self->{layers_z}[$z_idx]);
  83. } else {
  84. $self->{slider}->SetValue(0);
  85. $self->set_z($self->{layers_z}[0]) if @{$self->{layers_z}};
  86. }
  87. $self->{slider}->Show;
  88. $self->Layout;
  89. }
  90. sub set_z {
  91. my ($self, $z) = @_;
  92. return if !$self->enabled;
  93. $self->{z_label}->SetLabel(sprintf '%.2f', $z);
  94. $self->{canvas}->set_z($z);
  95. }
  96. package Slic3r::GUI::Plater::2DToolpaths::Canvas;
  97. use Wx::Event qw(EVT_PAINT EVT_SIZE EVT_IDLE EVT_MOUSEWHEEL EVT_MOUSE_EVENTS);
  98. use OpenGL qw(:glconstants :glfunctions :glufunctions :gluconstants);
  99. use base qw(Wx::GLCanvas Class::Accessor);
  100. use Wx::GLCanvas qw(:all);
  101. use List::Util qw(min first);
  102. use Slic3r::Geometry qw(scale unscale epsilon);
  103. use Slic3r::Print::State ':steps';
  104. __PACKAGE__->mk_accessors(qw(print z layers color init bb _dirty));
  105. # make OpenGL::Array thread-safe
  106. {
  107. no warnings 'redefine';
  108. *OpenGL::Array::CLONE_SKIP = sub { 1 };
  109. }
  110. sub new {
  111. my ($class, $parent, $print) = @_;
  112. my $self = $class->SUPER::new($parent);
  113. $self->print($print);
  114. EVT_PAINT($self, sub {
  115. my $dc = Wx::PaintDC->new($self);
  116. $self->Render($dc);
  117. });
  118. EVT_SIZE($self, sub { $self->_dirty(1) });
  119. EVT_IDLE($self, sub {
  120. return unless $self->_dirty;
  121. return if !$self->IsShownOnScreen;
  122. $self->Resize( $self->GetSizeWH );
  123. $self->Refresh;
  124. });
  125. return $self;
  126. }
  127. sub set_z {
  128. my ($self, $z) = @_;
  129. my $print = $self->print;
  130. # can we have interlaced layers?
  131. my $interlaced = (defined first { $_->config->support_material } @{$print->objects})
  132. || (defined first { $_->config->infill_every_layers > 1 } @{$print->regions});
  133. my $max_layer_height = $print->max_allowed_layer_height;
  134. my @layers = ();
  135. foreach my $object (@{$print->objects}) {
  136. foreach my $layer (@{$object->layers}, @{$object->support_layers}) {
  137. if ($interlaced) {
  138. push @layers, $layer
  139. if $z > ($layer->print_z - $max_layer_height - epsilon)
  140. && $z <= $layer->print_z + epsilon;
  141. } else {
  142. push @layers, $layer if abs($layer->print_z - $z) < epsilon;
  143. }
  144. }
  145. }
  146. $self->z($z);
  147. $self->layers([ @layers ]);
  148. $self->Refresh;
  149. }
  150. sub Render {
  151. my ($self, $dc) = @_;
  152. # prevent calling SetCurrent() when window is not shown yet
  153. return unless $self->IsShownOnScreen;
  154. return unless my $context = $self->GetContext;
  155. $self->SetCurrent($context);
  156. $self->InitGL;
  157. glClearColor(1, 1, 1, 0);
  158. glClear(GL_COLOR_BUFFER_BIT);
  159. if (!$self->GetParent->enabled || !$self->layers) {
  160. glFlush();
  161. $self->SwapBuffers;
  162. return;
  163. }
  164. glMatrixMode(GL_PROJECTION);
  165. glLoadIdentity();
  166. my $bb = $self->bb;
  167. my ($x1, $y1, $x2, $y2) = ($bb->x_min, $bb->y_min, $bb->x_max, $bb->y_max);
  168. my ($x, $y) = $self->GetSizeWH;
  169. if (($x2 - $x1)/($y2 - $y1) > $x/$y) {
  170. # adjust Y
  171. my $new_y = $y * ($x2 - $x1) / $x;
  172. $y1 = ($y2 + $y1)/2 - $new_y/2;
  173. $y2 = $y1 + $new_y;
  174. } else {
  175. my $new_x = $x * ($y2 - $y1) / $y;
  176. $x1 = ($x2 + $x1)/2 - $new_x/2;
  177. $x2 = $x1 + $new_x;
  178. }
  179. glOrtho($x1, $x2, $y1, $y2, 0, 1);
  180. glDisable(GL_DEPTH_TEST);
  181. glMatrixMode(GL_MODELVIEW);
  182. glLoadIdentity();
  183. # anti-alias
  184. if (0) {
  185. glEnable(GL_LINE_SMOOTH);
  186. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  187. glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
  188. glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
  189. }
  190. my $tess;
  191. if (!(&Wx::wxMSW && $OpenGL::VERSION < 0.6704)) {
  192. # We can't use the GLU tesselator on MSW with older OpenGL versions
  193. # because of an upstream bug:
  194. # http://sourceforge.net/p/pogl/bugs/16/
  195. $tess = gluNewTess();
  196. gluTessCallback($tess, GLU_TESS_BEGIN, 'DEFAULT');
  197. gluTessCallback($tess, GLU_TESS_END, 'DEFAULT');
  198. gluTessCallback($tess, GLU_TESS_VERTEX, 'DEFAULT');
  199. gluTessCallback($tess, GLU_TESS_COMBINE, 'DEFAULT');
  200. gluTessCallback($tess, GLU_TESS_ERROR, 'DEFAULT');
  201. gluTessCallback($tess, GLU_TESS_EDGE_FLAG, 'DEFAULT');
  202. }
  203. foreach my $layer (@{$self->layers}) {
  204. my $object = $layer->object;
  205. # only draw the slice for the current layer
  206. next unless abs($layer->print_z - $self->z) < epsilon;
  207. # draw slice contour
  208. glLineWidth(1);
  209. foreach my $copy (@{ $object->_shifted_copies }) {
  210. glPushMatrix();
  211. glTranslatef(@$copy, 0);
  212. foreach my $slice (@{$layer->slices}) {
  213. glColor3f(0.95, 0.95, 0.95);
  214. if ($tess) {
  215. gluTessBeginPolygon($tess);
  216. foreach my $polygon (@$slice) {
  217. gluTessBeginContour($tess);
  218. gluTessVertex_p($tess, @$_, 0) for @$polygon;
  219. gluTessEndContour($tess);
  220. }
  221. gluTessEndPolygon($tess);
  222. }
  223. glColor3f(0.9, 0.9, 0.9);
  224. foreach my $polygon (@$slice) {
  225. foreach my $line (@{$polygon->lines}) {
  226. glBegin(GL_LINES);
  227. glVertex2f(@{$line->a});
  228. glVertex2f(@{$line->b});
  229. glEnd();
  230. }
  231. }
  232. }
  233. glPopMatrix();
  234. }
  235. }
  236. my $skirt_drawn = 0;
  237. my $brim_drawn = 0;
  238. foreach my $layer (@{$self->layers}) {
  239. my $object = $layer->object;
  240. my $print_z = $layer->print_z;
  241. # draw brim
  242. if ($self->print->step_done(STEP_BRIM) && $layer->id == 0 && !$brim_drawn) {
  243. $self->color([0, 0, 0]);
  244. $self->_draw(undef, $print_z, $_) for @{$self->print->brim};
  245. $brim_drawn = 1;
  246. }
  247. if ($self->print->step_done(STEP_SKIRT)
  248. && ($self->print->has_infinite_skirt() || $self->print->config->skirt_height > $layer->id)
  249. && !$skirt_drawn) {
  250. $self->color([0, 0, 0]);
  251. $self->_draw(undef, $print_z, $_) for @{$self->print->skirt};
  252. $skirt_drawn = 1;
  253. }
  254. foreach my $layerm (@{$layer->regions}) {
  255. if ($object->step_done(STEP_PERIMETERS)) {
  256. $self->color([0.7, 0, 0]);
  257. $self->_draw($object, $print_z, $_) for map @$_, @{$layerm->perimeters};
  258. }
  259. if ($object->step_done(STEP_INFILL)) {
  260. $self->color([0, 0, 0.7]);
  261. $self->_draw($object, $print_z, $_) for map @$_, @{$layerm->fills};
  262. }
  263. }
  264. if ($object->step_done(STEP_SUPPORTMATERIAL)) {
  265. if ($layer->isa('Slic3r::Layer::Support')) {
  266. $self->color([0, 0, 0]);
  267. $self->_draw($object, $print_z, $_) for @{$layer->support_fills};
  268. $self->_draw($object, $print_z, $_) for @{$layer->support_interface_fills};
  269. }
  270. }
  271. }
  272. gluDeleteTess($tess) if $tess;
  273. glFlush();
  274. $self->SwapBuffers;
  275. }
  276. sub _draw {
  277. my ($self, $object, $print_z, $path) = @_;
  278. my @paths = $path->isa('Slic3r::ExtrusionLoop')
  279. ? @$path
  280. : ($path);
  281. $self->_draw_path($object, $print_z, $_) for @paths;
  282. }
  283. sub _draw_path {
  284. my ($self, $object, $print_z, $path) = @_;
  285. return if $print_z - $path->height > $self->z - epsilon;
  286. if (abs($print_z - $self->z) < epsilon) {
  287. glColor3f(@{$self->color});
  288. } else {
  289. glColor3f(0.8, 0.8, 0.8);
  290. }
  291. glLineWidth(1);
  292. if (defined $object) {
  293. foreach my $copy (@{ $object->_shifted_copies }) {
  294. glPushMatrix();
  295. glTranslatef(@$copy, 0);
  296. foreach my $line (@{$path->polyline->lines}) {
  297. glBegin(GL_LINES);
  298. glVertex2f(@{$line->a});
  299. glVertex2f(@{$line->b});
  300. glEnd();
  301. }
  302. glPopMatrix();
  303. }
  304. } else {
  305. foreach my $line (@{$path->polyline->lines}) {
  306. glBegin(GL_LINES);
  307. glVertex2f(@{$line->a});
  308. glVertex2f(@{$line->b});
  309. glEnd();
  310. }
  311. }
  312. }
  313. sub InitGL {
  314. my $self = shift;
  315. return if $self->init;
  316. return unless $self->GetContext;
  317. $self->init(1);
  318. }
  319. sub GetContext {
  320. my ($self) = @_;
  321. if (Wx::wxVERSION >= 2.009) {
  322. return $self->{context} ||= Wx::GLContext->new($self);
  323. } else {
  324. return $self->SUPER::GetContext;
  325. }
  326. }
  327. sub SetCurrent {
  328. my ($self, $context) = @_;
  329. if (Wx::wxVERSION >= 2.009) {
  330. return $self->SUPER::SetCurrent($context);
  331. } else {
  332. return $self->SUPER::SetCurrent;
  333. }
  334. }
  335. sub Resize {
  336. my ($self, $x, $y) = @_;
  337. return unless $self->GetContext;
  338. $self->SetCurrent($self->GetContext);
  339. glViewport(0, 0, $x, $y);
  340. }
  341. sub line {
  342. my (
  343. $x1, $y1, $x2, $y2, # coordinates of the line
  344. $w, # width/thickness of the line in pixel
  345. $Cr, $Cg, $Cb, # RGB color components
  346. $Br, $Bg, $Bb, # color of background when alphablend=false
  347. # Br=alpha of color when alphablend=true
  348. $alphablend, # use alpha blend or not
  349. ) = @_;
  350. my $t;
  351. my $R;
  352. my $f = $w - int($w);
  353. my $A;
  354. if ($alphablend) {
  355. $A = $Br;
  356. } else {
  357. $A = 1;
  358. }
  359. # determine parameters t,R
  360. if ($w >= 0 && $w < 1) {
  361. $t = 0.05; $R = 0.48 + 0.32 * $f;
  362. if (!$alphablend) {
  363. $Cr += 0.88 * (1-$f);
  364. $Cg += 0.88 * (1-$f);
  365. $Cb += 0.88 * (1-$f);
  366. $Cr = 1.0 if ($Cr > 1.0);
  367. $Cg = 1.0 if ($Cg > 1.0);
  368. $Cb = 1.0 if ($Cb > 1.0);
  369. } else {
  370. $A *= $f;
  371. }
  372. } elsif ($w >= 1.0 && $w < 2.0) {
  373. $t = 0.05 + $f*0.33; $R = 0.768 + 0.312*$f;
  374. } elsif ($w >= 2.0 && $w < 3.0) {
  375. $t = 0.38 + $f*0.58; $R = 1.08;
  376. } elsif ($w >= 3.0 && $w < 4.0) {
  377. $t = 0.96 + $f*0.48; $R = 1.08;
  378. } elsif ($w >= 4.0 && $w < 5.0) {
  379. $t= 1.44 + $f*0.46; $R = 1.08;
  380. } elsif ($w >= 5.0 && $w < 6.0) {
  381. $t= 1.9 + $f*0.6; $R = 1.08;
  382. } elsif ($w >= 6.0) {
  383. my $ff = $w - 6.0;
  384. $t = 2.5 + $ff*0.50; $R = 1.08;
  385. }
  386. #printf( "w=%f, f=%f, C=%.4f\n", $w, $f, $C);
  387. # determine angle of the line to horizontal
  388. my $tx = 0; my $ty = 0; # core thinkness of a line
  389. my $Rx = 0; my $Ry = 0; # fading edge of a line
  390. my $cx = 0; my $cy = 0; # cap of a line
  391. my $ALW = 0.01;
  392. my $dx = $x2 - $x1;
  393. my $dy = $y2 - $y1;
  394. if (abs($dx) < $ALW) {
  395. # vertical
  396. $tx = $t; $ty = 0;
  397. $Rx = $R; $Ry = 0;
  398. if ($w > 0.0 && $w < 1.0) {
  399. $tx *= 8;
  400. } elsif ($w == 1.0) {
  401. $tx *= 10;
  402. }
  403. } elsif (abs($dy) < $ALW) {
  404. #horizontal
  405. $tx = 0; $ty = $t;
  406. $Rx = 0; $Ry = $R;
  407. if ($w > 0.0 && $w < 1.0) {
  408. $ty *= 8;
  409. } elsif ($w == 1.0) {
  410. $ty *= 10;
  411. }
  412. } else {
  413. if ($w < 3) { # approximate to make things even faster
  414. my $m = $dy/$dx;
  415. # and calculate tx,ty,Rx,Ry
  416. if ($m > -0.4142 && $m <= 0.4142) {
  417. # -22.5 < $angle <= 22.5, approximate to 0 (degree)
  418. $tx = $t * 0.1; $ty = $t;
  419. $Rx = $R * 0.6; $Ry = $R;
  420. } elsif ($m > 0.4142 && $m <= 2.4142) {
  421. # 22.5 < $angle <= 67.5, approximate to 45 (degree)
  422. $tx = $t * -0.7071; $ty = $t * 0.7071;
  423. $Rx = $R * -0.7071; $Ry = $R * 0.7071;
  424. } elsif ($m > 2.4142 || $m <= -2.4142) {
  425. # 67.5 < $angle <= 112.5, approximate to 90 (degree)
  426. $tx = $t; $ty = $t*0.1;
  427. $Rx = $R; $Ry = $R*0.6;
  428. } elsif ($m > -2.4142 && $m < -0.4142) {
  429. # 112.5 < angle < 157.5, approximate to 135 (degree)
  430. $tx = $t * 0.7071; $ty = $t * 0.7071;
  431. $Rx = $R * 0.7071; $Ry = $R * 0.7071;
  432. } else {
  433. # error in determining angle
  434. printf("error in determining angle: m=%.4f\n", $m);
  435. }
  436. } else { # calculate to exact
  437. $dx= $y1 - $y2;
  438. $dy= $x2 - $x1;
  439. my $L = sqrt($dx*$dx + $dy*$dy);
  440. $dx /= $L;
  441. $dy /= $L;
  442. $cx = -0.6*$dy; $cy=0.6*$dx;
  443. $tx = $t*$dx; $ty = $t*$dy;
  444. $Rx = $R*$dx; $Ry = $R*$dy;
  445. }
  446. }
  447. # draw the line by triangle strip
  448. glBegin(GL_TRIANGLE_STRIP);
  449. if (!$alphablend) {
  450. glColor3f($Br, $Bg, $Bb);
  451. } else {
  452. glColor4f($Cr, $Cg, $Cb, 0);
  453. }
  454. glVertex2f($x1 - $tx - $Rx, $y1 - $ty - $Ry); # fading edge
  455. glVertex2f($x2 - $tx - $Rx, $y2 - $ty - $Ry);
  456. if (!$alphablend) {
  457. glColor3f($Cr, $Cg, $Cb);
  458. } else {
  459. glColor4f($Cr, $Cg, $Cb, $A);
  460. }
  461. glVertex2f($x1 - $tx, $y1 - $ty); # core
  462. glVertex2f($x2 - $tx, $y2 - $ty);
  463. glVertex2f($x1 + $tx, $y1 + $ty);
  464. glVertex2f($x2 + $tx, $y2 + $ty);
  465. if ((abs($dx) < $ALW || abs($dy) < $ALW) && $w <= 1.0) {
  466. # printf("skipped one fading edge\n");
  467. } else {
  468. if (!$alphablend) {
  469. glColor3f($Br, $Bg, $Bb);
  470. } else {
  471. glColor4f($Cr, $Cg, $Cb, 0);
  472. }
  473. glVertex2f($x1 + $tx+ $Rx, $y1 + $ty + $Ry); # fading edge
  474. glVertex2f($x2 + $tx+ $Rx, $y2 + $ty + $Ry);
  475. }
  476. glEnd();
  477. # cap
  478. if ($w < 3) {
  479. # do not draw cap
  480. } else {
  481. # draw cap
  482. glBegin(GL_TRIANGLE_STRIP);
  483. if (!$alphablend) {
  484. glColor3f($Br, $Bg, $Bb);
  485. } else {
  486. glColor4f($Cr, $Cg, $Cb, 0);
  487. }
  488. glVertex2f($x1 - $Rx + $cx, $y1 - $Ry + $cy);
  489. glVertex2f($x1 + $Rx + $cx, $y1 + $Ry + $cy);
  490. glColor3f($Cr, $Cg, $Cb);
  491. glVertex2f($x1 - $tx - $Rx, $y1 - $ty - $Ry);
  492. glVertex2f($x1 + $tx + $Rx, $y1 + $ty + $Ry);
  493. glEnd();
  494. glBegin(GL_TRIANGLE_STRIP);
  495. if (!$alphablend) {
  496. glColor3f($Br, $Bg, $Bb);
  497. } else {
  498. glColor4f($Cr, $Cg, $Cb, 0);
  499. }
  500. glVertex2f($x2 - $Rx - $cx, $y2 - $Ry - $cy);
  501. glVertex2f($x2 + $Rx - $cx, $y2 + $Ry - $cy);
  502. glColor3f($Cr, $Cg, $Cb);
  503. glVertex2f($x2 - $tx - $Rx, $y2 - $ty - $Ry);
  504. glVertex2f($x2 + $tx + $Rx, $y2 + $ty + $Ry);
  505. glEnd();
  506. }
  507. }
  508. package Slic3r::GUI::Plater::2DToolpaths::Dialog;
  509. use Wx qw(:dialog :id :misc :sizer);
  510. use Wx::Event qw(EVT_CLOSE);
  511. use base 'Wx::Dialog';
  512. sub new {
  513. my $class = shift;
  514. my ($parent, $print) = @_;
  515. my $self = $class->SUPER::new($parent, -1, "Toolpaths", wxDefaultPosition, [500,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
  516. my $sizer = Wx::BoxSizer->new(wxVERTICAL);
  517. $sizer->Add(Slic3r::GUI::Plater::2DToolpaths->new($self, $print), 1, wxEXPAND, 0);
  518. $self->SetSizer($sizer);
  519. $self->SetMinSize($self->GetSize);
  520. # needed to actually free memory
  521. EVT_CLOSE($self, sub {
  522. $self->EndModal(wxID_OK);
  523. $self->Destroy;
  524. });
  525. return $self;
  526. }
  527. 1;