Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 71bfc13d authored by Cory Quammen's avatar Cory Quammen

Augment vtkTexture to color directly by more scalar types

Deprecated MapColorScalarsThroughLookupTable and setters/getters in
favor of new ColorMode that is analagous to the color mode in
vtkMapper, i.e., it adds a mode where additional scalar types such as
float and double can be used for direct coloring.
parent 83c511e4
......@@ -367,7 +367,7 @@ void vtkIVExporter::WriteAnActor(vtkActor *anActor, FILE *fp)
}
// make sure using unsigned char data of color scalars type
if (aTexture->GetMapColorScalarsThroughLookupTable () ||
if (aTexture->GetColorMode() == VTK_COLOR_MODE_MAP_SCALARS ||
(scalars->GetDataType() != VTK_UNSIGNED_CHAR) )
{
mappedScalars = aTexture->GetMappedScalars ();
......
......@@ -1233,7 +1233,7 @@ void vtkRIBExporter::WriteTexture (vtkTexture *aTexture)
}
// make sure using unsigned char data of color scalars type
if (aTexture->GetMapColorScalarsThroughLookupTable () ||
if (aTexture->GetColorMode() == VTK_COLOR_MODE_MAP_SCALARS ||
(scalars->GetDataType() != VTK_UNSIGNED_CHAR) )
{
mappedScalars = aTexture->GetMappedScalars ();
......
......@@ -588,7 +588,7 @@ void vtkVRMLExporter::WriteShapeBegin( vtkActor* actor, FILE *fileP,
}
// make sure using unsigned char data of color scalars type
if (aTexture->GetMapColorScalarsThroughLookupTable () ||
if (aTexture->GetColorMode() == VTK_COLOR_MODE_MAP_SCALARS ||
(scalars->GetDataType() != VTK_UNSIGNED_CHAR) )
{
mappedScalars = aTexture->GetMappedScalars ();
......
......@@ -820,7 +820,7 @@ void vtkX3DExporter::WriteATexture(vtkActor *anActor,
}
// make sure using unsigned char data of color scalars type
if (aTexture->GetMapColorScalarsThroughLookupTable () ||
if (aTexture->GetColorMode() == VTK_COLOR_MODE_MAP_SCALARS ||
(scalars->GetDataType() != VTK_UNSIGNED_CHAR) )
{
mappedScalars = aTexture->GetMappedScalars ();
......
......@@ -2752,7 +2752,7 @@ void vtkImagePlaneWidget::GenerateTexturePlane()
this->PlaneSource->GetOutputPort());
this->Texture->SetQualityTo32Bit();
this->Texture->MapColorScalarsThroughLookupTableOff();
this->Texture->SetColorMode(VTK_COLOR_MODE_DEFAULT);
this->Texture->SetInterpolate(this->TextureInterpolate);
this->Texture->RepeatOff();
this->Texture->SetLookupTable(this->LookupTable);
......
......@@ -107,7 +107,7 @@ vtkResliceCursorRepresentation::vtkResliceCursorRepresentation()
texturePlaneMapper->SetResolveCoincidentTopologyToPolygonOffset();
this->Texture->SetQualityTo32Bit();
this->Texture->MapColorScalarsThroughLookupTableOff();
this->Texture->SetColorMode(VTK_COLOR_MODE_DEFAULT);
this->Texture->SetInterpolate(1);
this->Texture->RepeatOff();
this->Texture->SetLookupTable(this->LookupTable);
......
......@@ -559,7 +559,7 @@ void vtkGraphMapper::Render(vtkRenderer *ren, vtkActor * vtkNotUsed(act))
this->IconActor->GetVisibility())
{
this->IconTransform->SetViewport(ren);
this->IconActor->GetTexture()->MapColorScalarsThroughLookupTableOff();
this->IconActor->GetTexture()->SetColorMode(VTK_COLOR_MODE_DEFAULT);
this->IconActor->GetTexture()->GetInputAlgorithm()->Update();
int *dim = this->IconActor->GetTexture()->GetInput()->GetDimensions();
this->IconGlyph->SetIconSheetSize(dim);
......
......@@ -46,7 +46,7 @@ vtkTexture::vtkTexture()
this->LookupTable = nullptr;
this->MappedScalars = nullptr;
this->MapColorScalarsThroughLookupTable = 0;
this->ColorMode = VTK_COLOR_MODE_DEFAULT;
this->Transform = nullptr;
this->SelfAdjustingTableRange = 0;
......@@ -82,6 +82,53 @@ vtkTexture::~vtkTexture()
}
}
#ifndef VTK_LEGACY_REMOVE
//----------------------------------------------------------------------------
void vtkTexture::SetMapColorScalarsThroughLookupTable(int val)
{
VTK_LEGACY_REPLACED_BODY(vtkTexture::SetMapColorScalarsThroughLookupTable, "VTK 8.1",
vtkTexture::SetColorMode);
int newMode = val ? VTK_COLOR_MODE_MAP_SCALARS : VTK_COLOR_MODE_DEFAULT;
if (newMode != this->ColorMode)
{
this->ColorMode = newMode;
this->Modified();
}
}
//----------------------------------------------------------------------------
int vtkTexture::GetMapColorScalarsThroughLookupTable()
{
VTK_LEGACY_REPLACED_BODY(vtkTexture::GetMapColorScalarsThroughLookupTable, "VTK 8.1",
vtkTexture::GetColorMode);
return (this->ColorMode == VTK_COLOR_MODE_MAP_SCALARS ? 1 : 0);
}
//----------------------------------------------------------------------------
void vtkTexture::MapColorScalarsThroughLookupTableOn()
{
VTK_LEGACY_REPLACED_BODY(vtkTexture::MapColorScalarsThroughLookupTableOn, "VTK 8.1",
vtkTexture::SetColorMode);
if (this->ColorMode != VTK_COLOR_MODE_MAP_SCALARS)
{
this->ColorMode = VTK_COLOR_MODE_MAP_SCALARS;
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkTexture::MapColorScalarsThroughLookupTableOff()
{
VTK_LEGACY_REPLACED_BODY(vtkTexture::MapColorScalarsThroughLookupTableOff, "VTK 8.1",
vtkTexture::SetColorMode);
if (this->ColorMode != VTK_COLOR_MODE_DEFAULT)
{
this->ColorMode = VTK_COLOR_MODE_DEFAULT;
this->Modified();
}
}
#endif
//----------------------------------------------------------------------------
vtkImageData *vtkTexture::GetInput()
{
......@@ -92,6 +139,7 @@ vtkImageData *vtkTexture::GetInput()
return vtkImageData::SafeDownCast(this->GetExecutive()->GetInputData(0, 0));
}
//----------------------------------------------------------------------------
void vtkTexture::SetCubeMap(bool val)
{
if (val == this->CubeMap)
......@@ -163,8 +211,22 @@ void vtkTexture::PrintSelf(ostream& os, vtkIndent indent)
os << "32Bit\n";
break;
}
os << indent << "MapColorScalarsThroughLookupTable: " <<
(this->MapColorScalarsThroughLookupTable ? "On\n" : "Off\n");
os << indent << "ColorMode: ";
switch (this->ColorMode)
{
case VTK_COLOR_MODE_DEFAULT:
os << "VTK_COLOR_MODE_DEFAULT";
break;
case VTK_COLOR_MODE_MAP_SCALARS:
os << "VTK_COLOR_MODE_MAP_SCALARS";
break;
case VTK_COLOR_MODE_DIRECT_SCALARS:
default:
os << "VTK_COLOR_MODE_DIRECT_SCALARS";
break;
}
os << "\n";
os << indent << "PremultipliedAlpha: " << (this->PremultipliedAlpha ? "On\n" : "Off\n");
if ( this->GetInput() )
......@@ -261,9 +323,7 @@ unsigned char *vtkTexture::MapScalarsToColors (vtkDataArray *scalars)
}
// map the scalars to colors
this->MappedScalars = this->LookupTable->MapScalars(scalars,
this->MapColorScalarsThroughLookupTable?
VTK_COLOR_MODE_MAP_SCALARS : VTK_COLOR_MODE_DEFAULT, -1);
this->MappedScalars = this->LookupTable->MapScalars(scalars, this->ColorMode, -1);
return this->MappedScalars? reinterpret_cast<unsigned char*>(
this->MappedScalars->GetVoidPointer(0)): nullptr;
......
......@@ -150,6 +150,7 @@ public:
{ this->SetQuality(VTK_TEXTURE_QUALITY_32BIT); }
//@}
#ifndef VTK_LEGACY_REMOVE
//@{
/**
* Turn on/off the mapping of color scalars through the lookup table.
......@@ -158,10 +159,36 @@ public:
* lookup table to generate 4-component unsigned char scalars.
* This ivar does not affect other scalars like unsigned short, float,
* etc. These scalars are always mapped through lookup tables.
*
* @deprecated Use SetColorMode, SetColorModeToDefault,
* SetColorModeToMapScalars, and SetColorModeToDirectScalars instead.
*/
vtkGetMacro(MapColorScalarsThroughLookupTable, int);
vtkSetMacro(MapColorScalarsThroughLookupTable, int);
vtkBooleanMacro(MapColorScalarsThroughLookupTable, int);
VTK_LEGACY(void SetMapColorScalarsThroughLookupTable(int val);)
VTK_LEGACY(int GetMapColorScalarsThroughLookupTable();)
VTK_LEGACY(void MapColorScalarsThroughLookupTableOn();)
VTK_LEGACY(void MapColorScalarsThroughLookupTableOff();)
//@}
#endif
//@{
/**
* Default: ColorModeToDefault. unsigned char scalars are treated
* as colors, and NOT mapped through the lookup table (set with SetLookupTable),
* while other kinds of scalars are. ColorModeToDirectScalar extends
* ColorModeToDefault such that all integer types are treated as
* colors with values in the range 0-255 and floating types are
* treated as colors with values in the range 0.0-1.0. Setting
* ColorModeToMapScalars means that all scalar data will be mapped
* through the lookup table.
*/
vtkSetMacro(ColorMode, int);
vtkGetMacro(ColorMode, int);
void SetColorModeToDefault()
{ this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
void SetColorModeToMapScalars()
{ this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS); }
void SetColorModeToDirectScalars()
{ this->SetColorMode(VTK_COLOR_MODE_DIRECT_SCALARS); }
//@}
/**
......@@ -298,7 +325,7 @@ protected:
int EdgeClamp;
int Interpolate;
int Quality;
int MapColorScalarsThroughLookupTable;
int ColorMode;
vtkScalarsToColors* LookupTable;
vtkUnsignedCharArray* MappedScalars;
vtkTransform * Transform;
......
......@@ -228,7 +228,7 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren)
int bytesPerPixel = scalars->GetNumberOfComponents();
// make sure using unsigned char data of color scalars type
if (this->MapColorScalarsThroughLookupTable ||
if (this->ColorMode == VTK_COLOR_MODE_MAP_SCALARS ||
scalars->GetDataType() != VTK_UNSIGNED_CHAR )
{
dataPtr = this->MapScalarsToColors (scalars);
......
......@@ -249,7 +249,7 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren)
// make sure using unsigned char data of color scalars type
if (this->IsDepthTexture != 1 &&
(this->MapColorScalarsThroughLookupTable ||
(this->ColorMode == VTK_COLOR_MODE_MAP_SCALARS ||
inscalars->GetDataType() != VTK_UNSIGNED_CHAR ))
{
dataPtr[i] = this->MapScalarsToColors (inscalars);
......
......@@ -1044,7 +1044,7 @@ void vtkRenderedGraphRepresentation::PrepareForRendering(vtkRenderView* view)
this->VertexIconGlyph->SetIconSize(view->GetIconSize());
this->VertexIconGlyph->SetDisplaySize(view->GetDisplaySize());
this->VertexIconGlyph->SetUseIconSize(false);
this->VertexIconActor->GetTexture()->MapColorScalarsThroughLookupTableOff();
this->VertexIconActor->GetTexture()->SetColorMode(VTK_COLOR_MODE_DEFAULT);
this->VertexIconActor->GetTexture()->GetInputAlgorithm()->Update();
int* dim = this->VertexIconActor->GetTexture()->GetInput()->GetDimensions();
this->VertexIconGlyph->SetIconSheetSize(dim);
......
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