Browse Source

COMP: fix for platforms on which qreal is not the same as double

Marco Nolden 11 years ago
parent
commit
6fa18a7c1a
1 changed files with 7 additions and 7 deletions
  1. 7 7
      Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp

+ 7 - 7
Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp

@@ -302,9 +302,9 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
         qreal specularComp = specular*pow(specularDot, specular_power);
         qreal specularComp = specular*pow(specularDot, specular_power);
         
         
         QVector3D intensity;
         QVector3D intensity;
-        intensity.setX( qMin((ambient + diffuseComp)*d->Color.redF() + specularComp, 1.));
-        intensity.setY( qMin((ambient + diffuseComp)*d->Color.greenF() + specularComp, 1.));
-        intensity.setZ( qMin((ambient + diffuseComp)*d->Color.blueF() + specularComp, 1.));
+        intensity.setX( qMin((ambient + diffuseComp)*d->Color.redF() + specularComp, static_cast<qreal>(1.)));
+        intensity.setY( qMin((ambient + diffuseComp)*d->Color.greenF() + specularComp, static_cast<qreal>(1.)));
+        intensity.setZ( qMin((ambient + diffuseComp)*d->Color.blueF() + specularComp, static_cast<qreal>(1.)));
         
         
         if (opacity == 1.)
         if (opacity == 1.)
           {
           {
@@ -315,10 +315,10 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
           }
           }
         else
         else
           {
           {
-          rgba = qRgba(static_cast<unsigned char>(qMin(255. * intensity.x() * opacity + qRed(rgba)*(1. - opacity), 255.)),
-                       static_cast<unsigned char>(qMin(255. * intensity.y() * opacity + qGreen(rgba)*(1. - opacity), 255.)),
-                       static_cast<unsigned char>(qMin(255. * intensity.z() * opacity + qBlue(rgba)*(1. - opacity), 255.)),
-                       static_cast<unsigned char>(qMin(255. * opacity + qAlpha(rgba)*(1. - opacity), 255.)));
+          rgba = qRgba(static_cast<unsigned char>(qMin(255. * intensity.x() * opacity + qRed(rgba)*(1. - opacity), static_cast<qreal>(255.))),
+                       static_cast<unsigned char>(qMin(255. * intensity.y() * opacity + qGreen(rgba)*(1. - opacity), static_cast<qreal>(255.))),
+                       static_cast<unsigned char>(qMin(255. * intensity.z() * opacity + qBlue(rgba)*(1. - opacity), static_cast<qreal>(255.))),
+                       static_cast<unsigned char>(qMin(255. * opacity + qAlpha(rgba)*(1. - opacity), static_cast<qreal>(255.))));
           }
           }
         }
         }
       image.setPixel(i,j,rgba);
       image.setPixel(i,j,rgba);