Commit a2d110aa authored by Julien Finet's avatar Julien Finet Committed by Marcus D. Hanwell

BUG: vtk[ColorTransferFunction LookupTable]Item didn't handle well opacity

The opacity is overwritten by MapScalarsThroughTable2
parent 036cbacc
......@@ -56,6 +56,7 @@ int TestMultipleScalarsToColors( int argc, char * argv [] )
// Lookup Table
vtkSmartPointer<vtkLookupTable> lookupTable =
vtkSmartPointer<vtkLookupTable>::New();
lookupTable->SetAlpha(0.5);
lookupTable->Build();
// Color transfer function
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
......@@ -107,7 +108,7 @@ int TestMultipleScalarsToColors( int argc, char * argv [] )
vtkSmartPointer<vtkColorTransferFunctionItem> item =
vtkSmartPointer<vtkColorTransferFunctionItem>::New();
item->SetColorTransferFunction(colorTransferFunction);
item->SetOpacity(0.9);
item->SetOpacity(0.8);
chart->AddPlot(item);
chart->SetTitle("vtkColorTransferFunction");
break;
......
......@@ -13,7 +13,6 @@
=========================================================================*/
#include "vtkChartXY.h"
#include "vtkPlot.h"
#include "vtkTable.h"
#include "vtkChartXY.h"
......
......@@ -98,18 +98,22 @@ void vtkColorTransferFunctionItem::ComputeTexture()
this->Texture->SetScalarTypeToUnsignedChar();
this->Texture->AllocateScalars();
unsigned char* ptr =
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0));
for (int i = 0; i < dimension; ++i)
{
values[i] = bounds[0] + i * (bounds[1] - bounds[0]) / (dimension - 1);
ptr[3] = static_cast<unsigned char>(this->Opacity * 255 + 0.5);
ptr+=4;
}
unsigned char* ptr =
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0));
this->ColorTransferFunction->MapScalarsThroughTable2(
values,
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0)),
VTK_DOUBLE,dimension,1,4);
values, ptr, VTK_DOUBLE, dimension, 1, 4);
if (this->Opacity != 1.0)
{
for (int i = 0; i < dimension; ++i)
{
ptr[3] = static_cast<unsigned char>(this->Opacity * ptr[3]);
ptr+=4;
}
}
delete [] values;
}
......
......@@ -95,18 +95,22 @@ void vtkLookupTableItem::ComputeTexture()
vtkWarningMacro(<< "The lookuptable seems empty");
return;
}
unsigned char* ptr =
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0));
for (int i = 0; i < dimension; ++i)
{
values[i] = bounds[0] + i * (bounds[1] - bounds[0]) / (dimension - 1);
ptr[3] = static_cast<unsigned char>(this->Opacity * 255 + 0.5);
ptr+=4;
}
unsigned char* ptr =
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0));
this->LookupTable->MapScalarsThroughTable2(
values,
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0)),
VTK_DOUBLE, dimension, 1, 4);
values, ptr, VTK_DOUBLE, dimension, 1, 4);
if (this->Opacity != 1.)
{
for (int i = 0; i < dimension; ++i)
{
ptr[3] = static_cast<unsigned char>(this->Opacity * ptr[3]);
ptr+=4;
}
}
}
//-----------------------------------------------------------------------------
......
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