opennurbs_annotationbase.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_ANNOTATIONBASE_INC_)
18 #define OPENNURBS_ANNOTATIONBASE_INC_
19 
20 
21 
22 
23 class ON_CLASS ON_Annotation : public ON_Geometry
24 {
25  ON_OBJECT_DECLARE(ON_Annotation);
26 
27 protected:
28  ON_Annotation( ON::AnnotationType annotation_type );
29  ON_Annotation( const ON_Annotation& src);
30  ~ON_Annotation();
32 
33 public:
34  static ON_Annotation* CreateFromV2Annotation(
35  const class ON_OBSOLETE_V2_Annotation& V2_annotation,
36  const class ON_3dmAnnotationContext* annotation_context
37  );
38 
39 public:
40  static ON_Annotation* CreateFromV5Annotation(
41  const class ON_OBSOLETE_V5_Annotation& V5_annotation,
42  const class ON_3dmAnnotationContext* annotation_context
43  );
44 
45 protected:
46  void Internal_SetDimStyleFromV5Annotation(
47  const class ON_OBSOLETE_V5_Annotation& V5_annotation,
48  const class ON_3dmAnnotationContext* annotation_context
49  );
50 
51 
52 private:
53  ON_Annotation() = delete;
54 
55 private:
56  void Internal_CopyFrom(const ON_Annotation& src);
57  void Internal_Destroy();
58 
59 public:
60  /*
61  Returns:
62  An ON::AnnotationType value that indicates the
63  type of the annotation.
64  */
65  ON::AnnotationType Type() const;
66 
67  ON::object_type ObjectType() const override;
68  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
69 
70  virtual bool GetAnnotationBoundingBox(
71  const ON_Viewport* vp,
72  const ON_DimStyle* dimstyle,
73  double dimscale,
74  double* boxmin,
75  double* boxmax,
76  bool bGrow = false
77  ) const = 0;
78 
79  /*
80  Parameters:
81  vp - [in]
82  nullptr or viewport where annotation object is displayed
83  dimstyle - [in]
84  &this->DimensionStyle(const ON_DimStyle& parent_dimstyle)
85  bApplyDimStyleDimScale - [in]
86  If true, dimsytyle->DimScale() is applied.
87  If vp is a page view, bApplyDimStyleDimScale is generally false.
88  If vp is a model view, bApplyDimStyleDimScale is generally
89  the value of a model property IsAnnotationScalingEnabled().
90  from
91  bSingleStrokeFont - [in]
92  True if text uses a single font that is a single stroke font and returned contours
93  should be left open.
94  text_contours - [out]
95  */
96  bool GetTextGlyphContours(
97  const ON_Viewport* vp,
98  const ON_DimStyle* dimstyle,
99  bool bApplyDimStyleDimScale,
100  bool bSingleStrokeFont,
102  ) const;
103 
104 protected:
105 
106  /*
107  Parameters:
108  vp - [in]
109  nullptr or viewport where annotation object is displayed
110  dimstyle - [in]
111  &this->DimensionStyle(const ON_DimStyle& parent_dimstyle)
112  */
113  const ON_SHA1_Hash Internal_GetBBox_InputHash(
114  const ON_Viewport* vp,
115  const ON_DimStyle* dimstyle,
116  double dimscale,
117  const ON_2dPoint& text_point,
118  unsigned int point_count,
119  const ON_2dPoint* points
120  ) const;
121 
122  /*
123  Parameters:
124  vp - [in]
125  nullptr or viewport where annotation object is displayed
126  dimstyle - [in]
127  &this->DimensionStyle(const ON_DimStyle& parent_dimstyle)
128  */
129  bool Internal_GetBBox_TextGlyphBox(
130  const ON_Viewport* vp,
131  const ON_DimStyle* dimstyle,
132  double dimscale,
133  ON_BoundingBox& text_glyph_box
134  ) const;
135 
136  /*
137  Returns:
138  True if a cached bounding box was found
139  and boxmin, boxmax are set.
140  */
141  bool Internal_GetBBox_Begin(
142  const ON_SHA1_Hash& hash,
143  double* boxmin,
144  double* boxmax,
145  bool bGrow
146  ) const;
147 
148  /*
149  Returns:
150  True if a boxmin, boxmax is a valid bounding box
151  */
152  bool Internal_GetBBox_End(
153  const ON_BoundingBox& bbox,
154  const ON_SHA1_Hash& hash,
155  double* boxmin,
156  double* boxmax,
157  bool bGrow
158  ) const;
159 
160 public:
161 
162  virtual bool GetTextXform(
163  const ON_Viewport* vp,
164  const ON_DimStyle* dimstyle,
165  double dimscale,
166  ON_Xform& text_xform_out
167  ) const = 0;
168 
169  void SetPlane(const ON_Plane& plane);
170  const ON_Plane& Plane() const;
171 
172  void SetHorizontalDirection(ON_2dVector);
173  const ON_2dVector HorizontalDirection() const;
174 
175  // Returns a 2d vector to use as annotation horizontal
176  // Use this function when you don't have a known horizontal direction
177  static ON_3dVector GetDefaultHorizontal(const ON_Plane& plane);
178 
179  /*
180  Returns:
181  Rich text that can contain rich text formatting instructions.
182  */
183  const ON_wString RichText() const;
184 
185  /*
186  Returns:
187  Text information with rich text formatting insturctions removed.
188  Fields are not evaluated.
189  */
190  const ON_wString PlainText() const;
191 
192  /*
193  Returns:
194  Text information with rich text formatting insturctions removed.
195  The result string from evaluating fields is included
196  Field results may be cached from previous evaluation
197  */
198  const ON_wString PlainTextWithFields() const;
199 
200  // Return the id of the main (parent) dimstyle used by this object.
201  // The style with this id should not be used directly if there is
202  // an override dimstyle present.
203  // Use this->DimensionStyle(parent_style) to get the effective
204  // dimstyle for this object.
205  ON_UUID DimensionStyleId() const;
206 
207  // Sets the id of the main (parent) dimstyle used by this annotation object
208  // Any override dimstyle on this object will be deleted when this is called,
209  // resetting any style overrides.
210  void SetDimensionStyleId(ON_UUID dimstyle_id);
211 
212  /*
213  Description:
214  Set the id of the main (parent) dimstyle used by this annotation object
215  and allow an expert user to control what happens to style override settings
216  in cases where id collisions occur and ids need to be changed.
217  Parameters:
218  bKeepOverrides - [in]
219  If you are not an expert oding something low level and complicated, then
220  call SetDimensionStyleId(dimstyle_id) or pass bKeepOverrides = false.
221 
222  If bKeepOverrides is true and dimstyle_id is not nil and this object has
223  valid overrides, those overrides are retained. In all other cases, any
224  existing overrides are deleted.
225  */
226  void SetDimensionStyleIdForExperts(
227  ON_UUID dimstyle_id,
228  bool bKeepOverrides
229  );
230 
231  /*
232  parameters:
233  dim_style - [in]
234  If dim_style.ParentId() is nil, then this function
235  calls SetDimensionStyleId(dim_style.Id()) and returns.
236  If dim_style.ParentId() is not nil, then this functions
237  calls SetDimensionStyleId(dim_style.ParentId()) and uses a copy
238  of dim_style as the override dimstyle.
239  */
240  void SetDimensionStyleId(
241  const class ON_DimStyle& dim_style
242  );
243 
244  // Get the proper dimension style, including overrides, to use for this
245  // annotation object.
246  // If there is an override in place, that dimstyle will be returned
247  // If there is no override, the parent style passed in will be returned
248  // If the content of the parent style has changed since the override was made,
249  // the override style will be updated with the non-overriden values from
250  // the parent before returning.
251  // If your annotation object has an override style and you call either of
252  // these functions with a dimstyle other than the correct parent style
253  // for this annotation, the override style will be removed.
254  const ON_DimStyle& DimensionStyle(const ON_DimStyle& parent_dimstyle) const;
255  const ON_DimStyle& DimensionStyle(
256  const ON_DimStyle& parent_dimstyle,
257  bool bForceOverrideUpdate
258  ) const;
259 
260  // Apply a dimstyle with overrides set to this annotation object.
261  //
262  // Use ON_Annotation::IsOverrideDimStyleCandidate() to determine if a non-nullptr
263  // override_style is a valid to be used to set overrides.
264  //
265  // The override dimstyle memory will be managed and deleted by the annotation object and
266  // must have been allocated using new.
267  // On return, if this function returns true,
268  // The dimstyle id of the annotation object must be set before this function is called.
269  // Calling SetOverrideDimensionStyle(nullptr) will remove all overrides for this object.
270  // override_dimstyle will be null.
271  //
272  // Returns:
273  // true if the override style was successfully set
274  // false if this->m_dimstyle_id is ON_nil_uuid causing failure
275  bool SetOverrideDimensionStyle(ON_DimStyle*& override_style) const;
276 
277  /*
278  Description:
279  Removes any override dimension style that is present.
280  */
281  void ClearOverrideDimensionStyle();
282 
283  /*
284  Description:
285  If this->IsOverrideDimStyleCandidate(override_style_candidate,bRequireSetOverrides)
286  is true, then a managed copy of override_style_candidate is set as an override.
287  Returns:
288  True if an override is set.
289  */
290  bool SetOverrideDimensionStyle(
291  const ON_DimStyle* override_style_candidate,
292  bool bRequireSetOverrides
293  );
294 
295 
296  /*
297  Description:
298  A valid override dimstyle candidate has all of the following properties.
299  override_style_candidate != nullptr.
300  IsDeleted() = false;
301  Id() = ON_nil_uuid;
302  Name() is empty.
303  Index() = ON_ModelComponent::Unset.Index()
304  bRequireSetOverrides is false or HasOverrides() returns true.
305  Parameters:
306  override_style_candidate -[in]
307  style candidate to evaluate.
308  bRequireSetOverrides - [in]
309  If bRequireSetOverrides is true, then override_style_candidate->HasOverrides() must be true for a valid candidate.
310  If bRequireSetOverrides is flase, then override_style_candidate->HasOverrides() can have any value.
311  Returns:
312  True if override_style could be successfully used as the parameter
313  to SetOverrideDimensionStyle.
314  */
315  bool IsOverrideDimStyleCandidate(
316  const ON_DimStyle* override_style_candidate,
317  bool bRequireSetOverrides
318  ) const;
319 
320 protected:
321  static bool Internal_IsOverrideDimStyleCandidate(
322  const ON_DimStyle* override_style_candidate,
323  ON_UUID parent_id,
324  bool bRequireSetOverrides,
325  bool bIssueErrorsAndWarnings
326  );
327 
328 
329 public:
330  // Quickly check if this annotation object has style overrides applied.
331  bool HasDimensionStyleOverrides() const;
332 
333  const ON_TextContent* Text() const;
334  ON_TextContent* Text();
335  void SetText(ON_TextContent*& text) const;
336  void ClearText() const;
337 
338  // return angle in radians between text plane and object plane
339  virtual double TextRotationRadians() const;
340  virtual void SetTextRotationRadians(double rotation);
341 
342  // return angle in degrees between text plane and object plane
343  virtual double TextRotationDegrees() const;
344  virtual void SetTextRotationDegrees(double rotation);
345 
346  //virtual bool Explode(
347  // const ON_DimStyle* dimstyle,
348  // ON_SimpleArray<const ON_Geometry*> object_parts) const = 0;
349 
350  /*
351  Returns:
352  The value of ON_DimStyle.TextPositionPropertiesHash() from the dimension style used
353  to calculate the runtime text position (location, glyphs, and size).
354  */
355  ON_SHA1_Hash DimStyleTextPositionPropertiesHash() const;
356 
357  /*
358  Returns:
359  True if this text position information used to create this text
360  is identical to the text position paramters on dimstyle.
361  */
362  bool EqualTextPositionProperties(
363  const class ON_DimStyle* dimstyle
364  ) const;
365 
366  const wchar_t* RtfText() const;
367 
368  bool ReplaceTextString(
369  const wchar_t* RtfString,
370  const ON_DimStyle* dimstyle
371  );
372 
373  void GetAlignment(ON::TextHorizontalAlignment& horz, ON::TextVerticalAlignment& vert) const;
374  void SetAlignment(ON::TextHorizontalAlignment horz, ON::TextVerticalAlignment vert);
376  // FormattingRectangleWidth is a width set by text wrapping. It's in model units
377  double FormattingRectangleWidth() const;
378  void SetFormattingRectangleWidth(double width);
380  // Get corners of the whole text object
381  // corners requires space for 4 points
382  bool GetText3dCorners(ON_3dPoint corners[4]) const;
383 
384  /*
385  Parameters:
386  ptr - [in]
387  pointer to test
388  Returns:
389  True if ptr is not nullptr and points to the override style mangaged by this
390  instance.
391  */
392  bool IsOverrideStylePointer(
393  const ON_DimStyle* ptr
394  ) const;
395 
396 protected:
397  ON::AnnotationType m_annotation_type = ON::AnnotationType::Unset;
398  unsigned char m_reserved1 = 0;
399  unsigned char m_reserved2 = 0;
400  unsigned char m_reserved3 = 0;
401  unsigned int m_reserved4 = 0;
402  ON_UUID m_dimstyle_id = ON_DimStyle::Default.Id();
403  ON_Plane m_plane = ON_Plane::World_xy; // plane origin used for alignment point
404  ON_2dVector m_horizontal_direction = ON_2dVector::XAxis; // direction used as horizontal to draw annotation, especially text
405  mutable ON_TextContent* m_text = nullptr; // Deleted by ~ON_Annotation()
406 private:
407  // Pointer to an override dimstyle when style properties are overridden for this annotation object
408  // If this pointer is null, use the style with id = m_dimstyle_id
409  // Copy and delete this dimstyle (not this pointer) with the object.
410  // This dimstyle should never be one held in a dimstyle table. It is owned by this object
411  mutable ON_DimStyle* m_override_dimstyle = nullptr;
412  mutable ON__UINT64 m_parent_dimstyle_content_version_number = 0;
413  void Internal_DeleteOverrideDimstyle() const;
414 
415  mutable ON_BoundingBoxCache m_bbox_cache;
416 
417 protected:
418  bool Internal_WriteAnnotation(
419  ON_BinaryArchive& archive
420  ) const;
421 
422  bool Internal_ReadAnnotation(
423  ON_BinaryArchive& archive
424  );
425 
426 private:
427  ON_DimStyle* Internal_GetOverrideStyle(bool bCreateIfNull) const;
428 
429  /*
430  Description:
431  Gets the appropriate ON_DimStyle to query for a property value.
432  Parameters:
433  parent_style - [in]
434  parent style pased to the ON_Annotation query function
435  field_id - [in]
436  field being queried - this is used to select between using the override style or the parent style.
437  */
438 
439  const ON_DimStyle& Internal_StyleForFieldQuery(
440  const ON_DimStyle* parent_style,
441  ON_DimStyle::field field_id
442  ) const;
443 
444 private:
445  static bool Internal_DimStyleDoubleChanged(
446  const double current_value,
447  double candidate_value
448  );
449 
450 public:
451  void ClearFieldOverride(ON_DimStyle::field field);
452 
453  bool FieldIsOverridden(ON_DimStyle::field field) const;
454 
455  // These next several functions are to set overrides on individual annotation objects
456 
457  // Extension line extension
458  double ExtensionLineExtension(const ON_DimStyle* parent_style) const;
459  void SetExtensionLineExtension(const ON_DimStyle* parent_style, double d);
460 
461  // Extension line offset
462  double ExtensionLineOffset(const ON_DimStyle* parent_style) const;
463  void SetExtensionLineOffset(const ON_DimStyle* parent_style, double d);
464 
465  // Arrow size
466  double ArrowSize(const ON_DimStyle* parent_style) const;
467  void SetArrowSize(const ON_DimStyle* parent_style, double d);
468 
469  // Arrow size
470  double LeaderArrowSize(const ON_DimStyle* parent_style) const;
471  void SetLeaderArrowSize(const ON_DimStyle* parent_style, double d);
472 
473  // Centermark size
474  double CenterMarkSize(const ON_DimStyle* parent_style) const;
475  void SetCenterMarkSize(const ON_DimStyle* parent_style, double d);
476 
477  // Centermark style
478  ON_DimStyle::centermark_style CenterMarkStyle(const ON_DimStyle* parent_style) const;
479  void SetCenterMarkStyle(const ON_DimStyle* parent_style, ON_DimStyle::centermark_style style);
480 
481  // The location of text relative to the dimension line in linear, angular, and ordinate dimensions.
482  ON_DimStyle::TextLocation DimTextLocation(const ON_DimStyle* parent_style) const;
483  void SetDimTextLocation(const ON_DimStyle* parent_style, ON_DimStyle::TextLocation dim_text_location);
484 
485  // The location of text relative to the dimension line in radial dimensions.
486  ON_DimStyle::TextLocation DimRadialTextLocation(const ON_DimStyle* parent_style) const;
487  void SetDimRadialTextLocation(const ON_DimStyle* parent_style, ON_DimStyle::TextLocation dim_text_location);
488 
489  // Angle units - Degrees, Degrees-Minutes-Seconds, Radians
490  ON_DimStyle::angle_format AngleFormat(const ON_DimStyle* parent_style) const;
491  void SetAngleFormat(const ON_DimStyle* parent_style, ON_DimStyle::angle_format format);
492 
493  // Display resolution for distance measurements
494  int LengthResolution(const ON_DimStyle* parent_style) const;
495  void SetLengthResolution(const ON_DimStyle* parent_style, int r);
496 
497  // Display resolution for angle measurements
498  int AngleResolution(const ON_DimStyle* parent_style) const;
499  void SetAngleResolution(const ON_DimStyle* parent_style, int r);
500 
501  // Distance from dimension lines to text
502  double TextGap(const ON_DimStyle* parent_style) const;
503  void SetTextGap(const ON_DimStyle* parent_style, double gap);
504 
505  // Height of dimension text
506  double TextHeight(const ON_DimStyle* parent_style) const;
507  void SetTextHeight(const ON_DimStyle* parent_style, double height);
508 
509  // Scale factor for displayed distances
510  double LengthFactor(const ON_DimStyle* parent_style) const;
511  void SetLengthFactor(const ON_DimStyle* parent_style, double);
512 
513  // Additional measurement display toggle
514  bool Alternate(const ON_DimStyle* parent_style) const;
515  void SetAlternate(const ON_DimStyle* parent_style, bool);
516 
517  // Distance scale factor for alternate display
518  double AlternateLengthFactor(const ON_DimStyle* parent_style) const;
519  void SetAlternateLengthFactor(const ON_DimStyle* parent_style, double);
520 
521  // Display resolution for alternate length measurements
522  int AlternateLengthResolution(const ON_DimStyle* parent_style) const;
523  void SetAlternateLengthResolution(const ON_DimStyle* parent_style, int);
524 
525  // Dimension prefix text
526  const wchar_t* Prefix(const ON_DimStyle* parent_style) const;
527  void SetPrefix(const ON_DimStyle* parent_style, const wchar_t*);
528 
529  // Dimension suffix text
530  const wchar_t* Suffix(const ON_DimStyle* parent_style) const;
531  void SetSuffix(const ON_DimStyle* parent_style, const wchar_t*);
532 
533  // Dimension alternate prefix text
534  const wchar_t* AlternatePrefix(const ON_DimStyle* parent_style) const;
535  void SetAlternatePrefix(const ON_DimStyle* parent_style, const wchar_t*);
536 
537  // Dimension alternate suffix text
538  const wchar_t* AlternateSuffix(const ON_DimStyle* parent_style) const;
539  void SetAlternateSuffix(const ON_DimStyle* parent_style, const wchar_t*);
540 
541  // Suppress first dimension extension line
542  bool SuppressExtension1(const ON_DimStyle* parent_style) const;
543  void SetSuppressExtension1(const ON_DimStyle* parent_style, bool b);
544 
545  // Suppress second dimension extension line
546  bool SuppressExtension2(const ON_DimStyle* parent_style) const;
547  void SetSuppressExtension2(const ON_DimStyle* parent_style, bool b);
548 
549  // Extension of dimension line past extension lines
550  double DimExtension(const ON_DimStyle* parent_style) const;
551  void SetDimExtension(const ON_DimStyle* parent_style, const double e);
552 
553  ON_DimStyle::tolerance_format ToleranceFormat(const ON_DimStyle* parent_style) const;
554  void SetToleranceFormat(const ON_DimStyle* parent_style, ON_DimStyle::tolerance_format format);
555 
556  int ToleranceResolution(const ON_DimStyle* parent_style) const;
557  void SetToleranceResolution(const ON_DimStyle* parent_style, int resolution);
558 
559  double ToleranceUpperValue(const ON_DimStyle* parent_style) const;
560  void SetToleranceUpperValue(const ON_DimStyle* parent_style, double upper_value);
561 
562  double ToleranceLowerValue(const ON_DimStyle* parent_style) const;
563  void SetToleranceLowerValue(const ON_DimStyle* parent_style, double lower_value);
564 
565  double ToleranceHeightScale(const ON_DimStyle* parent_style) const;
566  void SetToleranceHeightScale(const ON_DimStyle* parent_style, double scale);
567 
568  double BaselineSpacing(const ON_DimStyle* parent_style) const;
569  void SetBaselineSpacing(const ON_DimStyle* parent_style, double spacing);
570 
571  // Determines whether or not to draw a Text Mask
572  bool DrawTextMask(const ON_DimStyle* parent_style) const;
573  void SetDrawTextMask(const ON_DimStyle* parent_style, bool bDraw);
574 
575  // Determines where to get the color to draw a Text Mask
576  ON_TextMask::MaskType MaskFillType(const ON_DimStyle* parent_style) const;
577  void SetMaskFillType(const ON_DimStyle* parent_style, ON_TextMask::MaskType source);
578 
579  ON_Color MaskColor(const ON_DimStyle* parent_style) const; // Only works right if MaskColorSource returns 1.
580  void SetMaskColor(const ON_DimStyle* parent_style, ON_Color color); // Does not return viewport background color
581 
582  // Offset for the border around text to the rectangle used to draw the mask
583  // This number is the offset on each side of the tight rectangle around the
584  // text characters to the mask rectangle.
585  double MaskBorder(const ON_DimStyle* parent_style) const;
586  void SetMaskBorder(const ON_DimStyle* parent_style, double offset);
587 
588  // The ON_TextMask class contains the property values for
589  // DrawTextMask()
590  // MaskColor()
591  // MaskFillType()
592  // MaskBorder()
593  // Use the
594  // DrawTextMask()
595  // MaskColor()
596  // MaskFillType()
597  // MaskBorder()
598  // functions to query individual text mask properties.
599  void SetTextMask(const ON_DimStyle* parent_style, const ON_TextMask& mask);
600 
601  double FixedExtensionLength(const ON_DimStyle* parent_style) const;
602  void SetFixedExtensionLength(const ON_DimStyle* parent_style, double l);
603 
604  bool FixedExtensionLengthOn(const ON_DimStyle* parent_style) const;
605  void SetFixedExtensionLengthOn(const ON_DimStyle* parent_style, bool on);
606 
607  int AlternateToleranceResolution(const ON_DimStyle* parent_style) const;
608  void SetAlternateToleranceResolution(const ON_DimStyle* parent_style, int r);
609 
610  bool SuppressArrow1(const ON_DimStyle* parent_style) const;
611  void SetSuppressArrow1(const ON_DimStyle* parent_style, bool s);
612 
613  bool SuppressArrow2(const ON_DimStyle* parent_style) const;
614  void SetSuppressArrow2(const ON_DimStyle* parent_style, bool s);
615 
616  int TextMoveLeader(const ON_DimStyle* parent_style) const;
617  void SetTextMoveLeader(const ON_DimStyle* parent_style, int m);
618 
619  int ArcLengthSymbol(const ON_DimStyle* parent_style) const;
620  void SetArcLengthSymbol(const ON_DimStyle* parent_style, int m);
621 
622  ON_DimStyle::stack_format StackFractionFormat(const ON_DimStyle* parent_style) const;
623  void SetStackFractionFormat(const ON_DimStyle* parent_style, ON_DimStyle::stack_format f);
624 
625  double StackHeightScale(const ON_DimStyle* parent_style) const;
626  void SetStackHeightScale(const ON_DimStyle* parent_style, double f);
627 
628  double RoundOff(const ON_DimStyle* parent_style) const;
629  void SetRoundOff(const ON_DimStyle* parent_style, double r);
630 
631  double AlternateRoundOff(const ON_DimStyle* parent_style) const;
632  void SetAlternateRoundOff(const ON_DimStyle* parent_style, double r);
633 
634  double AngleRoundOff(const ON_DimStyle* parent_style) const;
635  void SetAngleRoundOff(const ON_DimStyle* parent_style, double r);
636 
637  ON_DimStyle::suppress_zero ZeroSuppress(const ON_DimStyle* parent_style) const;
638  void SetZeroSuppress(const ON_DimStyle* parent_style, ON_DimStyle::suppress_zero s);
639 
640  ON_DimStyle::suppress_zero AlternateZeroSuppress(const ON_DimStyle* parent_style) const;
641  void SetAlternateZeroSuppress(const ON_DimStyle* parent_style, ON_DimStyle::suppress_zero s);
642 
643  // OBSOLETE - The ZeroSuppress() or AlternateZeroSuppress() property
644  // is used to format tolerance display. ToleranceZeroSuppress() is ignored.
645  ON_DimStyle::suppress_zero ToleranceZeroSuppress(const ON_DimStyle* parent_style) const;
646 
647  // OBSOLETE - The ZeroSuppress() or AlternateZeroSuppress() property
648  // is used to format tolerance display. ToleranceZeroSuppress() is ignored.
649  void SetToleranceZeroSuppress(const ON_DimStyle* parent_style, ON_DimStyle::suppress_zero s);
650 
651  ON_DimStyle::suppress_zero AngleZeroSuppress(const ON_DimStyle* parent_style) const;
652  void SetAngleZeroSuppress(const ON_DimStyle* parent_style, ON_DimStyle::suppress_zero s);
653 
654  bool AlternateBelow(const ON_DimStyle* parent_style) const;
655  void SetAlternateBelow(const ON_DimStyle* parent_style, bool below);
656 
657  ON_Arrowhead::arrow_type ArrowType1(const ON_DimStyle* parent_style) const;
658  void SetArrowType1(const ON_DimStyle* parent_style, ON_Arrowhead::arrow_type);
659 
660  ON_Arrowhead::arrow_type ArrowType2(const ON_DimStyle* parent_style) const;
661  void SetArrowType2(const ON_DimStyle* parent_style, ON_Arrowhead::arrow_type);
662 
663  void SetArrowType1And2(const ON_DimStyle* parent_style, ON_Arrowhead::arrow_type);
664 
665  ON_Arrowhead::arrow_type LeaderArrowType(const ON_DimStyle* parent_style) const;
666  void SetLeaderArrowType(const ON_DimStyle* parent_style, ON_Arrowhead::arrow_type);
667 
668  ON_UUID ArrowBlockId1(const ON_DimStyle* parent_style) const;
669  void SetArrowBlockId1(const ON_DimStyle* parent_style, ON_UUID id);
670 
671  ON_UUID ArrowBlockId2(const ON_DimStyle* parent_style) const;
672  void SetArrowBlockId2(const ON_DimStyle* parent_style, ON_UUID id);
673 
674  ON_UUID LeaderArrowBlockId(const ON_DimStyle* parent_style) const;
675  void SetLeaderArrowBlockId(const ON_DimStyle* parent_style, ON_UUID id);
676 
677  ON::TextVerticalAlignment TextVerticalAlignment(const ON_DimStyle* parent_style) const;
678  void SetTextVerticalAlignment(const ON_DimStyle* parent_style, ON::TextVerticalAlignment style);
679 
680  ON::TextVerticalAlignment LeaderTextVerticalAlignment(const ON_DimStyle* parent_style) const;
681  void SetLeaderTextVerticalAlignment(const ON_DimStyle* parent_style, ON::TextVerticalAlignment style);
682 
683  ON_DimStyle::ContentAngleStyle LeaderContentAngleStyle(const ON_DimStyle* parent_style) const;
684  void SetLeaderContentAngleStyle(const ON_DimStyle* parent_style, ON_DimStyle::ContentAngleStyle style);
685 
686  ON_DimStyle::leader_curve_type LeaderCurveType(const ON_DimStyle* parent_style) const;
687  void SetLeaderCurveType(const ON_DimStyle* parent_style, ON_DimStyle::leader_curve_type type);
688 
689  bool LeaderHasLanding(const ON_DimStyle* parent_style) const;
690  void SetLeaderHasLanding(const ON_DimStyle* parent_style, bool landing);
691 
692  double LeaderLandingLength(const ON_DimStyle* parent_style) const;
693  void SetLeaderLandingLength(const ON_DimStyle* parent_style, double length);
694 
695  double LeaderContentAngleRadians(const ON_DimStyle* parent_style) const;
696  void SetLeaderContentAngleRadians(const ON_DimStyle* parent_style, double angle_radians);
697 
698  double LeaderContentAngleDegrees(const ON_DimStyle* parent_style) const;
699  void SetLeaderContentAngleDegrees(const ON_DimStyle* parent_style, double angle_degrees);
700 
701  ON_DimStyle::ContentAngleStyle DimTextAngleStyle(const ON_DimStyle* parent_style) const;
702  void SetDimTextAngleStyle(const ON_DimStyle* parent_style, ON_DimStyle::ContentAngleStyle style);
703 
704  ON_DimStyle::ContentAngleStyle DimRadialTextAngleStyle(const ON_DimStyle* parent_style) const;
705  void SetDimRadialTextAngleStyle(const ON_DimStyle* parent_style, ON_DimStyle::ContentAngleStyle style);
706 
707  ON::TextHorizontalAlignment TextHorizontalAlignment(const ON_DimStyle* parent_style) const;
708  void SetTextHorizontalAlignment(const ON_DimStyle* parent_style, ON::TextHorizontalAlignment halign);
709 
710  ON::TextHorizontalAlignment LeaderTextHorizontalAlignment(const ON_DimStyle* parent_style) const;
711  void SetLeaderTextHorizontalAlignment(const ON_DimStyle* parent_style, ON::TextHorizontalAlignment halign);
712 
713  ON::TextOrientation TextOrientation(const ON_DimStyle* parent_style) const;
714  void SetTextOrientation(const ON_DimStyle* parent_style, ON::TextOrientation orientation);
715 
716  ON::TextOrientation LeaderTextOrientation(const ON_DimStyle* parent_style) const;
717  void SetLeaderTextOrientation(const ON_DimStyle* parent_style, ON::TextOrientation orientation);
718 
719  ON::TextOrientation DimTextOrientation(const ON_DimStyle* parent_style) const;
720  void SetDimTextOrientation(const ON_DimStyle* parent_style, ON::TextOrientation orientation);
721 
722  ON::TextOrientation DimRadialTextOrientation(const ON_DimStyle* parent_style) const;
723  void SetDimRadialTextOrientation(const ON_DimStyle* parent_style, ON::TextOrientation orientation);
724 
725  bool DrawForward(const ON_DimStyle* parent_style) const;
726  void SetDrawForward(const ON_DimStyle* parent_style, bool drawforward);
727 
728  bool TextUnderlined(const ON_DimStyle* parent_style) const;
729  void SetTextUnderlined(const ON_DimStyle* parent_style, bool underlined);
730 
731  bool SignedOrdinate(const ON_DimStyle* parent_style) const;
732  void SetSignedOrdinate(const ON_DimStyle* parent_style, bool allowsigned);
733 
734  double DimScale(const ON_DimStyle* parent_style) const;
735  void SetDimScale(const ON_DimStyle* parent_style, double scale);
736 
737  ON_DimStyle::LengthDisplay DimensionLengthDisplay(const ON_DimStyle* parent_style) const;
738  void SetDimensionLengthDisplay(const ON_DimStyle* parent_style, ON_DimStyle::LengthDisplay length_display);
739 
740  ON_DimStyle::LengthDisplay AlternateDimensionLengthDisplay(const ON_DimStyle* parent_style) const;
741  void SetAlternateDimensionLengthDisplay(const ON_DimStyle* parent_style, ON_DimStyle::LengthDisplay length_display);
742 
743  /// <summary>
744  /// Parameters:
745  /// model_sn - 0, a model serial number, or ON_UNSET_UINT_INDEX to
746  /// use the dimstyle's ModelSerialNumber() value.
747  /// Returns
748  /// Unit system for dimension length display.
749  /// If DimensionLengthDisplay() == ON_DimStyle::LengthDisplay::ModelUnits
750  /// and model_sn > 0, then the value of ON::LengthUnitSystemFromModelSerialNumber(model_sn)
751  /// is returned.
752  /// If DimensionLengthDisplay() == ON_DimStyle::LengthDisplay::ModelUnits
753  /// and model_sn == 0, then ON::LengthUnitSystem::None is returned.
754  ///</summary>
755  ON::LengthUnitSystem DimensionLengthDisplayUnit(
756  const ON_DimStyle* parent_style,
757  unsigned int model_sn
758  ) const;
759 
760  /// <summary>
761  /// Parameters:
762  /// model_sn - 0, a model serial number, or ON_UNSET_UINT_INDEX to
763  /// use the dimstyle's ModelSerialNumber() value.
764  /// Returns
765  /// Unit system for dimension length display.
766  /// If DimensionLengthDisplay() == ON_DimStyle::LengthDisplay::ModelUnits
767  /// and model_sn > 0, then the value of ON::LengthUnitSystemFromModelSerialNumber(model_sn)
768  /// is returned.
769  /// If DimensionLengthDisplay() == ON_DimStyle::LengthDisplay::ModelUnits
770  /// and model_sn == 0, then ON::LengthUnitSystem::None is returned.
771  ///</summary>
772  ON::LengthUnitSystem AlternateDimensionLengthDisplayUnit(
773  const ON_DimStyle* parent_style,
774  unsigned int model_sn
775  ) const;
776 
777  /*
778  Description:
779  Set the font used to render text.
780  Parameters:
781  font_characteristics - [in]
782  This parameter does not have to be a managed font.
783  Remarks:
784  If the parameter is a managed font (font_characteristics.IsManagedFont() is true),
785  then the identical value is returned by ON_DimStyle.Font().
786  If the parameter is not a managed font (font_characteristics.IsManagedFont() is false),
787  then the ON_Font::GetManagedFont(font_characteristics) will be returned by
788  ON_DimStyle.Font().
789  */
790  void SetFont(const ON_DimStyle* parent_style, const class ON_Font& font_characteristics);
791 
792  /*
793  Returns:
794  The managed font used to render text.
795  */
796  const class ON_Font& Font(const ON_DimStyle* parent_style) const;
797 
798  /*
799  Returns:
800  A copy of the font_characteristics information.
801  Remarks:
802  You probably want to use Font(). This function is only useful
803  in isolated situations and is typically used to study font
804  substitutions when a model moves between computers or platforms.
805  */
806  const class ON_Font& FontCharacteristics(const ON_DimStyle* parent_style) const;
808  /*
809  Returns:
810  True if the font returned by Font() is a substitute
811  for the font passed to SetFont().
812  Remarks:
813  Font substitution can occur when a model is moved between
814  computers that have different fonts installed.
815  */
816  const bool FontSubstituted(const ON_DimStyle* parent_style) const;
817 
818 
819 
820  bool SetAnnotationBold(bool bold, const ON_DimStyle* dimstyle);
821  bool SetAnnotationItalic(bool italic, const ON_DimStyle* dimstyle);
822  bool SetAnnotationUnderline(bool underline, const ON_DimStyle* dimstyle);
823  bool SetAnnotationFacename(bool set_or_clear, const wchar_t* facename, const ON_DimStyle* parent_style);
824  static bool SetAnnotationTextFormat(ON_wString& rtf_in, const wchar_t* fmt_str_on, const wchar_t* fmt_str_off, bool set_on);
825 
826  static bool SetRtfFmt(ON_wString& rtf_in, const wchar_t* fmt_str);
827  static bool ClearRtfFmt(const wchar_t* fmt_str_on, const wchar_t* fmt_str_off, ON_wString& rtf_in);
828  static int FindRtfTable(ON_wString rtf_in, int startidx, const wchar_t* tablename);
829 
830  static bool FirstCharTextProperties(const wchar_t* rtf_in, bool& bold, bool& italic, bool& underline, ON_wString& facename);
831 };
832 
833 
834 /*
835  A simple dot with text that doesn't rotate witn the world axes
836 */
837 class ON_CLASS ON_TextDot : public ON_Geometry
838 {
839  ON_OBJECT_DECLARE(ON_TextDot);
840 public:
841  static const wchar_t* DefaultFontFace; // Arial
842  static const int DefaultHeightInPoints; // 14 points
843  static const int MinimumHeightInPoints; // 3 points
844  static const ON_TextDot Unset;
845 
846  ON_TextDot();
847  ~ON_TextDot();
848  ON_TextDot( const ON_TextDot& ) = default;
849  ON_TextDot& operator=( const ON_TextDot& ) = default;
850 
851  ON_TextDot(
852  ON_3dPoint center_point,
853  const wchar_t* primary_text,
854  const wchar_t* secondary_text
855  );
856 
857  static ON_TextDot* CreateFromV2AnnotationTextDot(
858  const class ON_OBSOLETE_V2_TextDot& V2_text_dot,
859  const class ON_3dmAnnotationContext* annotation_context,
860  ON_TextDot* destination
861  );
862 
863  void EmergencyDestroy();
864 
865  //---------------------------
866  // ON_Object overrides
867 
868  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
869 
870  /*
871  Description: Write data values to a text file for debugging
872  */
873  void Dump( ON_TextLog& log) const override;
874 
875  /*
876  Description: Writes the object to a file
877 
878  Returns:
879  @untitled Table
880  true Success
881  false Failure
882  */
883  bool Write( ON_BinaryArchive& ar) const override;
884 
885  /*
886  Description: Reads the object from a file
887 
888  Returns:
889  @untitled Table
890  true Success
891  false Failure
892  */
893  bool Read( ON_BinaryArchive& ar) override;
894 
895  /*
896  Returns: The Object Type of this object
897  */
898  ON::object_type ObjectType() const override;
899 
900  //---------------------------
901  // ON_Geometry overrides
902 
903  /*
904  Returns the geometric dimension of the object ( usually 3)
905  */
906  int Dimension() const override;
907 
908  // virtual ON_Geometry GetBBox override
909  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
910 
911  /*
912  Description:
913  Transform the object by a 4x4 xform matrix
914  Parameters:
915  [in] xform - An ON_Xform with the transformation information
916  Returns:
917  true = Success
918  false = Failure
919  Remarks:
920  The object has been transformed when the function returns
921  */
922  bool Transform( const ON_Xform& xform) override;
923 
924  // virtual ON_Geometry::IsDeformable() override
925  bool IsDeformable() const override;
926 
927  // virtual ON_Geometry::MakeDeformable() override
928  bool MakeDeformable() override;
929 
930 
931  ON_3dPoint CenterPoint() const;
932  void SetCenterPoint(
933  ON_3dPoint center_point
934  );
935 
936  ON_DEPRECATED_MSG("use CenterPoint")
937  const ON_3dPoint& Point() const;
938  ON_DEPRECATED_MSG("use SetCenterPoint")
939  void SetPoint(const ON_3dPoint& point);
940 
941  /*
942  Returns:
943  Text height in "points".
944  Remarks:
945  Default height = 14;
946  */
947  int HeightInPoints() const;
948  void SetHeightInPoints(
949  int height_in_points
950  );
951 
952  /*
953  Returns:
954  Dot's primary text displayed in the model
955  Typically a short and terse string.
956  Default = empty string.
957  Remarks:
958  Additional information can be saved as secondary text.
959 
960  Never save the pointer value for future use.
961  Save a copy in ON_wString if the text is needed beyond the scope of
962  the call to Text().
963  */
964  const wchar_t* PrimaryText() const;
965  void SetPrimaryText(
966  const wchar_t* primary_dot_text
967  );
968 
969  ON_DEPRECATED_MSG("use PrimaryText")
970  const wchar_t* TextString() const;
971  ON_DEPRECATED_MSG("use SetPrimaryText")
972  void SetTextString(const wchar_t* string);
973  /*
974  Returns:
975  Dot's secondary text displayed when a user interface event like cliking or hovering occurs.
976  Typically longer and more detailed than the primary text.
977  Default = empty string.
978  Remarks:
979  Never save the pointer value for future use.
980  Save a copy in ON_wString if the text is needed beyond the scope of
981  the call to Text().
982  */
983  const wchar_t* SecondaryText() const;
984  void SetSecondaryText(
985  const wchar_t* secondary_dot_text
986  );
987 
988 
989  /*
990  Returns:
991  Primary text font face.
992  Default = "Arial Bold";
993  Remarks:
994  Never save the pointer value for future use.
995  Save a copy in ON_wString if the text is needed beyond the scope of
996  the call to FontFace().
997  */
998  const wchar_t* FontFace() const;
999  void SetFontFace(
1000  const wchar_t* font_face)
1001  ;
1002 
1003  /*
1004  Description:
1005  Get or Set whether the dot is drawn "On Top" of other geometry
1006  Parameters:
1007  [in] bTop bool - It is or isn't on top
1008  Returns:
1009  @untitled table
1010  true - on top
1011  false - not on top
1012  */
1013  void SetAlwaysOnTop(
1014  bool bAlwaysOnTop
1015  );
1016  bool AlwaysOnTop() const;
1017 
1018  /*
1019  Description:
1020  Get or Set whether the dot is drawn with a transparent background
1021  Parameters:
1022  [in] bTransparent bool - It is or isn't transparent
1023  Returns:
1024  @untitled table
1025  true - transparent
1026  false - not transparent
1027  */
1028  void SetTransparent(
1029  bool bTransparent
1030  );
1031  bool Transparent() const;
1032 
1033  /*
1034  Description:
1035  Get or Set whether the dot is drawn with Bold text
1036  Parameters:
1037  [in] bBold bool - It is or isn't Bold
1038  Returns:
1039  @untitled table
1040  true - Bold
1041  false - not Bold
1042  */
1043  void SetBold(
1044  bool bBold
1045  );
1046  bool Bold() const;
1047 
1048  /*
1049  Description:
1050  Get or Set whether the dot is drawn with Italic text
1051  Parameters:
1052  [in] bItalic bool - It is or isn't Italic
1053  Returns:
1054  @untitled table
1055  true - Italic
1056  false - not Italic
1057  */
1058  void SetItalic(
1059  bool bItalic
1060  );
1061  bool Italic() const;
1062 
1063 private:
1064  // Location of the center of the text dot.
1065  ON_3dPoint m_center_point = ON_3dPoint::UnsetPoint;
1066 
1067 private:
1068  ON_wString m_primary_text; // default is empty
1069 
1070 private:
1071  ON_wString m_secondary_text; // default is empty
1072 
1073 private:
1074  ON_wString m_font_face; // Empty means ON_TextDot::DefaultFontFace
1075 
1076 private:
1077  unsigned int m_display_bits = 0;
1078 
1079 private:
1080  int m_height_in_points = ON_TextDot::DefaultHeightInPoints;
1081 };
1082 
1083 #endif
Definition: opennurbs_annotationbase.h:23
virtual bool Transform(const ON_Xform &xform)
Transforms the object.
suppress_zero
Marks leading and trailing zeros for removal.
Definition: opennurbs_dimensionstyle.h:950
angle_format
Display format for angles
Definition: opennurbs_dimensionstyle.h:860
ON_UUID is a 16 byte universally unique identifier.
Definition: opennurbs_uuid.h:32
Definition: opennurbs_bounding_box.h:606
virtual int Dimension() const
Dimension of the object.
centermark_style
Style for drawing centermark for Radial dimensions and Centermark objects
Definition: opennurbs_dimensionstyle.h:996
const ON_UUID & Id() const
arrow_type
Defines enumerated values for arrowhead shapes.
Definition: opennurbs_dimensionstyle.h:37
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
field
Field identifiers used for file i/o and getting/setting values
Definition: opennurbs_dimensionstyle.h:584
virtual bool MakeDeformable()
If possible, converts the object into a form that can be accuratly modified with "squishy" transforma...
Definition: opennurbs_sha1.h:19
A simple dot with text that doesn&#39;t rotate witn the world axes.
Definition: opennurbs_annotationbase.h:807
stack_format
Format of stacked fractions
Definition: opennurbs_dimensionstyle.h:977
LengthDisplay
Interface.
Definition: opennurbs_dimensionstyle.h:426
Definition: opennurbs_string.h:2020
Definition: opennurbs_dimensionstyle.h:218
virtual ON::object_type ObjectType() const
Useful for switch statements that need to differentiate between basic object types like points...
TextLocation
The location of text in linear, angular, radial, and ordinate dimensions.
Definition: opennurbs_dimensionstyle.h:920
Context for an annotation object. This context is required when converting current annotation objects...
Definition: opennurbs_archive.h:1592
Base class for all geometry classes that must provide runtime class id. Provides interface for common...
Definition: opennurbs_geometry.h:37
Definition: opennurbs_color.h:24
Definition: opennurbs_point.h:277
MaskType
Text mask drawn with background color or explicit color
Definition: opennurbs_dimensionstyle.h:103
Definition: opennurbs_text.h:28
Definition: opennurbs_dimensionstyle.h:95
static const ON_Plane World_xy
world plane coordinate system ON_Plane(ON_3dPoint::Origin, ON_3dVector::XAxis, ON_3dVector::YAxis); ...
Definition: opennurbs_plane.h:483
Definition: opennurbs_bounding_box.h:25
static const ON_2dVector XAxis
Definition: opennurbs_point.h:853
Definition: opennurbs_xform.h:28
static const ON_Geometry Unset
Definition: opennurbs_geometry.h:49
An ON_Font is a face in a font family. It corresponds to a Windows LOGFONT, a .NET System...
Definition: opennurbs_font.h:225
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
void EmergencyDestroy()
Sets m_user_data_list = 0.
virtual bool IsDeformable() const
static const ON_DimStyle Default
Definition: opennurbs_dimensionstyle.h:227
tolerance_format
Style of tolerance display for dimensions
Definition: opennurbs_dimensionstyle.h:503
ON_Geometry & operator=(const ON_Geometry &)=default
Definition: opennurbs_array.h:409
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
leader_curve_type
Type of leader curve
Definition: opennurbs_dimensionstyle.h:558
Definition: opennurbs_viewport.h:31
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
Definition: opennurbs_point.h:460
ContentAngleStyle
Angle for text or other leader or dimension content
Definition: opennurbs_dimensionstyle.h:533
bool IsValid(class ON_TextLog *text_log=nullptr) const override
Tests an object to see if its data members are correctly initialized.
virtual bool Write(ON_BinaryArchive &binary_archive) const
Low level archive writing tool used by ON_BinaryArchive::WriteObject().
Definition: opennurbs_plane.h:20
Definition: opennurbs_point.h:839
Definition: opennurbs_point.h:1152