本文整理汇总了C++中TextRenderer::addText方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRenderer::addText方法的具体用法?C++ TextRenderer::addText怎么用?C++ TextRenderer::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRenderer
的用法示例。
在下文中一共展示了TextRenderer::addText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showDistance
void Viewer_impl::showDistance(QPoint pixel)
{
static bool isAset = false;
bool found;
CGAL::qglviewer::Vec point;
point = viewer->camera()->pointUnderPixel(pixel, found);
if(!isAset && found)
{
//set APoint
APoint = point;
isAset = true;
clearDistancedisplay();
}
else if (found)
{
//set BPoint
BPoint = point;
isAset = false;
// fills the buffers
std::vector<float> v;
v.resize(6);
v[0] = float(APoint.x); v[1] = float(APoint.y); v[2] = float(APoint.z);
v[3] = float(BPoint.x); v[4] = float(BPoint.y); v[5] = float(BPoint.z);
vao.bind();
buffer.bind();
buffer.allocate(v.data(),6*sizeof(float));
rendering_program_dist.enableAttributeArray("vertex");
rendering_program_dist.setAttributeBuffer("vertex",GL_FLOAT,0,3);
buffer.release();
vao.release();
distance_is_displayed = true;
double dist = std::sqrt((BPoint.x-APoint.x)*(BPoint.x-APoint.x) + (BPoint.y-APoint.y)*(BPoint.y-APoint.y) + (BPoint.z-APoint.z)*(BPoint.z-APoint.z));
QFont font;
font.setBold(true);
TextItem *ACoord = new TextItem(float(APoint.x),
float(APoint.y),
float(APoint.z),
QString("A(%1,%2,%3)").arg(APoint.x-viewer->offset().x).arg(APoint.y-viewer->offset().y).arg(APoint.z-viewer->offset().z), true, font, Qt::red, true);
distance_text.append(ACoord);
TextItem *BCoord = new TextItem(float(BPoint.x),
float(BPoint.y),
float(BPoint.z),
QString("B(%1,%2,%3)").arg(BPoint.x-viewer->offset().x).arg(BPoint.y-viewer->offset().y).arg(BPoint.z-viewer->offset().z), true, font, Qt::red, true);
distance_text.append(BCoord);
CGAL::qglviewer::Vec centerPoint = 0.5*(BPoint+APoint);
TextItem *centerCoord = new TextItem(float(centerPoint.x),
float(centerPoint.y),
float(centerPoint.z),
QString(" distance: %1").arg(dist), true, font, Qt::red, true);
distance_text.append(centerCoord);
Q_FOREACH(TextItem* ti, distance_text)
textRenderer->addText(ti);
Q_EMIT(viewer->sendMessage(QString("First point : A(%1,%2,%3), second point : B(%4,%5,%6), distance between them : %7")
.arg(APoint.x-viewer->offset().x)
.arg(APoint.y-viewer->offset().y)
.arg(APoint.z-viewer->offset().z)
.arg(BPoint.x-viewer->offset().x)
.arg(BPoint.y-viewer->offset().y)
.arg(BPoint.z-viewer->offset().z)
.arg(dist)));
}
}