int GraphView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = CommonView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 6)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 6;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< GraphWidget::Orientation*>(_v) = orientation(); break;
        case 1: *reinterpret_cast< GraphWidget::Mode*>(_v) = mode(); break;
        case 2: *reinterpret_cast< int*>(_v) = timeLinesCount(); break;
        case 3: *reinterpret_cast< int*>(_v) = valueLinesCount(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = cursorColor(); break;
        case 5: *reinterpret_cast< QColor*>(_v) = linesColor(); break;
        case 6: *reinterpret_cast< QColor*>(_v) = textColor(); break;
        case 7: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 8: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 9: *reinterpret_cast< Plots*>(_v) = plots(); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOrientation(*reinterpret_cast< GraphWidget::Orientation*>(_v)); break;
        case 1: setMode(*reinterpret_cast< GraphWidget::Mode*>(_v)); break;
        case 2: setTimeLinesCount(*reinterpret_cast< int*>(_v)); break;
        case 3: setValueLinesCount(*reinterpret_cast< int*>(_v)); break;
        case 4: setCursorColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setLinesColor(*reinterpret_cast< QColor*>(_v)); break;
        case 6: setTextColor(*reinterpret_cast< QColor*>(_v)); break;
        case 7: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 8: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 9: setPlots(*reinterpret_cast< Plots*>(_v)); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 10;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 2
0
//==============================
// OvrGazeCursorLocal::Render
void OvrGazeCursorLocal::Render( int const eye, Matrix4f const & mvp ) const
{
	GL_CheckErrors( "OvrGazeCursorLocal::Render - pre" );

	//LOG( "OvrGazeCursorLocal::Render" );

	if ( HiddenFrames >= 0 )
	{
		return;
	}

	if ( !HasUser && !TimerActive() )
	{
		return;
	}

	if ( Hidden && !TimerActive() )
	{
		return;
	}

	if ( CursorScale <= 0.0f )
	{
		LOG( "OvrGazeCursorLocal::Render - scale 0" );
		return;
	}

	// It is important that glBlendFuncSeparate be used so that destination alpha
	// correctly holds the opacity over the overlay plane.  If normal blending is
	// used, the cursor ghosts will "punch holes" in things through to the overlay plane.
	glEnable( GL_BLEND );
	glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA );

	// If the cursor is not active, allow it to depth sort... if it is active we know it should
	// be on top, so don't bother depth testing. However, this assumes that the cursor is placed 
	// correctly. If it isn't, then it could still appear stereoscopically behind the object it's
	// on top of, which would be bad. The reason for not using depth testing when active is to
	// solve any z-fighting issues, particularly with SwipeView, where the panel distance isn't
	// entirely accurate right now. It can also be solved by pushing the cursor in a little bit
	// from the panel, but in stereo vision it looks like it's floating further above the panel
	// than it does with other systems like the VRMenu.

	glDepthMask( GL_FALSE );	// don't write to depth, or ghost trails wouldn't work

	// We always want depth test enabled so we can see if any GUI panels have
	// been placed too close and obscured the cursor.
	glEnable( GL_DEPTH_TEST );

	glUseProgram( CursorProgram.program );
	glActiveTexture( GL_TEXTURE0 );
	glBindTexture( GL_TEXTURE_2D, CursorTextureHandle[Info.State] );

	// draw from oldest and faintest to newest
	for ( int i = TRAIL_GHOSTS-1 ; i >= 0 ; i-- )
	{
		const int index = ( CurrentTransform - i ) % TRAIL_GHOSTS;
		if ( index <= 0 )
		{
			continue;
		}
		Vector4f cursorColor( 1.0f, 1.0f, 1.0f, 0.5 * ( 1.0 - (float)i / TRAIL_GHOSTS ) );
		glUniform4fv( CursorProgram.uColor, 1, &cursorColor.x );
		Matrix4f cursorMVP = mvp * CursorTransform[index];
		glUniformMatrix4fv( CursorProgram.uMvp, 1, GL_FALSE, cursorMVP.Transposed().M[0] );
		CursorGeometry.Draw();
	}

	// Reverse depth test and draw the scattered ghosts where they are occluded
	glDepthFunc( GL_GREATER );

	for ( int i = TRAIL_GHOSTS-1 ; i >= 0 ; i-- )
	{
		const int index = ( CurrentTransform - i ) % TRAIL_GHOSTS;
		if ( index <= 0 )
		{
			continue;
		}
		Vector4f cursorColor( 1.0f, 0.0f, 0.0f, 0.15 * ( 1.0 - (float)i / TRAIL_GHOSTS ) );
		glUniform4fv( CursorProgram.uColor, 1, &cursorColor.x );
		Matrix4f cursorMVP = mvp * CursorScatterTransform[index];
		glUniformMatrix4fv( CursorProgram.uMvp, 1, GL_FALSE, cursorMVP.Transposed().M[0] );
		CursorGeometry.Draw();
	}

	glDepthFunc( GL_LEQUAL );

	// draw the timer if it's enabled
	if ( TimerEndTime > 0.0 && ovr_GetTimeInSeconds() >= TimerShowTime )
	{
		glUseProgram( TimerProgram.program );
		glActiveTexture( GL_TEXTURE0 );
		glBindTexture( GL_TEXTURE_2D, TimerTextureHandle );

		glActiveTexture( GL_TEXTURE1 );
		glBindTexture( GL_TEXTURE_2D, ColorTableHandle );
		// do not do any filtering on the "palette" texture
		glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f );
		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
		glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

		Matrix4f timerMVP = mvp * TimerTransform;
		glUniformMatrix4fv( TimerProgram.uMvp, 1, GL_FALSE, timerMVP.Transposed().M[0] );

		Vector4f cursorColor( 0.0f, 0.643f, 1.0f, 1.0f );
		glUniform4fv( TimerProgram.uColor, 1, &cursorColor.x );
		glUniform2fv( TimerProgram.uColorTableOffset, 1, &ColorTableOffset.x );

		CursorGeometry.Draw();
	}

	glDepthMask( GL_TRUE );
	glDisable( GL_BLEND );

	GL_CheckErrors( "OvrGazeCursorLocal::Render - post" );
}
Exemplo n.º 3
0
void WindowEdit::onRender( RenderContext & context, const RectInt & window )
{
	if (! windowStyle() )
		return;

	DisplayDevice * pDisplay = context.display();
	ASSERT( pDisplay );
	Font * pFont = windowStyle()->font();
	ASSERT( pFont );

	// calculate the total text size
	SizeInt textSize( pFont->size( WideString( m_Text ) ) );
	// get the text color
	Color textColor( windowStyle()->color() );
	textColor.m_A = m_Editing ? ACTIVE_ALPHA : INACTIVE_ALPHA;

	SizeInt windowSize( window.size() );

	// check the size of the window compared to the text size
	m_EditBegin = 0;
	m_EditEnd = m_Text.length() - 1;
	while ( textSize.m_Width > windowSize.m_Width )
	{
		if ( m_EditBegin < m_Cursor )
		{
			textSize.m_Width -= pFont->characterWidth( m_Text[ m_EditBegin ] );
			m_EditBegin++;
		}
		else if ( m_EditEnd > m_Cursor )
		{
			textSize.m_Width -= pFont->characterWidth( m_Text[ m_EditEnd ] );
			m_EditEnd--;
		}
		else	// not enough room, the font is probably too large so just return
			return;
	}

	// extract the displayable part of the text
	WideString display( m_Text );
	display.mid( m_EditBegin, (m_EditEnd - m_EditBegin) + 1 );

	// draw text left justified and centered vertically
	PointInt ptText( window.m_Left, window.m_Top + ((windowSize.m_Height / 2) - (textSize.m_Height / 2)) );
	// draw the text, construct another PointInt on the stack because Font::push will modify the point
	PointInt ptText2 = ptText;
	Font::push( pDisplay, pFont, ptText2, display, textColor );

	// display cursor if editing
	if ( m_Editing )
	{
		// draw cursor
		for(int i=m_EditBegin;i<m_Cursor;i++)
			ptText.m_X += pFont->characterWidth( m_Text[i] );

		Color cursorColor( textColor );
		cursorColor.m_A = (u8)(fmod( m_ActiveTime, CURSOR_BLINK_RATE ) * 255);

		RectInt cursorRect( ptText, SizeInt( CURSOR_WIDTH, textSize.height ) );

		PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::ADDITIVE );
		PrimitiveWindow::push( pDisplay, cursorRect , RectFloat(0,0,0,0), cursorColor );
	}
}