Commit 94bcb4fd authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

BUG: Fixed BUG #5460. Adding virtual method to vtkScalarsToColors to get if the

subclass is using log mapping. Overridden by vtkPVLookupTable and vtkLookupTable
to repsond appropriately. ScalarBar uses the value returned by this method to
decide if it should show labels using log scale or not.
parent 503b679b
......@@ -213,6 +213,14 @@ public:
// Copy the contents from another LookupTable
void DeepCopy(vtkLookupTable *lut);
// Description:
// This should return 1 is the subclass is using log scale for mapping scalars
// to colors. Returns 1 is scale == VTK_SCALE_LOG10.
virtual int UsingLogScale()
{
return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
}
protected:
vtkLookupTable(int sze=256, int ext=256);
~vtkLookupTable();
......
......@@ -151,6 +151,11 @@ public:
virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
vtkUnsignedCharArray *colors, int numComp, int numTuples);
// Description:
// This should return 1 is the subclass is using log scale for mapping scalars
// to colors. Default implementation returns 0.
virtual int UsingLogScale()
{ return 0; }
protected:
vtkScalarsToColors();
~vtkScalarsToColors() {}
......
......@@ -32,7 +32,7 @@
#include "vtkRenderer.h"
#include "vtkProperty2D.h"
vtkCxxRevisionMacro(vtkScalarBarActor, "1.61");
vtkCxxRevisionMacro(vtkScalarBarActor, "1.62");
vtkStandardNewMacro(vtkScalarBarActor);
vtkCxxSetObjectMacro(vtkScalarBarActor,LookupTable,vtkScalarsToColors);
......@@ -322,22 +322,8 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
}
// Build scalar bar object; determine its type
//
// is this a vtkLookupTable or a subclass of vtkLookupTable
// with its scale set to log
// NOTE: it's possible we could to without the 'lut' variable
// later in the code, but if the vtkLookupTableSafeDownCast operation
// fails for some reason, this code will break in new ways. So, the 'LUT'
// variable is used for this operation only
vtkLookupTable *LUT = vtkLookupTable::SafeDownCast( this->LookupTable );
int isLogTable = 0;
if ( LUT )
{
if ( LUT->GetScale() == VTK_SCALE_LOG10 )
{
isLogTable = 1;
}
}
// i.e. has scale set to log
int isLogTable = this->LookupTable->UsingLogScale();
// we hard code how many steps to display
vtkScalarsToColors *lut = this->LookupTable;
......@@ -721,15 +707,7 @@ void vtkScalarBarActor::AllocateAndSizeLabels(int *labelSize,
// is this a vtkLookupTable or a subclass of vtkLookupTable
// with its scale set to log
vtkLookupTable *LUT = vtkLookupTable::SafeDownCast( this->LookupTable );
int isLogTable = 0;
if ( LUT )
{
if ( LUT->GetScale() == VTK_SCALE_LOG10 )
{
isLogTable = 1;
}
}
int isLogTable = this->LookupTable->UsingLogScale();
for (i=0; i < this->NumberOfLabels; i++)
{
......
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