Commit ed61792a authored by vrnova's avatar vrnova
Browse files

ENH: adding new feature (volume rendering appearance follows volumes module)

git-svn-id: http://svn.slicer.org/Slicer4/trunk@11560 3bd1e089-480b-0410-8dfb-8563597acbee
parent b7ab6ea5
......@@ -1106,8 +1106,12 @@ void vtkSlicerVolumeRenderingHelper::ProcessGUIEvents(vtkObject *caller,unsigned
this->SVP_VolumePropertyWidget->GetEditorFrame()->CollapseFrame();
this->FrameThresholding->CollapseFrame();
this->Gui->PauseRenderInteraction();
this->Gui->GetLogic()->UpdateVolumePropertyByDisplayNode(vspNode);
this->UpdateVolumeProperty();
this->Gui->ResumeRenderInteraction();
this->Gui->RequestRender();
}
else
......
......@@ -1573,3 +1573,21 @@ void vtkVolumeRenderingGUI::RequestRender()
}
}
}
void vtkVolumeRenderingGUI::PauseRenderInteraction()
{
vtkSlicerViewerWidget *slicer_viewer_widget = this->GetApplicationGUI()->GetActiveViewerWidget();
if (slicer_viewer_widget)
{
slicer_viewer_widget->GetMainViewer()->GetRenderWindowInteractor()->Disable();
}
}
void vtkVolumeRenderingGUI::ResumeRenderInteraction()
{
vtkSlicerViewerWidget *slicer_viewer_widget = this->GetApplicationGUI()->GetActiveViewerWidget();
if (slicer_viewer_widget)
{
slicer_viewer_widget->GetMainViewer()->GetRenderWindowInteractor()->Enable();
}
}
......@@ -106,6 +106,9 @@ public:
void RequestRender();
void PauseRenderInteraction();
void ResumeRenderInteraction();
// Description:
// Get/Set the main slicer viewer widget, for picking
vtkGetObjectMacro(ViewerWidget, vtkSlicerViewerWidget);
......
......@@ -377,7 +377,7 @@ void vtkVolumeRenderingLogic::UpdateFgVolumePropertyScalarRange(vtkMRMLVolumeRen
void vtkVolumeRenderingLogic::UpdateVolumePropertyByDisplayNode(vtkMRMLVolumeRenderingParametersNode* vspNode)
{
vtkMRMLScalarVolumeDisplayNode *vpNode = vtkMRMLScalarVolumeDisplayNode::SafeDownCast(vspNode->GetVolumeNode()->GetDisplayNode());
double windowLevel[2];
windowLevel[0] = vpNode->GetWindow();
windowLevel[1] = vpNode->GetLevel();
......@@ -405,11 +405,50 @@ void vtkVolumeRenderingLogic::UpdateVolumePropertyByDisplayNode(vtkMRMLVolumeRen
vtkColorTransferFunction *colorTransfer = prop->GetRGBTransferFunction();
colorTransfer->RemoveAllPoints();
colorTransfer->AddRGBPoint(range[0], 0.0, 0.0, 0.0);
colorTransfer->AddRGBPoint(windowLevel[1] - windowLevel[0]*0.5, 0.0, 0.0, 0.0);
colorTransfer->AddRGBPoint(windowLevel[1] + windowLevel[0]*0.5, 1.0, 1.0, 1.0);
colorTransfer->AddRGBPoint(range[1], 1.0, 1.0, 1.0);
vtkLookupTable* pLut = vpNode->GetColorNode()->GetLookupTable();
if (pLut == NULL)
{
colorTransfer->AddRGBPoint(range[0], 0.0, 0.0, 0.0);
colorTransfer->AddRGBPoint(windowLevel[1] - windowLevel[0]*0.5, 0.0, 0.0, 0.0);
colorTransfer->AddRGBPoint(windowLevel[1] + windowLevel[0]*0.5, 1.0, 1.0, 1.0);
colorTransfer->AddRGBPoint(range[1], 1.0, 1.0, 1.0);
}
else
{
int size = pLut->GetNumberOfTableValues();
double color[4];
pLut->GetTableValue(0, color);
if (size == 1)
{
colorTransfer->AddRGBPoint(range[0], color[0], color[1], color[2]);
colorTransfer->AddRGBPoint(windowLevel[1] - windowLevel[0]*0.5, color[0], color[1], color[2]);
colorTransfer->AddRGBPoint(windowLevel[1] + windowLevel[0]*0.5, color[0], color[1], color[2]);
colorTransfer->AddRGBPoint(range[1], color[0], color[1], color[2]);
}
else
{
colorTransfer->AddRGBPoint(range[0], color[0], color[1], color[2]);
double value = windowLevel[1] - windowLevel[0]*0.5;
double step;
step = windowLevel[0] / (size - 1);
for (int i = 0; i < size; i++, value += step)
{
pLut->GetTableValue(i, color);
colorTransfer->AddRGBPoint(value, color[0], color[1], color[2]);
}
pLut->GetTableValue(size - 1, color);
colorTransfer->AddRGBPoint(range[1], color[0], color[1], color[2]);
}
}
prop->ShadeOn();
prop->SetAmbient(0.30);
prop->SetDiffuse(0.60);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment