CAD-Drawing

 view release on metacpan or  search on metacpan

lib/CAD/Drawing/IO.pm  view on Meta::CPAN

=head1 NO WARRANTY

This software is distributed with ABSOLUTELY NO WARRANTY.  The author,
his former employer, and any other contributors will in no way be held
liable for any loss or damages resulting from its use.

=head1 Modifications

The source code of this module is made freely available and
distributable under the GPL or Artistic License.  Modifications to and
use of this software must adhere to one of these licenses.  Changes to
the code should be noted as such and this notification (as well as the
above copyright information) must remain intact on all copies of the
code.

Additionally, while the author is actively developing this code,
notification of any intended changes or extensions would be most helpful
in avoiding repeated work for all parties involved.  Please contact the
author with any such development plans.

=head1 SEE ALSO

=over

=item L<CAD::Drawing|CAD::Drawing>

The frontend.

=back

=head2 Builtin Backends

The following modules are included in the main distribution.

=over

=item L<CAD::Drawing::IO::Circ|CAD::Drawing::IO::Circ>

=item L<CAD::Drawing::IO::Compressed|CAD::Drawing::IO::Compressed>

=item L<CAD::Drawing::IO::FlatYAML|CAD::Drawing::IO::FlatYAML>

=item L<CAD::Drawing::IO::Split|CAD::Drawing::IO::Split>

=back

=head2 External Backends

=over

=item L<CAD::Drawing::IO::OpenDWG|CAD::Drawing::IO::OpenDWG>

DWG/DXF handling using the OpenDWG toolkit.

=item L<CAD::Drawing::IO::PostScript|CAD::Drawing::IO::PostScript>

Postscript output.

=item L<CAD::Drawing::IO::Image|CAD::Drawing::IO::Image>

Image::Magick based output.

=item L<CAD::Drawing::IO::PgDB|CAD::Drawing::IO::PgDB>

PostgreSQL connected drawing database.

=item L<CAD::Drawing::IO::Tk|CAD::Drawing::IO::Tk>

Tk::WorldCanvas popup viewer -- not exactly an input/output backend, but
it uses much of the same facility because it is primarily just output to
a display.

=back

=cut
########################################################################

=head1 front-end Input and output methods

The functions load() and save() are responsible for determining the
filetype (with forced types available via $options{type}.)  These then
call the appropriate <Package>::load() or <Package>::save() functions.

See the Plug-In Architecture section for details on how to add support
for additional filetypes.

Beginning with version 0.26, a string-based type specification is
available by using $filename = "$type:filename".  While this prevents
you from saving files with colons in the names, an explicit type passed
in the options will allow it.  This gives the added bonus that your
program's users may directly control the output type simply by giving a
<type>:<file> argument on the command line (if that is where you get
your filenames.)

=head2 save

Saves a file to disk.  See the save<type> functions in this file and the
other filetype functions in the CAD::Drawing::IO::<type> modules.

See each save<type> function for available options for that type.

While you may call the save<type> function directly (if you include the
module), it is recommended that you stick to the single point of
interface provided here so that your code does not become overwhelmingly
infected with hard-coded filetypes.

Note that this method also implements forking.  If $options{forkokay} is
true, save() will return the pid of the child process to the parent
process and setup the child to exit after saving (with currently no way
for the child to give a return value to the parent (but (-e $filename)
might work for you).)

  $drw->save($filename, \%options);

=cut
sub save {
	my $self = shift;
	my ( $filename, $opt) = @_;
	my $type = $$opt{type};
	if($$opt{forkokay}) {
		$SIG{CHLD} = 'IGNORE';



( run in 2.263 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )