X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=4e70cd415ae45f378ab8a823a4c825f1cdacecde;hb=f6e6c849ba5ea6ba2b553bd2ded0bb5f12fed494;hp=bbbb2d8f4d89979c1f42bdd1a91eb306cfdc0174;hpb=7710267bd8a9764984655596ff14307b4a8a9884;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index bbbb2d8..4e70cd4 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -100,7 +100,11 @@ #define COLUMN_RELOAD_IMAGE 6 #define COLUMN_IMAGE_NAME 7 -#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr)" +#if CLITK_PRIVATE_FEATURES + #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.usf)" +#else + #define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr)" +#endif /*Data Tree values 0,Qt::UserRole full filename @@ -305,10 +309,10 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited())); connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap())); connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel())); + connect(slicingPresetComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateSlicingPreset())); connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel())); connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages())); - connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint))); connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString))); @@ -316,8 +320,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() 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,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(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double, bool)), + this,SLOT(SetFusionProperty(int,int,int,double,double, bool))); connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows())); playMode = 0;//pause @@ -948,6 +952,8 @@ void vvMainWindow::LoadImages(std::vector files, vvImageReader::Loa this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), + this,SLOT(ImageInfoChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)), this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)), @@ -1135,7 +1141,7 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setOrigin(GetVectorDoubleAsString(origin)); infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); - transformation = imageSelected->GetTransform()->GetMatrix(); + transformation = imageSelected->GetTransform()[mSlicerManagers[index]->GetTSlice()]->GetMatrix(); infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation)); landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), @@ -1172,6 +1178,7 @@ void vvMainWindow::ImageInfoChanged() } } WindowLevelChanged(); + slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset()); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str()); @@ -1717,6 +1724,16 @@ void vvMainWindow::UpdateWindowLevel() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::UpdateSlicingPreset() +{ + if (DataTree->selectedItems().size()) { + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex())); + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateColorMap() { @@ -2221,7 +2238,7 @@ void vvMainWindow::SetOverlayProperty(int color, int linked, double window, doub //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level) +void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level, bool showLegend) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { @@ -2230,6 +2247,7 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity); mSlicerManagers[index]->SetFusionWindow(window); mSlicerManagers[index]->SetFusionLevel(level); + mSlicerManagers[index]->SetFusionShowLegend(showLegend); mSlicerManagers[index]->SetColorMap(0); mSlicerManagers[index]->Render(); } @@ -2303,7 +2321,8 @@ void vvMainWindow::SaveAs() bool bId = true; for(int i=0; i<4; i++) for(int j=0; j<4; j++) { - double elt = mSlicerManagers[index]->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j); + // TODO SR and BP: check on the list of transforms and not the first only + double elt = mSlicerManagers[index]->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j); if(i==j && elt!=1.) bId = false; if(i!=j && elt!=0.) @@ -2779,19 +2798,19 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) w2i->Update(); vtkImageData *image = w2i->GetOutput(); - const char *ext = fileName.toStdString().c_str() + strlen(fileName.toStdString().c_str()) - 4; + std::string ext(itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString())); // Image vtkImageWriter *imgwriter = NULL; - if (!strcmp(ext, ".bmp")) + if (ext==".bmp") imgwriter = vtkBMPWriter::New(); - else if (!strcmp(ext, ".tif")) + else if (ext==".tif") imgwriter = vtkTIFFWriter::New(); - else if (!strcmp(ext, ".ppm")) + else if (ext==".ppm") imgwriter = vtkPNMWriter::New(); - else if (!strcmp(ext, ".png")) + else if (ext==".png") imgwriter = vtkPNGWriter::New(); - else if (!strcmp(ext, ".jpg")) + else if (ext==".jpg") imgwriter = vtkJPEGWriter::New(); // Snapshot image if not null @@ -2805,7 +2824,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) // Video vtkGenericMovieWriter *vidwriter = NULL; #if CLITK_EXPERIMENTAL == 1 - if (!strcmp(ext, ".gif")) { + if (ext==".gif") { vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New(); vidwriter = gif; @@ -2821,10 +2840,17 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok); if(ok) gif->SetLoops(loops); + + // Dithering + QString msg = "Would you like to activate dithering?"; + QMessageBox msgBox(QMessageBox::Question, tr("Dithering"),msg, 0, this); + msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole); + msgBox.addButton(tr("No"), QMessageBox::RejectRole); + gif->SetDither(msgBox.exec() == QMessageBox::AcceptRole); } #endif #ifdef VTK_USE_VIDEO_FOR_WINDOWS - if (!strcmp(ext, ".avi")) { + if (ext==".avi") { vtkAVIWriter *mpg = vtkAVIWriter::New(); vidwriter = mpg; mpg->SetQuality(2); @@ -2837,7 +2863,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) } #endif #ifdef VTK_USE_FFMPEG_ENCODER - if (!strcmp(ext, ".avi")) { + if (ext==".avi") { vtkFFMPEGWriter *mpg = vtkFFMPEGWriter::New(); vidwriter = mpg; mpg->SetQuality(2); @@ -2851,7 +2877,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) } #endif #ifdef VTK_USE_MPEG2_ENCODER - if (!strcmp(ext, ".mpg")) { + if (ext==".mpg") { vtkMPEG2Writer *mpg = vtkMPEG2Writer::New(); vidwriter = mpg; } @@ -3067,6 +3093,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen this,SLOT(UpdateSlice(int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), this,SLOT(UpdateTSlice(int, int))); + connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)), + this,SLOT(ImageInfoChanged())); connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)), this,SLOT(UpdateSliceRange(int,int,int,int,int))); connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),