X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=vv%2FvvMainWindow.cxx;h=760fa758558712aa798d07847b614a2ffd5f569f;hb=ff1d5b8af965e75ecdbc1b0cbff0dad6f3b3c511;hp=fb764580f224f30bb6fe8cd3fd8655b0171dc2dc;hpb=5fb8553213994e031467ba14b92a9c1319d28f83;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index fb76458..760fa75 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -38,7 +38,6 @@ #include "vvDeformationDialog.h" #include "vvImageWarp.h" #include "vvUtils.h" -#include "vvMaximumIntensityProjection.h" #include "vvMidPosition.h" #include "vvMesh.h" #include "vvStructSelector.h" @@ -109,6 +108,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() mMainWidget = this; mCurrentTime = -1; mCurrentSelectedImageId = ""; + mCurrentPickedImageId = ""; + mCurrentPickedImageIndex = 0; //Init the contextMenu this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -229,7 +230,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(SEHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(SEHorizontalSliderMoved())); //connect everything - connect(actionMaximum_Intensity_Projection,SIGNAL(triggered()),this,SLOT(ComputeMIP())); connect(actionCompute_mid_position_image,SIGNAL(triggered()),this,SLOT(ComputeMidPosition())); connect(actionDeformable_Registration,SIGNAL(triggered()),this,SLOT(ComputeDeformableRegistration())); connect(actionWarp_image_with_vector_field,SIGNAL(triggered()),this,SLOT(WarpImage())); @@ -327,6 +327,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() //timerMemory->setInterval(5); connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage())); timerMemory->start(2000); + } //------------------------------------------------------------------------------ @@ -341,19 +342,6 @@ void vvMainWindow::UpdateMemoryUsage() //------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -void vvMainWindow::ComputeMIP() -{ - vvMaximumIntensityProjection mip; - vvSlicerManager* selected_slicer = mSlicerManagers[GetSlicerIndexFromItem(DataTree->selectedItems()[0])]; - QFileInfo info(selected_slicer->GetFileName().c_str()); - mip.Compute(selected_slicer); - if (!mip.error) - AddImage(mip.GetOutput(),info.path().toStdString()+"/"+info.completeBaseName().toStdString()+"_mip.mhd"); -} -//------------------------------------------------------------------------------ - - //------------------------------------------------------------------------------ void vvMainWindow::ComputeMidPosition() { @@ -876,6 +864,8 @@ void vvMainWindow::LoadImages(std::vector files, LoadedImageType fi connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), this,SLOT(CurrentImageChanged(std::string))); + connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)), + this, SLOT(CurrentPickedImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)), this,SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)), @@ -963,6 +953,27 @@ void vvMainWindow::CurrentImageChanged(std::string id) } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvMainWindow::CurrentPickedImageChanged(std::string id) +{ + if (id == mCurrentPickedImageId) return; // Do nothing + int selected = 0; + for (int i = 0; i < DataTree->topLevelItemCount(); i++) { + if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString().toStdString() == id) { + selected = i; + } else { + DataTree->topLevelItem(i)->setSelected(0); + } + for (int child = 0; child < DataTree->topLevelItem(i)->childCount(); child++) + DataTree->topLevelItem(i)->child(child)->setSelected(0); + + } + DataTree->topLevelItem(selected)->setSelected(1); + mCurrentPickedImageId = id; + mCurrentPickedImageIndex = selected; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvMainWindow::ImageInfoChanged() { @@ -1081,8 +1092,6 @@ void vvMainWindow::ImageInfoChanged() inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000); } - transformation = imageSelected->GetTransform()->GetMatrix(); - QString dim = QString::number(dimension) + " ("; dim += pixelType + ")"; @@ -1093,6 +1102,7 @@ void vvMainWindow::ImageInfoChanged() infoPanel->setOrigin(GetVectorDoubleAsString(origin)); infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing)); infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")"); + transformation = imageSelected->GetTransform()->GetMatrix(); infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation)); landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(), @@ -2211,15 +2221,29 @@ void vvMainWindow::SaveAs() //------------------------------------------------------------------------------ void vvMainWindow::AddLink(QString image1,QString image2) { + unsigned int sm1 = 0; + unsigned int sm2 = 0; + for (unsigned int i = 0; i < mSlicerManagers.size(); i++) { if (image1.toStdString() == mSlicerManagers[i]->GetId()) { mSlicerManagers[i]->AddLink(image2.toStdString()); + sm1 = i; } if (image2.toStdString() == mSlicerManagers[i]->GetId()) { mSlicerManagers[i]->AddLink(image1.toStdString()); + sm2 = i; } } + + if (linkPanel->isLinkAll()) { + emit UpdateLinkedNavigation(mSlicerManagers[sm1]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]); + emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[mCurrentPickedImageIndex]); + } + else { + emit UpdateLinkedNavigation(mSlicerManagers[sm2]->GetId(), mSlicerManagers[sm1]); + } } + //------------------------------------------------------------------------------ @@ -2711,7 +2735,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen //create an item in the tree with good settings QTreeWidgetItem *item = new QTreeWidgetItem(); item->setData(0,Qt::UserRole,slicer_manager->GetFileName().c_str());//files[i].c_str()); - item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,filename.c_str()); + item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,slicer_manager->GetFileName().c_str());//filename.c_str()); qApp->processEvents(); for (int j = 1; j <= 4; j++) item->setData(j,Qt::CheckStateRole,1); @@ -2742,10 +2766,13 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen item->setData(COLUMN_IMAGE_NAME,Qt::UserRole,id.toStdString().c_str()); mSlicerManagers.back()->SetId(id.toStdString()); - linkPanel->addImage(filename, id.toStdString()); + linkPanel->addImage(slicer_manager->GetFileName().c_str()// filename + , id.toStdString()); connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)), this, SLOT(CurrentImageChanged(std::string))); + connect(mSlicerManagers.back(), SIGNAL(currentPickedImageChanged(std::string)), + this, SLOT(CurrentPickedImageChanged(std::string))); connect(mSlicerManagers.back(), SIGNAL(UpdatePosition(int, double, double, double, double, double, double, double)), this, SLOT(MousePositionChanged(int,double, double, double, double, double, double, double))); connect(mSlicerManagers.back(), SIGNAL(UpdateVector(int, double, double, double, double)),