예제 #1
0
void GLWidget::mainDraw() {
   if ( actionOn->isChecked() ==false ) return;
   if (ALLOW_QPAINTER) {
    makeCurrent();
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    myGLinit();
    setupViewPort(width(), height());
   }

   myGLdraw();

   if (ALLOW_QPAINTER) {
    /// new qpainter overlay stuff
    QTransform trans=zoom.getQTransform(false);
    QPainter painter;
    painter.begin((QGLWidget*)this);
    painter.setRenderHint(QPainter::Antialiasing);
    myQPainterOverlay(painter,trans);
  
    painter.end();
  
    glMatrixMode ( GL_MODELVIEW );
    glPopMatrix();
  }
   c_draw.count();
}
예제 #2
0
void POIsImageWidget::paintEvent(QPaintEvent *paintEvent) {

	//--- Make this widget the current context for OpenGL drawing
	makeCurrent();

	//Save current state, QPainter modifies MODELVIEW matrix.
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	setupViewPort(width(), height());

	glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	drawBackgroundImage();

	//Restore state after drawing pure openGL
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	QPainter painter;
	painter.begin(this);
	drawPOIs(&painter);
	painter.end();

	//--- Set OpenGL drawing context to no area
	doneCurrent();

}
예제 #3
0
/**
*Overrides the paintGL method of the base class.
*Dispatches the handling to the active child application.
*/
void ThreeDWidget::paintGL()
{
	qreal pixelRatio = 1;
#if QT_VERSION >= 0x050000
	pixelRatio = devicePixelRatio();
#endif
	setupViewPort(width() * pixelRatio, height() * pixelRatio);

	if(m_iView==GLMIAREXVIEW)
	{
		QMiarex* pMiarex = (QMiarex*)s_pMiarex;
		pMiarex->GLDraw3D();
		if(pMiarex->m_iView==W3DVIEW) pMiarex->GLRenderView();
	}
	else if(m_iView == GLBODYVIEW)
	{
		GL3dBodyDlg *pDlg = (GL3dBodyDlg*)m_pParent;
		pDlg->GLDraw3D();
		pDlg->GLRenderBody();
	}
	else if(m_iView == GLWINGVIEW)
	{
		GL3dWingDlg *pDlg = (GL3dWingDlg*)m_pParent;
		pDlg->GLDraw3D();
		pDlg->GLRenderView();
	}
}
예제 #4
0
/**
*Overrides the resizeGL method of the base class.
* Sets the GL viewport to fit in the client area.
* Sets the scaling factors for the objects to be drawn in the viewport.
*@param width the width in pixels of the client area
*@param height the height in pixels of the client area
*/
void ThreeDWidget::resizeGL(int width, int height)
{
	double w, h, s;
	m_rCltRect = geometry();
	w = (double)width;
	h = (double)height;
	s = 1.0;

	makeCurrent();

	setupViewPort(width, height);

	glLoadIdentity();
	if(w>h)	m_GLViewRect.SetRect(-s, s*h/w, s, -s*h/w);
	else    m_GLViewRect.SetRect(-s*w/h, s, s*w/h, -s*h/w);

	if(m_iView == GLMIAREXVIEW)
	{
		QMiarex* pMiarex = (QMiarex*)s_pMiarex;
//		pMiarex->m_ArcBall.GetMatrix();
		pMiarex->m_bIs3DScaleSet = false;
        pMiarex->m_bResetTextLegend = true;
		pMiarex->Set3DScale();
	}
	else if(m_iView == GLWINGVIEW)
	{
	}
	else if(m_iView == GLBODYVIEW)
	{
		GL3dBodyDlg *pDlg = (GL3dBodyDlg*)m_pParent;
		pDlg->m_bIs3DScaleSet = false;
		pDlg->SetRectangles();
		pDlg->SetBodyScale();
		pDlg->SetBodyLineScale();
		pDlg->SetFrameScale();
	}
}
예제 #5
0
///Create Direct3D Device
HRESULT initD3D(HWND hWnd){

	if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
		return E_FAIL;
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_HARDWARE_VERTEXPROCESSING,
		&d3dpp, &g_pDevice ) ) ){
		return E_FAIL;
	}

	g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	g_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);//default is open

	setupViewProjMatrix();
	setupViewPort();

	return S_OK;
}
예제 #6
0
void GLWidget::resizeGL ( int width, int height ) {
  setupViewPort(width,height);
}