Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit b4c68d6b authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Text alignment fixed in the renderText function of the GLViewer class.

Performance counter activated when F12 is pressed.
parent 685e2162
...@@ -216,6 +216,7 @@ void GLViewer::init( DisplayDoF dof ) ...@@ -216,6 +216,7 @@ void GLViewer::init( DisplayDoF dof )
m_AnimationsRunningAtPreviousFrame = false; m_AnimationsRunningAtPreviousFrame = false;
m_PerformanceCounterEnabled = false;
// Initialize the layout that will contains options for all active displayables. // Initialize the layout that will contains options for all active displayables.
...@@ -901,6 +902,7 @@ void GLViewer::manageAnimations() ...@@ -901,6 +902,7 @@ void GLViewer::manageAnimations()
TimeMeasurement now = std::chrono::high_resolution_clock::now(); TimeMeasurement now = std::chrono::high_resolution_clock::now();
double dt = 0.000001 * std::chrono::duration_cast< std::chrono::microseconds >( now - m_AnimationFrameTime ).count(); double dt = 0.000001 * std::chrono::duration_cast< std::chrono::microseconds >( now - m_AnimationFrameTime ).count();
m_AnimationFrameTime = now; m_AnimationFrameTime = now;
m_AnimationFrameRate = float( 1.0 / dt );
// Make all active animated objects to execute a new animation step. // Make all active animated objects to execute a new animation step.
...@@ -1078,7 +1080,7 @@ void GLViewer::paintGL() ...@@ -1078,7 +1080,7 @@ void GLViewer::paintGL()
QString label = m_BelowCursor->displayable->label(); QString label = m_BelowCursor->displayable->label();
QFont f( font().family(), 10, QFont::Bold ); QFont f( font().family(), 10, QFont::Bold );
Qt::Alignment align = static_cast<Qt::Alignment>( Qt::AlignHCenter | Qt::AlignTop ); Qt::Alignment align = static_cast<Qt::Alignment>( Qt::AlignHCenter | Qt::AlignBottom );
glColor3ub( 220, 220, 220 ); glColor3ub( 220, 220, 220 );
renderText( textX-1, textY-1, label, f, align ); renderText( textX-1, textY-1, label, f, align );
...@@ -1097,6 +1099,15 @@ void GLViewer::paintGL() ...@@ -1097,6 +1099,15 @@ void GLViewer::paintGL()
} }
if( m_PerformanceCounterEnabled )
{
QString label = QString::number( m_AnimationFrameRate, 'f', 2 ) + " FPS";
glColor3ub( 0, 0, 0 );
renderText( 10, 10, label, QFont( font().family(), 20, QFont::Bold ), static_cast<Qt::Alignment>( Qt::AlignLeft | Qt::AlignTop ) );
update();
}
// Display the information bar. // Display the information bar.
m_InfoBarManager->display(); m_InfoBarManager->display();
} }
...@@ -1213,12 +1224,12 @@ void GLViewer::displayLabel( DisplayableInterface *d ) ...@@ -1213,12 +1224,12 @@ void GLViewer::displayLabel( DisplayableInterface *d )
int textY = bottomLeft.y() - 2; int textY = bottomLeft.y() - 2;
glColor3ub( 220, 220, 220 ); glColor3ub( 220, 220, 220 );
renderText( textX-1, textY-1, imgName, f, Qt::AlignTop ); renderText( textX-1, textY-1, imgName, f, Qt::AlignBottom );
renderText( textX-1, textY+1, imgName, f, Qt::AlignTop ); renderText( textX-1, textY+1, imgName, f, Qt::AlignBottom );
renderText( textX+1, textY-1, imgName, f, Qt::AlignTop ); renderText( textX+1, textY-1, imgName, f, Qt::AlignBottom );
renderText( textX+1, textY+1, imgName, f, Qt::AlignTop ); renderText( textX+1, textY+1, imgName, f, Qt::AlignBottom );
glColor3ub( 64, 64, 64 ); glColor3ub( 64, 64, 64 );
renderText( textX, textY, imgName, f, Qt::AlignTop ); renderText( textX, textY, imgName, f, Qt::AlignBottom );
} }
} }
} }
...@@ -1516,10 +1527,12 @@ void GLViewer::renderText( double x, double y, const QString &text, const QFont ...@@ -1516,10 +1527,12 @@ void GLViewer::renderText( double x, double y, const QString &text, const QFont
// Paint text. // Paint text.
if( align & Qt::AlignTop ) if( align & Qt::AlignBottom )
y -= (textLines.size()-1) * fm.height() + fm.descent(); y -= (textLines.size()-1) * fm.lineSpacing() + fm.descent();
else if( align & Qt::AlignCenter ) else if( align & Qt::AlignVCenter )
y -= ((textLines.size()-2) * fm.height())/2/* + fm.descent()*/; y -= ((textLines.size()) * fm.lineSpacing())/2 - fm.ascent();
else if( align & Qt::AlignTop )
y += fm.ascent();
QPainter painter; QPainter painter;
painter.begin( this ); painter.begin( this );
...@@ -1533,7 +1546,7 @@ void GLViewer::renderText( double x, double y, const QString &text, const QFont ...@@ -1533,7 +1546,7 @@ void GLViewer::renderText( double x, double y, const QString &text, const QFont
painter.drawText( x - fm.width(l)/2, y, l ); painter.drawText( x - fm.width(l)/2, y, l );
else else
painter.drawText( x, y, l ); painter.drawText( x, y, l );
y += fm.height(); y += fm.lineSpacing();
} }
painter.end(); painter.end();
...@@ -2105,7 +2118,6 @@ void GLViewer::keyPressEvent( QKeyEvent *evt ) ...@@ -2105,7 +2118,6 @@ void GLViewer::keyPressEvent( QKeyEvent *evt )
case Qt::Key_F9: case Qt::Key_F9:
case Qt::Key_F10: case Qt::Key_F10:
case Qt::Key_F11: case Qt::Key_F11:
case Qt::Key_F12:
{ {
qint32 viewId = evt->key() - Qt::Key_F1; qint32 viewId = evt->key() - Qt::Key_F1;
std::ostringstream filename; std::ostringstream filename;
...@@ -2129,7 +2141,13 @@ void GLViewer::keyPressEvent( QKeyEvent *evt ) ...@@ -2129,7 +2141,13 @@ void GLViewer::keyPressEvent( QKeyEvent *evt )
break; break;
} }
case Qt::Key_PageDown: m_ChangeNearPlaneMode = true; break; case Qt::Key_F12:
{
m_PerformanceCounterEnabled = !m_PerformanceCounterEnabled;
update();
break;
}
case Qt::Key_PageDown: m_ChangeNearPlaneMode = true; break;
case Qt::Key_PageUp: m_ChangeFarPlaneMode = true; break; case Qt::Key_PageUp: m_ChangeFarPlaneMode = true; break;
default: emit keyPressed( evt ); default: emit keyPressed( evt );
} }
......
...@@ -142,6 +142,9 @@ protected: ...@@ -142,6 +142,9 @@ protected:
TimeMeasurement m_AnimationFrameTime; TimeMeasurement m_AnimationFrameTime;
QMap<DisplayableInterface*,double> m_ActiveAnimations; QMap<DisplayableInterface*,double> m_ActiveAnimations;
bool m_AnimationsRunningAtPreviousFrame; bool m_AnimationsRunningAtPreviousFrame;
float m_AnimationFrameRate;
bool m_PerformanceCounterEnabled;
bool m_SelectionEnabled; bool m_SelectionEnabled;
SelectionToolName m_SelectionCurrentToolName; SelectionToolName m_SelectionCurrentToolName;
...@@ -330,8 +333,8 @@ public: ...@@ -330,8 +333,8 @@ public:
void processSelection( DisplayableInterface *d, BaseSelectionProcessor &proc ); void processSelection( DisplayableInterface *d, BaseSelectionProcessor &proc );
void renderCoords( double x, double y, double z, double *screenX, double *screenY ); void renderCoords( double x, double y, double z, double *screenX, double *screenY );
void renderText( double x, double y, const QString &text, const QFont &font = QFont(), Qt::Alignment align = Qt::AlignLeft ); void renderText( double x, double y, const QString &text, const QFont &font = QFont(), Qt::Alignment align = 0 );
void renderText( double x, double y, double z, const QString &text, const QFont &font = QFont(), Qt::Alignment align = Qt::AlignLeft ); void renderText( double x, double y, double z, const QString &text, const QFont &font = QFont(), Qt::Alignment align = 0 );
bool imageOfCurrentDisplay( const GenericUIData *m, QImage &renderResult ); bool imageOfCurrentDisplay( const GenericUIData *m, QImage &renderResult );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment