本文整理汇总了C++中QOpenGLFunctions_2_1::glPopName方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glPopName方法的具体用法?C++ QOpenGLFunctions_2_1::glPopName怎么用?C++ QOpenGLFunctions_2_1::glPopName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glPopName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tab
//.........这里部分代码省略.........
255 - context.labelDefaultBkgCol.g,
255 - context.labelDefaultBkgCol.b);
}
//label title
context.display->displayText( title,
xStart+xStartRel,
yStart+yStartRel,
ccGenericGLDisplay::ALIGN_DEFAULT,
0,
defaultTextColor.rgb,
&titleFont);
yStartRel -= margin;
if (m_showFullBody)
{
#ifdef DRAW_CONTENT_AS_TAB
int xCol = xStartRel;
for (int c=0; c<tab.colCount; ++c)
{
int width = tab.colWidth[c] + 2*tabMarginX;
int height = rowHeight + 2*tabMarginY;
int yRow = yStartRel;
int actualRowCount = std::min(tab.rowCount,tab.colContent[c].size());
bool labelCol = ((c & 1) == 0);
const unsigned char* textColor = labelCol ? ccColor::white.rgba : defaultTextColor.rgb;
for (int r=0; r<actualRowCount; ++r)
{
if (r && (r % 3) == 0)
yRow -= margin;
if (labelCol)
{
//draw background
int rgbIndex = (r % 3);
if (rgbIndex == 0)
glFunc->glColor3ubv(ccColor::red.rgba);
else if (rgbIndex == 1)
glFunc->glColor3ubv(c_darkGreen.rgba);
else if (rgbIndex == 2)
glFunc->glColor3ubv(ccColor::blue.rgba);
glFunc->glBegin(GL_QUADS);
glFunc->glVertex2i(m_labelROI.left() + xCol, -m_labelROI.top() + yRow);
glFunc->glVertex2i(m_labelROI.left() + xCol, -m_labelROI.top() + yRow - height);
glFunc->glVertex2i(m_labelROI.left() + xCol + width, -m_labelROI.top() + yRow - height);
glFunc->glVertex2i(m_labelROI.left() + xCol + width, -m_labelROI.top() + yRow);
glFunc->glEnd();
}
const QString& str = tab.colContent[c][r];
int xShift = 0;
if (labelCol)
{
//align characters in the middle
xShift = (tab.colWidth[c] - QFontMetrics(bodyFont).width(str)) / 2;
}
else
{
//align digits on the right
xShift = tab.colWidth[c] - QFontMetrics(bodyFont).width(str);
}
context.display->displayText( str,
xStart + xCol + tabMarginX + xShift,
yStart + yRow - rowHeight, ccGenericGLDisplay::ALIGN_DEFAULT, 0, textColor, &bodyFont);
yRow -= height;
}
xCol += width;
}
#else
if (!body.empty())
{
//display body
yStartRel -= margin;
for (int i=0; i<body.size(); ++i)
{
yStartRel -= rowHeight;
context.display->displayText(body[i],xStart+xStartRel,yStart+yStartRel,ccGenericGLDisplay::ALIGN_DEFAULT,0,defaultTextColor.rgb,&bodyFont);
}
}
#endif //DRAW_CONTENT_AS_TAB
}
}
glFunc->glPopAttrib();
glFunc->glPopMatrix();
if (pushName)
{
glFunc->glPopName();
}
}
示例2: font
//.........这里部分代码省略.........
}
case 1:
{
//display point marker as spheres
{
if (!c_unitPointMarker)
{
c_unitPointMarker = QSharedPointer<ccSphere>(new ccSphere(1.0f, 0, "PointMarker", 12));
c_unitPointMarker->showColors(true);
c_unitPointMarker->setVisible(true);
c_unitPointMarker->setEnabled(true);
}
//build-up point maker own 'context'
CC_DRAW_CONTEXT markerContext = context;
markerContext.drawingFlags &= (~CC_DRAW_ENTITY_NAMES); //we must remove the 'push name flag' so that the sphere doesn't push its own!
markerContext.display = 0;
if (isSelected() && !pushName)
c_unitPointMarker->setTempColor(ccColor::red);
else
c_unitPointMarker->setTempColor(context.labelDefaultMarkerCol);
const ccViewportParameters& viewPortParams = context.display->getViewportParameters();
ccGLCameraParameters camera;
context.display->getGLCameraParameters(camera);
for (unsigned i = 0; i<count; i++)
{
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
const CCVector3* P = m_points[i].cloud->getPoint(m_points[i].index);
ccGL::Translate(glFunc, P->x, P->y, P->z);
float scale = context.labelMarkerSize * m_relMarkerScale;
if (viewPortParams.perspectiveView && viewPortParams.zFar > 0)
{
//in perspective view, the actual scale depends on the distance to the camera!
const double* M = camera.modelViewMat.data();
double d = (camera.modelViewMat * CCVector3d::fromArray(P->u)).norm();
double unitD = viewPortParams.zFar / 2; //we consider that the 'standard' scale is at half the depth
scale = static_cast<float>(scale * sqrt(d / unitD)); //sqrt = empirical (probably because the marker size is already partly compensated by ccGLWindow::computeActualPixelSize())
}
glFunc->glScalef(scale, scale, scale);
c_unitPointMarker->draw(markerContext);
glFunc->glPopMatrix();
}
}
if (m_dispIn3D && !pushName) //no need to display label in point picking mode
{
QFont font(context.display->getTextDisplayFont()); //takes rendering zoom into account!
//font.setPointSize(font.pointSize()+2);
font.setBold(true);
static const QChar ABC[3] = {'A','B','C'};
//we can't use the context 'ccGLCameraParameters' (viewport, modelView matrix, etc. )
//because it doesn't take the temporary 'GL transformation' into account!
ccGLCameraParameters camera;
//context.display->getGLCameraParameters(camera);
glFunc->glGetIntegerv(GL_VIEWPORT, camera.viewport);
glFunc->glGetDoublev(GL_PROJECTION_MATRIX, camera.projectionMat.data());
glFunc->glGetDoublev(GL_MODELVIEW_MATRIX, camera.modelViewMat.data());
//draw their name
glFunc->glPushAttrib(GL_DEPTH_BUFFER_BIT);
glFunc->glDisable(GL_DEPTH_TEST);
for (unsigned j=0; j<count; j++)
{
const CCVector3* P = m_points[j].cloud->getPoint(m_points[j].index);
QString title;
if (count == 1)
title = getName(); //for single-point labels we prefer the name
else if (count == 3)
title = ABC[j]; //for triangle-labels, we only display "A","B","C"
else
title = QString("P#%0").arg(m_points[j].index);
//project it in 2D screen coordinates
CCVector3d Q2D;
camera.project(*P, Q2D);
context.display->displayText( title,
static_cast<int>(Q2D.x) + context.labelMarkerTextShift_pix,
static_cast<int>(Q2D.y) + context.labelMarkerTextShift_pix,
ccGenericGLDisplay::ALIGN_DEFAULT,
context.labelOpacity / 100.0f,
ccColor::white.rgba,
&font );
}
glFunc->glPopAttrib();
}
}
}
if (pushName)
{
glFunc->glPopName();
}
}
示例3: drawMeOnly
void ccClipBox::drawMeOnly(CC_DRAW_CONTEXT& context)
{
if (!MACRO_Draw3D(context))
return;
if (!m_box.isValid())
return;
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
return;
if (m_showBox)
{
//m_box.draw(m_selected ? context.bbDefaultCol : ccColor::magenta);
m_box.draw(context, ccColor::yellow);
}
if (!m_selected)
{
//nothing to show
return;
}
//standard case: list names pushing (1st level)
bool pushName = MACRO_DrawEntityNames(context);
if (pushName)
{
glFunc->glPushName(getUniqueIDForDisplay());
}
//draw the interactors
{
const CCVector3& minC = m_box.minCorner();
const CCVector3& maxC = m_box.maxCorner();
const CCVector3 center = m_box.getCenter();
PointCoordinateType scale = computeArrowsScale();
//custom arrow 'context'
CC_DRAW_CONTEXT componentContext = context;
componentContext.drawingFlags &= (~CC_DRAW_ENTITY_NAMES); //we must remove the 'push name flag' so that the arows don't push their own!
componentContext.display = 0;
if (pushName) //2nd level = sub-item
{
glFunc->glPushName(0); //fake ID, will be replaced by the arrows one if any
}
DrawUnitArrow(X_MINUS_ARROW*pushName, CCVector3(minC.x, center.y, center.z), CCVector3(-1.0, 0.0, 0.0), scale, ccColor::red, componentContext);
DrawUnitArrow(X_PLUS_ARROW*pushName, CCVector3(maxC.x, center.y, center.z), CCVector3(1.0, 0.0, 0.0), scale, ccColor::red, componentContext);
DrawUnitArrow(Y_MINUS_ARROW*pushName, CCVector3(center.x, minC.y, center.z), CCVector3(0.0, -1.0, 0.0), scale, ccColor::green, componentContext);
DrawUnitArrow(Y_PLUS_ARROW*pushName, CCVector3(center.x, maxC.y, center.z), CCVector3(0.0, 1.0, 0.0), scale, ccColor::green, componentContext);
DrawUnitArrow(Z_MINUS_ARROW*pushName, CCVector3(center.x, center.y, minC.z), CCVector3(0.0, 0.0, -1.0), scale, ccColor::blue, componentContext);
DrawUnitArrow(Z_PLUS_ARROW*pushName, CCVector3(center.x, center.y, maxC.z), CCVector3(0.0, 0.0, 1.0), scale, ccColor::blue, componentContext);
DrawUnitCross(CROSS*pushName, minC - CCVector3(scale, scale, scale) / 2.0, scale, ccColor::yellow, componentContext);
//DrawUnitSphere(SPHERE*pushName, maxC + CCVector3(scale, scale, scale) / 2.0, scale / 2.0, ccColor::yellow, componentContext);
DrawUnitTorus(X_MINUS_TORUS*pushName, CCVector3(minC.x, center.y, center.z), CCVector3(-1.0, 0.0, 0.0), scale, c_lightRed, componentContext);
DrawUnitTorus(Y_MINUS_TORUS*pushName, CCVector3(center.x, minC.y, center.z), CCVector3(0.0, -1.0, 0.0), scale, c_lightGreen, componentContext);
DrawUnitTorus(Z_MINUS_TORUS*pushName, CCVector3(center.x, center.y, minC.z), CCVector3(0.0, 0.0, -1.0), scale, c_lightBlue, componentContext);
DrawUnitTorus(X_PLUS_TORUS*pushName, CCVector3(maxC.x, center.y, center.z), CCVector3(1.0, 0.0, 0.0), scale, c_lightRed, componentContext);
DrawUnitTorus(Y_PLUS_TORUS*pushName, CCVector3(center.x, maxC.y, center.z), CCVector3(0.0, 1.0, 0.0), scale, c_lightGreen, componentContext);
DrawUnitTorus(Z_PLUS_TORUS*pushName, CCVector3(center.x, center.y, maxC.z), CCVector3(0.0, 0.0, 1.0), scale, c_lightBlue, componentContext);
if (pushName)
{
glFunc->glPopName();
}
}
if (pushName)
{
glFunc->glPopName();
}
}
示例4: drawMeOnly
//.........这里部分代码省略.........
{
if (m_width != 0)
{
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(static_cast<GLfloat>(m_width));
}
//DGM: we do the 'GL_LINE_LOOP' manually as I have a strange bug
//on one on my graphic card with this mode!
//glBegin(m_isClosed ? GL_LINE_LOOP : GL_LINE_STRIP);
glFunc->glBegin(GL_LINE_STRIP);
for (unsigned i = 0; i < vertCount; ++i)
{
ccGL::Vertex3v(glFunc, getPoint(i)->u);
}
if (m_isClosed)
{
ccGL::Vertex3v(glFunc, getPoint(0)->u);
}
glFunc->glEnd();
//display arrow
if (m_showArrow && m_arrowIndex < vertCount && (m_arrowIndex > 0 || m_isClosed))
{
const CCVector3* P0 = getPoint(m_arrowIndex == 0 ? vertCount - 1 : m_arrowIndex - 1);
const CCVector3* P1 = getPoint(m_arrowIndex);
//direction of the last polyline chunk
CCVector3 u = *P1 - *P0;
u.normalize();
if (m_mode2D)
{
u *= -m_arrowLength;
static const PointCoordinateType s_defaultArrowAngle = static_cast<PointCoordinateType>(15.0 * CC_DEG_TO_RAD);
static const PointCoordinateType cost = cos(s_defaultArrowAngle);
static const PointCoordinateType sint = sin(s_defaultArrowAngle);
CCVector3 A(cost * u.x - sint * u.y, sint * u.x + cost * u.y, 0);
CCVector3 B(cost * u.x + sint * u.y, -sint * u.x + cost * u.y, 0);
glFunc->glBegin(GL_POLYGON);
ccGL::Vertex3v(glFunc, (A + *P1).u);
ccGL::Vertex3v(glFunc, (B + *P1).u);
ccGL::Vertex3v(glFunc, (*P1).u);
glFunc->glEnd();
}
else
{
if (!c_unitArrow)
{
c_unitArrow = QSharedPointer<ccCone>(new ccCone(0.5, 0.0, 1.0));
c_unitArrow->showColors(true);
c_unitArrow->showNormals(false);
c_unitArrow->setVisible(true);
c_unitArrow->setEnabled(true);
}
if (colorsShown())
c_unitArrow->setTempColor(m_rgbColor);
else
c_unitArrow->setTempColor(context.pointsDefaultCol);
//build-up unit arrow own 'context'
CC_DRAW_CONTEXT markerContext = context;
markerContext.drawingFlags &= (~CC_DRAW_ENTITY_NAMES); //we must remove the 'push name flag' so that the sphere doesn't push its own!
markerContext.display = 0;
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, P1->x, P1->y, P1->z);
ccGLMatrix rotMat = ccGLMatrix::FromToRotation(u, CCVector3(0, 0, PC_ONE));
glFunc->glMultMatrixf(rotMat.inverse().data());
glFunc->glScalef(m_arrowLength, m_arrowLength, m_arrowLength);
ccGL::Translate(glFunc, 0.0, 0.0, -0.5);
c_unitArrow->draw(markerContext);
glFunc->glPopMatrix();
}
}
if (m_width != 0)
{
glFunc->glPopAttrib();
}
}
//display vertices
if (m_showVertices)
{
glFunc->glPushAttrib(GL_POINT_BIT);
glFunc->glPointSize((GLfloat)m_vertMarkWidth);
glFunc->glBegin(GL_POINTS);
for (unsigned i = 0; i < vertCount; ++i)
{
ccGL::Vertex3v(glFunc, getPoint(i)->u);
}
glFunc->glEnd();
glFunc->glPopAttrib();
}
if (pushName)
glFunc->glPopName();
}
示例5: drawMeOnly
void ccSample::drawMeOnly(CC_DRAW_CONTEXT& context)
{
if (MACRO_Draw3D(context)) {
if (!this->getSample())
return;
QOpenGLFunctions_2_1* glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
bool pushName = MACRO_DrawEntityNames(context);
if (pushName) {
// not particularily fast
if (MACRO_DrawFastNamesOnly(context))
return;
glFunc->glPushName(getUniqueIDForDisplay());
}
if (!c_unitPointMarker) {
c_unitPointMarker = QSharedPointer<ccSphere>(new ccSphere(m_radius_, 0, "PointMarker", 12));
c_unitPointMarker->showColors(true);
c_unitPointMarker->setVisible(true);
c_unitPointMarker->setEnabled(true);
}
// build-up point maker own 'context'
CC_DRAW_CONTEXT markerContext = context;
markerContext.drawingFlags
&= (~CC_DRAW_ENTITY_NAMES); // we must remove the 'push name flag' so
// that the sphere doesn't push its own!
markerContext.display = nullptr;
if (isSelected() && !pushName) {
c_unitPointMarker->setTempColor(ccColor::red);
c_unitPointMarker->setRadius(2 * m_radius_);
}
else {
c_unitPointMarker->setTempColor(ccColor::magenta);
c_unitPointMarker->setRadius(m_radius_);
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
float x, y, z;
Eigen::Vector3f p = this->getSample()->getPosition();
// const CCVector3* P = m_points[i].cloud->getPoint(m_points[i].index);
// ccGL::Translate();
glFunc->glTranslatef(p(0), p(1), p(2));
glFunc->glScalef(context.labelMarkerSize, context.labelMarkerSize,
context.labelMarkerSize);
m_current_scaling_ = context.labelMarkerSize;
c_unitPointMarker->draw(markerContext);
glFunc->glPopMatrix();
drawStratPos(context);
if (pushName)
glFunc->glPopName();
}
}