Draft::Entity::Reference - CAD reference drawing-object


Draft documentation Contained in the Draft distribution.

Index


Code Index:

NAME

Top

Draft::Entity::Reference - CAD reference drawing-object

SYNOPSIS

Top

Points to one or more Draft::Drawing objects and places them in space.

DESCRIPTION

Top

A reference has some interesting attributes; coordinates for placing it in space, paths to Draft::Drawing objects and parts of them to ignore.

USAGE

Top

Processing the data in a Reference object causes referenced drawings to be read if necessary:

    $self->Process;


Draft documentation Contained in the Draft distribution.
package Draft::Entity::Reference;

use strict;
use warnings;
use Draft::Drawing;

# FIXME shouldn't depend on Tk
use Draft::TkGui::Entity::Reference;
use vars qw /@ISA/;
@ISA = qw /Draft::TkGui::Entity::Reference/;

sub Process
{
    my $self = shift;

    my $dir = $self->{_path};
    $dir =~ s/[^\/]*$//;

    for my $path (@{$self->{location}})
    {
        $path = _clean_path ($dir . $path);
        $Draft::WORLD->{$path} = Draft::Drawing->new ($path)
            unless exists $Draft::WORLD->{$path};
        $Draft::WORLD->{$path}->Read;
    }

    @{$self->{ignore}} = map _clean_path ($dir . $_), @{$self->{ignore}};
}

sub _clean_path
{
    my $path = shift;
    while ($path =~ /[^\/]\/\.\.\//) { $path =~ s/[^\/]+\/\.\.\/// }
    return $path;
}

1;