X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=7b83b7005b6e4debcc39be72531d4493c70cbd52;hb=1bfa0da6c453a072c0b04003e297dcf0073dc168;hp=596e6af969f9859f0520de3e3f70ab8eb61af613;hpb=5999f0266615dddfc3d2e885d8fb9e60b5172058;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 596e6af..7b83b70 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -275,6 +275,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(actionNorth_West_Window,SIGNAL(triggered()),this,SLOT(SaveNOScreenshot())); connect(actionSouth_East_Window,SIGNAL(triggered()),this,SLOT(SaveSEScreenshot())); connect(actionSouth_West_Window,SIGNAL(triggered()),this,SLOT(SaveSOScreenshot())); + connect(actionSave_all_slices,SIGNAL(triggered()),this,SLOT(SaveScreenshotAllSlices())); connect(DataTree,SIGNAL(itemSelectionChanged()),this,SLOT(ImageInfoChanged())); connect(DataTree,SIGNAL(itemClicked(QTreeWidgetItem*, int)),this, @@ -2573,6 +2574,56 @@ void vvMainWindow::SaveSEScreenshot() //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::SaveScreenshotAllSlices() +{ + QVTKWidget *widget = NOViewWidget; + + int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + vvSlicerManager * SM = mSlicerManagers[index]; + vvImage * image = SM->GetImage(); + vvSlicer * slicer = SM->GetSlicer(0); + int orientation = slicer->GetOrientation(); + int nbSlices = image->GetSize()[orientation]; + vtkSmartPointer renderWindow = widget->GetRenderWindow(); + + // Select filename base + QString filename = QFileDialog::getSaveFileName(this, + tr("Save As (filename will be completed by slice number)"), + itksys::SystemTools::GetFilenamePath(mSlicerManagers[index]->GetFileName()).c_str(), + "Images( *.png);;Images( *.jpg)"); + + // Loop on slices + for(uint i=0; iSetSlice(i); // -> change the slice of the current slicer + SM->UpdateSlice(0); // --> this one emit UpdateSlice + QCoreApplication::flush(); // -> needed to force display of contours + + // Screenshot + vtkSmartPointer windowToImageFilter = vtkSmartPointer::New(); + windowToImageFilter->SetInput(renderWindow); + windowToImageFilter->SetMagnification(1); + windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel + windowToImageFilter->Update(); + + vtkSmartPointer writer = vtkSmartPointer::New(); + std::string fn = itksys::SystemTools::GetFilenameWithoutLastExtension(filename.toStdString()); + std::string num = clitk::toString(i); + if (i<10) num = "0"+num; + if (i<100) num = "0"+num; + if (i<1000) num = "0"+num; + + fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn + + "_" + num + itksys::SystemTools::GetFilenameLastExtension(filename.toStdString()); + writer->SetFileName(fn.c_str()); + writer->SetInput(windowToImageFilter->GetOutput()); + writer->Write(); + } +} +//------------------------------------------------------------------------------ + + //------------------------------------------------------------------------------ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) {