line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::Estimate::Shape; |
2
|
|
|
|
|
|
|
$SVG::Estimate::Shape::VERSION = '1.0114'; |
3
|
23
|
|
|
23
|
|
10891
|
use Moo; |
|
23
|
|
|
|
|
46
|
|
|
23
|
|
|
|
|
122
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
SVG::Estimate::Shape - Base class for all other shape calculations. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
version 1.0114 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
There are a lot of methods and parameters shared between the various shape classes in L. This base class encapsulates them all. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 INHERITANCE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This class consumes L and L. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 new( properties ) |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Constructor. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item properties |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item start_point |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
An array ref that describes the position of the cursor (or CNC head) prior to drawing this shape (where it left off from the last object). |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item transformer |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
A reference to a L object that contains all the transforms for this shape. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=back |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has start_point => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
required => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
##Note, named transformer because Transformers are cool, and because it clashes with the transform attribute |
53
|
|
|
|
|
|
|
has transformer => ( |
54
|
|
|
|
|
|
|
is => 'ro', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
with 'SVG::Estimate::Role::Round'; |
59
|
|
|
|
|
|
|
with 'SVG::Estimate::Role::Pythagorean'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 length ( ) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns the sum of C and C. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub length { |
68
|
599
|
|
|
599
|
1
|
786
|
my $self = shift; |
69
|
599
|
|
|
|
|
784
|
return $self->travel_length + $self->shape_length; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 draw_start ( ) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns an x and a y value as an array ref of where the drawing will start that can be used by the C method. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has draw_start => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
required => 1, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 draw_end ( ) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns the same as C. Override this if you have an open ended shape like a line. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has draw_end => ( |
90
|
|
|
|
|
|
|
is => 'ro', |
91
|
|
|
|
|
|
|
lazy => 1, |
92
|
|
|
|
|
|
|
default => sub { |
93
|
|
|
|
|
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
return $self->draw_start; |
95
|
|
|
|
|
|
|
}, |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 travel_length ( ) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns the distance between C and where the drawing of the shape begins, which the developer must define as C |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub travel_length { |
105
|
1093
|
|
|
1093
|
1
|
2607
|
my $self = shift; |
106
|
1093
|
|
|
|
|
2508
|
return $self->pythagorean($self->draw_start, $self->start_point); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 shape_length ( ) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the total length of the vectors in the shape. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has shape_length => ( |
116
|
|
|
|
|
|
|
is => 'ro', |
117
|
|
|
|
|
|
|
required => 1, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 min_x ( ) |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the minimum position of C that this shape will ever reach. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
has min_x => ( |
127
|
|
|
|
|
|
|
is => 'ro', |
128
|
|
|
|
|
|
|
required => 1, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 max_x ( ) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns the maximum position of C that this shape will ever reach. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
has max_x => ( |
138
|
|
|
|
|
|
|
is => 'ro', |
139
|
|
|
|
|
|
|
required => 1, |
140
|
|
|
|
|
|
|
); |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 min_y ( ) |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns the minimum position of C that this shape will ever reach. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
has min_y => ( |
149
|
|
|
|
|
|
|
is => 'ro', |
150
|
|
|
|
|
|
|
required => 1, |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 max_y ( ) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns the max position of C that this shape will ever reach. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
has max_y => ( |
160
|
|
|
|
|
|
|
is => 'ro', |
161
|
|
|
|
|
|
|
required => 1, |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub summarize_myself { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
print ref $self; |
167
|
0
|
|
|
|
|
|
printf "\n\tstart point: [%s, %s]", $self->round($self->start_point->[0]), $self->round($self->start_point->[1]); |
168
|
0
|
|
|
|
|
|
printf "\n\tdraw start : [%s, %s]", $self->round($self->draw_start->[0]), $self->round($self->draw_start->[1]); |
169
|
0
|
|
|
|
|
|
printf "\n\tdraw end : [%s, %s]", $self->round($self->draw_end->[0]), $self->round($self->draw_end->[1]); |
170
|
0
|
|
|
|
|
|
print "\n\ttotal length: ". $self->round($self->length); |
171
|
0
|
|
|
|
|
|
print "\n\ttravel length: ". $self->round($self->travel_length); |
172
|
0
|
|
|
|
|
|
print "\n\tshape length: ". $self->round($self->shape_length); |
173
|
0
|
|
|
|
|
|
print "\n"; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |