From: David Sarrut Date: Mon, 10 Oct 2011 07:55:57 +0000 (+0200) Subject: SaveScreenshotAllSlices : filenames correction and correct update to force the displa... X-Git-Tag: v1.3.0~195 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0cc07164d2ccd6614ae487008353113f68842b0b;p=clitk.git SaveScreenshotAllSlices : filenames correction and correct update to force the display of ROI. --- diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index ca0d09f..7b83b70 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -2578,7 +2578,6 @@ void vvMainWindow::SaveSEScreenshot() void vvMainWindow::SaveScreenshotAllSlices() { QVTKWidget *widget = NOViewWidget; - vtkSmartPointer renderWindow = widget->GetRenderWindow(); int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]); vvSlicerManager * SM = mSlicerManagers[index]; @@ -2586,18 +2585,21 @@ void vvMainWindow::SaveScreenshotAllSlices() 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( *.png);;Images( *.jpg)"); // Loop on slices for(uint i=0; iSetSlice(i); - + slicer->SetSlice(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); @@ -2607,7 +2609,13 @@ void vvMainWindow::SaveScreenshotAllSlices() vtkSmartPointer writer = vtkSmartPointer::New(); std::string fn = itksys::SystemTools::GetFilenameWithoutLastExtension(filename.toStdString()); - fn = fn + "_" + clitk::toString(i) + itksys::SystemTools::GetFilenameLastExtension(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();