#include "QTreePushButton.h"
#include <QUrl>
#include <QSettings>
+#include <QShortcut>
// VV include
#include "vvMainWindow.h"
#include "vvMeshReader.h"
#include "vvSaveState.h"
#include "vvReadState.h"
+#ifdef CLITK_USE_PACS_CONNECTION
+#include "vvQPacsConnection.h"
+#endif
#include "clitkConfiguration.h"
#include "clitkMatrix.h"
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
// ITK include
#include <itkImage.h>
#include <itkNumericSeriesFileNames.h>
// VTK include
+#include <vtkImageMapper3D.h>
+#include <vtkInformation.h>
+#include <vtkVersion.h>
#include <vtkImageData.h>
#include <vtkImageActor.h>
#include <vtkCornerAnnotation.h>
#define COLUMN_IMAGE_NAME 7
#ifdef CLITK_PRIVATE_FEATURES
-#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)"
#else
-#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
#endif
//------------------------------------------------------------------------------
vvMainWindow::vvMainWindow():vvMainWindowBase()
-{
+{
setupUi(this); // this sets up the GUI
+ setDicomClient();
+
+ //Qt::WindowFlags flags = windowFlags();
+ //setWindowFlags(flags | Qt::WindowStaysOnTopHint);
+
mInputPathName = "";
mMenuTools = menuTools;
// mMenuSegmentation = menuSegmentation;
contextActions.resize(0);
QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")),
tr("O&pen new Image"));
- actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O")));
connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
contextActions.push_back(actionOpen_new_image);
contextMenu.addSeparator();
tr("Reset transformation to identity"));
connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
- // TRIAL DS
- /*
- QMenu * m = new QMenu(menubar);
- m->setTitle("TOTO");
- // m->setObjectName(QString::fromUtf8("TOTOTO"));
- contextMenu.addMenu(m);
- QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
- tr("BIDON"));
- QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
- tr("BIDON2"));
- m->addAction(a);
- m->addAction(b);
- connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
- */
-
//init the DataTree
mSlicerManagers.resize(0);
documentation = new vvDocumentation();
help_dialog = new vvHelpDialog();
dicomSeriesSelector = new vvDicomSeriesSelector();
+#ifdef CLITK_USE_PACS_CONNECTION
+ PacsConnection = new vvQPacsConnection();
+#endif
inverseButton->setEnabled(0);
actionAdd_overlay_image_to_current_image->setEnabled(0);
connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage()));
connect(actionLoad_images,SIGNAL(triggered()),this,SLOT(OpenImages()));
connect(actionOpen_Dicom,SIGNAL(triggered()),this,SLOT(OpenDicom()));
+ #ifdef CLITK_USE_PACS_CONNECTION
+connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
+#endif
// connect(actionOpen_Dicom_Struct,SIGNAL(triggered()),this,SLOT(OpenDCStructContour()));
connect(actionOpen_VTK_contour,SIGNAL(triggered()),this,SLOT(OpenVTKContour()));
connect(actionOpen_Multiple_Images_As_One,SIGNAL(triggered()),this,SLOT(MergeImages()));
connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
connect(actionAdd_USSequence_toCT,SIGNAL(triggered()), this,SLOT(SelectFusionSequence()));
connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+
+ QShortcut *shortcutHelp = new QShortcut(QKeySequence(QKeySequence::HelpContents),this);
+ shortcutHelp->setContext(Qt::ApplicationShortcut);
+ QObject::connect(shortcutHelp, SIGNAL(activated()), this, SLOT(ShowHelpDialog()));
+
connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
SOViewWidget->hide();
SEViewWidget->hide();
+#ifdef Q_OS_OSX
+ disableGLHiDPI(NOViewWidget->winId());
+ disableGLHiDPI(NEViewWidget->winId());
+ disableGLHiDPI(SOViewWidget->winId());
+ disableGLHiDPI(SEViewWidget->winId());
+#endif
+
//Recently opened files
std::list<std::string> recent_files = GetRecentlyOpenedImages();
recentlyOpenedFilesMenu=NULL;
vvToolManager::GetInstance()->InsertToolsInMenu(this);
vvToolManager::GetInstance()->EnableToolsInMenu(this, false);
+//#ifndef CLITK_EXPERIMENTAL
+//#define CLITK_EXPERIMENTAL 0
+//#endif
+#ifdef CLITK_EXPERIMENTAL
if (!CLITK_EXPERIMENTAL)
menuExperimental->menuAction()->setVisible(false);
-
+#endif
QTimer * timerMemory = new QTimer(this);
//timerMemory->setInterval(5);
connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
timerMemory->start(2000);
-
}
+
//------------------------------------------------------------------------------
void vvMainWindow::show()
-{
+{
vvMainWindowBase::show();
PopupRegisterForm(true);
}
//------------------------------------------------------------------------------
void vvMainWindow::UpdateMemoryUsage()
-{
+{
// clitk::PrintMemory(true);
if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
//------------------------------------------------------------------------------
void vvMainWindow::createRecentlyOpenedFilesMenu()
-{
+{
recentlyOpenedFilesMenu = new QMenu("Recently opened files...");
recentlyOpenedFilesMenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
menuFile->insertMenu(actionOpen_Image_With_Time,recentlyOpenedFilesMenu);
//------------------------------------------------------------------------------
void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &recent_files)
-{
+{
if(recentlyOpenedFilesMenu==NULL) {
createRecentlyOpenedFilesMenu();
} else {
//------------------------------------------------------------------------------
void vvMainWindow::ComputeMidPosition()
-{
+{
bool ok;
int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
- mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
+ int ref = QInputDialog::getInt(this,"Chose reference phase","Reference phase",0,0,\
+mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
if (ok) {
vvMidPosition midp;
midp.slicer_manager = mSlicerManagers[index];
//------------------------------------------------------------------------------
void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
-{
+{
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setData(0,Qt::UserRole,"filename.vtk");
item->setData(1,Qt::UserRole,tr("contour"));
brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
brush.setStyle(Qt::SolidPattern);
item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
- // item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
+ item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
for (int j = 1; j <= 4; j++)
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
//------------------------------------------------------------------------------
void vvMainWindow::OpenVTKContour()
-{
+{
if (mSlicerManagers.size() > 0) {
QString Extensions = "Images ( *.vtk *.obj)";
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvMainWindow::AddDCStructContour(int index, QString file)
-{
+{
vvMeshReader reader;
reader.SetFilename(file.toStdString());
vvStructSelector selector;
//------------------------------------------------------------------------------
void vvMainWindow::OpenDCStructContour()
-{
+{
if (mSlicerManagers.size() > 0) {
QString Extensions = "Dicom Files ( *.dcm RS*)";
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvMainWindow::ComputeDeformableRegistration()
-{
+{
if (mSlicerManagers.size() > 0) {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
vvDeformationDialog dialog(index,mSlicerManagers);
//------------------------------------------------------------------------------
void vvMainWindow::WarpImage()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if (!mSlicerManagers[index]->GetVF().IsNull()) {
bool ok;
- int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
+ int ref = QInputDialog::getInt(this,"Chose reference phase","Reference phase",0,0,\
mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
if (ok) {
WarpImage(mSlicerManagers[index],ref);
//------------------------------------------------------------------------------
void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
-{
+{
if (!selected_slicer->GetVF().IsNull()) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QFileInfo info(selected_slicer->GetFileName().c_str());
//------------------------------------------------------------------------------
vvMainWindow::~vvMainWindow()
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
if (mSlicerManagers[i] != NULL)
delete mSlicerManagers[i];
}
+ delete documentation;
+ delete help_dialog;
+ delete dicomSeriesSelector;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
QTabWidget * vvMainWindow::GetTab()
-{
+{
return tabWidget;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::MergeImages()
-{
+{
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
//------------------------------------------------------------------------------
void vvMainWindow::SliceImages()
-{
+{
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvMainWindow::MergeImagesWithTime()
-{
+{
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
//------------------------------------------------------------------------------
void vvMainWindow::OpenDicom()
-{
+{
std::vector<std::string> files;
//std::cout << "dicomSeriesSelector " << std::endl;
files = *(dicomSeriesSelector->GetFilenames());
LoadImages(files, vvImageReader::DICOM);
}
-}
+}
+#ifdef CLITK_USE_PACS_CONNECTION
+void vvMainWindow::ConnectPacs()
+{
+ std::vector<std::string> files;
+
+ //std::cout << "dicomSeriesSelector " << std::endl;
+if (PacsConnection->exec() == QDialog::Accepted) {
+ for (int i = 0; i < PacsConnection->getSeriesCount(); i++)
+ {
+ files = PacsConnection->getFileNames(i);
+ LoadImages(files, vvImageReader::DICOM);
+ }
+ PacsConnection->clearMove();
+ }
+ }
+
+#endif
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::OpenImages()
-{
+{
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
}
//------------------------------------------------------------------------------
void vvMainWindow::OpenRecentImage()
-{
+{
QAction * caller = qobject_cast<QAction*>(sender());
std::vector<std::string> images;
images.push_back(caller->text().toStdString());
//------------------------------------------------------------------------------
void vvMainWindow::OpenImageWithTime()
-{
+{
QString Extensions = EXTENSIONS;
Extensions += ";;All Files (*)";
//------------------------------------------------------------------------------
void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::LoadedImageType filetype)
-{
+{
//Separate the way to open images and dicoms
int fileSize;
if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME)
// Change filename if an image with the same already exist
int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
- if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED)
+ if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED) {
SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
- else {
+ } else {
SetImageSucceed = imageManager->SetImages(files,filetype, number);
}
-
if (!SetImageSucceed) {
QApplication::restoreOverrideCursor();
QString error = "Cannot open file \n";
QMessageBox::information(this,tr("Reading problem"),error);
delete imageManager;
} else {
+
mSlicerManagers.push_back(imageManager);
//create an item in the tree with good settings
connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
-
InitSlicers();
numberofsuccesulreads++;
}
}
}
+
if (numberofsuccesulreads) {
NOViewWidget->show();
NEViewWidget->show();
//------------------------------------------------------------------------------
void vvMainWindow::UpdateTree()
-{
+{
DataTree->resizeColumnToContents(COLUMN_TREE);
DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
//------------------------------------------------------------------------------
void vvMainWindow::CurrentImageChanged(std::string id)
-{
+{
if (id == mCurrentSelectedImageId) return; // Do nothing
int selected = 0;
for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
mSlicerManagers[selected]->GetTSlice());
landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
landmarksPanel->SetCurrentImage(mSlicerManagers[selected]->GetFileName().c_str());
-
+
emit SelectedImageHasChanged(mSlicerManagers[selected]);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::CurrentPickedImageChanged(std::string id)
-{
+{
if (id == mCurrentPickedImageId) return; // Do nothing
int selected = 0;
for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
//------------------------------------------------------------------------------
void vvMainWindow::ImageInfoChanged()
-{
+{
contextActions[6]->setEnabled(1);
contextActions[5]->setEnabled(1);
actionSave_As->setEnabled(1);
// infoPanel->setOrigin(GetVectorDoubleAsString(origin));
// infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
// infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-//
+//
// landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
// mSlicerManagers[index]->GetTSlice());
// landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
// landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
-//
+//
// overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
// for (int i = 0; i < 4; i++) {
// if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) {
//------------------------------------------------------------------------------
void vvMainWindow::ShowDocumentation()
-{
+{
documentation->show();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::PopupRegisterForm(bool checkCanPush)
-{
+{
vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://www.creatis.insa-lyon.fr/~dsarrut/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
if(!checkCanPush) {
registerForm->show();
//------------------------------------------------------------------------------
void vvMainWindow::ShowHelpDialog()
-{
+{
help_dialog->show();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::ChangeViewMode()
-{
+{
typedef struct _SIZE{
QSplitter* splitter;
QList<int> size1, size2;
//------------------------------------------------------------------------------
QString vvMainWindow::GetSizeInBytes(unsigned long size)
-{
+{
QString result = "";// QString::number(size);
//result += " bytes (";
if (size > 1000000000) {
//------------------------------------------------------------------------------
QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
-{
+{
QString result;
for (unsigned int i= 0; i < vectorDouble.size(); i++) {
if (i != 0)
//------------------------------------------------------------------------------
QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
-{
+{
QString result;
for (unsigned int i= 0; i < vectorInt.size(); i++) {
if (i != 0)
//------------------------------------------------------------------------------
//this actually returns the SlicerManager index!
int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
-{
+{
QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
//------------------------------------------------------------------------------
QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
-{
+{
QString id = sm->GetId().c_str();
for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
//------------------------------------------------------------------------------
void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
-{
+{
if ( column >= COLUMN_CLOSE_IMAGE || column <= 0)
return;
clickedParentItem->setData(column, Qt::CheckStateRole, vis?2:0);
// Children
- std::map<std::string, int> actorTypeCounts;
+ std::map<std::string, int> actorTypeCounts;
for (int iChild = 0; iChild < clickedParentItem->childCount(); iChild++) {
QTreeWidgetItem* currentChildItem = clickedParentItem->child(iChild);
std::string actorType = currentChildItem->data(1,Qt::UserRole).toString().toStdString();
//------------------------------------------------------------------------------
void vvMainWindow::InitSlicers()
-{
+{
if (mSlicerManagers.size()) {
mSlicerManagers.back()->GenerateDefaultLookupTable();
-
mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
+#if VTK_MAJOR_VERSION <= 5
+ mSlicerManagers.back()->Render(); // SR: displayed #slice is wrong without this / TB: With VTK6 and multiple images, all slicers are updated, not only the first
+#endif
}
}
//------------------------------------------------------------------------------
void vvMainWindow::InitDisplay()
-{
+{
if (mSlicerManagers.size()) {
//BE CAREFUL : this is absolutely necessary to set the interactor style
//in order to have the same style instanciation for all SlicerManagers in
bool AlreadySelected = false;
for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
mSlicerManagers[i]->SetInteractorStyleNavigator(j,style);
-
//select the image only if previous are not selected
if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1) {
mSlicerManagers[i]->UpdateSlicer(j,1);
AlreadySelected = true;
} else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected) {
- if (DataTree->selectedItems().size() == 0)
+ if (DataTree->selectedItems().size() == 0) {
DataTree->topLevelItem(i)->setSelected(1);
+ }
DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2);
mSlicerManagers[i]->UpdateSlicer(j,1);
DisplaySliders(i,j);
//------------------------------------------------------------------------------
void vvMainWindow::DisplaySliders(int slicer, int window)
-{
+{
if(!mSlicerManagers[slicer]->GetSlicer(window)->GetRenderer()->GetDraw())
return;
//------------------------------------------------------------------------------
void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
-{
+{
int index = GetSlicerIndexFromItem(item);
if (DataTree->topLevelItem(index) != item) {
if (DataTree->topLevelItem(index)->child(child) == item) break;
}
if (overlay_type=="fusionSequence") {
- //removing the overlay sequence in a fusion sequence visualization mode
+ //removing the overlay sequence in a fusion sequence visualization mode
//reset the transforms
overlayPanel->getFusionSequenceProperty(-1, false, 0, false);
//------------------------------------------------------------------------------
void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
-{
+{
// int index = GetSlicerIndexFromItem(item);
// QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
// if (item->data(1,Qt::UserRole).toString() == "vector")
else if (role == "fusionSequence") {
//both versions of the secondary sequence must be updated.
mSlicerManagers[index]->ReloadFusionSequence();
- mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload();
+ mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload();
}
else {
mSlicerManagers[index]->Reload();
//if we update the secondary sequence, then the overlay of the main sequence should also be updated
- if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence();
+ if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence();
}
// Update view and info
ImageInfoChanged();
//------------------------------------------------------------------------------
void vvMainWindow::MousePositionChanged(int visibility,double x, double y, double z, double X, double Y, double Z , double value)
-{
+{
infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::VectorChanged(int visibility,double x, double y, double z, double value)
-{
+{
overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::OverlayChanged(int visibility, double valueOver, double valueRef)
-{
+{
overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::FusionChanged(int visibility, double value)
-{
+{
overlayPanel->getCurrentFusionInfo(visibility,value);
}
//------------------------------------------------------------------------------
//or when UpdateWindowLevel() is called ; when slicerManager emits WindowLevelChanged
//when ImageInfoChanged() is called
void vvMainWindow::WindowLevelChanged()
-{
+{
// Base image
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if(index==-1) return;
mSlicerManagers[index]->GetFusionLevel());
if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(),
- mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(),
+ mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(),
mSlicerManagers[index]->GetFusionSequenceNbFrames(),
mSlicerManagers[index]->GetFusionSequenceTemporalSyncFlag());
}
mSlicerManagers[ind]->GetFusionWindow(),
mSlicerManagers[ind]->GetFusionLevel());
overlayPanel->getFusionSequenceProperty(mSlicerManagers[ind]->GetFusionSequenceFrameIndex(),
- mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(),
+ mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(),
mSlicerManagers[ind]->GetFusionSequenceNbFrames(),
mSlicerManagers[ind]->GetFusionSequenceTemporalSyncFlag());
}
//------------------------------------------------------------------------------
void vvMainWindow::WindowLevelEdited()
-{
+{
presetComboBox->setCurrentIndex(WL_USER);
UpdateWindowLevel();
}
//------------------------------------------------------------------------------
void vvMainWindow::SetWindowLevel(double w, double l)
-{
+{
windowSpinBox->setValue(w);
levelSpinBox->setValue(l);
presetComboBox->setCurrentIndex(WL_USER);
//------------------------------------------------------------------------------
void vvMainWindow::UpdateWindowLevel()
-{
+{
if (DataTree->selectedItems().size()) {
if (presetComboBox->currentIndex() == WL_VENTILATION) //For ventilation
colorMapComboBox->setCurrentIndex(5);
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSlicingPreset()
-{
+{
if (DataTree->selectedItems().size()) {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex()));
//------------------------------------------------------------------------------
void vvMainWindow::UpdateColorMap()
-{
+{
if (DataTree->selectedItems().size()) {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
}
//------------------------------------------------------------------------------
void vvMainWindow::SwitchWindowLevel()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
int window = mSlicerManagers[index]->GetColorWindow();
presetComboBox->setCurrentIndex(WL_USER);
//------------------------------------------------------------------------------
void vvMainWindow::ApplyWindowLevelToAllImages()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if(index==-1) return;
double window = mSlicerManagers[index]->GetColorWindow();
//------------------------------------------------------------------------------
void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax)
-{
+{
for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
if (mSlicerManagers[i] == NULL)
continue;
+ SetWindowLevel(window, mSlicerManagers[i]->GetColorLevel());
mSlicerManagers[i]->SetColorWindow(window);
mSlicerManagers[i]->SetPreset(WL_USER);
mSlicerManagers[i]->Render();
//------------------------------------------------------------------------------
void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax)
-{
+{
for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
if (mSlicerManagers[i] == NULL)
continue;
+ SetWindowLevel(mSlicerManagers[i]->GetColorWindow(), level);
mSlicerManagers[i]->SetColorLevel(level);
mSlicerManagers[i]->SetPreset(WL_USER);
mSlicerManagers[i]->Render();
//------------------------------------------------------------------------------
void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps)
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
if (mSlicerManagers[i]->GetId() == id) {
mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
//------------------------------------------------------------------------------
void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm, vvSlicer* refSlicer)
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
if (id == mSlicerManagers[i]->GetId()) {
mSlicerManagers[i]->UpdateLinkedNavigation(refSlicer);
//------------------------------------------------------------------------------
void vvMainWindow::ShowContextMenu(QPoint point)
-{
+{
if (!DataTree->selectedItems().size()) {
contextActions[1]->setEnabled(0);
contextActions[2]->setEnabled(0);
//------------------------------------------------------------------------------
void vvMainWindow::CloseImage()
-{
+{
CloseImage(DataTree->selectedItems()[0],0);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::ReloadImage()
-{
+{
ReloadImage(DataTree->selectedItems()[0],0);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::SelectOverlayImage()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ if (!(CheckAddedImage(index, "overlay")))
+ return;
+
+ QString Extensions = EXTENSIONS;
+ Extensions += ";;All Files (*)";
+ QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions);
+ if (files.isEmpty())
+ return;
+
+ std::vector<std::string> vecFileNames;
+ for (int i = 0; i < files.size(); i++) {
+ vecFileNames.push_back(files[i].toStdString());
+ }
+
+ AddOverlayImage(index,vecFileNames,vvImageReader::IMAGE);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+bool vvMainWindow::CheckAddedImage(int index, QString imageType)
+{
//check if one overlay image is added
for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
- if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay") {
+ if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString().compare(imageType) == 0) {
QString error = "Cannot add more than one compared image\n";
error += "Please remove first ";
error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
QMessageBox::information(this,tr("Problem adding compared image !"),error);
- return;
- }
-
- QString Extensions = EXTENSIONS;
- Extensions += ";;All Files (*)";
- QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions);
- if (files.isEmpty())
- return;
-
- std::vector<std::string> vecFileNames;
- for (int i = 0; i < files.size(); i++) {
- vecFileNames.push_back(files[i].toStdString());
+ return false;
}
- AddOverlayImage(index,vecFileNames,vvImageReader::IMAGE);
+ return true;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{
QString file(fileNames[0].c_str());
if (QFile::exists(file))
{
item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("overlay").c_str());
qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+ for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+ mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
//------------------------------------------------------------------------------
void vvMainWindow::AddROI(int index, QString file)
-{
+{
/*
// Get slice manager
//------------------------------------------------------------------------------
void vvMainWindow::SelectFusionImage()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- //check if one fusion image is added
- for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
- if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
- (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
- QString error = "Cannot add more than one fusion image\n";
- error += "Please remove first ";
- error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
- QMessageBox::information(this,tr("Problem adding fusion image !"),error);
- return;
- }
+ if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+ return;
- QString Extensions = EXTENSIONS;
- Extensions += ";;All Files (*)";
- QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion image"),mInputPathName,Extensions);
- if (files.isEmpty())
- return;
+ QString Extensions = EXTENSIONS;
+ Extensions += ";;All Files (*)";
+ QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion image"),mInputPathName,Extensions);
+ if (files.isEmpty())
+ return;
- std::vector<std::string> vecFileNames;
- for (int i = 0; i < files.size(); i++) {
- vecFileNames.push_back(files[i].toStdString());
- }
- AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
+ std::vector<std::string> vecFileNames;
+ for (int i = 0; i < files.size(); i++) {
+ vecFileNames.push_back(files[i].toStdString());
+ }
+ AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::ResetTransformationToIdentity()
-{
+{
std::string actorType = DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString().toStdString();
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
mSlicerManagers[index]->ResetTransformationToIdentity(actorType);
//------------------------------------------------------------------------------
void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{
QString file(fileNames[0].c_str());
if (QFile::exists(file))
{
item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusion").c_str());
qApp->processEvents();
-
+#if VTK_MAJOR_VERSION > 5
+ for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+ mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::AddLandmarks(int index, std::vector<std::string> files)
-{
+{
if (!landmarksPanel->LoadFromFile(files))
QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!");
-
+
landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
}
//------------------------------------------------------------------------------
void vvMainWindow::OpenField()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- //check if a vector field has already been added
- for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
- if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector") {
- QString error = "Cannot add more than one vector field\n";
- error += "Please remove first ";
- error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
- QMessageBox::information(this,tr("Problem adding vector field!"),error);
- return;
- }
+
+ if (!(CheckAddedImage(index, "vector")))
+ return;
- QString Extensions = "Images ( *.mhd)";
- Extensions += ";;Images ( *.mha)";
- Extensions += ";;VF Images ( *.vf)";
- Extensions += ";;nii Images ( *.nii)";
- Extensions += ";;nrrd Images ( *.nrrd)";
- Extensions += ";;nhdr Images ( *.nhdr)";
- Extensions += ";;All Files (*)";
- QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
- if (!file.isEmpty())
- AddField(file,index);
+ QString Extensions = "Images ( *.mhd *.mha *.vf *.nii *.nrrd *.nhdr)";
+ // Extensions += ";;Images ( *.mha)";
+ // Extensions += ";;VF Images ( *.vf)";
+ // Extensions += ";;nii Images ( *.nii)";
+ // Extensions += ";;nrrd Images ( *.nrrd)";
+ // Extensions += ";;nhdr Images ( *.nhdr)";
+ Extensions += ";;All Files (*)";
+ QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
+ if (!file.isEmpty())
+ AddField(file,index);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
-{
+{
//create an item in the tree with good settings
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setData(0,Qt::UserRole,filename.toStdString().c_str());
//------------------------------------------------------------------------------
void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
-{
+{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
vvSlicerManager* imageManager = mSlicerManagers[index];
if (imageManager->SetVF(vf,file.toStdString())) {
AddFieldEntry(file,index,false);
+#if VTK_MAJOR_VERSION > 5
+ for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+ mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
} else {
QString error = "Cannot import the vector field for this image.\n";
error += imageManager->GetLastError().c_str();
//------------------------------------------------------------------------------
void vvMainWindow::AddField(QString file,int index)
-{
+{
if (QFile::exists(file)) {
mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
//------------------------------------------------------------------------------
void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, double r, double g, double b)
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
for (int i = 0; i < 4; i++) {
//------------------------------------------------------------------------------
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);
//------------------------------------------------------------------------------
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]->SetFusionColorMap(colormap);
//------------------------------------------------------------------------------
void vvMainWindow::SelectFusionSequence()
-{
+{
//get the index of the slicer manager of the main sequence (CT)
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- //check if one overlay image is already associated
- for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
- if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
- (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
- QString error = "Cannot add more than one compared image\n";
- error += "Please remove first ";
- error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
- QMessageBox::information(this,tr("Problem adding compared image !"),error);
- return;
- }
- QString Extensions = EXTENSIONS;
- Extensions += ";;All Files (*)";
- QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
- if (files.isEmpty())
- return;
+ if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+ return;
- std::vector<std::string> vecFileNames;
- for (int i = 0; i < files.size(); i++) {
- vecFileNames.push_back(files[i].toStdString());
- }
+ QString Extensions = EXTENSIONS;
+ Extensions += ";;All Files (*)";
+ QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
+ if (files.isEmpty())
+ return;
- //associate the secondary sequence (US) to the main one
- AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
+ std::vector<std::string> vecFileNames;
+ for (int i = 0; i < files.size(); i++) {
+ vecFileNames.push_back(files[i].toStdString());
+ }
+
+ //associate the secondary sequence (US) to the main one
+ AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvMainWindow::SelectFusionSequenceCorrespondances() {
-
+void vvMainWindow::SelectFusionSequenceCorrespondances()
+{
//make sure the index is right?
//in the end, I should attach the temporal data to the right sequence!
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
bool signalOK = true;
unsigned nbFrameMain = mSlicerManagers[index]->GetImage()->GetTransform().size();
unsigned nbFrameSecondary = mSlicerManagers[index]->GetFusionSequenceNbFrames();
-std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSecondary<<", signal size: "<<tmpVect.size()<<std::endl;
+ std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSecondary<<", signal size: "<<tmpVect.size()<<std::endl;
std::vector<unsigned> temporalCorrespondances;
if ( tmpVect.size() == nbFrameMain + nbFrameSecondary ) {
for (unsigned i=0 ; i<tmpVect.size() ; i++) {
}
else { //first part of the file -> index in secondary seq.
if ( tmpVect(i)<nbFrameMain ) temporalCorrespondances.push_back(tmpVect(i));
- else { signalOK=false; break; } //pointing outside the secondary sequence...
- }
+ else { signalOK=false; break; } //pointing outside the secondary sequence...
+ }
}
}
else {signalOK=false;}
//when this function is called index is the slicer manager index corresponding to the main sequence (CT)
//the files behind fileNames points to the data for the secondary sequence
void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{
QString file(fileNames[0].c_str());
if (QFile::exists(file))
{
item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str());
qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+ for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+ mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
}
//------------------------------------------------------------------------------
//fusionSequenceFrameIndex and fusionSequenceNbFrames are relative to the secondary sequence (US)
void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag)
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return;
+ if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return;
//check if the focus moved to the linked sequence, and in this case, select the master sequence instead
if (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
}
int secondaryIndex = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager();
if (secondaryIndex==-1) return; //this should never happen
- if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) ||
- (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) )
+ if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) ||
+ (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) )
{return;} //this should never happen, raise an exception?
if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
mainSequenceFrameIndex = mSlicerManagers[index]->GetFusionSequenceCorrespondances()[ nbFramesMain + fusionSequenceFrameIndex];
//and set it!
mSlicerManagers[index]->SetTSlice(mainSequenceFrameIndex, false);
- //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc...
+ //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc...
}
//------------------------------------------------------------------------------
void vvMainWindow::SaveAs()
-{
+{
if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
return;
//------------------------------------------------------------------------------
void vvMainWindow::SaveCurrentState()
-{
+{
QString Extensions = "XML Files(*.xml)";
QString fileName = QFileDialog::getSaveFileName(this,
tr("Save Current Window State"),
//------------------------------------------------------------------------------
void vvMainWindow::SaveCurrentStateAs(const std::string& stateFile)
-{
+{
vvSaveState save_state;
save_state.Run(this, stateFile);
}
//------------------------------------------------------------------------------
void vvMainWindow::ReadSavedState()
-{
+{
QString Extensions = "XML Files(*.xml)";
QString fileName = QFileDialog::getOpenFileName(this,
tr("Load Window State"),
//------------------------------------------------------------------------------
void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
-{
+{
vvReadState read_state;
read_state.Run(this, stateFile);
}
//------------------------------------------------------------------------------
void vvMainWindow::LinkAllImages()
-{
+{
linkPanel->linkAll();
}
//------------------------------------------------------------------------------
void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
-{
+{
if (!fromPanel) {
// delegate to linkPanel if call came from elsewhere...
linkPanel->addLinkFromIds(image1, image2);
//------------------------------------------------------------------------------
void vvMainWindow::RemoveLink(QString image1,QString image2)
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
mSlicerManagers[i]->RemoveLink(image2.toStdString());
//------------------------------------------------------------------------------
void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
-{
+{
if(mSlicerManagers.size()==1)
return;
}
//------------------------------------------------------------------------------
void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1) {
//i is the SlicerManager that is in charge of this slicer.
if (mSlicerManagers[i]->IsInvolvedInFusionSequence()) {
//if the slicerManager is involved in a fusionSequence as the secondary sequence, then update the slider position in the overlay panel and everything accordingly
- if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) {
- overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true);
+ if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) {
+ overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true);
}
else { //if this is the primary sequence that has been modified
- if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {
+ if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {
//WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex();
int estimatedValue=0;
//estimate a corresponding time index for the secondary (US) sequence, and update it accordingly.
- estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];
+ estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];
//TODO: at the moment, there is a loop in TSlice modifications
//modifying sequence 1 causes seq 2 to update, which in turns update seq1...
//I disable control on seq1 at the moment.
//------------------------------------------------------------------------------
void vvMainWindow::NOHorizontalSliderMoved()
-{
+{
// if (mCurrentTime == NOHorizontalSlider->value()) return;
HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
// mCurrentTime = NOHorizontalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::NEHorizontalSliderMoved()
-{
+{
// if (mCurrentTime == NEHorizontalSlider->value()) return;
HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
// mCurrentTime = NEHorizontalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::SOHorizontalSliderMoved()
-{
+{
// if (mCurrentTime == SOHorizontalSlider->value()) return;
HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
// mCurrentTime = SOHorizontalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::SEHorizontalSliderMoved()
-{
+{
// if (mCurrentTime == SEHorizontalSlider->value()) return;
HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
// mCurrentTime = SEHorizontalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::NOVerticalSliderChanged()
-{
+{
static int value=-1;
if (value == NOVerticalSlider->value()) return;
else value = NOVerticalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::NEVerticalSliderChanged()
-{
+{
static int value=-1;
if (value == NEVerticalSlider->value()) return;
else value = NEVerticalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::SOVerticalSliderChanged()
-{
+{
static int value=-1;
if (value == SOVerticalSlider->value()) return;
else value = SOVerticalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::SEVerticalSliderChanged()
-{
+{
static int value=-1;
if (value == SEVerticalSlider->value()) return;
else value = SEVerticalSlider->value();
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSlice(int slicer, int slice)
-{
+{
// DD("vvMainWindow::UpdateSlice");
// DD(slicer);
// DD(slice);
//------------------------------------------------------------------------------
void vvMainWindow::UpdateTSlice(int slicer, int slice, int code)
-{
+{
//FusionSequence: the slider value should be updated for slicers which show the same sequence as requested
bool doUpdate=false;
if (code==-1) doUpdate=true;
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
-{
+{
//int position = int((min+max)/2);
int position = mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(slicer)->GetSlice();
if (slicer == 0) {
//------------------------------------------------------------------------------
void vvMainWindow::SaveNOScreenshot()
-{
+{
SaveScreenshot(NOViewWidget);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::SaveNEScreenshot()
-{
+{
SaveScreenshot(NEViewWidget);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::SaveSOScreenshot()
-{
+{
SaveScreenshot(SOViewWidget);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::SaveSEScreenshot()
-{
+{
SaveScreenshot(SEViewWidget);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvMainWindow::SaveScreenshotAllSlices()
-{
+{
QVTKWidget *widget = NOViewWidget;
int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
// 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
+ QCoreApplication::flush(); // -> needed to force display of contours
- // Screenshot
+ // Screenshot
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
windowToImageFilter->SetInput(renderWindow);
windowToImageFilter->SetMagnification(1);
if (i<100) num = "0"+num;
if (i<1000) num = "0"+num;
- fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn
+ fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn
+ "_" + num + itksys::SystemTools::GetFilenameLastExtension(filename.toStdString());
writer->SetFileName(fn.c_str());
+#if VTK_MAJOR_VERSION <= 5
writer->SetInput(windowToImageFilter->GetOutput());
+#else
+ writer->SetInputConnection(windowToImageFilter->GetOutputPort());
+#endif
writer->Write();
}
}
//------------------------------------------------------------------------------
void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
-{
+{
QString Extensions = "Images( *.png);;";
Extensions += "Images( *.jpg);;";
Extensions += "Images( *.bmp);;";
if (!fileName.isEmpty()) {
vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
w2i->SetInput(widget->GetRenderWindow());
+ w2i->SetMagnification(1);
+ w2i->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
w2i->Update();
vtkImageData *image = w2i->GetOutput();
// Snapshot image if not null
if(imgwriter!=NULL) {
+#if VTK_MAJOR_VERSION <= 5
imgwriter->SetInput(image);
+#else
+ imgwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
imgwriter->SetFileName(fileName.toStdString().c_str());
imgwriter->Write();
return;
// FPS
bool ok;
- int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ int fps = QInputDialog::getInt(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"),
+ int loops = QInputDialog::getInt(this, tr("Loops"),
tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok);
if(ok)
gif->SetLoops(loops);
vidwriter = mpg;
mpg->SetQuality(2);
bool ok;
- int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
tr("FPS:"), 5, 0, 1024, 1, &ok);
if(!ok)
fps = 5;
vidwriter = mpg;
mpg->SetQuality(2);
bool ok;
- int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
tr("FPS:"), 5, 0, 1024, 1, &ok);
if(!ok)
fps = 5;
// Take video if not null
if(vidwriter!=NULL){
+#if VTK_MAJOR_VERSION <= 5
vidwriter->SetInput(image);
+#else
+ vidwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
vidwriter->SetFileName(fileName.toStdString().c_str());
vidwriter->Start();
int nSlice = mSlicerManagers[smIndex]->GetSlicer(0)->GetTMax();
vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
w2i->SetInput(widget->GetRenderWindow());
w2i->Update();
+#if VTK_MAJOR_VERSION <= 5
vidwriter->SetInput(w2i->GetOutput());
+#else
+ vidwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
vidwriter->Write();
}
vidwriter->End();
//------------------------------------------------------------------------------
void vvMainWindow::GoToCursor()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
for (int column = 1; column < 5; column++) {
if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
//------------------------------------------------------------------------------
void vvMainWindow::GoToLandmark()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
for (int column = 1; column < 5; column++) {
if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
//------------------------------------------------------------------------------
void vvMainWindow::PlayPause()
-{
+{
if (playMode) {
playMode = 0;
playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_play.png")));
//------------------------------------------------------------------------------
void vvMainWindow::PlayNext()
-{
+{
if (playMode && !this->isHidden()) {
int image_number=DataTree->topLevelItemCount();
///Only play one slicer per SM, and only if the SM is being displayed
//------------------------------------------------------------------------------
void vvMainWindow::ShowLastImage()
-{
+{
if (mSlicerManagers.size() > 1) {
QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel
+ //mSlicerManagers[GetSlicerIndexFromItem(item)]->GetSlicer(0)->SetActorVisibility("image", 0, 1); //Set the Last Image visibles
DisplayChanged(item,1);
}
}
//------------------------------------------------------------------------------
void vvMainWindow::UpdateRenderWindows()
-{
+{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
- mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks();
- mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks();
- mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks();
- mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks();
+ for (unsigned int j = 0; j < 4; ++j) {
+ mSlicerManagers[i]->GetSlicer(j)->RemoveLandmarks();
+ mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks();
+ }
}
if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
//------------------------------------------------------------------------------
void vvMainWindow::SegmentationOnCurrentImage()
-{
+{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
vvSegmentationDialog segmentation;
//------------------------------------------------------------------------------
void vvMainWindow::SurfaceViewerLaunch()
-{
+{
vvSurfaceViewerDialog surfaceViewer;
surfaceViewer.exec();
}
//------------------------------------------------------------------------------
int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
-{
+{
int number=0;
for(unsigned int l=0; l<mSlicerManagers.size(); l++) {
vvSlicerManager * v = mSlicerManagers[l];
//------------------------------------------------------------------------------
vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
-{
+{
// Change filename if another image exist with the same name
int number = GetImageDuplicateFilenameNumber(filename);
connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+
+ InitSlicers();
UpdateTree();
qApp->processEvents();
- InitSlicers();
- ShowLastImage();
InitDisplay();
+ ShowLastImage();
qApp->processEvents();
-
// End
ImageInfoChanged();
return slicer_manager;
//------------------------------------------------------------------------------
void vvMainWindow::UpdateCurrentSlicer()
-{
+{
int index = -1;
if (DataTree->selectedItems().size() > 0) {
index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
mSlicerManagerCurrentIndex = index;
}
//------------------------------------------------------------------------------
-