Point Cloud Library (PCL)  1.9.1-dev
opennurbs_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_ANNOTATION_INC_)
18 #define OPENNURBS_ANNOTATION_INC_
19 
20 
21 class ON_CLASS ON_AnnotationTextDot : public ON_Point
22 {
23  // 3d annotation dot with text
24  ON_OBJECT_DECLARE(ON_AnnotationTextDot);
25 public:
30 
31  /////////////////////////////////////////////////////////////////
32  //
33  // ON_Object overrides
34  //
35 
36  /*
37  Description:
38  Tests an object to see if its data members are correctly
39  initialized.
40  Parameters:
41  text_log - [in] if the object is not valid and text_log
42  is not NULL, then a brief englis description of the
43  reason the object is not valid is appened to the log.
44  The information appended to text_log is suitable for
45  low-level debugging purposes by programmers and is
46  not intended to be useful as a high level user
47  interface tool.
48  Returns:
49  @untitled table
50  true object is valid
51  false object is invalid, uninitialized, etc.
52  Remarks:
53  Overrides virtual ON_Object::IsValid
54  */
55  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
56 
57  void Dump( ON_TextLog& ) const; // for debugging
58 
59  ON_BOOL32 Write(
60  ON_BinaryArchive& // serialize definition to binary archive
61  ) const;
62 
63  ON_BOOL32 Read(
64  ON_BinaryArchive& // restore definition from binary archive
65  );
66 
68 };
69 
70 class ON_CLASS ON_AnnotationArrow : public ON_Geometry
71 {
72  // 3d annotation arrow
73  ON_OBJECT_DECLARE(ON_AnnotationArrow);
74 public:
79 
80  /////////////////////////////////////////////////////////////////
81  //
82  // ON_Object overrides
83  //
84 
85  /*
86  Description:
87  Tests an object to see if its data members are correctly
88  initialized.
89  Parameters:
90  text_log - [in] if the object is not valid and text_log
91  is not NULL, then a brief englis description of the
92  reason the object is not valid is appened to the log.
93  The information appended to text_log is suitable for
94  low-level debugging purposes by programmers and is
95  not intended to be useful as a high level user
96  interface tool.
97  Returns:
98  @untitled table
99  true object is valid
100  false object is invalid, uninitialized, etc.
101  Remarks:
102  Overrides virtual ON_Object::IsValid
103  */
104  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
105 
106  void Dump( ON_TextLog& ) const; // for debugging
107 
108  ON_BOOL32 Write(
109  ON_BinaryArchive& // serialize definition to binary archive
110  ) const;
111 
112  ON_BOOL32 Read(
113  ON_BinaryArchive& // restore definition from binary archive
114  );
115 
116  ON::object_type ObjectType() const;
117 
118  /////////////////////////////////////////////////////////////////
119  //
120  // ON_Geometry overrides
121  //
122 
123  int Dimension() const;
124 
125  // work horse bounding box getter
126  ON_BOOL32 GetBBox( // returns true if successful
127  double*, // boxmin[dim]
128  double*, // boxmax[dim]
129  ON_BOOL32 = false // true means grow box
130  ) const;
131 
132  ON_BOOL32 Transform(
133  const ON_Xform&
134  );
135 
136  /////////////////////////////////////////////////////////////////
137  //
138  // Interface
139  //
140  ON_3dVector Vector() const;
141  ON_3dPoint Head() const;
142  ON_3dPoint Tail() const;
143 
146 };
147 
148 ////////////////////////////////////////////////////////////////
149 //
150 // ON_Annotation - used to serialize definitions of annotation
151 // objects (dimensions, text blocks, etc.).
152 //
153 
154 class ON_CLASS ON_Annotation : public ON_Geometry
155 {
156  ON_OBJECT_DECLARE(ON_Annotation);
157 
158  enum SYMBOLS
159  {
160  degreesym = 176,
161  radiussym = 'R',
162  diametersym = 216,
163  plusminussym = 177,
164  };
165 
166 
167 
168 public:
169 
170  virtual ON_BOOL32 IsRealObject() const = 0;
171 
172  ON_Annotation();
174  ~ON_Annotation();
176 
177  void Create(); // initialize class's fields assuming
178  // memory is uninitialized
179  void Destroy();
180  void EmergencyDestroy();
181 
182  /////////////////////////////////////////////////////////////////
183  //
184  // ON_Object overrides
185  //
186 
187  /*
188  Description:
189  Tests an object to see if its data members are correctly
190  initialized.
191  Parameters:
192  text_log - [in] if the object is not valid and text_log
193  is not NULL, then a brief englis description of the
194  reason the object is not valid is appened to the log.
195  The information appended to text_log is suitable for
196  low-level debugging purposes by programmers and is
197  not intended to be useful as a high level user
198  interface tool.
199  Returns:
200  @untitled table
201  true object is valid
202  false object is invalid, uninitialized, etc.
203  Remarks:
204  Overrides virtual ON_Object::IsValid
205  */
206  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
207 
208  void Dump( ON_TextLog& ) const; // for debugging
209 
210  ON_BOOL32 Write(
211  ON_BinaryArchive& // serialize definition to binary archive
212  ) const;
213 
214  ON_BOOL32 Read(
215  ON_BinaryArchive& // restore definition from binary archive
216  );
217 
218  ON::object_type ObjectType() const;
219 
220  /////////////////////////////////////////////////////////////////
221  //
222  // ON_Geometry overrides
223  //
224 
225  int Dimension() const;
226 
227  ON_BOOL32 GetBBox( // returns true if successful
228  double*, // boxmin[dim]
229  double*, // boxmax[dim]
230  ON_BOOL32 = false // true means grow box
231  ) const;
232 
233  ON_BOOL32 Transform(
234  const ON_Xform&
235  );
236 
237  /////////////////////////////////////////////////////////////////
238  //
239  // ON_Annotation interface
240  //
241 
242  // use these to get/set the current annotation settings
243  static const ON_3dmAnnotationSettings& AnnotationSettings();
244  static void SetAnnotationSettings( const ON_3dmAnnotationSettings* );
245 
246  bool IsText() const;
247  bool IsLeader() const;
248  bool IsDimension() const;
249 
250  virtual double NumericValue() const;
251  virtual void SetTextToDefault();
252 
253  void SetType( ON::eAnnotationType type );
254  ON::eAnnotationType Type() const;
255  void SetTextDisplayMode( ON::eTextDisplayMode mode);
256  ON::eTextDisplayMode TextDisplayMode() const;
257 
258  void SetPlane( const ON_Plane& plane );
259  ON_Plane Plane() const;
260  int PointCount() const;
261  void SetPoints( const ON_SimpleArray<ON_2dPoint>& points );
262  const ON_SimpleArray<ON_2dPoint>& Points() const;
263  void SetPoint( int idx, ON_3dPoint point );
264  ON_2dPoint Point( int idx ) const;
265  void SetUserText( const wchar_t* string );
266  const ON_wString& UserText() const;
267  void SetDefaultText( const wchar_t* string );
268  const ON_wString& DefaultText() const;
269  void SetUserPositionedText( int bUserPositionedText );
270  bool UserPositionedText() const;
271 
272  // to convert world 3d points to and from annotation 2d points
273  bool GetECStoWCSXform( ON_Xform& xform ) const;
274  bool GeWCStoECSXform( ON_Xform& xform ) const;
275 
276  ON::eAnnotationType m_type; // enum for type of annotation
277  // DimLinear, DimRadius, etc.
278 
279  ON::eTextDisplayMode m_textdisplaymode; // how the text is displayed
280  // Horizontal, InLine, AboveLine
281 
282  ON_Plane m_plane; // ECS reference plane in WCS coordinates
283  ON_SimpleArray<ON_2dPoint> m_points; // Definition points for the dimension
284 
285  ON_wString m_usertext; // "<>", or user override
286  ON_wString m_defaulttext; // The displayed text string
287 
288  bool m_userpositionedtext; // true: User has positioned text
289  // false: use default location
290 };
291 
292 
293 class ON_CLASS ON_LinearDimension : public ON_Annotation
294 {
295  ON_OBJECT_DECLARE(ON_LinearDimension);
296 
297 public:
298  ON_BOOL32 IsRealObject() const;
303 
304  double NumericValue();
305  void SetTextToDefault();
306  void EmergencyDestroy();
307 };
308 
309 class ON_CLASS ON_RadialDimension : public ON_Annotation
310 {
311  ON_OBJECT_DECLARE(ON_RadialDimension);
312 
313 public:
314  ON_BOOL32 IsRealObject() const;
319 
320  double NumericValue();
321  void SetTextToDefault();
322 
323  void EmergencyDestroy();
324 };
325 
326 class ON_CLASS ON_AngularDimension : public ON_Annotation
327 {
328  ON_OBJECT_DECLARE(ON_AngularDimension);
329 
330 public:
331  ON_BOOL32 IsRealObject() const;
332 
337 
338  void EmergencyDestroy();
339 
340  ON_BOOL32 Write( ON_BinaryArchive& file ) const;
341  ON_BOOL32 Read( ON_BinaryArchive& file );
342 
343  void SetAngle( double angle ) { m_angle = angle; }
344  double Angle() const { return m_angle; }
345  void SetRadius( double radius ) { m_radius = radius; }
346  double Radius() const { return m_radius; }
347 
348  double NumericValue();
349  void SetTextToDefault();
350 
351 
352 private:
353  double m_angle; // angle being dimensioned
354  double m_radius; // radius for dimension arc
355 };
356 
357 class ON_CLASS ON_TextEntity : public ON_Annotation
358 {
359  ON_OBJECT_DECLARE(ON_TextEntity);
360 
361 public:
362  ON_BOOL32 IsRealObject() const;
363  ON_TextEntity();
365  ~ON_TextEntity();
367 
368  void EmergencyDestroy();
369 
370  ON_BOOL32 Write( ON_BinaryArchive& file ) const;
371  ON_BOOL32 Read( ON_BinaryArchive& file );
372 
373  void SetFaceName( ON_wString string ) { m_facename = string; }
374  ON_wString FaceName() const { return m_facename; }
375  void SetFontWeight( int weight ) { m_fontweight = weight; }
376  int FontWeight() const { return m_fontweight; }
377  void SetHeight( double height ) { m_height = height; }
378  double Height() const { return m_height; }
379 
380 private:
381  ON_wString m_facename;
382  int m_fontweight; // windows - 400 = NORMAL )
383  double m_height; // gets multiplied by dimscale
384 };
385 
386 class ON_CLASS ON_Leader : public ON_Annotation
387 {
388  ON_OBJECT_DECLARE(ON_Leader);
389 
390 public:
391  ON_BOOL32 IsRealObject() const;
392  ON_Leader();
393  ON_Leader(const ON_Leader&);
394  ~ON_Leader();
395  ON_Leader& operator=(const ON_Leader&);
396 
397  void EmergencyDestroy();
398 };
399 
400 
401 
402 
403 #endif
404 
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
void EmergencyDestroy()
void SetFaceName(ON_wString string)
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
ON_wString FaceName() const
void SetHeight(double height)
virtual double NumericValue() const
void SetFontWeight(int weight)
virtual ON_BOOL32 Transform(const ON_Xform &xform)
int FontWeight() const
ON_Point & operator=(const ON_Point &)
ON_BOOL32 Write(ON_BinaryArchive &) const
ON_Annotation & operator=(const ON_Annotation &)
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
virtual ON::object_type ObjectType() const
virtual void SetTextToDefault()
virtual int Dimension() const =0
ON_wString m_defaulttext
ON_BOOL32 Read(ON_BinaryArchive &)
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
ON_Geometry & operator=(const ON_Geometry &)
virtual ON_BOOL32 IsRealObject() const =0
ON_BOOL32 Write(ON_BinaryArchive &) const
ON_BOOL32 Read(ON_BinaryArchive &)
void SetRadius(double radius)
virtual void Dump(ON_TextLog &) const
ON_SimpleArray< ON_2dPoint > m_points
void EmergencyDestroy()
ON::eAnnotationType m_type
void SetAngle(double angle)
void Dump(ON_TextLog &) const
ON::eTextDisplayMode m_textdisplaymode
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
double Height() const