opennurbs_textobject.h
1 //
2 // Copyright (c) 1993-2016 Robert McNeel & Associates. All rights reserved.
3 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
4 // McNeel & Associates.
5 //
6 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
7 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
8 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
9 //
10 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
11 //
12 ////////////////////////////////////////////////////////////////
13 
14 // ON_Table class
15 #ifndef OPENNURBS_TEXTOBJECT_H_INCLUDED
16 #define OPENNURBS_TEXTOBJECT_H_INCLUDED
17 
18 class ON_CLASS ON_Text : public ON_Annotation
19 {
20  ON_OBJECT_DECLARE(ON_Text);
21 
22 public:
23  static const ON_Text Empty;
24 
25  ON_Text();
26  ~ON_Text();
27 
28  ON_Text(const ON_Text& src);
29  ON_Text& operator=(const ON_Text& src);
30 
31 public:
32 
33  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
34 
35  // Parses text string and makes runs
36  bool Create(
37  const wchar_t* RtfString,
38  const ON_DimStyle* dimstyle,
39  ON_Plane plane,
40  bool bWrapped,
41  double rect_width,
42  double text_rotation_radians
43  );
44 
45  // Parses text string and makes runs - wrapped = false, rotation = 0
46  bool Create(
47  const wchar_t* RtfString,
48  const ON_DimStyle* dimstyle,
49  ON_Plane plane
50  );
51 
52  void Destroy();
53 
54  // virtual
55  void Dump(ON_TextLog&) const override; // for debugging
56 
57  bool Write(
58  ON_BinaryArchive& // serialize definition to binary archive
59  ) const override;
60 
61  bool Read(
62  ON_BinaryArchive& // restore definition from binary archive
63  ) override;
64 
65  int Dimension() const override;
66 
67  /*
68  Description:
69  Create a V5 text object from a V6 text object.
70  The function is used when reading V5 files.
71  Parameters:
72  v5_text_object -[in]
73  dimstyle - [in]
74  Dimstyle referenced by v5_text_object or nullptr if not available.
75  destination - [in]
76  If destination is not nullptr, then the V6 text object is constructed
77  in destination. If destination is nullptr, then the new V6 text object
78  is allocated with a call to new ON_Text().
79  */
80  static ON_Text* CreateFromV5TextObject(
81  const class ON_OBSOLETE_V5_TextObject& V5_text_object,
82  const class ON_3dmAnnotationContext* annotation_context,
83  ON_Text* destination
84  );
85 
86  //bool Explode(
87  // const ON_DimStyle* dimstyle,
88  // ON_SimpleArray<const ON_Geometry*> object_parts) const;
89 
90 
91 
92  // virtual ON_Geometry GetBBox override
93  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
94 
96  const ON_Viewport* vp,
97  const ON_DimStyle* dimstyle,
98  double dimscale,
99  double* boxmin,
100  double* boxmax,
101  bool bGrow = false
102  ) const override; // ON_Annotation override
103 
104  bool Transform(const ON_Xform& xform) override;
105 
106  /*
107  Description:
108  Transform the object by a 4x4 xform matrix and change text height
109  override to accomodate scaling in the transform if necessary
110  Parameters:
111  [in] xform - An ON_Xform with the transformation information
112  Returns:
113  true = Success
114  false = Failure
115  Remarks:
116  The object has been transformed when the function returns
117  If the scale changed because of the transform, an override for text height
118  is either changed, if one already was in place, or is added.
119  */
120  bool Transform(const ON_Xform& xform, const ON_DimStyle* dimstyle);
121 
122  // Transforms text from natural position at origin to
123  // 3d location as it displays in the text object
124  bool GetTextXform(
125  const ON_Viewport* vp,
126  const ON_DimStyle* dimstyle,
127  double dimscale,
128  ON_Xform& text_xform_out
129  ) const override;
130 
131  // returns the base point and with grip using the current alignments
132  bool GetGripPoints(ON_2dPoint& base, ON_2dPoint& width, double textscale) const;
133 
134 private:
135  void Internal_SetObsoleteV5TextObjectInformation(
136  const class ON_3dmAnnotationContext* annotation_context,
137  const class ON_OBSOLETE_V5_TextObject& V5_text_object
138  );
139 };
140 
141 #endif
142 
Definition: opennurbs_annotationbase.h:23
virtual bool Transform(const ON_Xform &xform)
Transforms the object.
virtual int Dimension() const
Dimension of the object.
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
Definition: opennurbs_dimensionstyle.h:218
bool IsValid(class ON_TextLog *text_log=nullptr) const override
Tests an object to see if its data members are correctly initialized.
Context for an annotation object. This context is required when converting current annotation objects...
Definition: opennurbs_archive.h:1592
virtual bool GetAnnotationBoundingBox(const ON_Viewport *vp, const ON_DimStyle *dimstyle, double dimscale, double *boxmin, double *boxmax, bool bGrow=false) const =0
Definition: opennurbs_point.h:277
Definition: opennurbs_xform.h:28
ON_Annotation & operator=(const ON_Annotation &src)
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
static const ON_Text Empty
Definition: opennurbs_textobject.h:23
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
Definition: opennurbs_viewport.h:31
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
virtual bool Write(ON_BinaryArchive &binary_archive) const
Low level archive writing tool used by ON_BinaryArchive::WriteObject().
virtual bool GetTextXform(const ON_Viewport *vp, const ON_DimStyle *dimstyle, double dimscale, ON_Xform &text_xform_out) const =0
Definition: opennurbs_plane.h:20
Definition: opennurbs_textobject.h:18