Files
envi-code/SourceCode/Code2026/Dimension/TMasterProperties.cpp
T
2026-09-28 15:28:50 +08:00

265 lines
4.4 KiB
C++

#include "StdAfx.h"
#include "globalFunc.h"
#include "TMasterProperties.h"
TMasterProperties::TMasterProperties()
{
m_nColor = 0;
}
TMasterProperties::TMasterProperties(const TMasterProperties &src)
{
*this = src;
}
TMasterProperties::~TMasterProperties()
{
}
TMasterProperties & TMasterProperties::operator = (const TMasterProperties &src)
{
m_idLayer = src.m_idLayer;
m_nColor = src.m_nColor;
m_idLineType = src.m_idLineType;
m_idMaterial = src.m_idMaterial;
return *this;
}
// 从一个图形对象中获得属性
void TMasterProperties::SetFrom(const AcDbEntity *pEnt)
{
int color = pEnt->colorIndex();
AcDbObjectId layer = pEnt->layerId();
AcDbObjectId lineType = pEnt->linetypeId();
if (!m_idLayer)
{
m_idLayer = layer;
}
else
{
if (!!layer)
{
TCString sName = GlobalFunc::GetSymbolName(layer);
if (_tcscmp(sName, _T("0")) != 0)
{
m_idLayer = layer;
}
}
}
if (!m_nColor)
{
m_nColor = color;
}
else
{
if (color > 0 && color <= 256)
{
m_nColor = color;
}
}
if (!m_idLineType)
{
m_idLineType = lineType;
}
else
{
if (!!lineType)
{
TCString sName = GlobalFunc::GetSymbolName(lineType);
if (_tcscmp(sName, _T("BYBLOCK")) != 0)
{
m_idLineType = lineType;
}
}
}
#if ADS > 16
AcDbObjectId material = pEnt->materialId();
if (!m_idMaterial)
{
m_idMaterial = material;
}
else
{
if (!!material)
{
ACHAR *sName = pEnt->material();
if (sName != NULL)
{
if (_tcsicmp(sName, _T("BYBLOCK")) != 0)
{
m_idMaterial = material;
}
acutDelString(sName);
}
}
}
#endif
}
// 从一个图形对象中获得属性
void TMasterProperties::SetFromEx(const AcDbEntity *pEnt)
{
int color = pEnt->colorIndex();
AcDbObjectId layer = pEnt->layerId();
AcDbObjectId lineType = pEnt->linetypeId();
if (!m_idLayer)
{
m_idLayer = layer;
}
else
{
if (!!layer)
{
TCString sName = GlobalFunc::GetSymbolName(layer);
if (_tcscmp(sName, _T("0")) != 0)
{
m_idLayer = layer;
}
}
}
if (color == 256)
{
color = GlobalFunc::GetLayerColor(m_idLayer);
}
if (!m_nColor)
{
m_nColor = color;
}
else
{
if (color > 0 && color <= 256)
{
m_nColor = color;
}
}
if (!m_idLineType)
{
m_idLineType = lineType;
}
else
{
if (!!lineType)
{
TCString sName = GlobalFunc::GetSymbolName(lineType);
if (_tcscmp(sName, _T("BYBLOCK")) != 0)
{
m_idLineType = lineType;
}
}
}
#if ADS > 16
AcDbObjectId material = pEnt->materialId();
if (!m_idMaterial)
{
m_idMaterial = material;
}
else
{
if (!!material)
{
ACHAR *sName = pEnt->material();
if (sName != NULL)
{
if (_tcsicmp(sName, _T("BYBLOCK")) != 0)
{
m_idMaterial = material;
}
acutDelString(sName);
}
}
}
#endif
}
void TMasterProperties::SetTo(AcDbEntity *pEnt) const
{
int nColor = pEnt->colorIndex();
AcDbObjectId idLayer = pEnt->layerId();
AcDbObjectId idLineType = pEnt->linetypeId();
if ((nColor == 0 || nColor > 256) && m_nColor > 0 && m_nColor <= 256)
{
pEnt->setColorIndex(m_nColor);
}
if (!!m_idLayer)
{
if (!idLayer)
{
pEnt->setLayer(m_idLayer);
}
else
{
TCString sName = GlobalFunc::GetSymbolName(idLayer);
if (_tcscmp(sName, _T("0")) == 0)
{
pEnt->setLayer(m_idLayer);
}
}
}
if (!!m_idLineType)
{
if (!idLineType)
{
pEnt->setLinetype(m_idLineType);
}
else
{
TCString sName = GlobalFunc::GetSymbolName(idLineType);
if (sName == _T("BYBLOCK"))
{
pEnt->setLinetype(m_idLineType);
}
}
}
#if ADS > 16
AcDbObjectId idMaterial = pEnt->materialId();
if (!!m_idMaterial)
{
if (!idMaterial)
{
pEnt->setMaterial(m_idMaterial);
}
else
{
ACHAR* sName = pEnt->material();
if (sName!=NULL)
{
if (sName == _T("BYBLOCK"))
{
pEnt->setMaterial(m_idMaterial);
}
acutDelString(sName);
}
}
}
#endif
}
void TMasterProperties::SetTo(AcDbVoidPtrArray &entSet) const
{
int nLen = entSet.length();
for(int i = 0; i < nLen; i++)
{
AcDbEntity *pEnt = (AcDbEntity *)entSet[i];
SetTo(pEnt);
}
}