Exemplo n.º 1
0
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
	if (!isEnabled())
		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;

	//are we currently drawing objects in 2D or 3D?
	bool draw3D = MACRO_Draw3D(context);
	
	//the entity must be either visible or selected, and of course it should be displayed in this context
	bool drawInThisContext = ((m_visible || m_selected) && m_currentDisplay == context.display);

	if (draw3D)
	{
		//apply 3D 'temporary' transformation (for display only)
		if (m_glTransEnabled)
		{
			glFunc->glMatrixMode(GL_MODELVIEW);
			glFunc->glPushMatrix();
			glFunc->glMultMatrixf(m_glTrans.data());
		}

		//LOD for clouds is enabled?
		if (	context.decimateCloudOnMove
			&&	context.currentLODLevel > 0)
		{
			//only for real clouds
			drawInThisContext &= isA(CC_TYPES::POINT_CLOUD);
		}
	}

	//draw entity
	if (m_visible && drawInThisContext)
	{
		if (( !m_selected || !MACRO_SkipSelected(context) ) &&
			(  m_selected || !MACRO_SkipUnselected(context) ))
		{
			//apply default color (in case of)
			ccGL::Color3v(glFunc, context.pointsDefaultCol.rgb);

			//enable clipping planes (if any)
			bool useClipPlanes = (draw3D && !m_clipPlanes.empty());
			if (useClipPlanes)
			{
				toggleClipPlanes(context, true);
			}

			drawMeOnly(context);

			//disable clipping planes (if any)
			if (useClipPlanes)
			{
				toggleClipPlanes(context, false);
			}

			//draw name in 3D (we display it in the 2D foreground layer in fact!)
			if (m_showNameIn3D && MACRO_Draw2D(context) && MACRO_Foreground(context) && !MACRO_DrawEntityNames(context))
				drawNameIn3D(context);
		}
	}

	//draw entity's children
	for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it)
		(*it)->draw(context);

	//if the entity is currently selected, we draw its bounding-box
	if (m_selected && draw3D && drawInThisContext && !MACRO_DrawEntityNames(context) && context.currentLODLevel == 0)
	{
		drawBB(context, context.bbDefaultCol);
	}

	if (draw3D && m_glTransEnabled)
		glFunc->glPopMatrix();
}
Exemplo n.º 2
0
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
	if (!isEnabled())
		return;

	//are we currently drawing objects in 2D or 3D?
	bool draw3D = MACRO_Draw3D(context);
	
	//the entity must be either visible and selected, and of course it should be displayed in this context
	bool drawInThisContext = ((m_visible || m_selected) && m_currentDisplay == context._win);

	//no need to display anything but clouds and meshes in "element picking mode"
	drawInThisContext &= (	( !MACRO_DrawPointNames(context)	|| isKindOf(CC_TYPES::POINT_CLOUD) ) || 
							( !MACRO_DrawTriangleNames(context)	|| isKindOf(CC_TYPES::MESH) ));

	//apply 3D 'temporary' transformation (for display only)
	if (draw3D && m_glTransEnabled)
	{
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glMultMatrixf(m_glTrans.data());
	}

	//draw entity
	if (m_visible && drawInThisContext)
	{
		if (( !m_selected || !MACRO_SkipSelected(context) ) &&
			( m_selected || !MACRO_SkipUnselected(context) ))
		{
			//apply default color (in case of)
			glColor3ubv(context.pointsDefaultCol);

			drawMeOnly(context);

			//draw name in 3D (we display it in the 2D foreground layer in fact!)
			if (m_showNameIn3D && MACRO_Draw2D(context) && MACRO_Foreground(context) && !MACRO_DrawNames(context))
				drawNameIn3D(context);
		}
	}

	//draw entity's children
	for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it)
		(*it)->draw(context);

	//if the entity is currently selected, we draw its bounding-box
	if (m_selected && draw3D && drawInThisContext && !MACRO_DrawNames(context))
	{
		switch (m_selectionBehavior)
		{
		case SELECTION_AA_BBOX:
			drawBB(context.bbDefaultCol);
			break;
		case SELECTION_FIT_BBOX:
			{
				ccGLMatrix trans;
				ccBBox box = getFitBB(trans);
				if (box.isValid())
				{
					glMatrixMode(GL_MODELVIEW);
					glPushMatrix();
					glMultMatrixf(trans.data());
					box.draw(context.bbDefaultCol);
					glPopMatrix();
				}
			}
			break;
		case SELECTION_IGNORED:
			break;
		default:
			assert(false);
		}
	}

	if (draw3D && m_glTransEnabled)
		glPopMatrix();
}
Exemplo n.º 3
0
//================================================draw====================================================//
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
	if (!isEnabled())return;  //是否开启

	//are we currently drawing objects in 2D or 3D?
	bool draw3D = MACRO_Draw3D(context); //判断是在三维上绘制还是在二维上绘制?
	
	//the entity must be either visible and selected, and of course it should be displayed in this context
	//是否可视,是否被选择,是否在当前窗口下显示
	bool drawInThisContext = ((m_visible || m_selected) && m_currentDisplay == context._win); 

	//no need to display anything but clouds and meshes in "element picking mode"
	drawInThisContext &= (	( !MACRO_DrawPointNames(context)	|| isKindOf(CC_TYPES::POINT_CLOUD) ) || 
							( !MACRO_DrawTriangleNames(context)	|| isKindOf(CC_TYPES::MESH) ));

	if (draw3D){
		//apply 3D 'temporary' transformation (for display only)
		if (m_glTransEnabled){  //可以进行变换		
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			glMultMatrixf(m_glTrans.data());
		}

		if (	context.decimateCloudOnMove						//LOD for clouds is enabled?
			&&	context.currentLODLevel >= context.minLODLevel	//and we are currently rendering higher levels?
			){
			//only for real clouds
			drawInThisContext &= isA(CC_TYPES::POINT_CLOUD); //LOD只对点云有效??????????
		}
	}

	//draw entity
	if (m_visible && drawInThisContext){
		if (( !m_selected || !MACRO_SkipSelected(context) ) &&
			(  m_selected || !MACRO_SkipUnselected(context) ))
		{
			//apply default color (in case of)
			ccGL::Color3v(context.pointsDefaultCol.rgb);

			//不同的物体绘制方式不同
			drawMeOnly(context);
			 
			//draw name in 3D (we display it in the 2D foreground layer in fact!)
			if (m_showNameIn3D && MACRO_Draw2D(context) && MACRO_Foreground(context) && !MACRO_DrawNames(context))
				drawNameIn3D(context);
		}
	}

	//draw entity's children
	//绘制物体的子物体
	for (Container::iterator it = m_children.begin(); it != m_children.end(); ++it)
		(*it)->draw(context);

	//绘制BB
	//if the entity is currently selected, we draw its bounding-box
	if (m_selected && draw3D && drawInThisContext && !MACRO_DrawNames(context) && context.currentLODLevel == 0){
		drawBB(context.bbDefaultCol);
	}

	if (draw3D && m_glTransEnabled)
		glPopMatrix();
}
Exemplo n.º 4
0
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
	if (!isEnabled())
		return;

	bool draw3D = MACRO_Draw3D(context);
	bool drawInThisContext = (!m_visible && !m_selected ? false : m_currentDisplay == context._win);

	//no need to display anything but clouds and meshes in "point picking mode"
	bool DrawMesh = false;
	if (MACRO_DrawTriangleNames(context) && isKindOf(CC_MESH))
	{
		ccGenericMesh *mesh = static_cast<ccGenericMesh*>(this);
		ccGenericPointCloud *cloud = mesh->getAssociatedCloud();
		DrawMesh = (cloud == NULL || !cloud->isEnabled());
	}
	drawInThisContext &= (
		                 (!MACRO_DrawPointNames(context) || isKindOf(CC_POINT_CLOUD)) || 
		                 (!MACRO_DrawTriangleNames(context) || DrawMesh)
						 );

	//apply 3D 'temporary' transformation (for display only)
	if (draw3D && m_glTransEnabled)
	{
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glMultMatrixf(m_glTrans.data());
	}

	//draw entity
	if (m_visible && drawInThisContext)
	{
		if ((!m_selected || !MACRO_SkipSelected(context)) &&
			(m_selected || !MACRO_SkipUnselected(context)))
		{
			glColor3ubv(context.pointsDefaultCol);
			drawMeOnly(context);

			//draw name in 3D (we display it in the 2D foreground layer in fact!)
			if (m_showNameIn3D && MACRO_Draw2D(context) && MACRO_Foreground(context) && !MACRO_DrawNames(context))
				drawNameIn3D(context);
		}
	}

	//draw entity's children
	for (Container::iterator it = m_children.begin(); it!=m_children.end(); ++it)
		(*it)->draw(context);

	//if the entity is currently selected
	if (m_selected && draw3D && drawInThisContext)
	{
		switch (m_selectionBehavior)
		{
		case SELECTION_AA_BBOX:
			drawBB(context.bbDefaultCol);
			break;
		case SELECTION_FIT_BBOX:
			{
				ccGLMatrix trans;
				ccBBox box = getFitBB(trans);
				if (box.isValid())
				{
					glMatrixMode(GL_MODELVIEW);
					glPushMatrix();
					glMultMatrixf(trans.data());
					box.draw(context.bbDefaultCol);
					glPopMatrix();
				}
			}
			break;
		case SELECTION_IGNORED:
			break;
		default:
			assert(false);
		}
	}

	if (draw3D && m_glTransEnabled)
		glPopMatrix();
}
Exemplo n.º 5
0
void ccHObject::draw(CC_DRAW_CONTEXT& context)
{
	if (!isEnabled())
		return;

	bool draw3D = MACRO_Draw3D(context);
	bool drawInThisContext = (!visible && !selected ? false : currentDisplay == context._win);

	//no need to display anything but clouds in "point picking mode"
	drawInThisContext &= (!MACRO_DrawPointNames(context) || isKindOf(CC_POINT_CLOUD));

	//apply 3D 'temporary' transformation (for display only)
	if (draw3D && glTransEnabled)
	{
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glMultMatrixf(glTrans.data());
	}

	//draw entity
	if (visible && drawInThisContext)
	{
		if ((!selected || !MACRO_SkipSelected(context)) &&
			(selected || !MACRO_SkipUnselected(context)))
		{
			glColor3ubv(context.pointsDefaultCol);
			drawMeOnly(context);
		}
	}

	//draw entity's children
	for (Container::iterator it = m_children.begin(); it!=m_children.end(); ++it)
		(*it)->draw(context);

	//if the entity is currently selected
	if (selected && draw3D && drawInThisContext)
	{
		switch (m_selectionBehavior)
		{
		case SELECTION_AA_BBOX:
			drawBB(context.bbDefaultCol);
			break;
		case SELECTION_FIT_BBOX:
			{
				ccGLMatrix trans;
				ccBBox box = getFitBB(trans);
				if (box.isValid())
				{
					glMatrixMode(GL_MODELVIEW);
					glPushMatrix();
					glMultMatrixf(trans.data());
					box.draw(context.bbDefaultCol);
					glPopMatrix();
				}
			}
			break;
		case SELECTION_IGNORED:
			break;
		default:
			assert(false);
		}
	}

	if (draw3D && glTransEnabled)
		glPopMatrix();
}