As shown in the diagram above, this demonstrates how to add text information at specified positions in the interface. C++
// 1. Obtain the Viewer instance
CATViewer* pViewer = nullptr;
CATFrmLayout* pCurrentLayout = CATFrmLayout::GetCurrentLayout();
if (pCurrentLayout != nullptr)
{
CATFrmWindow* pCurrentWindow = pCurrentLayout->GetCurrentWindow();
if (pCurrentWindow != nullptr)
{
pViewer = pCurrentWindow->GetViewer();
}
}
// 2. Create 2D Bag Representation container
CAT2DBagRep* pRep = new CAT2DBagRep();
pViewer->AddRep(pRep);
// 3. Configure text properties
const float textPosition[2] = {10.0f, -10.0f};
const CATUnicodeString displayText = "112233";
const CAT2DAnnotationAnchor anchorType = BASE_LEFT;
// Initialize text annotation with positioning parameters
CAT2DAnnotationTextRep* pTextAnnotation = new CAT2DAnnotationTextRep(
textPosition,
displayText,
anchorType
);
// 4. Add text element to visualization and update display
if (pTextAnnotation != nullptr)
{
pRep->AddChild(*pTextAnnotation);
}
// Refresh visualization pipeline
pViewer->Draw();
pViewer->Reframe();
来源链接:https://www.cnblogs.com/lianxi528/p/18811055
没有回复内容