本文整理汇总了C++中QOpenGLFunctions_2_1::glPushMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glPushMatrix方法的具体用法?C++ QOpenGLFunctions_2_1::glPushMatrix怎么用?C++ QOpenGLFunctions_2_1::glPushMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glPushMatrix方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMeOnly
void ccIndexedTransformationBuffer::drawMeOnly(CC_DRAW_CONTEXT& context)
{
//no picking enabled on trans. buffers
if (MACRO_DrawEntityNames(context))
return;
//only in 3D
if (!MACRO_Draw3D(context))
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;
size_t count = size();
//show path
{
ccGL::Color3v(glFunc, ccColor::green.rgba);
glFunc->glBegin(count > 1 && m_showAsPolyline ? GL_LINE_STRIP : GL_POINTS); //show path as a polyline or points?
for (ccIndexedTransformationBuffer::const_iterator it=begin(); it!=end(); ++it)
glFunc->glVertex3fv(it->getTranslation());
glFunc->glEnd();
}
//show trihedrons?
if (m_showTrihedrons)
{
for (ccIndexedTransformationBuffer::const_iterator it=begin(); it!=end(); ++it)
{
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glMultMatrixf(it->data());
//force line width
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(2.0f);
glFunc->glBegin(GL_LINES);
glFunc->glColor3f(1.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(m_trihedronsScale,0.0f,0.0f);
glFunc->glColor3f(0.0f,1.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,m_trihedronsScale,0.0f);
glFunc->glColor3f(0.0f,0.7f,1.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,m_trihedronsScale);
glFunc->glEnd();
glFunc->glPopAttrib(); //GL_LINE_BIT
glFunc->glPopMatrix();
}
}
}
示例2: DrawUnitArrow
void DrawUnitArrow(int ID, const CCVector3& start, const CCVector3& direction, PointCoordinateType scale, const ccColor::Rgb& col, CC_DRAW_CONTEXT& context)
{
//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 (ID > 0)
{
glFunc->glLoadName(ID);
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, start.x, start.y, start.z);
ccGL::Scale(glFunc, scale, scale, scale);
//we compute scalar prod between the two vectors
CCVector3 Z(0.0,0.0,1.0);
PointCoordinateType ps = Z.dot(direction);
if (ps < 1)
{
CCVector3 axis(1,0,0);
PointCoordinateType angle_deg = static_cast<PointCoordinateType>(180.0);
if (ps > -1)
{
//we deduce angle from scalar prod
angle_deg = acos(ps) * static_cast<PointCoordinateType>(CC_RAD_TO_DEG);
//we compute rotation axis with scalar prod
axis = Z.cross(direction);
}
ccGL::Rotate(glFunc,angle_deg, axis.x, axis.y, axis.z);
}
if (!c_arrowShaft)
c_arrowShaft = QSharedPointer<ccCylinder>(new ccCylinder(0.15f,0.6f,0,"ArrowShaft",12));
if (!c_arrowHead)
c_arrowHead = QSharedPointer<ccCone>(new ccCone(0.3f,0,0.4f,0,0,0,"ArrowHead",24));
glFunc->glTranslatef(0,0,0.3f);
c_arrowShaft->setTempColor(col);
c_arrowShaft->draw(context);
glFunc->glTranslatef(0,0,0.3f+0.2f);
c_arrowHead->setTempColor(col);
c_arrowHead->draw(context);
glFunc->glPopMatrix();
}
示例3: drawBB
void ccHObject::drawBB(CC_DRAW_CONTEXT& context, const ccColor::Rgb& col)
{
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
if (glFunc == nullptr)
return;
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(1.0f);
switch (m_selectionBehavior)
{
case SELECTION_AA_BBOX:
getDisplayBB_recursive(true, m_currentDisplay).draw(context, col);
break;
case SELECTION_FIT_BBOX:
{
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
break;
ccGLMatrix trans;
ccBBox box = getOwnFitBB(trans);
if (box.isValid())
{
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glMultMatrixf(trans.data());
box.draw(context, col);
glFunc->glPopMatrix();
}
}
break;
case SELECTION_IGNORED:
break;
default:
assert(false);
}
glFunc->glPopAttrib(); //GL_LINE_BIT
}
示例4: DrawUnitTorus
static void DrawUnitTorus(int ID, const CCVector3& center, const CCVector3& direction, PointCoordinateType scale, const ccColor::Rgb& col, CC_DRAW_CONTEXT& context)
{
//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 (ID > 0)
glFunc->glLoadName(ID);
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, center.x, center.y, center.z);
ccGL::Scale(glFunc, scale, scale, scale);
//we compute scalar prod between the two vectors
CCVector3 Z(0,0,1);
PointCoordinateType ps = Z.dot(direction);
if (ps < 1)
{
CCVector3 axis(1,0,0);
PointCoordinateType angle_deg = 180;
if (ps > -1)
{
//we deduce angle from scalar prod
angle_deg = acos(ps) * static_cast<PointCoordinateType>(CC_RAD_TO_DEG);
//we compute rotation axis with scalar prod
axis = Z.cross(direction);
}
ccGL::Rotate(glFunc, angle_deg, axis.x, axis.y, axis.z);
}
if (!c_torus)
c_torus = QSharedPointer<ccTorus>(new ccTorus(0.2f, 0.4f, 2.0*M_PI, false, 0, 0, "Torus", 12));
glFunc->glTranslatef(0,0,0.3f);
c_torus->setTempColor(col);
c_torus->draw(context);
glFunc->glPopMatrix();
}
示例5: tab
//.........这里部分代码省略.........
//automatically elide the title
//title = titleFontMetrics.elidedText(title,Qt::ElideRight,m_closeButtonROI[0]-2*margin);
}
int halfW = (context.glW >> 1);
int halfH = (context.glH >> 1);
//draw label rectangle
int xStart = static_cast<int>(context.glW * m_screenPos[0]);
int yStart = static_cast<int>(context.glH * (1.0f - m_screenPos[1]));
m_lastScreenPos[0] = xStart;
m_lastScreenPos[1] = yStart - m_labelROI.height();
//colors
bool highlighted = (!pushName && isSelected());
//default background color
unsigned char alpha = static_cast<unsigned char>((context.labelOpacity/100.0) * 255);
ccColor::Rgbaub defaultBkgColor(context.labelDefaultBkgCol,alpha);
//default border color (mustn't be totally transparent!)
ccColor::Rgbaub defaultBorderColor(ccColor::red);
if (!highlighted)
{
//apply only half of the transparency
unsigned char halfAlpha = static_cast<unsigned char>((50.0 + context.labelOpacity/200.0) * 255);
defaultBorderColor = ccColor::Rgbaub(context.labelDefaultBkgCol,halfAlpha);
}
glFunc->glPushAttrib(GL_COLOR_BUFFER_BIT);
glFunc->glEnable(GL_BLEND);
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glTranslatef(static_cast<GLfloat>(-halfW + xStart), static_cast<GLfloat>(-halfH + yStart), 0);
if (!pushName)
{
//compute arrow base position relatively to the label rectangle (for 0 to 8)
int arrowBaseConfig = 0;
int iArrowDestX = static_cast<int>(arrowDestX)-xStart;
int iArrowDestY = static_cast<int>(arrowDestY)-yStart;
{
if (iArrowDestX < m_labelROI.left()) //left
arrowBaseConfig += 0;
else if (iArrowDestX > m_labelROI.right()) //Right
arrowBaseConfig += 2;
else //Middle
arrowBaseConfig += 1;
if (iArrowDestY > -m_labelROI.top()) //Top
arrowBaseConfig += 0;
else if (iArrowDestY < -m_labelROI.bottom()) //Bottom
arrowBaseConfig += 6;
else //Middle
arrowBaseConfig += 3;
}
//we make the arrow base start from the nearest corner
if (arrowBaseConfig != 4) //4 = label above point!
{
glFunc->glColor4ubv(defaultBorderColor.rgba);
glFunc->glBegin(GL_TRIANGLE_FAN);
glFunc->glVertex2d(arrowDestX - xStart, arrowDestY - yStart);
switch(arrowBaseConfig)
{
示例6: 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);
//.........这里部分代码省略.........
示例7: drawMeOnly
void ccSNECloud::drawMeOnly(CC_DRAW_CONTEXT& context)
{
if (!MACRO_Foreground(context)) //2D foreground only
return; //do nothing
//draw point cloud
ccPointCloud::drawMeOnly(context);
//draw normal vectors
if (MACRO_Draw3D(context))
{
if (size() == 0) //no points -> bail!
return;
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
if (glFunc == nullptr) {
assert(false);
return;
}
//glDrawParams glParams;
//getDrawingParameters(glParams);
//get camera info
ccGLCameraParameters camera;
glFunc->glGetIntegerv(GL_VIEWPORT, camera.viewport);
glFunc->glGetDoublev(GL_PROJECTION_MATRIX, camera.projectionMat.data());
glFunc->glGetDoublev(GL_MODELVIEW_MATRIX, camera.modelViewMat.data());
const ccViewportParameters& viewportParams = context.display->getViewportParameters();
//get point size for drawing
float pSize;
glFunc->glGetFloatv(GL_POINT_SIZE, &pSize);
//draw normal vectors if highlighted
//if ((m_isHighlighted | m_isAlternate | m_isActive))
//{
//setup
if (pSize != 0)
{
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(static_cast<GLfloat>(pSize));
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glEnable(GL_BLEND);
//get normal vector properties
int thickID = getScalarFieldIndexByName("Thickness");
//int weightID = getScalarFieldIndexByName("Weight");
//float weight;
//float maxWeight = getScalarField( weightID )->getMax();
//draw normals
glFunc->glBegin(GL_LINES);
for (unsigned p = 0; p < size(); p++)
{
//get weight
//weight = getScalarField(weightID)->getValue(p);
//weight /= maxWeight;
//push colour
const ccColor::Rgb* col = m_currentDisplayedScalarField->getColor(m_currentDisplayedScalarField->getValue(p));
const ccColor::Rgba col4(col->r, col->g, col->b,200);
glFunc->glColor4ubv(col4.rgba);
//get length from thickness (if defined)
float length = 1.0;
if (thickID != -1)
{
length = getScalarField(thickID)->getValue(p);
}
//calculate start and end points of normal vector
const CCVector3 start = *getPoint(p);
CCVector3 end = start + (getPointNormal(p)*length);
//push line to opengl
ccGL::Vertex3v(glFunc, start.u);
ccGL::Vertex3v(glFunc, end.u);
}
glFunc->glEnd();
//cleanup
if (pSize != 0) {
glFunc->glPopAttrib();
}
glFunc->glPopMatrix();
}
}
示例8: 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();
}
示例9: 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();
}
}