X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=0673eae896c5dbe7d3f355daa42fcd9e92b5c531;hb=2462405ada0fb899d56bf6d4fc9f2e0c15935cb9;hp=1c9765efbbb37983a293ffd37f72abc9768c6e0e;hpb=d3682a4b4db6ce9090a38c37d124ee9c24f6fd5f;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 1c9765e..0673eae 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -67,9 +67,13 @@ #include "vtkPNMWriter.h" #include "vtkPNGWriter.h" #include "vtkJPEGWriter.h" +#include "vtkMatrix4x4.h" +#include "vtkTransform.h" // Standard includes #include +#include +#include #define COLUMN_TREE 0 #define COLUMN_UL_VIEW 1 @@ -268,13 +272,14 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap())); connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel())); connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel())); + connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages())); connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint))); 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)),this,SLOT(SetVFProperty(int,int,int,int))); + 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(FusionPropertyUpdated(int,int,double,double)), this,SLOT(SetFusionProperty(int,int,double,double))); @@ -316,6 +321,22 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() if (!CLITK_EXPERIMENTAL) menuExperimental->menuAction()->setVisible(false); + + + QTimer * timerMemory = new QTimer(this); + //timerMemory->setInterval(5); + connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage())); + timerMemory->start(2000); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvMainWindow::UpdateMemoryUsage() +{ + // clitk::PrintMemory(true); + if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA"); + else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB"); } //------------------------------------------------------------------------------ @@ -821,6 +842,7 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi item->setData(0,Qt::UserRole,files[i].c_str()); QFileInfo fileinfo(imageManager->GetFileName().c_str()); //Do not show the path item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath()); qApp->processEvents(); //Create the buttons for reload and close @@ -896,8 +918,6 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi // Try to guess default WindowLevel double range[2]; mSlicerManagers.back()->GetImage()->GetFirstVTKImageData()->GetScalarRange(range); - // DD(range[0]); - // DD(range[1]); if ((range[0] == 0) && (range[1] == 1)) { presetComboBox->setCurrentIndex(5);// binary } else { @@ -925,9 +945,6 @@ void vvMainWindow::UpdateTree() //------------------------------------------------------------------------------ void vvMainWindow::CurrentImageChanged(std::string id) { - // DD("CurrentImageChanged"); -// DD(id); -// DD(mCurrentSelectedImageId); if (id == mCurrentSelectedImageId) return; // Do nothing int selected = 0; for (int i = 0; i < DataTree->topLevelItemCount(); i++) { @@ -941,7 +958,6 @@ void vvMainWindow::CurrentImageChanged(std::string id) } DataTree->topLevelItem(selected)->setSelected(1); - // DD(mSlicerManagers[selected]->GetFileName()); mCurrentSelectedImageId = id; emit SelectedImageHasChanged(mSlicerManagers[selected]); } @@ -979,6 +995,7 @@ void vvMainWindow::ImageInfoChanged() std::vector inputSpacing; std::vector inputSize; std::vector sizeMM; + vtkSmartPointer transformation; int dimension=0; QString pixelType; QString inputSizeInBytes; @@ -1012,6 +1029,7 @@ void vvMainWindow::ImageInfoChanged() sizeMM[i] = inputSize[i]*inputSpacing[i]; NPixel *= inputSize[i]; } + transformation = imageSelected->GetTransform()->GetMatrix(); inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000); } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") { vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF(); @@ -1073,6 +1091,7 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setOrigin(GetVectorDoubleAsString(origin)); infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); + infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation)); landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size()); @@ -1088,8 +1107,6 @@ void vvMainWindow::ImageInfoChanged() } windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow()); levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel()); - // DD(mSlicerManagers[index]->GetColorMap()); - // DD(mSlicerManagers[index]->GetPreset()); presetComboBox->setCurrentIndex(mSlicerManagers[index]->GetPreset()); colorMapComboBox->setCurrentIndex(mSlicerManagers[index]->GetColorMap()); @@ -1223,6 +1240,29 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer matrix) +{ + std::ostringstream strmatrix; + + for (unsigned int i = 0; i < 4; i++) { + for (unsigned int j = 0; j < 4; j++) { + strmatrix.flags(ios::showpos); + strmatrix.width(10); + strmatrix.precision(3); + strmatrix.setf(ios::fixed,ios::floatfield); + strmatrix.fill(' '); + strmatrix << std::left << matrix->GetElement(i, j); + //strmatrix.width(10); + strmatrix << " "; + } + strmatrix << std::endl; + } + QString result = strmatrix.str().c_str(); + return result; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ QString vvMainWindow::GetVectorDoubleAsString(std::vector vectorDouble) { @@ -1494,6 +1534,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column) InitDisplay(); } } + ImageInfoChanged(); } //------------------------------------------------------------------------------ @@ -1591,6 +1632,8 @@ 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()); } } //------------------------------------------------------------------------------ @@ -1615,6 +1658,20 @@ void vvMainWindow::SwitchWindowLevel() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::ApplyWindowLevelToAllImages() +{ + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { + if (mSlicerManagers[i] == NULL) + continue; + mSlicerManagers[i]->SetColorWindow(windowSpinBox->value()); + mSlicerManagers[i]->SetColorLevel(levelSpinBox->value()); + mSlicerManagers[i]->SetPreset(6); + mSlicerManagers[i]->Render(); + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps) { @@ -1727,7 +1784,9 @@ void vvMainWindow::AddOverlayImage(int index, QString file) QTreeWidgetItem *item = new QTreeWidgetItem(); item->setData(0,Qt::UserRole,file.toStdString().c_str()); item->setData(1,Qt::UserRole,tr("overlay")); - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str()); + QFileInfo fileinfo(file); //Do not show the path + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath()); qApp->processEvents(); for (int j = 1; j <= 4; j++) { @@ -1779,7 +1838,6 @@ void vvMainWindow::AddOverlayImage(int index, QString file) //------------------------------------------------------------------------------ void vvMainWindow::AddROI(int index, QString file) { - DD("AddImageAndROI"); /* // Get slice manager @@ -1848,7 +1906,9 @@ void vvMainWindow::AddFusionImage(int index, QString file) QTreeWidgetItem *item = new QTreeWidgetItem(); item->setData(0,Qt::UserRole,file.toStdString().c_str()); item->setData(1,Qt::UserRole,tr("fusion")); - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str()); + QFileInfo fileinfo(filename.c_str()); //Do not show the path + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath()); qApp->processEvents(); for (int j = 1; j <= 4; j++) { @@ -1931,7 +1991,9 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk) QTreeWidgetItem *item = new QTreeWidgetItem(); item->setData(0,Qt::UserRole,filename.toStdString().c_str()); item->setData(1,Qt::UserRole,tr("vector")); - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename); + QFileInfo fileinfo(filename); //Do not show the path + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName()); + item->setToolTip(COLUMN_IMAGE_NAME,fileinfo.absoluteFilePath()); qApp->processEvents(); for (int j = 1; j <= 4; j++) { @@ -2025,7 +2087,7 @@ void vvMainWindow::AddField(QString file,int index) //------------------------------------------------------------------------------ -void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) +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()) { @@ -2033,6 +2095,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling); mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale); mSlicerManagers[index]->GetSlicer(i)->SetVFWidth(width); + mSlicerManagers[index]->GetSlicer(i)->SetVFColor(r,g,b); if (log > 0) mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1); else @@ -2161,7 +2224,6 @@ void vvMainWindow::AddLink(QString image1,QString image2) //------------------------------------------------------------------------------ void vvMainWindow::RemoveLink(QString image1,QString image2) { - // DD("vvMainWindow:RemoveLink"); for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (image1.toStdString() == mSlicerManagers[i]->GetId()) { mSlicerManagers[i]->RemoveLink(image2.toStdString()); @@ -2296,8 +2358,6 @@ void vvMainWindow::NEVerticalSliderChanged() void vvMainWindow::SOVerticalSliderChanged() { static int value=-1; - // DD(value); -// DD(SOVerticalSlider->value()); if (value == SOVerticalSlider->value()) return; else value = SOVerticalSlider->value(); //int value = SOVerticalSlider->value(); @@ -2717,6 +2777,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen qApp->processEvents(); // End + ImageInfoChanged(); return slicer_manager; } //------------------------------------------------------------------------------