[vtkusers] Questions on vtkLookupTable, SetIndexedLookup in connection with graph display

Frese Daniel Dr. frese at heidenhain.de
Fri Dec 7 05:23:24 EST 2012


Thanks a lot to all who responded. Some things have become much clearer now. As I wrote, I had some workarounds in place, which were similar to Alessandro's suggestion to modify the table dynamically, but this feels somewhat like a hack, especially if there is method available which seems to be designed to achieve exactly what I am looking for.

Therefore I'd really like to get David's example working. And it starts to get working - which one or two caveats remaining. The code as it is produces the expexted output now (vertices colored in red, blue and white), but after minor modifications, things look strange again.

If I define the colors as (which is unchanged from David's code)
  lookupTable->SetTableValue(0, 1.0, 0.0, 0.0); // red
  lookupTable->SetTableValue(1, 0.0, 0.0, 1.0); // blue
  lookupTable->SetTableValue(2, 1.0, 1.0, 1.0); // white
and the vertex coloring as
  vertexColors->InsertNextValue(0);
  vertexColors->InsertNextValue(1);
  vertexColors->InsertNextValue(1); // modification from original code, where we had vertexColors->InsertNextValue(2);

I would expect here three vertices; one colored in red and two colored in blue. In fact, the output gives one vertex colored red and two white ones... If I additionally comment the line lookupTable->SetTableRange(0,2); it gives me the expected behavior - although the docs on the web says, that this command should be ignored in case of IndexedLookup = true. That does not feel right, does it ?

Another similar thing is, that if I omit the line lookupTable->SetTableRange(0,2); with the same vertexColors array as in David's code (i.e. using colors 0, 1, 2 without the modification above), the third vertex is drawn in NaNColor again. Which again does not feel correct.

I'd really appreciate any further hints.

Daniel


-----Ursprüngliche Nachricht-----
Von: David Thompson [mailto:david.thompson at kitware.com] 
Gesendet: Donnerstag, 6. Dezember 2012 20:40
An: Frese Daniel Dr.
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] Questions on vtkLookupTable, SetIndexedLookup in connection with graph display

Hi Daniel,

> nobody knows what's going on ? Or is my question not clear enough ?
> Does anybody have any experience with line lookupTable->SetIndexedLookup() ? For my concrete application, I found work arounds for the most pressing issues, but still I'd really like to understand what's happening.

Sorry for the slow response. There are 3 changes you must make for the program below to work.

1. You must apply the view theme *after* creating representations. This is because the ApplyViewTheme() immediately visits each representation of the view and sets the lookup table; the representation must already be present for its theme to be changed.

2. You should not call Build() on the lookup table after manually setting table entries. vtkLookupTable::Build() overwrites the table entries with a linear ramp of colors.

3. In IndexedLookup mode, only annotated values are assigned colors from the lookup table; all other values are assigned the NaN color. So, in addition to calling lookupTable->SetTableValue(i, r, g, b), you must also

  for (int i = 0; i < 3; ++i)
    lookupTable->SetAnnotation(vtkVariant(i),"")

Note that the second argument annotation may be any string; if you create a vtkScalarBarActor to draw a legend for vertex colors, these strings will be displayed next to the color swatch in the legend. Attached is a modified version of the code that works for me.

	David


------------------------------------------------------------------------------------------------------
Registergericht: Traunstein / Registry Court: HRB 275 - Sitz / Head Office: Traunreut
Aufsichtsratsvorsitzender / Chairman of Supervisory Board: Rainer Burkhard
Geschäftsführung / Management Board: Thomas Sesselmann (Vorsitzender / Chairman),
Michael Grimm, Matthias Fauser, Sebastian Tondorf

E-Mail Haftungsausschluss / E-Mail Disclaimer 




More information about the vtkusers mailing list