| 1 | package Draft::Entity::Reference; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Draft::Entity::Reference - CAD reference drawing-object | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | Points to one or more L<Draft::Drawing> objects and places them in | ||||||||||
| 10 | space. | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use Draft::Drawing; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | # FIXME shouldn't depend on Tk | ||||||||||
| 19 | 1 | ▶ | use Draft::TkGui::Entity::Reference; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | ▶ | use vars qw /@ISA/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | @ISA = qw /Draft::TkGui::Entity::Reference/; | |||||||||
| 22 | |||||||||||
| 23 | =pod | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | A reference has some interesting attributes; coordinates for placing | ||||||||||
| 28 | it in space, paths to L<Draft::Drawing> objects and parts of them to | ||||||||||
| 29 | ignore. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 USAGE | ||||||||||
| 32 | |||||||||||
| 33 | Processing the data in a Reference object causes referenced drawings | ||||||||||
| 34 | to be read if necessary: | ||||||||||
| 35 | |||||||||||
| 36 | $self->Process; | ||||||||||
| 37 | |||||||||||
| 38 | =cut | ||||||||||
| 39 | |||||||||||
| 40 | sub Process | ||||||||||
| 41 | 1 | ▶ | { | ||||||||
|
Subroutine
Process: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||
| 42 | 1 | my $self = shift; | |||||||||
| 43 | |||||||||||
| 44 | 1 | my $dir = $self->{_path}; | |||||||||
| 45 | 1 | $dir =~ s/[^\/]*$//; | |||||||||
| 46 | |||||||||||
| 47 | 1 | for my $path (@{$self->{location}}) | |||||||||
| 48 | { | ||||||||||
| 49 | 1 | $path = _clean_path ($dir . $path); | |||||||||
| 50 | $Draft::WORLD->{$path} = Draft::Drawing->new ($path) | ||||||||||
| 51 | 1 | ▶ | unless exists $Draft::WORLD->{$path}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 1 | $Draft::WORLD->{$path}->Read; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | @{$self->{ignore}} = map _clean_path ($dir . $_), @{$self->{ignore}}; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | sub _clean_path | ||||||||||
| 59 | 1 | ▶ | { | ||||||||
|
Subroutine
_clean_path: called CC=2 SCAR=6.9
| |||||||||||
| 60 | 1 | my $path = shift; | |||||||||
| 61 | 1 | ▶ | while ($path =~ /[^\/]\/\.\.\//) { $path =~ s/[^\/]+\/\.\.\/// } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 1 | return $path; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | 1; | |||||||||