Point Cloud Library (PCL)  1.14.1-dev
opennurbs_dimstyle.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_DIMSTYLE_INC_)
18 #define OPENNURBS_DIMSTYLE_INC_
19 
20 class ON_CLASS ON_DimStyle : public ON_Object
21 {
22  ON_OBJECT_DECLARE(ON_DimStyle);
23 
24 public:
26  {
27  solidtriangle = 0, // 2:1
28  dot = 1,
29  tick = 2,
30  shorttriangle = 3, // 1:1
31  arrow = 4,
32  rectangle = 5,
33  longtriangle = 6, // 4:1
34  longertriangle = 7, // 6:1
35  };
36 
39  // C++ default copy construction and operator= work fine.-
40 
42 
43  //////////////////////////////////////////////////////////////////////
44  //
45  // ON_Object overrides
46 
47  /*
48  Description:
49  Tests an object to see if its data members are correctly
50  initialized.
51  Parameters:
52  text_log - [in] if the object is not valid and text_log
53  is not NULL, then a brief englis description of the
54  reason the object is not valid is appened to the log.
55  The information appended to text_log is suitable for
56  low-level debugging purposes by programmers and is
57  not intended to be useful as a high level user
58  interface tool.
59  Returns:
60  @untitled table
61  true object is valid
62  false object is invalid, uninitialized, etc.
63  Remarks:
64  Overrides virtual ON_Object::IsValid
65  */
66  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
67 
68  // virtual
69  void Dump( ON_TextLog& ) const; // for debugging
70 
71  // virtual
72  ON_BOOL32 Write(
73  ON_BinaryArchive& // serialize definition to binary archive
74  ) const;
75 
76  // virtual
77  ON_BOOL32 Read(
78  ON_BinaryArchive& // restore definition from binary archive
79  );
80 
82 
83  // virtual
85 
86 
87  //////////////////////////////////////////////////////////////////////
88  //
89  // Interface
90 
91  void SetName( const wchar_t* );
92  void SetName( const char* );
93 
94  void GetName( ON_wString& ) const;
95  const wchar_t* Name() const;
96 
97  void SetIndex(int);
98  int Index() const;
99 
100  void SetDefaults();
102 
103 
104  double ExtExtension() const;
105  void SetExtExtension( const double);
106 
107  double ExtOffset() const;
108  void SetExtOffset( const double);
109 
110  double ArrowSize() const;
111  void SetArrowSize( const double);
112 
113  double LeaderArrowSize() const;
114  void SetLeaderArrowSize( const double);
115 
116  double CenterMark() const;
117  void SetCenterMark( const double);
118 
119  int TextAlignment() const;
120  void SetTextAlignment( ON::eTextDisplayMode);
121 
122  int ArrowType() const;
124 
125  int LeaderArrowType() const;
127 
128  int AngularUnits() const;
129  void SetAngularUnits( int);
130 
131  int LengthFormat() const;
132  void SetLengthFormat( int);
133 
134  int AngleFormat() const;
135  void SetAngleFormat( int);
136 
137  int LengthResolution() const;
139 
140  int AngleResolution() const;
141  void SetAngleResolution( int);
142 
143  int FontIndex() const;
144  virtual void SetFontIndex( int index);
145 
146  double TextGap() const;
147  void SetTextGap( double gap);
148 
149  double TextHeight() const;
150  void SetTextHeight( double height);
151 
152  // added at ver 1.3
153  double LengthFactor() const;
154  ON_DEPRECATED void SetLengthactor( double);
155  void SetLengthFactor( double); // added 6/24/07 because of typo
156 
157  bool Alternate() const;
158  void SetAlternate( bool);
159 
160  double AlternateLengthFactor() const;
161  ON_DEPRECATED void SetAlternateLengthactor( double);
162  void SetAlternateLengthFactor( double); // added 6/24/07 because of typo
163 
166 
169 
170  int AlternateAngleFormat() const;
172 
175 
176  void GetPrefix( ON_wString& ) const;
177  const wchar_t* Prefix() const;
178  void SetPrefix( const wchar_t*);
179  void SetPrefix( wchar_t*);
180 
181  void GetSuffix( ON_wString& ) const;
182  const wchar_t* Suffix() const;
183  void SetSuffix( const wchar_t*);
184  void SetSuffix( wchar_t*);
185 
187  const wchar_t* AlternatePrefix() const;
188  void SetAlternatePrefix( const wchar_t*);
189  void SetAlternatePrefix( wchar_t*);
190 
192  const wchar_t* AlternateSuffix() const;
193  void SetAlternateSuffix( const wchar_t*);
194  void SetAlternateSuffix( wchar_t*);
195 
196  bool SuppressExtension1() const;
198 
199  bool SuppressExtension2() const;
201 
202  // obsolete
203  ON_DEPRECATED void Composite( const ON_DimStyle& override);
204 
205  // Don't change these enum values
206  // They are used in file reading & writing
207  enum eField
208  {
209  fn_name = 0,
210  fn_index = 1,
211  fn_extextension = 2,
212  fn_extoffset = 3,
213  fn_arrowsize = 4,
214  fn_centermark = 5,
215  fn_textgap = 6,
216  fn_textheight = 7,
217  fn_textalign = 8,
218  fn_arrowtype = 9,
219  fn_angularunits = 10,
220  fn_lengthformat = 11,
221  fn_angleformat = 12,
222  fn_angleresolution = 13,
223  fn_lengthresolution = 14,
224  fn_fontindex = 15,
225  fn_lengthfactor = 16,
226  fn_bAlternate = 17,
227  fn_alternate_lengthfactor = 18,
228  fn_alternate_lengthformat = 19,
229  fn_alternate_lengthresolution = 20,
230  fn_alternate_angleformat = 21,
231  fn_alternate_angleresolution = 22,
232  fn_prefix = 23,
233  fn_suffix = 24,
234  fn_alternate_prefix = 25,
235  fn_alternate_suffix = 26,
236  fn_dimextension = 27,
237  fn_leaderarrowsize = 28,
238  fn_leaderarrowtype = 29,
239  fn_suppressextension1 = 30,
240  fn_suppressextension2 = 31,
241  fn_last = 32, // not used - left here for sdk
242 
243  // Added for v5 - 5/01/07 LW
244  // version 1.6
245  fn_overall_scale = 33,
246  fn_ext_line_color_source = 34,
247  fn_dim_line_color_source = 35,
248  fn_arrow_color_source = 36,
249  fn_text_color_source = 37,
250  fn_ext_line_color = 38,
251  fn_dim_line_color = 39,
252  fn_arrow_color = 40,
253  fn_text_color = 41,
254  fn_ext_line_plot_color_source = 42,
255  fn_dim_line_plot_color_source = 43,
256  fn_arrow_plot_color_source = 44,
257  fn_text_plot_color_source = 45,
258  fn_ext_line_plot_color = 46,
259  fn_dim_line_plot_color = 47,
260  fn_arrow_plot_color = 48,
261  fn_text_plot_color = 49,
262  fn_ext_line_plot_weight_source = 50,
263  fn_dim_line_plot_weight_source = 51,
264  fn_ext_line_plot_weight_mm = 52,
265  fn_dim_line_plot_weight_mm = 53,
266  fn_tolerance_style = 54,
267  fn_tolerance_resolution = 55,
268  fn_tolerance_upper_value = 56,
269  fn_tolerance_lower_value = 57,
270  fn_tolerance_height_scale = 58,
271  fn_baseline_spacing = 59,
272 
273  // Added for v5 - 12/15/09 LW
274  // version 1.7
275  fn_draw_mask = 60,
276  fn_mask_color_source = 61,
277  fn_mask_color = 62,
278  fn_mask_border = 63,
279 
280  // Added for v5 - 12/17/09 LW
281  // version 1.8
282  fn_dimscale = 64,
283  fn_dimscale_source = 65,
284 
285  //When fields are added to ON_DimStyleExtra,
286  // enum { eFieldCount = 64 }; in opennurbs_dimstyle.cpp
287  // needs to be changed.
288  fn_really_last = 0xFFFF
289  };
290 
291  // These are obsolete - don't use
292  // 5/01/07 - LW
293  ON_DEPRECATED void InvalidateField( eField field);
294  ON_DEPRECATED void InvalidateAllFields();
295  ON_DEPRECATED void ValidateField( eField field);
296  ON_DEPRECATED bool IsFieldValid( eField) const;
297 
298  // added version 1.3
299  double DimExtension() const;
300  void SetDimExtension( const double);
301 
302  // This section Added for v5 - 4-24-07 LW
303  // version 1.6
304 
305  // Test if a specific field has been set in this dimstyle
306  // and not inherited from its parent.
307  bool IsFieldOverride( eField field_id) const;
308  // Set a field to be overridden or not
309  // Fields that aren't overrides inherit from their parent dimstyle
310  void SetFieldOverride( ON_DimStyle::eField field_id, bool bOverride);
311 
312  // Test if the dimstyle has any field override flags set
313  bool HasOverrides() const;
314 
315  // Change the fields in this dimstyle to match the fields of the
316  // source dimstyle for all of the fields that are marked overridden in the source
317  // and to match the parent for all of the fields not marked overriden.
318  // Returns true if any overrides were set.
319  bool OverrideFields( const ON_DimStyle& source, const ON_DimStyle& parent);
320 
321  //
322  // Change the fields in this dimstyle to match the fields of the
323  // parent dimstyle for all of the fields that are not marked overridden in the
324  // target dimstyle.
325  // This is the complement of OverrideFields()
326  bool InheritFields( const ON_DimStyle& parent);
327 
328  // Test if this dimstyle is the child of any other dimstyle
329  bool IsChildDimstyle() const;
330 
331  // Test if this dimstyle is the child of a given dimstyle
332  // A dimstyle may have several child dimstyles, but only one parent
333  bool IsChildOf( const ON_UUID& parent_uuid) const;
334  bool IsChildOf( ON_UUID& parent_uuid) const; // decl error - const forgotten
335 
336  ON_UUID ParentId() const;
337 
338  // Set the parent of this dimstyle
339  void SetParentId( ON_UUID parent_uuid);
340  ON_DEPRECATED void SetParent( ON_UUID& parent_uuid); // use set parent id
341 
342  // Tolerances
343  // Tolerance style
344  // 0: None
345  // 1: Symmetrical
346  // 2: Deviation
347  // 3: Limits
348  // 4: Basic
349  int ToleranceStyle() const;
350  int ToleranceResolution() const;
351  double ToleranceUpperValue() const;
352  double ToleranceLowerValue() const;
353  double ToleranceHeightScale() const;
354 
355  double BaselineSpacing() const;
356 
357  void SetToleranceStyle( int style);
358  void SetToleranceResolution( int resolution);
359  void SetToleranceUpperValue( double upper_value);
360  void SetToleranceLowerValue( double lower_value);
361  void SetToleranceHeightScale( double scale);
362 
363  void SetBaselineSpacing( double spacing = false);
364 
365  // Determines whether or not to draw a Text Mask
366  bool DrawTextMask() const;
367  void SetDrawTextMask(bool bDraw);
368 
369  // Determines where to get the color to draw a Text Mask
370  // 0: Use background color of the viewport. Initially, gradient backgrounds will not be supported
371  // 1: Use the ON_Color returned by MaskColor()
372  int MaskColorSource() const;
373  void SetMaskColorSource(int source);
374 
375  ON_Color MaskColor() const; // Only works right if MaskColorSource returns 1.
376  // Does not return viewport background color
377  void SetMaskColor(ON_Color color);
378 
379  // Per DimStyle DimScale
380  void SetDimScaleSource(int source);
381  int DimScaleSource() const; // 0: Global DimScale, 1: DimStyle DimScale
382  void SetDimScale(double scale);
383  double DimScale() const;
384 
385  // Offset for the border around text to the rectangle used to draw the mask
386  // This number * CRhinoAnnotation::TextHeight() for the text is the offset
387  // on each side of the tight rectangle around the text characters to the mask rectangle.
388  double MaskOffsetFactor() const;
389 
390  void Scale( double scale);
391 
392  // UUID of the dimstyle this was originally copied from
393  // so Restore Defaults has some place to look
394  void SetSourceDimstyle(ON_UUID source_uuid);
396 
397  // Defaults for values stored in Userdata extension
398  static int DefaultToleranceStyle();
400  static double DefaultToleranceUpperValue();
401  static double DefaultToleranceLowerValue();
403  static double DefaultBaselineSpacing();
404  static bool DefaultDrawTextMask(); // false
405  static int DefaultMaskColorSource(); // 0;
406  static ON_Color DefaultMaskColor(); // .SetRGB(255,255,255);
407  static double DefaultDimScale(); // 1.0;
408  static int DefaultDimScaleSource(); // 0;
409 
410  bool CompareFields(const ON_DimStyle& other) const;
411 
412 public:
413  ON_wString m_dimstyle_name; // String name of the style
414  int m_dimstyle_index; // Index in the dimstyle table
416 
417  double m_extextension; // extension line extension
418  double m_extoffset; // extension line offset
419  double m_arrowsize; // length of an arrow - may mean different things to different arrows
420  double m_centermark; // size of the + at circle centers
421  double m_textgap; // gap around the text for clipping dim line
422  double m_textheight; // model unit height of dimension text before applying dimscale
423  int m_textalign; // text alignment relative to the dimension line
424  int m_arrowtype; // 0: filled narrow triangular arrow
425  int m_angularunits; // 0: degrees, 1: radians
426  int m_lengthformat; // 0: decimal, 1: feet, 2: feet & inches
427  int m_angleformat; // 0: decimal degrees, ...
428  int m_angleresolution; // for decimal degrees, digits past decimal
429  int m_lengthresolution; // depends on m_lengthformat
430  // for decimal, digits past the decimal point
431  int m_fontindex; // index of the ON_Font used by this dimstyle
432 
433  // added fields version 1.2, Jan 13, 05
434  double m_lengthfactor; // (dimlfac) model units multiplier for length display
435  bool m_bAlternate; // (dimalt) display alternate dimension string (or not)
436  // using m_alternate_xxx values
437  double m_alternate_lengthfactor; // (dimaltf) model units multiplier for alternate length display
438  int m_alternate_lengthformat; // 0: decimal, 1: feet, 2: feet & inches
439  int m_alternate_lengthresolution; // depends on m_lengthformat
440  // for decimal, digits past the decimal point
441  int m_alternate_angleformat; // 0: decimal degrees, ...
442  int m_alternate_angleresolution; // for decimal degrees, digits past decimal
443  ON_wString m_prefix; // string preceding dimension value string
444  ON_wString m_suffix; // string following dimension value string
445  ON_wString m_alternate_prefix; // string preceding alternate value string
446  ON_wString m_alternate_suffix; // string following alternate value string
447 
448 private:
449  unsigned int m_valid; // Obsolete deprecated field to be removed - Do not use
450 public:
451 
452  // field added version 1.4, Dec 28, 05
453  double m_dimextension; // (dimdle) dimension line extension past the "tip" location
454 
455  // fields added version 1.5 Mar 23 06
456  double m_leaderarrowsize; // Like dimension arrow size but applies to leaders
457  int m_leaderarrowtype; // Like dimension arrow type but applies to leaders
458  bool m_bSuppressExtension1; // flag to not draw extension lines
459  bool m_bSuppressExtension2; // flag to not draw extension lines
460 
461 
462  // Added March 23, 2008 -LW
463  // This function is temporary and will be removed next time the SDK can be modified.
464  class ON_DimStyleExtra* DimStyleExtension(); // can return null
465  const class ON_DimStyleExtra* DimStyleExtension() const; // can return null
466 };
467 
468 #endif
469 
void SetMaskColorSource(int source)
bool HasOverrides() const
bool OverrideFields(const ON_DimStyle &source, const ON_DimStyle &parent)
void SetSuffix(wchar_t *)
void SetAlternateSuffix(const wchar_t *)
void SetDrawTextMask(bool bDraw)
void SetPrefix(wchar_t *)
void SetDimScale(double scale)
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
int ToleranceStyle() const
ON_BOOL32 Write(ON_BinaryArchive &) const
bool InheritFields(const ON_DimStyle &parent)
double BaselineSpacing() const
ON_DimStyle & operator=(const ON_3dmAnnotationSettings &src)
ON_UUID ModelObjectId() const
ON_wString m_dimstyle_name
int Index() const
ON_DEPRECATED void InvalidateAllFields()
static double DefaultToleranceUpperValue()
void SetName(const wchar_t *)
static double DefaultToleranceLowerValue()
static bool DefaultDrawTextMask()
double m_alternate_lengthfactor
double m_leaderarrowsize
double LeaderArrowSize() const
int ArrowType() const
void EmergencyDestroy()
void SetArrowType(eArrowType)
double DimScale() const
int AlternateLengthFormat() const
void SetLeaderArrowType(eArrowType)
int LengthResolution() const
void SetLengthFormat(int)
void SetSourceDimstyle(ON_UUID source_uuid)
void SetTextAlignment(ON::eTextDisplayMode)
double ExtOffset() const
void SetAlternate(bool)
int LeaderArrowType() const
double ArrowSize() const
void SetSuppressExtension2(bool)
int TextAlignment() const
int MaskColorSource() const
ON_wString m_alternate_suffix
const class ON_DimStyleExtra * DimStyleExtension() const
void SetLeaderArrowSize(const double)
void SetDefaults()
int AlternateLengthResolution() const
void SetAngleResolution(int)
double ToleranceLowerValue() const
void GetName(ON_wString &) const
static ON_Color DefaultMaskColor()
static int DefaultToleranceStyle()
void GetPrefix(ON_wString &) const
double CenterMark() const
double TextGap() const
void GetSuffix(ON_wString &) const
void SetDimExtension(const double)
double TextHeight() const
void SetAlternatePrefix(const wchar_t *)
void SetDimScaleSource(int source)
ON_DEPRECATED void ValidateField(eField field)
ON_wString m_prefix
int AlternateAngleFormat() const
int ToleranceResolution() const
bool IsFieldOverride(eField field_id) const
bool SuppressExtension1() const
void SetTextGap(double gap)
ON_wString m_suffix
int AlternateAngleResolution() const
int m_alternate_lengthresolution
static double DefaultDimScale()
void SetToleranceHeightScale(double scale)
void SetAlternateLengthResolution(int)
ON_UUID SourceDimstyle() const
void SetAlternateSuffix(wchar_t *)
double ToleranceHeightScale() const
bool IsChildDimstyle() const
void SetAlternateAngleFormat(int)
bool Alternate() const
static int DefaultToleranceResolution()
double LengthFactor() const
int AngleFormat() const
virtual void SetFontIndex(int index)
void SetToleranceLowerValue(double lower_value)
int DimScaleSource() const
void SetLengthResolution(int)
ON_DEPRECATED void Composite(const ON_DimStyle &override)
void SetAlternateLengthFactor(double)
bool SuppressExtension2() const
class ON_DimStyleExtra * DimStyleExtension()
int AngularUnits() const
void SetArrowSize(const double)
void SetTextHeight(double height)
ON_BOOL32 Read(ON_BinaryArchive &)
double DimExtension() const
const wchar_t * Suffix() const
ON_DEPRECATED void SetLengthactor(double)
void SetToleranceResolution(int resolution)
void SetAngleFormat(int)
int AngleResolution() const
void SetToleranceStyle(int style)
ON_DEPRECATED void SetParent(ON_UUID &parent_uuid)
ON_UUID ParentId() const
ON_DEPRECATED void InvalidateField(eField field)
void SetAngularUnits(int)
void SetAlternatePrefix(wchar_t *)
ON_DEPRECATED bool IsFieldValid(eField) const
static int DefaultDimScaleSource()
void Scale(double scale)
const wchar_t * AlternatePrefix() const
const wchar_t * Name() const
int LengthFormat() const
void SetFieldOverride(ON_DimStyle::eField field_id, bool bOverride)
void SetMaskColor(ON_Color color)
void SetParentId(ON_UUID parent_uuid)
void SetSuppressExtension1(bool)
void SetToleranceUpperValue(double upper_value)
void SetCenterMark(const double)
void SetName(const char *)
const wchar_t * AlternateSuffix() const
int m_alternate_angleresolution
static double DefaultToleranceHeightScale()
void SetIndex(int)
static int DefaultMaskColorSource()
void SetExtOffset(const double)
bool CompareFields(const ON_DimStyle &other) const
static double DefaultBaselineSpacing()
ON_wString m_alternate_prefix
bool DrawTextMask() const
void SetPrefix(const wchar_t *)
void SetBaselineSpacing(double spacing=false)
void SetAlternateAngleResolution(int)
ON_Color MaskColor() const
bool IsChildOf(const ON_UUID &parent_uuid) const
double ExtExtension() const
void Dump(ON_TextLog &) const
void SetAlternateLengthFormat(int)
double MaskOffsetFactor() const
void GetAlternateSuffix(ON_wString &) const
void SetExtExtension(const double)
double ToleranceUpperValue() const
double AlternateLengthFactor() const
void SetLengthFactor(double)
void GetAlternatePrefix(ON_wString &) const
void SetSuffix(const wchar_t *)
void SetDefaultsNoExtension()
ON_DEPRECATED void SetAlternateLengthactor(double)
bool IsChildOf(ON_UUID &parent_uuid) const
const wchar_t * Prefix() const
int FontIndex() const