Sync changes from upstream repository

Co-authored-by: croudyj <croudyj@gmail.com>
Co-authored-by: Dale Fugier <dale@mcneel.com>
Co-authored-by: Dale Lear <dalelear@mcneel.com>
Co-authored-by: piac <giulio@mcneel.com>
Co-authored-by: Steve Baer <steve@mcneel.com>
This commit is contained in:
Bozo The Builder
2022-12-01 15:03:41 -08:00
parent 31c37dea1a
commit 2db8cc1d8a
21 changed files with 1903 additions and 994 deletions

View File

@@ -25,7 +25,10 @@
class ON_3dmObjectAttributesPrivate
{
public:
ON_3dmObjectAttributesPrivate() = delete;
ON_3dmObjectAttributesPrivate(const ON_3dmObjectAttributes* attr);
~ON_3dmObjectAttributesPrivate() = default;
ON_3dmObjectAttributesPrivate& operator=(const ON_3dmObjectAttributesPrivate&) = default;
bool operator==(const ON_3dmObjectAttributesPrivate&) const;
bool operator!=(const ON_3dmObjectAttributesPrivate&) const;
@@ -43,6 +46,8 @@ public:
ON_Color m_hatch_background_fill;
bool m_hatch_boundary_visible = false;
std::shared_ptr<ON_Linetype> m_custom_linetype;
ON_DecalCollection m_decals;
ON_MeshModifiers m_mesh_modifiers;
};
@@ -89,6 +94,11 @@ bool ON_3dmObjectAttributesPrivate::operator==(const ON_3dmObjectAttributesPriva
if (m_hatch_boundary_visible != other.m_hatch_boundary_visible)
return false;
const ON_Linetype* customThis = m_custom_linetype.get();
const ON_Linetype* customOther = other.m_custom_linetype.get();
if (customThis != customOther)
return false;
return true;
}
@@ -415,10 +425,15 @@ enum ON_3dmObjectAttributesTypeCodes : unsigned char
// 26 Jan 2022 Andy Le Bihan
// file version 2.8: object frame
ObjectFrame = 36,
// 15 Jun 2022 S. Baer (file version 2.9) - SectionFillRule
// 15 Jun 2022 S. Baer
// file version 2.9: SectionFillRule
SectionFillRule = 37,
// 30 Nov 2022 S. Baer
// file version 2.10: custom linetype
CustomLinetype = 38,
// add items here
LastAttributeTypeCode = 37
LastAttributeTypeCode = 38
};
bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file )
@@ -745,7 +760,7 @@ bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file )
double scale = 1.0;
rc = file.ReadDouble(&scale);
if (!rc) break;
SetLinetypeScale(scale);
SetLinetypePatternScale(scale);
rc = file.ReadChar(&itemid);
if (!rc || 0 == itemid) break;
}
@@ -811,6 +826,21 @@ bool ON_3dmObjectAttributes::Internal_ReadV5( ON_BinaryArchive& file )
if (minor_version <= 9)
break;
if (ON_3dmObjectAttributesTypeCodes::CustomLinetype == itemid) // 38
{
ON_Linetype lt;
rc = lt.Read(file);
if (!rc) break;
SetCustomLinetype(lt);
rc = file.ReadChar(&itemid);
if (!rc || 0 == itemid) break;
}
if (minor_version <= 10)
break;
// Add new item reading above and increment the LastAttributeTypeCode value
// in the enum. Be sure to test reading of old and new files by old and new
// code, before checking in your changes.
@@ -1005,7 +1035,9 @@ bool ON_3dmObjectAttributes::Internal_WriteV5( ON_BinaryArchive& file ) const
// Chunk version = 2.8 to support object frame.
// 15 Jun 2022 S. Baer
// Chunk version = 2.9 to support SectionFillRule
bool rc = file.Write3dmChunkVersion(2,9);
// 30 Nov 2022 S. Baer
// Chunk version = 2.10 to support
bool rc = file.Write3dmChunkVersion(2,10);
while(rc)
{
if (!rc) break;
@@ -1277,12 +1309,12 @@ bool ON_3dmObjectAttributes::Internal_WriteV5( ON_BinaryArchive& file ) const
if (!rc) break;
}
if (fabs(1.0 - LinetypeScale()) > ON_EPSILON)
if (fabs(1.0 - LinetypePatternScale()) > ON_EPSILON)
{
c = ON_3dmObjectAttributesTypeCodes::LinetypeScale; // 33
rc = file.WriteChar(c);
if (!rc) break;
rc = file.WriteDouble(LinetypeScale());
rc = file.WriteDouble(LinetypePatternScale());
if (!rc) break;
}
@@ -1336,6 +1368,19 @@ bool ON_3dmObjectAttributes::Internal_WriteV5( ON_BinaryArchive& file ) const
if (!rc) break;
}
// 30 Nov 2022 S. Baer
// Write custom linetype
{
const ON_Linetype* linetype = CustomLinetype();
if (linetype)
{
c = ON_3dmObjectAttributesTypeCodes::CustomLinetype; // 38
rc = file.WriteChar(c);
if (!rc) break;
rc = linetype->Write(file);
if (!rc) break;
}
}
// 0 indicates end of attributes - this should be the last item written
c = 0;
@@ -1586,6 +1631,16 @@ void ON_3dmObjectAttributes::Dump( ON_TextLog& dump ) const
}
dump.Print("\n");
}
const ON_Linetype* linetype = CustomLinetype();
if (nullptr == linetype)
{
dump.Print("no custom linetype\n");
}
else
{
dump.Print("contains custom linetype\n");
}
}
ON::object_mode ON_3dmObjectAttributes::Mode() const
@@ -2344,16 +2399,16 @@ void ON_3dmObjectAttributes::SetSectionAttributesSource(ON::SectionAttributesSou
m_private->m_section_attributes_source = source;
}
double ON_3dmObjectAttributes::LinetypeScale() const
double ON_3dmObjectAttributes::LinetypePatternScale() const
{
return m_private ? m_private->m_linetype_scale : 1.0;
}
void ON_3dmObjectAttributes::SetLinetypeScale(double scale)
void ON_3dmObjectAttributes::SetLinetypePatternScale(double scale)
{
if (scale < ON_EPSILON)
return;
if (fabs(LinetypeScale() - scale) < ON_EPSILON)
if (fabs(LinetypePatternScale() - scale) < ON_EPSILON)
return;
if (nullptr == m_private)
@@ -2361,6 +2416,27 @@ void ON_3dmObjectAttributes::SetLinetypeScale(double scale)
m_private->m_linetype_scale = scale;
}
void ON_3dmObjectAttributes::SetCustomLinetype(const ON_Linetype& linetype)
{
if (nullptr == m_private)
m_private = new ON_3dmObjectAttributesPrivate(this);
m_private->m_custom_linetype.reset(new ON_Linetype(linetype));
}
const ON_Linetype* ON_3dmObjectAttributes::CustomLinetype() const
{
const ON_Linetype* rc = nullptr;
if (m_private)
rc = m_private->m_custom_linetype.get();
return rc;
}
void ON_3dmObjectAttributes::RemoveCustomLinetype()
{
if (m_private)
m_private->m_custom_linetype.reset();
}
ON_Color ON_3dmObjectAttributes::HatchBackgroundFillColor() const
{
return m_private ? m_private->m_hatch_background_fill : ON_Color::UnsetColor;
@@ -2392,7 +2468,6 @@ void ON_3dmObjectAttributes::SetHatchBoundaryVisible(bool on)
}
//https://mcneel.myjetbrains.com/youtrack/issue/RH-20531
ON_Plane ON_3dmObjectAttributes::ObjectFrame(const ON_COMPONENT_INDEX& ci) const
{