#include "vvSlicer.h"
#include "vvInteractorStyleNavigator.h"
#include "vvImageWriter.h"
-#include "vvResamplerDialog.h"
#include "vvSegmentationDialog.h"
#include "vvSurfaceViewerDialog.h"
#include "vvDeformationDialog.h"
mContextMenu = &contextMenu;
mMenuExperimentalTools = menuExperimental;
mMainWidget = this;
+ mCurrentTime = -1;
//Init the contextMenu
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
///////////////////////////////////////////////
- contextMenu.addAction(actionResampler);
- connect(actionResampler,SIGNAL(triggered()),this,SLOT(ResampleCurrentImage()));
connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
connect(actionSurface_Viewer,SIGNAL(triggered()),this,SLOT(SurfaceViewerLaunch()));
///////////////////////////////////////////////
linkPanel->addImage(imageManager->GetFileName(), id.toStdString());
- connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
+ connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
this,SLOT(CurrentImageChanged(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)),
+ 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)),
this, SLOT(VectorChanged(int,double,double,double, double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
this, SLOT(OverlayChanged(int,double,double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
this,SLOT(WindowsChanged(int, int, int)));
- connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
this,SLOT(WindowLevelChanged(double, double, int, int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
this,SLOT(UpdateSlice(int,int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
this,SLOT(UpdateTSlice(int, int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
this,SLOT(UpdateSliceRange(int,int,int,int,int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
+ connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
+ this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
InitSlicers();
numberofsuccesulreads++;
}
QApplication::restoreOverrideCursor();
+ // 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 {
+ // TODO
+ }
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+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)
+ return DataTree->topLevelItem(i);
+ }
+ return NULL;
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column) {
int index = GetSlicerIndexFromItem(clicked_item);
return;
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
{
+ //Trick to avoid redoing twice the job for a key (sr)
+ mSlicerManagers[i]->GetSlicer(column-1)->GetRenderWindow()-> GetInteractor()->SetKeySym("Crap");
+
QTreeWidgetItem* current_row=DataTree->topLevelItem(i);
if (DataTree->topLevelItem(index) == current_row)
{
}
}
}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
void vvMainWindow::OpenField()
{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
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
ImageInfoChanged();
QApplication::restoreOverrideCursor();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
QApplication::restoreOverrideCursor();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
void vvMainWindow::AddField(QString file,int index)
{
if (QFile::exists(file))
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SetVFProperty(int subsampling, int scale, int log) {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SetOverlayProperty(int color) {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
+{
+ int index = 0;
+ while(sm != mSlicerManagers[index])
+ index++;
+ index = (index+offset) % mSlicerManagers.size();
+
+ QTreeWidgetItem* item = GetItemFromSlicerManager(mSlicerManagers[index]);
+ //CurrentImageChanged(mSlicerManagers[index]->GetId()); //select new image
+ item->setData(slicer+1,Qt::CheckStateRole,2); //change checkbox
+ DisplayChanged(item,slicer+1);
+}
+//------------------------------------------------------------------------------
+
void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
{
for (unsigned int i = 0; i < mSlicerManagers.size(); i++)
}
}
}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
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();
}
//------------------------------------------------------------------------------
if (DataTree->topLevelItem(i)->data(COLUMN_UL_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
- mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ?
+ mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
+ // mSlicerManagers[i]->UpdateSlice(0); // <-- DS add this. Not too much update ? YES.
+ mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::NEVerticalSliderChanged() {
int value = NEVerticalSlider->value();
if (DataTree->topLevelItem(i)->data(COLUMN_UR_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
+ mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SOVerticalSliderChanged() {
int value = SOVerticalSlider->value();
if (DataTree->topLevelItem(i)->data(COLUMN_DL_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
+ mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SEVerticalSliderChanged() {
int value = SEVerticalSlider->value();
if (DataTree->topLevelItem(i)->data(COLUMN_DR_VIEW,Qt::CheckStateRole).toInt() > 1)
{
mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
+ mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
+ mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ?
break;
}
}
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSlice(int slicer, int slice) {
if (slicer == 0) {
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::UpdateTSlice(int slicer, int slice) {
switch (slicer)
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax) {
int position = int((min+max)/2);
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveNOScreenshot() {
vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveNEScreenshot() {
vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveSOScreenshot() {
vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveSEScreenshot() {
vtkWindowToImageFilter *w2i = vtkWindowToImageFilter::New();
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::SaveScreenshot(vtkImageData* image) {
QString Extensions = "Images( *.png);;";
}
//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::GoToCursor() {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
}
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-void vvMainWindow::ResampleCurrentImage() {
- vvResamplerDialog resampler;
- int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
- resampler.SetSlicerManagers(mSlicerManagers,index);
- if (resampler.exec())
- AddImage(resampler.GetOutput(),resampler.GetOutputFileName());
-}
-//------------------------------------------------------------------------------
-
//------------------------------------------------------------------------------
void vvMainWindow::SegmentationOnCurrentImage() {
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
//------------------------------------------------------------------------------
void vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
{
- vvSlicerManager* m = new vvSlicerManager(4);
- m->SetImage(image);
- m->SetFilename(filename);
- AddImage(m);
-}
-
-//------------------------------------------------------------------------------
-void vvMainWindow::AddImage(vvSlicerManager * slicer_manager) {
+ vvSlicerManager* slicer_manager = new vvSlicerManager(4);
+ slicer_manager->SetImage(image);
+ slicer_manager->SetFilename(filename);
mSlicerManagers.push_back(slicer_manager);
- std::string filename = slicer_manager->GetFileName();
-
//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());
linkPanel->addImage(filename, id.toStdString());
- connect(mSlicerManagers.back(),SIGNAL(currentImageChanged(std::string)),
- this,SLOT(CurrentImageChanged(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)),
+ connect(mSlicerManagers.back(), SIGNAL(currentImageChanged(std::string)),
+ this, SLOT(CurrentImageChanged(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)),
this, SLOT(VectorChanged(int,double,double,double, double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateOverlay(int, double, double)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateOverlay(int, double, double)),
this, SLOT(OverlayChanged(int,double,double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateFusion(int, double)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
this, SLOT(FusionChanged(int,double)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateWindows(int, int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
this,SLOT(WindowsChanged(int, int, int)));
- connect(mSlicerManagers.back(),SIGNAL(WindowLevelChanged(double, double,int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
this,SLOT(WindowLevelChanged(double, double, int, int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateSlice(int,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
this,SLOT(UpdateSlice(int,int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateTSlice(int, int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
this,SLOT(UpdateTSlice(int, int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateSliceRange(int,int,int,int,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
this,SLOT(UpdateSliceRange(int,int,int,int,int)));
- connect(mSlicerManagers.back(),SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
+ connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
this,SLOT(UpdateLinkManager(std::string,int,double,double,double,int)));
- connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
+ connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
+ this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
+ connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
UpdateTree();
qApp->processEvents();
InitSlicers();