本文整理汇总了C++中Viewer::camera方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::camera方法的具体用法?C++ Viewer::camera怎么用?C++ Viewer::camera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewer
的用法示例。
在下文中一共展示了Viewer::camera方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawLabel
void Atom::drawLabel(Viewer& viewer, LabelType const type, QFontMetrics& fontMetrics)
{
Vec pos(getPosition());
Vec shift = viewer.camera()->position() - pos;
shift.normalize();
QString label(getLabel(type));
pos = pos + 1.05 * shift * getRadius(true);
pos = viewer.camera()->projectedCoordinatesOf(pos);
pos.x -= fontMetrics.width(label)/2.0;
pos.y += fontMetrics.height()/4.0;
pos = viewer.camera()->unprojectedCoordinatesOf(pos);
glColor3f(0.1, 0.1, 0.1);
viewer.renderText(pos[0], pos[1], pos[2], label, viewer.labelFont());
}
示例2: mouseMoveEvent
/*
* Event: mouse move
* We change the scene center in the main viewer
*/
void MiniViewer::mouseMoveEvent(QMouseEvent* const e) {
qglviewer::Vec point;
Viewer* mainViewer = parent->Viewer1;
mainViewer->setSceneCenter(convertPoint(e->pos()));
mainViewer->camera()->centerScene();
mainViewer->updateGL();
//mainViewer->draw_cross();
refresh();
}
示例3: 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)));
}
}