opencascade AIS_GlobalStatus管理交互式对象显示信息 源码学习

前言

存储有关图形上下文中对象的信息:

方法

AIS_GlobalStatus类的翻译

构造函数
AIS_GlobalStatus()

AIS_GlobalStatus::AIS_GlobalStatus ( )

默认构造函数。

成员函数文档
AddSelectionMode()

Standard_Boolean AIS_GlobalStatus::AddSelectionMode (const Standard_Integer theMode) inline

添加选择模式。

ClearSelectionModes()

void AIS_GlobalStatus::ClearSelectionModes ( ) inline

删除所有选择模式。

DisplayMode()

Standard_Integer AIS_GlobalStatus::DisplayMode ( ) const inline

返回显示模式。

HilightStyle()

const Handle<Prs3d_Drawer>& AIS_GlobalStatus::HilightStyle ( ) const inline

返回特定对象应用的高亮样式。

IsHilighted()

Standard_Boolean AIS_GlobalStatus::IsHilighted ( ) const inline

如果对象被高亮,则返回TRUE。

IsSModeIn()

Standard_Boolean AIS_GlobalStatus::IsSModeIn (Standard_Integer theMode) const inline

如果选择模式已注册,则返回TRUE。

IsSubIntensityOn()

Standard_Boolean AIS_GlobalStatus::IsSubIntensityOn ( ) const inline

返回子强度状态是否开启。

RemoveSelectionMode()

Standard_Boolean AIS_GlobalStatus::RemoveSelectionMode (const Standard_Integer theMode) inline

删除选择模式。

SelectionModes()

const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes ( ) const inline

返回对象的活动选择模式。

SetDisplayMode()

void AIS_GlobalStatus::SetDisplayMode (const Standard_Integer theMode) inline

设置显示模式。

SetHilightStatus()

void AIS_GlobalStatus::SetHilightStatus (const Standard_Boolean theStatus) inline

设置高亮状态。

SetHilightStyle()

void AIS_GlobalStatus::SetHilightStyle (const Handle<Prs3d_Drawer>& theStyle) inline

更改特定对象应用的高亮样式。

SetSubIntensity()

void AIS_GlobalStatus::SetSubIntensity (Standard_Boolean theIsOn)

设置子强度状态。

示例

以下是一个关于如何使用 AIS_GlobalStatus 类的示例。此示例展示了如何创建 AIS_GlobalStatus 对象,并设置和获取各种属性,例如选择模式、显示模式和高亮状态。

cpp 复制代码
#include <AIS_GlobalStatus.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <Prs3d_Drawer.hxx>
#include <Handle.hxx>

int main()
{
    // 创建AIS_GlobalStatus对象
    AIS_GlobalStatus globalStatus;

    // 添加选择模式
    globalStatus.AddSelectionMode(1);
    globalStatus.AddSelectionMode(2);

    // 设置显示模式
    globalStatus.SetDisplayMode(3);

    // 设置高亮样式
    Handle(Prs3d_Drawer) hilightStyle = new Prs3d_Drawer();
    globalStatus.SetHilightStyle(hilightStyle);

    // 设置高亮状态
    globalStatus.SetHilightStatus(Standard_True);

    // 打印当前高亮状态
    if (globalStatus.IsHilighted())
    {
        std::cout << "The object is highlighted." << std::endl;
    }
    else
    {
        std::cout << "The object is not highlighted." << std::endl;
    }

    // 检查选择模式是否已注册
    if (globalStatus.IsSModeIn(1))
    {
        std::cout << "Selection mode 1 is registered." << std::endl;
    }
    else
    {
        std::cout << "Selection mode 1 is not registered." << std::endl;
    }

    // 获取当前显示模式
    Standard_Integer displayMode = globalStatus.DisplayMode();
    std::cout << "Current display mode: " << displayMode << std::endl;

    // 获取所有选择模式
    const TColStd_ListOfInteger& selectionModes = globalStatus.SelectionModes();
    std::cout << "Active selection modes: ";
    for (TColStd_ListOfInteger::Iterator it(selectionModes); it.More(); it.Next())
    {
        std::cout << it.Value() << " ";
    }
    std::cout << std::endl;

    // 清除所有选择模式
    globalStatus.ClearSelectionModes();

    // 确认选择模式已被清除
    if (!globalStatus.IsSModeIn(1))
    {
        std::cout << "Selection modes have been cleared." << std::endl;
    }

    return 0;
}

代码解释

  1. 创建 AIS_GlobalStatus 对象 : AIS_GlobalStatus globalStatus;
  2. 添加选择模式 : 使用 AddSelectionMode 方法添加选择模式,例如模式 1 和模式 2。
  3. 设置显示模式 : 使用 SetDisplayMode 方法设置显示模式,例如模式 3。
  4. 设置高亮样式 : 创建 Prs3d_Drawer 对象并使用 SetHilightStyle 方法设置高亮样式。
  5. 设置高亮状态 : 使用 SetHilightStatus 方法将高亮状态设置为 Standard_True
  6. 打印当前高亮状态 : 使用 IsHilighted 方法检查对象是否被高亮,并输出结果。
  7. 检查选择模式是否已注册 : 使用 IsSModeIn 方法检查选择模式 1 是否已注册,并输出结果。
  8. 获取当前显示模式 : 使用 DisplayMode 方法获取当前显示模式,并输出结果。
  9. 获取所有选择模式 : 使用 SelectionModes 方法获取活动的选择模式,并输出结果。
  10. 清除所有选择模式 : 使用 ClearSelectionModes 方法清除所有选择模式。
  11. 确认选择模式已被清除 : 使用 IsSModeIn 方法确认选择模式已被清除,并输出结果。

通过这个示例,您可以了解如何使用 AIS_GlobalStatus 类的各种功能来管理和操作对象的显示和选择模式。

相关推荐
醉暮天40 分钟前
4.25学习——文件上传之00截断
学习
blackA_4 小时前
数据库MySQL学习——day4(更多查询操作与更新数据)
数据库·学习·mysql
梁下轻语的秋缘6 小时前
每日c/c++题 备战蓝桥杯(P1049 [NOIP 2001 普及组] 装箱问题)
c语言·c++·学习·蓝桥杯
球求了7 小时前
C++:继承机制详解
开发语言·c++·学习
时光追逐者7 小时前
MongoDB从入门到实战之MongoDB快速入门(附带学习路线图)
数据库·学习·mongodb
一弓虽7 小时前
SpringBoot 学习
java·spring boot·后端·学习
genggeng不会代码9 小时前
用于协同显著目标检测的小组协作学习 2021 GCoNet(总结)
学习
搞机小能手9 小时前
六个能够白嫖学习资料的网站
笔记·学习·分类
The_cute_cat12 小时前
25.4.22学习总结
学习
冰茶_12 小时前
.NET MAUI 发展历程:从 Xamarin 到现代跨平台应用开发框架
学习·microsoft·微软·c#·.net·xamarin