Skip to content
Snippets Groups Projects
Commit 293e5386 authored by Andrew Maclean's avatar Andrew Maclean Committed by Dave DeMarle
Browse files

Make some color methods consistent.

In order to use functions like SetTableValue(2, "Blue") in a lookup table
  or other SetColors in derived classes in the same manner,
  these methods should be virtual.
This commit just makes the relevant Set methods virtual.
In the case of vtkProperty, the definition of SetColor(double a[3]) has
  been moved into vtkProperty.cxx, the rationale is that, in VTK classes,
  definitions occur in the implementation file not the header file.

Change-Id: I89fee8eb4902e0847114b068374c3bff0bf10b9d
parent 5e3c5393
Branches
Tags
No related merge requests found
......@@ -207,7 +207,7 @@ public:
// The name is treated as being case-insensitive.
// The range of each color is 0...255.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name,
virtual void SetColor(const vtkStdString & name,
const unsigned char & r, const unsigned char & g,
const unsigned char & b, const unsigned char & a = 255);
......@@ -216,7 +216,7 @@ public:
// The name is treated as being case-insensitive.
// The range of each color is 0...1.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name,
virtual void SetColor(const vtkStdString & name,
const double & r, const double & g,
const double & b, const double & a = 1);
......@@ -227,21 +227,21 @@ public:
// [red, green, blue, alpha]. The range of each element is 0...255.
// The user must ensure that the color array size is 4.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const unsigned char rgba[4]);
virtual void SetColor(const vtkStdString & name, const unsigned char rgba[4]);
// Description:
// Set the color by name.
// The name is treated as being case-insensitive.
// The color is a vtkColor4ub class.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const vtkColor4ub & rgba);
virtual void SetColor(const vtkStdString & name, const vtkColor4ub & rgba);
// Description:
// Set the color by name.
// The name is treated as being case-insensitive.
// The color is a vtkColor3ub class.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const vtkColor3ub & rgb);
virtual void SetColor(const vtkStdString & name, const vtkColor3ub & rgb);
// Description:
// Set the color by name.
......@@ -249,21 +249,21 @@ public:
// The color is a double array:
// [red, green, blue, alpha]. The range of each element is 0...1.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const double rgba[4]);
virtual void SetColor(const vtkStdString & name, const double rgba[4]);
// Description:
// Set the color by name.
// The name is treated as being case-insensitive.
// The color is a vtkColor4d class.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const vtkColor4d & rgba);
virtual void SetColor(const vtkStdString & name, const vtkColor4d & rgba);
// Description:
// Set the color by name.
// The name is treated as being case-insensitive.
// The color is a vtkColor3d class.
// No color is set if the name is empty.
void SetColor(const vtkStdString & name, const vtkColor3d & rgb);
virtual void SetColor(const vtkStdString & name, const vtkColor3d & rgb);
// Description:
// Remove the color by name.
......
/*=========================================================================
/*=========================================================================
Program: Visualization Toolkit
Module: vtkLookupTable.h
......@@ -188,12 +188,13 @@ public:
// component specification. Make sure that you've either used the
// Build() method or used SetNumberOfTableValues() prior to using this
// method.
void SetTableValue(vtkIdType indx, double rgba[4]);
virtual void SetTableValue(vtkIdType indx, double rgba[4]);
// Description:
// Directly load color into lookup table. Use [0,1] double values for color
// component specification.
void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
virtual void SetTableValue(vtkIdType indx,
double r, double g, double b, double a=1.0);
// Description:
// Return a rgba color value for the given index into the lookup table. Color
......@@ -278,7 +279,8 @@ public:
// Description:
// Return a color given an integer index.
//
// This is used to assign colors to annotations (given an offset into the list of annotations).
// This is used to assign colors to annotations (given an offset into the
// list of annotations).
// If the table is empty or \a idx < 0, then NanColor is returned.
virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
......
......@@ -278,6 +278,12 @@ void vtkProperty::SetColor(double r, double g, double b)
this->SetSpecularColor(this->Color);
}
//----------------------------------------------------------------------------
void vtkProperty::SetColor(double a[3])
{
this->SetColor(a[0], a[1], a[2]);
}
//----------------------------------------------------------------------------
void vtkProperty::ComputeCompositeColor(double result[3],
double ambient, const double ambient_color[3],
......
......@@ -126,9 +126,8 @@ public:
// Set the color of the object. Has the side effect of setting the
// ambient diffuse and specular colors as well. This is basically
// a quick overall color setting method.
void SetColor(double r, double g, double b);
void SetColor(double a[3])
{ this->SetColor(a[0], a[1], a[2]); }
virtual void SetColor(double r, double g, double b);
virtual void SetColor(double a[3]);
double *GetColor();
void GetColor(double rgb[3]);
void GetColor(double &r, double &g, double &b);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment