Skip to content

Commit

Permalink
spec: ATTDEF refactor, re-use AcDbMTextObjectContextData
Browse files Browse the repository at this point in the history
as embedded subclass for ATTRIB, ATTDEF, GEOPOSITIONMARKER,
MTEXTOBJECTCONTEXTDATA.
  • Loading branch information
rurban committed Oct 7, 2024
1 parent 2bb3e6c commit 1f9e6cd
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 595 deletions.
86 changes: 45 additions & 41 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1180,12 +1180,8 @@ B
H, DXF 7
@item mtext_type
RC, DXF 70
@item is_really_locked
B, DXF 70
@item num_secondary_atts
BS, DXF 70
@item secondary_atts
H*, DXF 340
@item mtext
Dwg_AcDbMTextObjectContextData
@item prompt
T, DXF 3

Expand Down Expand Up @@ -1245,12 +1241,8 @@ B
H, DXF 7
@item mtext_type
RC, DXF 70
@item is_really_locked
RC, DXF 70
@item num_secondary_atts
BS, DXF 70
@item secondary_atts
H*, DXF 340
@item mtext
Dwg_AcDbMTextObjectContextData

@end vtable
@end indentedblock
Expand Down Expand Up @@ -2061,7 +2053,7 @@ B, DXF 290
@item enable_frame_text
B, DXF 290
@item mtext
struct _dwg_object*
Dwg_AcDbMTextObjectContextData

@end vtable
@end indentedblock
Expand Down Expand Up @@ -10811,34 +10803,8 @@ BS, DXF 70
B, DXF 290
@item scale
H, DXF 340
@item attachment
BL, DXF 70
@item ins_pt
3BD, DXF 10
@item x_axis_dir
3BD, DXF 11
@item rect_height
BD, DXF 41
@item rect_width
BD, DXF 40
@item extents_width
BD, DXF 42
@item extents_height
BD, DXF 43
@item column_type
BL, DXF 71
@item column_width
BD, DXF 44
@item gutter
BD, DXF 45
@item auto_height
B, DXF 73
@item flow_reversed
B, DXF 74
@item num_column_heights
BL, DXF 72
@item column_heights
BD*, DXF 46
@item mtext
Dwg_AcDbMTextObjectContextData

@end vtable
@end indentedblock
Expand Down Expand Up @@ -13186,6 +13152,44 @@ H
@end vtable
@end indentedblock

@strong{Dwg_AcDbMTextObjectContextData} @anchor{Dwg_AcDbMTextObjectContextData}
@vindex Dwg_AcDbMTextObjectContextData

@indentedblock
@vtable @code

@item attachment
BL
@item ins_pt
3BD
@item x_axis_dir
3BD
@item rect_height
BD
@item rect_width
BD
@item extents_width
BD
@item extents_height
BD
@item column_type
BL
@item column_width
BD
@item gutter
BD
@item auto_height
B
@item flow_reversed
B
@item num_column_heights
BL
@item column_heights
BD*

@end vtable
@end indentedblock

@strong{Dwg_AcDs} @anchor{Dwg_AcDs}
@vindex Dwg_AcDs

Expand Down
57 changes: 35 additions & 22 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,28 @@ typedef struct _dwg_entity_TEXT
BITCODE_H style; /*!< code 5, DXF 7, optional */
} Dwg_Entity_TEXT;

/**
* R2010+ Subclass of ATTRIB, ATTDEF, GEOPOSITIONMARKER, MTEXTOBJECTCONTEXTDATA
*/
typedef struct _dwg_AcDbMTextObjectContextData
{
BITCODE_BL attachment; /*<! DXF 70 */
BITCODE_3BD ins_pt; /*!< DXF 10 */
BITCODE_3BD x_axis_dir; /*!< DXF 11 */
BITCODE_BD rect_height; /*!< DXF 40 */
BITCODE_BD rect_width; /*!< DXF 41 */
BITCODE_BD extents_width; /*!< DXF 42 */
BITCODE_BD extents_height; /*!< DXF 43 */
BITCODE_BL column_type; /*!< DXF 71 0: none, 1: static, 2: dynamic.
Note: BS in MTEXT! */
BITCODE_BD column_width; /*!< DXF 44 */
BITCODE_BD gutter; /*!< DXF 45 */
BITCODE_B auto_height; /*!< DXF 73 */
BITCODE_B flow_reversed; /*!< DXF 74 */
BITCODE_BL num_column_heights;/*!< DXF 72 or numfragments */
BITCODE_BD *column_heights; /*!< DXF 46 if dynamic and not auto_height */
} Dwg_AcDbMTextObjectContextData;

