[vtk-developers] Manual conversion of some Tcl to Python tests.

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Aug 31 14:37:58 EDT 2012


On Fri, Aug 31, 2012 at 12:39 PM, David Thompson
<david.thompson at kitware.com> wrote:
> Hi David,
>
>>> Yes, although it might be easier to have
>>>
>>>    void SetColor( std::string, double* rgba, int numRGBATuples = 1 );
>>>    double* GetColor( std::string, int swatch = 0 );
>>
>> But then you are making unwrappable methods.  It's possible to
>> have a wrapper hint that "double *rgba" is a 4-tuple, but it isn't
>> possible to hint that it is a "4*N-tuple".
>
> I agree SetColor would not be wrappable as-is.
>
>> If you want to support swatches, you should have a GetColorSwatch()
>> method, rather than complicate the GetColor() method.
>
> ... but why wouldn't GetColor() work? It would always return a pointer to a 4-tuple of doubles. Or do the wrappers prefer
>
>    void GetColor( double color[4], std::string name, int swatch = 0 );
>
> How about the following for SetColor()?
>
>    void InsertColor( std::string name, double* rgba, int swatch = 0 );
>    void InsertColor( std::string name, double r, double g, double b, double a=1., int swatch = 0 );
>    void RemoveColor( std::string name );
>    int  GetNumberOfSwatches( std::string name );
>
> That seems wrappable and the vector could just be increased in size to accommodate whatever swatch number was provided (hence the name change from SetXXX to InsertXXX).
>
The vtkColor4d is just a double[4] in memory, and an
std::vector<vtkColor4d> colors would be laid out as 4*N doubles. The
color classes can also convert between different representations and
you don't need to guess the size. I personally prefer the compactness
of the vtkColor4ub, and the representation is easy to send to GL (as
is the vtkColor4d but it does use more space).

I would love to see us move towards using actual types to represent
things like color, with accessors that can give the pointers for
older/C function calls.

My $0.02, there is another color table class in the charts modules
that lets us pass around color sequences for plot colors too.

Marcus



More information about the vtk-developers mailing list