Ejemplo n.º 1
0
//==================================================drawBB==========================================================//
void ccHObject::drawBB(const ccColor::Rgb& col)
{
	switch (m_selectionBehavior)
	{
	case SELECTION_AA_BBOX:
		getDisplayBB_recursive(true,m_currentDisplay).draw(col);
		break;
	
	case SELECTION_FIT_BBOX: //
		{
			assert(getChildrenNumber() == 0);
			ccGLMatrix trans;
			ccBBox box = getOwnFitBB(trans); //当前版本下trans=indentity()  getOwnFitBB 返回OwnBB
			if (box.isValid()){
				glMatrixMode(GL_MODELVIEW);
				glPushMatrix();
				glMultMatrixf(trans.data());
				box.draw(col);
				glPopMatrix();
			}
		}
		break;
	
	case SELECTION_IGNORED:
		break;

	default:
		assert(false);
	}
}
Ejemplo n.º 2
0
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
}