opennurbs_internal_V2_annotation.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_INTERNAL_V2_ANNOTATION_H_INC)
18 #define OPENNURBS_INTERNAL_V2_ANNOTATION_H_INC
19 
20 #if defined(ON_COMPILING_OPENNURBS)
21 
22 #include "opennurbs_internal_defines.h"
23 
24 // Annotation classes used in version 2 .3dm archives and Rhino version 2.
25 // All classes in this file are obsolete. They exist so that old files can be read.
26 
27 // Legacy annotation arrow is in some old .3dm files.
28 // Gets converted to an ON_Line with ON_3dmObjectAttributes arrow head
29 // ON_3dmObjectAttributes.m_object_decoration = (ON::end_arrowhead | other bits)
30 class ON_OBSOLETE_V2_AnnotationArrow : public ON_Geometry
31 {
32  // 3d annotation arrow
33  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_AnnotationArrow);
34 public:
35  ON_OBSOLETE_V2_AnnotationArrow();
36  ~ON_OBSOLETE_V2_AnnotationArrow();
37  ON_OBSOLETE_V2_AnnotationArrow(const ON_OBSOLETE_V2_AnnotationArrow&);
38  ON_OBSOLETE_V2_AnnotationArrow& operator=(const ON_OBSOLETE_V2_AnnotationArrow&);
39 
40  /////////////////////////////////////////////////////////////////
41  //
42  // ON_Object overrides
43  //
44  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
45 
46  void Dump( ON_TextLog& ) const override; // for debugging
47 
48  bool Write(
49  ON_BinaryArchive& // serialize definition to binary archive
50  ) const override;
51 
52  bool Read(
53  ON_BinaryArchive& // restore definition from binary archive
54  ) override;
55 
56  ON::object_type ObjectType() const override;
57 
58  /////////////////////////////////////////////////////////////////
59  //
60  // ON_Geometry overrides
61  //
62 
63  int Dimension() const override;
64 
65  // virtual ON_Geometry GetBBox override
66  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
67 
68  bool Transform(
69  const ON_Xform&
70  ) override;
71 
72  /////////////////////////////////////////////////////////////////
73  //
74  // Interface
75  //
76  ON_3dVector Vector() const;
77  ON_3dPoint Head() const;
78  ON_3dPoint Tail() const;
79 
80  ON_3dPoint m_tail;
81  ON_3dPoint m_head;
82 };
83 
84 class ON_OBSOLETE_V2_TextDot : public ON_Point
85 {
86  // 3d annotation dot with text
87  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_TextDot);
88 public:
89  ON_OBSOLETE_V2_TextDot();
90  ~ON_OBSOLETE_V2_TextDot();
91  ON_OBSOLETE_V2_TextDot(const ON_OBSOLETE_V2_TextDot&);
92  ON_OBSOLETE_V2_TextDot& operator=(const ON_OBSOLETE_V2_TextDot&);
93 
94  /////////////////////////////////////////////////////////////////
95  //
96  // ON_Object overrides
97  //
98 
99  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
100  void Dump( ON_TextLog& ) const override; // for debugging
101 
102  bool Write(
103  ON_BinaryArchive& // serialize definition to binary archive
104  ) const override;
105 
106  bool Read(
107  ON_BinaryArchive& // restore definition from binary archive
108  ) override;
109 
110  ON_wString m_text;
111 };
112 
113 
114 ////////////////////////////////////////////////////////////////
115 //
116 // ON_OBSOLETE_V2_Annotation - used to serialize definitions of annotation
117 // objects (dimensions, text blocks, etc.).
118 //
119 
120 class ON_OBSOLETE_V2_Annotation : public ON_Geometry
121 {
122  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_Annotation);
123 
124 protected:
125  ON_OBSOLETE_V2_Annotation() = default;
126  ON_OBSOLETE_V2_Annotation(const ON_OBSOLETE_V2_Annotation&) = default;
127  ON_OBSOLETE_V2_Annotation& operator=(const ON_OBSOLETE_V2_Annotation&) = default;
128 
129 public:
130  virtual ~ON_OBSOLETE_V2_Annotation() = default;
131 
132 protected:
133  void Internal_Initialize(); // initialize class's fields assuming
134  // memory is uninitialized
135 
136 public:
137  static ON_OBSOLETE_V2_Annotation* CreateFromV5Annotation(
138  const class ON_OBSOLETE_V5_Annotation& V5_annotation,
139  const class ON_3dmAnnotationContext* annotation_context
140  );
141 
142  static ON_OBSOLETE_V2_Annotation* CreateFromV6Annotation(
143  const class ON_Annotation& V6_annotation,
144  const class ON_3dmAnnotationContext* annotation_context
145  );
146 
147 protected:
148  void Internal_InitializeFromV5Annotation(
149  const ON_OBSOLETE_V5_Annotation& V5_annotation,
150  const class ON_3dmAnnotationContext* annotation_context
151  );
152 
153 public:
154  void Destroy();
155  void EmergencyDestroy();
156 
157  /////////////////////////////////////////////////////////////////
158  //
159  // ON_Object overrides
160  //
161  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
162 
163  void Dump( ON_TextLog& ) const override; // for debugging
164 
165  bool Write(
166  ON_BinaryArchive& // serialize definition to binary archive
167  ) const override;
168 
169  bool Read(
170  ON_BinaryArchive& // restore definition from binary archive
171  ) override;
172 
173  ON::object_type ObjectType() const override;
174 
175  /////////////////////////////////////////////////////////////////
176  //
177  // ON_Geometry overrides
178  //
179 
180  int Dimension() const override;
181 
182  // virtual ON_Geometry GetBBox override
183  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
184 
185  bool Transform(
186  const ON_Xform&
187  ) override;
188 
189  /////////////////////////////////////////////////////////////////
190  //
191  // ON_OBSOLETE_V2_Annotation interface
192  //
193 
194  // use these to get/set the current annotation settings
195  static const ON_3dmAnnotationSettings& AnnotationSettings();
196  static void SetAnnotationSettings( const ON_3dmAnnotationSettings* );
197 
198  bool IsText() const;
199  bool IsLeader() const;
200  bool IsDimension() const;
201 
202  virtual double NumericValue() const;
203  virtual void SetTextToDefault();
204 
205  void SetType( ON_INTERNAL_OBSOLETE::V5_eAnnotationType type );
206  ON_INTERNAL_OBSOLETE::V5_eAnnotationType Type() const;
207  void SetTextDisplayMode( ON_INTERNAL_OBSOLETE::V5_TextDisplayMode mode);
208  ON_INTERNAL_OBSOLETE::V5_TextDisplayMode TextDisplayMode() const;
209 
210  void SetPlane( const ON_Plane& plane );
211  ON_Plane Plane() const;
212  int PointCount() const;
213  void SetPoints( const ON_SimpleArray<ON_2dPoint>& points );
214  const ON_SimpleArray<ON_2dPoint>& Points() const;
215  void SetPoint( int idx, ON_3dPoint point );
216  ON_2dPoint Point( int idx ) const;
217  void SetUserText( const wchar_t* string );
218  const ON_wString& UserText() const;
219  void SetDefaultText( const wchar_t* string );
220  const ON_wString& DefaultText() const;
221  void SetUserPositionedText( int bUserPositionedText );
222  bool UserPositionedText() const;
223 
224  // to convert world 3d points to and from annotation 2d points
225  bool GetECStoWCSXform( ON_Xform& xform ) const;
226  bool GeWCStoECSXform( ON_Xform& xform ) const;
227 
228  ON_INTERNAL_OBSOLETE::V5_eAnnotationType m_type = ON_INTERNAL_OBSOLETE::V5_eAnnotationType::dtNothing; // enum for type of annotation
229  // DimLinear, DimRadius, etc.
230 
231  ON_INTERNAL_OBSOLETE::V5_TextDisplayMode m_textdisplaymode = ON_INTERNAL_OBSOLETE::V5_TextDisplayMode::kNormal; // how the text is displayed
232  // Horizontal, InLine, AboveLine
233 
234  ON_Plane m_plane = ON_Plane::World_xy; // ECS reference plane in WCS coordinates
235  ON_SimpleArray<ON_2dPoint> m_points; // Definition points for the dimension
236 
237  ON_wString m_usertext; // "<>", or user override
238  ON_wString m_defaulttext; // The displayed text string
239 
240  bool m_userpositionedtext = false; // true: User has positioned text
241  // false: use default location
242 };
243 
244 class ON_OBSOLETE_V2_DimLinear : public ON_OBSOLETE_V2_Annotation
245 {
246  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_DimLinear);
247 
248 public:
249  ON_OBSOLETE_V2_DimLinear();
250  ON_OBSOLETE_V2_DimLinear(const ON_OBSOLETE_V2_DimLinear&);
251  ~ON_OBSOLETE_V2_DimLinear();
252  ON_OBSOLETE_V2_DimLinear& operator=(const ON_OBSOLETE_V2_DimLinear&);
253 
254  double NumericValue() const override;
255  void SetTextToDefault() override;
256  void EmergencyDestroy();
257 
258  static ON_OBSOLETE_V2_DimLinear* CreateFromV5LinearDimension(
259  const class ON_OBSOLETE_V5_DimLinear& V5_linear_dimension,
260  const class ON_3dmAnnotationContext* annotation_context,
261  ON_OBSOLETE_V2_DimLinear* destination
262  );
263 };
264 
265 class ON_OBSOLETE_V2_DimRadial : public ON_OBSOLETE_V2_Annotation
266 {
267  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_DimRadial);
268 
269 public:
270  ON_OBSOLETE_V2_DimRadial();
271  ON_OBSOLETE_V2_DimRadial(const ON_OBSOLETE_V2_DimRadial&);
272  ~ON_OBSOLETE_V2_DimRadial();
273  ON_OBSOLETE_V2_DimRadial& operator=(const ON_OBSOLETE_V2_DimRadial&);
274 
275  double NumericValue() const override;
276  void SetTextToDefault() override;
277 
278  void EmergencyDestroy();
279 
280  static ON_OBSOLETE_V2_DimRadial* CreateFromV5RadialDimension(
281  const class ON_OBSOLETE_V5_DimRadial& V5_linear_dimension,
282  const class ON_3dmAnnotationContext* annotation_context,
283  ON_OBSOLETE_V2_DimRadial* destination
284  );
285 };
286 
287 class ON_OBSOLETE_V2_DimAngular : public ON_OBSOLETE_V2_Annotation
288 {
289  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_DimAngular);
290 
291 public:
292  ON_OBSOLETE_V2_DimAngular();
293  ON_OBSOLETE_V2_DimAngular(const ON_OBSOLETE_V2_DimAngular&);
294  ~ON_OBSOLETE_V2_DimAngular();
295  ON_OBSOLETE_V2_DimAngular& operator=(const ON_OBSOLETE_V2_DimAngular&);
296 
297  static ON_OBSOLETE_V2_DimAngular* CreateFromV5AngularDimension(
298  const class ON_OBSOLETE_V5_DimAngular& V5_angular_dimension,
299  const class ON_3dmAnnotationContext* annotation_context,
300  ON_OBSOLETE_V2_DimAngular* destination
301  );
302 
303  void EmergencyDestroy();
304 
305  bool Write( ON_BinaryArchive& file ) const override;
306  bool Read( ON_BinaryArchive& file ) override;
307 
308  void SetAngle( double angle ) { m_angle = angle; }
309  double Angle() const { return m_angle; }
310  void SetRadius( double radius ) { m_radius = radius; }
311  double Radius() const { return m_radius; }
312 
313  double NumericValue() const override;
314  void SetTextToDefault() override;
315 
316 private:
317  double m_angle; // angle being dimensioned
318  double m_radius; // radius for dimension arc
319 };
320 
321 class ON_OBSOLETE_V2_TextObject : public ON_OBSOLETE_V2_Annotation
322 {
323  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_TextObject);
324 
325 public:
326  ON_OBSOLETE_V2_TextObject();
327  ON_OBSOLETE_V2_TextObject(const ON_OBSOLETE_V2_TextObject&);
328  ~ON_OBSOLETE_V2_TextObject();
329  ON_OBSOLETE_V2_TextObject& operator=(const ON_OBSOLETE_V2_TextObject&);
330 
331  static ON_OBSOLETE_V2_TextObject* CreateFromV5TextObject(
332  const class ON_OBSOLETE_V5_TextObject& V5_text_object,
333  const class ON_3dmAnnotationContext* annotation_context,
334  ON_OBSOLETE_V2_TextObject* destination
335  );
336 
337  void EmergencyDestroy();
338 
339  bool Write( ON_BinaryArchive& file ) const override;
340  bool Read( ON_BinaryArchive& file ) override;
341 
342  void SetFaceName( ON_wString string ) { m_facename = string; }
343  ON_wString FaceName() const { return m_facename; }
344  void SetFontWeight( int weight ) { m_fontweight = weight; }
345  int FontWeight() const { return m_fontweight; }
346  void SetHeight( double height ) { m_height = height; }
347  double Height() const { return m_height; }
348 
349 
350 private:
351  ON_wString m_facename;
352  int m_fontweight; // windows - 400 = NORMAL )
353  double m_height; // gets multiplied by dimscale
354 };
355 
356 class ON_OBSOLETE_V2_Leader : public ON_OBSOLETE_V2_Annotation
357 {
358  ON_OBJECT_DECLARE(ON_OBSOLETE_V2_Leader);
359 
360 public:
361  ON_OBSOLETE_V2_Leader();
362  ON_OBSOLETE_V2_Leader(const ON_OBSOLETE_V2_Leader&);
363  ~ON_OBSOLETE_V2_Leader();
364  ON_OBSOLETE_V2_Leader& operator=(const ON_OBSOLETE_V2_Leader&);
365 
366  static ON_OBSOLETE_V2_Leader* CreateFromV5Leader(
367  const class ON_OBSOLETE_V5_Leader& V5_leader,
368  const class ON_3dmAnnotationContext* annotation_context,
369  ON_OBSOLETE_V2_Leader* destination
370  );
371 
372  void EmergencyDestroy();
373 };
374 
375 #endif
376 #endif
377 
Definition: opennurbs_annotationbase.h:23
virtual bool Transform(const ON_Xform &xform)
Transforms the object.
virtual int Dimension() const
Dimension of the object.
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
Definition: opennurbs_string.h:2020
virtual ON::object_type ObjectType() const
Useful for switch statements that need to differentiate between basic object types like points...
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_point.h:277
Definition: opennurbs_3dm_settings.h:110
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_xform.h:28
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
ON_Geometry & operator=(const ON_Geometry &)=default
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
Definition: opennurbs_point.h:460
Definition: opennurbs_pointgeometry.h:24
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:1152