Files
envi-code/SourceCode/Code2026/AdsXRx/XMasterProperties.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

277 lines
4.8 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, SH Software Co. Ltd.
// = FileName : XMasterProperties 类
// = Version : ver2.0
// = Author : zjq
// = CreateDate : 2002-09-09
// = Description: XMasterProperties 定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "XMasterProperties.h"
#include "XGlobalFunc.h"
XMasterProperties::XMasterProperties()
{
m_nColor = 0;
}
XMasterProperties::XMasterProperties(const XMasterProperties &src)
{
*this = src;
}
XMasterProperties::~XMasterProperties()
{
}
XMasterProperties & XMasterProperties::operator = (const XMasterProperties &src)
{
m_idLayer = src.m_idLayer;
m_nColor = src.m_nColor;
m_idLineType = src.m_idLineType;
m_idMaterial = src.m_idMaterial;
return *this;
}
// 从一个图形对象中获得属性
void XMasterProperties::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)
{
XString sName = XExport::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)
{
XString sName = XExport::GetSymbolName(lineType);
if (_tcscmp(sName, _T("BYBLOCK")) != 0)
{
m_idLineType = lineType;
}
}
}
#if ARX > 17
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 XMasterProperties::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)
{
XString sName = XExport::GetSymbolName(layer);
if (_tcscmp(sName, _T("0")) != 0)
{
m_idLayer = layer;
}
}
}
if (color == 256)
{
color = 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)
{
XString sName = XExport::GetSymbolName(lineType);
if (_tcscmp(sName, _T("BYBLOCK")) != 0)
{
m_idLineType = lineType;
}
}
}
#if ARX > 17
AcDbObjectId material = pEnt->materialId();
if (m_idMaterial.isNull())
{
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 XMasterProperties::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
{
XString sName = XExport::GetSymbolName(idLayer);
if (_tcscmp(sName, _T("0")) == 0)
{
pEnt->setLayer(m_idLayer);
}
}
}
if (!!m_idLineType)
{
if (!idLineType)
{
pEnt->setLinetype(m_idLineType);
}
else
{
XString sName = XExport::GetSymbolName(idLineType);
if (sName == _T("BYBLOCK"))
{
pEnt->setLinetype(m_idLineType);
}
}
}
#if ARX > 17
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 XMasterProperties::SetTo(AcDbVoidPtrArray &entSet) const
{
int nLen = entSet.length();
for(int i = 0; i < nLen; i++)
{
AcDbEntity *pEnt = (AcDbEntity *)entSet[i];
SetTo(pEnt);
}
}