本文整理汇总了C++中QOpenGLFunctions_2_1类的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1类的具体用法?C++ QOpenGLFunctions_2_1怎么用?C++ QOpenGLFunctions_2_1使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QOpenGLFunctions_2_1类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyGL
void ccMaterial::applyGL(const QOpenGLContext* context, bool lightEnabled, bool skipDiffuse) const
{
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1* glFunc = context->versionFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
if (glFunc == nullptr)
return;
if (lightEnabled)
{
if (!skipDiffuse)
{
glFunc->glMaterialfv(GL_FRONT, GL_DIFFUSE, m_diffuseFront.rgba);
glFunc->glMaterialfv(GL_BACK, GL_DIFFUSE, m_diffuseBack.rgba);
}
glFunc->glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, m_ambient.rgba);
glFunc->glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_specular.rgba);
glFunc->glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, m_emission.rgba);
glFunc->glMaterialf (GL_FRONT, GL_SHININESS, std::max(0.0f, std::min(m_shininessFront, 128.0f)));
glFunc->glMaterialf (GL_BACK, GL_SHININESS, std::max(0.0f, std::min(m_shininessBack, 128.0f)));
}
else
{
glFunc->glColor4fv(m_diffuseFront.rgba);
}
}
示例2: MakeLightsNeutral
void ccMaterial::MakeLightsNeutral(const QOpenGLContext* context)
{
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1* glFunc = context->versionFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
if (glFunc == nullptr)
return;
GLint maxLightCount;
glFunc->glGetIntegerv(GL_MAX_LIGHTS, &maxLightCount);
for (int i = 0; i < maxLightCount; ++i)
{
if (glFunc->glIsEnabled(GL_LIGHT0 + i))
{
float diffuse[4];
float ambiant[4];
float specular[4];
glFunc->glGetLightfv(GL_LIGHT0 + i, GL_DIFFUSE, diffuse);
glFunc->glGetLightfv(GL_LIGHT0 + i, GL_AMBIENT, ambiant);
glFunc->glGetLightfv(GL_LIGHT0 + i, GL_SPECULAR, specular);
diffuse[0] = diffuse[1] = diffuse[2] = ( diffuse[0] + diffuse[1] + diffuse[2]) / 3; //'mean' (gray) value
ambiant[0] = ambiant[1] = ambiant[2] = ( ambiant[0] + ambiant[1] + ambiant[2]) / 3; //'mean' (gray) value
specular[0] = specular[1] = specular[2] = (specular[0] + specular[1] + specular[2]) / 3; //'mean' (gray) value
glFunc->glLightfv(GL_LIGHT0 + i, GL_DIFFUSE, diffuse);
glFunc->glLightfv(GL_LIGHT0 + i, GL_AMBIENT, ambiant);
glFunc->glLightfv(GL_LIGHT0 + i, GL_SPECULAR, specular);
}
}
}
示例3: assert
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: DrawUnitCross
static void DrawUnitCross(int ID, const CCVector3& center, 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);
scale /= 2;
DrawUnitArrow(0, center, CCVector3(-1, 0, 0), scale, col, context);
DrawUnitArrow(0, center, CCVector3( 1, 0, 0), scale, col, context);
DrawUnitArrow(0, center, CCVector3( 0,-1, 0), scale, col, context);
DrawUnitArrow(0, center, CCVector3( 0, 1, 0), scale, col, context);
DrawUnitArrow(0, center, CCVector3( 0, 0,-1), scale, col, context);
DrawUnitArrow(0, center, CCVector3( 0, 0, 1), scale, col, context);
}
示例5: 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();
}
示例6: drawStratPos
void ccSample::drawStratPos(CC_DRAW_CONTEXT& context)
{
if (MACRO_Draw3D(context)) {
QOpenGLFunctions_2_1* glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
QFont font(context.display->getTextDisplayFont()); // takes rendering zoom into
// account!
font.setPointSize(font.pointSize());
font.setBold(true);
// // draw their name
// glPushAttrib(GL_DEPTH_BUFFER_BIT);
glFunc->glDisable(GL_DEPTH_TEST);
QString name = QString::number(getSample()->getStratigraphicPosition(), 'g', 3);
context.display->display3DLabel(name,
CCVector3(getSample()->getPosition().data()),
ccColor::red.rgb, font);
// CCVector3 p (x,y,z);
// QString title = (getName());
// context.display->display3DLabel( title,
// p + CCVector3(
// context.pickedPointsTextShift,
// context.pickedPointsTextShift,
// context.pickedPointsTextShift),
// ccColor::magenta,
// font );
// glPopAttrib();
glFunc->glEnable(GL_DEPTH_TEST);
}
}
示例7: 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();
}
示例8: assert
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)
{
//.........这里部分代码省略.........
示例9: 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();
}
}
示例10: size
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;
//.........这里部分代码省略.........
示例11: draw
//override draw function
void ccMouseCircle::draw(CC_DRAW_CONTEXT& context)
{
//only draw when visible
if (!ccMouseCircle::isVisible())
return;
//only draw in 2D foreground mode
if (!MACRO_Foreground(context) || !MACRO_Draw2D(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;
//test viewport parameters
const ccViewportParameters& params = context.display->getViewportParameters();
glFunc->glPushAttrib(GL_LINE_BIT);
float relativeZoom = 1.0f;
float dx = 0.0f;
float dy = 0.0f;
if (!m_params.perspectiveView) //ortho mode
{
//Screen pan & pivot compensation
float totalZoom = m_params.zoom / m_params.pixelSize;
m_winTotalZoom = params.zoom / params.pixelSize;
relativeZoom = m_winTotalZoom / totalZoom;
CCVector3d dC = m_params.cameraCenter - params.cameraCenter;
CCVector3d P = m_params.pivotPoint - params.pivotPoint;
m_params.viewMat.apply(P);
static_cast<float>(dC.x + P.x);
static_cast<float>(dC.y + P.y);
dx *= m_winTotalZoom;
dy *= m_winTotalZoom;
}
//thick dotted line
glFunc->glLineWidth(2);
glFunc->glLineStipple(1, 0xAAAA);
glFunc->glEnable(GL_LINE_STIPPLE);
const unsigned char* defaultColor = m_selected ? ccColor::red.rgba : context.textDefaultCol.rgb;
glFunc->glColor3ubv(ccColor::red.rgba);
//get height & width
int halfW = static_cast<int>(context.glW / 2.0f);
int halfH = static_cast<int>(context.glH / 2.0f);
//get mouse position
QPoint p = m_owner->asWidget()->mapFromGlobal(QCursor::pos());
int mx = p.x(); //mouse x-coord
int my = 2*halfH - p.y(); //mouse y-coord in OpenGL coordinates (origin at bottom left, not top left)
//calculate circle location
int cx = dx+mx-halfW;
int cy = dy+my-halfH;
//draw circle
glFunc->glBegin(GL_LINE_LOOP);
for (int n = 0; n < ccMouseCircle::RESOLUTION; n++)
{
glFunc->glVertex2f(ccMouseCircle::UNIT_CIRCLE[n][0] * ccMouseCircle::RADIUS + cx, ccMouseCircle::UNIT_CIRCLE[n][1] * ccMouseCircle::RADIUS + cy);
}
glFunc->glEnd();
glFunc->glPopAttrib();
}
示例12: assert
void ccGLUtils::DisplayTexture2DPosition(GLuint texID, int x, int y, int w, int h, unsigned char alpha/*=255*/)
{
QOpenGLContext* context = QOpenGLContext::currentContext();
if (!context)
{
assert(false);
return;
}
QOpenGLFunctions_2_1* glFunc = context->versionFunctions<QOpenGLFunctions_2_1>();
if (glFunc)
{
glFunc->glBindTexture(GL_TEXTURE_2D, texID);
glFunc->glPushAttrib(GL_ENABLE_BIT);
glFunc->glEnable(GL_TEXTURE_2D);
glFunc->glColor4ub(255, 255, 255, alpha);
glFunc->glBegin(GL_QUADS);
glFunc->glTexCoord2f(0.0, 1.0);
glFunc->glVertex2i(x, y + h);
glFunc->glTexCoord2f(0.0, 0.0);
glFunc->glVertex2i(x, y);
glFunc->glTexCoord2f(1.0, 0.0);
glFunc->glVertex2i(x + w, y);
glFunc->glTexCoord2f(1.0, 1.0);
glFunc->glVertex2i(x + w, y + h);
glFunc->glEnd();
glFunc->glBindTexture(GL_TEXTURE_2D, 0);
glFunc->glPopAttrib();
glFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
}
示例13: 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();
}
}
示例14: 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();
}
}
}
示例15: DrawColorRamp
void ccRenderingTools::DrawColorRamp(const CC_DRAW_CONTEXT& context, const ccScalarField* sf, ccGLWindow* win, int glW, int glH, float renderZoom/*=1.0f*/)
{
if (!sf || !sf->getColorScale() || !win)
{
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;
bool logScale = sf->logScale();
bool symmetricalScale = sf->symmetricalScale();
bool alwaysShowZero = sf->isZeroAlwaysShown();
//set of particular values
//DGM: we work with doubles for maximum accuracy
ccColorScale::LabelSet keyValues;
bool customLabels = false;
try
{
ccColorScale::Shared colorScale = sf->getColorScale();
if (colorScale && colorScale->customLabels().size() >= 2)
{
keyValues = colorScale->customLabels();
if (alwaysShowZero)
{
keyValues.insert(0.0);
}
customLabels = true;
}
else if (!logScale)
{
keyValues.insert(sf->displayRange().min());
keyValues.insert(sf->displayRange().start());
keyValues.insert(sf->displayRange().stop());
keyValues.insert(sf->displayRange().max());
keyValues.insert(sf->saturationRange().min());
keyValues.insert(sf->saturationRange().start());
keyValues.insert(sf->saturationRange().stop());
keyValues.insert(sf->saturationRange().max());
if (symmetricalScale)
keyValues.insert(-sf->saturationRange().max());
if (alwaysShowZero)
keyValues.insert(0.0);
}
else
{
ScalarType minDisp = sf->displayRange().min();
ScalarType maxDisp = sf->displayRange().max();
ConvertToLogScale(minDisp, maxDisp);
keyValues.insert(minDisp);
keyValues.insert(maxDisp);
ScalarType startDisp = sf->displayRange().start();
ScalarType stopDisp = sf->displayRange().stop();
ConvertToLogScale(startDisp, stopDisp);
keyValues.insert(startDisp);
keyValues.insert(stopDisp);
keyValues.insert(sf->saturationRange().min());
keyValues.insert(sf->saturationRange().start());
keyValues.insert(sf->saturationRange().stop());
keyValues.insert(sf->saturationRange().max());
}
}
catch (const std::bad_alloc&)
{
//not enough memory
return;
}
//magic fix (for infinite values!)
{
for (ccColorScale::LabelSet::iterator it = keyValues.begin(); it != keyValues.end(); ++it)
{
#if defined(CC_WINDOWS) && defined(_MSC_VER)
if (!_finite(*it))
#else
if (!std::isfinite(*it))
#endif
{
bool minusInf = (*it < 0);
keyValues.erase(it);
if (minusInf)
keyValues.insert(-std::numeric_limits<ScalarType>::max());
else
keyValues.insert(std::numeric_limits<ScalarType>::max());
it = keyValues.begin(); //restart the process (easier than trying to be intelligent here ;)
}
}
}
//.........这里部分代码省略.........