Skip to content

Commit

Permalink
spec: change some ATTRIB fields
Browse files Browse the repository at this point in the history
analog
  • Loading branch information
rurban committed Oct 5, 2024
1 parent de8a42c commit 1b7905c
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 64 deletions.
10 changes: 6 additions & 4 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1233,14 +1233,16 @@ BS, DXF 72
BS, DXF 74
@item dataflags
RC
@item class_version
@item is_locked_in_block
RC, DXF 280
@item type
RC, DXF 70
@item keep_duplicate_records
RC, DXF 280
@item mtext_type
RC
@item tag
T, DXF 2
@item field_length
BS
BS, DXF 73
@item flags
RC, DXF 70
@item lock_position_flag
Expand Down
7 changes: 4 additions & 3 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,11 @@ typedef struct _dwg_entity_ATTRIB
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; /* DXF 73 but unused */
BITCODE_BS field_length; /* DXF 73 */
BITCODE_RC flags; /* bitmask of:
0 none
1 invisible, overridden by ATTDISP
Expand Down
24 changes: 13 additions & 11 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -339,23 +339,25 @@ DWG_ENTITY (ATTRIB)
SUBCLASS (AcDbAttribute)
DXF {
FIELD_T (tag, 2);
FIELD_RC (type, 70);
//FIELD_BS (field_length, 73);
FIELD_RC (flags, 70); // 1 invisible, 2 constant, 4 verify, 8 preset
FIELD_BS0 (field_length, 73);
FIELD_BS0 (vert_alignment, 74);
LOG_VERT_ALIGNMENT
SINCE (R_2004a) {
FIELD_RC (class_version, 280);
FIELD_RC (is_locked_in_block, 280);
FIELD_RC (keep_duplicate_records, 280);
}
}
SINCE (R_2010b)
SINCE (R_2004a)
{
FIELD_RC (class_version, 0); // 0 = r2010
VALUEOUTOFBOUNDS (class_version, 10)
FIELD_RC (is_locked_in_block, 0);
VALUEOUTOFBOUNDS (is_locked_in_block, 2)
// FIELD_RC (keep_duplicate_records, 280);
}
SINCE (R_2018b)
{
FIELD_RC (type, 0); // 1=single line, 2=multi line attrib, 4=multi line attdef
if (FIELD_VALUE (type) > 1)
FIELD_RC (mtext_type, 0); // 1=single line, 2=multi line attrib, 4=multi line attdef
if (FIELD_VALUE (mtext_type) > 1)
{
SUBCLASS (AcDbMText)
LOG_WARN ("MTEXT fields")
Expand Down Expand Up @@ -569,11 +571,11 @@ DWG_ENTITY (ATTDEF)
FIELD_RC (keep_duplicate_records, 280);
}
}
SINCE (R_2010b)
SINCE (R_2004a)
{
//int dxf = dat->version == R_2010 ? 280: 0;
FIELD_RC (is_locked_in_block, 0); // 0 = r2010
FIELD_RC (is_locked_in_block, 0);
VALUEOUTOFBOUNDS (is_locked_in_block, 1)
// FIELD_RC (keep_duplicate_records, 280);
}
IF_FREE_OR_SINCE (R_2018)
{
Expand Down
10 changes: 6 additions & 4 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,14 +1190,16 @@ static const Dwg_DYNAPI_field _dwg_ATTRIB_fields[] = {
0,0,0, 74 },
{ "dataflags", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, dataflags),
0,0,0, 0 },
{ "class_version", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, class_version),
{ "is_locked_in_block", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, is_locked_in_block),
0,0,0, 280 },
{ "type", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, type),
0,0,0, 70 },
{ "keep_duplicate_records", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, keep_duplicate_records),
0,0,0, 280 },
{ "mtext_type", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, mtext_type),
0,0,0, 0 },
{ "tag", "T", sizeof (BITCODE_T), OFF (struct _dwg_entity_ATTRIB, tag),
1,1,1, 2 },
{ "field_length", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_entity_ATTRIB, field_length),
0,0,0, 0 },
0,0,0, 73 },
{ "flags", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_entity_ATTRIB, flags),
0,0,0, 70 },
{ "lock_position_flag", "B", sizeof (BITCODE_B), OFF (struct _dwg_entity_ATTRIB, lock_position_flag),
Expand Down
9 changes: 5 additions & 4 deletions test/unit-testing/attdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ api_process (dwg_object *obj)
CHK_ENTITY_3RD_W_OLD (attdef, ATTDEF, extrusion);
CHK_ENTITY_TYPE (attdef, ATTDEF, elevation, BD);
CHK_ENTITY_TYPE (attdef, ATTDEF, dataflags, RC);
CHK_ENTITY_TYPE_W_OLD (attdef, ATTDEF, flags, RC);
CHK_ENTITY_TYPE_W_OLD (attdef, ATTDEF, height, RD);
CHK_ENTITY_TYPE_W_OLD (attdef, ATTDEF, thickness, RD);
CHK_ENTITY_TYPE_W_OLD (attdef, ATTDEF, rotation, RD);
Expand All @@ -47,19 +48,19 @@ api_process (dwg_object *obj)
if (version >= R_2007)
{
CHK_ENTITY_TYPE (attdef, ATTDEF, is_locked_in_block, RC);
CHK_ENTITY_MAX (attdef, ATTDEF, is_locked_in_block, RC, 1);
CHK_ENTITY_TYPE (attdef, ATTDEF, keep_duplicate_records, RC);
CHK_ENTITY_MAX (attdef, ATTDEF, keep_duplicate_records, RC, 1);
CHK_ENTITY_TYPE (attdef, ATTDEF, lock_position_flag, B);
}
if (version >= R_2018)
{
CHK_ENTITY_TYPE (attdef, ATTDEF, mtext_type, RC);
CHK_ENTITY_MAX (attdef, ATTDEF, mtext_type, RC, 4);
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);
CHK_ENTITY_H (attdef, ATTDEF, annotative_app);
CHK_ENTITY_TYPE (attdef, ATTDEF, annotative_short, BS);
}
if (version >= R_2007)
{
CHK_ENTITY_TYPE (attdef, ATTDEF, lock_position_flag, B);
}
}
19 changes: 11 additions & 8 deletions test/unit-testing/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ api_process (dwg_object *obj)
double elevation, thickness, rotation, height, oblique_angle, width_factor;
BITCODE_BS generation, vert_alignment, horiz_alignment, annotative_data_size,
annotative_short;
BITCODE_RC dataflags, class_version, type, annotative_data_bytes;
BITCODE_RC dataflags, flags, is_locked_in_block, keep_duplicate_records, mtext_type,
annotative_data_bytes;
char *text_value;
dwg_point_3d extrusion;
dwg_point_2d ins_pt, alignment_pt;
Expand All @@ -30,6 +31,7 @@ api_process (dwg_object *obj)
CHK_ENTITY_3RD_W_OLD (attrib, ATTRIB, extrusion);
CHK_ENTITY_TYPE (attrib, ATTRIB, elevation, BD);
CHK_ENTITY_TYPE (attrib, ATTRIB, dataflags, RC);
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, flags, RC);
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, height, RD);
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, thickness, RD);
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, rotation, RD);
Expand All @@ -42,21 +44,22 @@ api_process (dwg_object *obj)
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, vert_alignment, BS);
CHK_ENTITY_TYPE_W_OLD (attrib, ATTRIB, horiz_alignment, BS);
CHK_ENTITY_H (attrib, ATTRIB, style);
if (version >= R_2010)
if (version >= R_2007)
{
CHK_ENTITY_TYPE (attrib, ATTRIB, class_version, RC);
CHK_ENTITY_TYPE (attrib, ATTRIB, is_locked_in_block, RC);
CHK_ENTITY_MAX (attrib, ATTRIB, is_locked_in_block, RC, 1);
CHK_ENTITY_TYPE (attrib, ATTRIB, keep_duplicate_records, RC);
CHK_ENTITY_MAX (attrib, ATTRIB, keep_duplicate_records, RC, 1);
CHK_ENTITY_TYPE (attrib, ATTRIB, lock_position_flag, B);
}
if (version >= R_2018)
{
CHK_ENTITY_TYPE (attrib, ATTRIB, type, RC);
CHK_ENTITY_TYPE (attrib, ATTRIB, mtext_type, RC);
CHK_ENTITY_MAX (attrib, ATTRIB, mtext_type, RC, 4);
CHK_ENTITY_H (attrib, ATTRIB, mtext_style);
CHK_ENTITY_TYPE (attrib, ATTRIB, annotative_data_size, BS);
CHK_ENTITY_TYPE (attrib, ATTRIB, annotative_data_bytes, RC);
CHK_ENTITY_H (attrib, ATTRIB, annotative_app);
CHK_ENTITY_TYPE (attrib, ATTRIB, annotative_short, BS);
}
if (version >= R_2007)
{
CHK_ENTITY_TYPE (attrib, ATTRIB, lock_position_flag, B);
}
}
75 changes: 45 additions & 30 deletions test/unit-testing/dynapi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8079,21 +8079,6 @@ static int test_ATTRIB (const Dwg_Object *obj)
fail ("ATTRIB.annotative_short [BS] set+1 %hu != %hu", attrib->annotative_short, annotative_short);
attrib->annotative_short--;
}
{
BITCODE_RC class_version;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "class_version", &class_version, NULL)
&& class_version == attrib->class_version)
pass ();
else
fail ("ATTRIB.class_version [RC] %u != %u", attrib->class_version, class_version);
class_version++;
if (dwg_dynapi_entity_set_value (attrib, "ATTRIB", "class_version", &class_version, 0)
&& class_version == attrib->class_version)
pass ();
else
fail ("ATTRIB.class_version [RC] set+1 %u != %u", attrib->class_version, class_version);
attrib->class_version--;
}
{
BITCODE_RC dataflags;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "dataflags", &dataflags, NULL)
Expand Down Expand Up @@ -8215,6 +8200,36 @@ static int test_ATTRIB (const Dwg_Object *obj)
else
fail ("ATTRIB.ins_pt [2DPOINT]");
}
{
BITCODE_RC is_locked_in_block;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "is_locked_in_block", &is_locked_in_block, NULL)
&& is_locked_in_block == attrib->is_locked_in_block)
pass ();
else
fail ("ATTRIB.is_locked_in_block [RC] %u != %u", attrib->is_locked_in_block, is_locked_in_block);
is_locked_in_block++;
if (dwg_dynapi_entity_set_value (attrib, "ATTRIB", "is_locked_in_block", &is_locked_in_block, 0)
&& is_locked_in_block == attrib->is_locked_in_block)
pass ();
else
fail ("ATTRIB.is_locked_in_block [RC] set+1 %u != %u", attrib->is_locked_in_block, is_locked_in_block);
attrib->is_locked_in_block--;
}
{
BITCODE_RC keep_duplicate_records;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "keep_duplicate_records", &keep_duplicate_records, NULL)
&& keep_duplicate_records == attrib->keep_duplicate_records)
pass ();
else
fail ("ATTRIB.keep_duplicate_records [RC] %u != %u", attrib->keep_duplicate_records, keep_duplicate_records);
keep_duplicate_records++;
if (dwg_dynapi_entity_set_value (attrib, "ATTRIB", "keep_duplicate_records", &keep_duplicate_records, 0)
&& keep_duplicate_records == attrib->keep_duplicate_records)
pass ();
else
fail ("ATTRIB.keep_duplicate_records [RC] set+1 %u != %u", attrib->keep_duplicate_records, keep_duplicate_records);
attrib->keep_duplicate_records--;
}
{
BITCODE_B lock_position_flag;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "lock_position_flag", &lock_position_flag, NULL)
Expand All @@ -8238,6 +8253,21 @@ static int test_ATTRIB (const Dwg_Object *obj)
else
fail ("ATTRIB.mtext_style [H]");
}
{
BITCODE_RC mtext_type;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "mtext_type", &mtext_type, NULL)
&& mtext_type == attrib->mtext_type)
pass ();
else
fail ("ATTRIB.mtext_type [RC] %u != %u", attrib->mtext_type, mtext_type);
mtext_type++;
if (dwg_dynapi_entity_set_value (attrib, "ATTRIB", "mtext_type", &mtext_type, 0)
&& mtext_type == attrib->mtext_type)
pass ();
else
fail ("ATTRIB.mtext_type [RC] set+1 %u != %u", attrib->mtext_type, mtext_type);
attrib->mtext_type--;
}
{
BITCODE_RD oblique_angle;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "oblique_angle", &oblique_angle, NULL)
Expand Down Expand Up @@ -8319,21 +8349,6 @@ static int test_ATTRIB (const Dwg_Object *obj)
fail ("ATTRIB.thickness [RD] set+1 %g != %g", attrib->thickness, thickness);
attrib->thickness--;
}
{
BITCODE_RC type;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "type", &type, NULL)
&& type == attrib->type)
pass ();
else
fail ("ATTRIB.type [RC] %u != %u", attrib->type, type);
type++;
if (dwg_dynapi_entity_set_value (attrib, "ATTRIB", "type", &type, 0)
&& type == attrib->type)
pass ();
else
fail ("ATTRIB.type [RC] set+1 %u != %u", attrib->type, type);
attrib->type--;
}
{
BITCODE_BS vert_alignment;
if (dwg_dynapi_entity_value (attrib, "ATTRIB", "vert_alignment", &vert_alignment, NULL)
Expand Down

0 comments on commit 1b7905c

Please sign in to comment.