/** \ref Dwg_Entity_ATTRIB
ATTRIB (2/16) entity
*/
Expand Down Expand Up @@ -1372,9 +1394,7 @@ typedef struct _dwg_entity_ATTRIB
BITCODE_B lock_position_flag; /* R2007+ */
BITCODE_H style;
BITCODE_RC mtext_type; /* R2018+ */
BITCODE_RC is_really_locked; /* R2018+ */
BITCODE_BS num_secondary_atts; /* R2018+ TODO */
BITCODE_H *secondary_atts;
Dwg_AcDbMTextObjectContextData mtext;
} Dwg_Entity_ATTRIB;

/** \ref Dwg_Entity_ATTDEF
Expand Down Expand Up @@ -1411,10 +1431,15 @@ typedef struct _dwg_entity_ATTDEF
8 preset, inserted only with its default values, not editable. */
BITCODE_B lock_position_flag; /* R2007+ */
BITCODE_H style;
BITCODE_RC mtext_type; /* R2018+ */
BITCODE_B is_really_locked; /* R2018+ */
BITCODE_BS num_secondary_atts; /* R2018+ TODO */
BITCODE_H *secondary_atts;
BITCODE_RC mtext_type; /* R2018+ */
Dwg_AcDbMTextObjectContextData mtext;
// BITCODE_B is_really_locked; /* R2018+ */
// BITCODE_BS annotative_data_size;/* R2018+ */
// BITCODE_RC* annotative_data; /* R2018+ */
// BITCODE_BS annotative_short; /* R2018+ */
// BITCODE_H annotative_mtext; /* R2018+ */
// BITCODE_BS num_secondary_atts; /* R2018+ TODO */
// BITCODE_H *secondary_atts;

BITCODE_T prompt;
} Dwg_Entity_ATTDEF;
Expand Down Expand Up @@ -4879,7 +4904,7 @@ typedef struct _dwg_entity_GEOPOSITIONMARKER
BITCODE_RC text_alignment; /*!< DXF 70 0 left, 1 center, 2 right */
BITCODE_B mtext_visible; /*!< DXF 290 */
BITCODE_B enable_frame_text; /*!< DXF 290 */
struct _dwg_object *mtext;
Dwg_AcDbMTextObjectContextData mtext;
} Dwg_Entity_GEOPOSITIONMARKER;

/**
Expand Down Expand Up @@ -6769,6 +6794,7 @@ typedef struct _dwg_object_GROUND_PLANE_BACKGROUND
* R2010+
* 20.4.89 SubClass AcDbObjectContextData (varies)
*/

#define OBJECTCONTEXTDATA_fields \
struct _dwg_object_object *parent; \
BITCODE_BS class_version; /*!< r2010+ =4, before 3 */ \
Expand Down Expand Up @@ -6831,20 +6857,7 @@ typedef struct _dwg_object_TEXTOBJECTCONTEXTDATA
typedef struct _dwg_object_MTEXTOBJECTCONTEXTDATA
{
ANNOTSCALEOBJECTCONTEXTDATA_fields;
BITCODE_BL attachment; /*<! DXF 70 */
BITCODE_3BD ins_pt; /*!< DXF 10 */
BITCODE_3BD x_axis_dir; /*!< DXF 11 */
BITCODE_BD rect_height; /*!< DXF 40 */
BITCODE_BD rect_width; /*!< DXF 41 */
BITCODE_BD extents_width; /*!< DXF 42 */
BITCODE_BD extents_height; /*!< DXF 43 */
BITCODE_BL column_type; /*!< DXF 71 0: none, 1: static, 2: dynamic. Note: BS in MTEXT! */
BITCODE_BD column_width; /*!< DXF 44 */
BITCODE_BD gutter; /*!< DXF 45 */
BITCODE_B auto_height; /*!< DXF 73 */
BITCODE_B flow_reversed; /*!< DXF 74 */
BITCODE_BL num_column_heights;/*!< DXF 72 or numfragments */
BITCODE_BD *column_heights; /*!< DXF 46 if dynamic and not auto_height */
Dwg_AcDbMTextObjectContextData mtext;
} Dwg_Object_MTEXTOBJECTCONTEXTDATA;

