[vtk-developers] Patch: Allowing a graph to be colored directly by an array

Will Schroeder will.schroeder at kitware.com
Tue Aug 31 08:09:57 EDT 2010


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);};


On Tue, Aug 31, 2010 at 7:55 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> Currently when you use a vtkGraphLayoutView you must use a look up table to
> color the points. I modified vtkApplyColors and
> vtkRenderedGraphRepresentation to allow a user to color graph vertices
> directly with a vtkUnsignedCharArray. Here is an example usage:
>
>   vtkSmartPointer<vtkUnsignedCharArray> vertexColors =
>     vtkSmartPointer<vtkUnsignedCharArray>::New();
>   vertexColors->SetNumberOfComponents(3);
>   vertexColors->SetName("PassVertexColors");
>
> // ... add colors ... ///
>
>   vtkSmartPointer<vtkRenderedGraphRepresentation> representation =
>     vtkSmartPointer<vtkRenderedGraphRepresentation>::New();
>   std::cout << representation->GetClassName() << std::endl;
>   representation->SetInputConnection(tree->GetProducerPort());
>   representation->ColorVerticesByArrayOn();
> *  representation->SetPassThroughPointColors(vertexColors);*
>
>   vtkSmartPointer<vtkGraphLayoutView> graphLayoutView =
>      vtkSmartPointer<vtkGraphLayoutView>::New();
>   graphLayoutView->AddRepresentation(representation);
>
> The branch is here:
>
> repo: git at github.com:daviddoria/daviddoria-vtk.git
> branch: VTK-GraphColors
>
> Please let me know what you think.
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>


-- 
William J. Schroeder, PhD
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
will.schroeder at kitware.com
http://www.kitware.com
(518) 881-4902
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100831/0b489880/attachment.html>


More information about the vtk-developers mailing list