9 struct CADGeometryWriter;
10 class DXFTableWriteIterator;
12 class CADTextWriteModifier :
public CADWriteModifier
15 static void WriteText(DXFWriter& writer,
const Matrix<fltp08>& tr,
const Text& text, uint04 handle, uint04 parent_handle)
19 text_data.handle = handle;
20 text_data.parent_handle = parent_handle;
21 text_data.text = text.plainText();
22 text_data.text.replace(
"\n",
"\\P");
23 if (text_data.text.size() == 0)
27 writer.cleanupCADName(text_data.layer);
29 Model text_object = text.textObject();
30 Bounds<3, fltp08> bounds = text_object.getBounds();
32 bounds = text_object.getSelectionBounds();
33 Matrix<fltp08> text_sub_matrix = tr * text_object.getTransform();
34 text_data.align_a = text_sub_matrix * bounds[
MIN];
35 text_data.align_b = text_sub_matrix * bounds.center();
37 text_data.alignment = cast<uint01>(TextAlignment::e_center);
38 Vector<3, fltp08> scale = text_sub_matrix.decomposeScale();
39 text_data.height = scale[
Y] * bounds.span()[
Y];
40 text_data.reference_width = scale[
X] * bounds.span()[
X];
42 text_data.line_spacing_factor = text.lineSpaceFactor();
44 Ray<3, fltp08> up(0.0, 0.0, 1.0);
45 text_data.extrusion = (text_sub_matrix * up).normalized<fltp08>();
46 auto rotation = (EntityConverter::GetOrientation(text_data.extrusion) * text_sub_matrix).decomposeRotation<fltp08>();
47 text_data.rotatation = rotation[
YAW];
49 writer.addText(text_data);
51 bool canHandleBlock(
const Model& model)
final override
53 return model.isOfType(Text::TypeName());
55 ModelIterator::ParseResult handleBlock(
const Model& model, DXFTableWriteIterator& options)
final override
57 BlockData data = options.convertToBlock(model);
59 data.handle = options.handle_manager->getHandleIndex(data.name);
60 options.handle_manager->setHandleToUUID(model.uuid(), data.handle);
61 options.writer.handleManager()->setTransfromCoords(data.handle
62 , options.params.options.units.coordinate_space_unit.get()->matrix() * model.getCompleteTransform());
64 return ModelIterator::ParseResult::e_do_not_parse_children;
66 ModelIterator::ParseResult handleBlock(
const Model&, DXFBlockWriter&)
final override
68 return ModelIterator::ParseResult::e_do_not_parse_children;
71 bool canHandleInsert(
const Model& model)
final override
73 return model.isOfType(Text::TypeName());
75 void handleInsert(
const Matrix<fltp08>& parent_transform,
const Model& model, uint04 parent_handle, DXFBlockWriter& options)
final override
78 WriteText(options.writer, parent_transform, text, options.writer.handleManager()->getHandleIndex(model.uuid()), parent_handle);
80 void handleInsert(
const Matrix<fltp08>&,
const Model&, uint04, CADGeometryWriter&)
final override
@ MIN
Definition BaseValues.hpp:226
@ YAW
Definition Angle.h:53
CADColorInfo GenerateDXFColorInfo(const Model &model, bool is_flat, bool is_vertex)
Definition CADGeometryWriter.h:22
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
void FillOutData(const Model &model, EntityData &data)
Definition CADGeometryWriter.h:117