V5-3D环境下Pick点坐标的计算

在3D环境下获取面上的点击位置,该处理需要依托于输入面的Agent:

    // 面输入Agent
    _pPlaneAgent = new CATPathElementAgent ("PlaneAgent");
    if (NULL != _pPlaneAgent)
    {
        _pPlaneAgent -> SetOrderedElementType (CATPlane::ClassName());
        _pPlaneAgent->SetBehavior(CATDlgEngWithPrevaluation | CATDlgEngWithCSO | CATDlgEngOneShot);
    }

建立其关联响应函数:

    AddTransition( initialState, initialState, 
        IsOutputSetCondition (_pPlaneAgent),
        Action ((ActionMethod) &TSTFaceDirectionCmd::ActionFaceInout));

头文件中添加:

#include "CATEventSubscriberTypedefs.h"
#include "CATViewer.h"
······
CATViewer*          _pCurrentView;
CATCallback         _ViewFeedBack;

Cpp中:对于Pick点坐标的求解需要附加到相对应的面输入的Agent响应函数:

_pPlaneAgent->InitializeAcquisition(); 

    //////////////////////////////////////////////////////////////////////////
    // pick点的实验代码
    // 添加一个Callback响应点的获取
    CATFrmLayout*   pCurrentLayout = CATFrmLayout::GetCurrentLayout();
    if (NULL == pCurrentLayout)
    {
        return FALSE;
    }
    CATFrmWindow*   pCurrentWindow = pCurrentLayout->GetCurrentWindow();
    if (NULL == pCurrentWindow)
    {
        return FALSE;
    }
    _pCurrentView = pCurrentWindow->GetViewer();
    if (NULL == _pCurrentView)
    {
        return FALSE;
    }
    _pCurrentView->SetFeedbackMode(TRUE);
    
    _ViewFeedBack = ::AddCallback (this,_pCurrentView, CATViewer::VIEWER_FEEDBACK_UPDATE(),
        (CATSubscriberMethod)&TSTFaceDirectionCmd::OnViewFeedbackCB);

添加相对应的响应函数:

void TSTFaceDirectionCmd::OnViewFeedbackCB(
    CATCallbackEvent event,
    void* client,
    CATNotification *iNotification,
    CATSubscriberData data,
    CATCallback callbcak)
{ 
    _pCurrentView->SetFeedbackMode(FALSE);
    ::RemoveCallback(this,_pCurrentView,_ViewFeedBack);
    CATVisViewerFeedbackEvent* pFeedbackEvent = NULL;

    pFeedbackEvent = (CATVisViewerFeedbackEvent*) iNotification;
    CATGraphicElementIntersection* pIntersection = pFeedbackEvent->GetIntersection();

    double PtrPoint[3];
    PtrPoint[0] = pIntersection->point.GetX();
    PtrPoint[1] = pIntersection->point.GetY();
    PtrPoint[2] = pIntersection->point.GetZ();
    return;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容