本文整理汇总了C++中QOpenGLFunctions_2_1::glPushName方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glPushName方法的具体用法?C++ QOpenGLFunctions_2_1::glPushName怎么用?C++ QOpenGLFunctions_2_1::glPushName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glPushName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tab
void cc2DLabel::drawMeOnly2D(CC_DRAW_CONTEXT& context)
{
if (!m_dispIn2D)
return;
assert(!m_points.empty());
//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;
//standard case: list names pushing
bool pushName = MACRO_DrawEntityNames(context);
if (pushName)
{
glFunc->glPushName(getUniqueID());
}
//we should already be in orthoprojective & centered omde
//glFunc->glOrtho(-halfW,halfW,-halfH,halfH,-maxS,maxS);
//label title
const int precision = context.dispNumberPrecision;
QString title = getTitle(precision);
#define DRAW_CONTENT_AS_TAB
#ifdef DRAW_CONTENT_AS_TAB
//draw contents as an array
Tab tab(4);
int rowHeight = 0;
#else
//simply display the content as text
QStringList body;
#endif
//render zoom
int margin = static_cast<int>(c_margin * context.renderZoom);
int tabMarginX = static_cast<int>(c_tabMarginX * context.renderZoom);
int tabMarginY = static_cast<int>(c_tabMarginY * context.renderZoom);
int arrowBaseSize = static_cast<int>(c_arrowBaseSize * context.renderZoom);
int titleHeight = 0;
GLdouble arrowDestX = -1.0, arrowDestY = -1.0;
QFont bodyFont,titleFont;
if (!pushName)
{
/*** line from 2D point to label ***/
//compute arrow head position
CCVector3 arrowDest;
m_points[0].cloud->getPoint(m_points[0].index,arrowDest);
for (unsigned i = 1; i < m_points.size(); ++i)
{
arrowDest += *m_points[i].cloud->getPointPersistentPtr(m_points[i].index);
}
arrowDest /= static_cast<PointCoordinateType>(m_points.size());
//project it in 2D screen coordinates
{
ccGLCameraParameters camera;
context.display->getGLCameraParameters(camera);
CCVector3d Q2D;
camera.project(arrowDest, Q2D);
arrowDestX = Q2D.x;
arrowDestY = Q2D.y;
}
/*** label border ***/
bodyFont = context.display->getLabelDisplayFont(); //takes rendering zoom into account!
titleFont = bodyFont; //takes rendering zoom into account!
//titleFont.setBold(true);
QFontMetrics titleFontMetrics(titleFont);
titleHeight = titleFontMetrics.height();
QFontMetrics bodyFontMetrics(bodyFont);
rowHeight = bodyFontMetrics.height();
//get label box dimension
int dx = 100;
int dy = 0;
//int buttonSize = static_cast<int>(c_buttonSize * context.renderZoom);
{
//base box dimension
dx = std::max(dx,titleFontMetrics.width(title));
dy += margin; //top vertical margin
dy += titleHeight; //title
if (m_showFullBody)
{
#ifdef DRAW_CONTENT_AS_TAB
try
{
size_t labelCount = m_points.size();
if (labelCount == 1)
{
//.........这里部分代码省略.........
示例2: font
void cc2DLabel::drawMeOnly3D(CC_DRAW_CONTEXT& context)
{
assert(!m_points.empty());
//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;
//standard case: list names pushing
bool pushName = MACRO_DrawEntityNames(context);
if (pushName)
{
//not particularily fast
if (MACRO_DrawFastNamesOnly(context))
return;
glFunc->glPushName(getUniqueIDForDisplay());
}
const float c_sizeFactor = 4.0f;
bool loop = false;
size_t count = m_points.size();
switch (count)
{
case 3:
{
glFunc->glPushAttrib(GL_COLOR_BUFFER_BIT);
glFunc->glEnable(GL_BLEND);
//we draw the triangle
glFunc->glColor4ub(255,255,0,128);
glFunc->glBegin(GL_TRIANGLES);
ccGL::Vertex3v(glFunc, m_points[0].cloud->getPoint(m_points[0].index)->u);
ccGL::Vertex3v(glFunc, m_points[1].cloud->getPoint(m_points[1].index)->u);
ccGL::Vertex3v(glFunc, m_points[2].cloud->getPoint(m_points[2].index)->u);
glFunc->glEnd();
glFunc->glPopAttrib();
loop = true;
}
case 2:
{
//segment width
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(c_sizeFactor * context.renderZoom);
//we draw the segments
if (isSelected())
ccGL::Color3v(glFunc, ccColor::red.rgba);
else
ccGL::Color3v(glFunc, ccColor::green.rgba);
glFunc->glBegin(GL_LINES);
for (unsigned i=0; i<count; i++)
{
if (i+1<count || loop)
{
ccGL::Vertex3v(glFunc, m_points[i].cloud->getPoint(m_points[i].index)->u);
ccGL::Vertex3v(glFunc, m_points[(i+1)%count].cloud->getPoint(m_points[(i+1)%count].index)->u);
}
}
glFunc->glEnd();
glFunc->glPopAttrib();
}
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);
//.........这里部分代码省略.........
示例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
void ccPolyline::drawMeOnly(CC_DRAW_CONTEXT& context)
{
unsigned vertCount = size();
if (vertCount < 2)
return;
bool draw = false;
if (MACRO_Draw3D(context))
{
draw = !m_mode2D;
}
else if (m_mode2D)
{
bool drawFG = MACRO_Foreground(context);
draw = ((drawFG && m_foreground) || (!drawFG && !m_foreground));
}
if (!draw)
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;
//standard case: list names pushing
bool pushName = MACRO_DrawEntityNames(context);
if (pushName)
glFunc->glPushName(getUniqueIDForDisplay());
if (isColorOverriden())
ccGL::Color3v(glFunc, m_tempColor.rgb);
else if (colorsShown())
ccGL::Color3v(glFunc, m_rgbColor.rgb);
//display polyline
if (vertCount > 1)
{
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;
//.........这里部分代码省略.........
示例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();
}
}