X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=bbbb2d8f4d89979c1f42bdd1a91eb306cfdc0174;hb=43eb9911403380d11b8839c0f955ec590d5e0368;hp=0635d7bd7cc1fb94f17b170563cc4c7098af2b7b;hpb=ea3651a8d897fad6285b84032dd0a121ec8db2dd;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 0635d7b..bbbb2d8 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -71,6 +71,12 @@ #include #include #include +#ifdef CLITK_EXPERIMENTAL +# include +#endif +#ifdef VTK_USE_VIDEO_FOR_WINDOWS +# include +#endif #ifdef VTK_USE_FFMPEG_ENCODER # include #endif @@ -2291,6 +2297,27 @@ void vvMainWindow::SaveAs() vvImageWriter::Pointer writer = vvImageWriter::New(); writer->SetOutputFileName(fileName.toStdString()); writer->SetInput(mSlicerManagers[index]->GetImage()); + + // Check on transform and prompt user + writer->SetSaveTransform(false); + 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); + if(i==j && elt!=1.) + bId = false; + if(i!=j && elt!=0.) + bId = false; + } + if( !bId ) { + QString warning = "The image has an associated linear transform. Do you want to save it along?"; + QMessageBox msgBox(QMessageBox::Warning, tr("Save transform"), warning, 0, this); + msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole); + msgBox.addButton(tr("No"), QMessageBox::RejectRole); + if (msgBox.exec() == QMessageBox::AcceptRole) + writer->SetSaveTransform(true); + } + writer->Update(); QApplication::restoreOverrideCursor(); if (writer->GetLastError().size()) { @@ -2330,8 +2357,6 @@ void vvMainWindow::SaveCurrentStateAs(const std::string& stateFile) { vvSaveState save_state; save_state.Run(this, stateFile); - - std::cout << "void vvMainWindow::SaveCurrentState()" << std::endl; } //------------------------------------------------------------------------------ @@ -2732,11 +2757,14 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) Extensions += "Images( *.bmp);;"; Extensions += "Images( *.tif);;"; Extensions += "Images( *.ppm)"; -#ifdef VTK_USE_FFMPEG_ENCODER - Extensions += "Images( *.avi)"; +#if defined(VTK_USE_FFMPEG_ENCODER) || defined(VTK_USE_VIDEO_FOR_WINDOWS) + Extensions += ";;Video( *.avi)"; #endif #ifdef VTK_USE_MPEG2_ENCODER - Extensions += "Images( *.mpg)"; + Extensions += ";;Video( *.mpg)"; +#endif +#ifdef CLITK_EXPERIMENTAL + Extensions += ";;Video( *.gif)"; #endif int smIndex=GetSlicerIndexFromItem(DataTree->selectedItems()[0]); @@ -2776,13 +2804,45 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) // Video vtkGenericMovieWriter *vidwriter = NULL; +#if CLITK_EXPERIMENTAL == 1 + if (!strcmp(ext, ".gif")) { + vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New(); + vidwriter = gif; + + // FPS + bool ok; + int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), + tr("FPS:"), 5, 0, 1000, 1, &ok); + if(ok) + gif->SetRate(fps); + + // Loops + int loops = QInputDialog::getInteger(this, tr("Loops"), + tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok); + if(ok) + gif->SetLoops(loops); + } +#endif +#ifdef VTK_USE_VIDEO_FOR_WINDOWS + if (!strcmp(ext, ".avi")) { + vtkAVIWriter *mpg = vtkAVIWriter::New(); + vidwriter = mpg; + mpg->SetQuality(2); + bool ok; + int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), + tr("FPS:"), 5, 0, 1024, 1, &ok); + if(!ok) + fps = 5; + mpg->SetRate(fps); + } +#endif #ifdef VTK_USE_FFMPEG_ENCODER if (!strcmp(ext, ".avi")) { vtkFFMPEGWriter *mpg = vtkFFMPEGWriter::New(); vidwriter = mpg; mpg->SetQuality(2); bool ok; - int fps = QInputDialog::getInt(this, tr("Number of frames per second"), + int fps = QInputDialog::getInteger(this, tr("Number of frames per second"), tr("FPS:"), 5, 0, 1024, 1, &ok); if(!ok) fps = 5;