#include "vvMesh.h"
#include "vvStructSelector.h"
#include "vvMeshReader.h"
+#include "vvSaveState.h"
+#include "vvReadState.h"
#include "clitkConfiguration.h"
// ITK include
connect(actionSave_image,SIGNAL(triggered()),this,SLOT(SaveAs()));
contextActions.push_back(actionSave_image);
+ QAction* actionSave_state = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")),
+ tr("Save Current State"));
+ connect(actionSave_state,SIGNAL(triggered()),this,SLOT(SaveCurrentState()));
+ contextActions.push_back(actionSave_state);
+
+ QAction* actionRead_state = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/filesave.png")),
+ tr("Read Saved State"));
+ connect(actionRead_state,SIGNAL(triggered()),this,SLOT(ReadSavedState()));
+ contextActions.push_back(actionRead_state);
+
contextMenu.addSeparator();
contextMenu.addAction(actionAdd_VF_to_current_Image);
connect(actionOpen_Image_With_Time,SIGNAL(triggered()),this,SLOT(OpenImageWithTime()));
connect(actionMerge_images_as_n_dim_t, SIGNAL(triggered()), this, SLOT(MergeImagesWithTime()));
connect(actionSave_As,SIGNAL(triggered()),this,SLOT(SaveAs()));
+ connect(actionSave_current_state,SIGNAL(triggered()),this,SLOT(SaveCurrentState()));
+ connect(actionRead_saved_state,SIGNAL(triggered()),this,SLOT(ReadSavedState()));
connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
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,
connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
+#include "vvSaveState.h"
connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString)));
connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
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)),this,SLOT(SetOverlayProperty(int)));
+ 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(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
- this,SLOT(WindowLevelChanged(double, double, int, int)));
+ connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()),
+ this,SLOT(WindowLevelChanged()));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
this,SLOT(UpdateSlice(int,int)));
connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
break;
}
}
- windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
- levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
- presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
- colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
infoPanel->setFileName(image);
infoPanel->setDimension(dim);
break;
}
}
- windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
- levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
- presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
- colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+ WindowLevelChanged();
if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
}
if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
- overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor());
} else {
overlayPanel->getOverlayName(mSlicerManagers[index]->GetOverlayName().c_str());
- overlayPanel->getOverlayProperty(-1);
}
if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
- overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
- mSlicerManagers[index]->GetFusionThresholdOpacity(),
- mSlicerManagers[index]->GetFusionColorMap(),
- mSlicerManagers[index]->GetFusionWindow(),
- mSlicerManagers[index]->GetFusionLevel());
} else {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
- overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap)
+void vvMainWindow::WindowLevelChanged()
{
- windowSpinBox->setValue(window);
- levelSpinBox->setValue(level);
- colorMapComboBox->setCurrentIndex(colormap);
- presetComboBox->setCurrentIndex(preset);
+ // Base image
+ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ if(index==-1) return;
+ windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
+ levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
+ colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap());
+ presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset());
+
+ // Overlay image
+ if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay())
+ overlayPanel->getOverlayProperty(mSlicerManagers[index]->GetOverlayColor(),
+ mSlicerManagers[index]->GetLinkOverlayWindowLevel(),
+ mSlicerManagers[index]->GetOverlayColorWindow(),
+ mSlicerManagers[index]->GetOverlayColorLevel());
+ else
+ overlayPanel->getOverlayProperty(-1,0,0.,0.);
+
+ // Fusion image
+ if (mSlicerManagers[index]->GetSlicer(0)->GetFusion())
+ overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
+ mSlicerManagers[index]->GetFusionThresholdOpacity(),
+ mSlicerManagers[index]->GetFusionColorMap(),
+ mSlicerManagers[index]->GetFusionWindow(),
+ mSlicerManagers[index]->GetFusionLevel());
+ else
+ overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::SetWindowLevel(double w, double l)
+{
+ windowSpinBox->setValue(w);
+ levelSpinBox->setValue(l);
+ presetComboBox->setCurrentIndex(6);
+ colorMapComboBox->setCurrentIndex(0);
+ UpdateWindowLevel();
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::UpdateWindowLevel()
{
mSlicerManagers[index]->SetColorLevel(levelSpinBox->value());
mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex());
mSlicerManagers[index]->Render();
- windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
- levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
+ WindowLevelChanged();
}
}
//------------------------------------------------------------------------------
error += mSlicerManagers[index]->GetLastError().c_str();
QMessageBox::information(this,tr("Problem reading image !"),error);
}
+ WindowLevelChanged();
}
//------------------------------------------------------------------------------
}
QString Extensions = "Images ( *.mhd)";
+ Extensions += ";;Images ( *.mha)";
Extensions += ";;Images ( *.vf)";
QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
if (!file.isEmpty())
//------------------------------------------------------------------------------
-void vvMainWindow::SetOverlayProperty(int color)
+void vvMainWindow::SetOverlayProperty(int color, int linked, double window, double level)
{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
mSlicerManagers[index]->SetOverlayColor(color);
mSlicerManagers[index]->SetColorMap(0);
+ mSlicerManagers[index]->SetLinkOverlayWindowLevel(linked);
+ mSlicerManagers[index]->SetOverlayColorWindow(window);
+ mSlicerManagers[index]->SetOverlayColorLevel(level);
mSlicerManagers[index]->Render();
}
}
OutputListeFormat.clear();
if (dimension == 1) {
OutputListeFormat.push_back(".mhd");
+ OutputListeFormat.push_back(".mha");
}
if (dimension == 2) {
OutputListeFormat.push_back(".bmp");
OutputListeFormat.push_back(".jpeg");
OutputListeFormat.push_back(".tif");
OutputListeFormat.push_back(".mhd");
+ OutputListeFormat.push_back(".mha");
OutputListeFormat.push_back(".hdr");
OutputListeFormat.push_back(".vox");
} else if (dimension == 3) {
OutputListeFormat.push_back(".mhd");
+ OutputListeFormat.push_back(".mha");
OutputListeFormat.push_back(".hdr");
OutputListeFormat.push_back(".vox");
} else if (dimension == 4) {
OutputListeFormat.push_back(".mhd");
+ OutputListeFormat.push_back(".mha");
}
QString Extensions = "AllFiles(*.*)";
for (int i = 0; i < OutputListeFormat.count(); i++) {
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::SaveCurrentState()
+{
+ QString Extensions = "XML Files(*.xml)";
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save Current Window State"),
+ "",
+ Extensions);
+
+ SaveCurrentStateAs(fileName.toStdString());
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::SaveCurrentStateAs(const std::string& stateFile)
+{
+ vvSaveState save_state;
+ save_state.Run(this, stateFile);
+
+ std::cout << "void vvMainWindow::SaveCurrentState()" << std::endl;
+}
+
+//------------------------------------------------------------------------------
+void vvMainWindow::ReadSavedState()
+{
+ QString Extensions = "XML Files(*.xml)";
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Load Window State"),
+ "",
+ Extensions);
+
+ ReadSavedStateFile(fileName.toStdString());
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
+{
+ vvReadState read_state;
+ read_state.Run(this, stateFile);
+}
+//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::AddLink(QString image1,QString image2)
void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
{
int position = int((min+max)/2);
- int tPosition = int((tmin+tmax)/2);
if (slicer == 0) {
NOVerticalSlider->setValue(position);
NOVerticalSlider->setRange(min,max);
NOHorizontalSlider->setRange(tmin,tmax);
- NOHorizontalSlider->setValue(tPosition);
} else if (slicer == 1) {
NEVerticalSlider->setValue(position);
NEVerticalSlider->setRange(min,max);
NEHorizontalSlider->setRange(tmin,tmax);
- NEHorizontalSlider->setValue(tPosition);
} else if (slicer == 2) {
SOVerticalSlider->setValue(position);
SOVerticalSlider->setRange(min,max);
SOHorizontalSlider->setRange(tmin,tmax);
- SOHorizontalSlider->setValue(tPosition);
} else if (slicer == 3) {
SEVerticalSlider->setValue(position);
SEVerticalSlider->setRange(min,max);
SEHorizontalSlider->setRange(tmin,tmax);
- SEHorizontalSlider->setValue(tPosition);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+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<vtkRenderWindow> 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; i<nbSlices; i++) {
+ // Change the slice
+ 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<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
+ windowToImageFilter->SetInput(renderWindow);
+ windowToImageFilter->SetMagnification(1);
+ windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
+ windowToImageFilter->Update();
+
+ vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::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)
{
this, SLOT(OverlayChanged(int,double,double)));
connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
- this,SLOT(WindowLevelChanged(double, double, int, int)));
+ connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged()),
+ this,SLOT(WindowLevelChanged()));
connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
this,SLOT(UpdateSlice(int,int)));
connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),