[vtk-developers] Patch: Allowing a graph to be colored directly by an array
David Doria
daviddoria+vtk at gmail.com
Tue Aug 31 11:44:05 EDT 2010
On Tue, Aug 31, 2010 at 8:09 AM, Will Schroeder
<will.schroeder at kitware.com>wrote:
> David-
>
> Can you make it consistent with vtkMapper? vtkMapper has a color mode to
> determine how to treat unsigned char as follows:
>
> // Description:
> // Control how the scalar data is mapped to colors. By default
> // (ColorModeToDefault), unsigned char scalars are treated as colors, and
> // NOT mapped through the lookup table, while everything else is. Setting
> // ColorModeToMapScalars means that all scalar data will be mapped
> through
> // the lookup table. (Note that for multi-component scalars, the
> // particular component to use for mapping can be specified using the
> // SelectColorArray() method.)
> vtkSetMacro(ColorMode,int);
> vtkGetMacro(ColorMode,int);
> void SetColorModeToDefault()
> {this->SetColorMode(VTK_COLOR_MODE_DEFAULT);};
> void SetColorModeToMapScalars()
> {this->SetColorMode(VTK_COLOR_MODE_MAP_SCALARS);};
>
Thanks for the quick feedback!
I added SetColorModeToDefault and SetColorModeToMapScalars to both
vtkRenderedGraphRepresentation
and vtkGraphLayoutView. The procedure is now very easy:
// Add the color array to the graph
tree->GetVertexData()->SetScalars(vertexColors);
vtkSmartPointer<vtkGraphLayoutView> graphLayoutView =
vtkSmartPointer<vtkGraphLayoutView>::New();
graphLayoutView->AddRepresentationFromInput(tree);
graphLayoutView->SetLayoutStrategyToTree();
graphLayoutView->ColorVerticesOn();
graphLayoutView->SetColorModeToDefault(); // new functionality (color by
Scalars)
//graphLayoutView->SetColorModeToMapScalars(); //old functionality
graphLayoutView->ResetCamera();
graphLayoutView->Render();
graphLayoutView->GetInteractor()->Start();
repo: git at github.com:daviddoria/daviddoria-vtk.git
branch: VTK-GraphColors
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100831/c9f2ed16/attachment-0001.html>
More information about the vtk-developers
mailing list