]> Creatis software - clitk.git/blobdiff - vv/vvOverlayPanel.cxx
remove tools (now in tests_dav)
[clitk.git] / vv / vvOverlayPanel.cxx
index f19e13b0cc167325b3b9b87826a91ac3a098ead9..28d893991556a77eed1277aa8e4738989040428b 100644 (file)
@@ -47,8 +47,15 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent)
   connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
   connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
   connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
-  connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
-  connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
+  connect(fusionWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
+  connect(fusionLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
+  connect(fusionOpacitySpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
+  connect(fusionThresSpin,SIGNAL(valueChanged(double)),this,SLOT(setFusionSpinProperty()));
+  connect(overlayWindowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
+  connect(overlayLevelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setOverlayProperty()));
+  connect(overlayLinkCheckBox,SIGNAL(stateChanged(int)),this,SLOT(setOverlayProperty()));
+
+  disableFusionSignals = false;
 }
 
 void vvOverlayPanel::getCurrentImageName(QString name)
@@ -123,13 +130,16 @@ void vvOverlayPanel::getOverlayName(QString name)
   imageComparedLabel->setText(filename.toStdString().c_str());
 }
 
-void vvOverlayPanel::getOverlayProperty(int value)
+void vvOverlayPanel::getOverlayProperty(int color, int linked, double window, double level)
 {
-  if (value > -1) {
+  if (color > -1) {
     compareFrame->show();
     compareFrame->setEnabled(1);
     colorHorizontalSlider->setEnabled(1);
-    colorHorizontalSlider->setValue(value);
+    colorHorizontalSlider->setValue(color);
+    overlayLinkCheckBox->setCheckState( (linked)?Qt::Checked:Qt::Unchecked );
+    overlayWindowSpinBox->setValue(window);
+    overlayLevelSpinBox->setValue(level);
   } else {
     compareFrame->hide();
     compareFrame->setEnabled(0);
@@ -140,7 +150,12 @@ void vvOverlayPanel::getOverlayProperty(int value)
 
 void vvOverlayPanel::setOverlayProperty()
 {
-  emit OverlayPropertyUpdated(colorHorizontalSlider->value());
+  overlayWindowSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
+  overlayLevelSpinBox->setEnabled(!overlayLinkCheckBox->checkState());
+  emit OverlayPropertyUpdated(colorHorizontalSlider->value(),
+                              overlayLinkCheckBox->checkState(),
+                              overlayWindowSpinBox->value(),
+                              overlayLevelSpinBox->value());
 }
 
 void vvOverlayPanel::getCurrentOverlayInfo(int visibility,double valueOver, double valueRef)
@@ -167,18 +182,26 @@ 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);
+    fusionOpacitySpin->setValue(opacity); 
+    fusionThresSpin->setValue(thresOpacity);
+    fusionWindowSpinBox->setEnabled(1);
+    fusionLevelSpinBox->setEnabled(1);
+    fusionWindowSpinBox->setValue(window);
+    fusionLevelSpinBox->setValue(level);
+    
+    // re-enable signals and trigger slot function
+    disableFusionSignals = false;
+    setFusionProperty();
   } else {
     fusionFrame->hide();
     fusionFrame->setEnabled(0);
@@ -186,17 +209,31 @@ void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colorm
     opacityHorizontalSlider->setValue(0);
     thresOpacityHorizontalSlider->setEnabled(0);
     thresOpacityHorizontalSlider->setValue(0);
+    fusionOpacitySpin->setValue(0); 
+    fusionThresSpin->setValue(0);
     fusionColorMapComboBox->setEnabled(0);
     fusionColorMapComboBox->setCurrentIndex(-1);
-    windowSpinBox->setEnabled(0);
-    levelSpinBox->setEnabled(0);
+    fusionWindowSpinBox->setEnabled(0);
+    fusionLevelSpinBox->setEnabled(0);
   }
 }
 
 void vvOverlayPanel::setFusionProperty()
 {
+  if (disableFusionSignals)
+    return;
+  
+  fusionOpacitySpin->setValue(opacityHorizontalSlider->value()); 
+  fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
+
   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
-                             windowSpinBox->value(), levelSpinBox->value());
+                             fusionWindowSpinBox->value(), fusionLevelSpinBox->value());
+}
+
+void vvOverlayPanel::setFusionSpinProperty()
+{
+  opacityHorizontalSlider->setValue(fusionOpacitySpin->value()); 
+  thresOpacityHorizontalSlider->setValue(fusionThresSpin->value());
 }
 
 void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value)
@@ -213,7 +250,8 @@ void vvOverlayPanel::VFColorChangeRequest()
   QColor color(vfColorButton->palette().color(QPalette::Background));
   color = QColorDialog::getColor(color, this, "Choose the new color of the vector field");
   //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working?
-  vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
+  if (color.isValid())
+    vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }");
   this->setVFProperty();
 }