From: Simon Rit Date: Tue, 23 Aug 2011 17:05:58 +0000 (+0200) Subject: Allow unlinking of window/level of overlay, enable ctrl+w for local X-Git-Tag: v1.3.0~240^2^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=97b13fba69a83e91416caa9e689e012211649f12;p=clitk.git Allow unlinking of window/level of overlay, enable ctrl+w for local windowing of fusion and overlay image --- diff --git a/vv/qt_ui/vvHelpDialog.ui b/vv/qt_ui/vvHelpDialog.ui index 6c827c3..29623b3 100644 --- a/vv/qt_ui/vvHelpDialog.ui +++ b/vv/qt_ui/vvHelpDialog.ui @@ -22,9 +22,9 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">F1: </span><span style=" font-size:12pt;">Help (this window)</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600; text-decoration: underline;">Slice Selection</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">F2:</span><span style=" font-size:12pt;"> Sagital</span></p> @@ -38,6 +38,10 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">0,1,2,3,4,5</span><span style=" font-size:12pt;"> : Windowing Preset Selection</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">6,7,8,9</span><span style=" font-size:12pt;">: Colormap Selection</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">w</span><span style=" font-size:12pt;">: Local </span><span style=" font-size:12pt; text-decoration: underline;">w</span><span style=" font-size:12pt;">indowing around mouse cursor</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Ctrl+w</span><span style=" font-size:12pt;">: Idem for fusion or overlay</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600; text-decoration: underline;">Miscellaneous</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">l</span><span style=" font-size:12pt;">: Toggle </span><span style=" font-size:12pt; text-decoration: underline;">l</span><span style=" font-size:12pt;">inear interpolation</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">c</span><span style=" font-size:12pt;">: Toggle </span><span style=" font-size:12pt; text-decoration: underline;">c</span><span style=" font-size:12pt;">ontour superposition mode</span></p></body></html> diff --git a/vv/qt_ui/vvOverlayPanel.ui b/vv/qt_ui/vvOverlayPanel.ui index af07fe8..eab2f23 100644 --- a/vv/qt_ui/vvOverlayPanel.ui +++ b/vv/qt_ui/vvOverlayPanel.ui @@ -221,7 +221,7 @@ p, li { white-space: pre-wrap; } QFrame::Raised - + 2 @@ -267,7 +267,7 @@ p, li { white-space: pre-wrap; } - + 359 @@ -277,7 +277,7 @@ p, li { white-space: pre-wrap; } - + @@ -290,7 +290,7 @@ p, li { white-space: pre-wrap; } - + @@ -303,7 +303,7 @@ p, li { white-space: pre-wrap; } - + @@ -316,6 +316,81 @@ p, li { white-space: pre-wrap; } + + + + Window : + + + + + + + 4 + + + -999999.000000000000000 + + + 999999.000000000000000 + + + 10.000000000000000 + + + 100.000000000000000 + + + + + + + Level : + + + + + + + 4 + + + -999999.000000000000000 + + + 999999.000000000000000 + + + 10.000000000000000 + + + 1000.000000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Link + + + true + + + @@ -330,7 +405,7 @@ p, li { white-space: pre-wrap; } QFrame::Raised - + @@ -462,7 +537,7 @@ p, li { white-space: pre-wrap; } - + 4 @@ -488,7 +563,7 @@ p, li { white-space: pre-wrap; } - + 4 @@ -538,7 +613,6 @@ p, li { white-space: pre-wrap; } - diff --git a/vv/vv.cxx b/vv/vv.cxx index 546f68a..9811050 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -192,7 +192,7 @@ int main( int argc, char** argv ) } if(win!="" && lev!="") { - window.WindowLevelChanged(atof(win.c_str()), atof(lev.c_str()), 6, 0); + window.SetWindowLevel(atof(win.c_str()), atof(lev.c_str())); window.ApplyWindowLevelToAllImages(); } diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 3d8c51a..1c2230f 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -294,7 +294,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString))); connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString))); connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double))); - connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int))); + connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int,int,double,double)), + this,SLOT(SetOverlayProperty(int,int,double,double))); connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double)), this,SLOT(SetFusionProperty(int,int,int,double,double))); connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows())); @@ -915,8 +916,8 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa this, SLOT(OverlayChanged(int,double,double))); connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), this, SLOT(FusionChanged(int,double))); - connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)), - this,SLOT(WindowLevelChanged(double, double, int, int))); + connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()), + this,SLOT(WindowLevelChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), @@ -1122,10 +1123,6 @@ void vvMainWindow::ImageInfoChanged() break; } } - windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); - levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); - colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); infoPanel->setFileName(image); infoPanel->setDimension(dim); @@ -1147,10 +1144,7 @@ void vvMainWindow::ImageInfoChanged() break; } } - windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); - levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); - colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); + WindowLevelChanged(); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); @@ -1163,22 +1157,14 @@ void vvMainWindow::ImageInfoChanged() } if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) { overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); - overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor()); } else { overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str()); - overlayPanel->getOverlayProperty(-1); } if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); - overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), - mSlicerManagers[index]->GetFusionThresholdOpacity(), - mSlicerManagers[index]->GetFusionColorMap(), - mSlicerManagers[index]->GetFusionWindow(), - mSlicerManagers[index]->GetFusionLevel()); } else { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); - overlayPanel->getFusionProperty(-1, -1, -1, -1, -1); } } } @@ -1629,12 +1615,34 @@ void vvMainWindow::FusionChanged(int visibility, double value) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap) +void vvMainWindow::WindowLevelChanged() { - windowSpinBox->setValue(window); - levelSpinBox->setValue(level); - colorMapComboBox->setCurrentIndex(colormap); - presetComboBox->setCurrentIndex(preset); + // Base image + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + if(index==-1) return; + windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); + levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); + colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); + presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); + + // Overlay image + if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) + overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor(), + mSlicerManagers[index]->GetLinkOverlayWindowLevel(), + mSlicerManagers[index]->GetOverlayColorWindow(), + mSlicerManagers[index]->GetOverlayColorLevel()); + else + overlayPanel->getOverlayProperty(-1,0,0.,0.); + + // Fusion image + if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) + overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), + mSlicerManagers[index]->GetFusionThresholdOpacity(), + mSlicerManagers[index]->GetFusionColorMap(), + mSlicerManagers[index]->GetFusionWindow(), + mSlicerManagers[index]->GetFusionLevel()); + else + overlayPanel->getFusionProperty(-1, -1, -1, -1, -1); } //------------------------------------------------------------------------------ @@ -1646,6 +1654,17 @@ void vvMainWindow::WindowLevelEdited() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::SetWindowLevel(double w, double l) +{ + windowSpinBox->setValue(w); + levelSpinBox->setValue(l); + presetComboBox->setCurrentIndex(6); + colorMapComboBox->setCurrentIndex(0); + UpdateWindowLevel(); +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateWindowLevel() { @@ -1657,8 +1676,7 @@ void vvMainWindow::UpdateWindowLevel() mSlicerManagers[index]->SetColorLevel(levelSpinBox->value()); mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex()); mSlicerManagers[index]->Render(); - windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); - levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); + WindowLevelChanged(); } } //------------------------------------------------------------------------------ @@ -1854,6 +1872,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) error += mSlicerManagers[index]->GetLastError().c_str(); QMessageBox::information(this,tr("Problem reading image !"),error); } + WindowLevelChanged(); } //------------------------------------------------------------------------------ @@ -2137,12 +2156,15 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, //------------------------------------------------------------------------------ -void vvMainWindow::SetOverlayProperty(int color) +void vvMainWindow::SetOverlayProperty(int color, int linked, double window, double level) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) { mSlicerManagers[index]->SetOverlayColor(color); mSlicerManagers[index]->SetColorMap(0); + mSlicerManagers[index]->SetLinkOverlayWindowLevel(linked); + mSlicerManagers[index]->SetOverlayColorWindow(window); + mSlicerManagers[index]->SetOverlayColorLevel(level); mSlicerManagers[index]->Render(); } } @@ -2836,8 +2858,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen this, SLOT(OverlayChanged(int,double,double))); connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)), this, SLOT(FusionChanged(int,double))); - connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)), - this,SLOT(WindowLevelChanged(double, double, int, int))); + connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()), + this,SLOT(WindowLevelChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)), this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 7da8a91..8ee5ab2 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -101,11 +101,12 @@ public slots: void SegmentationOnCurrentImage(); void SurfaceViewerLaunch(); - void WindowLevelChanged(double window, double level,int preset, int colormap); + void WindowLevelChanged(); void UpdateSlice(int slicer, int slice); void UpdateTSlice(int slicer, int slice); void UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax); void WindowLevelEdited(); + void SetWindowLevel(double w, double l); void UpdateColorMap(); void UpdateWindowLevel(); void SwitchWindowLevel(); @@ -142,7 +143,7 @@ public slots: void ResetTransformationToIdentity(); void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b); - void SetOverlayProperty(int color); + void SetOverlayProperty(int color, int linked, double window, double level); void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level); void GoToCursor(); diff --git a/vv/vvOverlayPanel.cxx b/vv/vvOverlayPanel.cxx index bc3a7d0..eb2eaa1 100644 --- a/vv/vvOverlayPanel.cxx +++ b/vv/vvOverlayPanel.cxx @@ -47,9 +47,12 @@ 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(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; } @@ -125,13 +128,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); @@ -142,7 +148,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) @@ -179,10 +190,10 @@ void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colorm opacityHorizontalSlider->setValue(opacity); thresOpacityHorizontalSlider->setEnabled(1); thresOpacityHorizontalSlider->setValue(thresOpacity); - windowSpinBox->setEnabled(1); - levelSpinBox->setEnabled(1); - windowSpinBox->setValue(window); - levelSpinBox->setValue(level); + fusionWindowSpinBox->setEnabled(1); + fusionLevelSpinBox->setEnabled(1); + fusionWindowSpinBox->setValue(window); + fusionLevelSpinBox->setValue(level); // re-enable signals and trigger slot function disableFusionSignals = false; @@ -196,8 +207,8 @@ void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colorm thresOpacityHorizontalSlider->setValue(0); fusionColorMapComboBox->setEnabled(0); fusionColorMapComboBox->setCurrentIndex(-1); - windowSpinBox->setEnabled(0); - levelSpinBox->setEnabled(0); + fusionWindowSpinBox->setEnabled(0); + fusionLevelSpinBox->setEnabled(0); } } @@ -207,7 +218,7 @@ void vvOverlayPanel::setFusionProperty() return; emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(), - windowSpinBox->value(), levelSpinBox->value()); + fusionWindowSpinBox->value(), fusionLevelSpinBox->value()); } void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value) diff --git a/vv/vvOverlayPanel.h b/vv/vvOverlayPanel.h index 5000e64..63bad7b 100644 --- a/vv/vvOverlayPanel.h +++ b/vv/vvOverlayPanel.h @@ -38,7 +38,7 @@ public: void getVFProperty(int subsampling, int scale, int log); void getVFName(QString name); - void getOverlayProperty(int color); + void getOverlayProperty(int color, int linked, double window, double level); void getOverlayName(QString name); void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level); @@ -56,7 +56,7 @@ public slots: signals: void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b); - void OverlayPropertyUpdated(int color); + void OverlayPropertyUpdated(int color, int linked, double window, double level); void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level); diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 302da7e..2473c87 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -135,6 +135,8 @@ vvSlicer::vvSlicer() this->WindowLevel = vvImageMapToWLColors::New(); this->InstallPipeline(); + + mLinkOverlayWindowLevel = true; } //------------------------------------------------------------------------------ @@ -1111,7 +1113,6 @@ void vvSlicer::SetColorWindow(double window) } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicer::SetColorLevel(double level) { @@ -1125,9 +1126,43 @@ void vvSlicer::SetColorLevel(double level) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +double vvSlicer::GetOverlayColorWindow() +{ + if(mOverlayMapper) + return mOverlayMapper->GetWindow(); + else + return 0.; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +double vvSlicer::GetOverlayColorLevel() +{ + if(mOverlayMapper) + return mOverlayMapper->GetLevel(); + else + return 0.; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicer::SetOverlayColorWindow(double window) +{ + mOverlayMapper->SetWindow(window); +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicer::SetOverlayColorLevel(double level) +{ + mOverlayMapper->SetLevel(level); +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- // Returns the min an the max value in a 41x41 region around the mouse pointer -void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) +void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image) { //Get mouse pointer position in view coordinates double fLocalExtents[6]; @@ -1149,8 +1184,8 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) //Convert to image pixel coordinates (rounded) int iLocalExtents[6]; for(int i=0; i<3; i++) { - fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i]; - fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i]; + fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - image->GetOrigin()[i])/image->GetSpacing()[i]; + fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - image->GetOrigin()[i])/image->GetSpacing()[i]; iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]); iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]); @@ -1160,7 +1195,7 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) } vtkSmartPointer voiFilter = vtkSmartPointer::New(); - voiFilter->SetInput(this->GetInput()); + voiFilter->SetInput(image); voiFilter->SetVOI(iLocalExtents); voiFilter->Update(); if (!voiFilter->GetOutput()->GetNumberOfPoints()) { @@ -1275,8 +1310,10 @@ void vvSlicer::Render() if (mOverlay && mOverlayActor->GetVisibility()) { - mOverlayMapper->SetWindow(this->GetColorWindow()); - mOverlayMapper->SetLevel(this->GetColorLevel()); + if(mLinkOverlayWindowLevel) { + mOverlayMapper->SetWindow(this->GetColorWindow()); + mOverlayMapper->SetLevel(this->GetColorLevel()); + } mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent()); mOverlayMapper->GetOutput()->Update(); mOverlayMapper->Update(); diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 0536bc1..a5156f2 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -153,7 +153,7 @@ public: void SetCornerAnnotationVisibility(bool s); bool GetCornerAnnotationVisibility(); - void GetExtremasAroundMousePointer(double & min, double & max); + void GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image); void UpdateLandmarks(); void ForceUpdateDisplayExtent(); @@ -168,6 +168,14 @@ public: virtual void SetColorWindow(double s); virtual void SetColorLevel(double s); + double GetOverlayColorWindow(); + double GetOverlayColorLevel(); + bool GetLinkOverlayWindowLevel() { return mLinkOverlayWindowLevel; } + + void SetOverlayColorWindow(double s); + void SetOverlayColorLevel(double s); + void SetLinkOverlayWindowLevel(bool b) { mLinkOverlayWindowLevel = b; } + /** * When it is enabled, beware of a call to GetExtent. * we must have setted mReducedExtent otherwhise random values @@ -235,6 +243,7 @@ protected: bool mUseReducedExtent; int * mReducedExtent; int * mInitialExtent; + bool mLinkOverlayWindowLevel; private: void UpdateOrientation(); diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index fd8f09f..c38496e 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -512,7 +512,6 @@ void vvSlicerManager::SetColorWindow(double s) } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicerManager::SetColorLevel(double s) { @@ -522,6 +521,33 @@ void vvSlicerManager::SetColorLevel(double s) } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicerManager::SetOverlayColorWindow(double s) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetOverlayColorWindow(s); + } +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicerManager::SetOverlayColorLevel(double s) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetOverlayColorLevel(s); + } +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +void vvSlicerManager::SetLinkOverlayWindowLevel(bool b) +{ + for ( unsigned int i = 0; i < mSlicers.size(); i++) { + mSlicers[i]->SetLinkOverlayWindowLevel(b); + } +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s) { @@ -736,6 +762,33 @@ double vvSlicerManager::GetColorLevel() } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +double vvSlicerManager::GetOverlayColorWindow() +{ + if (mSlicers.size()) + return mSlicers[0]->GetOverlayColorWindow(); + return -1; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +double vvSlicerManager::GetOverlayColorLevel() +{ + if (mSlicers.size()) + return mSlicers[0]->GetOverlayColorLevel(); + return -1; +} +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +bool vvSlicerManager::GetLinkOverlayWindowLevel() +{ + if (mSlicers.size()) + return mSlicers[0]->GetLinkOverlayWindowLevel(); + return -1; +} +//---------------------------------------------------------------------------- + //------------------------------------------------------------------------------ void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType) { @@ -950,10 +1003,11 @@ void vvSlicerManager::Picked() } //---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- void vvSlicerManager::UpdateWindowLevel() { - emit WindowLevelChanged(mSlicers[0]->GetColorWindow(),mSlicers[0]->GetColorLevel(),mPreset,mColorMap); + emit WindowLevelChanged(); } //---------------------------------------------------------------------------- @@ -1057,14 +1111,34 @@ void vvSlicerManager::SetPreset(int preset) //---------------------------------------------------------------------------- -void vvSlicerManager::SetLocalColorWindowing(const int slicer) +void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey) { double min, max; - this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max); - this->SetColorWindow(max-min); - this->SetColorLevel(0.5*(min+max)); - this->UpdateWindowLevel(); + int t = this->mSlicers[slicer]->GetTSlice(); + if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t]); + this->SetFusionWindow(max-min); + this->SetFusionLevel(0.5*(min+max)); + this->SetColorMap(mColorMap); + } + else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t]); + if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){ + this->SetColorWindow(max-min); + this->SetColorLevel(0.5*(min+max)); + } else { + this->SetOverlayColorWindow(max-min); + this->SetOverlayColorLevel(0.5*(min+max)); + } + } + else { + this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetInput()); + this->SetColorWindow(max-min); + this->SetColorLevel(0.5*(min+max)); + this->SetPreset(6); + } this->Render(); + this->UpdateWindowLevel(); } //---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 5e0ef60..e8a229b 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -111,7 +111,10 @@ class vvSlicerManager : public QObject { void GenerateDefaultLookupTable(); void SetColorWindow(double s); void SetColorLevel(double s); - void SetLocalColorWindowing(const int slicer); + void SetOverlayColorWindow(double s); + void SetOverlayColorLevel(double s); + void SetLinkOverlayWindowLevel(bool b); + void SetLocalColorWindowing(const int slicer, const bool bCtrlKey); void SetOpacity(int i, double factor); void SetColorMap(int colormap); void SetPreset(int preset); @@ -136,6 +139,9 @@ class vvSlicerManager : public QObject { double GetColorWindow(); double GetColorLevel(); + double GetOverlayColorWindow(); + double GetOverlayColorLevel(); + bool GetLinkOverlayWindowLevel(); int GetColorMap() { return mColorMap; } @@ -145,7 +151,6 @@ class vvSlicerManager : public QObject { int GetOverlayColor() { return mOverlayColor; } - int GetFusionOpacity() { return mFusionOpacity; } @@ -216,7 +221,7 @@ signals : void UpdateSlice(int slicer, int slice); void UpdateTSlice(int slicer, int slice); void UpdateSliceRange(int slice, int min, int max, int tmin, int tmax); - void WindowLevelChanged(double window, double level, int preset, int colormap); + void WindowLevelChanged(); void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps); void UpdateLinkedNavigation(std::string, vvSlicerManager*, vvSlicer*); void LandmarkAdded(); diff --git a/vv/vvSlicerManagerCommand.cxx b/vv/vvSlicerManagerCommand.cxx index 805f51b..1b71033 100644 --- a/vv/vvSlicerManagerCommand.cxx +++ b/vv/vvSlicerManagerCommand.cxx @@ -109,7 +109,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, return; } if (KeyPress == "w") { - this->SM->SetLocalColorWindowing(VisibleInWindow); + this->SM->SetLocalColorWindowing(VisibleInWindow, bCtrlKey); return; } if (KeyPress == "0") { @@ -186,7 +186,6 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, return; } if (KeyPress == "h") { - std::cout << "KeyPress == \"h\"\n"; this->SM->SetCursorAndCornerAnnotationVisibility(0); this->SM->Render(); return; @@ -405,8 +404,8 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller, this->SM->SetColorWindow(window*dx); this->SM->SetColorLevel(level-dy); this->SM->SetPreset(6); - this->SM->UpdateWindowLevel(); this->SM->Render(); + this->SM->UpdateWindowLevel(); return; } }