在NX二次开发当中,我们经常需要高亮一个或者多个对象,或者设置对象的颜色方便实现,直接调用函数稍微显得麻烦,尤其是当我们需要处理的对象是容器的时候,于是我写了几个简单的模板实现,方便调试。
//author:autumoon
//邮箱:9506@163.com
//日期:2023-07-05
//修改原因:方便调试显示
template <typename T>
void HighlightObjects(const std::set<T*>& sObjects, int action_switch = 1)
{
for (auto s = sObjects.begin(); s != sObjects.end(); ++s)
{
TaggedObject* pObject = static_cast<TaggedObject*>(*s);
if (pObject)
{
UF_DISP_set_highlight(pObject->Tag(), action_switch);
}
}
}
template <typename T>
void HighlightObjects(const std::vector<T*>& vObjects, int action_switch = 1)
{
for (auto s = vObjects.begin(); s != vObjects.end(); ++s)
{
TaggedObject* pObject = static_cast<TaggedObject*>(*s);
if (pObject)
{
UF_DISP_set_highlight(pObject->Tag(), action_switch);
}
}
}
//修改原因:跟边界设置颜色,方便调试
template <typename T>
void ColorObject(const std::set<T*>& sObjects, int nColor = 2)
{
for (auto s = sObjects.begin(); s != sObjects.end(); ++s)
{
DisplayableObject* pObject = static_cast<DisplayableObject*>(*s);
if (pObject)
{
pObject->SetColor(nColor);
pObject->RedisplayObject();
}
}
}
template <typename T>
void ColorObject(const std::vector<T*>& vObjects, int nColor = 2)
{
for (auto s = vObjects.begin(); s != vObjects.end(); ++s)
{
DisplayableObject* pObject = static_cast<DisplayableObject*>(*s);
if (pObject)
{
pObject->SetColor(nColor);
pObject->RedisplayObject();
}
}
}
欢迎交流与讨论。