]> Creatis software - clitk.git/blobdiff - vv/vvOverlayPanel.cxx
solved bug 519 (Fusion flickering)
[clitk.git] / vv / vvOverlayPanel.cxx
index f19e13b0cc167325b3b9b87826a91ac3a098ead9..bc3a7d0180ffa93dcc024c5e14766fe5f3a7daa2 100644 (file)
@@ -49,6 +49,8 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
   connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
   connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
   connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
+  
+  disableFusionSignals = false;
 }
 
 void vvOverlayPanel::getCurrentImageName(QString name)
@@ -167,18 +169,24 @@ void vvOverlayPanel::getFusionName(QString name)
 void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
 {
   if (opacity > -1) {
+    //first disable signals generated by each setValue() call
+    disableFusionSignals = true;
     fusionFrame->show();
     fusionFrame->setEnabled(1);
+    fusionColorMapComboBox->setEnabled(1);
+    fusionColorMapComboBox->setCurrentIndex(colormap);
     opacityHorizontalSlider->setEnabled(1);
     opacityHorizontalSlider->setValue(opacity);
     thresOpacityHorizontalSlider->setEnabled(1);
     thresOpacityHorizontalSlider->setValue(thresOpacity);
-    fusionColorMapComboBox->setEnabled(1);
-    fusionColorMapComboBox->setCurrentIndex(colormap);
     windowSpinBox->setEnabled(1);
     levelSpinBox->setEnabled(1);
     windowSpinBox->setValue(window);
     levelSpinBox->setValue(level);
+    
+    // re-enable signals and trigger slot function
+    disableFusionSignals = false;
+    setFusionProperty();
   } else {
     fusionFrame->hide();
     fusionFrame->setEnabled(0);
@@ -195,6 +203,9 @@ void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colorm
 
 void vvOverlayPanel::setFusionProperty()
 {
+  if (disableFusionSignals)
+    return;
+  
   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
                              windowSpinBox->value(), levelSpinBox->value());
 }