Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 class ON_DimStyleExtra : public ON_UserData
00061 {
00062 ON_OBJECT_DECLARE(ON_DimStyleExtra);
00063 public:
00067
00068
00069
00070
00071
00072 static ON_DimStyleExtra* DimStyleExtensionGet( ON_DimStyle* pDimStyle, bool bCreateIfNoneExists );
00073
00074
00075
00076
00077
00078
00079 static const ON_DimStyleExtra* DimStyleExtensionGet( const ON_DimStyle* pDimStyle);
00080
00081 ON_DimStyleExtra();
00082 ~ON_DimStyleExtra();
00083
00084 void SetDefaults();
00085
00086
00087
00088
00089
00090 bool IsDefault() const;
00091
00092
00093 void Dump( ON_TextLog& text_log ) const;
00094
00095
00096 unsigned int SizeOf() const;
00097
00098
00099 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const;
00100
00101
00102 ON_BOOL32 Read(ON_BinaryArchive& binary_archive);
00103
00104
00105 ON_BOOL32 GetDescription( ON_wString& description );
00106
00107
00108 ON_BOOL32 Archive() const;
00109
00110 void SetFieldOverride( int field_id, bool bOverride);
00111 bool IsFieldOverride( int field_id) const;
00112
00113
00114
00115 void Scale( double scale);
00116
00117
00118
00119
00120
00121
00122
00123
00124 void SetToleranceStyle( int style);
00125 int ToleranceStyle() const;
00126
00127 void SetToleranceResolution( int resolution);
00128 int ToleranceResolution() const;
00129
00130 void SetToleranceUpperValue( double upper_value);
00131 double ToleranceUpperValue() const;
00132
00133 void SetToleranceLowerValue( double lower_value);
00134 double ToleranceLowerValue() const;
00135
00136 void SetToleranceHeightScale( double scale);
00137 double ToleranceHeightScale() const;
00138
00139 void SetBaselineSpacing( double);
00140 double BaselineSpacing() const;
00141
00142
00143 bool DrawTextMask() const;
00144 void SetDrawTextMask(bool bDraw);
00145
00146
00147
00148
00149 int MaskColorSource() const;
00150 void SetMaskColorSource(int source);
00151
00152 ON_Color MaskColor() const;
00153
00154 void SetMaskColor(ON_Color color);
00155
00156 void SetDimScale(double scale);
00157 double DimScale() const;
00158 void SetDimScaleSource(int source);
00159 int DimScaleSource() const;
00160
00161 void SetSourceDimstyle(ON_UUID source_uuid);
00162 ON_UUID SourceDimstyle() const;
00163
00164 bool CompareFields(const ON_DimStyleExtra* pOther) const;
00165
00166
00167
00168 ON_UUID m_parent_dimstyle;
00169 ON_SimpleArray<bool> m_valid_fields;
00170 enum { eFieldCount = 66 };
00171
00172 int m_tolerance_style;
00173 int m_tolerance_resolution;
00174 double m_tolerance_upper_value;
00175 double m_tolerance_lower_value;
00176 double m_tolerance_height_scale;
00177
00178 double m_baseline_spacing;
00179
00180
00181 bool m_bDrawMask;
00182 int m_mask_color_source;
00183 ON_Color m_mask_color;
00184
00185
00186 double m_dimscale;
00187 int m_dimscale_source;
00188
00189
00190 ON_UUID m_source_dimstyle;
00191 };
00192
00193
00194
00195
00196
00197
00198 ON_OBJECT_IMPLEMENT(ON_DimStyleExtra,ON_UserData,"513FDE53-7284-4065-8601-06CEA8B28D6F");
00199
00222
00223
00224 ON_DimStyleExtra* ON_DimStyleExtra::DimStyleExtensionGet( ON_DimStyle* pDimStyle, bool bCreateIfNoneExists )
00225 {
00226 ON_DimStyleExtra* pExtra = 0;
00227 if( pDimStyle)
00228 {
00229 pExtra = ON_DimStyleExtra::Cast( pDimStyle->GetUserData( ON_DimStyleExtra::m_ON_DimStyleExtra_class_id.Uuid()));
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 if( pExtra == 0 && bCreateIfNoneExists )
00243 {
00244 pExtra = new ON_DimStyleExtra;
00245 if( pExtra)
00246 {
00247 if( !pDimStyle->AttachUserData( pExtra))
00248 {
00249 delete pExtra;
00250 pExtra = 0;
00251 }
00252 }
00253 }
00254 }
00255 return pExtra;
00256 }
00257
00258 const
00259 ON_DimStyleExtra* ON_DimStyleExtra::DimStyleExtensionGet( const ON_DimStyle* pDimStyle)
00260 {
00261
00262 return ON_DimStyleExtra::DimStyleExtensionGet( (ON_DimStyle*)pDimStyle, false );
00263 }
00264
00265 ON_DimStyleExtra::ON_DimStyleExtra()
00266 {
00267 m_userdata_uuid = ON_DimStyleExtra::m_ON_DimStyleExtra_class_id.Uuid();
00268 m_application_uuid = ON_opennurbs5_id;
00269
00270
00271
00272 m_userdata_copycount = 1;
00273 m_valid_fields.Reserve( ON_DimStyleExtra::eFieldCount);
00274 m_valid_fields.SetCount( ON_DimStyleExtra::eFieldCount);
00275 m_parent_dimstyle = ON_nil_uuid;
00276 m_source_dimstyle = ON_nil_uuid;
00277 SetDefaults();
00278 }
00279
00280 ON_DimStyleExtra::~ON_DimStyleExtra()
00281 {
00282 }
00283
00284 void ON_DimStyleExtra::SetDefaults()
00285 {
00286 m_tolerance_style = ON_DimStyle::DefaultToleranceStyle();
00287 m_tolerance_resolution = ON_DimStyle::DefaultToleranceResolution();
00288 m_tolerance_upper_value = ON_DimStyle::DefaultToleranceUpperValue();
00289 m_tolerance_lower_value = ON_DimStyle::DefaultToleranceLowerValue();
00290 m_tolerance_height_scale = ON_DimStyle::DefaultToleranceHeightScale();
00291 m_baseline_spacing = ON_DimStyle::DefaultBaselineSpacing();
00292 m_bDrawMask = ON_DimStyle::DefaultDrawTextMask();
00293 m_mask_color_source = ON_DimStyle::DefaultMaskColorSource();
00294 m_mask_color = ON_DimStyle::DefaultMaskColor();
00295 m_dimscale = ON_DimStyle::DefaultDimScale();
00296 m_dimscale_source = ON_DimStyle::DefaultDimScaleSource();
00297
00298 for( int i = 0; i < m_valid_fields.Count(); i++)
00299 m_valid_fields[i] = false;
00300 }
00301
00302 bool ON_DimStyleExtra::IsDefault() const
00303 {
00304 if ( m_tolerance_style != ON_DimStyle::DefaultToleranceStyle() ) return false;
00305 if ( m_tolerance_resolution != ON_DimStyle::DefaultToleranceResolution() ) return false;
00306 if ( m_tolerance_upper_value != ON_DimStyle::DefaultToleranceUpperValue() ) return false;
00307 if ( m_tolerance_lower_value != ON_DimStyle::DefaultToleranceLowerValue() ) return false;
00308 if ( m_tolerance_height_scale != ON_DimStyle::DefaultToleranceHeightScale() ) return false;
00309 if ( m_baseline_spacing != ON_DimStyle::DefaultBaselineSpacing() ) return false;
00310 if ( m_bDrawMask != ON_DimStyle::DefaultDrawTextMask() ) return false;
00311 if ( m_mask_color_source != ON_DimStyle::DefaultMaskColorSource() ) return false;
00312 if ( m_mask_color != ON_DimStyle::DefaultMaskColor() ) return false;
00313 if ( m_dimscale != ON_DimStyle::DefaultDimScale() ) return false;
00314 if ( m_dimscale_source != ON_DimStyle::DefaultDimScaleSource() ) return false;
00315
00316
00317
00318 if ( !(m_parent_dimstyle == ON_nil_uuid) )
00319 {
00320 for( int i = 0; i < m_valid_fields.Count() && i < ON_DimStyleExtra::eFieldCount; i++)
00321 {
00322 if ( !m_valid_fields[i] )
00323 return false;
00324 }
00325 }
00326
00327 return true;
00328 }
00329
00330 void ON_DimStyleExtra::Dump( ON_TextLog& text_log ) const
00331 {
00332
00333 }
00334
00335 unsigned int ON_DimStyleExtra::SizeOf() const
00336 {
00337 unsigned int sz = ON_UserData::SizeOf();
00338 sz += sizeof(*this) - sizeof(ON_UserData);
00339 return sz;
00340 }
00341
00342 ON_BOOL32 ON_DimStyleExtra::Write(ON_BinaryArchive& archive) const
00343 {
00344
00345
00346
00347 bool rc = archive.BeginWrite3dmChunk(TCODE_ANONYMOUS_CHUNK,1,3);
00348
00349 if(rc) rc = archive.WriteUuid( m_parent_dimstyle);
00350 if(rc) rc = archive.WriteArray( m_valid_fields);
00351
00352 if(rc) rc = archive.WriteInt(m_tolerance_style);
00353 if(rc) rc = archive.WriteInt(m_tolerance_resolution);
00354
00355 if(rc) rc = archive.WriteDouble(m_tolerance_upper_value);
00356 if(rc) rc = archive.WriteDouble(m_tolerance_lower_value);
00357 if(rc) rc = archive.WriteDouble(m_tolerance_height_scale);
00358
00359
00360
00361 if(archive.Archive3dmVersion() < 5)
00362 {
00363 if(rc) rc = archive.WriteDouble(m_baseline_spacing * m_dimscale);
00364 }
00365 else
00366 {
00367 if(rc) rc = archive.WriteDouble(m_baseline_spacing);
00368 }
00369
00370 if(rc) rc = archive.WriteBool(m_bDrawMask);
00371 if(rc) rc = archive.WriteInt(m_mask_color_source);
00372 if(rc) rc = archive.WriteColor(m_mask_color);
00373
00374 if(archive.Archive3dmVersion() < 5)
00375 {
00376 if(rc) rc = archive.WriteDouble(1.0);
00377 }
00378 else
00379 {
00380 if(rc) rc = archive.WriteDouble(m_dimscale);
00381 }
00382 if(rc) rc = archive.WriteInt(m_dimscale_source);
00383
00384 if(rc) rc = archive.WriteUuid(m_source_dimstyle);
00385
00386 if(!archive.EndWrite3dmChunk())
00387 rc = false;
00388
00389 return rc;
00390 }
00391
00392 ON_BOOL32 ON_DimStyleExtra::Read(ON_BinaryArchive& archive)
00393 {
00394
00395 int major_version = 0;
00396 int minor_version = 0;
00397 bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version);
00398 if(major_version != 1)
00399 rc = false;
00400
00401 if(rc) rc = archive.ReadUuid(m_parent_dimstyle);
00402 if(rc) rc = archive.ReadArray(m_valid_fields);
00403
00404 if(rc) rc = archive.ReadInt(&m_tolerance_style);
00405 if(rc) rc = archive.ReadInt(&m_tolerance_resolution);
00406
00407 if(rc) rc = archive.ReadDouble(&m_tolerance_upper_value);
00408 if(rc) rc = archive.ReadDouble(&m_tolerance_lower_value);
00409 if(rc) rc = archive.ReadDouble(&m_tolerance_height_scale);
00410
00411 if(rc) rc = archive.ReadDouble(&m_baseline_spacing);
00412
00413 if(minor_version >= 1)
00414 {
00415 if(rc) rc = archive.ReadBool(&m_bDrawMask);
00416 if(rc) rc = archive.ReadInt(&m_mask_color_source);
00417 if(rc) rc = archive.ReadColor(m_mask_color);
00418 }
00419
00420 if(minor_version >= 2)
00421 {
00422 if(rc) rc = archive.ReadDouble(&m_dimscale);
00423 if(rc) rc = archive.ReadInt(&m_dimscale_source);
00424 }
00425
00426 if(minor_version >= 3)
00427 {
00428 if(rc) rc = archive.ReadUuid(m_source_dimstyle);
00429 }
00430
00431 if ( !archive.EndRead3dmChunk() )
00432 rc = false;
00433
00434 return rc;
00435 }
00436
00437 ON_BOOL32 ON_DimStyleExtra::GetDescription( ON_wString& description)
00438 {
00439 description.Format( "Userdata extension of ON_DimStyle");
00440 return true;
00441 }
00442
00443 ON_BOOL32 ON_DimStyleExtra::Archive() const
00444 {
00445
00446 return true;
00447 }
00448
00449 void ON_DimStyleExtra::Scale( double scale)
00450 {
00451 if( ON_IsValid( scale) && scale > ON_SQRT_EPSILON)
00452 m_baseline_spacing *= scale;
00453 }
00454
00455
00456 void ON_DimStyleExtra::SetToleranceStyle( int style)
00457 {
00458 if( style >= 0 && style <= 4)
00459 m_tolerance_style = style;
00460 }
00461
00462 int ON_DimStyleExtra::ToleranceStyle() const
00463 {
00464 return m_tolerance_style;
00465 }
00466
00467 void ON_DimStyleExtra::SetToleranceResolution( int resolution)
00468 {
00469 if( resolution >= 0 && resolution < 16)
00470 m_tolerance_resolution = resolution;
00471 }
00472
00473 int ON_DimStyleExtra::ToleranceResolution() const
00474 {
00475 return m_tolerance_resolution;
00476 }
00477
00478 void ON_DimStyleExtra::SetToleranceUpperValue( double upper_value)
00479 {
00480 if( ON_IsValid(upper_value))
00481 m_tolerance_upper_value = upper_value;
00482 }
00483
00484 double ON_DimStyleExtra::ToleranceUpperValue() const
00485 {
00486 return m_tolerance_upper_value;
00487 }
00488
00489 void ON_DimStyleExtra::SetToleranceLowerValue( double lower_value)
00490 {
00491 if( ON_IsValid(lower_value))
00492 m_tolerance_lower_value = lower_value;
00493 }
00494
00495 double ON_DimStyleExtra::ToleranceLowerValue() const
00496 {
00497 return m_tolerance_lower_value;
00498 }
00499
00500 void ON_DimStyleExtra::SetToleranceHeightScale( double scale)
00501 {
00502 if( ON_IsValid( scale) && scale > ON_SQRT_EPSILON)
00503 m_tolerance_height_scale = scale;
00504 }
00505
00506 double ON_DimStyleExtra::ToleranceHeightScale() const
00507 {
00508 return m_tolerance_height_scale;
00509 }
00510
00511 void ON_DimStyleExtra::SetBaselineSpacing( double spacing)
00512 {
00513 if( ON_IsValid( spacing) && spacing > ON_SQRT_EPSILON)
00514 m_baseline_spacing = spacing;
00515 }
00516
00517 double ON_DimStyleExtra::BaselineSpacing() const
00518 {
00519 return m_baseline_spacing;
00520 }
00521
00522 bool ON_DimStyleExtra::DrawTextMask() const
00523 {
00524 return m_bDrawMask;
00525 }
00526
00527 void ON_DimStyleExtra::SetDrawTextMask(bool bDraw)
00528 {
00529 m_bDrawMask = bDraw ? true : false;
00530 }
00531
00532 int ON_DimStyleExtra::MaskColorSource() const
00533 {
00534 return m_mask_color_source;
00535 }
00536
00537 void ON_DimStyleExtra::SetMaskColorSource(int source)
00538 {
00539 if(source == 1)
00540 m_mask_color_source = 1;
00541 else
00542 m_mask_color_source = 0;
00543 }
00544
00545 ON_Color ON_DimStyleExtra::MaskColor() const
00546 {
00547 return m_mask_color;
00548 }
00549
00550 void ON_DimStyleExtra::SetMaskColor(ON_Color color)
00551 {
00552 m_mask_color = color;
00553 }
00554
00555 void ON_DimStyleExtra::SetDimScale(double scale)
00556 {
00557 m_dimscale = scale;
00558 }
00559
00560 double ON_DimStyleExtra::DimScale() const
00561 {
00562 return m_dimscale;
00563 }
00564
00565 void ON_DimStyleExtra::SetDimScaleSource(int source)
00566 {
00567 m_dimscale_source = source;
00568 }
00569
00570 int ON_DimStyleExtra::DimScaleSource() const
00571 {
00572 return m_dimscale_source;
00573 }
00574
00575 void ON_DimStyleExtra::SetSourceDimstyle(ON_UUID source_uuid)
00576 {
00577 m_source_dimstyle = source_uuid;
00578 }
00579
00580 ON_UUID ON_DimStyleExtra::SourceDimstyle() const
00581 {
00582 return m_source_dimstyle;
00583 }
00584
00585
00586 bool ON_DimStyleExtra::CompareFields(const ON_DimStyleExtra* pOther) const
00587 {
00588 if(pOther == 0)
00589 return false;
00590
00591 if((m_parent_dimstyle != pOther->m_parent_dimstyle) ||
00592 (m_tolerance_style != pOther->m_tolerance_style) ||
00593 (m_tolerance_resolution != pOther->m_tolerance_resolution) ||
00594 (m_tolerance_upper_value != pOther->m_tolerance_upper_value) ||
00595 (m_tolerance_lower_value != pOther->m_tolerance_lower_value) ||
00596 (m_tolerance_height_scale != pOther->m_tolerance_height_scale) ||
00597 (m_baseline_spacing != pOther->m_baseline_spacing) ||
00598 (m_bDrawMask != pOther->m_bDrawMask) ||
00599 (m_mask_color_source != pOther->m_mask_color_source) ||
00600 (m_mask_color != pOther->m_mask_color) ||
00601 (m_dimscale != pOther->m_dimscale) ||
00602 (m_dimscale_source != pOther->m_dimscale_source)
00603 )
00604 return false;
00605
00606 for(int i = 0; i < m_valid_fields.Count(); i++)
00607 {
00608 if(m_valid_fields[i] != pOther->m_valid_fields[i])
00609 return false;
00610 }
00611 return true;
00612 }
00613
00614
00615 ON_OBJECT_IMPLEMENT( ON_DimStyle, ON_Object, "81BD83D5-7120-41c4-9A57-C449336FF12C" );
00616
00617 ON_DimStyle::ON_DimStyle()
00618 {
00619
00620
00621
00622
00623 SetDefaultsNoExtension();
00624 }
00625
00626 ON_DimStyle::~ON_DimStyle()
00627 {
00628 }
00629
00630 void ON_DimStyle::SetDefaults()
00631 {
00632
00633
00634 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, false );
00635 if( pDE)
00636 {
00637
00638
00639
00640
00641
00642
00643 delete pDE;
00644
00649 }
00650 SetDefaultsNoExtension();
00651 }
00652
00653
00654
00655 void ON_DimStyle::SetDefaultsNoExtension()
00656 {
00657 m_dimstyle_index = -1;
00658 memset(&m_dimstyle_id,0,sizeof(m_dimstyle_id));
00659 m_dimstyle_name = L"Default";
00660
00661 m_extextension = 0.5;
00662 m_extoffset = 0.5;
00663 m_arrowsize = 1.0;
00664 m_centermark = 0.5;
00665 m_textgap = 0.25;
00666 m_textheight = 1.0;
00667 m_textalign = ON::dtAboveLine;
00668 m_arrowtype = 0;
00669 m_angularunits = 0;
00670 m_lengthformat = 0;
00671 m_angleformat = 0;
00672 m_lengthresolution = 2;
00673 m_angleresolution = 2;
00674 m_fontindex = -1;
00675
00676
00677 m_lengthfactor = 1.0;
00678 m_bAlternate = false;
00679 m_alternate_lengthfactor = 25.4;
00680 m_alternate_lengthformat = 0;
00681 m_alternate_lengthresolution = 2;
00682 m_alternate_angleformat = 0;
00683 m_alternate_angleresolution = 2;
00684
00685 m_prefix = L"";
00686 m_suffix = L"";
00687 m_alternate_prefix = L" [";
00688 m_alternate_suffix = L"]";
00689 m_valid = 0;
00690
00691 m_dimextension = 0.0;
00692
00693 m_leaderarrowsize = 1.0;
00694 m_leaderarrowtype = 0;
00695 m_bSuppressExtension1 = false;
00696 m_bSuppressExtension2 = false;
00697 }
00698
00699
00700
00701 ON_DimStyle& ON_DimStyle::operator=( const ON_3dmAnnotationSettings& src)
00702 {
00703 SetDefaults();
00704
00705 m_extextension = src.m_dimexe;
00706 m_extoffset = src.m_dimexo;
00707 m_arrowsize = src.m_arrowlength;
00708 m_textalign = src.m_textalign;
00709 m_centermark = src.m_centermark;
00710 m_textgap = src.m_dimexo / 2.0;
00711 m_textheight = src.m_textheight;
00712 m_arrowtype = src.m_arrowtype;
00713 m_angularunits = src.m_angularunits;
00714 m_lengthformat = src.m_lengthformat;
00715 m_angleformat = src.m_angleformat;
00716 m_lengthresolution = src.m_resolution;
00717 m_angleresolution = src.m_resolution;
00718
00719 return *this;
00720 }
00721
00723
00724
00725
00726 ON_BOOL32 ON_DimStyle::IsValid( ON_TextLog* text_log ) const
00727 {
00728 return ( m_dimstyle_name.Length() > 0 && m_dimstyle_index >= 0);
00729 }
00730
00731 void ON_DimStyle::Dump( ON_TextLog& dump ) const
00732 {
00733 const wchar_t* wsName = m_dimstyle_name;
00734 if ( !wsName )
00735 wsName = L"";
00736 dump.Print("dimstyle index = %d\n",m_dimstyle_index);
00737 dump.Print("dimstyle name = \"%ls\"\n",wsName);
00738 }
00739
00740 ON_BOOL32 ON_DimStyle::Write(
00741 ON_BinaryArchive& file
00742 ) const
00743 {
00744
00745
00746 double ds = 1.0;
00747 if(file.Archive3dmVersion() < 5)
00748 ds = DimScale();
00749
00750
00751
00752 ON_BOOL32 rc = file.Write3dmChunkVersion(1,5);
00753
00754 if (rc) rc = file.WriteInt(m_dimstyle_index);
00755 if (rc) rc = file.WriteString(m_dimstyle_name);
00756
00757 if (rc) rc = file.WriteDouble(m_extextension * ds);
00758 if (rc) rc = file.WriteDouble(m_extoffset * ds);
00759 if (rc) rc = file.WriteDouble(m_arrowsize * ds);
00760 if (rc) rc = file.WriteDouble(m_centermark * ds);
00761 if (rc) rc = file.WriteDouble(m_textgap * ds);
00762
00763 if (rc) rc = file.WriteInt(m_textalign);
00764 if (rc) rc = file.WriteInt(m_arrowtype);
00765 if (rc) rc = file.WriteInt(m_angularunits);
00766 if (rc) rc = file.WriteInt(m_lengthformat);
00767 if (rc) rc = file.WriteInt(m_angleformat);
00768 if (rc) rc = file.WriteInt(m_lengthresolution);
00769 if (rc) rc = file.WriteInt(m_angleresolution);
00770 if (rc) rc = file.WriteInt(m_fontindex);
00771
00772 if (rc) rc = file.WriteDouble(m_textheight * ds);
00773
00774
00775 if (rc) rc = file.WriteDouble(m_lengthfactor);
00776 if (rc) rc = file.WriteString(m_prefix);
00777 if (rc) rc = file.WriteString(m_suffix);
00778
00779 if (rc) rc = file.WriteBool(m_bAlternate);
00780 if (rc) rc = file.WriteDouble(m_alternate_lengthfactor);
00781 if (rc) rc = file.WriteInt(m_alternate_lengthformat);
00782 if (rc) rc = file.WriteInt(m_alternate_lengthresolution);
00783 if (rc) rc = file.WriteInt(m_alternate_angleformat);
00784 if (rc) rc = file.WriteInt(m_alternate_angleresolution);
00785 if (rc) rc = file.WriteString(m_alternate_prefix);
00786 if (rc) rc = file.WriteString(m_alternate_suffix);
00787 if (rc) rc = file.WriteInt(m_valid);
00788
00789
00790 if (rc) rc = file.WriteUuid(m_dimstyle_id);
00791
00792
00793 if (rc) rc = file.WriteDouble(m_dimextension * ds);
00794
00795
00796 if (rc) rc = file.WriteDouble(m_leaderarrowsize * ds);
00797 if (rc) rc = file.WriteInt(m_leaderarrowtype);
00798 if (rc) rc = file.WriteBool(m_bSuppressExtension1);
00799 if (rc) rc = file.WriteBool(m_bSuppressExtension2);
00800
00801 return rc;
00802 }
00803
00804 ON_BOOL32 ON_DimStyle::Read(
00805 ON_BinaryArchive& file
00806 )
00807 {
00808 SetDefaultsNoExtension();
00809
00810 int major_version = 0;
00811 int minor_version = 0;
00812 ON_BOOL32 rc = file.Read3dmChunkVersion(&major_version,&minor_version);
00813
00814
00815 if ( major_version >= 1 )
00816 {
00817 if ( rc) rc = file.ReadInt( &m_dimstyle_index);
00818 if ( rc) rc = file.ReadString( m_dimstyle_name);
00819
00820 if ( rc) rc = file.ReadDouble( &m_extextension);
00821 if ( rc) rc = file.ReadDouble( &m_extoffset);
00822 if ( rc) rc = file.ReadDouble( &m_arrowsize);
00823 if ( rc) rc = file.ReadDouble( &m_centermark);
00824 if ( rc) rc = file.ReadDouble( &m_textgap);
00825
00826 if ( rc) rc = file.ReadInt( &m_textalign);
00827 if ( rc) rc = file.ReadInt( &m_arrowtype);
00828 if ( rc) rc = file.ReadInt( &m_angularunits);
00829 if ( rc) rc = file.ReadInt( &m_lengthformat);
00830 if ( rc) rc = file.ReadInt( &m_angleformat);
00831 if ( rc) rc = file.ReadInt( &m_lengthresolution);
00832 if ( rc) rc = file.ReadInt( &m_angleresolution);
00833 if ( rc) rc = file.ReadInt( &m_fontindex);
00834
00835 if( minor_version >= 1)
00836 if ( rc) rc = file.ReadDouble( &m_textheight);
00837
00838
00839 if( minor_version >= 2)
00840 {
00841 if (rc) rc = file.ReadDouble( &m_lengthfactor);
00842 if (rc) rc = file.ReadString( m_prefix);
00843 if (rc) rc = file.ReadString( m_suffix);
00844
00845 if (rc) rc = file.ReadBool( &m_bAlternate);
00846 if (rc) rc = file.ReadDouble(&m_alternate_lengthfactor);
00847 if (rc) rc = file.ReadInt( &m_alternate_lengthformat);
00848 if (rc) rc = file.ReadInt( &m_alternate_lengthresolution);
00849 if (rc) rc = file.ReadInt( &m_alternate_angleformat);
00850 if (rc) rc = file.ReadInt( &m_alternate_angleresolution);
00851 if (rc) rc = file.ReadString( m_alternate_prefix);
00852 if (rc) rc = file.ReadString( m_alternate_suffix);
00853 if (rc) rc = file.ReadInt( &m_valid);
00854
00855 if ( minor_version >= 3 )
00856 {
00857 if (rc) rc = file.ReadUuid(m_dimstyle_id);
00858 }
00859 }
00860
00861 if( minor_version >= 4)
00862 if( rc) rc = file.ReadDouble( &m_dimextension);
00863
00864
00865 if( minor_version >= 5)
00866 {
00867 if (rc) rc = file.ReadDouble( &m_leaderarrowsize);
00868 if (rc) rc = file.ReadInt( &m_leaderarrowtype);
00869 if (rc) rc = file.ReadBool( &m_bSuppressExtension1);
00870 if (rc) rc = file.ReadBool( &m_bSuppressExtension2);
00871 }
00872 }
00873 else
00874 rc = false;
00875
00876 return rc;
00877 }
00878
00879 void ON_DimStyle::EmergencyDestroy()
00880 {
00881 m_prefix.EmergencyDestroy();
00882 m_suffix.EmergencyDestroy();
00883 m_alternate_prefix.EmergencyDestroy();
00884 m_alternate_suffix.EmergencyDestroy();
00885 }
00886
00888
00889
00890 void ON_DimStyle::SetName( const wchar_t* s )
00891 {
00892 m_dimstyle_name = s;
00893 m_dimstyle_name.TrimLeftAndRight();
00894 }
00895
00896 void ON_DimStyle::SetName( const char* s )
00897 {
00898 m_dimstyle_name = s;
00899 m_dimstyle_name.TrimLeftAndRight();
00900 }
00901
00902 void ON_DimStyle::GetName( ON_wString& s ) const
00903 {
00904 s = m_dimstyle_name;
00905 }
00906
00907 const wchar_t* ON_DimStyle::Name() const
00908 {
00909 const wchar_t* s = m_dimstyle_name;
00910 return s;
00911 }
00912
00913 void ON_DimStyle::SetIndex(int i )
00914 {
00915 m_dimstyle_index = i;
00916 }
00917
00918 int ON_DimStyle::Index() const
00919 {
00920 return m_dimstyle_index;
00921 }
00922
00923 double ON_DimStyle::ExtExtension() const
00924 {
00925 return m_extextension;
00926 }
00927
00928 void ON_DimStyle::SetExtExtension( const double e)
00929 {
00930
00931 m_extextension = e;
00932 }
00933
00934 double ON_DimStyle::ExtOffset() const
00935 {
00936 return m_extoffset;
00937 }
00938
00939 void ON_DimStyle::SetExtOffset( const double e)
00940 {
00941 m_extoffset = e;
00942 }
00943
00944 double ON_DimStyle::ArrowSize() const
00945 {
00946 return m_arrowsize;
00947 }
00948
00949 void ON_DimStyle::SetArrowSize( const double e)
00950 {
00951 m_arrowsize = e;
00952 }
00953
00954 double ON_DimStyle::LeaderArrowSize() const
00955 {
00956 return m_leaderarrowsize;
00957 }
00958
00959 void ON_DimStyle::SetLeaderArrowSize( const double e)
00960 {
00961 m_leaderarrowsize = e;
00962 }
00963
00964 double ON_DimStyle::CenterMark() const
00965 {
00966 return m_centermark;
00967 }
00968
00969 void ON_DimStyle::SetCenterMark( const double e)
00970 {
00971 m_centermark = e;
00972 }
00973
00974 int ON_DimStyle::TextAlignment() const
00975 {
00976 return m_textalign;
00977 }
00978
00979 void ON_DimStyle::SetTextAlignment( ON::eTextDisplayMode a)
00980 {
00981 m_textalign = a;
00982 }
00983
00984 int ON_DimStyle::ArrowType() const
00985 {
00986 return m_arrowtype;
00987 }
00988
00989 void ON_DimStyle::SetArrowType( eArrowType a)
00990 {
00991 m_arrowtype = a;
00992 }
00993
00994 int ON_DimStyle::LeaderArrowType() const
00995 {
00996 return m_leaderarrowtype;
00997 }
00998
00999 void ON_DimStyle::SetLeaderArrowType( eArrowType a)
01000 {
01001 m_leaderarrowtype = a;
01002 }
01003
01004 int ON_DimStyle::AngularUnits() const
01005 {
01006 return m_angularunits;
01007 }
01008
01009 void ON_DimStyle::SetAngularUnits( int u)
01010 {
01011 m_angularunits = u;
01012 }
01013
01014 int ON_DimStyle::LengthFormat() const
01015 {
01016 return m_lengthformat;
01017 }
01018
01019 void ON_DimStyle::SetLengthFormat( int f)
01020 {
01021 m_lengthformat = f;
01022 }
01023
01024 int ON_DimStyle::AngleFormat() const
01025 {
01026 return m_angleformat;
01027 }
01028
01029 void ON_DimStyle::SetAngleFormat( int f)
01030 {
01031 m_angleformat = f;
01032 }
01033
01034 int ON_DimStyle::LengthResolution() const
01035 {
01036 return m_lengthresolution;
01037 }
01038
01039 void ON_DimStyle::SetLengthResolution( int r)
01040 {
01041 if( r >= 0 && r < 16)
01042 {
01043 m_lengthresolution = r;
01044 }
01045 }
01046
01047 int ON_DimStyle::AngleResolution() const
01048 {
01049 return m_angleresolution;
01050 }
01051
01052 void ON_DimStyle::SetAngleResolution( int r)
01053 {
01054 if( r >= 0 && r < 16)
01055 {
01056 m_angleresolution = r;
01057 }
01058 }
01059
01060 int ON_DimStyle::FontIndex() const
01061 {
01062 return m_fontindex;
01063 }
01064
01065 void ON_DimStyle::SetFontIndex( int index)
01066 {
01067 m_fontindex = index;
01068 }
01069
01070 double ON_DimStyle::TextGap() const
01071 {
01072 return m_textgap;
01073 }
01074
01075 void ON_DimStyle::SetTextGap( double gap)
01076 {
01077 if( gap >= 0.0)
01078 {
01079 m_textgap = gap;
01080 }
01081 }
01082
01083 double ON_DimStyle::TextHeight() const
01084 {
01085 return m_textheight;
01086 }
01087
01088 void ON_DimStyle::SetTextHeight( double height)
01089 {
01090 if( ON_IsValid( height) && height > ON_SQRT_EPSILON)
01091 {
01092 m_textheight = height;
01093 }
01094 }
01095
01096
01097 double ON_DimStyle::LengthFactor() const
01098 {
01099 return m_lengthfactor;
01100 }
01101 void ON_DimStyle::SetLengthactor( double factor)
01102 {
01103 SetLengthFactor( factor);
01104 }
01105 void ON_DimStyle::SetLengthFactor( double factor)
01106 {
01107 m_lengthfactor = factor;
01108
01109 m_valid |= ( 1 << fn_lengthfactor);
01110 }
01111
01112 bool ON_DimStyle::Alternate() const
01113 {
01114 return m_bAlternate;
01115 }
01116 void ON_DimStyle::SetAlternate( bool bAlternate)
01117 {
01118 m_bAlternate = bAlternate;
01119 }
01120
01121 double ON_DimStyle::AlternateLengthFactor() const
01122 {
01123 return m_alternate_lengthfactor;
01124 }
01125 void ON_DimStyle::SetAlternateLengthactor( double factor)
01126 {
01127 SetAlternateLengthFactor( factor);
01128 }
01129 void ON_DimStyle::SetAlternateLengthFactor( double factor)
01130 {
01131 m_alternate_lengthfactor = factor;
01132
01133 m_valid |= ( 1 << fn_alternate_lengthfactor);
01134 }
01135
01136 int ON_DimStyle::AlternateLengthFormat() const
01137 {
01138 return m_alternate_lengthformat;
01139 }
01140 void ON_DimStyle::SetAlternateLengthFormat( int format)
01141 {
01142 m_alternate_lengthformat = format;
01143 }
01144
01145 int ON_DimStyle::AlternateLengthResolution() const
01146 {
01147 return m_alternate_lengthresolution;
01148 }
01149 void ON_DimStyle::SetAlternateLengthResolution( int resolution)
01150 {
01151 m_alternate_lengthresolution = resolution;
01152 }
01153
01154 int ON_DimStyle::AlternateAngleFormat() const
01155 {
01156 return m_alternate_angleformat;
01157 }
01158 void ON_DimStyle::SetAlternateAngleFormat( int format)
01159 {
01160 m_alternate_angleformat = format;
01161 }
01162
01163 int ON_DimStyle::AlternateAngleResolution() const
01164 {
01165 return m_alternate_angleresolution;
01166 }
01167 void ON_DimStyle::SetAlternateAngleResolution( int resolution)
01168 {
01169 m_alternate_angleresolution = resolution;
01170 }
01171
01172 void ON_DimStyle::GetPrefix( ON_wString& prefix) const
01173 {
01174 prefix = m_prefix;
01175 }
01176 const wchar_t* ON_DimStyle::Prefix() const
01177 {
01178 return m_prefix;
01179 }
01180 void ON_DimStyle::SetPrefix( wchar_t* prefix)
01181 {
01182 m_prefix = prefix;
01183 }
01184 void ON_DimStyle::SetPrefix( const wchar_t* prefix)
01185 {
01186 m_prefix = prefix;
01187 }
01188
01189 void ON_DimStyle::GetSuffix( ON_wString& suffix) const
01190 {
01191 suffix = m_suffix;
01192 }
01193 const wchar_t* ON_DimStyle::Suffix() const
01194 {
01195 return m_suffix;
01196 }
01197 void ON_DimStyle::SetSuffix( wchar_t* suffix)
01198 {
01199 m_suffix = suffix;
01200 }
01201 void ON_DimStyle::SetSuffix( const wchar_t* suffix)
01202 {
01203 m_suffix = suffix;
01204 }
01205
01206 void ON_DimStyle::GetAlternatePrefix( ON_wString& prefix) const
01207 {
01208 prefix = m_alternate_prefix;
01209 }
01210 const wchar_t* ON_DimStyle::AlternatePrefix() const
01211 {
01212 return m_alternate_prefix;
01213 }
01214 void ON_DimStyle::SetAlternatePrefix( wchar_t* prefix)
01215 {
01216 m_alternate_prefix = prefix;
01217 }
01218 void ON_DimStyle::SetAlternatePrefix( const wchar_t* prefix)
01219 {
01220 m_alternate_prefix = prefix;
01221 }
01222
01223 void ON_DimStyle::GetAlternateSuffix( ON_wString& suffix) const
01224 {
01225 suffix = m_alternate_suffix;
01226 }
01227 const wchar_t* ON_DimStyle::AlternateSuffix() const
01228 {
01229 return m_alternate_suffix;
01230 }
01231 void ON_DimStyle::SetAlternateSuffix( wchar_t* suffix)
01232 {
01233 m_alternate_suffix = suffix;
01234 }
01235 void ON_DimStyle::SetAlternateSuffix( const wchar_t* suffix)
01236 {
01237 m_alternate_suffix = suffix;
01238 }
01239
01240 bool ON_DimStyle::SuppressExtension1() const
01241 {
01242 return m_bSuppressExtension1;
01243 }
01244 void ON_DimStyle::SetSuppressExtension1( bool suppress)
01245 {
01246 m_bSuppressExtension1 = suppress;
01247 }
01248 bool ON_DimStyle::SuppressExtension2() const
01249 {
01250 return m_bSuppressExtension2;
01251 }
01252 void ON_DimStyle::SetSuppressExtension2( bool suppress)
01253 {
01254 m_bSuppressExtension2 = suppress;
01255 }
01256
01257
01258 void ON_DimStyle::Composite( const ON_DimStyle& OverRide)
01259 {
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294 }
01295
01296
01297 void ON_DimStyle::InvalidateField( eField field)
01298 {
01299 m_valid &= ~( 1 << field);
01300 }
01301
01302 void ON_DimStyle::InvalidateAllFields()
01303 {
01304 m_valid = 0;
01305 }
01306
01307 void ON_DimStyle::ValidateField( eField field)
01308 {
01309 m_valid |= ( 1 << field);
01310 }
01311
01312 bool ON_DimStyle::IsFieldValid( eField field) const
01313 {
01314 return ( m_valid & ( 1 << field)) ? true : false;
01315 }
01316
01317
01318
01319 double ON_DimStyle::DimExtension() const
01320 {
01321 return m_dimextension;
01322 }
01323
01324 void ON_DimStyle::SetDimExtension( const double e)
01325 {
01326
01327 m_dimextension = e;
01328 }
01329
01330
01331
01332
01333
01334 bool ON_DimStyle::IsFieldOverride( ON_DimStyle::eField field_id) const
01335 {
01336 const ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this);
01337 if(pDE)
01338 return pDE->IsFieldOverride( field_id);
01339
01340 return false;
01341 }
01342
01343 void ON_DimStyle::SetFieldOverride( ON_DimStyle::eField field_id, bool bOverride)
01344 {
01345
01346
01347
01348 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bOverride );
01349 if(pDE)
01350 {
01351 pDE->SetFieldOverride( field_id, bOverride);
01352 }
01353 }
01354
01355 bool ON_DimStyle::HasOverrides() const
01356 {
01357 const ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this );
01358 if(pDE)
01359 {
01360 for( int i = 0; i < pDE->m_valid_fields.Count(); i++)
01361 {
01362 if( pDE->m_valid_fields[i])
01363 return true;
01364 }
01365 }
01366 return false;
01367 }
01368
01369 bool ON_DimStyle::OverrideFields( const ON_DimStyle& src, const ON_DimStyle& parent)
01370 {
01371
01372
01373
01374 const ON_DimStyleExtra* pDEsrc = ON_DimStyleExtra::DimStyleExtensionGet( &src);
01375
01376
01377
01378
01379
01380 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, false );
01381
01382 const int src_valid_fields_count = pDEsrc ? pDEsrc->m_valid_fields.Count() : 0;
01383 int this_valid_fields_count = pDE ? pDE->m_valid_fields.Count() : 0;
01384
01385 for( int i = 0; i < ON_DimStyleExtra::eFieldCount; i++)
01386 {
01387 bool bValidSrcField = ( 0 != pDEsrc && i < src_valid_fields_count )
01388 ? pDEsrc->m_valid_fields[i]
01389 : false;
01390
01391 if ( bValidSrcField && 0 == pDE )
01392 {
01393
01394 pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, true );
01395 if ( pDE )
01396 this_valid_fields_count = pDE->m_valid_fields.Count();
01397 }
01398
01399 if ( 0 != pDE && i < this_valid_fields_count )
01400 {
01401 pDE->m_valid_fields[i] = bValidSrcField;
01402 }
01403
01404 const ON_DimStyle* copyfrom = bValidSrcField ? (&src) : (&parent);
01405
01406 switch( i)
01407 {
01408 case fn_extextension:
01409 SetExtExtension( copyfrom->ExtExtension());
01410 break;
01411 case fn_extoffset:
01412 SetExtOffset( copyfrom->ExtOffset());
01413 break;
01414 case fn_arrowsize:
01415 SetArrowSize( copyfrom->ArrowSize());
01416 break;
01417 case fn_centermark:
01418 SetCenterMark( copyfrom->CenterMark());
01419 break;
01420 case fn_textgap:
01421 SetTextGap( copyfrom->TextGap());
01422 break;
01423 case fn_textheight:
01424 SetTextHeight( copyfrom->TextHeight());
01425 break;
01426 case fn_textalign:
01427 SetTextAlignment( (ON::eTextDisplayMode)copyfrom->TextAlignment());
01428 break;
01429 case fn_arrowtype:
01430 SetArrowType( (eArrowType)copyfrom->ArrowType());
01431 break;
01432 case fn_angularunits:
01433 SetAngularUnits( (eArrowType)copyfrom->AngularUnits());
01434 break;
01435 case fn_lengthformat:
01436 SetLengthFormat( copyfrom->LengthFormat());
01437 break;
01438 case fn_angleformat:
01439 SetAngleFormat( copyfrom->AngleFormat());
01440 break;
01441 case fn_angleresolution:
01442 SetAngleResolution( copyfrom->AngleResolution());
01443 break;
01444 case fn_lengthresolution:
01445 SetLengthResolution( copyfrom->LengthResolution());
01446 break;
01447 case fn_fontindex:
01448 SetFontIndex( copyfrom->FontIndex());
01449 break;
01450 case fn_lengthfactor:
01451 SetLengthFactor( copyfrom->LengthFactor());
01452 break;
01453 case fn_bAlternate:
01454 SetAlternate( copyfrom->Alternate());
01455 break;
01456 case fn_alternate_lengthfactor:
01457 SetAlternateLengthFactor( copyfrom->AlternateLengthFactor());
01458 break;
01459 case fn_alternate_lengthformat:
01460 SetAlternateLengthFormat( copyfrom->AlternateLengthFormat());
01461 break;
01462 case fn_alternate_lengthresolution:
01463 SetAlternateLengthResolution( copyfrom->AlternateLengthResolution());
01464 break;
01465 case fn_alternate_angleformat:
01466 SetAlternateLengthResolution( copyfrom->AlternateLengthResolution());
01467 break;
01468 case fn_alternate_angleresolution:
01469 SetAlternateAngleResolution( copyfrom->AlternateAngleResolution());
01470 break;
01471 case fn_prefix:
01472 SetPrefix( copyfrom->Prefix());
01473 break;
01474 case fn_suffix:
01475 SetSuffix( copyfrom->Suffix());
01476 break;
01477 case fn_alternate_prefix:
01478 SetAlternatePrefix( copyfrom->AlternatePrefix());
01479 break;
01480 case fn_alternate_suffix:
01481 SetAlternateSuffix( copyfrom->AlternateSuffix());
01482 break;
01483 case fn_dimextension:
01484 SetDimExtension( copyfrom->DimExtension());
01485 break;
01486 case fn_leaderarrowsize:
01487 SetLeaderArrowSize( copyfrom->LeaderArrowSize());
01488 break;
01489 case fn_leaderarrowtype:
01490 SetLeaderArrowType( (eArrowType)copyfrom->LeaderArrowType());
01491 break;
01492 case fn_suppressextension1:
01493 SetSuppressExtension1( copyfrom->SuppressExtension1());
01494 break;
01495 case fn_suppressextension2:
01496 SetSuppressExtension2( copyfrom->SuppressExtension2());
01497 break;
01498 case fn_tolerance_style:
01499 SetToleranceStyle( copyfrom->ToleranceStyle());
01500 break;
01501 case fn_tolerance_resolution:
01502 SetToleranceResolution( copyfrom->ToleranceResolution());
01503 break;
01504 case fn_tolerance_upper_value:
01505 SetToleranceUpperValue( copyfrom->ToleranceUpperValue());
01506 break;
01507 case fn_tolerance_lower_value:
01508 SetToleranceLowerValue( copyfrom->ToleranceLowerValue());
01509 break;
01510 case fn_tolerance_height_scale:
01511 SetToleranceHeightScale( copyfrom->ToleranceHeightScale());
01512 break;
01513 case fn_baseline_spacing:
01514 SetBaselineSpacing( copyfrom->BaselineSpacing());
01515 break;
01516 case fn_draw_mask:
01517 SetDrawTextMask( copyfrom->DrawTextMask());
01518 break;
01519 case fn_mask_color_source:
01520 SetMaskColorSource( copyfrom->MaskColorSource());
01521 break;
01522 case fn_mask_color:
01523 SetMaskColor( copyfrom->MaskColor());
01524 break;
01525 case fn_dimscale:
01526 SetDimScale( copyfrom->DimScale());
01527 break;
01528 case fn_dimscale_source:
01529 SetDimScaleSource( copyfrom->DimScaleSource());
01530 break;
01531 }
01532 }
01533 return true;
01534 }
01535
01536 bool ON_DimStyle::InheritFields( const ON_DimStyle& parent)
01537 {
01538 bool rc = false;
01539
01540
01541
01542
01543 const ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this);
01544 for( int i = 0; i < ON_DimStyleExtra::eFieldCount; i++ )
01545 {
01546 bool bValidField = ( 0 != pDE && i < pDE->m_valid_fields.Count() )
01547 ? pDE->m_valid_fields[i] :
01548 false;
01549
01550 switch( i)
01551 {
01552 case fn_extextension:
01553 if( !bValidField)
01554 {
01555 SetExtExtension( parent.ExtExtension());
01556 rc = true;
01557 }
01558 break;
01559 case fn_extoffset:
01560 if( !bValidField)
01561 {
01562 SetExtOffset( parent.ExtOffset());
01563 rc = true;
01564 }
01565 break;
01566 case fn_arrowsize:
01567 if( !bValidField)
01568 {
01569 SetArrowSize( parent.ArrowSize());
01570 rc = true;
01571 }
01572 break;
01573 case fn_centermark:
01574 if( !bValidField)
01575 {
01576 SetCenterMark( parent.CenterMark());
01577 rc = true;
01578 }
01579 break;
01580 case fn_textgap:
01581 if( !bValidField)
01582 {
01583 SetTextGap( parent.TextGap());
01584 rc = true;
01585 }
01586 break;
01587 case fn_textheight:
01588 if( !bValidField)
01589 {
01590 SetTextHeight( parent.TextHeight());
01591 rc = true;
01592 }
01593 break;
01594 case fn_textalign:
01595 if( !bValidField)
01596 {
01597 SetTextAlignment( (ON::eTextDisplayMode)parent.TextAlignment());
01598 rc = true;
01599 }
01600 break;
01601 case fn_arrowtype:
01602 if( !bValidField)
01603 {
01604 SetArrowType( (eArrowType)parent.ArrowType());
01605 rc = true;
01606 }
01607 break;
01608 case fn_angularunits:
01609 if( !bValidField)
01610 {
01611 SetAngularUnits( (eArrowType)parent.AngularUnits());
01612 rc = true;
01613 }
01614 break;
01615 case fn_lengthformat:
01616 if( !bValidField)
01617 {
01618 SetLengthFormat( parent.LengthFormat());
01619 rc = true;
01620 }
01621 break;
01622 case fn_angleformat:
01623 if( !bValidField)
01624 {
01625 SetAngleFormat( parent.AngleFormat());
01626 rc = true;
01627 }
01628 break;
01629 case fn_angleresolution:
01630 if( !bValidField)
01631 {
01632 SetAngleResolution( parent.AngleResolution());
01633 rc = true;
01634 }
01635 break;
01636 case fn_lengthresolution:
01637 if( !bValidField)
01638 {
01639 SetLengthResolution( parent.LengthResolution());
01640 rc = true;
01641 }
01642 break;
01643 case fn_fontindex:
01644 if( !bValidField)
01645 {
01646 SetFontIndex( parent.FontIndex());
01647 rc = true;
01648 }
01649 break;
01650 case fn_lengthfactor:
01651 if( !bValidField)
01652 {
01653 SetLengthFactor( parent.LengthFactor());
01654 rc = true;
01655 }
01656 break;
01657 case fn_bAlternate:
01658 if( !bValidField)
01659 {
01660 SetAlternate( parent.Alternate());
01661 rc = true;
01662 }
01663 break;
01664 case fn_alternate_lengthfactor:
01665 if( !bValidField)
01666 {
01667 SetAlternateLengthFactor( parent.LengthFactor());
01668 rc = true;
01669 }
01670 break;
01671 case fn_alternate_lengthformat:
01672 if( !bValidField)
01673 {
01674 SetAlternateLengthFormat( parent.AlternateLengthFormat());
01675 rc = true;
01676 }
01677 break;
01678 case fn_alternate_lengthresolution:
01679 if( !bValidField)
01680 {
01681 SetAlternateLengthResolution( parent.AlternateLengthResolution());
01682 rc = true;
01683 }
01684 break;
01685 case fn_alternate_angleformat:
01686 if( !bValidField)
01687 {
01688 SetAlternateLengthResolution( parent.AlternateLengthResolution());
01689 rc = true;
01690 }
01691 break;
01692 case fn_alternate_angleresolution:
01693 if( !bValidField)
01694 {
01695 SetAlternateAngleResolution( parent.AlternateAngleResolution());
01696 rc = true;
01697 }
01698 break;
01699 case fn_prefix:
01700 if( !bValidField)
01701 {
01702 SetPrefix( parent.Prefix());
01703 rc = true;
01704 }
01705 break;
01706 case fn_suffix:
01707 if( !bValidField)
01708 {
01709 SetSuffix( parent.Suffix());
01710 rc = true;
01711 }
01712 break;
01713 case fn_alternate_prefix:
01714 if( !bValidField)
01715 {
01716 SetAlternatePrefix( parent.AlternatePrefix());
01717 rc = true;
01718 }
01719 break;
01720 case fn_alternate_suffix:
01721 if( !bValidField)
01722 {
01723 SetAlternateSuffix( parent.AlternateSuffix());
01724 rc = true;
01725 }
01726 break;
01727 case fn_dimextension:
01728 if( !bValidField)
01729 {
01730 SetDimExtension( parent.DimExtension());
01731 rc = true;
01732 }
01733 break;
01734 case fn_leaderarrowsize:
01735 if( !bValidField)
01736 {
01737 SetLeaderArrowSize( parent.LeaderArrowSize());
01738 rc = true;
01739 }
01740 break;
01741 case fn_leaderarrowtype:
01742 if( !bValidField)
01743 {
01744 SetLeaderArrowType( (eArrowType)parent.LeaderArrowType());
01745 rc = true;
01746 }
01747 break;
01748 case fn_suppressextension1:
01749 if( !bValidField)
01750 {
01751 SetSuppressExtension1( parent.SuppressExtension1());
01752 rc = true;
01753 }
01754 break;
01755 case fn_suppressextension2:
01756 if( !bValidField)
01757 {
01758 SetSuppressExtension2( parent.SuppressExtension2());
01759 rc = true;
01760 }
01761 break;
01762 case fn_tolerance_style:
01763 if( !bValidField)
01764 {
01765 SetToleranceStyle( parent.ToleranceStyle());
01766 rc = true;
01767 }
01768 break;
01769 case fn_tolerance_resolution:
01770 if( !bValidField)
01771 {
01772 SetToleranceResolution( parent.ToleranceResolution());
01773 rc = true;
01774 }
01775 break;
01776 case fn_tolerance_upper_value:
01777 if( !bValidField)
01778 {
01779 SetToleranceUpperValue( parent.ToleranceUpperValue());
01780 rc = true;
01781 }
01782 break;
01783 case fn_tolerance_lower_value:
01784 if( !bValidField)
01785 {
01786 SetToleranceLowerValue( parent.ToleranceLowerValue());
01787 rc = true;
01788 }
01789 break;
01790 case fn_tolerance_height_scale:
01791 if( !bValidField)
01792 {
01793 SetToleranceHeightScale( parent.ToleranceHeightScale());
01794 rc = true;
01795 }
01796 break;
01797 case fn_baseline_spacing:
01798 if( !bValidField)
01799 {
01800 SetBaselineSpacing( parent.BaselineSpacing());
01801 rc = true;
01802 }
01803 break;
01804 case fn_draw_mask:
01805 if( !bValidField)
01806 {
01807 SetDrawTextMask( parent.DrawTextMask());
01808 rc = true;
01809 }
01810 break;
01811 case fn_mask_color_source:
01812 if( !bValidField)
01813 {
01814 SetMaskColorSource( parent.MaskColorSource());
01815 rc = true;
01816 }
01817 break;
01818 case fn_mask_color:
01819 if( !bValidField)
01820 {
01821 SetMaskColor( parent.MaskColor());
01822 rc = true;
01823 }
01824 break;
01825 case fn_dimscale:
01826 if( !bValidField)
01827 {
01828 SetDimScale( parent.DimScale());
01829 rc = true;
01830 }
01831 break;
01832 case fn_dimscale_source:
01833 if( !bValidField)
01834 {
01835 SetDimScaleSource( parent.DimScaleSource());
01836 rc = true;
01837 }
01838 break;
01839 }
01840 }
01841 return rc;
01842 }
01843
01844
01845 bool ON_DimStyle::IsChildDimstyle() const
01846 {
01847 const ON_DimStyleExtra* pDE = DimStyleExtension();
01848 if(pDE && pDE->m_parent_dimstyle != ON_nil_uuid)
01849 return true;
01850 else
01851 return false;
01852 }
01853
01854 bool ON_DimStyle::IsChildOf( ON_UUID& parent_uuid) const
01855 {
01856
01857
01858 const ON_DimStyleExtra* pDE = DimStyleExtension();
01859 if(pDE && parent_uuid != ON_nil_uuid && pDE->m_parent_dimstyle == parent_uuid)
01860 return true;
01861 else
01862 return false;
01863 }
01864
01865 bool ON_DimStyle::IsChildOf( const ON_UUID& parent_uuid) const
01866 {
01867 const ON_DimStyleExtra* pDE = DimStyleExtension();
01868 if(pDE && parent_uuid != ON_nil_uuid && pDE->m_parent_dimstyle == parent_uuid)
01869 return true;
01870 else
01871 return false;
01872 }
01873
01874 void ON_DimStyle::SetParent( ON_UUID& parent_uuid)
01875 {
01876
01877
01878 SetParentId(parent_uuid);
01879 }
01880
01881 void ON_DimStyle::SetParentId( ON_UUID parent_id )
01882 {
01883 bool bCreateIfNoneExists = !ON_UuidIsNil(parent_id);
01884 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfNoneExists );
01885 if ( pDE )
01886 pDE->m_parent_dimstyle = parent_id;
01887 }
01888
01889
01890 ON_UUID ON_DimStyle::ParentId() const
01891 {
01892 const ON_DimStyleExtra* pDE = DimStyleExtension();
01893 return ( 0 != pDE ? pDE->m_parent_dimstyle : ON_nil_uuid );
01894 }
01895
01896 bool ON_DimStyleExtra::IsFieldOverride( int field_id) const
01897 {
01898 if( field_id >= 0 && field_id < m_valid_fields.Count())
01899 return m_valid_fields[field_id];
01900 else
01901 return false;
01902 }
01903
01904 void ON_DimStyleExtra::SetFieldOverride( int field_id, bool bOverride)
01905 {
01906 if( field_id >= 0 && field_id < m_valid_fields.Count())
01907 m_valid_fields[field_id] = bOverride;
01908 }
01909
01910
01911
01912
01913
01914
01915
01916
01917 int ON_DimStyle::ToleranceStyle() const
01918 {
01919
01920
01921
01922 const ON_DimStyleExtra* pDE = DimStyleExtension();
01923 if(pDE)
01924 return pDE->ToleranceStyle();
01925 else
01926 return ON_DimStyle::DefaultToleranceStyle();
01927 }
01928
01929 int ON_DimStyle::ToleranceResolution() const
01930 {
01931
01932
01933
01934 const ON_DimStyleExtra* pDE = DimStyleExtension();
01935 if(pDE)
01936 return pDE->ToleranceResolution();
01937 else
01938 return ON_DimStyle::DefaultToleranceResolution();
01939 }
01940
01941 double ON_DimStyle::ToleranceUpperValue() const
01942 {
01943
01944
01945
01946 const ON_DimStyleExtra* pDE = DimStyleExtension();
01947 if(pDE)
01948 return pDE->ToleranceUpperValue();
01949 else
01950 return ON_DimStyle::DefaultToleranceUpperValue();
01951 }
01952
01953 double ON_DimStyle::ToleranceLowerValue() const
01954 {
01955
01956
01957
01958 const ON_DimStyleExtra* pDE = DimStyleExtension();
01959 if(pDE)
01960 return pDE->ToleranceLowerValue();
01961 else
01962 return ON_DimStyle::DefaultToleranceLowerValue();
01963 }
01964
01965 double ON_DimStyle::ToleranceHeightScale() const
01966 {
01967
01968
01969
01970 const ON_DimStyleExtra* pDE = DimStyleExtension();
01971 if(pDE)
01972 return pDE->ToleranceHeightScale();
01973 else
01974 return ON_DimStyle::DefaultToleranceHeightScale();
01975 }
01976
01977 double ON_DimStyle::BaselineSpacing() const
01978 {
01979
01980
01981
01982 const ON_DimStyleExtra* pDE = DimStyleExtension();
01983 if(pDE)
01984 return pDE->BaselineSpacing();
01985 else
01986 return ON_DimStyle::DefaultBaselineSpacing();
01987 }
01988
01989
01990 int ON_DimStyle::DefaultToleranceStyle()
01991 {
01992 return 0;
01993 }
01994
01995
01996 int ON_DimStyle::DefaultToleranceResolution()
01997 {
01998 return 4;
01999 }
02000
02001
02002 double ON_DimStyle::DefaultToleranceUpperValue()
02003 {
02004 return 0.0;
02005 }
02006
02007
02008 double ON_DimStyle::DefaultToleranceLowerValue()
02009 {
02010 return 0.0;
02011 }
02012
02013
02014 double ON_DimStyle::DefaultToleranceHeightScale()
02015 {
02016 return 1.0;
02017 }
02018
02019
02020 double ON_DimStyle::DefaultBaselineSpacing()
02021 {
02022 return 1.0;
02023 }
02024
02025
02026 bool ON_DimStyle::DefaultDrawTextMask()
02027 {
02028 return false;
02029 }
02030
02031
02032 int ON_DimStyle::DefaultMaskColorSource()
02033 {
02034 return 0;
02035 }
02036
02037
02038 ON_Color ON_DimStyle::DefaultMaskColor()
02039 {
02040
02041
02042
02043
02044
02045 return ON_Color(255,255,255);
02046 }
02047
02048
02049 double ON_DimStyle::DefaultDimScale()
02050 {
02051 return 1.0;
02052 }
02053
02054
02055 int ON_DimStyle::DefaultDimScaleSource()
02056 {
02057 return 0;
02058 }
02059
02060
02061
02062 void ON_DimStyle::Scale( double scale)
02063 {
02064 if( ON_IsValid( scale) && scale > ON_SQRT_EPSILON && 1.0 != scale )
02065 {
02066 m_extextension *= scale;
02067 m_extoffset *= scale;
02068 m_arrowsize *= scale;
02069 m_centermark *= scale;
02070 m_textgap *= scale;
02071 m_textheight *= scale;
02072 m_dimextension *= scale;
02073 m_leaderarrowsize *= scale;
02074
02075 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, true );
02076 if(pDE)
02077 {
02078 pDE->Scale( scale);
02079 }
02080 }
02081 }
02082
02083 void ON_DimStyle::SetToleranceStyle( int style)
02084 {
02085 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultToleranceStyle() != style );
02086 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02087 if(pDE)
02088 {
02089 pDE->SetToleranceStyle( style);
02090 }
02091 }
02092
02093 void ON_DimStyle::SetToleranceResolution( int resolution)
02094 {
02095 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultToleranceResolution() != resolution );
02096 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02097 if(pDE)
02098 {
02099 pDE->SetToleranceResolution( resolution);
02100 }
02101 }
02102
02103 void ON_DimStyle::SetToleranceUpperValue( double upper_value)
02104 {
02105 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultToleranceUpperValue() != upper_value );
02106 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02107 if(pDE)
02108 {
02109 pDE->SetToleranceUpperValue( upper_value);
02110 }
02111 }
02112
02113 void ON_DimStyle::SetToleranceLowerValue( double lower_value)
02114 {
02115 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultToleranceLowerValue() != lower_value );
02116 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02117 if(pDE)
02118 {
02119 pDE->SetToleranceLowerValue( lower_value);
02120 }
02121 }
02122
02123 void ON_DimStyle::SetToleranceHeightScale( double scale)
02124 {
02125 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultToleranceHeightScale() != scale );
02126 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02127 if(pDE)
02128 {
02129 pDE->SetToleranceHeightScale( scale);
02130 }
02131 }
02132
02133 void ON_DimStyle::SetBaselineSpacing( double spacing)
02134 {
02135 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultBaselineSpacing() != spacing );
02136 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02137 if(pDE)
02138 {
02139 pDE->SetBaselineSpacing( spacing);
02140 }
02141 }
02142
02143 bool ON_DimStyle::DrawTextMask() const
02144 {
02145
02146
02147 const ON_DimStyleExtra* pDE = DimStyleExtension();
02148 if(pDE)
02149 return pDE->DrawTextMask();
02150 else
02151 return ON_DimStyle::DefaultDrawTextMask();
02152 }
02153
02154 void ON_DimStyle::SetDrawTextMask(bool bDraw)
02155 {
02156 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultDrawTextMask() != (bDraw?true:false) );
02157 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02158 if(pDE)
02159 pDE->SetDrawTextMask(bDraw);
02160 }
02161
02162 int ON_DimStyle::MaskColorSource() const
02163 {
02164
02165
02166 const ON_DimStyleExtra* pDE = DimStyleExtension();
02167 if(pDE)
02168 return pDE->MaskColorSource();
02169 else
02170 return ON_DimStyle::DefaultMaskColorSource();
02171 }
02172
02173 void ON_DimStyle::SetMaskColorSource(int source)
02174 {
02175 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultMaskColorSource() != source );
02176 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02177 if(pDE)
02178 pDE->SetMaskColorSource(source);
02179 }
02180
02181 ON_Color ON_DimStyle::MaskColor() const
02182 {
02183
02184
02185 const ON_DimStyleExtra* pDE = DimStyleExtension();
02186 if(pDE)
02187 return pDE->MaskColor();
02188 else
02189 return ON_DimStyle::DefaultMaskColor();
02190 }
02191
02192 void ON_DimStyle::SetMaskColor(ON_Color color)
02193 {
02194 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultMaskColor() != color );
02195 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02196 if(pDE)
02197 pDE->SetMaskColor(color);
02198 }
02199
02200 double ON_DimStyle::MaskOffsetFactor() const
02201 {
02202 if(m_textheight != 0.0)
02203 return 0.5 * m_textgap / m_textheight;
02204 else
02205 return 0.0;
02206 }
02207
02208 void ON_DimStyle::SetDimScale(double scale)
02209 {
02210 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultDimScale() != scale );
02211 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02212 if(pDE)
02213 pDE->SetDimScale(scale);
02214 }
02215
02216 double ON_DimStyle::DimScale() const
02217 {
02218
02219
02220 const ON_DimStyleExtra* pDE = DimStyleExtension();
02221 if(pDE)
02222 return pDE->DimScale();
02223 else
02224 return ON_DimStyle::DefaultDimScale();
02225 }
02226
02227 void ON_DimStyle::SetDimScaleSource(int source)
02228 {
02229 bool bCreateIfDoesNotExist = ( ON_DimStyle::DefaultDimScaleSource() != source );
02230 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02231 if(pDE)
02232 pDE->SetDimScaleSource(source);
02233 }
02234
02235 int ON_DimStyle::DimScaleSource() const
02236 {
02237
02238
02239 const ON_DimStyleExtra* pDE = DimStyleExtension();
02240 if(pDE)
02241 return pDE->DimScaleSource();
02242 else
02243 return ON_DimStyle::DefaultDimScaleSource();
02244 }
02245
02246 void ON_DimStyle::SetSourceDimstyle(ON_UUID source_uuid)
02247 {
02248 bool bCreateIfDoesNotExist = ( !(ON_nil_uuid == source_uuid) );
02249 ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet( this, bCreateIfDoesNotExist );
02250 if(pDE)
02251 pDE->SetSourceDimstyle(source_uuid);
02252 }
02253
02254 ON_UUID ON_DimStyle::SourceDimstyle() const
02255 {
02256
02257
02258 const ON_DimStyleExtra* pDE = DimStyleExtension();
02259 if(pDE)
02260 return pDE->SourceDimstyle();
02261 else
02262 return ON_nil_uuid;
02263 }
02264
02265
02266
02267
02268
02269 class ON_DimStyleExtra* ON_DimStyle::DimStyleExtension()
02270 {
02271
02272
02273 ON_DimStyleExtra* pExtra = ON_DimStyleExtra::Cast( GetUserData( ON_DimStyleExtra::m_ON_DimStyleExtra_class_id.Uuid()));
02274 return pExtra;
02275 }
02276
02277 const class ON_DimStyleExtra* ON_DimStyle::DimStyleExtension() const
02278 {
02279
02280
02281 ON_DimStyleExtra* pExtra = ON_DimStyleExtra::Cast( GetUserData( ON_DimStyleExtra::m_ON_DimStyleExtra_class_id.Uuid()));
02282 return pExtra;
02283 }
02284
02285
02286 bool ON_DimStyle::CompareFields(const ON_DimStyle& other) const
02287 {
02288 if((m_extextension != other.m_extextension) ||
02289 (m_extoffset != other.m_extoffset) ||
02290 (m_arrowsize != other.m_arrowsize) ||
02291 (m_centermark != other.m_centermark) ||
02292 (m_textgap != other.m_textgap) ||
02293 (m_textheight != other.m_textheight) ||
02294 (m_textalign != other.m_textalign) ||
02295 (m_arrowtype != other.m_arrowtype) ||
02296 (m_angularunits != other.m_angularunits) ||
02297 (m_lengthformat != other.m_lengthformat) ||
02298 (m_angleformat != other.m_angleformat) ||
02299 (m_angleresolution != other.m_angleresolution) ||
02300 (m_lengthresolution != other.m_lengthresolution) ||
02301 (m_fontindex != other.m_fontindex) ||
02302 (m_lengthfactor != other.m_lengthfactor) ||
02303 (m_bAlternate != other.m_bAlternate) ||
02304 (m_alternate_lengthfactor != other.m_alternate_lengthfactor) ||
02305 (m_alternate_lengthformat != other.m_alternate_lengthformat) ||
02306 (m_alternate_lengthresolution != other.m_alternate_lengthresolution) ||
02307 (m_alternate_angleformat != other.m_alternate_angleformat) ||
02308 (m_alternate_angleresolution != other.m_alternate_angleresolution) ||
02309 (m_prefix != other.m_prefix) ||
02310 (m_suffix != other.m_suffix) ||
02311 (m_alternate_prefix != other.m_alternate_prefix) ||
02312 (m_alternate_suffix != other.m_alternate_suffix) ||
02313 (m_dimextension != other.m_dimextension) ||
02314 (m_leaderarrowsize != other.m_leaderarrowsize) ||
02315 (m_leaderarrowtype != other.m_leaderarrowtype) ||
02316 (m_bSuppressExtension1 != other.m_bSuppressExtension1) ||
02317 (m_bSuppressExtension2 != other.m_bSuppressExtension2))
02318 return false;
02319
02320
02321
02322 const ON_DimStyleExtra* pDEo = ON_DimStyleExtra::DimStyleExtensionGet(&other);
02323 const ON_DimStyleExtra* pDE = ON_DimStyleExtra::DimStyleExtensionGet(this);
02324
02325 if ( 0 != pDEo && 0 != pDE && !pDE->CompareFields(pDEo) )
02326 return false;
02327
02328
02329
02330
02331
02332
02333
02334
02335 if ( 0 == pDEo && 0 != pDE && !pDE->IsDefault() )
02336 return false;
02337
02338 if ( 0 == pDE && 0 != pDEo && !pDEo->IsDefault() )
02339 return false;
02340
02341 return true;
02342 }