<property name="spacing">
<number>2</number>
</property>
- <item row="0" column="17">
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="0" column="0">
<widget class="QPushButton" name="goToCursorPushButton">
<property name="sizePolicy">
</item>
</widget>
</item>
- <item row="0" column="19">
+ <item row="0" column="21">
<widget class="QPushButton" name="viewButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="0" column="18">
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
<item row="0" column="4">
<widget class="QSpinBox" name="frameRateSpinBox">
<property name="minimum">
</property>
</widget>
</item>
+ <item row="0" column="19">
+ <widget class="QComboBox" name="slicingPresetComboBox">
+ <item>
+ <property name="text">
+ <string>World</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Voxels</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="18">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Slice to</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="17">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
<x>0</x>
<y>0</y>
<width>1008</width>
- <height>22</height>
+ <height>25</height>
</rect>
</property>
<property name="defaultUp">
connect(levelSpinBox,SIGNAL(editingFinished()),this,SLOT(WindowLevelEdited()));
connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
+ connect(slicingPresetComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateSlicingPreset()));
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)));
}
}
WindowLevelChanged();
+ slicingPresetComboBox->setCurrentIndex(mSlicerManagers[index]->GetSlicingPreset());
if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
overlayPanel->getVFName(mSlicerManagers[index]->GetVFName().c_str());
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::UpdateSlicingPreset()
+{
+ if (DataTree->selectedItems().size()) {
+ int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+ mSlicerManagers[index]->SetSlicingPreset(slicingPresetComboBox->currentIndex());
+ }
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::UpdateColorMap()
{
void SetWindowLevel(double w, double l);
void UpdateColorMap();
void UpdateWindowLevel();
+ void UpdateSlicingPreset();
void SwitchWindowLevel();
void ApplyWindowLevelToAllImages();
void UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps);
#if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
this->GetImageActor()->GetMapper()->BorderOn();
#endif
+
+ mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
+ mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
}
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+double* vvSlicer::GetCurrentPosition()
+{
+ return mCurrentBeforeSlicingTransform;
+}
+//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
{
- mCurrent[0] = x;
- mCurrent[1] = y;
- mCurrent[2] = z;
+ mCurrentBeforeSlicingTransform[0]=x;
+ mCurrentBeforeSlicingTransform[1]=y;
+ mCurrentBeforeSlicingTransform[2]=z;
+ mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
mCurrentTSlice = t;
}
//------------------------------------------------------------------------------
mImageReslice->AutoCropOutputOn();
mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
}
- mImageReslice->SetResliceTransform(mImage->GetTransform());
+
+ mConcatenatedTransform->Identity();
+ mConcatenatedTransform->Concatenate(mImage->GetTransform());
+ mConcatenatedTransform->Concatenate(mSlicingTransform);
+ mImageReslice->SetResliceTransform(mConcatenatedTransform);
mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
mImageReslice->UpdateInformation();
if (ca->GetVisibility()) {
std::stringstream worldPos;
- double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
- double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
- double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
-
-// if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
-// else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
-// if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
-// else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
-// if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
-// else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
-
- if (X >= this->GetInput()->GetWholeExtent()[0] &&
- X <= this->GetInput()->GetWholeExtent()[1] &&
- Y >= this->GetInput()->GetWholeExtent()[2] &&
- Y <= this->GetInput()->GetWholeExtent()[3] &&
- Z >= this->GetInput()->GetWholeExtent()[4] &&
- Z <= this->GetInput()->GetWholeExtent()[5]) {
+ double pt[3];
+ mConcatenatedTransform->TransformPoint(mCurrent, pt);
+ double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
+ double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
+ double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
+
+ if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
+ X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
+ Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
+ Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
+ Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
+ Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
int ix, iy, iz;
- double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
+ double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
if(ImageActor->GetVisibility())
worldPos << "data value : " << value << std::endl;
- worldPos << "mm : " << lrint(mCurrent[0]) << ' '
- << lrint(mCurrent[1]) << ' '
- << lrint(mCurrent[2]) << ' '
+ worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
+ << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
+ << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
<< mCurrentTSlice
<< std::endl;
worldPos << "pixel : " << ix << ' '
return mCursor;
}
+ vtkTransform * GetSlicingTransform() { return mSlicingTransform; }
+ vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; }
+
void SetCurrentPosition(double x, double y, double z, int t);
- double* GetCurrentPosition() {
- return mCurrent;
- }
+ double* GetCurrentPosition();
void UpdateCursorPosition();
void SetCursorVisibility(bool s);
vvLandmarks* mLandmarks;
vtkSmartPointer<vtkImageReslice> mImageReslice;
+ vtkSmartPointer<vtkTransform> mSlicingTransform;
+ vtkSmartPointer<vtkTransform> mConcatenatedTransform;
vtkSmartPointer<vtkImageReslice> mOverlayReslice;
vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
vtkSmartPointer<vvBlendImageActor> mOverlayActor;
int mCurrentTSlice;
double mCurrent[3];
+ double mCurrentBeforeSlicingTransform[3];
double mCursor[4];
int mSubSampling;
int mScale;
mPreviousSlice.resize(numberOfSlicers);
mPreviousTSlice.resize(numberOfSlicers);
+ mSlicingPreset = 0;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicerManager::UpdateViews(int current,int slicer)
{
- double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
+ double p[3], pt[3];
+ p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
+ p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
+ p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
+ mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
+
+ double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
/mSlicers[slicer]->GetInput()->GetSpacing()[0];
- double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
+ double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
/mSlicers[slicer]->GetInput()->GetSpacing()[1];
- double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
+ double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
/mSlicers[slicer]->GetInput()->GetSpacing()[2];
- if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&
- x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
- y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&
- y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
- z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
- z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
+ if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
+ x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
+ y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
+ y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
+ z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
+ z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
mSlicers[slicer]->UpdateCursorPosition();
mSlicers[slicer]->SetCursorColor(10,212,255);
switch (mSlicers[slicer]->GetSliceOrientation()) {
case vtkImageViewer2::SLICE_ORIENTATION_XY:
- if (mSlicers[slicer]->GetSlice() != (int)floor(z))
- mSlicers[slicer]->SetSlice((int)floor(z));
+ if (mSlicers[slicer]->GetSlice() != (int)lrint(z))
+ mSlicers[slicer]->SetSlice((int)lrint(z));
break;
case vtkImageViewer2::SLICE_ORIENTATION_XZ:
- if (mSlicers[slicer]->GetSlice() != (int)floor(y))
- mSlicers[slicer]->SetSlice((int)floor(y));
+ if (mSlicers[slicer]->GetSlice() != (int)lrint(y))
+ mSlicers[slicer]->SetSlice((int)lrint(y));
break;
case vtkImageViewer2::SLICE_ORIENTATION_YZ:
- if (mSlicers[slicer]->GetSlice() != (int)floor(x))
- mSlicers[slicer]->SetSlice((int)floor(x));
+ if (mSlicers[slicer]->GetSlice() != (int)lrint(x))
+ mSlicers[slicer]->SetSlice((int)lrint(x));
break;
}
mSlicers[slicer]->Render();
&& mSlicers[i]->GetRenderer()->GetDraw()
&& mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
&& mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
- mSlicers[i]->SetCurrentPosition(mSlicers[slicer]->GetCurrentPosition()[0],
- mSlicers[slicer]->GetCurrentPosition()[1],
- mSlicers[slicer]->GetCurrentPosition()[2],
- mSlicers[slicer]->GetTSlice());
+ mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetTSlice());
mSlicers[i]->UpdateCursorPosition();
if (current) { //do not display corner annotation if image is the one picked
mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
//----------------------------------------------------------------------------
void vvSlicerManager::UpdateLinked(int slicer)
{
- double x = (mSlicers[slicer]->GetCurrentPosition()[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
- /mSlicers[slicer]->GetInput()->GetSpacing()[0];
- double y = (mSlicers[slicer]->GetCurrentPosition()[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
- /mSlicers[slicer]->GetInput()->GetSpacing()[1];
- double z = (mSlicers[slicer]->GetCurrentPosition()[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
- /mSlicers[slicer]->GetInput()->GetSpacing()[2];
-
- if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&
- x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
- y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&
- y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
- z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
- z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
+ double p[3], pt[3];
+ p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
+ p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
+ p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
+ mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
+ double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) / mSlicers[slicer]->GetInput()->GetSpacing()[0];
+ double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) / mSlicers[slicer]->GetInput()->GetSpacing()[1];
+ double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) / mSlicers[slicer]->GetInput()->GetSpacing()[2];
+
+ if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
+ x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
+ y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
+ y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
+ z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
+ z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {
emit UpdateLinkManager(*i, slicer,mSlicers[slicer]->GetCurrentPosition()[0],
mSlicers[slicer]->GetCurrentPosition()[1],
refCam->GetPosition(refPosition);
refCam->GetFocalPoint(refFocal);
+ refSlicer->GetSlicingTransform()->TransformPoint(refPosition);
+ refSlicer->GetSlicingTransform()->TransformPoint(refFocal);
+ mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition);
+ mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refFocal);
+
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera();
camera->SetParallelScale(refCam->GetParallelScale());
focal[2] = refFocal[2];
}
}
-
+DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
camera->SetFocalPoint(focal);
+DD(camera->GetFocalPoint()[0] << ' ' << camera->GetFocalPoint()[1] << ' ' << camera->GetFocalPoint()[2])
+DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
camera->SetPosition(position);
-
+DD(camera->GetPosition()[0] << ' ' << camera->GetPosition()[1] << ' ' << camera->GetPosition()[2])
+
//Fix for bug #243
mSlicers[i]->ForceUpdateDisplayExtent();
}
}
//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+void vvSlicerManager::SetSlicingPreset(int preset)
+{
+ if(mSlicingPreset==preset)
+ return;
+
+ vtkMatrix4x4 *mImageTransformInverse = vtkMatrix4x4::New();
+ mImage->GetTransform()->GetInverse(mImageTransformInverse);
+
+ for(int i=0; i< this->GetNumberOfSlicers(); i++){
+ switch(preset)
+ {
+ case 0: // World
+ this->GetSlicer(i)->GetSlicingTransform()->Identity();
+ break;
+ case 1: // Voxels
+ this->GetSlicer(i)->GetSlicingTransform()->SetMatrix(mImageTransformInverse);
+ break;
+ default:
+ mImageTransformInverse->Delete();
+ return;
+ }
+ this->GetSlicer(i)->ForceUpdateDisplayExtent();
+ this->GetSlicer(i)->ResetCamera();
+ this->GetSlicer(i)->Render();
+ }
+
+ mImageTransformInverse->Delete();
+ mSlicingPreset = preset;
+}
+
+//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void vvSlicerManager::SetPreset(int preset)
else {
this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
this->mSlicers[slicer]->GetImage()->GetVTKImages()[t],
- this->mSlicers[slicer]->GetImage()->GetTransform());
+ this->mSlicers[slicer]->GetConcatenatedTransform());
this->SetColorWindow(max-min);
this->SetColorLevel(0.5*(min+max));
this->SetPreset(6);
int GetPreset() {
return mPreset;
}
+ int GetSlicingPreset() {
+ return mSlicingPreset;
+ }
int GetOverlayColor() const {
return mOverlayColor;
}
void UpdateSlice(int slicer);
void UpdateTSlice(int slicer);
void UpdateSliceRange(int slicer);
+ void SetSlicingPreset(int preset);
vvLandmarks *GetLandmarks();
void AddLandmark(float x,float y,float z,float t);
bool mFusionShowLegend;
int mPreset;
+ int mSlicingPreset;
vvImageReader::LoadedImageType mType;
std::string mVFComponent;
std::string mOverlayComponent;
zWorld = z;
break;
}
- this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
+
+ double p[3]; p[0] = xWorld; p[1] = yWorld; p[2] = zWorld;
+ double pt[3];
+ this->SM->GetSlicer(VisibleInWindow)->GetSlicingTransform()->TransformPoint(p, pt);
+
+ this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(pt[0],pt[1],pt[2],
this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
if (newLandmark) {
this->SM->AddLandmark(xWorld,yWorld,zWorld,