📄 insert.c
字号:
/****************************************************************/
/* COPYRIGHT NOTICE */
/* ---------------- */
/* All software in this listing remain the strict copyright */
/* of Ilija Kovacevic and cannot be copied or used in any way */
/* except by written permission of Ilija Kovacevic. */
/* */
/* Copyright (c) 1992 Ilija Kovacevic */
/* www.kov.com email ilija@kov.com */
/****************************************************************/
#include "dwgin.h"
PUBLIC AcadInsert *AcadInsert__create( void )
{
return( ( AcadInsert * )get_memory( sizeof( AcadInsert ) ) );
}
PUBLIC void AcadInsert__delete( AcadInsert *me )
{
free( ( char * )me );
}
PUBLIC int AcadInsert__length( AcadInsert *me )
{
return( me->common.size );
}
PUBLIC void AcadInsert__read( AcadInsert *me )
{
AcadEntity__read_elevation_etc( &me->common,true,true );
me->x_scale = me->y_scale = me->z_scale = 1.0;
me->rotation = 0.0;
me->columns = me->rows = 1;
me->column_spacing = me->row_spacing = 0.0;
get_INT16( &me->block_number );
if ( me->block_number < 0 OR me->block_number > __drawing->header->blocks ) read_error( "Block number out of bounds %xH",me->block_number );
get_DOUBLE( &me->x );
get_DOUBLE( &me->y );
if ( me->common.pflags&0x1 ) get_DOUBLE( &me->x_scale );
if ( me->common.pflags&0x2 ) get_DOUBLE( &me->y_scale );
if ( me->common.pflags&0x4 ) get_DOUBLE( &me->rotation );
if ( me->common.pflags&0x8 ) get_DOUBLE( &me->z_scale );
if ( me->common.pflags&0x10 ) get_INT16( &me->columns );
if ( me->common.pflags&0x20 ) get_INT16( &me->rows );
if ( me->common.pflags&0x40 ) get_DOUBLE( &me->column_spacing );
if ( me->common.pflags&0x80 ) get_DOUBLE( &me->row_spacing );
if ( ( __drawing->acad10 OR __drawing->acad11 ) AND me->common.pflags&0x100 ) AcadEntity__get_ucs_directions( &me->common );
}
PUBLIC void AcadInsert__dump_to_debug_file( AcadInsert *me )
{
dprintf( "INSERT\n" );
dprintf( "\tblock %xH\n",me->block_number );
dprintf( "\tat %lf,%lf\n",me->x,me->y );
dprintf( "\tscale %lf,%lf,%lf\n",me->x_scale,me->y_scale,me->z_scale );
dprintf( "\t%lf\n",me->rotation );
dprintf( "\tspacing\n",me->column_spacing,me->row_spacing );
dprintf( "\tcolums %d rows %d\n",me->columns,me->rows );
AcadEntity__dump_to_debug_file( &me->common );
}
PUBLIC void AcadInsert__dxfout( AcadInsert *me )
{
dxf_string( 0,"INSERT" );
AcadEntity__dxfout( &me->common );
if ( __drawing->block[ me->block_number ]->flag & 0x2 ) dxf_INT16( 66,1 );
dxf_string( 2,__drawing->block[ me->block_number ]->name );
dxf_DOUBLE( 10,me->x );
dxf_DOUBLE( 20,me->y );
if ( !__drawing->header->flatland ) dxf_DOUBLE( 30,me->common.elevation );
if ( me->x_scale NEQ 1.0 ) dxf_DOUBLE( 41,me->x_scale );
if ( me->y_scale NEQ 1.0 ) dxf_DOUBLE( 42,me->y_scale );
if ( me->rotation ) dxf_DOUBLE( 50,rad_to_degrees( me->rotation ) );
if ( me->z_scale NEQ 1.0 ) dxf_DOUBLE( 43,me->z_scale );
if ( me->columns NEQ 1 OR me->rows NEQ 1 )
{
dxf_INT16( 70,me->columns );
dxf_INT16( 71,me->rows );
}
if ( me->column_spacing ) dxf_DOUBLE( 44,me->column_spacing );
if ( me->row_spacing ) dxf_DOUBLE( 45,me->row_spacing );
AcadEntity__dxfout_ucs( &me->common );
}
PUBLIC void AcadInsert__write( AcadInsert *me )
{
int size;
put_UINT8( 0xe ); /* INSERT TYPE */
size = 1;
if ( me->common.ucs ) size += sizeof( DOUBLE )*3;
size += sizeof( me->block_number );
size += sizeof( me->x );
size += sizeof( me->y );
if ( me->common.pflags&0x1 ) size += sizeof( me->x_scale );
if ( me->common.pflags&0x2 ) size += sizeof( me->y_scale );
if ( me->common.pflags&0x4 ) size += sizeof( me->rotation );
if ( me->common.pflags&0x8 ) size += sizeof( me->z_scale );
if ( me->common.pflags&0x10 ) size += sizeof( me->columns );
if ( me->common.pflags&0x20 ) size += sizeof( me->rows );
if ( me->common.pflags&0x40 ) size += sizeof( me->column_spacing );
if ( me->common.pflags&0x80 ) size += sizeof( me->row_spacing );
AcadEntity__write_elevation_etc( &me->common,true,true,size );
if ( debugger ) dprintf( "\tinsert entity\n" );
put_INT16( me->block_number );
put_DOUBLE( me->x );
put_DOUBLE( me->y );
if ( me->common.pflags&0x1 ) put_DOUBLE( me->x_scale );
if ( me->common.pflags&0x2 ) put_DOUBLE( me->y_scale );
if ( me->common.pflags&0x4 ) put_DOUBLE( me->rotation );
if ( me->common.pflags&0x8 ) put_DOUBLE( me->z_scale );
if ( me->common.pflags&0x10 ) put_INT16( me->columns );
if ( me->common.pflags&0x20 ) put_INT16( me->rows );
if ( me->common.pflags&0x40 ) put_DOUBLE( me->column_spacing );
if ( me->common.pflags&0x80 ) put_DOUBLE( me->row_spacing );
if ( me->common.ucs ) AcadEntity__put_ucs_directions( &me->common );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -