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

LightDirectionWidget display now modified when disabled.

parent 8ff93fb5
......@@ -13,6 +13,10 @@
void LightDirectionWidget::updateSphereImageContent()
{
QPalette palette = this->palette();
QColor dark = palette.windowText().color();
QColor light = palette.window().color();
for( int i=0, n=0; i<height(); ++i )
for( int j=0; j<width(); ++j, ++n )
{
......@@ -20,8 +24,15 @@ void LightDirectionWidget::updateSphereImageContent()
if( v.z() != -1.0f )
{
float lum = QVector3D::dotProduct( m_LightDir, v );
int c = int( 255.0f * std::max( lum, 0.0f ) );
m_SphereImg.setPixelColor( j, i, QColor(c,c,c,255) );
lum = std::max( 0.0f, std::min( 1.0f, lum ) );
QColor c;
c.setRed ( (1.0f-lum)*dark.red () + lum*light.red () );
c.setGreen( (1.0f-lum)*dark.green() + lum*light.green() );
c.setBlue ( (1.0f-lum)*dark.blue () + lum*light.blue () );
c.setAlpha( 255 );
m_SphereImg.setPixelColor( j, i, c );
}
else
m_SphereImg.setPixelColor( j, i, QColor(0,0,0,0) );
......@@ -105,3 +116,10 @@ void LightDirectionWidget::mouseMoveEvent( QMouseEvent *evt )
setDirection( dir.normalized() );
}
}
void LightDirectionWidget::changeEvent( QEvent *evt )
{
if( evt->type() == QEvent::EnabledChange )
updateSphereImageContent();
}
......@@ -25,15 +25,16 @@ class LightDirectionWidget : public QWidget
void updateSphereImageContent();
public:
LightDirectionWidget( const QString& label, QWidget *parent = NULL );
void resizeEvent( QResizeEvent *evt );
void paintEvent( QPaintEvent *evt );
void mouseDoubleClickEvent( QMouseEvent *evt );
void mousePressEvent( QMouseEvent *evt );
void mouseMoveEvent( QMouseEvent *evt );
void changeEvent( QEvent *evt );
public:
LightDirectionWidget( const QString& label, QWidget *parent = NULL );
inline QVector3D getDirection() const { return m_LightDir; }
inline void setDirection( const QVector3D &dir ) { m_LightDir = dir; updateSphereImageContent(); emit directionModified(); }
......
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