当前位置: 首页>>代码示例>>C++>>正文


C++ QOpenGLFunctions_2_1::glPopAttrib方法代码示例

本文整理汇总了C++中QOpenGLFunctions_2_1::glPopAttrib方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glPopAttrib方法的具体用法?C++ QOpenGLFunctions_2_1::glPopAttrib怎么用?C++ QOpenGLFunctions_2_1::glPopAttrib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QOpenGLFunctions_2_1的用法示例。


在下文中一共展示了QOpenGLFunctions_2_1::glPopAttrib方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

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);
	}
}
开发者ID:3660628,项目名称:trunk,代码行数:34,代码来源:ccGLUtils.cpp

示例2: 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();
		}
	}
}
开发者ID:Puwong,项目名称:CloudCompare,代码行数:58,代码来源:ccIndexedTransformationBuffer.cpp

示例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
}
开发者ID:MrCairo90,项目名称:CloudCompare,代码行数:48,代码来源:ccHObject.cpp

示例4: 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();
}
开发者ID:luca-penasa,项目名称:trunk,代码行数:74,代码来源:ccMouseCircle.cpp

示例5: DrawColorRamp


//.........这里部分代码省略.........
					glFunc->glVertex2i(histoStart+xSpan,y+j);
				}
			}
			glFunc->glEnd();
		}
		else
		{
			//if there's a unique (visible) scalar value, we only draw a square!
			double value = sortedKeyValues.front();
			if (logScale)
				value = exp(value*c_log10);
			const ColorCompType* col = sf->getColor(static_cast<ScalarType>(value));
			glFunc->glColor3ubv(col ? col : ccColor::lightGrey.rgba);
			glFunc->glBegin(GL_POLYGON);
			glFunc->glVertex2i(x,y);
			glFunc->glVertex2i(x+scaleWidth,y);
			glFunc->glVertex2i(x+scaleWidth,y+scaleMaxHeight-1);
			glFunc->glVertex2i(x,y+scaleMaxHeight-1);
			glFunc->glEnd();
		}

		//scale border
		const ccColor::Rgbub& lineColor = textColor;
		glFunc->glColor3ubv(lineColor.rgb);
		glFunc->glLineWidth(2.0f * renderZoom);
		glFunc->glEnable(GL_LINE_SMOOTH);
		glFunc->glBegin(GL_LINE_LOOP);
		glFunc->glVertex2i(x,y);
		glFunc->glVertex2i(x+scaleWidth,y);
		glFunc->glVertex2i(x+scaleWidth,y+scaleMaxHeight);
		glFunc->glVertex2i(x,y+scaleMaxHeight);
		glFunc->glEnd();

		glFunc->glPopAttrib();
	}

	//display labels
	{
		//list of labels to draw
		vlabelSet drawnLabels;

		//add first label
		drawnLabels.push_back(vlabel(0, 0, strHeight, sortedKeyValues.front()));

		if (keyValues.size() > 1)
		{
			//add last label
			drawnLabels.push_back(vlabel(scaleMaxHeight, scaleMaxHeight - strHeight, scaleMaxHeight, sortedKeyValues.back()));
		}

		//we try to display the other keyPoints (if any)
		if (keyValues.size() > 2)
		{
			assert(maxRange > 0.0);
			const int minGap = strHeight;
			for (size_t i=1; i<keyValues.size()-1; ++i)
			{
				int yScale = static_cast<int>((sortedKeyValues[i]-sortedKeyValues[0]) * scaleMaxHeight / maxRange);
				vlabelPair nLabels = GetVLabelsAround(yScale,drawnLabels);

				assert(nLabels.first != drawnLabels.end() && nLabels.second != drawnLabels.end());
				if (	(nLabels.first == drawnLabels.end() || nLabels.first->yMax <= yScale - minGap)
					&&	(nLabels.second == drawnLabels.end() || nLabels.second->yMin >= yScale + minGap))
				{
					//insert it at the right place (so as to keep a sorted list!)
					drawnLabels.insert(nLabels.second,vlabel(yScale,yScale-strHeight/2,yScale+strHeight/2,sortedKeyValues[i]));
开发者ID:Puwong,项目名称:CloudCompare,代码行数:67,代码来源:ccRenderingTools.cpp

示例6: tab


//.........这里部分代码省略.........
				glFunc->glVertex2i(std::max(m_labelROI.left(),iArrowDestX-arrowBaseSize), -m_labelROI.bottom());
				glFunc->glVertex2i(std::min(m_labelROI.right(),iArrowDestX+arrowBaseSize), -m_labelROI.bottom());
				break;
			case 8: //bottom-right corner
				glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.bottom()+2*arrowBaseSize);
				glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.bottom());
				glFunc->glVertex2i(m_labelROI.right()-2*arrowBaseSize, -m_labelROI.bottom());
				break;
			}
			glFunc->glEnd();
		}
	}

	//main rectangle
	glFunc->glColor4ubv(defaultBkgColor.rgba);
	glFunc->glBegin(GL_QUADS);
	glFunc->glVertex2i(m_labelROI.left(),  -m_labelROI.top());
	glFunc->glVertex2i(m_labelROI.left(),  -m_labelROI.bottom());
	glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.bottom());
	glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.top());
	glFunc->glEnd();

	//if (highlighted)
	{
		glFunc->glPushAttrib(GL_LINE_BIT);
		glFunc->glLineWidth(3.0f * context.renderZoom);
		glFunc->glColor4ubv(defaultBorderColor.rgba);
		glFunc->glBegin(GL_LINE_LOOP);
		glFunc->glVertex2i(m_labelROI.left(),  -m_labelROI.top());
		glFunc->glVertex2i(m_labelROI.left(),  -m_labelROI.bottom());
		glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.bottom());
		glFunc->glVertex2i(m_labelROI.right(), -m_labelROI.top());
		glFunc->glEnd();
		glFunc->glPopAttrib();
	}

	//draw close button
	//glFunc->glColor3ubv(ccColor::black);
	//glFunc->glBegin(GL_LINE_LOOP);
	//glFunc->glVertex2i(m_closeButtonROI.left(),-m_closeButtonROI.top());
	//glFunc->glVertex2i(m_closeButtonROI.left(),-m_closeButtonROI.bottom());
	//glFunc->glVertex2i(m_closeButtonROI.right(),-m_closeButtonROI.bottom());
	//glFunc->glVertex2i(m_closeButtonROI.right(),-m_closeButtonROI.top());
	//glFunc->glEnd();
	//glFunc->glBegin(GL_LINES);
	//glFunc->glVertex2i(m_closeButtonROI.left()+2,-m_closeButtonROI.top()+2);
	//glFunc->glVertex2i(m_closeButtonROI.right()-2,-m_closeButtonROI.bottom()-2);
	//glFunc->glVertex2i(m_closeButtonROI.right()-2,-m_closeButtonROI.top()+2);
	//glFunc->glVertex2i(m_closeButtonROI.left()+2,-m_closeButtonROI.bottom()-2);
	//glFunc->glEnd();

	//display text
	if (!pushName)
	{
		int xStartRel = margin;
		int yStartRel = 0;
		yStartRel -= titleHeight;

		ccColor::Rgbub defaultTextColor;
		if (context.labelOpacity < 40)
		{
			//under a given opacity level, we use the default text color instead!
			defaultTextColor = context.textDefaultCol;
		}
		else
		{
开发者ID:stephaniewxk,项目名称:trunk,代码行数:67,代码来源:cc2DLabel.cpp

示例7: 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);
//.........这里部分代码省略.........
开发者ID:stephaniewxk,项目名称:trunk,代码行数:101,代码来源:cc2DLabel.cpp

示例8: 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();
	}
}
开发者ID:MrCairo90,项目名称:CloudCompare,代码行数:94,代码来源:ccSNECloud.cpp

示例9: 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();
}
开发者ID:3660628,项目名称:trunk,代码行数:101,代码来源:ccPolyline.cpp

示例10: title

void cc2DViewportLabel::drawMeOnly(CC_DRAW_CONTEXT& context)
{
	//2D foreground only
	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();

	//general parameters
	if (	params.perspectiveView != m_params.perspectiveView
		||	params.objectCenteredView != m_params.objectCenteredView
		||	params.pixelSize != m_params.pixelSize)
	{
			return;
	}

	//test base view matrix
	for (unsigned i = 0; i < 12; ++i)
		if (fabs(params.viewMat.data()[i] - m_params.viewMat.data()[i]) > ZERO_TOLERANCE)
			return;

	if (m_params.perspectiveView)
	{
		if (params.fov != m_params.fov || params.perspectiveAspectRatio != m_params.perspectiveAspectRatio)
			return;

		if ((params.pivotPoint - m_params.pivotPoint).norm() > ZERO_TOLERANCE
			|| (params.cameraCenter - m_params.cameraCenter).norm() > ZERO_TOLERANCE)
			return;
	}
	else
	{
		if (params.orthoAspectRatio != m_params.orthoAspectRatio)
			return;
	}

	glFunc->glPushAttrib(GL_LINE_BIT);

	float relativeZoom = 1.0f;
	float dx = 0, dy = 0;
	if (!m_params.perspectiveView) //ortho mode
	{
		//Screen pan & pivot compensation
		float totalZoom = m_params.zoom / m_params.pixelSize;
		float winTotalZoom = params.zoom / params.pixelSize;
		relativeZoom = winTotalZoom / totalZoom;

		CCVector3d dC = m_params.cameraCenter - params.cameraCenter;

		CCVector3d P = m_params.pivotPoint - params.pivotPoint;
		m_params.viewMat.apply(P);

		dx = static_cast<float>(dC.x + P.x);
		dy = static_cast<float>(dC.y + P.y);

		dx *= winTotalZoom;
		dy *= 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(defaultColor);

	glFunc->glBegin(GL_LINE_LOOP);
	glFunc->glVertex2f(dx + m_roi[0] * relativeZoom, dy + m_roi[1] * relativeZoom);
	glFunc->glVertex2f(dx + m_roi[2] * relativeZoom, dy + m_roi[1] * relativeZoom);
	glFunc->glVertex2f(dx + m_roi[2] * relativeZoom, dy + m_roi[3] * relativeZoom);
	glFunc->glVertex2f(dx + m_roi[0] * relativeZoom, dy + m_roi[3] * relativeZoom);
	glFunc->glEnd();

	glFunc->glPopAttrib();

	//title
	QString title(getName());
	if (!title.isEmpty())
	{
		QFont titleFont(context.display->getTextDisplayFont()); //takes rendering zoom into account!
		titleFont.setBold(true);
		QFontMetrics titleFontMetrics(titleFont);
		int titleHeight = titleFontMetrics.height();

		int xStart = (int)(dx + 0.5f*(float)context.glW + std::min<float>(m_roi[0], m_roi[2])*relativeZoom);
		int yStart = (int)(dy + 0.5f*(float)context.glH + std::min<float>(m_roi[1], m_roi[3])*relativeZoom);

		context.display->displayText(title, xStart, yStart - 5 - titleHeight, ccGenericGLDisplay::ALIGN_DEFAULT, 0, defaultColor, &titleFont);
	}
}
开发者ID:3660628,项目名称:trunk,代码行数:99,代码来源:cc2DViewportLabel.cpp


注:本文中的QOpenGLFunctions_2_1::glPopAttrib方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。