#include <vtkPNGWriter.h>
#include <vtkJPEGWriter.h>
#include <vtkGenericMovieWriter.h>
+#ifdef CLITK_EXPERIMENTAL
+# include <vvAnimatedGIFWriter.h>
+#endif
#ifdef VTK_USE_VIDEO_FOR_WINDOWS
# include <vtkAVIWriter.h>
#endif
#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
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
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-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()) {
mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity);
mSlicerManagers[index]->SetFusionWindow(window);
mSlicerManagers[index]->SetFusionLevel(level);
+ mSlicerManagers[index]->SetFusionShowLegend(showLegend);
mSlicerManagers[index]->SetColorMap(0);
mSlicerManagers[index]->Render();
}
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()) {
{
vvSaveState save_state;
save_state.Run(this, stateFile);
-
- std::cout << "void vvMainWindow::SaveCurrentState()" << std::endl;
}
//------------------------------------------------------------------------------
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]);
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
// Video
vtkGenericMovieWriter *vidwriter = NULL;
+#if CLITK_EXPERIMENTAL == 1
+ if (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);
+
+ // 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);
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;
}
#endif
#ifdef VTK_USE_FFMPEG_ENCODER
- if (!strcmp(ext, ".avi")) {
+ if (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;
}
#endif
#ifdef VTK_USE_MPEG2_ENCODER
- if (!strcmp(ext, ".mpg")) {
+ if (ext==".mpg") {
vtkMPEG2Writer *mpg = vtkMPEG2Writer::New();
vidwriter = mpg;
}