lib/App/Asciio/stripes/section_wirl_arrow.pm

filter: Statementstmt 34.6% 153 / 441 Branchbran 35.9% 46 / 128 Conditioncond 27.5% 19 / 69 MC/DCmcdc 18.4% 7 / 38 Subroutinesub 34.2% 13 / 38 Podpod 0.0% 0 / 31 totaltotal 31.9% 238 / 745 CC 106 SCAR 37.7
CC
106
Cov
34%
resize
156.0
get_named_connection
132.0
find_elements_for_connector_at
56.0
CRAP 43.3
« blib/lib/App/Asciio/Elements.pm ↑ Summary blib/lib/App/Asciio/Actions/ElementsManipulation.pm »
1  
2 package App::Asciio::stripes::section_wirl_arrow ;
3 2 ▶use base App::Asciio::stripes::stripes ;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use List::Util qw(min max) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Readonly ;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Clone ;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use App::Asciio::stripes::wirl_arrow ;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #-----------------------------------------------------------------------------
15  
16 2 Readonly my $DEFAULT_ARROW_TYPE =>
17 [
18 ['origin', '', '*', '', '', '', 1],
19 ['up', '|', '|', '', '', '^', 1],
20 ['down', '|', '|', '', '', 'v', 1],
21 ['left', '-', '-', '', '', '<', 1],
22 ['up-left', '|', '|', '.', '-', '<', 1],
23 ['left-up', '-', '-', '\'', '|', '^', 1],
24 ['down-left', '|', '|', '\'', '-', '<', 1],
25 ['left-down', '-', '-', '.', '|', 'v', 1],
26 ['right', '-', '-', '', '', '>', 1],
27 ['up-right', '|', '|', '.', '-', '>', 1],
28 ['right-up', '-', '-', '\'', '|', '^', 1],
29 ['down-right', '|', '|', '\'', '-', '>', 1],
30 ['right-down', '-', '-', '.', '|', 'v', 1],
31 ['45', '/', '/', '', '', '^', 1],
32 ['135', '\\', '\\', '', '', 'v', 1],
33 ['225', '/', '/', '', '', 'v', 1],
34 ['315', '\\', '\\', '', '', '^', 1],
35 ] ;
36  
37 # constants for connector overlays
38 2 Readonly my $body_index => 2 ;
39 2 Readonly my $connection_index => 3 ;
40  
41 2 Readonly my $up_index=> 1 ;
42 2 Readonly my $left_index=> 3 ;
43 2 Readonly my $leftup_index => 5 ;
44 2 Readonly my $leftdown_index => 7 ;
45 2 Readonly my $rightup_index => 10 ;
46 2 Readonly my $rightdown_index => 12 ;
47  
48 #-----------------------------------------------------------------------------
49  
50 sub new
51 96 ▶{
Subroutine new: called CC=2 SCAR=7.4
Pod undocumented
52 96 my ($class, $element_definition) = @_ ;
53  
54 96 my $self = bless {}, __PACKAGE__ ;
55  
56 $self->setup
57 (
58 $element_definition->{ARROW_TYPE} || Clone::clone($DEFAULT_ARROW_TYPE),
59 $element_definition->{POINTS},
60 $element_definition->{DIRECTION},
61 $element_definition->{ALLOW_DIAGONAL_LINES},
62 $element_definition->{EDITABLE},
63 $element_definition->{NOT_CONNECTABLE_START},
64 $element_definition->{NOT_CONNECTABLE_END},
65 96 ▶ ) ;
Condition33%1/3
$element_definition->{'ARROW_TYPE'} || &Clone::clone($DEFAULT_ARROW_TYPE)
l!l&&r!l&&!r
0960
MC/DC0%0/2
$element_definition->{'ARROW_TYPE'} || &Clone::clone($DEFAULT_ARROW_TYPE)
$element_definition->{'ARROW_TYPE'} &Clone::clone($DEFAULT_ARROW_TYPE)
Truth table33%1/3
A || B
A= $element_definition->{'ARROW_TYPE'}B= &Clone::clone($DEFAULT_ARROW_TYPE)
ABresult
1X1
011
000
66  
67 96 return $self ;
68 }
69  
70 #-----------------------------------------------------------------------------
71  
72 sub setup
73 96 ▶{
Subroutine setup: called CC=5 SCAR=16.6
Pod undocumented
74 96 my ($self, $arrow_type, $points, $direction, $allow_diagonal_lines, $editable, $not_connectable_start, $not_connectable_end) = @_ ;
75  
76 96 ▶if('ARRAY' eq ref $points && @{$points} > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ('ARRAY' eq ref $points and @{$points;} > 0) { } 96 0 96
Condition33%1/3
"ARRAY" eq ref $points and @{$points;} > 0
!ll&&!rl&&r
0096
MC/DC0%0/2
"ARRAY" eq ref $points and @{$points;} > 0
"ARRAY" eq ref $points @{$points;} > 0
Truth table33%1/3
A and B
A= "ARRAY" eq ref $pointsB= @{$points;} > 0
ABresult
0X0
100
111
77 {
78 96 delete $self->{CACHE} ;
79
80 96 my ($start_x, $start_y, $arrows) = (0, 0, []) ;
81
82 96 my $points_offsets ;
83 96 my $arrow_index = 0 ; # must have a numeric index or 'undo' won't work
84
85 96 for my $point (@{$points})
86 {
87 192 my ($x, $y, $point_direction) = @{$point} ;
88
89 192 ▶ my $arrow = new App::Asciio::stripes::wirl_arrow
Condition33%1/3
$point_direction || $direction
l!l&&r!l&&!r
19200
MC/DC0%0/2
$point_direction || $direction
$point_direction $direction
Truth table33%1/3
A || B
A= $point_directionB= $direction
ABresult
1X1
011
000
90 ({
91 ARROW_TYPE => $arrow_type,
92 END_X => $x - $start_x,
93 END_Y => $y - $start_y,
94 DIRECTION => $point_direction || $direction,
95 ALLOW_DIAGONAL_LINES => $allow_diagonal_lines,
96 EDITABLE => $editable,
97 }) ;
98
99 192 $points_offsets->[$arrow_index++] = [$start_x, $start_y] ;
100
101 192 push @{$arrows}, $arrow ;
102 192 ($start_x, $start_y) = ($x, $y) ;
103 }
104
105 $self->set
106 (
107 96 POINTS_OFFSETS => $points_offsets,
108 ARROWS => $arrows,
109
110 # keep data to allow section insertion later
111 ARROW_TYPE => $arrow_type,
112 DIRECTION => $direction,
113 ALLOW_DIAGONAL_LINES => $allow_diagonal_lines,
114 EDITABLE => $editable,
115 NOT_CONNECTABLE_START => $not_connectable_start,
116 NOT_CONNECTABLE_END => $not_connectable_end,
117 ) ;
118
119 96 my ($width, $height) = $self->get_width_and_height() ;
120 96 $self->set
121 (
122 WIDTH => $width,
123 HEIGHT => $height,
124 ) ;
125 }
126 else
127 {
128 0 die "Bad 'section wirl arrow' defintion! Expecting points array." ;
129 }
130 }
131  
132 #-----------------------------------------------------------------------------
133  
134 my %diagonal_direction_to_overlay_character =
135 (
136 8 (map {$_ => q{\\}} qw( down-right right-down up-left left-up)),
137 2 (map {$_ => q{/}} qw( down-left left-down up-right right-up)),
138 ) ;
139  
140 my %diagonal_non_diagonal_to_overlay_character =
141 (
142 8 (map {$_ => q{.}} qw( down-right right-down up-left left-up)),
143 2 (map {$_ => q{'}} qw( down-left left-down up-right right-up)),
144 ) ;
145  
146 sub get_stripes
147 96 ▶{
Subroutine get_stripes: called CC=33 SCAR=35.3
Pod undocumented
148 96 my ($self) = @_ ;
149  
150 96 my $stripes = $self->{CACHE}{STRIPES} ;
151  
152 96 ▶unless (defined $stripes)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $stripes) 96 0 96
153 {
154 96 my @stripes ;
155
156 96 my $arrow_index = 0 ;
157 96 for my $arrow(@{$self->{ARROWS}})
158 {
159 push @stripes,
160 map
161 {
162 {
163 TEXT => $_->{TEXT},
164 WIDTH => $_->{WIDTH},
165 HEIGHT => $_->{HEIGHT} ,
166 X_OFFSET => $_->{X_OFFSET} + $self->{POINTS_OFFSETS}[$arrow_index][0],
167 461 Y_OFFSET => $_->{Y_OFFSET} + $self->{POINTS_OFFSETS}[$arrow_index][1],
168 }
169 192 } @{$arrow->get_stripes()} ;
170
171 192 $arrow_index++ ;
172 }
173
174 # handle connections
175 96 my ($previous_direction) = ($self->{ARROWS}[0]{DIRECTION} =~ /^([^-]+)/) ;
176
177 96 my $previous_was_diagonal ;
178
179 96 $arrow_index = 0 ;
180 96 for my $arrow(@{$self->{ARROWS}})
181 {
182 192 ▶ last if @{$self->{ARROWS}} == 1 ;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"ARROWS"};} == 1 0 192 192
183
184 192 my ($connection, $d1, $d2) ;
185
186 192 ▶ if($arrow->{DIRECTION} =~ /^([^-]+)-([^-]+)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($arrow->{'DIRECTION'} =~ /^([^-]+)-([^-]+)$/) { } 109 83 192
187 {
188 109 ($d1, $d2) = ($1, $2) ;
189 }
190 else
191 {
192 83 $d1 = $arrow->{DIRECTION};
193 }
194
195 192 ▶ if($self->{ALLOW_DIAGONAL_LINES} && $arrow->{WIDTH} == $arrow->{HEIGHT})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ALLOW_DIAGONAL_LINES'} and $arrow->{'WIDTH'} == $arrow->{'HEIGHT'}) { } 64 128 192
Condition100%3/3
$self->{"ALLOW_DIAGONAL_LINES"} and $arrow->{"WIDTH"} == $arrow->{"HEIGHT"}
!ll&&!rl&&r
963264
MC/DC100%2/2
$self->{"ALLOW_DIAGONAL_LINES"} and $arrow->{"WIDTH"} == $arrow->{"HEIGHT"}
$self->{"ALLOW_DIAGONAL_LINES"} $arrow->{"WIDTH"} == $arrow->{"HEIGHT"}
Truth table100%3/3
A and B
A= $self->{"ALLOW_DIAGONAL_LINES"}B= $arrow->{"WIDTH"} == $arrow->{"HEIGHT"}
ABresult
0X0
100
111
196 {
197 # this section is diagonal
198 64 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($previous_was_diagonal and $previous_was_diagonal eq $arrow->{'DIRECTION'} || defined $d2 && $previous_was_diagonal eq "$d2-$d1") { } 4 60 64
Condition66%6/9
$previous_was_diagonal and $previous_was_diagonal eq $arrow->{"DIRECTION"} || defined $d2 && $previous_was_diagonal eq "$d2-$d1"
!ll&&!rl&&r
48124
$previous_was_diagonal eq $arrow->{"DIRECTION"} or defined $d2 and $previous_was_diagonal eq "$d2-$d1"
l!l&&r!l&&!r
4012
defined $d2 and $previous_was_diagonal eq "$d2-$d1"
!ll&&!rl&&r
0120
MC/DC50%2/4
$previous_was_diagonal and $previous_was_diagonal eq $arrow->{"DIRECTION"} || defined $d2 && $previous_was_diagonal eq "$d2-$d1"
$previous_was_diagonal $previous_was_diagonal eq $arrow->{"DIRECTION"} defined $d2 $previous_was_diagonal eq "$d2-$d1"
Truth table60%3/5
A and B or C and D
A= $previous_was_diagonalB= $previous_was_diagonal eq $arrow->{"DIRECTION"}C= defined $d2D= $previous_was_diagonal eq "$d2-$d1"
ABCDresult
0XXX0
100X0
10100
11XX1
10111
199 (
200 $previous_was_diagonal
201 &&
202 (
203 $previous_was_diagonal eq $arrow->{DIRECTION}
204 ||
205 (defined $d2 && $previous_was_diagonal eq "$d2-$d1")
206 )
207 )
208 {
209 # two diagonals going in the same direction
210 4 $connection = $diagonal_direction_to_overlay_character{$arrow->{DIRECTION}} ;
211 }
212 else
213 {
214 # previous non diagonal or two diagonals not going in the same direction
215 60 ▶ $connection = ($d1 eq 'up' || (defined $d2 && $d2 eq 'up')) ? q{'} : q{.} ;
Branch: 1 branch
BranchTrueFalseTotal
$d1 eq 'up' || defined $d2 && $d2 eq 'up' ? : 30 30 60
Condition66%4/6
$d1 eq "up" or defined $d2 and $d2 eq "up"
l!l&&r!l&&!r
03030
defined $d2 and $d2 eq "up"
!ll&&!rl&&r
03030
MC/DC33%1/3
$d1 eq "up" or defined $d2 and $d2 eq "up"
$d1 eq "up" defined $d2 $d2 eq "up"
Truth table50%2/4
A or B and C
A= $d1 eq "up"B= defined $d2C= $d2 eq "up"
ABCresult
1XX1
0111
00X0
0100
216 }
217
218 64 $previous_was_diagonal = $arrow->{DIRECTION} ;
219 }
220 else
221 {
222 # straight or angled arrow
223 128 ▶ if(defined $previous_was_diagonal)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $previous_was_diagonal) { } 16 112 128
224 {
225 16 ▶ if($arrow->{DIRECTION} =~ /^down/)
Branch: 2 branches
BranchTrueFalseTotal
if ($arrow->{'DIRECTION'} =~ /^down/) { } 4 12 16
elsif ($arrow->{'DIRECTION'} =~ /^up/) { } 4 8 12
226 {
227 4 $connection = q{.} ;
228 }
229 elsif($arrow->{DIRECTION} =~ /^up/)
230 {
231 4 $connection = q{'} ;
232 }
233 else
234 {
235 8 ▶ $connection = $previous_was_diagonal =~ /down/ ? q{'} : q{.} ;
Branch: 1 branch
BranchTrueFalseTotal
$previous_was_diagonal =~ /down/ ? : 4 4 8
236 }
237 }
238 else
239 {
240 112 ▶ if($previous_direction ne $d1)
Branch: 1 branch
BranchTrueFalseTotal
if ($previous_direction ne $d1) 36 76 112
241 {
242 36 ▶ if($d1 eq 'down')
Branch: 4 branches
BranchTrueFalseTotal
if ($d1 eq 'down') { } 8 28 36
elsif ($d1 eq 'up') { } 10 18 28
elsif ($previous_direction eq 'down') { } 9 9 18
elsif ($previous_direction eq 'up') { } 9 0 9
243 {
244 8 ▶ if($previous_direction eq 'right')
Branch: 2 branches
BranchTrueFalseTotal
if ($previous_direction eq 'right') { } 4 4 8
elsif ($previous_direction eq 'left') { } 4 0 4
245 {
246 4 $connection = $self->{ARROW_TYPE}[$rightdown_index][$connection_index] ;
247 }
248 elsif($previous_direction eq 'left')
249 {
250 4 $connection = $self->{ARROW_TYPE}[$leftdown_index][$connection_index] ;
251 }
252 else
253 {
254 0 $connection = $self->{ARROW_TYPE}[$up_index][$connection_index] ;
255 }
256 }
257 elsif($d1 eq 'up')
258 {
259 10 ▶ if($previous_direction eq 'right')
Branch: 2 branches
BranchTrueFalseTotal
if ($previous_direction eq 'right') { } 5 5 10
elsif ($previous_direction eq 'left') { } 5 0 5
260 {
261 5 $connection = $self->{ARROW_TYPE}[$rightup_index][$connection_index] ;
262 }
263 elsif($previous_direction eq 'left')
264 {
265 5 $connection = $self->{ARROW_TYPE}[$leftup_index][$connection_index] ;
266 }
267 else
268 {
269 0 $connection = $self->{ARROW_TYPE}[$up_index][$connection_index] ;
270 }
271 }
272 elsif($previous_direction eq 'down')
273 {
274 9 ▶ if($d1 eq 'left')
Branch: 1 branch
BranchTrueFalseTotal
if ($d1 eq 'left') { } 4 5 9
275 {
276 4 $connection = $self->{ARROW_TYPE}[$rightup_index][$connection_index] ;
277 }
278 else
279 {
280 5 $connection = $self->{ARROW_TYPE}[$leftup_index][$connection_index] ;
281 }
282 }
283 elsif($previous_direction eq 'up')
284 {
285 9 ▶ if($d1 eq 'left')
Branch: 1 branch
BranchTrueFalseTotal
if ($d1 eq 'left') { } 4 5 9
286 {
287 4 $connection = $self->{ARROW_TYPE}[$rightdown_index][$connection_index] ;
288 }
289 else
290 {
291 5 $connection = $self->{ARROW_TYPE}[$leftdown_index][$connection_index] ;
292 }
293 }
294 else
295 {
296 0 $connection = $self->{ARROW_TYPE}[$left_index][$body_index] ;
297 }
298 }
299 }
300
301 128 ▶ $previous_direction = defined $d2 ? $d2 : $d1 ;
Branch: 1 branch
BranchTrueFalseTotal
defined $d2 ? : 45 83 128
302 128 $previous_was_diagonal = undef ;
303 }
304
305 192 ▶ if($arrow_index != 0 && defined $connection) # first character of the first section is always right
Branch: 1 branch
BranchTrueFalseTotal
if ($arrow_index != 0 and defined $connection) 84 108 192
Condition100%3/3
$arrow_index != 0 and defined $connection
!ll&&!rl&&r
961284
MC/DC100%2/2
$arrow_index != 0 and defined $connection
$arrow_index != 0 defined $connection
Truth table100%3/3
A and B
A= $arrow_index != 0B= defined $connection
ABresult
0X0
100
111
306 {
307 # overlay the first character of this arrow
308 push @stripes,
309 {
310 TEXT => $connection,
311 WIDTH => 1,
312 HEIGHT => 1,
313 X_OFFSET => $self->{POINTS_OFFSETS}[$arrow_index][0],
314 84 Y_OFFSET => $self->{POINTS_OFFSETS}[$arrow_index][1],
315 } ;
316 }
317
318 192 $arrow_index++ ;
319 }
320
321 96 $stripes = $self->{CACHE}{STRIPES} = \@stripes ;
322 }
323  
324 96 return $stripes ;
325 }
326  
327 #-----------------------------------------------------------------------------
328  
329 sub get_selection_action
330 0 ▶{
Subroutine get_selection_action: not called CC=6 SCAR=37.4
Pod undocumented
331 0 my ($self, $x, $y) = @_ ;
332  
333 0 my $action = 'move' ;
334  
335 0 my $arrow_index = 0 ;
336 0 for my $arrow(@{$self->{ARROWS}})
337 {
338 0 my ($start_connector, $end_connector) = $arrow->get_connector_points() ;
339
340 0 $start_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
341 0 $start_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
342
343 0 ▶ if($x == $start_connector->{X} && $y == $start_connector->{Y})
Branch: 1 branch
BranchTrueFalseTotal
if ($x == $start_connector->{"X"} and $y == $start_connector->{"Y"}) 0 0 0
Condition0%0/3
$x == $start_connector->{"X"} and $y == $start_connector->{"Y"}
!ll&&!rl&&r
000
MC/DC0%0/2
$x == $start_connector->{"X"} and $y == $start_connector->{"Y"}
$x == $start_connector->{"X"} $y == $start_connector->{"Y"}
Truth table0%0/3
A and B
A= $x == $start_connector->{"X"}B= $y == $start_connector->{"Y"}
ABresult
0X0
100
111
344 {
345 0 $action = 'resize' ;
346 0 last ;
347 }
348
349 0 $end_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
350 0 $end_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
351
352 0 ▶ if($x == $end_connector->{X} && $y == $end_connector->{Y})
Branch: 1 branch
BranchTrueFalseTotal
if ($x == $end_connector->{"X"} and $y == $end_connector->{"Y"}) 0 0 0
Condition0%0/3
$x == $end_connector->{"X"} and $y == $end_connector->{"Y"}
!ll&&!rl&&r
000
MC/DC0%0/2
$x == $end_connector->{"X"} and $y == $end_connector->{"Y"}
$x == $end_connector->{"X"} $y == $end_connector->{"Y"}
Truth table0%0/3
A and B
A= $x == $end_connector->{"X"}B= $y == $end_connector->{"Y"}
ABresult
0X0
100
111
353 {
354 0 $action = 'resize' ;
355 0 last ;
356 }
357
358 0 $arrow_index++ ;
359 }
360  
361 0 return $action ;
362 }
363  
364 #-----------------------------------------------------------------------------
365  
366 sub allow_connection
367 0 ▶{
Subroutine allow_connection: not called CC=2 SCAR=17.9
Pod undocumented
368 0 my ($self, $which, $connect) = @_ ;
369  
370 0 ▶if($which eq 'start')
Branch: 1 branch
BranchTrueFalseTotal
if ($which eq 'start') { } 0 0 0
371 {
372 0 $self->{NOT_CONNECTABLE_START} = !$connect ;
373 }
374 else
375 {
376 0 $self->{NOT_CONNECTABLE_END} = !$connect ;
377 }
378 }
379  
380 #-----------------------------------------------------------------------------
381  
382 sub is_connection_allowed
383 0 ▶{
Subroutine is_connection_allowed: not called CC=2 SCAR=17.9
Pod undocumented
384 0 my ($self, $which) = @_ ;
385  
386 0 ▶if($which eq 'start')
Branch: 1 branch
BranchTrueFalseTotal
if ($which eq 'start') { } 0 0 0
387 {
388 0 return(! $self->{NOT_CONNECTABLE_START}) ;
389 }
390 else
391 {
392 0 return(! $self->{NOT_CONNECTABLE_END}) ;
393 }
394 }
395  
396 #-----------------------------------------------------------------------------
397  
398 sub are_diagonals_allowed
399 0 ▶{
Subroutine are_diagonals_allowed: not called CC=1 SCAR=6.9
Pod undocumented
400 0 my ($self, $allow) = @_ ;
401 0 return $self->{ALLOW_DIAGONAL_LINES} ;
402 }
403  
404 #-----------------------------------------------------------------------------
405  
406 sub allow_diagonals
407 0 ▶{
Subroutine allow_diagonals: not called CC=2 SCAR=17.9
Pod undocumented
408 0 my ($self, $allow) = @_ ;
409 0 $self->{ALLOW_DIAGONAL_LINES} = $allow ;
410  
411 0 for my $arrow(@{$self->{ARROWS}})
412 {
413 0 $arrow->{ALLOW_DIAGONAL_LINES} = $allow ;
414 }
415 }
416  
417 #-----------------------------------------------------------------------------
418  
419 sub get_connector_points
420 96 ▶{
Subroutine get_connector_points: called CC=3 SCAR=11.2
Pod undocumented
421 96 my ($self) = @_ ;
422  
423 96 my (@all_connector_points) = $self->get_all_points() ;
424 96 my (@connector_points) ;
425  
426 96 ▶push @connector_points, $all_connector_points[0] unless $self->{NOT_CONNECTABLE_START} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"NOT_CONNECTABLE_START"} 96 0 96
427 96 ▶push @connector_points, $all_connector_points[-1] unless $self->{NOT_CONNECTABLE_END} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"NOT_CONNECTABLE_END"} 96 0 96
428  
429 96 return(@connector_points) ;
430 }
431  
432 #-----------------------------------------------------------------------------
433  
434 sub get_extra_points
435 0 ▶{
Subroutine get_extra_points: not called CC=3 SCAR=24.8
Pod undocumented
436 0 my ($self) = @_ ;
437  
438 0 my(@all_connector_points) = $self->get_all_points() ;
439  
440 0 ▶shift @all_connector_points unless $self->{NOT_CONNECTABLE_START} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"NOT_CONNECTABLE_START"} 0 0 0
441 0 ▶pop @all_connector_points unless $self->{NOT_CONNECTABLE_END} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"NOT_CONNECTABLE_END"} 0 0 0
442  
443 0 return(@all_connector_points) ;
444 }
445  
446 #-----------------------------------------------------------------------------
447  
448 sub get_all_points
449 96 ▶{
Subroutine get_all_points: called CC=3 SCAR=11.0
Pod undocumented
450 96 my ($self) = @_ ;
451  
452 96 my(@connector_points) ;
453  
454 96 my $arrow_index = 0 ;
455  
456 96 for my $arrow(@{$self->{ARROWS}})
457 {
458 192 my ($start_connector, $end_connector) = $arrow->get_connector_points() ;
459
460 192 ▶ if($arrow == $self->{ARROWS}[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($arrow == $self->{"ARROWS"}[0]) 96 96 192
461 {
462 96 $start_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
463 96 $start_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
464 96 $start_connector->{NAME} .= "section_$arrow_index" ;
465
466 96 push @connector_points, $start_connector ;
467 }
468
469 192 $end_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
470 192 $end_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
471 192 $end_connector->{NAME} .= "section_$arrow_index" ;
472
473 192 push @connector_points, $end_connector ;
474 192 $arrow_index++ ;
475 }
476  
477 96 return(@connector_points) ;
478 }
479  
480 #-----------------------------------------------------------------------------
481  
482 sub get_named_connection
483 0 ▶{
Subroutine get_named_connection: not called CC=11 SCAR=48.8
Pod undocumented
484 0 my ($self, $name) = @_ ;
485  
486 0 my $connection ;
487  
488 0 my $arrow_index = 0 ;
489  
490 0 for my $arrow(@{$self->{ARROWS}})
491 {
492 0 my ($start_connector, $end_connector) = $arrow->get_connector_points() ;
493
494 0 ▶ if($arrow == $self->{ARROWS}[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($arrow == $self->{"ARROWS"}[0]) 0 0 0
495 {
496 0 $start_connector->{NAME} .= "section_$arrow_index" ;
497
498 0 ▶ if($name eq $start_connector->{NAME})
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq $start_connector->{"NAME"}) 0 0 0
499 {
500 0 $start_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
501 0 $start_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
502 0 $connection = $start_connector ;
503
504 0 for my $arrow_type (@{$arrow->{ARROW_TYPE}})
505 {
506 0 ▶ $connection->{CHAR} = $arrow_type->[1] and last if $arrow->{DIRECTION} eq $arrow_type->[0] ;
Branch: 1 branch
BranchTrueFalseTotal
if $arrow->{"DIRECTION"} eq $arrow_type->[0] 0 0 0
Condition0%0/5
$arrow->{'DIRECTION'} eq $arrow_type->[0] && (($connection->{'CHAR'} = $arrow_type->[1]) && (last))
!ll&&!rl&&r
000
$connection->{"CHAR"} = $arrow_type->[1] and last
!ll
00
MC/DC0%0/2
$arrow->{'DIRECTION'} eq $arrow_type->[0] && (($connection->{'CHAR'} = $arrow_type->[1]) && (last))
$arrow->{'DIRECTION'} eq $arrow_type->[0] $connection->{"CHAR"} = $arrow_type->[1]
Truth table0%0/3
A && B
A= $arrow->{'DIRECTION'} eq $arrow_type->[0]B= $connection->{"CHAR"} = $arrow_type->[1]
ABresult
0X0
100
111
507 }
508
509 0 last ;
510 }
511 }
512
513 0 $end_connector->{NAME} .= "section_$arrow_index" ;
514
515 0 ▶ if($name eq $end_connector->{NAME})
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq $end_connector->{"NAME"}) 0 0 0
516 {
517 0 $end_connector->{X} += $self->{POINTS_OFFSETS}[$arrow_index][0] ;
518 0 $end_connector->{Y} += $self->{POINTS_OFFSETS}[$arrow_index][1] ;
519 0 $connection = $end_connector ;
520
521 0 for my $arrow_type (@{$arrow->{ARROW_TYPE}})
522 {
523 0 ▶ $connection->{CHAR} = $arrow_type->[5] and last if $arrow->{DIRECTION} eq $arrow_type->[0] ;
Branch: 1 branch
BranchTrueFalseTotal
if $arrow->{"DIRECTION"} eq $arrow_type->[0] 0 0 0
Condition0%0/5
$arrow->{'DIRECTION'} eq $arrow_type->[0] && (($connection->{'CHAR'} = $arrow_type->[5]) && (last))
!ll&&!rl&&r
000
$connection->{"CHAR"} = $arrow_type->[5] and last
!ll
00
MC/DC0%0/2
$arrow->{'DIRECTION'} eq $arrow_type->[0] && (($connection->{'CHAR'} = $arrow_type->[5]) && (last))
$arrow->{'DIRECTION'} eq $arrow_type->[0] $connection->{"CHAR"} = $arrow_type->[5]
Truth table0%0/3
A && B
A= $arrow->{'DIRECTION'} eq $arrow_type->[0]B= $connection->{"CHAR"} = $arrow_type->[5]
ABresult
0X0
100
111
524 }
525
526 0 last ;
527 }
528
529 0 $arrow_index++ ;
530 }
531  
532 0 return $connection ;
533 }
534  
535 #-----------------------------------------------------------------------------
536  
537 sub move_connector
538 0 ▶{
Subroutine move_connector: not called CC=2 SCAR=17.9
Pod undocumented
539 0 my ($self, $connector_name, $x_offset, $y_offset, $hint) = @_ ;
540  
541 0 my $connection = $self->get_named_connection($connector_name) ;
542  
543 0 (my $no_section_connetor_name = $connector_name) =~ s/section_.*// ;
544  
545 0 ▶if($connection)
Branch: 1 branch
BranchTrueFalseTotal
if ($connection) { } 0 0 0
546 {
547 0 delete $self->{CACHE} ;
548
549 my ($x_offset, $y_offset, $width, $height, undef) =
550 $self->resize
551 (
552 $connection->{X},
553 $connection->{Y},
554 $connection->{X} + $x_offset,
555 0 $connection->{Y} + $y_offset,
556 $hint,
557 #~ [$no_section_connetor_name, $connector_name],
558 [$connector_name, $no_section_connetor_name],
559 ) ;
560
561 return
562 (
563 0 $x_offset, $y_offset, $width, $height,
564 $self->get_named_connection($connector_name)
565 ) ;
566 }
567 else
568 {
569 0 die "unknown connector '$connector_name'!\n" ;
570 }
571 }
572  
573 #-----------------------------------------------------------------------------
574  
575 sub resize
576 0 ▶{
Subroutine resize: not called CC=12 SCAR=50.5
Pod undocumented
577 0 my ($self, $reference_x, $reference_y, $new_x, $new_y, $hint, $connector_name_array) = @_ ;
578  
579 0 Readonly my $MULTI_WIRL_CONNECTOR_NAME_INDEX => 0 ;
580 0 Readonly my $WIRL_CONNECTOR_NAME_INDEX => 1 ;
581  
582 0 delete $self->{CACHE} ;
583  
584 0 my ($start_element, $start_element_index, $end_element, $end_element_index) ;
585  
586 # find elements connected by the connector
587 0 ▶if(defined $connector_name_array)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $connector_name_array) { } 0 0 0
588 {
589 0 ($start_element, $start_element_index, $end_element, $end_element_index, $connector_name_array) =
590 $self->find_elements_for_connector_named($connector_name_array) ;
591 }
592 else
593 {
594 0 ($start_element, $start_element_index, $end_element, $end_element_index, $connector_name_array) =
595 $self->find_elements_for_connector_at($reference_x, $reference_y) ;
596 }
597  
598 0 my ($start_x_offset, $start_y_offset) = (0, 0) ;
599 0 ▶if(defined $start_element)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $start_element) 0 0 0
600 {
601 0 my $is_start ;
602 0 ▶ if(defined $connector_name_array)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $connector_name_array) { } 0 0 0
603 {
604 0 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq "start" or $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq "startsection_0") 0 0 0
Condition0%0/3
$connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq "start" or $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq "startsection_0"
l!l&&r!l&&!r
000
MC/DC0%0/2
$connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq "start" or $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq "startsection_0"
$connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq "start" $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq "startsection_0"
Truth table0%0/3
A or B
A= $connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq "start"B= $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq "startsection_0"
ABresult
1X1
011
000
605 (
606 $connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX] eq 'start'
607 || $connector_name_array->[$MULTI_WIRL_CONNECTOR_NAME_INDEX] eq 'startsection_0'
608 )
609 {
610 0 $is_start++ ;
611 }
612 }
613 else
614 {
615 0 ▶ if($reference_x == 0 && $reference_y == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($reference_x == 0 and $reference_y == 0) 0 0 0
Condition0%0/3
$reference_x == 0 and $reference_y == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$reference_x == 0 and $reference_y == 0
$reference_x == 0 $reference_y == 0
Truth table0%0/3
A and B
A= $reference_x == 0B= $reference_y == 0
ABresult
0X0
100
111
616 {
617 0 $is_start++ ;
618 }
619 }
620
621 0 ▶ if($is_start)
Branch: 1 branch
BranchTrueFalseTotal
if ($is_start) { } 0 0 0
622 {
623 #~ print "Moving start connector\n" ;
624
625 0 ($start_x_offset, $start_y_offset) =
626 $start_element->resize
627 (
628 0, 0,
629 $new_x, $new_y,
630 $hint,
631 $connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX]
632 ) ;
633
634 0 my $arrow_index = 0 ;
635 0 for my $arrow(@{$self->{ARROWS}})
636 {
637 # offsets all other wirl_arrow start offsets
638 0 ▶ if($arrow == $start_element)
Branch: 1 branch
BranchTrueFalseTotal
if ($arrow == $start_element) { } 0 0 0
639 {
640 }
641 else
642 {
643 0 $self->{POINTS_OFFSETS}[$arrow_index][0] -= $start_x_offset ;
644 0 $self->{POINTS_OFFSETS}[$arrow_index][1] -= $start_y_offset ;
645 }
646
647 0 $arrow_index++ ;
648 }
649 }
650 else
651 {
652 0 my $start_element_x_offset = $self->{POINTS_OFFSETS}[$start_element_index][0] ;
653 0 my $start_element_y_offset = $self->{POINTS_OFFSETS}[$start_element_index][1] ;
654
655 0 my ($x_offset, $y_offset) =
656 $start_element ->resize
657 (
658 $reference_x - $start_element_x_offset,
659 $reference_y - $start_element_y_offset,
660 $new_x - $start_element_x_offset,
661 $new_y - $start_element_y_offset,
662 $hint,
663 $connector_name_array->[$WIRL_CONNECTOR_NAME_INDEX]
664 ) ;
665
666 0 $self->{POINTS_OFFSETS}[$start_element_index][0] += $x_offset ;
667 0 $self->{POINTS_OFFSETS}[$start_element_index][1] += $y_offset ;
668
669 0 ▶ if(defined $end_element)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $end_element) 0 0 0
670 {
671 0 my ($x_offset, $y_offset) = $end_element->resize(0, 0, $new_x - $reference_x, $new_y - $reference_y) ;
672 0 $self->{POINTS_OFFSETS}[$end_element_index][0] += $x_offset ;
673 0 $self->{POINTS_OFFSETS}[$end_element_index][1] += $y_offset ;
674 }
675 }
676 }
677  
678 0 my ($width, $height) = $self->get_width_and_height() ;
679 0 $self->set(WIDTH => $width, HEIGHT => $height) ;
680  
681 0 return($start_x_offset, $start_y_offset, $width, $height, $connector_name_array) ;
682 }
683  
684 sub find_elements_for_connector_at
685 0 ▶{
Subroutine find_elements_for_connector_at: not called CC=7 SCAR=40.3
Pod undocumented
686 0 my ($self, $reference_x, $reference_y) = @_ ;
687  
688 0 my ($start_element, $start_element_index, $end_element, $end_element_index, $connector_name, $wirl_connector_name) ;
689  
690 0 my $arrow_index = 0 ;
691 0 for my $arrow(@{$self->{ARROWS}})
692 {
693 0 my ($start_connector, $end_connector) = $arrow->get_connector_points() ;
694
695 0 ▶ if($reference_x == 0 && $reference_y == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($reference_x == 0 and $reference_y == 0) 0 0 0
Condition0%0/3
$reference_x == 0 and $reference_y == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$reference_x == 0 and $reference_y == 0
$reference_x == 0 $reference_y == 0
Truth table0%0/3
A and B
A= $reference_x == 0B= $reference_y == 0
ABresult
0X0
100
111
696 {
697 0 ($start_element, $start_element_index) = ($arrow, $arrow_index) ;
698 0 $wirl_connector_name = $start_connector->{NAME} ;
699 0 $connector_name = $wirl_connector_name . "section_$arrow_index" ;
700 0 last ;
701 }
702
703 0 ▶ if(defined $start_element)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $start_element) 0 0 0
704 {
705 0 ($end_element, $end_element_index) = ($arrow, $arrow_index) ;
706 0 last ;
707 }
708
709 0 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($reference_x == $end_connector->{"X"} + $self->{"POINTS_OFFSETS"}[$arrow_index][0] and $reference_y == $end_connector->{"Y"} + $self->{"POINTS_OFFSETS"}[$arrow_index][1]) 0 0 0
Condition0%0/3
$reference_x == $end_connector->{"X"} + $self->{"POINTS_OFFSETS"}[$arrow_index][0] and $reference_y == $end_connector->{"Y"} + $self->{"POINTS_OFFSETS"}[$arrow_index][1]
!ll&&!rl&&r
000
MC/DC0%0/2
$reference_x == $end_connector->{"X"} + $self->{"POINTS_OFFSETS"}[$arrow_index][0] and $reference_y == $end_connector->{"Y"} + $self->{"POINTS_OFFSETS"}[$arrow_index][1]
$reference_x == $end_connector->{"X"} + $self->{"POINTS_OFFSETS"}[$arrow_index][0] $reference_y == $end_connector->{"Y"} + $self->{"POINTS_OFFSETS"}[$arrow_index][1]
Truth table0%0/3
A and B
A= $reference_x == $end_connector->{"X"} + $self->{"POINTS_OFFSETS"}[$arrow_index][0]B= $reference_y == $end_connector->{"Y"} + $self->{"POINTS_OFFSETS"}[$arrow_index][1]
ABresult
0X0
100
111
710 (
711 $reference_x == $end_connector->{X} + $self->{POINTS_OFFSETS}[$arrow_index][0]
712 && $reference_y == $end_connector->{Y} + $self->{POINTS_OFFSETS}[$arrow_index][1]
713 )
714 {
715 0 ($start_element, $start_element_index) = ($arrow, $arrow_index) ;
716 0 $wirl_connector_name = $end_connector->{NAME} ;
717 0 $connector_name = $wirl_connector_name . "section_$arrow_index" ;
718 }
719
720 0 $arrow_index++ ;
721 }
722  
723 0 return($start_element, $start_element_index, $end_element, $end_element_index, [$connector_name, $wirl_connector_name])
724 }
725  
726 sub find_elements_for_connector_named
727 0 ▶{
Subroutine find_elements_for_connector_named: not called CC=5 SCAR=34.0
Pod undocumented
728 0 my ($self, $connector_name_array) = @_ ;
729  
730 0 my ($connector_name, $wirl_connector_name) = @{$connector_name_array} ;
731  
732 0 my ($start_element, $start_element_index, $end_element, $end_element_index) ;
733  
734 0 my $arrow_index = 0 ;
735 0 for my $arrow(@{$self->{ARROWS}})
736 {
737 0 my ($start_connector, $end_connector) = $arrow->get_connector_points() ;
738
739 0 ▶ if($connector_name eq $start_connector->{NAME} . "section_$arrow_index" )
Branch: 1 branch
BranchTrueFalseTotal
if ($connector_name eq $start_connector->{"NAME"} . "section_$arrow_index") 0 0 0
740 {
741 0 ($start_element, $start_element_index) = ($arrow, $arrow_index) ;
742 0 last ;
743 }
744
745 0 ▶ if(defined $start_element)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $start_element) 0 0 0
746 {
747 0 ($end_element, $end_element_index) = ($arrow, $arrow_index) ;
748 0 last ;
749 }
750
751 0 ▶ if($connector_name eq $end_connector->{NAME} . "section_$arrow_index")
Branch: 1 branch
BranchTrueFalseTotal
if ($connector_name eq $end_connector->{"NAME"} . "section_$arrow_index") 0 0 0
752 {
753 0 ($start_element, $start_element_index) = ($arrow, $arrow_index) ;
754 }
755
756 0 $arrow_index++ ;
757 }
758  
759 0 return($start_element, $start_element_index, $end_element, $end_element_index, $connector_name_array) ;
760 }
761  
762 #-----------------------------------------------------------------------------
763  
764 0 ▶sub get_number_of_sections { my ($self) = @_ ; return scalar(@{$self->{ARROWS}}) ; }
Subroutine get_number_of_sections: not called CC=1 SCAR=6.9
Pod undocumented
765  
766 #-----------------------------------------------------------------------------
767  
768 sub get_section_direction
769 0 ▶{
Subroutine get_section_direction: not called CC=2 SCAR=17.9
Pod undocumented
770 0 my ($self, $section_index) = @_ ;
771  
772 0 ▶if(exists($self->{ARROWS}[$section_index]))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'ARROWS'}[$section_index]) { } 0 0 0
773 {
774 0 return $self->{ARROWS}[$section_index]->get_direction() ;
775 }
776 else
777 {
778 0 return ;
779 }
780 }
781  
782 #-----------------------------------------------------------------------------
783  
784 sub insert_section
785 0 ▶{
Subroutine insert_section: not called CC=3 SCAR=24.8
Pod undocumented
786 0 my ($self, $x_offset, $y_offset) = @_ ;
787  
788 0 delete $self->{CACHE} ;
789  
790 0 my $index = 0 ;
791  
792 0 for my $arrow (@{$self->{ARROWS}})
793 {
794 0 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_over_element($arrow, $x_offset, $y_offset, 0, @{$$self{"POINTS_OFFSETS"}[$index];})) 0 0 0
795 (
796 $self->is_over_element
797 (
798 $arrow,
799 $x_offset, $y_offset, 0,
800 0 @{$self->{POINTS_OFFSETS}[$index]}
801 )
802 )
803 {
804 0 my ($original_arrow_end_x, $original_arrow_end_y) = ($arrow->{END_X}, $arrow->{END_Y}) ;
805
806 my $first_section = new App::Asciio::stripes::wirl_arrow
807 ({
808 END_X => $x_offset - $self->{POINTS_OFFSETS}[$index][0],
809 END_Y => $y_offset - $self->{POINTS_OFFSETS}[$index][1],
810 ARROW_TYPE => $arrow->{ARROW_TYPE},
811 DIRECTION => $arrow->{DIRECTION},
812 ALLOW_DIAGONAL_LINES => $arrow->{ALLOW_DIAGONAL_LINES},
813 EDITABLE => $arrow->{EDITABLE},
814 0 }) ;
815
816 0 $self->{ARROWS}[$index] = $first_section ;
817
818 my $new_section = new App::Asciio::stripes::wirl_arrow
819 ({
820 END_X => ($self->{POINTS_OFFSETS}[$index][0] + $original_arrow_end_x) - $x_offset,
821 END_Y => ($self->{POINTS_OFFSETS}[$index][1] + $original_arrow_end_y) - $y_offset,
822 ARROW_TYPE => $arrow->{ARROW_TYPE},
823 DIRECTION => $arrow->{DIRECTION},
824 ALLOW_DIAGONAL_LINES => $arrow->{ALLOW_DIAGONAL_LINES},
825 EDITABLE => $arrow->{EDITABLE},
826 0 }) ;
827
828 0 splice @{$self->{ARROWS}}, $index + 1, 0, $new_section ;
829 0 splice @{$self->{POINTS_OFFSETS}}, $index + 1, 0, [$x_offset, $y_offset] ;
830
831 0 last ;
832 }
833
834 0 $index++ ;
835 }
836 }
837  
838 #-----------------------------------------------------------------------------
839  
840 sub prepend_section
841 0 ▶{
Subroutine prepend_section: not called CC=2 SCAR=17.9
Pod undocumented
842 0 my ($self, $extend_x, $extend_y) = @_ ;
843  
844 0 delete $self->{CACHE} ;
845  
846 my $arrow = new App::Asciio::stripes::wirl_arrow
847 ({
848 END_X => -$extend_x,
849 END_Y => -$extend_y,
850 ARROW_TYPE => $self->{ARROW_TYPE},
851 DIRECTION => $self->{DIRECTION},
852 ALLOW_DIAGONAL_LINES => $self->{ALLOW_DIAGONAL_LINES},
853 EDITABLE => $self->{EDITABLE},
854 0 }) ;
855  
856 0 my $arrow_index = 0 ;
857 0 for my $arrow(@{$self->{ARROWS}})
858 {
859 0 $self->{POINTS_OFFSETS}[$arrow_index][0] += -$extend_x ;
860 0 $self->{POINTS_OFFSETS}[$arrow_index][1] += -$extend_y ;
861
862 0 $arrow_index++ ;
863 }
864  
865 0 unshift @{$self->{POINTS_OFFSETS}}, [0, 0] ;
866 0 unshift @{$self->{ARROWS}}, $arrow ;
867  
868 0 my ($width, $height) = $self->get_width_and_height() ;
869 0 $self->set(WIDTH => $width, HEIGHT => $height,) ;
870 }
871  
872 #-----------------------------------------------------------------------------
873  
874 sub append_section
875 0 ▶{
Subroutine append_section: not called CC=1 SCAR=6.9
Pod undocumented
876 0 my ($self, $extend_x, $extend_y) = @_ ;
877  
878 0 delete $self->{CACHE} ;
879  
880 0 my $last_point = $self->get_points()->[-1] ;
881  
882 my $arrow = new App::Asciio::stripes::wirl_arrow
883 ({
884 END_X => $extend_x - $last_point->[0],
885 END_Y => $extend_y - $last_point->[1],
886 ARROW_TYPE => $self->{ARROW_TYPE},
887 DIRECTION => $self->{DIRECTION},
888 ALLOW_DIAGONAL_LINES => $self->{ALLOW_DIAGONAL_LINES},
889 EDITABLE => $self->{EDITABLE},
890 0 }) ;
891  
892 0 my ($start_x, $start_y) = @{$self->{POINTS_OFFSETS}[-1]} ;
893 0 my ($start_connector, $end_connector) = $self->{ARROWS}[-1]->get_connector_points() ;
894  
895 0 $start_x += $end_connector->{X} ;
896 0 $start_y += $end_connector->{Y} ;
897  
898 0 push @{$self->{POINTS_OFFSETS}}, [$start_x, $start_y] ;
899 0 push @{$self->{ARROWS}}, $arrow ;
900  
901 0 my ($width, $height) = $self->get_width_and_height() ;
902 0 $self->set(WIDTH => $width, HEIGHT => $height,) ;
903 }
904  
905 #-----------------------------------------------------------------------------
906  
907 sub remove_last_section
908 0 ▶{
Subroutine remove_last_section: not called CC=2 SCAR=17.9
Pod undocumented
909 0 my ($self) = @_ ;
910  
911 0 ▶return if @{$self->{ARROWS}} == 1 ;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"ARROWS"};} == 1 0 0 0
912  
913 0 delete $self->{CACHE} ;
914  
915 0 pop @{$self->{POINTS_OFFSETS}} ;
916 0 pop @{$self->{ARROWS}} ;
917  
918 0 my ($width, $height) = $self->get_width_and_height() ;
919 0 $self->set(WIDTH => $width, HEIGHT => $height,) ;
920 }
921  
922 #-----------------------------------------------------------------------------
923  
924 sub remove_first_section
925 0 ▶{
Subroutine remove_first_section: not called CC=3 SCAR=24.8
Pod undocumented
926 0 my ($self) = @_ ;
927  
928 0 ▶return(0, 0) if @{$self->{ARROWS}} == 1 ;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"ARROWS"};} == 1 0 0 0
929  
930 0 delete $self->{CACHE} ;
931  
932 0 my $second_arrow_x_offset = $self->{POINTS_OFFSETS}[1][0] ;
933 0 my $second_arrow_y_offset = $self->{POINTS_OFFSETS}[1][1] ;
934  
935 0 shift @{$self->{POINTS_OFFSETS}} ;
936 0 shift @{$self->{ARROWS}} ;
937  
938 0 my $arrow_index = 0 ;
939 0 for my $arrow(@{$self->{ARROWS}})
940 {
941 0 $self->{POINTS_OFFSETS}[$arrow_index][0] -= $second_arrow_x_offset ;
942 0 $self->{POINTS_OFFSETS}[$arrow_index][1] -= $second_arrow_y_offset ;
943
944 0 $arrow_index++ ;
945 }
946  
947 0 my ($width, $height) = $self->get_width_and_height() ;
948 0 $self->set(WIDTH => $width, HEIGHT => $height,) ;
949  
950 0 return($second_arrow_x_offset, $second_arrow_y_offset) ;
951 }
952  
953 #-----------------------------------------------------------------------------
954  
955 sub change_section_direction
956 0 ▶{
Subroutine change_section_direction: not called CC=6 SCAR=37.4
Pod undocumented
957 0 my ($self, $x, $y) = @_ ;
958  
959 0 delete $self->{CACHE} ;
960  
961 0 ▶if(1 == @{$self->{ARROWS}})
Branch: 1 branch
BranchTrueFalseTotal
if (1 == @{$self->{'ARROWS'};}) { } 0 0 0
962 {
963 0 my $direction = $self->{ARROWS}[0]->get_direction() ;
964
965 0 ▶ if($direction =~ /(.*)-(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($direction =~ /(.*)-(.*)/) 0 0 0
966 {
967 0 $self->{ARROWS}[0]->resize(0, 0, 0, 0, "$2-$1") ;
968 }
969 }
970 else
971 {
972 0 my $index = 0 ;
973
974 0 for my $arrow(@{$self->{ARROWS}})
975 {
976 0 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_over_element($arrow, $x, $y, 0, @{$$self{"POINTS_OFFSETS"}[$index];})) 0 0 0
977 (
978 $self->is_over_element
979 (
980 $arrow,
981 $x, $y, 0,
982 0 @{$self->{POINTS_OFFSETS}[$index]}
983 )
984 )
985 {
986 0 my $direction = $arrow->get_direction() ;
987
988 0 ▶ if($direction =~ /(.*)-(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($direction =~ /(.*)-(.*)/) 0 0 0
989 {
990 0 $arrow->resize(0, 0, 0, 0, "$2-$1") ;
991 }
992
993 0 last ;
994 }
995
996 0 $index++ ;
997 }
998 }
999 }
1000  
1001 #-----------------------------------------------------------------------------
1002  
1003 sub change_last_section_direction
1004 0 ▶{
Subroutine change_last_section_direction: not called CC=2 SCAR=17.9
Pod undocumented
1005 0 my ($self, $x, $y) = @_ ;
1006  
1007 0 delete $self->{CACHE} ;
1008  
1009 0 my $direction = $self->{ARROWS}[-1]->get_direction() ;
1010  
1011 0 ▶if($direction =~ /(.*)-(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($direction =~ /(.*)-(.*)/) 0 0 0
1012 {
1013 0 $self->{ARROWS}[-1]->resize(0, 0, 0, 0, "$2-$1") ;
1014 }
1015 }
1016  
1017 #-----------------------------------------------------------------------------
1018  
1019 sub is_over_element
1020 0 ▶{
Subroutine is_over_element: not called CC=7 SCAR=40.3
Pod undocumented
1021 0 my ($self, $element, $x, $y, $field, $element_offset_x, $element_offset_y, ) = @_ ;
1022  
1023 0 ▶$field ||= 0 ;
Condition0%0/2
$field ||= 0
l!l
00
MC/DC0%0/1
$field ||= 0
$field
Truth table0%0/2
A
A= $field
Aresult
11
00
1024 0 my $is_under = 0 ;
1025  
1026 0 for my $strip (@{$element->get_stripes()})
1027 {
1028 0 my $stripe_x = $element_offset_x + $strip->{X_OFFSET} ;
1029 0 my $stripe_y = $element_offset_y + $strip->{Y_OFFSET} ;
1030
1031 0 ▶ if
Branch: 1 branch
BranchTrueFalseTotal
if ($stripe_x - $field <= $x and $x < $stripe_x + $strip->{"WIDTH"} + $field and $stripe_y - $field <= $y and $y < $stripe_y + $strip->{"HEIGHT"} + $field) 0 0 0
Condition0%0/9
$stripe_x - $field <= $x and $x < $stripe_x + $strip->{"WIDTH"} + $field and $stripe_y - $field <= $y and $y < $stripe_y + $strip->{"HEIGHT"} + $field
!ll&&!rl&&r
000
$stripe_x - $field <= $x and $x < $stripe_x + $strip->{"WIDTH"} + $field and $stripe_y - $field <= $y
!ll&&!rl&&r
000
$stripe_x - $field <= $x and $x < $stripe_x + $strip->{"WIDTH"} + $field
!ll&&!rl&&r
000
MC/DC0%0/4
$stripe_x - $field <= $x and $x < $stripe_x + $strip->{"WIDTH"} + $field and $stripe_y - $field <= $y and $y < $stripe_y + $strip->{"HEIGHT"} + $field
$stripe_x - $field <= $x $x < $stripe_x + $strip->{"WIDTH"} + $field $stripe_y - $field <= $y $y < $stripe_y + $strip->{"HEIGHT"} + $field
Truth table0%0/5
A and B and C and D
A= $stripe_x - $field <= $xB= $x < $stripe_x + $strip->{"WIDTH"} + $fieldC= $stripe_y - $field <= $yD= $y < $stripe_y + $strip->{"HEIGHT"} + $field
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1032 (
1033 $stripe_x - $field <= $x && $x < $stripe_x + $strip->{WIDTH} + $field
1034 && $stripe_y - $field <= $y && $y < $stripe_y + $strip->{HEIGHT} + $field
1035 )
1036 {
1037 0 $is_under++ ;
1038 0 last ;
1039 }
1040 }
1041  
1042 0 return($is_under) ;
1043 }
1044  
1045 #-----------------------------------------------------------------------------
1046  
1047 sub get_width_and_height
1048 96 ▶{
Subroutine get_width_and_height: called CC=2 SCAR=6.9
Pod undocumented
1049 96 my ($self) = @_ ;
1050  
1051 96 my ($smallest_x, $biggest_x, $smallest_y, $biggest_y) = (0, 0, 0, 0) ;
1052  
1053 96 my $arrow_index = 0 ;
1054 96 for my $start_point (@{$self->{POINTS_OFFSETS}})
1055 {
1056 192 my ($x, $y) = @{$start_point} ;
1057
1058 192 my ($start_connector, $end_connector) = $self->{ARROWS}[$arrow_index]->get_connector_points() ;
1059 192 $x += $end_connector->{X} ;
1060 192 $y += $end_connector->{Y} ;
1061
1062 192 $smallest_x = min($smallest_x, $x) ;
1063 192 $smallest_y = min($smallest_y, $y) ;
1064 192 $biggest_x = max($biggest_x, $x) ;
1065 192 $biggest_y = max($biggest_y, $y) ;
1066
1067 192 $arrow_index++ ;
1068 }
1069  
1070 96 $self->{EXTENTS} = [$smallest_x, $smallest_y, $biggest_x + 1, $biggest_y + 1] ;
1071  
1072 96 return(($biggest_x - $smallest_x) + 1, ($biggest_y - $smallest_y) + 1) ;
1073 }
1074  
1075 #-----------------------------------------------------------------------------
1076  
1077 0 ▶sub get_arrow_type { my ($self) = @_ ; return($self->{ARROW_TYPE}) ; }
Subroutine get_arrow_type: not called CC=1 SCAR=6.9
Pod undocumented
1078  
1079 #-----------------------------------------------------------------------------
1080  
1081 sub set_arrow_type
1082 0 ▶{
Subroutine set_arrow_type: not called CC=1 SCAR=6.9
Pod undocumented
1083 0 my ($self, $arrow_type) = @_ ;
1084  
1085 0 delete $self->{CACHE} ;
1086 0 $self->setup($arrow_type, $self->get_points(), $self->{DIRECTION}, $self->{ALLOW_DIAGONAL_LINES}, $self->{EDITABLE}) ;
1087 }
1088  
1089 #-----------------------------------------------------------------------------
1090  
1091 sub get_points
1092 0 ▶{
Subroutine get_points: not called CC=2 SCAR=17.9
Pod undocumented
1093 0 my ($self) = @_ ;
1094  
1095 0 my @points ;
1096 0 my $arrow_index = 0 ;
1097  
1098 0 for my $point_offset (@{$self->{POINTS_OFFSETS}})
1099 {
1100 0 my ($x_offset, $y_offset) = @{$point_offset} ;
1101 my ($start_connector, $end_connector, $direction)
1102 = (
1103 $self->{ARROWS}[$arrow_index]->get_connector_points(),
1104 0 $self->{ARROWS}[$arrow_index]->get_direction()
1105 ) ;
1106
1107 0 push @points, [$x_offset + $end_connector->{X}, $y_offset + $end_connector->{Y}, $direction] ;
1108
1109 0 $arrow_index++ ;
1110 }
1111  
1112 0 return \@points ;
1113 }
1114  
1115 #-----------------------------------------------------------------------------
1116  
1117 sub edit
1118 0 ▶{
Subroutine edit: not called CC=2 SCAR=17.9
Pod undocumented
1119 0 my ($self) = @_ ;
1120  
1121 0 ▶return unless $self->{EDITABLE} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"EDITABLE"} 0 0 0
1122  
1123 0 delete $self->{CACHE} ;
1124  
1125 0 $self->display_arrow_edit_dialog() ;
1126 }
1127  
1128 #-----------------------------------------------------------------------------
1129  
1130 2 1 ;
1131  
« blib/lib/App/Asciio/Elements.pm ↑ Summary blib/lib/App/Asciio/Actions/ElementsManipulation.pm »