<div class="gmail_quote"><div> Hi Derek,</div><div> You might like to look at: <a href="http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo">http://www.vtk.org/Wiki/VTK/Examples/Python/CurvaturesDemo</a></div><div>
This shows you how to use a diverging colour space very nicely!</div><div>To choose other colour spaces and to extend this look at the C++ code referred to in the document <a href="http://www.cs.unm.edu/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf" target="_new" style="font-size:12px;line-height:18px;text-align:left;color:rgb(0,102,153);text-decoration:none;margin:0px;padding:0px;vertical-align:baseline;outline:none">http://www.cs.unm.edu/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf</a> by Kenneth Moreland, this is a very good article.</div>
<div><br></div><div>Regards</div><div> Andrew</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---------- Forwarded message ----------<br>
From: Derek Gaston <<a href="mailto:friedmud@gmail.com">friedmud@gmail.com</a>><br>To: <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>Cc: <br>Date: Sun, 1 Jul 2012 15:15:53 -0600<br>Subject: [vtkusers] Change Contour Colors<br>
Hello all.<div><br></div><div>I'm writing a bit of custom Python with Qt and VTK to add some visualization to a small PyQt GUI we have.</div><div><br></div><div>I need to read ExodusII and just do some simple contour plotting of what's in there with a color scale/legend (I also draw the edges so you can see the mesh). I have it basically working at this point (although hardcoded to a specific variable name... but I'll change that later). But I'm hung up at trying to change the colors of the contours.</div>
<div><br></div><div>All I want is very simple. Right now it generates from Red to Blue (low to high)... all I need is for it to go from Blue to Red (BTW - why the heck is Red to Blue the default... shouldn't Blue to Red be the default? I think most people associate Red with a high color... especially if you are plotting temperature... but that's beside the point).</div>
<div><br></div><div>I've looked at vtkLookupTable and vtkColorTransferFunction... but I can't seem to come up with the right magic. Basically, what I want is just the simple Blue to Red HSV color bar that you can get in Paraview by choosing that preset. Any help would be awesome!</div>
<div><br></div><div>Here is my current code (it's in a Python class that inherits from QWidget and uses a QVTKWidget2 that is initialized elsewhere):</div><div><br></div><div><br></div><div><div><br></div><div><div> self.file_name = file_name</div>
<div> reader = vtk.vtkExodusIIReader()</div><div> reader.SetFileName(self.file_name)</div><div> reader.UpdateInformation()</div><div> reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL, 1)</div><div> reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL_TEMPORAL, 1)</div>
<div> reader.SetTimeStep(1)</div><div> reader.Update()</div><div><br></div><div> cdp = vtk.vtkCompositeDataPipeline()</div><div> vtk.vtkAlgorithm.SetDefaultExecutivePrototype(cdp)</div><div><br></div><div> geom = vtk.vtkCompositeDataGeometryFilter()</div>
<div> geom.SetInputConnection(0,reader.GetOutputPort(0));</div><div> geom.Update()</div><div><br></div><div> data = geom.GetOutput()</div><div> data.GetPointData().SetScalars(data.GetPointData().GetArray("u"))</div>
<div> mapper = vtk.vtkPolyDataMapper()</div><div> mapper.SetInput(data)</div><div> mapper.ScalarVisibilityOn()</div><div> mapper.SetColorModeToMapScalars()</div><div> mapper.SetColorMode(2)</div><div> mapper.SetScalarRange(0,1.0)</div>
<div><br></div><div> actor = vtk.vtkActor()</div><div> actor.SetMapper(mapper)</div><div> self.renderer.AddActor(actor)</div><div><br></div><div> edge_geom = vtk.vtkCompositeDataGeometryFilter()</div><div> edge_geom.SetInputConnection(0,reader.GetOutputPort(0));</div>
<div> edge_geom.Update()</div><div><br></div><div> edges = vtk.vtkExtractEdges()</div><div> edges.SetInput(edge_geom.GetOutput())</div><div> edge_mapper = vtk.vtkPolyDataMapper()</div><div> edge_mapper.SetInput(edges.GetOutput())</div>
<div><br></div><div> edge_actor = vtk.vtkActor()</div><div> edge_actor.SetMapper(edge_mapper)</div><div> edge_actor.GetProperty().SetColor(0,0,0)</div><div><br></div><div> self.renderer.AddActor(edge_actor)</div>
<div><br></div><div> scalar_bar = vtk.vtkScalarBarActor()</div><div> scalar_bar.SetLookupTable(mapper.GetLookupTable())</div><div> scalar_bar.SetTitle("u")</div><div> scalar_bar.SetNumberOfLabels(4)</div>
<div><br></div><div> self.renderer.AddActor2D(scalar_bar)</div><div><br></div><div> # Avoid z-buffer fighting</div><div> vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset()</div><div><br></div>
<div>
<br></div><div> self.renderer.ResetCamera()</div><div> self.vtkwidget.updateGL()</div></div></div><div><br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br>___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________<br>