Visual preview for bed shape dialog

This commit is contained in:
Alessandro Ranellucci
2014-08-03 00:20:55 +02:00
parent 3ff613d166
commit f462af20f9
7 changed files with 164 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ use overload
package Slic3r::Pointf;
use overload
'@{}' => sub { [ $_[0]->x, $_[0]->y ] }, #,
'@{}' => sub { $_[0]->arrayref },
'fallback' => 1;
package Slic3r::Pointf3;

View File

@@ -268,6 +268,15 @@ Pointf::translate(double x, double y)
this->y += y;
}
void
Pointf::rotate(double angle, const Pointf &center)
{
double cur_x = this->x;
double cur_y = this->y;
this->x = center.x + cos(angle) * (cur_x - center.x) - sin(angle) * (cur_y - center.y);
this->y = center.y + cos(angle) * (cur_y - center.y) + sin(angle) * (cur_x - center.x);
}
#ifdef SLIC3RXS
REGISTER_CLASS(Pointf, "Pointf");

View File

@@ -71,6 +71,7 @@ class Pointf
explicit Pointf(coordf_t _x = 0, coordf_t _y = 0): x(_x), y(_y) {};
void scale(double factor);
void translate(double x, double y);
void rotate(double angle, const Pointf &center);
#ifdef SLIC3RXS
bool from_SV(SV* point_sv);

View File

@@ -56,6 +56,10 @@ new_from_points(CLASS, points)
double x_max() %code{% RETVAL = THIS->max.x; %};
double y_min() %code{% RETVAL = THIS->min.y; %};
double y_max() %code{% RETVAL = THIS->max.y; %};
void set_x_min(double val) %code{% THIS->min.x = val; %};
void set_x_max(double val) %code{% THIS->max.x = val; %};
void set_y_min(double val) %code{% THIS->min.y = val; %};
void set_y_max(double val) %code{% THIS->max.y = val; %};
%{

View File

@@ -85,11 +85,18 @@ Point::coincides_with(point_sv)
~Pointf();
Clone<Pointf> clone()
%code{% RETVAL = THIS; %};
SV* arrayref()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
SV* pp()
%code{% RETVAL = THIS->to_SV_pureperl(); %};
double x()
%code{% RETVAL = THIS->x; %};
double y()
%code{% RETVAL = THIS->y; %};
void translate(double x, double y);
void scale(double factor);
void rotate(double angle, Pointf* center)
%code{% THIS->rotate(angle, *center); %};
};
%name{Slic3r::Pointf3} class Pointf3 {