// subclass AcDbDimensionObjectContextData
Expand Down
2 changes: 0 additions & 2 deletions src/dec_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@
LOG_POS; \
}

#define FIELD_VALUE(nam) _obj->nam

#define ANYCODE -1
#define VALUE_HANDLE(ref, nam, code, dxf) \
{ \
Expand Down
111 changes: 60 additions & 51 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,34 @@ DWG_ENTITY (TEXT)

DWG_ENTITY_END

// R2010+ Subclass of ATTRIB, ATTDEF, GEOPOSITIONMARKER, MTEXTOBJECTCONTEXTDATA
#define AcDbMTextObjectContextData_fields \
{ \
DXF { VALUE_TFF ( "Embedded Object", 101 ); } \
SUB_FIELD_BL (mtext, attachment, 70); \
SUB_FIELD_3BD (mtext, x_axis_dir, 11); \
SUB_FIELD_3BD (mtext, ins_pt, 10); /* ODA bug */ \
SUB_FIELD_BD (mtext, rect_width, 40); \
SUB_FIELD_BD (mtext, rect_height, 41); \
SUB_FIELD_BD (mtext, extents_width, 42); \
SUB_FIELD_BD (mtext, extents_height, 43); \
SUB_FIELD_BL (mtext, column_type, 71); \
SUB_VALUEOUTOFBOUNDS (mtext, column_type, 2) \
if (SUB_FIELD_VALUE (mtext, column_type)) \
{ \
SUB_FIELD_BL (mtext, num_column_heights, 72); \
SUB_FIELD_BD (mtext, column_width, 44); \
SUB_FIELD_BD (mtext, gutter, 45); \
SUB_FIELD_B (mtext, auto_height, 73); \
SUB_FIELD_B (mtext, flow_reversed, 74); \
if (!SUB_FIELD_VALUE (mtext, auto_height) \
&& SUB_FIELD_VALUE (mtext, column_type) == 2) \
{ \
SUB_FIELD_VECTOR (mtext, column_heights, BD, num_column_heights, 46); \
} \
} \
}

/* (2/16) */
DWG_ENTITY (ATTRIB)

Expand Down Expand Up @@ -359,14 +387,7 @@ DWG_ENTITY (ATTRIB)
{
FIELD_RC (mtext_type, 70); // 1=single line, 2=multi line attrib, 4=multi line attdef
if (FIELD_VALUE (mtext_type) > 1)
{
SUBCLASS (AcDbMText)
LOG_WARN ("MTEXT fields")
FIELD_B (is_really_locked, 70);
FIELD_BS (num_secondary_atts, 70);
DEBUG_HERE_OBJ
HANDLE_VECTOR (secondary_atts, num_secondary_atts, 4, 340);
}
AcDbMTextObjectContextData_fields
}

SINCE (R_13b1) {
Expand Down Expand Up @@ -580,14 +601,7 @@ DWG_ENTITY (ATTDEF)
{
FIELD_RC (mtext_type, 70); // 1=single line, 2=multi line attrib, 4=multi line attdef
if (FIELD_VALUE (mtext_type) > 1)
{
SUBCLASS (AcDbMText)
LOG_WARN ("MTEXT fields")
FIELD_B (is_really_locked, 70);
FIELD_BS (num_secondary_atts, 70);
DEBUG_HERE_OBJ
HANDLE_VECTOR (secondary_atts, num_secondary_atts, 4, 340);
}
AcDbMTextObjectContextData_fields
}
SINCE (R_13b1) {
FIELD_T (tag, 0);
Expand Down Expand Up @@ -3270,7 +3284,8 @@ DWG_ENTITY (OLEFRAME)

DWG_ENTITY_END

/* (44) */
/* (44)
*/
DWG_ENTITY (MTEXT)

SUBCLASS (AcDbMText)
Expand Down Expand Up @@ -10143,13 +10158,29 @@ DWG_ENTITY (GEOPOSITIONMARKER)
FIELD_B (enable_frame_text, 290);
if (FIELD_VALUE (enable_frame_text))
{
DECODER {
dwg_add_object (dwg);
_obj->mtext = &dwg->object[dwg->num_objects - 1];
dwg_setup_MTEXT (_obj->mtext);
}
DXF { VALUE_TFF ( "Embedded Object", 101 ); }
CALL_ENTITY (MTEXT, _obj->mtext);
SUB_FIELD_BL (mtext, attachment, 70); // ?
SUB_FIELD_3BD (mtext, x_axis_dir, 11);
SUB_FIELD_3BD (mtext, ins_pt, 10); // ODA bug
SUB_FIELD_BD (mtext, rect_width, 40);
SUB_FIELD_BD (mtext, rect_height, 41);
SUB_FIELD_BD (mtext, extents_width, 42);
SUB_FIELD_BD (mtext, extents_height, 43);

SUB_FIELD_BL (mtext, column_type, 71);
SUB_VALUEOUTOFBOUNDS (mtext, column_type, 2)
if (SUB_FIELD_VALUE (mtext, column_type))
{
SUB_FIELD_BL (mtext, num_column_heights, 72);
SUB_FIELD_BD (mtext, column_width, 44);
SUB_FIELD_BD (mtext, gutter, 45);
SUB_FIELD_B (mtext, auto_height, 73);
SUB_FIELD_B (mtext, flow_reversed, 74);
if (!SUB_FIELD_VALUE (mtext, auto_height) && SUB_FIELD_VALUE (mtext, column_type) == 2)
{
SUB_FIELD_VECTOR (mtext, column_heights, BD, num_column_heights, 46);
}
}
}
COMMON_ENTITY_HANDLE_DATA;
DWG_ENTITY_END
Expand Down Expand Up @@ -10717,11 +10748,11 @@ DWG_OBJECT (MTEXTATTRIBUTEOBJECTCONTEXTDATA)
DXF { VALUE_TFF ( "Embedded Object", 101 ); }
//CALL_ENTITY (SCALE, _obj->context);
SUBCLASS (AcDbScale);
SUB_FIELD_BS (context,flag, 70); // always 0
SUB_FIELD_T (context,name, 300);
SUB_FIELD_BD (context,paper_units, 140);
SUB_FIELD_BD (context,drawing_units, 141);
SUB_FIELD_B (context,is_unit_scale, 290);
SUB_FIELD_BS (context, flag, 70); // always 0
SUB_FIELD_T (context, name, 300);
SUB_FIELD_BD (context, paper_units, 140);
SUB_FIELD_BD (context, drawing_units, 141);
SUB_FIELD_B (context, is_unit_scale, 290);
}
START_OBJECT_HANDLE_STREAM;
DWG_OBJECT_END
Expand Down Expand Up @@ -10816,29 +10847,7 @@ DWG_OBJECT (MTEXTOBJECTCONTEXTDATA)
HANDLE_UNKNOWN_BITS;
AcDbAnnotScaleObjectContextData_fields;
SUBCLASS (AcDbMTextObjectContextData)
FIELD_BL (attachment, 70);
// From MTEXT Embedded object
FIELD_3BD (x_axis_dir, 11);
FIELD_3BD (ins_pt, 10); // ODA bug
FIELD_BD (rect_width, 40);
FIELD_BD (rect_height, 41);
FIELD_BD (extents_width, 42);
FIELD_BD (extents_height, 43);

FIELD_BL (column_type, 71);
VALUEOUTOFBOUNDS (column_type, 2)
if (FIELD_VALUE (column_type))
{
FIELD_BL (num_column_heights, 72);
FIELD_BD (column_width, 44);
FIELD_BD (gutter, 45);
FIELD_B (auto_height, 73);
FIELD_B (flow_reversed, 74);
if (!FIELD_VALUE (auto_height) && FIELD_VALUE (column_type) == 2)
{
FIELD_VECTOR (column_heights, BD, num_column_heights, 46);
}
}
AcDbMTextObjectContextData_fields;
START_OBJECT_HANDLE_STREAM;
DWG_OBJECT_END

Expand Down
Loading

0 comments on commit 1f9e6cd

Please sign in to comment.