Skip to content

Commit

Permalink
spec: change some ATTDEF fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Oct 5, 2024
1 parent b4b1ad6 commit de8a42c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 72 deletions.
10 changes: 5 additions & 5 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1164,14 +1164,16 @@ BS, DXF 72
BS, DXF 74
@item dataflags
RC
@item class_version
@item is_locked_in_block
RC, DXF 280
@item type
@item keep_duplicate_records
RC, DXF 280
@item mtext_type
RC, DXF 70
@item tag
T, DXF 2
@item field_length
BS
BS, DXF 73
@item flags
RC, DXF 70
@item lock_position_flag
Expand All @@ -1188,8 +1190,6 @@ RC
H
@item annotative_short
BS
@item attdef_class_version
RC
@item prompt
T, DXF 3

Expand Down
6 changes: 3 additions & 3 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1398,8 +1398,9 @@ typedef struct _dwg_entity_ATTDEF
BITCODE_BS horiz_alignment;
BITCODE_BS vert_alignment;
BITCODE_RC dataflags;
BITCODE_RC class_version; /* R2010+ */
BITCODE_RC type; /* R2018+ */
BITCODE_RC is_locked_in_block; /* R2007+ */
BITCODE_RC keep_duplicate_records; /* R2007+ */
BITCODE_RC mtext_type; /* R2018+ */
BITCODE_T tag;
BITCODE_BS field_length;
BITCODE_RC flags; /* => HEADER.AFLAGS */
Expand All @@ -1411,7 +1412,6 @@ typedef struct _dwg_entity_ATTDEF
BITCODE_H annotative_app;
BITCODE_BS annotative_short;

BITCODE_RC attdef_class_version; /* R2010+ */
BITCODE_T prompt;
} Dwg_Entity_ATTDEF;

