#include "vtkPNMWriter.h"
#include "vtkPNGWriter.h"
#include "vtkJPEGWriter.h"
+#include "vtkMatrix4x4.h"
+#include "vtkTransform.h"
// Standard includes
#include <iostream>
+#include <sstream>
+#include <iomanip>
#define COLUMN_TREE 0
#define COLUMN_UL_VIEW 1
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)));
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");
}
//------------------------------------------------------------------------------
progress.SetProgress(i,fileSize);
qApp->processEvents();
- for (int j = 0; j < nSlices[i]; j++) {
+ for (unsigned int j = 0; j < nSlices[i]; j++) {
//read the image and put it in mSlicerManagers
vvSlicerManager* imageManager = new vvSlicerManager(4);
qApp->processEvents();
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
// 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 {
//------------------------------------------------------------------------------
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++) {
}
DataTree->topLevelItem(selected)->setSelected(1);
- // DD(mSlicerManagers[selected]->GetFileName());
mCurrentSelectedImageId = id;
emit SelectedImageHasChanged(mSlicerManagers[selected]);
}
std::vector<double> inputSpacing;
std::vector<int> inputSize;
std::vector<double> sizeMM;
+ vtkSmartPointer<vtkMatrix4x4> transformation;
int dimension=0;
QString pixelType;
QString inputSizeInBytes;
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();
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());
}
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());
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> 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<double> vectorDouble)
{
InitDisplay();
}
}
+ ImageInfoChanged();
}
//------------------------------------------------------------------------------
mSlicerManagers[index]->SetColorLevel(levelSpinBox->value());
mSlicerManagers[index]->SetPreset(presetComboBox->currentIndex());
mSlicerManagers[index]->Render();
+ windowSpinBox->setValue(mSlicerManagers[index]->GetColorWindow());
+ levelSpinBox->setValue(mSlicerManagers[index]->GetColorLevel());
}
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+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)
{
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++) {
//------------------------------------------------------------------------------
void vvMainWindow::AddROI(int index, QString file)
{
- DD("AddImageAndROI");
/*
// Get slice manager
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++) {
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++) {
//------------------------------------------------------------------------------
-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()) {
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
//------------------------------------------------------------------------------
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());
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();
qApp->processEvents();
// End
+ ImageInfoChanged();
return slicer_manager;
}
//------------------------------------------------------------------------------