opencascade AIS_ManipulatorOwner AIS_MediaPlayer源码学习
创始人
2024-12-03 20:33:11
0

在这里插入图片描述

前言

AIS_ManipulatorOwner是OpenCascade中的一个类,主要用于操纵对象的交互控制。AIS_ManipulatorOwner结合AIS_Manipulator类,允许用户通过可视化工具(如旋转、平移、缩放等)来操纵几何对象。

以下是AIS_ManipulatorOwner的基本用法介绍:

1. 包含必要的头文件

首先,确保在代码中包含必要的OpenCascade头文件:

#include  #include  #include  #include  #include  #include  #include  

2. 创建几何对象和上下文

创建一个几何对象,并初始化一个AIS_InteractiveContext

Handle(AIS_InteractiveContext) context = ...; // 已初始化的交互上下文 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(100.0, 100.0, 100.0).Shape(); Handle(AIS_Shape) aShapeAIS = new AIS_Shape(aShape); context->Display(aShapeAIS, Standard_True); 

3. 创建和设置Manipulator

创建一个Manipulator,并将其与几何对象关联:

Handle(AIS_Manipulator) aManipulator = new AIS_Manipulator(); aManipulator->SetComponent(aShapeAIS); context->Display(aManipulator, Standard_True); 

4. 创建ManipulatorOwner

创建一个AIS_ManipulatorOwner,并将其与Manipulator关联:

Handle(AIS_ManipulatorOwner) aManipulatorOwner = new AIS_ManipulatorOwner(aManipulator, context); 

5. 操纵几何对象

通过ManipulatorOwner,可以对几何对象进行旋转、平移和缩放等操作。例如:

gp_Trsf transformation; transformation.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); // 平移10单位 aManipulatorOwner->SetLocalTransformation(transformation); context->Redisplay(aShapeAIS, Standard_True); 

6. 交互操作

用户可以通过鼠标操作与几何对象进行交互。AIS_InteractiveContext提供了许多方法来处理鼠标事件并相应地更新几何对象的位置。

// 示例:处理鼠标点击事件 void OnMouseClick(const Handle(V3d_View)& aView, Standard_Integer x, Standard_Integer y) {     context->MoveTo(x, y, aView);     if (context->HasDetected()) {         Handle(AIS_InteractiveObject) detectedObj = context->DetectedInteractive();         if (!detectedObj.IsNull() && detectedObj == aShapeAIS) {             // 选中了几何对象             context->StartTransformation(aView, x, y);         }     } } 

总结

AIS_ManipulatorOwner是一个强大的工具,可以帮助用户通过图形界面与几何对象进行交互。通过设置适当的变换矩阵,可以实现对对象的各种操作,从而极大地增强了用户的交互体验。

AIS_MediaPlayer

在这里插入图片描述
视频播放演示。

方法

1

空构造函数。
Standard_EXPORT AIS_MediaPlayer();

2

析构函数。
Standard_EXPORT virtual ~AIS_MediaPlayer();

3

设置回调函数,用于在队列进度时调用(例如,当需要显示新帧时)。
void SetCallback (Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr)
{
myFramePair->SetCallback (theCallbackFunction, theCallbackUserPtr);
}

4

打开指定文件。
Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath,
Standard_Boolean theToWait);

5

显示新帧。
Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize);

6

返回播放器上下文。
const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); }

7

切换播放状态。
Standard_EXPORT void PlayPause();

8

安排关闭播放器。
void SetClosePlayer()
{
myToClosePlayer = true;
myFramePair->Notify();
}

9

返回持续时间。
double Duration() const { return myFramePair->Duration(); }

//! @name AIS_InteractiveObject 接口
protected:

10

仅接受显示模式0。
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }

11

计算演示文稿。
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;

12

计算选择。
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;

13

更新帧大小。
Standard_EXPORT bool updateSize (const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize);

参考

相关内容

热门资讯

透视攻略"aapok... 透视攻略"aapoker怎么设置提高好牌几率"切实是有挂(透视)普及教程(有挂教程)1、aapoke...
透视实锤!aapoker怎么设... 透视实锤!aapoker怎么设置提高好牌几率(透视)真的假的(本来存在有挂)1、aapoker怎么设...
透视ai代打!uupoker透... 透视ai代打!uupoker透视,原先是有挂(透视)攻略方法(有挂方法)1、任何uupoker透视a...
透视黑科技"poke... 透视黑科技"pokernow辅助控制"一贯有挂(透视)2025版教程(有挂介绍)1、上手简单,内置详...
透视模拟器!aapoker破解... 透视模拟器!aapoker破解侠是真的吗(透视)ai插件(一直真的是有挂);aapoker破解侠是真...
透视模拟器!wepoker透视... 透视模拟器!wepoker透视底牌,素来是真的有挂(透视)揭秘教程(有挂技巧);wepoker透视底...
透视规律!aapoker辅助器... 透视规律!aapoker辅助器怎么用(透视)插件下载(竟然存在有挂)1、金币登录送、破产送、升级送、...
透视黑科技"soho... 透视黑科技"sohoo辅助"原来有挂(透视)爆料教程(有挂方法)1、sohoo辅助ai辅助优化,so...
透视智能ai!wepoker有... 透视智能ai!wepoker有没有挂,最初存在有挂(透视)详细教程(有挂细节)1、wepoker有没...
透视插件"竞技联盟辅... 透视插件"竞技联盟辅助插件"原来是真的有挂(透视)扑克教程(有挂脚本)1、起透看视 竞技联盟辅助插件...