Expand Down
19 changes: 10 additions & 9 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -559,26 +559,27 @@ DWG_ENTITY (ATTDEF)
DXF {
FIELD_T (prompt, 3);
FIELD_T (tag, 2);
FIELD_RC (type, 70);
FIELD_RC (mtext_type, 70);
SINCE (R_13b1) {
//FIELD_BS (field_length, 73);
FIELD_BS0 (field_length, 73);
FIELD_BS0 (vert_alignment, 74);
}
SINCE (R_2004a) {
FIELD_RC (class_version, 280);
FIELD_RC (is_locked_in_block, 280);
FIELD_RC (keep_duplicate_records, 280);
}
}
SINCE (R_2010b)
{
//int dxf = dat->version == R_2010 ? 280: 0;
FIELD_RC (class_version, 0); // 0 = r2010
VALUEOUTOFBOUNDS (class_version, 10)
FIELD_RC (is_locked_in_block, 0); // 0 = r2010
VALUEOUTOFBOUNDS (is_locked_in_block, 1)
}
IF_FREE_OR_SINCE (R_2018)
{
FIELD_RC (type, 0); // 1=single line, 2=multi line attrib, 4=multi line attdef
FIELD_RC (mtext_type, 0); // 1=single line, 2=multi line attrib, 4=multi line attdef

if (FIELD_VALUE (type) > 1)
if (FIELD_VALUE (mtext_type) > 1)
{
SUBCLASS (AcDbMText)
LOG_WARN ("MTEXT fields")
Expand Down Expand Up @@ -607,8 +608,8 @@ DWG_ENTITY (ATTDEF)
}
// specific to ATTDEF
SINCE (R_2010b) {
FIELD_RC (attdef_class_version, 0);
VALUEOUTOFBOUNDS (attdef_class_version, 10)
FIELD_RC (keep_duplicate_records, 0);
VALUEOUTOFBOUNDS (keep_duplicate_records, 1)
}
FIELD_T (prompt, 0);
}
Expand Down
10 changes: 5 additions & 5 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,14 +1128,16 @@ static const Dwg_DYNAPI_field _dwg_ATTDEF_fields[] = {
0,0,0, 74 },
{ "dataflags", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, dataflags),
0,0,0, 0 },
{ "class_version", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, class_version),
{ "is_locked_in_block", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, is_locked_in_block),
0,0,0, 280 },
{ "type", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, type),
{ "keep_duplicate_records", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, keep_duplicate_records),
0,0,0, 280 },
{ "mtext_type", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, mtext_type),
0,0,0, 70 },
{ "tag", "T", sizeof (BITCODE_T), OFF (struct _dwg_entity_ATTDEF, tag),
1,1,1, 2 },
{ "field_length", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_entity_ATTDEF, field_length),
0,0,0, 0 },
0,0,0, 73 },
{ "flags", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, flags),
0,0,0, 70 },
{ "lock_position_flag", "B", sizeof (BITCODE_B), OFF (struct _dwg_entity_ATTDEF, lock_position_flag),
Expand All @@ -1152,8 +1154,6 @@ static const Dwg_DYNAPI_field _dwg_ATTDEF_fields[] = {
1,0,0, 0 },
{ "annotative_short", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_entity_ATTDEF, annotative_short),
0,0,0, 0 },
{ "attdef_class_version", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTDEF, attdef_class_version),
0,0,0, 0 },
{ "prompt", "T", sizeof (BITCODE_T), OFF (struct _dwg_entity_ATTDEF, prompt),
1,1,1, 3 },
{NULL, NULL, 0, 0, 0,0,0, 0},
Expand Down
10 changes: 5 additions & 5 deletions test/unit-testing/attdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ api_process (dwg_object *obj)
double elevation, thickness, rotation, height, oblique_angle, width_factor;
BITCODE_BS generation, vert_alignment, horiz_alignment, field_length,
annotative_data_size, annotative_short;
BITCODE_RC dataflags, flags, type, class_version, attdef_class_version,
BITCODE_RC dataflags, flags, mtext_type, is_locked_in_block, keep_duplicate_records,
annotative_data_bytes;
BITCODE_B lock_position_flag;
char *tag, *default_value, *prompt;
Expand Down Expand Up @@ -44,14 +44,14 @@ api_process (dwg_object *obj)
CHK_ENTITY_TYPE (attdef, ATTDEF, field_length, BS);
CHK_ENTITY_TYPE (attdef, ATTDEF, flags, RC);
CHK_ENTITY_H (attdef, ATTDEF, style);
if (version >= R_2010)
if (version >= R_2007)
{
CHK_ENTITY_TYPE (attdef, ATTDEF, class_version, RC);
CHK_ENTITY_TYPE (attdef, ATTDEF, attdef_class_version, RC);
CHK_ENTITY_TYPE (attdef, ATTDEF, is_locked_in_block, RC);
CHK_ENTITY_TYPE (attdef, ATTDEF, keep_duplicate_records, RC);
}
if (version >= R_2018)
{
CHK_ENTITY_TYPE (attdef, ATTDEF, type, RC);
CHK_ENTITY_TYPE (attdef, ATTDEF, mtext_type, RC);
CHK_ENTITY_H (attdef, ATTDEF, mtext_style);
CHK_ENTITY_TYPE (attdef, ATTDEF, annotative_data_size, BS);
CHK_ENTITY_TYPE (attdef, ATTDEF, annotative_data_bytes, RC);
Expand Down
90 changes: 45 additions & 45 deletions test/unit-testing/dynapi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7690,36 +7690,6 @@ static int test_ATTDEF (const Dwg_Object *obj)
fail ("ATTDEF.annotative_short [BS] set+1 %hu != %hu", attdef->annotative_short, annotative_short);
attdef->annotative_short--;
}
{
BITCODE_RC attdef_class_version;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "attdef_class_version", &attdef_class_version, NULL)
&& attdef_class_version == attdef->attdef_class_version)
pass ();
else
fail ("ATTDEF.attdef_class_version [RC] %u != %u", attdef->attdef_class_version, attdef_class_version);
attdef_class_version++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "attdef_class_version", &attdef_class_version, 0)
&& attdef_class_version == attdef->attdef_class_version)
pass ();
else
fail ("ATTDEF.attdef_class_version [RC] set+1 %u != %u", attdef->attdef_class_version, attdef_class_version);
attdef->attdef_class_version--;
}
{
BITCODE_RC class_version;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "class_version", &class_version, NULL)
&& class_version == attdef->class_version)
pass ();
else
fail ("ATTDEF.class_version [RC] %u != %u", attdef->class_version, class_version);
class_version++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "class_version", &class_version, 0)
&& class_version == attdef->class_version)
pass ();
else
fail ("ATTDEF.class_version [RC] set+1 %u != %u", attdef->class_version, class_version);
attdef->class_version--;
}
{
BITCODE_RC dataflags;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "dataflags", &dataflags, NULL)
Expand Down Expand Up @@ -7851,6 +7821,36 @@ static int test_ATTDEF (const Dwg_Object *obj)
else
fail ("ATTDEF.ins_pt [2DPOINT]");
}
{
BITCODE_RC is_locked_in_block;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "is_locked_in_block", &is_locked_in_block, NULL)
&& is_locked_in_block == attdef->is_locked_in_block)
pass ();
else
fail ("ATTDEF.is_locked_in_block [RC] %u != %u", attdef->is_locked_in_block, is_locked_in_block);
is_locked_in_block++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "is_locked_in_block", &is_locked_in_block, 0)
&& is_locked_in_block == attdef->is_locked_in_block)
pass ();
else
fail ("ATTDEF.is_locked_in_block [RC] set+1 %u != %u", attdef->is_locked_in_block, is_locked_in_block);
attdef->is_locked_in_block--;
}
{
BITCODE_RC keep_duplicate_records;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "keep_duplicate_records", &keep_duplicate_records, NULL)
&& keep_duplicate_records == attdef->keep_duplicate_records)
pass ();
else
fail ("ATTDEF.keep_duplicate_records [RC] %u != %u", attdef->keep_duplicate_records, keep_duplicate_records);
keep_duplicate_records++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "keep_duplicate_records", &keep_duplicate_records, 0)
&& keep_duplicate_records == attdef->keep_duplicate_records)
pass ();
else
fail ("ATTDEF.keep_duplicate_records [RC] set+1 %u != %u", attdef->keep_duplicate_records, keep_duplicate_records);
attdef->keep_duplicate_records--;
}
{
BITCODE_B lock_position_flag;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "lock_position_flag", &lock_position_flag, NULL)
Expand All @@ -7874,6 +7874,21 @@ static int test_ATTDEF (const Dwg_Object *obj)
else
fail ("ATTDEF.mtext_style [H]");
}
{
BITCODE_RC mtext_type;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "mtext_type", &mtext_type, NULL)
&& mtext_type == attdef->mtext_type)
pass ();
else
fail ("ATTDEF.mtext_type [RC] %u != %u", attdef->mtext_type, mtext_type);
mtext_type++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "mtext_type", &mtext_type, 0)
&& mtext_type == attdef->mtext_type)
pass ();
else
fail ("ATTDEF.mtext_type [RC] set+1 %u != %u", attdef->mtext_type, mtext_type);
attdef->mtext_type--;
}
{
BITCODE_RD oblique_angle;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "oblique_angle", &oblique_angle, NULL)
Expand Down Expand Up @@ -7955,21 +7970,6 @@ static int test_ATTDEF (const Dwg_Object *obj)
fail ("ATTDEF.thickness [RD] set+1 %g != %g", attdef->thickness, thickness);
attdef->thickness--;
}
{
BITCODE_RC type;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "type", &type, NULL)
&& type == attdef->type)
pass ();
else
fail ("ATTDEF.type [RC] %u != %u", attdef->type, type);
type++;
if (dwg_dynapi_entity_set_value (attdef, "ATTDEF", "type", &type, 0)
&& type == attdef->type)
pass ();
else
fail ("ATTDEF.type [RC] set+1 %u != %u", attdef->type, type);
attdef->type--;
}
{
BITCODE_BS vert_alignment;
if (dwg_dynapi_entity_value (attdef, "ATTDEF", "vert_alignment", &vert_alignment, NULL)
Expand Down

0 comments on commit de8a42c

Please sign in to comment.