X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=ef064fad133444f39af74fe0e062a9b1538568e4;hb=000ac5b867a708575268c7c823db4fcbe727c2d6;hp=516c736acbc5eef76cdcbb9d56848464e2125ad4;hpb=78ae141332b4f8d5146952b08dced58e4d248e06;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 516c736..ef064fa 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -33,7 +33,6 @@ #include "vvSlicer.h" #include "vvInteractorStyleNavigator.h" #include "vvImageWriter.h" -#include "vvResamplerDialog.h" #include "vvSegmentationDialog.h" #include "vvSurfaceViewerDialog.h" #include "vvDeformationDialog.h" @@ -105,6 +104,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { mContextMenu = &contextMenu; mMenuExperimentalTools = menuExperimental; mMainWidget = this; + mCurrentTime = -1; //Init the contextMenu this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -255,8 +255,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() { connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation())); /////////////////////////////////////////////// - contextMenu.addAction(actionResampler); - connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage())); connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage())); connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch())); /////////////////////////////////////////////// @@ -287,7 +285,7 @@ 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)),this,SLOT(SetVFProperty(int,int,int))); + connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int)),this,SLOT(SetVFProperty(int,int,int,int))); connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int))); connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)), this,SLOT(SetFusionProperty(int,int,double,double))); @@ -922,6 +920,17 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi } QApplication::restoreOverrideCursor(); + // Try to guess default WindowLevel + double range[2]; + mSlicerManagers.back()->GetImage()->GetFirstVTKImageData()->GetScalarRange(range); + // DD(range[0]); + // DD(range[1]); + if ((range[0] == 0) && (range[1] == 1)) { + presetComboBox->setCurrentIndex(5);// binary + } + else { + // TODO + } } //------------------------------------------------------------------------------ @@ -1536,7 +1545,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) { msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); if (msgBox.exec() == QMessageBox::AcceptRole) { - this->close(); + this->close(); } } else @@ -1592,6 +1601,10 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column) { mSlicerManagers[index]->ReloadFusion(); else mSlicerManagers[index]->Reload(); + + // Update view and info + ImageInfoChanged(); + mSlicerManagers[index]->Render(); QApplication::restoreOverrideCursor(); } //------------------------------------------------------------------------------ @@ -1895,6 +1908,7 @@ void vvMainWindow::SelectOverlayImage() { //------------------------------------------------------------------------------ void vvMainWindow::AddOverlayImage(int index, QString file) { + mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str(); itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO( file.toStdString().c_str(), itk::ImageIOFactory::ReadMode); @@ -1905,7 +1919,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); vvProgressDialog progress("Opening " + file.toStdString()); qApp->processEvents(); - + std::string filename = itksys::SystemTools::GetFilenameWithoutExtension(file.toStdString()).c_str(); if (mSlicerManagers[index]->SetOverlay(file.toStdString(),dimension, component)) { @@ -1920,7 +1934,7 @@ void vvMainWindow::AddOverlayImage(int index, QString file) { { item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole)); mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0, - DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt()); + DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt()); } //Create the buttons for reload and close @@ -2059,8 +2073,10 @@ void vvMainWindow::AddFusionImage() } } } +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void vvMainWindow::OpenField() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2081,7 +2097,10 @@ void vvMainWindow::OpenField() if (!file.isEmpty()) AddField(file,index); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) { //create an item in the tree with good settings @@ -2130,7 +2149,10 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) ImageInfoChanged(); QApplication::restoreOverrideCursor(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -2147,7 +2169,10 @@ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index) } QApplication::restoreOverrideCursor(); } +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ void vvMainWindow::AddField(QString file,int index) { if (QFile::exists(file)) @@ -2183,8 +2208,9 @@ void vvMainWindow::AddField(QString file,int index) } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ -void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { +void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { @@ -2192,6 +2218,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { { mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling); mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale); + mSlicerManagers[index]->GetSlicer(i)->SetVFWidth(width); if (log > 0) mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1); else @@ -2201,6 +2228,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SetOverlayProperty(int color) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2376,28 +2404,41 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index) } } } +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NOHorizontalSliderMoved() { + // if (mCurrentTime == NOHorizontalSlider->value()) return; HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0); + // mCurrentTime = NOHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NEHorizontalSliderMoved() { + // if (mCurrentTime == NEHorizontalSlider->value()) return; HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1); + // mCurrentTime = NEHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SOHorizontalSliderMoved() { + // if (mCurrentTime == SOHorizontalSlider->value()) return; HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2); + // mCurrentTime = SOHorizontalSlider->value(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SEHorizontalSliderMoved() { + // if (mCurrentTime == SEHorizontalSlider->value()) return; HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3); + // mCurrentTime = SEHorizontalSlider->value(); } //------------------------------------------------------------------------------ @@ -2409,14 +2450,16 @@ void vvMainWindow::NOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(0)->SetSlice(value); - // mSlicerManagers[i]->UpdateSlice(0); - // <-- DS add this. Not too much update ? YES. + mSlicerManagers[i]->VerticalSliderHasChanged(0, value); + // mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES. + mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::NEVerticalSliderChanged() { int value = NEVerticalSlider->value(); @@ -2425,12 +2468,15 @@ void vvMainWindow::NEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(1)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(1, value); + mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SOVerticalSliderChanged() { int value = SOVerticalSlider->value(); @@ -2439,12 +2485,15 @@ void vvMainWindow::SOVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(2)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(2, value); + mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SEVerticalSliderChanged() { int value = SEVerticalSlider->value(); @@ -2453,12 +2502,15 @@ void vvMainWindow::SEVerticalSliderChanged() { if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1) { mSlicerManagers[i]->GetSlicer(3)->SetSlice(value); + mSlicerManagers[i]->VerticalSliderHasChanged(3, value); + mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? break; } } } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateSlice(int slicer, int slice) { if (slicer == 0) { @@ -2474,6 +2526,7 @@ void vvMainWindow::UpdateSlice(int slicer, int slice) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateTSlice(int slicer, int slice) { switch (slicer) @@ -2494,6 +2547,7 @@ void vvMainWindow::UpdateTSlice(int slicer, int slice) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax) { int position = int((min+max)/2); @@ -2529,6 +2583,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2539,6 +2594,7 @@ void vvMainWindow::SaveNOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveNEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2549,6 +2605,7 @@ void vvMainWindow::SaveNEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSOScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2559,6 +2616,7 @@ void vvMainWindow::SaveSOScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveSEScreenshot() { vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New(); @@ -2569,6 +2627,7 @@ void vvMainWindow::SaveSEScreenshot() { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshot(vtkImageData* image) { QString Extensions = "Images( *.png);;"; @@ -2633,6 +2692,7 @@ void vvMainWindow::SaveScreenshot(vtkImageData* image) { } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::GoToCursor() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2719,16 +2779,6 @@ void vvMainWindow::UpdateRenderWindows() { } //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvMainWindow::ResampleCurrentImage() { - vvResamplerDialog resampler; - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); - resampler.SetSlicerManagers(mSlicerManagers,index); - if (resampler.exec()) - AddImage(resampler.GetOutput(),resampler.GetOutputFileName()); -} -//------------------------------------------------------------------------------ - //------------------------------------------------------------------------------ void vvMainWindow::SegmentationOnCurrentImage() { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);