QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_annotation2.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#ifndef OPENNURBS_ANNOTATION2_H_INC
17#define OPENNURBS_ANNOTATION2_H_INC
18
19#if defined(ON_OS_WINDOWS_GDI)
20
21#define ON_RECT RECT
22
23#else
24
25typedef struct tagON_RECT
26{
27 int left;
28 int top;
29 int right;
30 int bottom;
32
33#endif
34
35
37{
38public:
41
43
44 // override virtual ON_Object::Dump function
45 void Dump( ON_TextLog& text_log ) const;
46
47 // override virtual ON_Object::Dump function
48 unsigned int SizeOf() const;
49
50 // override virtual ON_Object::Write function
51 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const;
52
53 // override virtual ON_Object::Read function
55
56 // override virtual ON_UserData::GetDescription function
58
59 // override virtual ON_UserData::Archive function
61
62
63
64 ON_Annotation2Text& operator=(const char*);
65 ON_Annotation2Text& operator=(const wchar_t*);
66
67 void SetText( const char* s );
68 void SetText( const wchar_t* s );
69
70 // m_rect is a Windows gdi RECT that bounds text
71 // ("x" increases to the right and "y" increases downwards).
72 // If all fields are 0, then m_rect is not set.
73 // If left < right and top < bottom, then the rect bounds
74 // the text when it is drawn with its font's
75 // lfHeight=ON_Font::normal_font_height and (0,0) left baseline
76 // point of the leftmost character on the first line
77 // of text. If (x,y) is a point on the drawn text, then
78 // left <= x < right and top <= y < bottom.
80};
81
82// Extension to ON_TextEntity added 12/10/2009 for Text background drawing
84{
86public:
87
90
91 static
92 ON_TextExtra* TextExtension(class ON_TextEntity2* pDim, bool bCreate);
93 static const
94 ON_TextExtra* TextExtension(const class ON_TextEntity2* pDim, bool bCreate);
95
96 void SetDefaults();
97
98 // override virtual ON_Object::Dump function
99 void Dump( ON_TextLog& text_log ) const;
100
101 // override virtual ON_Object::Dump function
102 unsigned int SizeOf() const;
103
104 // override virtual ON_Object::Write function
105 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const;
106
107 // override virtual ON_Object::Read function
108 ON_BOOL32 Read(ON_BinaryArchive& binary_archive);
109
110 // override virtual ON_UserData::GetDescription function
111 ON_BOOL32 GetDescription( ON_wString& description );
112
113 // override virtual ON_UserData::Archive function
114 ON_BOOL32 Archive() const;
115
116 ON_UUID ParentUUID() const;
117 void SetParentUUID( ON_UUID parent_uuid);
118
119 bool DrawTextMask() const;
120 void SetDrawTextMask(bool bDraw);
121
122 int MaskColorSource() const;
123 void SetMaskColorSource(int source);
124
125 ON_Color MaskColor() const; // Only works right if MaskColorSource returns 2.
126 // Does not return viewport background color
127 void SetMaskColor(ON_Color color);
128
129 double MaskOffsetFactor() const;
130 void SetMaskOffsetFactor(double offset);
131
132 ON_UUID m_partent_uuid; // uuid of the text using this extension
133
134 bool m_bDrawMask; // do or don't draw a mask
135
136 int m_color_source; // 0: Use background color from viewport
137 // 1: Use specific color from m_mask_color
138
139 ON_Color m_mask_color; // Color to use for mask if m_color_source is 2
140
141 double m_border_offset; // Offset for the border around text to the rectangle used to draw the mask
142 // This number * HeightOfI for the text is the offset on each side of the
143 // tight rectangle around the text characters to the mask rectangle.
144};
145
146
148{
150public:
151
154
155 static
156 ON_DimensionExtra* DimensionExtension(class ON_LinearDimension2* pDim, bool bCreate);
157 static const
159
160 void SetDefaults();
161
162 // override virtual ON_Object::Dump function
163 void Dump( ON_TextLog& text_log ) const;
164
165 // override virtual ON_Object::Dump function
166 unsigned int SizeOf() const;
167
168 // override virtual ON_Object::Write function
169 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const;
170
171 // override virtual ON_Object::Read function
172 ON_BOOL32 Read(ON_BinaryArchive& binary_archive);
173
174 // override virtual ON_UserData::GetDescription function
175 ON_BOOL32 GetDescription( ON_wString& description );
176
177 // override virtual ON_UserData::Archive function
178 ON_BOOL32 Archive() const;
179
180 ON_UUID ParentUUID() const;
181 void SetParentUUID( ON_UUID parent_uuid);
182
183 // 0: default position
184 // 1: force inside
185 // -1: force outside
186 int ArrowPosition() const;
187 void SetArrowPosition( int position);
188
189 //const wchar_t* ToleranceUpperString() const;
190 //ON_wString& ToleranceUpperString();
191 //void SetToleranceUpperString( const wchar_t* upper_string);
192 //void SetToleranceUpperString( ON_wString& upper_string);
193
194 //const wchar_t* ToleranceLowerString() const;
195 //ON_wString& ToleranceLowerString();
196 //void SetToleranceLowerString( const wchar_t* lower_string);
197 //void SetToleranceLowerString( ON_wString& lower_string);
198
199 //const wchar_t* AlternateString() const;
200 //ON_wString& AlternateString();
201 //void SetAlternateString( const wchar_t* alt_string);
202 //void SetAlternateString( ON_wString& alt_string);
203
204 //const wchar_t* AlternateToleranceUpperString() const;
205 //ON_wString& AlternateToleranceUpperString();
206 //void SetAlternateToleranceUpperString( const wchar_t* upper_string);
207 //void SetAlternateToleranceUpperString( ON_wString& upper_string);
208
209 //const wchar_t* AlternateToleranceLowerString() const;
210 //ON_wString& AlternateToleranceLowerString();
211 //void SetAlternateToleranceLowerString( const wchar_t* lower_string);
212 //void SetAlternateToleranceLowerString( ON_wString& lower_string);
213
214 ON_UUID m_partent_uuid; // the dimension using this extension
215
217
218 // This is either NULL or an array of GDI rects for the substrings
219 // that make up the dimension string.
220 // If the dimension text is all on the same line, there is just one
221 // rectangle needed to bound the text and that is the same as the
222 // m_rect on the ON_Annotation2Text.
223 // If the dimension has tolerances or for some other reason has more
224 // than one line of text, m_text_rects is an array of 7 rects, one
225 // each for the substrings that might be needed to display the dimension.
226 // If some of the rects aren't used, they are empty at 0,0
227 // The strings that correspond to these rectangles are generated from
228 // info in the dimstyle
230};
231
232
233/*
234 class ON_Annotation2
235
236 Description:
237 Used to serialize definitions of annotation objects (dimensions, text, leaders, etc.).
238 Virtual base class for annotation objects
239 Replaces ON_Annotation
240*/
242{
244
245 // UNICODE symbol code to use for degrees, radius, diameter and plus/minus in dimensions
247 {
248 degreesym = 176,
249 radiussym = L'R',
250 diametersym = 216,
251 plusminussym = 177,
252 };
253
254public:
257 // C++ automatically provides the correct copy constructor and operator= .
258 //ON_Annotation2(const ON_Annotation2&);
259 //ON_Annotation2& operator=(const ON_Annotation2&);
260
261 // convert from old style annotation
264
265 // Description:
266 // Sets initial defaults
267 void Create();
268
269 void Destroy();
270
271 void EmergencyDestroy();
272
274 //
275 // ON_Object overrides
276 //
277
278 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
279
280
281 /*
282 Description: Writes the object to a file
283
284 Returns:
285 @untitled Table
286 true Success
287 false Failure
288 */
289 ON_BOOL32 Write(
291 ) const;
292
293 /*
294 Description: Reads the object from a file
295
296 Returns:
297 @untitled Table
298 true Success
299 false Failure
300 */
301 ON_BOOL32 Read(
303 );
304
305 /*
306 Returns: The Object Type of this object
307 */
308 ON::object_type ObjectType() const;
309
311 //
312 // ON_Geometry overrides
313 //
314
315 /*
316 Returns the geometric dimension of the object ( usually 3)
317 */
318 int Dimension() const;
319
320 // overrides virtual ON_Geometry::Transform()
321 ON_BOOL32 Transform( const ON_Xform& xform );
322
323 // virtual ON_Geometry override
324 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const;
325
327 //
328 // ON_Annotation2 interface
329 //
330
331 // Definitions of text justification
332 // Not implemented on all annotation objects
334 {
335 tjUndefined = 0,
336 tjLeft = 1<<0,
337 tjCenter = 1<<1,
338 tjRight = 1<<2,
339 tjBottom = 1<<16,
340 tjMiddle = 1<<17,
341 tjTop = 1<<18,
342 tjBottomLeft = tjBottom | tjLeft,
343 tjBottomCenter = tjBottom | tjCenter,
344 tjBottomRight = tjBottom | tjRight,
345 tjMiddleLeft = tjMiddle | tjLeft,
346 tjMiddleCenter = tjMiddle | tjCenter,
347 tjMiddleRight = tjMiddle | tjRight,
348 tjTopLeft = tjTop | tjLeft,
349 tjTopCenter = tjTop | tjCenter,
350 tjTopRight = tjTop | tjRight,
351 };
352
353 /*
354 Description:
355 Query if the annotation object is a text object
356 Parameters:
357 none
358 Returns:
359 @untitled table
360 true It is text
361 false Its not text
362 */
363 bool IsText() const;
364
365 /*
366 Description:
367 Query if the annotation object is a leader
368 Parameters:
369 none
370 Returns:
371 @untitled table
372 true It is a leader
373 false Its not a leader
374 */
375 bool IsLeader() const;
376
377 /*
378 Description:
379 Query if the annotation object is a dimension
380 Parameters:
381 none
382 Returns:
383 @untitled table
384 true It is a dimension
385 false Its not a dimension
386 */
387 bool IsDimension() const;
388
389 /*
390 Description:
391 Set or get the index in the appropriate table for either the font or
392 dimstyle of this object
393 Parameters:
394 [in] int the new index (Set)
395 Returns:
396 int - The index (Get)
397 Remarks:
398 If the object is a text object the index is of object's font in the Font Table
399 If the object is anything else, the index is of the object's dimstyle in the DimStyle Table
400 Derived objects can use FontIndex() and StyleIndex() to set/get these same values.
401 */
402 int Index() const;
403 void SetIndex( int);
404
405 /*
406 Returns:
407 Dimension type
408 Linear dim: distance between arrow tips
409 Radial dim: radius or diameter depending on m_type value
410 Angular dim: angle in degrees
411 Leader: ON_UNSET_VALUE
412 Text: ON_UNSET_VALUE
413 */
414 virtual
415 double NumericValue() const;
416
417 /*
418 Description:
419 Set or Get the height of the text in this annotation
420 Parameters:
421 [in] double new text height to set
422 Returns:
423 double Height of the text
424 Remarks:
425 Height is in model units
426 */
427 void SetHeight( double);
428 double Height() const;
429
430 /*
431 Description:
432 Sets or gets the object type member to a specific annotation type:
433 dtDimLinear, dtDimAligned, dtDimAngular, etc.
434 Parameters:
435 [in] ON::eAnnotationType type - dtDimLinear, dtDimAligned, dtDimAngular, etc.
436 Returns:
437 ON::eAnnotationType of the object
438 */
439 void SetType( ON::eAnnotationType);
440 ON::eAnnotationType Type() const;
441
442 /*
443 Description:
444 Set or get the plane for the object's ECS
445 Parameters:
446 [in] ON_Plane& plane in WCS
447 Returns:
448 const ON_Plane& - the object's ECS plane in WCS coords
449 */
450 void SetPlane( const ON_Plane&);
451 const ON_Plane& Plane() const;
452
453 /*
454 Description:
455 Returns the number of definition points this object has
456 Parameters:
457 none
458 Returns:
459 @untitled table
460 int the object's point count
461 */
462 int PointCount() const;
463 void SetPointCount( int count);
464
465 /*
466 Description:
467 Set or get the object's whole points array at once
468 Parameters:
469 [in] ON_2dPointArray& pts
470 Returns:
471 const ON_2dPointArray& - ref to the object's point array
472 */
473 void SetPoints( const ON_2dPointArray&);
474 const ON_2dPointArray& Points() const;
475
476 /*
477 Description:
478 Set individual definition points for the annotation
479 Parameters:
480 @untitled table
481 [in] int index index of the point to set in ECS 2d coordinates
482 [in] const ON_2dPoint& pt the new point value
483 Returns:
484 ON_2dPoint the point coordinates in ECS
485 */
486 void SetPoint( int, const ON_2dPoint&);
487 ON_2dPoint Point( int) const;
488
489 /*
490 Description:
491 Set or get the string value of the user text, with no substitution for "<>"
492 Parameters:
493 [in] const wchar_t* string the new value for UserText
494 Returns:
495 const ON_wString& The object's UserText
496 Remarks:
497 UserText is the string that gets printed when the dimensoin is drawn.
498 If it contains the token "<>", that token is replaced with the measured
499 value for the dimension, formatted according to the DimStyle settings.
500 "<>" is the default for linear dimensions.
501 Other dimensions include "<>" in their default string
502 */
503 void SetUserText( const wchar_t*);
504 const ON_wString& UserText() const;
505
506 /*
507 Description:
508 Set or get a flag indication that the dimension text has been moved
509 from the default location.
510 Parameters:
511 bUserPositionedText - [in]
512 true to indicate that the text has been placed by the user.
513 false to indicate that it hasn't
514 Returns:
515 @untitled table
516 true The text has been moved
517 false The text is in the default location
518 Remarks:
519 If the text is in the default location, it should be repositioned
520 automatically when the dimension is adjusted.
521 If it has been moved, it should not be automatically positioned.
522 */
523 void SetUserPositionedText( int bUserPositionedText );
524 bool UserPositionedText() const;
525
526 /*
527 Description:
528 Set or get the text display mode for the annotation
529 Parameters:
530 [in] ON::eTextDisplayMode mode - new mode to set
531 Returns:
532 ON::eTextDisplayMode - current mode
533 Remarks:
534 This is the way the text is oriented with respect to the dimension line or screen:
535 Above line, In LIne, Horizontal
536 */
537 void SetTextDisplayMode( ON::eTextDisplayMode);
538 ON::eTextDisplayMode TextDisplayMode() const;
539
540
541 /*
542 Description:
543 Gets a transform matrix to change from the object's 2d ECS to 3d WCS
544 Parameters:
545 [out] xform set to produce the ECS to WCS transform
546 Returns:
547 @untitled table
548 true Success
549 false Failure
550 */
551 ON_BOOL32 GetECStoWCSXform( ON_Xform&) const;
552
553 /*
554 Description:
555 Gets a transform matrix to change from to 3d WCS to the object's 2d ECS
556 Parameters:
557 [out] xform - set to produce the WCS to ECS transform
558 Returns:
559 @untitled table
560 true Success
561 false Failure
562 */
563 ON_BOOL32 GetWCStoECSXform( ON_Xform& xform) const;
564
565 /*
566 Description:
567 Set the object's point array to a specified length
568 Parameters:
569 [in] length - the new size of the array
570 Returns:
571 void
572 */
573 void ReservePoints( int);
574
575
576 /*
577 Description:
578 static function to provide the default UserText string for the object
579 Returns:
580 const wchar_t* - the default string to use
581 */
582 static const wchar_t* DefaultText();
583
584 /*
585 Description:
586 Convert back to the version of ON_Annotation used in Rhino 2
587 Parameters:
588 target [out] the old-style object
589 Returns:
590 @untitled table
591 true Success
592 False Failure
593 See Also: ON_AngularDimension::ConvertBack()
594 */
595 virtual
596 void ConvertBack( ON_Annotation& target);
597
598 /*
599 Description:
600 Set or Get the text justification
601 Parameters:
602 justification [in] See enum eJustification for meanings
603 Returns:
604 The justification for the text in this object
605 Comments:
606 This is not implemented on all annotation objects.
607 The default SetJustification() does nothing
608 The default Justification() always returns 0
609
610 */
611 virtual
612 void SetJustification( unsigned int justification);
613
614 virtual
615 unsigned int Justification();
616
617 /*
618 Description:
619 Get the transformation that maps the annotation's
620 text to world coordinates.
621 Added Oct 30, 07 LW
622 Parameters:
623 gdi_text_rect - [in]
624 Windows gdi rect of text when it is drawn with
625 LOGFONT lfHeight = ON_Font::normal_font_height.
626 gdi_height_of_I - [in]
627 Value returned by ON_Font::HeightOfI().
628 dimstyle_textheight - [in]
629 Height of text in world units. If the annotation is
630 an ON_TextEntity2, this is the m_textheight value.
631 If the annotation is not an ON_TextEntity2, pass in
632 the value returned by the dimension style's
633 ON_DimStyle::TextHeight()
634 dimstyle_textgap - [in]
635 The value of the annotation's dimension style's
636 ON_DimStyle::TextGap().
637 dimstyle_textalignment - [in]
638 ON::TextDisplayMode(ON_DimStyle::TextAlignment()).
639 dimscale - [in]
640 Global dimension scaling value. If you are using the
641 Rhino SDK, this value is returned by
642 CRhinoDoc::Properties().AnnotationSettings().DimScale().
643 If you are using the OpenNURBS IO toolkit, this value
644 is on ON_3dmSettings::m_AnnotationSettings.m_dimscale.
645 cameraX - [in]
646 zero or the view's unit camera right vector
647 cameraY - [in]
648 zero or the view's unit camera up vector
649 model_xform - [in] transforms the text's parent entity
650 to world coordinates in case its instance geometry
651 NULL == Identity
652 text_xform - [out]
653 Returns:
654 True if text_xform is set.
655 */
656 bool GetTextXform(
657 ON_RECT gdi_text_rect,
658 int gdi_height_of_I,
659 double dimstyle_textheight,
660 double dimstyle_textgap,
661 ON::eTextDisplayMode dimstyle_textalignment,
662 double dimscale,
663 ON_3dVector cameraX,
664 ON_3dVector cameraY,
665 const ON_Xform* model_xform,
666 ON_Xform& text_xform // output
667 ) const;
668
669 /*
670 Description:
671
672 This function has been replaced with a version that
673 takes a model transform to transform block instance
674 geometry to world coordinates Oct 30, 07 LW
675
676 Get the transformation that maps the annotation's
677 text to world coordinates.
678 Parameters:
679 gdi_text_rect - [in]
680 Windows gdi rect of text when it is drawn with
681 LOGFONT lfHeight = ON_Font::normal_font_height.
682 gdi_height_of_I - [in]
683 Value returned by ON_Font::HeightOfI().
684 dimstyle_textheight - [in]
685 Height of text in world units. If the annotation is
686 an ON_TextEntity2, this is the m_textheight value.
687 If the annotation is not an ON_TextEntity2, pass in
688 the value returned by the dimension style's
689 ON_DimStyle::TextHeight()
690 dimstyle_textgap - [in]
691 The value of the annotation's dimension style's
692 ON_DimStyle::TextGap().
693 dimstyle_textalignment - [in]
694 ON::TextDisplayMode(ON_DimStyle::TextAlignment()).
695 dimscale - [in]
696 Global dimension scaling value. If you are using the
697 Rhino SDK, this value is returned by
698 CRhinoDoc::Properties().AnnotationSettings().DimScale().
699 If you are using the OpenNURBS IO toolkit, this value
700 is on ON_3dmSettings::m_AnnotationSettings.m_dimscale.
701 cameraX - [in]
702 zero or the view's unit camera right vector
703 cameraY - [in]
704 zero or the view's unit camera up vector
705 xform - [out]
706 Returns:
707 True if xform is set.
708 */
709 bool GetTextXform(
710 ON_RECT gdi_text_rect,
711 int gdi_height_of_I,
712 double dimstyle_textheight,
713 double dimstyle_textgap,
714 ON::eTextDisplayMode dimstyle_textalignment,
715 double dimscale,
716 ON_3dVector cameraX,
717 ON_3dVector cameraY,
718 ON_Xform& xform
719 ) const;
720
721 /*
722 Description:
723 Get the transformation that maps the annotation's
724 text to world coordinates.
725 Oct 30, 07 LW
726 Parameters:
727 gdi_text_rect - [in]
728 Windows gdi rect of text when it is drawn with
729 LOGFONT lfHeight = ON_Font::normal_font_height.
730 font - [in]
731 dimstyle - [in]
732 dimscale - [in]
733 Global dimension scaling value. If you are using the
734 Rhino SDK, this value is returned by
735 CRhinoDoc::Properties().AnnotationSettings().DimScale().
736 If you are using the OpenNURBS IO toolkit, this value
737 is on ON_3dmSettings::m_AnnotationSettings.m_dimscale.
738 vp - [in]
739 model_xform - [in] transforms the text's parent entity
740 to world coordinates in case its instance geometry
741 NULL == Identity
742 text_xform - [out]
743 Returns:
744 True if text_xform is set.
745 */
746 bool GetTextXform(
747 const ON_RECT gdi_text_rect,
748 const ON_Font& font,
749 const ON_DimStyle& dimstyle,
750 double dimscale,
751 const ON_Viewport* vp,
752 const ON_Xform* model_xform,
753 ON_Xform& text_xform // output
754 ) const;
755
756 /*
757 Description:
758
759 This function has been replaced with a version that
760 takes a model transform because the viewport doesn't
761 contain block instance transform info Oct 30, 07 LW
762
763 Get the transformation that maps the annotation's
764 text to world coordinates.
765 Parameters:
766 gdi_text_rect - [in]
767 Windows gdi rect of text when it is drawn with
768 LOGFONT lfHeight = ON_Font::normal_font_height.
769 font - [in]
770 dimstyle - [in]
771 dimscale - [in]
772 Global dimension scaling value. If you are using the
773 Rhino SDK, this value is returned by
774 CRhinoDoc::Properties().AnnotationSettings().DimScale().
775 If you are using the OpenNURBS IO toolkit, this value
776 is on ON_3dmSettings::m_AnnotationSettings.m_dimscale.
777 vp - [in]
778 xform - [out]
779 Returns:
780 True if xform is set.
781 */
782 bool GetTextXform(
783 ON_RECT gdi_text_rect,
784 const ON_Font& font,
785 const ON_DimStyle& dimstyle,
786 double dimscale,
787 const ON_Viewport* vp,
788 ON_Xform& xform
789 ) const;
790
791 /*
792 Description:
793 Get the annotation plane coordinates (ECS) of the point
794 that is used to position the text. The relative position
795 of the text to this points depends on the type of
796 annotation, the dimstyle's text alignment flag, and the
797 view projection.
798 This point is not the same as the base point of the text.
799 Parameters:
800 text_point - [out];
801 Returns:
802 True if text_point is set.
803 */
804 bool GetTextPoint( ON_2dPoint& text_2d_point ) const;
805
806 // enum for tyoe of annotation DimLinear, DimRadius, etc.
807 ON::eAnnotationType m_type;
808
809 // m_textdisplaymode controls the orientation
810 // of the text.
811 // If m_textdisplaymode = dtHorizontal, then
812 // the text is always horizontal and in the
813 // view plane. Otherwise it lies in m_plane.
814 ON::eTextDisplayMode m_textdisplaymode;
815
816 // m_plane is the plane containing the annotation.
817 // All parts of the annotation that are not
818 // text lie in this plane. If
819 // m_textdisplaymode != dtHorizontal, then
820 // the text lies in the plane too.
821 // (ECS reference plane in WCS coordinates.)
823
824 // Definition points for the dimension.
825 // These are 2d coordinates in m_plane.
826 // The location of these points depends on the
827 // type of annotation class. There is a comment
828 // at the start of the definions for
829 // ON_LinearDimension2, ON_RadialDimension2,
830 // ON_AngularDimension2, ON_TextEntity2, and
831 // ON_Leader2 that explains how the points are used.
833
834 // With the addition of tolerances and therefore multi-line
835 // text, the ON_wString in m_usertext will hold multiple
836 // strings with NULLs between them.
837 // The strings will be in this order:
838 // Result of expanding "<>", or user override
839 // Alternate dimension
840 // Tolerance upper
841 // Tolerance lower
842 // Alt tolerance upper
843 // Alt tolerance lower
844 // Prefix
845 // Suffix
846 // Alt prefix
847 // Alt suffix
848 //
850
851 // true: User has positioned text
852 // false: use default location
854
855 // For dimensions, this is the ON_DimStyle index
856 // For text, its the ON_Font index
858
859 // Text height in model units
860 // This is used by text, but not by dimensions
861 // Dimensions get their height from dimension styles
863
864 // Left, Center, Right / Bottom, Middle, Top text justification
865 // See eTextJustification above
866 unsigned int m_justification;
867};
868
869
870// Subclass of ON_Annotation2 to provide linear dimensions
872{
874
875public:
876
877 /*
878 The annotation's dimstyle controls the position of TEXT,
879 the size of the arrowheads, and the amount the ends of
880 linear dimension's extension lines extend beyond the
881 dimension lines.
882
883 In the picture below, [n] means ON_Annotation2::m_points[n].
884
885 [2]
886 |
887 | |
888 [1]-------------------------------------------[3]
889 | |
890 | TEXT
891 | [4]
892 [0]
893
894 The "x" and "y" coordinates of [0] must be (0.0, 0.0).
895
896 The "x" coordinate of [1] = "x" of [0]
897 The "y" coordinate of [1] can be any value.
898
899 The "x" and "y" coordinates of [2] can be any value.
900
901 The "x" coordinate of [3] = "x" coordinate of [2].
902 The "y" coordinate of [3] = "y" coordinate of [1].
903 */
904
906 {
907 // Do not change these enum values. They are saved in files as the
908 // ON_COMPONENT_INDEX.m_index value.
909 //
910 // Indices of linear dimension definition points in
911 // the m_points[] array
912 ext0_pt_index = 0, // end of first extension line
913 arrow0_pt_index = 1, // arrowhead tip on first extension line
914 ext1_pt_index = 2, // end of second extension line
915 arrow1_pt_index = 3, // arrowhead tip on second extension line
916 userpositionedtext_pt_index = 4,
917 dim_pt_count = 5, // number of m_points[] in an angular dim
918
919 // Points calculated from values in m_points[]
920 text_pivot_pt = 10000, // center of dimension text
921 dim_mid_pt = 10001 // midpoint of dimension line
922 };
923
926 // C++ automatically provides the correct copy constructor and operator= .
927 //ON_LinearDimension2( const ON_LinearDimension2& );
928 //ON_LinearDimension2& operator=(const ON_LinearDimension2&);
929
930 // overrides virtual ON_Geometry::Transform()
931 ON_BOOL32 Transform( const ON_Xform& xform );
932
933 /*
934 Description:
935 Checks the linear dimension and repairs any point locations or flags
936 that are not set correctly.
937 Returns:
938 0: linear dimension is damaged beyond repair
939 1: linear dimension was perfect and nothing needed to be repaired.
940 2: linear dimension had flaws that were repaired.
941 */
942 int Repair();
943
944 /*
945 Description:
946 Get the m_plane coordinates of the dimension point.
947 Parameters:
948 point_index - [in] One of the POINT_INDEX enum values
949 Returns:
950 2d point or ON_UNSET_POINT if point_index or m_points[]
951 array is not valid.
952 */
953 ON_2dPoint Dim2dPoint(
954 int point_index
955 ) const;
956
957 /*
958 Description:
959 Get the m_plane coordinates of the dimension point.
960 Parameters:
961 point_index - [in] One of the POINT_INDEX enum values
962 Returns:
963 2d point or ON_UNSET_POINT if point_index or m_points[]
964 array is not valid.
965 */
966 ON_3dPoint Dim3dPoint(
967 int point_index
968 ) const;
969
970 // overrides virual ON_Object::IsValid
971 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
972
973 // overrides virual ON_Object::Write
974 ON_BOOL32 Write(ON_BinaryArchive&) const;
975
976 // overrides virual ON_Object::Read
978
979 // overrides virual ON_Geometry::GetBBox
980 ON_BOOL32 GetBBox(
981 double*,
982 double*,
983 ON_BOOL32 = false
984 ) const;
985
986 // overrides virual ON_Geometry::GetTightBoundingBox
987 bool GetTightBoundingBox(
988 ON_BoundingBox& tight_bbox,
989 int bGrowBox = false,
990 const ON_Xform* xform = 0
991 ) const;
992
993 /*
994 Description:
995 Overrides virtual ON_Annotation2::NumericValue();
996 Returns:
997 distance between arrow tips
998 */
999 double NumericValue() const;
1000
1001 /*
1002 Description:
1003 Get or set the DimStyle index in the dimstyle table for the dimension
1004 Parameters:
1005 [in] int the new index (Set)
1006 Returns:
1007 int - The current index (Get)
1008 */
1009 int StyleIndex() const;
1010 void SetStyleIndex( int);
1011
1012 /*
1013 Description:
1014 static function to provide the default UserText string for the object
1015 Returns:
1016 const wchar_t* - the default string to use
1017 */
1018 static const wchar_t* DefaultText();
1019
1020
1021// 6-23-03 lw Added v2 file writing of annotation
1022 void GetV2Form( ON_LinearDimension& dim);
1023
1024 bool CreateFromV2(
1025 const ON_Annotation& v2_ann,
1026 const ON_3dmAnnotationSettings& settings,
1027 int dimstyle_index
1028 );
1029
1030 /*
1031 Description:
1032 Get the annotation plane x coordinates of the dimension
1033 line. The y coordinate of the dimension line is m_ponts[1].y.
1034 Parameters:
1035 gdi_text_rect - [in]
1036 Windows rect (left < right, top < bottom) that bounds text.
1037 The baseline of the text should be at y=0 in the rect coordinates.
1038 gdi_height_of_I - [in]
1039 Height of an I in the text in the same.
1040 gdi_to_world - [in]
1041 transform returned by ON_Annotation2::GetTextXform().
1042 dimstyle - [in]
1043 dimscale - [in]
1044 vp - [in]
1045 x - [out] plane x coordinates of the dimension line.
1046 The y coordinate = m_points[arrow0_pt_index].y
1047 bInside - [out] true if arrowheads go inside extension lines,
1048 false if they go outside
1049 Returns:
1050 0: the input or class is not valid
1051 1: A single line from x[0] to x[1] with arrow heads at both ends.
1052 Arrowtips at x[4] & x[5]
1053 2: Two lines from x[0] to x[1] and from x[1] to x[2]. The
1054 Arrowtips at x[4] & x[5]
1055
1056 */
1057 int GetDimensionLineSegments(
1058 ON_RECT gdi_text_rect,
1059 int gdi_height_of_I,
1060 ON_Xform gdi_to_world,
1061 const ON_DimStyle& dimstyle,
1062 double dimscale,
1063 const ON_Viewport* vp,
1064 double a[6],
1065 bool& bInside
1066 ) const;
1067
1068
1069 // Added for V5. 4/24/07 LW
1070 // Get the userdata extension for this dimension
1073
1074
1075
1076
1077};
1078
1080// class ON_RadialDimension2
1082{
1084
1085public:
1086
1087 /*
1088 The annotation's dimstyle controls the position of TEXT,
1089 and the size of the arrowheads.
1090
1091 In the picture below, [n] means ON_Annotation2::m_points[n].
1092
1093 Radial dimensions do not permit user positioned text
1094
1095
1096 knee
1097 [3]--------[2] TEXT
1098 / (tail)
1099 /
1100 /
1101 [1] (arrow head here)
1102
1103
1104 + [0] = (usually at (0,0) = center of circle)
1105 */
1106
1108 {
1109 // Do not change these enum values. They are saved in files as the
1110 // ON_COMPONENT_INDEX.m_index value.
1111 //
1112 // Indices of radial dimension definition points in
1113 // the m_points[] array
1114 center_pt_index = 0, // location of + (usually at center of circle)
1115 arrow_pt_index = 1, // arrow tip
1116 tail_pt_index = 2, // end of radial dimension
1117 knee_pt_index = 3, // number of m_points[] in a radial dim
1118 dim_pt_count = 4, // number of m_points[] in a radial dim
1119
1120 // Points calculated from values in m_points[]
1121 text_pivot_pt = 10000, // start/end of dimension text at tail
1122 };
1123
1126 // C++ automatically provides the correct copy constructor and operator= .
1127 //ON_RadialDimension2(const ON_RadialDimension2&);
1128 //ON_RadialDimension2& operator=(const ON_RadialDimension2&);
1129
1130 // overrides virtual ON_Geometry::Transform()
1131 ON_BOOL32 Transform( const ON_Xform& xform );
1132
1133 /*
1134 Description:
1135 Get the m_plane coordinates of the dimension point.
1136 Parameters:
1137 point_index - [in] One of the POINT_INDEX enum values
1138 Returns:
1139 2d point or ON_UNSET_POINT if point_index or m_points[]
1140 array is not valid.
1141 */
1142 ON_2dPoint Dim2dPoint(
1143 int point_index
1144 ) const;
1145
1146 /*
1147 Description:
1148 Get the m_plane coordinates of the dimension point.
1149 Parameters:
1150 point_index - [in] One of the POINT_INDEX enum values
1151 Returns:
1152 2d point or ON_UNSET_POINT if point_index or m_points[]
1153 array is not valid.
1154 */
1155 ON_3dPoint Dim3dPoint(
1156 int point_index
1157 ) const;
1158
1159
1160 // overrides virual ON_Object::IsValid
1161 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
1162
1163 // overrides virual ON_Object::Write
1164 ON_BOOL32 Write(ON_BinaryArchive&) const;
1165
1166 // overrides virual ON_Object::Read
1168
1169 // overrides virual ON_Geometry::GetBBox
1170 ON_BOOL32 GetBBox(
1171 double*,
1172 double*,
1173 ON_BOOL32 = false
1174 ) const;
1175
1176 // overrides virual ON_Geometry::GetTightBoundingBox
1177 bool GetTightBoundingBox(
1178 ON_BoundingBox& tight_bbox,
1179 int bGrowBox = false,
1180 const ON_Xform* xform = 0
1181 ) const;
1182
1183 /*
1184 Description:
1185 Set the plane and definition points from WCS 3d input
1186 Parameters:
1187 center - [in] center of circle
1188 arrowtip - [in] 3d point on the circle at the dimension arrow tip
1189 xaxis - [in] x axis of the dimension's plane
1190 normal - [in] normal to the dimension's plane
1191 offset_distance - [in] distance from arrow tip to knee point
1192 Returns:
1193 @untitled table
1194 true Success
1195 false Failure
1196 */
1197 bool CreateFromPoints(
1198 ON_3dPoint center,
1199 ON_3dPoint arrowtip,
1200 ON_3dVector xaxis,
1201 ON_3dVector normal,
1202 double offset_distance
1203 );
1204
1205 /*
1206 Description:
1207 Overrides virtual ON_Annotation2::NumericValue();
1208 Returns:
1209 If m_type is ON::dtDimDiameter, then the diameter
1210 is returned, othewise the radius is returned.
1211 */
1212 double NumericValue() const;
1213
1214 /*
1215 Description:
1216 Get or set the DimStyle index in the dimstyle table for the dimension
1217 Parameters:
1218 [in] int the new index (Set)
1219 Returns:
1220 int - The current index (Get)
1221 */
1222 int StyleIndex() const;
1223 void SetStyleIndex( int);
1224
1225 /*
1226 Description:
1227 static function to provide the default UserText string for the object
1228 Returns:
1229 const wchar_t* - the default string to use
1230 */
1231 static const wchar_t* DefaultDiameterText();
1232 static const wchar_t* DefaultRadiusText();
1233
1234// 6-23-03 lw Added v2 file writing of annotation
1235 void GetV2Form( ON_RadialDimension& dim);
1236
1237 bool CreateFromV2(
1238 const ON_Annotation& v2_ann,
1239 const ON_3dmAnnotationSettings& settings,
1240 int dimstyle_index
1241 );
1242
1243 bool GetArrowHeadDirection( ON_2dVector& arrowhead_dir ) const;
1244 bool GetArrowHeadTip( ON_2dPoint& arrowhead_tip ) const;
1245};
1246
1247
1249// class ON_AngularDimension2
1251{
1253
1254public:
1255
1256 /*
1257 The annotation's dimstyle controls the position of TEXT,
1258 the size of the arrowheads, and the amount the ends of
1259 linear dimension's extension lines extend beyond the
1260 dimension lines.
1261
1262 In the picture below, [n] means ON_Annotation2::m_points[n].
1263
1264 [0] = if m_userpositionedtext=true, this is the center of text.
1265 If m_userpositionedtext=false, this point is not used and
1266 the center of the text is at the arc's midpoint.
1267
1268 Always counter clockwise arc in m_plane with center = (0,0)
1269 [1] = a point somewhere on the line from the center through the start point.
1270 The distance from center to [1] can be any value.
1271 [2] = a point somewhere on the line from the center through the end point.
1272 The distance from center to [2] can be any value.
1273 [3] = a point on the interior of the arc. The distance
1274 from (0,0) to [3] is the radius of the arc.
1275
1276
1277 /
1278 [2]
1279 /
1280 / [0]TEXT
1281 /
1282 / [3]
1283 -----(0,0)----------[1]---
1284 /
1285 /
1286 /
1287
1288 */
1289
1291 {
1292 // Do not change these enum values. They are saved in files as the
1293 // ON_COMPONENT_INDEX.m_index value.
1294 //
1295 // Indices of angular dimension definition points in
1296 // the m_points[] array
1297 userpositionedtext_pt_index = 0, //
1298 start_pt_index = 1, // point on the start ray (not necessarily on arc)
1299 end_pt_index = 2, // point on the end ray (not necessarily on arc)
1300 arc_pt_index = 3, // point on the interior of dimension arc
1301 dim_pt_count = 4, // number of m_points[] in an angular dim
1302
1303 // Points calculated from values in m_points[]
1304 text_pivot_pt = 10000, // center of dimension text
1305 arcstart_pt = 10001,
1306 arcend_pt = 10002,
1307 arcmid_pt = 10003,
1308 arccenter_pt = 10004, // center of circle arc lies on
1309 extension0_pt = 10005, // point where first extension line starts
1310 extension1_pt = 10006 // point where second extension line starts
1312
1315 // C++ copy constructor and operator= work fine.
1316 //ON_AngularDimension2(const ON_AngularDimension2&);
1317 //ON_AngularDimension2& operator=(const ON_AngularDimension2&);
1318
1319 // overrides virtual ON_Geometry::Transform()
1320 ON_BOOL32 Transform( const ON_Xform& xform );
1321
1322 /*
1323 Description:
1324 Get the m_plane coordinates of the dimension point.
1325 Parameters:
1326 point_index - [in] One of the POINT_INDEX enum values
1327 Returns:
1328 2d point or ON_UNSET_POINT if point_index or m_points[]
1329 array is not valid.
1330 */
1331 ON_2dPoint Dim2dPoint(
1332 int point_index
1333 ) const;
1334
1335 /*
1336 Description:
1337 Get the m_plane coordinates of the dimension point.
1338 Parameters:
1339 point_index - [in] One of the POINT_INDEX enum values
1340 Returns:
1341 2d point or ON_UNSET_POINT if point_index or m_points[]
1342 array is not valid.
1343 */
1344 ON_3dPoint Dim3dPoint(
1345 int point_index
1346 ) const;
1347
1348
1349 // overrides virual ON_Object::IsValid
1350 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
1351
1352 // overrides virual ON_Geometry::GetBBox
1353 ON_BOOL32 GetBBox(
1354 double*,
1355 double*,
1356 ON_BOOL32 = false
1357 ) const;
1358
1359 // overrides virual ON_Geometry::GetTightBoundingBox
1360 bool GetTightBoundingBox(
1361 ON_BoundingBox& tight_bbox,
1362 int bGrowBox = false,
1363 const ON_Xform* xform = 0
1364 ) const;
1365
1366 /*
1367 Description:
1368 Read from or write to a file
1369 Returns:
1370 @untitled Table
1371 true Success
1372 false Failure
1373 */
1374 ON_BOOL32 Write( ON_BinaryArchive& file ) const;
1375 ON_BOOL32 Read( ON_BinaryArchive& file );
1376
1377 /*
1378 Description:
1379 Set the plane and definition points from 3d points
1380 in world coordinates.
1381 Parameters:
1382 apex - [in] 3d apex of the dimension
1383 (center of arc)
1384 p0 - [in] 3d point on first line
1385 p1 - [in] 3d point on second line
1386 arcpt - [in] 3d point on dimension arc
1387 (determines radius of arc)
1388 Normal - [in] normal of the plane on which to make the dimension
1389 (must be perpendicular to p0-apex and p1-apex)
1390 Returns:
1391 @untitled table
1392 true Success
1393 false Failure
1394 */
1395 bool CreateFromPoints(
1396 const ON_3dPoint& apex,
1397 const ON_3dPoint& p0,
1398 const ON_3dPoint& p1,
1399 ON_3dPoint& arcpt,
1400 ON_3dVector& Normal
1401 );
1402
1403 /*
1404 Description:
1405 Set the plane and definition points from a 3d arc.
1406 Parameters:
1407 arc - [in]
1408 Returns:
1409 @untitled table
1410 true Success
1411 false Failure
1412 */
1413 bool CreateFromArc(
1414 const ON_Arc& arc
1415 );
1416
1417 bool CreateFromV2(
1418 const ON_Annotation& v2_ann,
1419 const ON_3dmAnnotationSettings& settings,
1420 int dimstyle_index
1421 );
1422
1423 bool GetArc( ON_Arc& arc ) const;
1424
1425 bool GetExtensionLines(ON_Line extensions[2]) const;
1426
1427 // Set or get the measured angle in radians
1428 void SetAngle( double angle);
1429 double Angle() const;
1430 void SetRadius( double radius);
1431 double Radius() const;
1432
1433 /*
1434 Description:
1435 Overrides virtual ON_Annotation2::NumericValue();
1436 Returns:
1437 Angle in degrees
1438 */
1439 double NumericValue() const;
1440
1441 /*
1442 Description:
1443 Get or set the DimStyle index in the dimstyle table for the dimension
1444 Parameters:
1445 [in] int the new index (Set)
1446 Returns:
1447 int - The current index (Get)
1448 */
1449 int StyleIndex() const;
1450 void SetStyleIndex( int);
1451
1452 /*
1453 Description:
1454 static function to provide the default UserText string for the object
1455 Returns:
1456 const wchar_t* - the default string to use
1457 */
1458 static const wchar_t* DefaultText();
1459
1460
1461 /*
1462 Description:
1463 Convert back to the version of ON_Annotation used in Rhino 2
1464 Parameters:
1465 target [out] the old-style object
1466 Returns:
1467 @untitled table
1468 true Success
1469 False Failure
1470 See Also: ON_AnnotationObject::ConvertBack()
1471 */
1472 void ConvertBack( ON_AngularDimension2& target);
1473
1474// 6-23-03 lw Added v2 file writing of annotation
1475 void GetV2Form( ON_AngularDimension& dim);
1476
1477 double m_angle; // angle being dimensioned
1478 double m_radius; // radius for dimension arc
1479
1480 /*
1481 Description:
1482 Get the annotation plane angles of the dimension arc.
1483 Parameters:
1484 gdi_text_rect - [in] Windows rect (left < right, top < bottom)
1485 that bounds text.
1486 gdi_height_of_I - [in]
1487 Height of an I in the text.
1488 gdi_to_world - [in]
1489 transform returned by ON_Annotation2::GetTextXform().
1490 dimstyle - [in]
1491 dimscale - [in]
1492 vp - [in]
1493 a - [out]
1494 angles at the ends of the arc segment(s) and the arrow tips
1495 bInside - [out] true if arrowheads go inside, false if they go outside
1496 Returns:
1497 number of arc segments to draw
1498 0: the input or class is not valid
1499 1: A single arc from a[0] to a[1] with arrow heads at a[4] & a[5].
1500 2: Two arcs from a[0] to a[1] & from a[2] to a[3].
1501 Arrowheads are at a[4] & a[5].
1502 */
1503 int GetDimensionArcSegments(
1504 ON_RECT gdi_text_rect,
1505 int gdi_height_of_I,
1506 ON_Xform gdi_to_world,
1507 const ON_DimStyle& dimstyle,
1508 double dimscale,
1509 const ON_Viewport* vp,
1510 double a[6],
1511 bool& bInside
1512 ) const;
1513
1514
1515 /*
1516 Description:
1517 Get distance from dimension apex to extension line offset points
1518 Parameters:
1519 index - [in] which distance to get
1520 Returns:
1521 Distance to offset point [index]
1522 */
1523 double DimpointOffset(
1524 int index) const;
1525
1526 /*
1527 Description:
1528 Set distance from dimension apex to extension line offset points
1529 Parameters:
1530 index - [in] which distance to set
1531 offset - [in] Value to set
1532 */
1533 void SetDimpointOffset(
1534 int index,
1535 double offset);
1536};
1537
1538
1539
1540/*
1541 class ON_LinearDimension2
1542
1543 Description:
1544 Override od ON_Annotation2 to provide linear dimensions
1545*/
1547{
1549
1550public:
1551
1552 /*
1553 In the picture below, [n] means ON_Annotation2::m_points[n].
1554
1555 Measures in X direction
1556
1557 [1]
1558 |
1559 |
1560 |
1561 |
1562 |
1563 [0]
1564 +
1565 [plane origin] [plane origin]
1566 +
1567
1568 or - Measures in Y direction *---[1]
1569 /
1570 /
1571 [0]--------------------[1] [0]---------------*
1572
1573
1574 * = calculated, not stored
1575
1576
1577 +
1578 [plane origin]
1579
1580
1581 The reference point of for the dimension is at the entity plane origin
1582 The "x" and "y" coordinates of [1] can be any value.
1583 The "x" and "y" coordinates of [2] can be any value.
1584 If Direction is "x", the dimension measures along the "x" axis
1585 If Direction is "y", the dimension measures along the "y" axis
1586 If Direction is "x" and [1][x] <> [0][x], an offset segment is drawn
1587 If Direction is "y" and [1][y] <> [0][y], an offset segment is drawn
1588 The dimension lines are always drawn in the X or Y directions of the entity plane
1589 The distance represented by the dimension is measured from the
1590 plane origin to point [0], parallel to the appropriate axis.
1591 The points of the offset segment are calculated rather than stored
1592 */
1593
1595 {
1596 // Do not change these enum values. They are saved in files as the
1597 // ON_COMPONENT_INDEX.m_index value.
1598 //
1599 // Indices of linear dimension definition points in
1600 // the m_points[] array
1601 definition_pt_index = 0, // First end of the dimension line
1602 leader_end_pt_index = 1, // Other end of the leader (near the text)
1603 dim_pt_count = 2, // Number of m_points[] in an ordinate dim
1604
1605 // Points calculated from values in m_points[]
1606 text_pivot_pt = 10000, // Center of dimension text
1607 offset_pt_0 = 10001, // First offset point (nearest text)
1608 offset_pt_1 = 10002 // Second offset point
1610
1612 {
1613 x = 0, // measures horizontally
1614 y = 1, // measures vertically
1615 };
1616
1619
1620 // overrides virtual ON_Geometry::Transform()
1621 ON_BOOL32 Transform( const ON_Xform& xform );
1622
1623 /*
1624 Description:
1625 Get the m_plane coordinates of the dimension point.
1626 Parameters:
1627 point_index - [in] One of the POINT_INDEX enum values
1628 default_offset [in] - kink offset to use if m_kink_offset_0
1629 or m_kink_offset_1 are ON_UNSET_VALUE
1630 Returns:
1631 2d point or ON_UNSET_POINT if point_index or m_points[]
1632 array is not valid.
1633 */
1634 ON_2dPoint Dim2dPoint(
1635 int point_index,
1636 double default_offset = 1.0
1637 ) const;
1638
1639 /*
1640 Description:
1641 Get the m_plane coordinates of the dimension point.
1642 Parameters:
1643 point_index - [in] One of the POINT_INDEX enum values
1644 default_offset [in] - kink offset to use if m_kink_offset_0
1645 or m_kink_offset_1 are ON_UNSET_VALUE
1646 Returns:
1647 2d point or ON_UNSET_POINT if point_index or m_points[]
1648 array is not valid.
1649 */
1650 ON_3dPoint Dim3dPoint(
1651 int point_index,
1652 double default_offset = 1.0
1653 ) const;
1654
1655 // overrides virual ON_Object::IsValid
1656 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
1657
1658 // overrides virual ON_Geometry::GetBBox
1659 ON_BOOL32 GetBBox(
1660 double* boxmin,
1661 double* boxmax,
1662 ON_BOOL32 bGrowBox = false
1663 ) const;
1664
1665 // overrides virual ON_Geometry::GetTightBoundingBox
1666 bool GetTightBoundingBox(
1667 ON_BoundingBox& tight_bbox,
1668 int bGrowBox = false,
1669 const ON_Xform* xform = 0
1670 ) const;
1671
1672 /*
1673 Description:
1674 Read from or write to a file
1675 Returns:
1676 @untitled Table
1677 true Success
1678 false Failure
1679 */
1680 ON_BOOL32 Write( ON_BinaryArchive& file ) const;
1681 ON_BOOL32 Read( ON_BinaryArchive& file );
1682
1683 /*
1684 Description:
1685 Overrides virtual ON_Annotation2::NumericValue();
1686 Returns:
1687 If Direction is 'X', x coordinate of point[1]
1688 If Direction is 'Y', y coordinate of point[1]
1689 */
1690 double NumericValue() const;
1691
1692 /*
1693 Description:
1694 Get or set the DimStyle index in the dimstyle table for the dimension
1695 Parameters:
1696 [in] int the new index (Set)
1697 Returns:
1698 int - The current index (Get)
1699 */
1700 int StyleIndex() const;
1701 void SetStyleIndex( int);
1702
1703 /*
1704 Description:
1705 Gets the direction ( X or Y) that the ordinate dimension measures
1706 based on the relative location of the defining point and leader endpoint
1707 Returns:
1708 0: measures parallel to the entity plane x axis
1709 1: measures parallel to the entity plane y axis
1710 Remarks:
1711 This does not consider the dimension's explicit Direction setting
1712 */
1713 int ImpliedDirection() const;
1714
1715 /*
1716 Description:
1717 Gets or sets the direction ( X or Y) that the ordinate dimension measures
1718 Returns:
1719 -1: direction determined by dim point and leader point
1720 0: measures parallel to the entity plane x axis
1721 1: measures parallel to the entity plane y axis
1722 */
1723 int Direction() const;
1724 void SetDirection( int direction);
1725
1726 /*
1727 Description:
1728 Get the height of the text in this dimension
1729 by asking the dimension's dimstyle
1730 Returns:
1731 double Height of the text
1732 Remarks:
1733 Height is in model units
1734 double Height() const;
1735 */
1736
1737 /*
1738 Description:
1739 static function to provide the default UserText string for the object
1740 Returns:
1741 const wchar_t* - the default string to use
1742 */
1743 static const wchar_t* DefaultText();
1744
1745 /*
1746 Description:
1747 Returns or sets the offset distance parallel to the dimension
1748 line direction of from the text end of the dimension line to
1749 the offset point
1750 If the offset point hasn't been explicitly defined, returns
1751 ON_UNSET_VALUE and a default should be used to find the point.
1752 Parameters:
1753 index [in] - which offset distance to return
1754 (0 is closer to the text)
1755 offset [in] - the offset distance to set
1756 */
1757 double KinkOffset( int index) const;
1758 void SetKinkOffset( int index, double offset);
1759
1760
1761 int m_direction; // -1 == underermined
1762 // 0 == x direction
1763 // 1 == y direction
1764
1765 // kink offsets added 2-4-06 - LW
1766 double m_kink_offset_0; // from leader_end_point to first break point
1767 double m_kink_offset_1; // from first break point to second break point
1768
1769 /*
1770 Description:
1771 Calculates the 2d point locations of the dimension line kinks
1772
1773 Parameters:
1774 p0, p1 [in] - End points of the dimension line
1775 direction [in] - orientation of the dimension
1776 default_offset [in] - Use this if offsets are ON_UNSET_VALUE
1777 k0, k1 [out] - The kink points
1778 Remarks:
1779 The offsets must be set to the right values before calling this, or
1780 If they are ON_UNSET_VALUE, they will be set to the defaults
1781 */
1782 void CalcKinkPoints( ON_2dPoint p0, ON_2dPoint p1,
1783 int direction, double default_offset,
1784 ON_2dPoint& k0, ON_2dPoint& k1) const;
1785
1786};
1787
1788
1789
1791// class ON_TextEntity2
1793{
1795
1796public:
1799
1800 // overrides virual ON_Object::IsValid
1801 // Text entities with strings that contain no "printable" characters
1802 // are considered to be NOT valid.
1803 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
1804
1805 // overrides virual ON_Object::Write
1806 ON_BOOL32 Write(ON_BinaryArchive&) const;
1807
1808 // overrides virual ON_Object::Read
1810
1811 // overrides virtual ON_Geometry::Transform()
1812 ON_BOOL32 Transform( const ON_Xform& xform );
1813
1814 // overrides virual ON_Geometry::GetBBox
1815 // This just adds the text base point to the box
1816 // There is no calculation of the size of the text or its bounds
1817 ON_BOOL32 GetBBox(
1818 double*,
1819 double*,
1820 ON_BOOL32 = false
1821 ) const;
1822
1823 // overrides virual ON_Geometry::GetTightBoundingBox
1824 // This just adds the text base point to the box
1825 // There is no calculation of the size of the text or its bounds
1826 bool GetTightBoundingBox(
1827 ON_BoundingBox& tight_bbox,
1828 int bGrowBox = false,
1829 const ON_Xform* xform = 0
1830 ) const;
1831
1832 /*
1833 Description:
1834 Get or set the Font index in the Font Table for the text
1835
1836 Parameters:
1837 [in] int the new index (Set)
1838
1839 Returns:
1840 int - The current index (Get)
1841 */
1842 int FontIndex() const;
1843 void SetFontIndex( int);
1844
1845// 6-23-03 lw Added v2 file writing of annotation
1846 void GetV2Form( ON_TextEntity& text);
1847
1848 void SetJustification( unsigned int justification);
1849
1850 unsigned int Justification();
1851
1852 // Determines whether or not to draw a Text Mask
1853 bool DrawTextMask() const;
1854 void SetDrawTextMask(bool bDraw);
1855
1856 // Determines where to get the color to draw a Text Mask
1857 // 0: Use background color of the viewport. Initially, gradient backgrounds will not be supported
1858 // 1: Use the ON_Color returned by MaskColor()
1859 int MaskColorSource() const;
1860 void SetMaskColorSource(int source);
1861
1862 ON_Color MaskColor() const; // Only works right if MaskColorSource returns 1.
1863 // Does not return viewport background color
1864 void SetMaskColor(ON_Color color);
1865
1866 // Offset for the border around text to the rectangle used to draw the mask
1867 // This number * CRhinoAnnotation::TextHeight() for the text is the offset
1868 // on each side of the tight rectangle around the text characters to the mask rectangle.
1869 double MaskOffsetFactor() const;
1870 void SetMaskOffsetFactor(double offset);
1871
1872};
1873
1875// class ON_Leader2
1877{
1879
1880public:
1881
1882 /*
1883 The annotation's dimstyle controls the position of TEXT,
1884 the size of the arrowheads, and the amount the ends of
1885 linear dimension's extension lines extend beyond the
1886 dimension lines.
1887
1888 Leaders:
1889
1890 Polyline with N=m_points.Count() points (N >= 2).
1891
1892 [N-2] ----- [N-1] TEXT
1893 / (tail)
1894 /
1895 /
1896 [1]------[2]
1897 /
1898 /
1899 /
1900 [0] (arrow)
1901
1902 Leaders ignore the m_userpositionedtext setting. If the
1903 default leader text handling is not adequate, then use
1904 a leader with no text and an ON_TextEntity2.
1905 */
1906
1908 {
1909 // Do not change these enum values. They are saved in files as the
1910 // ON_COMPONENT_INDEX.m_index value.
1911 //
1912 // Indices of angular dimension definition points in
1913 // the m_points[] array
1914 arrow_pt_index = 0, // arrow tip
1915
1916 // Points calculated from values in m_points[]
1917 text_pivot_pt = 10000, // start/end of dimension text at tail
1918 tail_pt = 10001
1920
1921 // Constructors
1922 ON_Leader2();
1923 ~ON_Leader2();
1924 // C++ automatically provides the correct copy constructor and operator= .
1925 //ON_Leader2(const ON_Leader2&);
1926 //ON_Leader2& operator=(const ON_Leader2&);
1927
1928 // overrides virtual ON_Geometry::Transform()
1929 ON_BOOL32 Transform( const ON_Xform& xform );
1930
1931 /*
1932 Description:
1933 Get the m_plane coordinates of the dimension point.
1934 Parameters:
1935 point_index - [in] One of the POINT_INDEX enum values
1936 Returns:
1937 2d point or ON_UNSET_POINT if point_index or m_points[]
1938 array is not valid.
1939 */
1940 ON_2dPoint Dim2dPoint(
1941 int point_index
1942 ) const;
1943
1944 /*
1945 Description:
1946 Get the m_plane coordinates of the dimension point.
1947 Parameters:
1948 point_index - [in] One of the POINT_INDEX enum values
1949 Returns:
1950 2d point or ON_UNSET_POINT if point_index or m_points[]
1951 array is not valid.
1952 */
1953 ON_3dPoint Dim3dPoint(
1954 int point_index
1955 ) const;
1956
1957 // overrides virual ON_Object::IsValid
1958 ON_BOOL32 IsValid( ON_TextLog* text_log = 0 ) const;
1959
1960 // overrides virual ON_Object::Write
1961 ON_BOOL32 Write(ON_BinaryArchive&) const;
1962
1963 // overrides virual ON_Object::Read
1965
1966 // overrides virual ON_Geometry::GetBBox
1967 ON_BOOL32 GetBBox(
1968 double*,
1969 double*,
1970 ON_BOOL32 = false
1971 ) const;
1972
1973 // overrides virual ON_Geometry::GetTightBoundingBox
1974 bool GetTightBoundingBox(
1975 ON_BoundingBox& tight_bbox,
1976 int bGrowBox = false,
1977 const ON_Xform* xform = 0
1978 ) const;
1979
1980 /*
1981 Description:
1982 Add or delete points to the leader
1983 Parameters:
1984 index [in] the point to delete
1985 point [in] The point to add
1986 Returns:
1987 @untitled table
1988 true Success
1989 False Failure
1990 */
1991 void AddPoint( const ON_2dPoint& point);
1992 bool RemovePoint( int index = -1);
1993
1994 /*
1995 Description:
1996 Converts an ON_Leader2 to the v2 form ON_Leader
1997 Parameters:
1998 leader [out] - the result of the conversion
1999 */
2000 void GetV2Form( ON_Leader& leader);
2001 bool CreateFromV2(
2002 const ON_Annotation& v2_ann,
2003 const ON_3dmAnnotationSettings& settings,
2004 int dimstyle_index
2005 );
2006
2007 bool GetArrowHeadDirection( ON_2dVector& arrowhead_dir ) const;
2008 bool GetArrowHeadTip( ON_2dPoint& arrowhead_tip ) const;
2009};
2010
2011
2012/*
2013 A simple dot with text that doesn't rotate witn the world axes
2014*/
2016{
2018
2019public:
2020 ON_TextDot();
2021 ~ON_TextDot();
2022 // C++ automatically provides the correct copy constructor and operator= .
2023 //ON_TextDot( const ON_TextDot& src);
2024 //ON_TextDot& operator=( const ON_TextDot& src);
2025
2026 void EmergencyDestroy();
2027
2028 //---------------------------
2029 // ON_Object overrides
2030
2031 /*
2032 Description:
2033 Tests an object to see if its data members are correctly
2034 initialized.
2035 Paramters:
2036 text_log - [in] if the object is not valid and text_log
2037 is not NULL, then a brief english description of the
2038 reason the object is not valid is appened to the log.
2039 The information appended to text_log is suitable for
2040 low-level debugging purposes by programmers and is
2041 not intended to be useful as a high level user
2042 interface tool.
2043 Returns:
2044 @untitled table
2045 true object is valid
2046 false object is invalid, uninitialized, etc.
2047 Remarks:
2048 Overrides virtual ON_Object::IsValid
2049 */
2050 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
2051
2052 /*
2053 Description: Write data values to a text file for debugging
2054 */
2055 void Dump( ON_TextLog& log) const;
2056
2057 /*
2058 Description: Writes the object to a file
2059
2060 Returns:
2061 @untitled Table
2062 true Success
2063 false Failure
2064 */
2065 ON_BOOL32 Write( ON_BinaryArchive& ar) const;
2066
2067 /*
2068 Description: Reads the object from a file
2069
2070 Returns:
2071 @untitled Table
2072 true Success
2073 false Failure
2074 */
2075 ON_BOOL32 Read( ON_BinaryArchive& ar);
2076
2077 /*
2078 Returns: The Object Type of this object
2079 */
2080 ON::object_type ObjectType() const;
2081
2082 //---------------------------
2083 // ON_Geometry overrides
2084
2085 /*
2086 Returns the geometric dimension of the object ( usually 3)
2087 */
2088 int Dimension() const;
2089
2090 /*
2091 Description:
2092 Get a bounding 3d WCS box of the object
2093 Parameters:
2094 [in/out] double* boxmin - pointer to dim doubles for min box corner
2095 [in/out] double* boxmax - pointer to dim doubles for max box corner
2096 [in] ON_BOOL32 growbox - true to grow the existing box,
2097 false ( the default) to reset the box
2098 Returns:
2099 true = Success
2100 false = Failure
2101 Remarks:
2102 Since the bounding box of this entity changes size at different
2103 zoom levels, the bounding box is a point at the definition point
2104 */
2105 ON_BOOL32 GetBBox( double* box_min, double* box_max, ON_BOOL32 grow_box = false) const;
2106
2107 /*
2108 Description:
2109 Transform the object by a 4x4 xform matrix
2110 Parameters:
2111 [in] xform - An ON_Xform with the transformation information
2112 Returns:
2113 true = Success
2114 false = Failure
2115 Remarks:
2116 The object has been transformed when the function returns
2117 */
2118 ON_BOOL32 Transform( const ON_Xform& xform);
2119
2120 // virtual ON_Geometry::IsDeformable() override
2121 bool IsDeformable() const;
2122
2123 // virtual ON_Geometry::MakeDeformable() override
2124 bool MakeDeformable();
2125
2126 const ON_3dPoint& Point() const;
2127 void SetPoint( const ON_3dPoint& point);
2128
2129 int Height() const;
2130 void SetHeight( int);
2131
2132 const wchar_t* TextString() const;
2133 void SetTextString( const wchar_t* string);
2134
2135 const wchar_t* FontFace() const;
2136 void SetFontFace( const wchar_t* face);
2137
2138
2139 /*
2140 Description:
2141 Get or Set whether the dot is drawn "On Top" of other geometry
2142 Parameters:
2143 [in] bTop bool - It is or isn't on top
2144 Returns:
2145 @untitled table
2146 true - on top
2147 false - not on top
2148 */
2149 void SetAlwaysOnTop(bool bTop);
2150 bool AlwaysOnTop() const;
2151
2152 /*
2153 Description:
2154 Get or Set whether the dot is drawn with a transparent background
2155 Parameters:
2156 [in] bTransparent bool - It is or isn't transparent
2157 Returns:
2158 @untitled table
2159 true - transparent
2160 false - not transparent
2161 */
2162 void SetTransparent(bool bTransparent);
2163 bool Transparent() const;
2164
2165 /*
2166 Description:
2167 Get or Set whether the dot is drawn with Bold text
2168 Parameters:
2169 [in] bBold bool - It is or isn't Bold
2170 Returns:
2171 @untitled table
2172 true - Bold
2173 false - not Bold
2174 */
2175 void SetBold(bool bBold);
2176 bool Bold() const;
2177
2178 /*
2179 Description:
2180 Get or Set whether the dot is drawn with Italic text
2181 Parameters:
2182 [in] bItalic bool - It is or isn't Italic
2183 Returns:
2184 @untitled table
2185 true - Italic
2186 false - not Italic
2187 */
2188 void SetItalic(bool bItalic);
2189 bool Italic() const;
2190
2191
2193 int m_height; // in points
2196 int m_display; // some future display flags -
2197};
2198
2199
2200
2201#endif
2202
2203
@ Point
Definition RSMetaType.h:50
@ Transform
Definition RSMetaType.h:67
Base class for all dimensioning tools.
Definition Dimension.js:18
Definition Index.h:34
Definition opennurbs_array.h:353
Definition opennurbs_point.h:253
Definition opennurbs_point.h:655
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_3dm_settings.h:77
Definition opennurbs_annotation2.h:1251
double m_angle
Definition opennurbs_annotation2.h:1477
double m_radius
Definition opennurbs_annotation2.h:1478
POINT_INDEX
Definition opennurbs_annotation2.h:1291
ON_OBJECT_DECLARE(ON_AngularDimension2)
Definition opennurbs_annotation.h:326
Definition opennurbs_annotation2.h:242
SYMBOLS
Definition opennurbs_annotation2.h:247
unsigned int m_justification
Definition opennurbs_annotation2.h:866
ON_Annotation2Text m_usertext
Definition opennurbs_annotation2.h:849
ON_OBJECT_DECLARE(ON_Annotation2)
eTextJustification
Definition opennurbs_annotation2.h:334
ON::eTextDisplayMode m_textdisplaymode
Definition opennurbs_annotation2.h:814
int m_index
Definition opennurbs_annotation2.h:857
ON_2dPointArray m_points
Definition opennurbs_annotation2.h:832
ON::eAnnotationType m_type
Definition opennurbs_annotation2.h:807
bool m_userpositionedtext
Definition opennurbs_annotation2.h:853
ON_Plane m_plane
Definition opennurbs_annotation2.h:822
double m_textheight
Definition opennurbs_annotation2.h:862
Definition opennurbs_annotation2.h:37
ON_BOOL32 GetDescription(ON_wString &description)
ON_RECT m_rect
Definition opennurbs_annotation2.h:79
void Dump(ON_TextLog &text_log) const
ON_BOOL32 Archive() const
ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
unsigned int SizeOf() const
ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_annotation.h:154
Definition opennurbs_arc.h:34
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_color.h:24
Definition opennurbs_dimstyle.h:20
Definition opennurbs_annotation2.h:148
ON_RECT * m_text_rects
Definition opennurbs_annotation2.h:229
static const ON_DimensionExtra * DimensionExtension(const class ON_LinearDimension2 *pDim, bool bCreate)
int m_arrow_position
Definition opennurbs_annotation2.h:216
ON_OBJECT_DECLARE(ON_DimensionExtra)
ON_UUID m_partent_uuid
Definition opennurbs_annotation2.h:214
Definition opennurbs_font.h:20
Definition opennurbs_geometry.h:36
Definition opennurbs_annotation2.h:1877
ON_OBJECT_DECLARE(ON_Leader2)
POINT_INDEX
Definition opennurbs_annotation2.h:1908
Definition opennurbs_annotation.h:386
Definition opennurbs_line.h:20
Definition opennurbs_annotation2.h:872
ON_OBJECT_DECLARE(ON_LinearDimension2)
const ON_DimensionExtra * DimensionExtension() const
ON_DimensionExtra * DimensionExtension()
POINT_INDEX
Definition opennurbs_annotation2.h:906
Definition opennurbs_annotation.h:293
Definition opennurbs_objref.h:167
Definition opennurbs_annotation2.h:1547
DIRECTION
Definition opennurbs_annotation2.h:1612
double m_kink_offset_1
Definition opennurbs_annotation2.h:1767
int m_direction
Definition opennurbs_annotation2.h:1761
POINT_INDEX
Definition opennurbs_annotation2.h:1595
ON_OBJECT_DECLARE(ON_OrdinateDimension2)
double m_kink_offset_0
Definition opennurbs_annotation2.h:1766
Definition opennurbs_plane.h:20
Definition opennurbs_annotation2.h:1082
POINT_INDEX
Definition opennurbs_annotation2.h:1108
ON_OBJECT_DECLARE(ON_RadialDimension2)
Definition opennurbs_annotation.h:309
Definition opennurbs_annotation2.h:2016
ON_OBJECT_DECLARE(ON_TextDot)
ON_wString m_fontface
Definition opennurbs_annotation2.h:2195
int m_height
Definition opennurbs_annotation2.h:2193
ON_3dPoint m_point
Definition opennurbs_annotation2.h:2192
int m_display
Definition opennurbs_annotation2.h:2196
ON_wString m_text
Definition opennurbs_annotation2.h:2194
Definition opennurbs_annotation2.h:1793
ON_OBJECT_DECLARE(ON_TextEntity2)
Definition opennurbs_annotation.h:357
Definition opennurbs_annotation2.h:84
ON_Color m_mask_color
Definition opennurbs_annotation2.h:139
ON_UUID m_partent_uuid
Definition opennurbs_annotation2.h:132
bool m_bDrawMask
Definition opennurbs_annotation2.h:134
int m_color_source
Definition opennurbs_annotation2.h:136
ON_OBJECT_DECLARE(ON_TextExtra)
static const ON_TextExtra * TextExtension(const class ON_TextEntity2 *pDim, bool bCreate)
double m_border_offset
Definition opennurbs_annotation2.h:141
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_userdata.h:20
Definition opennurbs_viewport.h:31
Definition opennurbs_xform.h:28
Definition opennurbs_string.h:392
const ON_wString & operator=(const ON_wString &)
Definition opennurbs_wstring.cpp:553
unsigned int SizeOf() const
Definition opennurbs_wstring.cpp:783
void Create()
Definition opennurbs_wstring.cpp:138
void Destroy()
Definition opennurbs_wstring.cpp:167
void EmergencyDestroy()
Definition opennurbs_wstring.cpp:205
struct tagON_RECT ON_RECT
#define ON_CLASS
Definition opennurbs_defines.h:91
char s
Definition opennurbs_string.cpp:32
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
Definition opennurbs_annotation2.h:26
int left
Definition opennurbs_annotation2.h:27
int top
Definition opennurbs_annotation2.h:28
int right
Definition opennurbs_annotation2.h:29
int bottom
Definition opennurbs_annotation2.h:30