}
}
+ void SetPanelShift(double x, double y)
+ {
+ m_PanelShift[0] = x;
+ m_PanelShift[1] = y;
+ }
// itkSetMacro(IsoCenter, OutputPointType);
// itkGetConstReferenceMacro(IsoCenter, OutputPointType)
// itkSetMacro( SourceToScreen, double );
double m_SourceToAxis;
OutputPixelType m_EdgePaddingValue;
double m_ProjectionAngle;
+ double m_PanelShift[2];
// Output image info
OutputSizeType m_OutputSize; // Size of the output image
#include "clitkBackProjectImageFilter.h"
#include "itkContinuousIndex.h"
#include "vnl/vnl_math.h"
+#include "itkLinearInterpolateImageFunction.h"
namespace clitk
{
this->m_SourceToAxis = 1000.0;
this->m_EdgePaddingValue = itk::NumericTraits<OutputPixelType>::Zero;//density images
this->m_RigidTransformMatrix.SetIdentity();
+ this->m_PanelShift[0] = 0.;
+ this->m_PanelShift[1] = 0.;
//Parameters for output
this->m_OutputSpacing.Fill(1);
{
//Projection pointer
InputImageConstPointer inputPtr=this->GetInput();
- InputPixelType * beginPtr=const_cast<InputPixelType *>(this->GetInput()->GetBufferPointer());
- InputPixelType * pp;
//Volume pointer
OutputImagePointer outputPTr= this->GetOutput();
OutputIndexType oIndex;
ContinuousInputIndexType iIndex;
InputSizeType inputSize=inputPtr->GetLargestPossibleRegion().GetSize();
- double dx,dy,dxm,dym;
- int lx, ly;
//Get the first output coordinate
oIndex=iterator.GetIndex();//costly but only once a thread
//Compute the first input coordinate (invert Y/X)
homInputPoint= (m_ProjectionMatrix * homOutputPoint);
- iPoint[0]=-homInputPoint[0]/homInputPoint[2];
- iPoint[1]=homInputPoint[1]/homInputPoint[2];
-
+ iPoint[0]=-homInputPoint[0]/homInputPoint[2] + m_PanelShift[0];
+ iPoint[1]=homInputPoint[1]/homInputPoint[2] + m_PanelShift[1];
+
+ typedef itk::LinearInterpolateImageFunction< InputImageType, double > InterpolatorType;
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ interpolator->SetInputImage(this->GetInput());
+
//Run over all output voxels
for (unsigned int i=0; i<outputSizeForThread[2]; i++)
{
{
for (unsigned int k=0; k<outputSizeForThread[0]; k++)
{
- iPoint[0]=homInputPoint[0]/homInputPoint[2];
- iPoint[1]=homInputPoint[1]/homInputPoint[2];
+ iPoint[0]=-homInputPoint[0]/homInputPoint[2] + m_PanelShift[0];
+ iPoint[1]=homInputPoint[1]/homInputPoint[2] + m_PanelShift[1];
//Check wether inside, convert to index (use modified with correct origin)
- if( m_ModifiedInput->TransformPhysicalPointToContinuousIndex(iPoint, iIndex) )
- {
- //Own (fast bilinear) interpolation
- lx = (int)floor(iIndex[0]); dx = iIndex[0]-lx; dxm = 1.-dx;
- ly = (int)floor(iIndex[1]); dy = iIndex[1]-ly; dym = 1.-dy;
- pp = beginPtr + ly*inputSize[0]+lx;
- value =static_cast<OutputPixelType>( ( dxm * dym*(double)(*pp)
- + dx * dym*(double)(*(pp+1))
- + dxm* dy *(double)(*(pp + inputSize[0]))
- + dx * dy *(double)(*(pp + inputSize[0]+1))) );
-
- }
+ if (m_ModifiedInput->TransformPhysicalPointToContinuousIndex(iPoint, iIndex) && interpolator->IsInsideBuffer(iIndex))
+ value = interpolator->EvaluateAtContinuousIndex(iIndex);
//Outside: padding value
- else value=m_EdgePaddingValue;
-
+ else
+ value=m_EdgePaddingValue;
//Set it
iterator.Set(value);
option "spacing" - "Spacing for the output image" double multiple no default="0.8"
option "panel_position" - "Approximate position of the panel: small, medium or large" string no default="small"
-option "panel_shift" - "Precise position of the panel in mm" double no
+option "panel_shift" - "Precise position of the panel in mm" double multiple no
}
/** Set the panelshift. */
- void SetPanelShift(double shift)
+ void SetPanelShift(double x, double y)
{
- if (m_PanelShift!=shift)
+ if (m_PanelShift[0] != x)
{
- m_PanelShift=shift;
+ m_PanelShift[0] = x;
+ m_IsInitialized=false;
+ }
+ if (m_PanelShift[1] != y)
+ {
+ m_PanelShift[1] = y;
m_IsInitialized=false;
}
}
double m_SourceToScreen;
double m_SourceToAxis;
double m_ProjectionAngle;
- double m_PanelShift;
+ double m_PanelShift[2];
MatrixType m_RigidTransformMatrix;
OutputPixelType m_EdgePaddingValue;
m_IsoCenter.Fill(0.0);
m_SourceToScreen=1536.;
m_SourceToAxis=1000.;
+ m_PanelShift[0] = 0.;
+ m_PanelShift[1] = 0.;
m_ProjectionAngle=0.;
m_RigidTransformMatrix.SetIdentity();
m_EdgePaddingValue=itk::NumericTraits<OutputPixelType>::Zero;//density images
spacingOutput[1] = m_OutputSpacing[0]; // pixel spacing along Y of the 2D DRR image [mm]
spacingOutput[2] = m_OutputSpacing[1]; // pixel spacing along Y of the 2D DRR image [mm]
m_Resampler->SetOutputSpacing( spacingOutput );
- if (m_Verbose)std::cout<<"The output size is "<< m_OutputSpacing <<"..."<< std::endl;
+ if (m_Verbose)std::cout<<"The output spacing is "<< m_OutputSpacing <<"..."<< std::endl;
// The position of the DRR is specified, we presume that for an angle of 0° the flatpanel is located at the negative x-axis
// JV -1 seems to correspond better with shearwarp of Simon Rit
typename InterpolatorType::InputPointType originOutput;
originOutput[0] = m_IsoCenter[0]- (m_SourceToScreen - m_SourceToAxis);
DD(m_PanelShift);
- originOutput[1] = m_IsoCenter[1]-static_cast<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift;
- originOutput[2] = m_IsoCenter[2]-static_cast<double>(sizeOuput[2]-1)*spacingOutput[2]/2.0;
+ originOutput[1] = m_IsoCenter[1]-static_cast<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift[0];
+ originOutput[2] = m_IsoCenter[2]-static_cast<double>(sizeOuput[2]-1)*spacingOutput[2]/2.0 - m_PanelShift[1];
m_Resampler->SetOutputOrigin( originOutput );
if (m_Verbose)std::cout<<"The origin of the flat panel is at "<< originOutput <<",..."<< std::endl;
DD(m_ArgsInfo.panel_position_arg);
if (m_ArgsInfo.panel_shift_given) // one should read the specific values for each angle in Frame.dbf
- filter->SetPanelShift(m_ArgsInfo.panel_shift_arg);
+ filter->SetPanelShift(m_ArgsInfo.panel_shift_arg[0], m_ArgsInfo.panel_shift_arg[1]);
else { // approximate panel positions hard coded values for the elekta synergy
if (strcmp(m_ArgsInfo.panel_position_arg,"small") ==0)
- filter->SetPanelShift(0.);
+ filter->SetPanelShift(0., 0.);
else if (strcmp(m_ArgsInfo.panel_position_arg,"medium") ==0)
- filter->SetPanelShift(114.84);
+ filter->SetPanelShift(114.84, 0.); // VD : 120 , 0 ?
else if (strcmp(m_ArgsInfo.panel_position_arg,"large") ==0)
- filter->SetPanelShift(190.);
+ filter->SetPanelShift(190., 0.);
else assert(false); //Unsupported panel position
}
// Output image info
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
+</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">space</span><span style=" font-size:12pt;">: Landmark</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600; text-decoration: underline;">Navigation</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">u</span><span style=" font-size:12pt;">: </span><span style=" font-size:12pt; text-decoration: underline;">U</span><span style=" font-size:12pt;">pdate Image</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">f</span><span style=" font-size:12pt;">: </span><span style=" font-size:12pt; text-decoration: underline;">F</span><span style=" font-size:12pt;">ly To Mouse Position</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">g</span><span style=" font-size:12pt;">: </span><span style=" font-size:12pt; text-decoration: underline;">G</span><span style=" font-size:12pt;">o to Crosshair Position</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">o</span><span style=" font-size:12pt;">: Go to Image </span><span style=" font-size:12pt; text-decoration: underline;">O</span><span style=" font-size:12pt;">rigin</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">h</span><span style=" font-size:12pt;">: </span><span style=" font-size:12pt; text-decoration: underline;">H</span><span style=" font-size:12pt;">ide Crosshair and corner annotations</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Up,Down</span><span style=" font-size:12pt;">: Change Slice</span></p>
<rect>
<x>0</x>
<y>0</y>
- <width>323</width>
- <height>447</height>
+ <width>342</width>
+ <height>480</height>
</rect>
</property>
<property name="sizePolicy">
</item>
<item>
<widget class="QToolButton" name="vfColorButton">
- <property name="styleSheet">
- <string>
+ <property name="styleSheet">
+ <string>
background-color: rgb(0, 255, 0);
border: 0px;
</string>
- </property>
+ </property>
</widget>
</item>
</layout>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>2</number>
- </property>
- <property name="spacing">
- <number>2</number>
- </property>
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="maximumSize">
</property>
</widget>
</item>
- <item row="0" column="1" colspan="4">
+ <item row="0" column="1" colspan="2">
<widget class="QLabel" name="dataFusionnedLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2">
+ <item row="1" column="0" colspan="3">
<widget class="QLabel" name="opacityLabel">
<property name="text">
- <string>Opacity :</string>
+ <string>Global Opacity :</string>
</property>
</widget>
</item>
- <item row="1" column="2" colspan="3">
+ <item row="1" column="3" colspan="3">
<widget class="QSlider" name="opacityHorizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="2" column="0" colspan="3">
+ <widget class="QLabel" name="thresOpacityLabel">
+ <property name="toolTip">
+ <string>All colors below the threshold will be made transparent.</string>
+ </property>
+ <property name="statusTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string/>
+ </property>
+ <property name="text">
+ <string>Transparency Threshold :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3" colspan="3">
+ <widget class="QSlider" name="thresOpacityHorizontalSlider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</property>
</widget>
</item>
- <item row="2" column="2" colspan="2">
+ <item row="3" column="2" colspan="2">
<widget class="QComboBox" name="fusionColorMapComboBox">
<property name="currentIndex">
- <number>3</number>
+ <number>0</number>
</property>
<item>
<property name="text">
<string>Cold</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Dosimetry</string>
+ </property>
+ </item>
<item>
<property name="text">
<string>Full Color Range</string>
</item>
</widget>
</item>
- <item row="3" column="0" colspan="2">
+ <item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Window :</string>
</property>
</widget>
</item>
- <item row="3" column="2">
+ <item row="4" column="2" colspan="2">
<widget class="QDoubleSpinBox" name="windowSpinBox">
<property name="decimals">
<number>4</number>
</property>
</widget>
</item>
- <item row="3" column="3">
+ <item row="4" column="4">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Level :</string>
</property>
</widget>
</item>
- <item row="3" column="4">
+ <item row="4" column="5">
<widget class="QDoubleSpinBox" name="levelSpinBox">
<property name="decimals">
<number>4</number>
</property>
</widget>
</item>
- <item row="4" column="0" colspan="5">
+ <item row="5" column="0" colspan="3">
<widget class="QLabel" name="valueFusionnedLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString)));
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)));
+ connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double)),
+ this,SLOT(SetFusionProperty(int,int,int,double,double)));
connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows()));
playMode = 0;//pause
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->setData(1,Qt::UserRole,tr("image"));
item->setToolTip(COLUMN_IMAGE_NAME, imageManager->GetListOfAbsoluteFilePathInOneString("image").c_str());
qApp->processEvents();
if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(),
+ mSlicerManagers[index]->GetFusionThresholdOpacity(),
mSlicerManagers[index]->GetFusionColorMap(),
mSlicerManagers[index]->GetFusionWindow(),
mSlicerManagers[index]->GetFusionLevel());
} else {
overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str());
- overlayPanel->getFusionProperty(-1, -1,-1,-1);
+ overlayPanel->getFusionProperty(-1, -1, -1, -1, -1);
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvMainWindow::DisplayChanged(QTreeWidgetItem *clicked_item, int column)
+void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
{
- int index = GetSlicerIndexFromItem(clicked_item);
if ( column >= COLUMN_CLOSE_IMAGE || column <= 0)
return;
+
+ // Get parent information (might be the same item)
+ int slicerManagerIndex = GetSlicerIndexFromItem(clickedItem);
+ QTreeWidgetItem* clickedParentItem = DataTree->topLevelItem(slicerManagerIndex);
+ vvSlicer* clickedSlicer = mSlicerManagers[slicerManagerIndex]->GetSlicer(column-1);
+
+ // Go over the complete item tree (only 2 levels, parents and children)
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) {
- vvSlicer* clicked_slicer=mSlicerManagers[i]->GetSlicer(column-1);
- if (current_row == clicked_item) {
- //If we just activated a slicer
- if (current_row->data(column,Qt::CheckStateRole).toInt() > 0) {
- mSlicerManagers[i]->UpdateSlicer(column-1,clicked_item->data(column,Qt::CheckStateRole).toInt());
- mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
- DisplaySliders(i,column-1);
- std::map<std::string,int> overlay_counts;
- for (int child = 0; child < current_row->childCount(); child++) {
- std::string overlay_type =
- current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
- overlay_counts[overlay_type]++;
- current_row->child(child)->setData(column,Qt::CheckStateRole,
- current_row->data(column,Qt::CheckStateRole));
- clicked_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,true);
- }
- } else { //We don't allow simply desactivating a slicer
- clicked_item->setData(column,Qt::CheckStateRole,2);
- DisplayChanged(clicked_item, column);
- return;
- }
+ // Trick to avoid redoing twice the job for a key (sr)
+ mSlicerManagers[i]->GetSlicer(column-1)->GetRenderWindow()->GetInteractor()->SetKeySym("Crap");
+
+ QTreeWidgetItem* currentParentItem = DataTree->topLevelItem(i);
+ if(currentParentItem != clickedParentItem) {
+ // Not the branch of the clicked item, uncheck all
+
+ // Parent
+ currentParentItem->setData(column,Qt::CheckStateRole, 0);
+ mSlicerManagers[i]->UpdateSlicer(column-1, false);
+
+ // Children
+ for (int iChild = 0; iChild < currentParentItem->childCount(); iChild++) {
+ currentParentItem->child(iChild)->setData(column,Qt::CheckStateRole, 0);
}
- //if we clicked on the vector(or overlay) and not the image
- else {
- if (clicked_item->data(column,Qt::CheckStateRole).toInt()) {
- current_row->setData(column,Qt::CheckStateRole,2);
- mSlicerManagers[i]->UpdateSlicer(column-1,2);
- mSlicerManagers[i]->UpdateInfoOnCursorPosition(column-1);
- DisplaySliders(i,column-1);
- }
- int vis = clicked_item->data(column,Qt::CheckStateRole).toInt();
- std::string overlay_type = clicked_item->data(1,Qt::UserRole).toString().toStdString();
- int overlay_index=0;
- for (int child = 0; child < current_row->childCount(); child++) {
- if (current_row->child(child)->data(1,Qt::UserRole).toString().toStdString() == overlay_type)
- overlay_index++;
- if (current_row->child(child) == clicked_item) break;
- }
- clicked_slicer->SetActorVisibility(
- clicked_item->data(1,Qt::UserRole).toString().toStdString(), overlay_index-1,vis);
+ }
+ else {
+ // Branch of the clicked one: get check status from actor visibility in slicer
+ // and toggle the clicked one
+
+ // Parent
+ bool vis = clickedSlicer->GetActorVisibility("image", 0);
+ bool draw = clickedSlicer->GetRenderer()->GetDraw();
+
+ // Update slicer (after getting visibility)
+ mSlicerManagers[slicerManagerIndex]->UpdateSlicer(column-1, true);
+ mSlicerManagers[slicerManagerIndex]->UpdateInfoOnCursorPosition(column-1);
+ DisplaySliders(slicerManagerIndex, column-1);
+ if(clickedParentItem == clickedItem) {
+ // Toggle
+ vis = !draw || !vis;
}
- } else if (current_row->data(column,Qt::CheckStateRole).toInt() > 0) {
- current_row->setData(column,Qt::CheckStateRole,0);
- mSlicerManagers[i]->UpdateSlicer(column-1,0);
- std::map<std::string,int> overlay_counts;
- for (int child = 0; child < current_row->childCount(); child++) {
- std::string overlay_type =
- current_row->child(child)->data(1,Qt::UserRole).toString().toStdString();
- overlay_counts[overlay_type]++;
- current_row->child(child)->setData(column,Qt::CheckStateRole,0);
- vvSlicer * current_slicer=mSlicerManagers[i]->GetSlicer(column-1);
- current_slicer->SetActorVisibility(overlay_type,overlay_counts[overlay_type]-1,false);
+ clickedSlicer->SetActorVisibility("image", 0, vis);
+ clickedParentItem->setData(column, Qt::CheckStateRole, vis?2:0);
+
+ // Children
+ std::map<std::string, int> actorTypeCounts;
+ for (int iChild = 0; iChild < clickedParentItem->childCount(); iChild++) {
+ QTreeWidgetItem* currentChildItem = clickedParentItem->child(iChild);
+ std::string actorType = currentChildItem->data(1,Qt::UserRole).toString().toStdString();
+ vis = clickedSlicer->GetActorVisibility(actorType, actorTypeCounts[actorType]);
+ if(currentChildItem == clickedItem) {
+ // Toggle or force visibility if it was not on this branch so far
+ vis = !draw || !vis;
+ clickedSlicer->SetActorVisibility(actorType, actorTypeCounts[actorType], vis);
+ }
+ currentChildItem->setData(column, Qt::CheckStateRole, vis?2:0);
+ actorTypeCounts[actorType]++;
}
}
- //mSlicerManagers[i]->SetColorMap(-1);
- mSlicerManagers[i]->SetColorMap();
}
- mSlicerManagers[index]->GetSlicer(column-1)->Render();
+
+ clickedSlicer->Render();
}
//------------------------------------------------------------------------------
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
- mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("overlay",0,
- DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
}
//Create the buttons for reload and close
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
- mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("fusion",0,
- DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
}
//Create the buttons for reload and close
for (int j = 1; j <= 4; j++) {
item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
- mSlicerManagers[index]->GetSlicer(j-1)->SetActorVisibility("vector",0,
- DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole).toInt());
}
//Create the buttons for reload and close
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvMainWindow::SetFusionProperty(int opacity, int colormap,double window, double level)
+void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level)
{
int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
mSlicerManagers[index]->SetFusionOpacity(opacity);
+ mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity);
mSlicerManagers[index]->SetFusionColorMap(colormap);
mSlicerManagers[index]->SetFusionWindow(window);
mSlicerManagers[index]->SetFusionLevel(level);
//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(1,Qt::UserRole,tr("image"));
item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,slicer_manager->GetFileName().c_str());//filename.c_str());
qApp->processEvents();
void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
void SetOverlayProperty(int color);
- void SetFusionProperty(int opacity,int colormap,double window,double level);
+ void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level);
void GoToCursor();
void PlayPause();
connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest()));
connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty()));
connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
+ connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty()));
connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty()));
connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty()));
dataFusionnedLabel->setText(filename.toStdString().c_str());
}
-void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level)
+void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level)
{
if (opacity > -1) {
fusionFrame->show();
fusionFrame->setEnabled(1);
opacityHorizontalSlider->setEnabled(1);
opacityHorizontalSlider->setValue(opacity);
+ thresOpacityHorizontalSlider->setEnabled(1);
+ thresOpacityHorizontalSlider->setValue(thresOpacity);
fusionColorMapComboBox->setEnabled(1);
fusionColorMapComboBox->setCurrentIndex(colormap);
windowSpinBox->setEnabled(1);
fusionFrame->setEnabled(0);
opacityHorizontalSlider->setEnabled(0);
opacityHorizontalSlider->setValue(0);
+ thresOpacityHorizontalSlider->setEnabled(0);
+ thresOpacityHorizontalSlider->setValue(0);
fusionColorMapComboBox->setEnabled(0);
fusionColorMapComboBox->setCurrentIndex(-1);
windowSpinBox->setEnabled(0);
void vvOverlayPanel::setFusionProperty()
{
- emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
+ emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
windowSpinBox->value(), levelSpinBox->value());
}
void getOverlayProperty(int color);
void getOverlayName(QString name);
- void getFusionProperty(int opacity, int colormap, double window, double level);
+ void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level);
void getFusionName(QString name);
void getCurrentVectorInfo(int visibility, double x, double y, double z, double value);
signals:
void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b);
void OverlayPropertyUpdated(int color);
- void FusionPropertyUpdated(int opacity, int colormap, double window, double level);
+ void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level);
}; // end class vvOverlayPanel
//====================================================================
//------------------------------------------------------------------------------
-vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper()
+vtkImageMapToColors* vvSlicer::GetFusionMapper()
{
return mFusionMapper.GetPointer();
}
mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
mOverlayActor->SetInput(mOverlayMapper->GetOutput());
mOverlayActor->SetPickable(0);
- mOverlayActor->SetVisibility(false);
+ mOverlayActor->SetVisibility(true);
mOverlayActor->SetOpacity(0.5);
}
mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
if (!mFusionMapper)
- mFusionMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
+ mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
+
+ vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
+ lut->SetRange(0, 1);
+ lut->SetValueRange(0, 1);
+ lut->SetSaturationRange(0, 0);
+ lut->Build();
+ mFusionMapper->SetLookupTable(lut);
mFusionMapper->SetInput(mFusionReslice->GetOutput());
if (!mFusionActor) {
mFusionActor = vtkSmartPointer<vtkImageActor>::New();
mFusionActor->SetInput(mFusionMapper->GetOutput());
mFusionActor->SetPickable(0);
- mFusionActor->SetVisibility(false);
+ mFusionActor->SetVisibility(true);
mFusionActor->SetOpacity(0.7);
this->GetRenderer()->AddActor(mFusionActor);
}
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
+{
+ bool vis = false;
+ if (actor_type == "image") {
+ vis = this->ImageActor->GetVisibility();
+ }
+ else if (actor_type == "vector") {
+ vis = this->mVFActor->GetVisibility();
+ }
+ else if (actor_type == "overlay") {
+ vis = this->mOverlayActor->GetVisibility();
+ }
+ else if (actor_type == "fusion") {
+ vis = this->mFusionActor->GetVisibility();
+ }
+ else if (actor_type == "contour")
+ vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
+
+ return vis;
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
{
- if (actor_type == "vector") {
+ if (actor_type == "image") {
+ this->ImageActor->SetVisibility(vis);
+ }
+ else if (actor_type == "vector") {
this->mVFActor->SetVisibility(vis);
}
- if (actor_type == "overlay") {
+ else if (actor_type == "overlay") {
this->mOverlayActor->SetVisibility(vis);
}
- if (actor_type == "fusion") {
+ else if (actor_type == "fusion") {
this->mFusionActor->SetVisibility(vis);
}
- if (actor_type == "contour")
+ else if (actor_type == "contour")
this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
UpdateDisplayExtent();
}
//------------------------------------------------------------------------------
-
//------------------------------------------------------------------------------
void vvSlicer::SetVF(vvImage::Pointer vf)
{
//----------------------------------------------------------------------------
void vvSlicer::SetDisplayMode(bool i)
{
- this->GetImageActor()->SetVisibility(i);
- this->GetAnnotation()->SetVisibility(i);
this->GetRenderer()->SetDraw(i);
- if (mLandActor)
- mLandActor->SetVisibility(i);
- pdmA->SetVisibility(i);
if (i)
UpdateDisplayExtent();
}
int ix, iy, iz;
double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
- worldPos << "data value : " << value << std::endl;
+ if(ImageActor->GetVisibility())
+ worldPos << "data value : " << value << std::endl;
+
worldPos << "mm : " << lrint(mCurrent[0]) << ' '
<< lrint(mCurrent[1]) << ' '
<< lrint(mCurrent[2]) << ' '
//----------------------------------------------------------------------------
void vvSlicer::UpdateCursorPosition()
{
- if (this->GetImageActor()->GetVisibility()) {
- pdmA->SetVisibility(true);
- mCursor[0] = mCurrent[0];
- mCursor[1] = mCurrent[1];
- mCursor[2] = mCurrent[2];
- mCursor[3] = mCurrentTSlice;
- }
+ pdmA->SetVisibility(true);
+ mCursor[0] = mCurrent[0];
+ mCursor[1] = mCurrent[1];
+ mCursor[2] = mCurrent[2];
+ mCursor[3] = mCurrentTSlice;
}
//----------------------------------------------------------------------------
#include <vtkSmartPointer.h>
#include <vtkImageViewer2.h>
#include <vtkImageReslice.h>
+#include <vtkImageMapToColors.h>
class vtkActor;
class vtkActor2D;
}
vtkImageMapToWindowLevelColors* GetOverlayMapper();
vvBlendImageActor* GetOverlayActor() ;
- vtkImageMapToWindowLevelColors* GetFusionMapper() ;
+ vtkImageMapToColors* GetFusionMapper() ;
vtkImageActor* GetFusionActor() ;
vtkActor* GetVFActor() ;
vtkCornerAnnotation* GetAnnotation();
return mFusion;
}
- /**Set an actor's visibility ("overlay, fusion, vf, contour...")
+ /**Get/Set an actor's visibility ("overlay, fusion, vf, contour...")
Overlay index is the index of the overlay by type, eg. if there are
5 contours and we want to activate the 3rd one, pass 2 **/
+ bool GetActorVisibility(const std::string& actor_type, int overlay_index);
void SetActorVisibility(const std::string& actor_type, int overlay_index,bool vis);
void RemoveActor(const std::string& actor_type, int overlay_index);
vtkSmartPointer<vtkImageMapToWindowLevelColors> mOverlayMapper;
vtkSmartPointer<vvBlendImageActor> mOverlayActor;
vtkSmartPointer<vtkImageReslice> mFusionReslice;
- vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
+ vtkSmartPointer<vtkImageMapToColors> mFusionMapper;
vtkSmartPointer<vtkImageActor> mFusionActor;
vtkSmartPointer<vtkCornerAnnotation> ca;
vtkSmartPointer<vtkCursor2D> crossCursor;
mOverlayColor = 130;
mFusionOpacity = 70;
+ mFusionThresOpacity = 1;
mFusionColorMap = 3;
mFusionWindow = 1000;
mFusionLevel = 1000;
double *fusRange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
mFusionLevel = (fusRange[0]+fusRange[1])/2;
mFusionWindow = fusRange[1]-fusRange[0];
+
return true;
}
//----------------------------------------------------------------------------
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
if (slice != mSlicers[i]->GetTSlice()) {
mSlicers[i]->SetTSlice(slice);
- if (mSlicers[i]->GetImageActor()->GetVisibility())
UpdateTSlice(i);
}
}
if (mSlicers[slicer]->GetTSlice() == tslice) return;
mSlicers[slicer]->SetTSlice(tslice);
- if (mSlicers[slicer]->GetImageActor()->GetVisibility())
- UpdateTSlice(slicer);
+ UpdateTSlice(slicer);
}
//----------------------------------------------------------------------------
mSlicers[slicer]->Render();
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
- if (i != (unsigned int)slicer && mSlicers[i]->GetImageActor()->GetVisibility()
+ if (i != (unsigned int)slicer
+ && mSlicers[i]->GetRenderer()->GetDraw()
&& mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
&& mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
mSlicers[i]->SetCurrentPosition(mSlicers[slicer]->GetCurrentPosition()[0],
Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
- if (mSlicers[slicer]->GetVFActor() && mSlicers[slicer]->GetVFActor()->GetVisibility()) {
+ if (mSlicers[slicer]->GetVFActor() ) {
displayVec = 1;
unsigned int currentTime = mSlicers[slicer]->GetTSlice();
vtkImageData *vf = NULL;
valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);
}
}
- if (mSlicers[slicer]->GetOverlayActor() && mSlicers[slicer]->GetOverlayActor()->GetVisibility()) {
+ if (mSlicers[slicer]->GetOverlayActor() ) {
displayOver = 1;
vtkImageData *overlay = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput());
double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0];
double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];
valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);
}
- if (mSlicers[slicer]->GetFusionActor() && mSlicers[slicer]->GetFusionActor()->GetVisibility()) {
+ if (mSlicers[slicer]->GetFusionActor() ) {
displayFus = 1;
vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());
double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];
emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);
emit UpdateOverlay(displayOver,valueOver,value);
emit UpdateFusion(displayFus,valueFus);
- for (unsigned int i = 0; i < mSlicers.size(); i++) {
- if (mSlicers[i]->GetImageActor()->GetVisibility() == 1)
- emit UpdateWindows(i,mSlicers[i]->GetSliceOrientation(),mSlicers[i]->GetSlice());
- else
- emit UpdateWindows(i,-1,-1);
- }
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-void vvSlicerManager::SetColorMap()
-{
- SetColorMap(mColorMap);
-}
-//----------------------------------------------------------------------------
-
-
//----------------------------------------------------------------------------
void vvSlicerManager::SetColorMap(int colormap)
{
LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
LUT->Build();
}
- vtkLookupTable* fusLUT = NULL;
- if (mSlicers[0]->GetFusion()) {
- fusLUT = vtkLookupTable::New();
+ vtkWindowLevelLookupTable* fusLUT = NULL;
+ if (mSlicers[0]->GetFusion()) { // && mFusionColorMap != 0) {
+ fusLUT = vtkWindowLevelLookupTable::New();
double fusRange [2];
fusRange[0] = mFusionLevel - mFusionWindow/2;
fusRange[1] = mFusionLevel + mFusionWindow/2;
- fusLUT->SetTableRange(fusRange[0],fusRange[1]);
+ double* frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
+ fusLUT->SetTableRange(frange);
fusLUT->SetValueRange(1,1);
fusLUT->SetSaturationRange(1,1);
+ fusLUT->SetAlphaRange(1, 1);
+ fusLUT->SetWindow(mFusionWindow);
+ fusLUT->SetLevel(mFusionLevel);
if (mFusionColorMap == 1)
fusLUT->SetHueRange(0,0.18);
else if (mFusionColorMap == 2)
fusLUT->SetHueRange(0.4,0.80);
else if (mFusionColorMap == 3)
+ {
+ fusLUT->SetHueRange(0.666, 0);
+ fusLUT->SetValueRange(0.5, 1);
+ }
+ else if (mFusionColorMap == 4)
fusLUT->SetHueRange(0,1);
- fusLUT->Build();
- if (mFusionColorMap == 0)
- fusLUT = NULL;
+ else if (mFusionColorMap == 0)
+ {
+ fusLUT->SetValueRange(0,1);
+ fusLUT->SetSaturationRange(0,0);
+ }
+
+ fusLUT->ForceBuild();
+
+ // set color table transparancy
+ double alpha_range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100;
+ for (double i = frange[0]; i < alpha_range_end; i++) {
+ double v[4];
+ vtkIdType index = fusLUT->GetIndex(i);
+ fusLUT->GetTableValue(index, v);
+ v[3] = 0;
+ fusLUT->SetTableValue(index, v);
+ }
}
for ( unsigned int i = 0; i < mSlicers.size(); i++) {
- if (mSlicers[i]->GetOverlay() && mSlicers[i]->GetOverlayActor()->GetVisibility()) {
+
+ if (mSlicers[i]->GetOverlay()) {
vtkLookupTable* supLUT = vtkLookupTable::New();
supLUT->SetTableRange(range[0],range[1]);
supLUT->SetValueRange(1,1);
} else {
mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
}
- if (mSlicers[i]->GetFusion() && mSlicers[i]->GetFusionActor()->GetVisibility()) {
+
+ if (mSlicers[i]->GetFusion()) {
mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100);
mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT);
- mSlicers[i]->GetFusionMapper()->SetWindow(mFusionWindow);
- mSlicers[i]->GetFusionMapper()->SetLevel(mFusionLevel);
}
}
if (fusLUT)
void SetColorLevel(double s);
void SetLocalColorWindowing(const int slicer);
void SetOpacity(int i, double factor);
- void SetColorMap();
void SetColorMap(int colormap);
void SetPreset(int preset);
void SetOverlayColor(int color) {
void SetFusionOpacity(int opacity) {
mFusionOpacity = opacity;
}
+ void SetFusionThresholdOpacity(int thresOpacity) {
+ mFusionThresOpacity = thresOpacity;
+ }
void SetFusionColorMap(int colorMap) {
mFusionColorMap = colorMap;
}
int GetFusionOpacity() {
return mFusionOpacity;
}
+ int GetFusionThresholdOpacity() {
+ return mFusionThresOpacity;
+ }
int GetFusionColorMap() {
return mFusionColorMap;
}
int mOverlayColor;
int mFusionOpacity;
+ int mFusionThresOpacity;
int mFusionColorMap;
double mFusionWindow;
double mFusionLevel;
this->SM->UpdateLinked(VisibleInWindow);
return;
}
+ if (KeyPress == "o") {
+ this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(0,0,0,0);
+ this->SM->UpdateViews(1,VisibleInWindow);
+ this->SM->UpdateLinked(VisibleInWindow);
+ return;
+ }
if (KeyPress == "F5") {
this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
this->SM->GetSlicer(VisibleInWindow)->Render();
#include <QMenu>
//------------------------------------------------------------------------------
-vvToolCreatorBase::vvToolCreatorBase(QString name): mExperimental(false), mAction(NULL)
+vvToolCreatorBase::vvToolCreatorBase(QString name): mAction(NULL), mExperimental(false)
{
mUseContextMenu = false;
mToolName = name;