From d72029773898da31c5c5ee9ac92aac0b649c5178 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 8 Sep 2015 12:17:03 -0700 Subject: [PATCH 1/9] improved pipeline gm is stored at init time (should we do the same for template?) pipeline now have a getcolormap() func that look for the colormap to use in this order: * graphic method has the colormap attribute * canvas has the colormap attribute set * otherwise use vcs.colormap fix #1271 --- Packages/vcs/Lib/Canvas.py | 2 +- Packages/vcs/Lib/VTKPlots.py | 14 +++++--- Packages/vcs/Lib/__init__.py | 2 ++ Packages/vcs/Lib/vcs2vtk.py | 37 +++++++++----------- Packages/vcs/Lib/vcsvtk/boxfillpipeline.py | 12 ++++--- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 11 +++--- Packages/vcs/Lib/vcsvtk/isolinepipeline.py | 12 +++---- Packages/vcs/Lib/vcsvtk/meshfillpipeline.py | 9 ++--- Packages/vcs/Lib/vcsvtk/pipeline.py | 16 ++++++++- Packages/vcs/Lib/vcsvtk/pipeline1d.py | 38 ++++++++++----------- Packages/vcs/Lib/vcsvtk/pipeline2d.py | 9 ++--- Packages/vcs/Lib/vcsvtk/pipelinefactory.py | 12 +++---- Packages/vcs/Lib/vcsvtk/vectorpipeline.py | 7 ++-- 13 files changed, 99 insertions(+), 82 deletions(-) diff --git a/Packages/vcs/Lib/Canvas.py b/Packages/vcs/Lib/Canvas.py index 7f066aec8e..a309e92758 100644 --- a/Packages/vcs/Lib/Canvas.py +++ b/Packages/vcs/Lib/Canvas.py @@ -865,7 +865,7 @@ def __init__(self, gui=0, mode=1, pause_time=0, self._canvas_id = vcs.next_canvas_id self.ParameterChanged = SIGNAL('ParameterChanged') vcs.next_canvas_id += 1 - self.colormap = "default" + self.colormap = None self.backgroundcolor = 255, 255, 255 # default size for bg self.bgX = 814 diff --git a/Packages/vcs/Lib/VTKPlots.py b/Packages/vcs/Lib/VTKPlots.py index bbae479515..38fb673265 100644 --- a/Packages/vcs/Lib/VTKPlots.py +++ b/Packages/vcs/Lib/VTKPlots.py @@ -461,7 +461,7 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): pipeline = vcsvtk.createPipeline(gm, self) if pipeline is not None: - returned.update(pipeline.plot(data1, data2, tpl, gm, + returned.update(pipeline.plot(data1, data2, tpl, vtk_backend_grid, vtk_backend_geo)) elif gtype in ["3d_scalar", "3d_dual_scalar", "3d_vector"]: cdms_file = kargs.get('cdmsfile', None) @@ -485,11 +485,13 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): returned["vtk_backend_text_actors"] = vcs2vtk.genTextActor( ren, to=to, - tt=tt) + tt=tt, + cmap = self.canvas.colormap) self.setLayer(ren, tt.priority) elif gtype == "line": if gm.priority != 0: - actors = vcs2vtk.prepLine(self.renWin, gm) + actors = vcs2vtk.prepLine(self.renWin, gm, + cmap = self.canvas.colormap) returned["vtk_backend_line_actors"] = actors for act, geo in actors: ren = self.fitToViewport( @@ -500,7 +502,8 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): priority=gm.priority) elif gtype == "marker": if gm.priority != 0: - actors = vcs2vtk.prepMarker(self.renWin, gm) + actors = vcs2vtk.prepMarker(self.renWin, gm, + cmap = self.canvas.colormap) returned["vtk_backend_marker_actors"] = actors for g, gs, pd, act, geo in actors: ren = self.fitToViewport( @@ -514,7 +517,8 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): elif gtype == "fillarea": if gm.priority != 0: - actors = vcs2vtk.prepFillarea(self.renWin, gm) + actors = vcs2vtk.prepFillarea(self.renWin, gm, + cmap = self.canvas.colormap) returned["vtk_backend_fillarea_actors"] = actors for act, geo in actors: ren = self.fitToViewport( diff --git a/Packages/vcs/Lib/__init__.py b/Packages/vcs/Lib/__init__.py index e269ad9b45..48e14cfb5a 100755 --- a/Packages/vcs/Lib/__init__.py +++ b/Packages/vcs/Lib/__init__.py @@ -36,6 +36,8 @@ import os from manageElements import * # noqa +colormap = "default" + _default_time_units = 'days since 2000' diff --git a/Packages/vcs/Lib/vcs2vtk.py b/Packages/vcs/Lib/vcs2vtk.py index c8ab92d1a9..c97860b0e5 100644 --- a/Packages/vcs/Lib/vcs2vtk.py +++ b/Packages/vcs/Lib/vcs2vtk.py @@ -897,11 +897,10 @@ def prepTextProperty(p, winSize, to="default", tt="default", cmap=None, if isinstance(tt, str): tt = vcs.elements["texttable"][tt] - if cmap is None: - if tt.colormap is not None: - cmap = tt.colormap - else: - cmap = 'default' + if tt.colormap is not None: + cmap = tt.colormap + elif cmap is None: + cmap = vcs.colormap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] colorIndex = overrideColorIndex if overrideColorIndex else tt.color @@ -1031,11 +1030,10 @@ def prepFillarea(renWin, farea, cmap=None): actors = [] # Find color map: - if cmap is None: - if farea.colormap is not None: - cmap = farea.colormap - else: - cmap = 'default' + if farea.colormap is not None: + cmap = farea.colormap + elif cmap is None: + cmap = vcs.colormap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] @@ -1288,11 +1286,10 @@ def prepGlyph(g, marker, index=0): def setMarkerColor(p, marker, c, cmap=None): # Color - if cmap is None: - if marker.colormap is not None: - cmap = marker.colormap - else: - cmap = 'default' + if marker.colormap is not None: + cmap = marker.colormap + elif cmap is None: + cmap = vcs.colormap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] color = cmap.index[c] @@ -1424,11 +1421,11 @@ def prepLine(renWin, line, cmap=None): p = a.GetProperty() p.SetLineWidth(w) - if cmap is None: - if line.colormap is not None: - cmap = line.colormap - else: - cmap = 'default' + if line.colormap is not None: + cmap = line.colormap + elif cmap is None: + cmap = vcs.colormap + if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] color = cmap.index[c] diff --git a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py index 25d301a8c1..7aa3197570 100644 --- a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py @@ -18,8 +18,8 @@ class BoxfillPipeline(Pipeline2D): set of ivars (at minimum, identify what the mappers are rendering). """ - def __init__(self, context_): - super(BoxfillPipeline, self).__init__(context_) + def __init__(self, gm, context_): + super(BoxfillPipeline, self).__init__(gm, context_) self._contourLabels = None self._mappers = None @@ -220,7 +220,7 @@ def _plotInternal(self): self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, self._contourLabels, - self._colorMap)) + self.getcolormap())) if self._context().canvas._continents is None: self._useContinents = False @@ -264,8 +264,9 @@ def _plotInternalBoxfill(self): lut = vtk.vtkLookupTable() lut.SetNumberOfTableValues(numLevels) + _colorMap = self.getcolormap() for i in range(numLevels): - r, g, b = self._colorMap.index[self._contourColors[i]] + r, g, b = _colorMap.index[self._contourColors[i]] lut.SetTableValue(i, r / 100., g / 100., b / 100.) mapper.SetLookupTable(lut) @@ -333,6 +334,7 @@ def _plotInternalCustomBoxfill(self): luts = [] geos = [] wholeDataMin, wholeDataMax = vcs.minmax(self._originalData1) + _colorMap = self.getcolormap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off @@ -350,7 +352,7 @@ def _plotInternalCustomBoxfill(self): geos.append(geoFilter2) mapper.SetInputConnection(geoFilter2.GetOutputPort()) lut.SetNumberOfTableValues(1) - r, g, b = self._colorMap.index[color] + r, g, b = _colorMap.index[color] lut.SetTableValue(0, r / 100., g / 100., b / 100.) mapper.SetLookupTable(lut) mapper.SetScalarRange(l[j], l[j + 1]) diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 0b361461d6..3610bdfdfc 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -11,8 +11,8 @@ class IsofillPipeline(Pipeline2D): """Implementation of the Pipeline interface for VCS isofill plots.""" - def __init__(self, context_): - super(IsofillPipeline, self).__init__(context_) + def __init__(self, gm, context_): + super(IsofillPipeline, self).__init__(gm, context_) def _updateVTKDataSet(self): """Overrides baseclass implementation.""" @@ -134,6 +134,7 @@ def _plotInternal(self): luts = [] cots = [] mappers = [] + _colorMap = self.getcolormap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off @@ -152,7 +153,7 @@ def _plotInternal(self): mapper.SetInputConnection(cot.GetOutputPort()) lut.SetNumberOfTableValues(len(tmpColors[i])) for j, color in enumerate(tmpColors[i]): - r, g, b = self._colorMap.index[color] + r, g, b = _colorMap.index[color] lut.SetTableValue(j, r / 100., g / 100., b / 100.) luts.append([lut, [0, len(l) - 1, True]]) mapper.SetLookupTable(lut) @@ -176,7 +177,7 @@ def _plotInternal(self): lut = vtk.vtkLookupTable() lut.SetNumberOfTableValues(numLevels) for i in range(numLevels): - r, g, b = self._colorMap.index[self._contourColors[i]] + r, g, b = _colorMap.index[self._contourColors[i]] lut.SetTableValue(i, r / 100., g / 100., b / 100.) mapper.SetLookupTable(lut) @@ -262,7 +263,7 @@ def _plotInternal(self): self._resultDict.update( self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, legend, - self._colorMap)) + self.getcolormap())) if self._context().canvas._continents is None: self._useContinents = False diff --git a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py index 68fb1e7a17..b2842dc873 100644 --- a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py @@ -10,8 +10,8 @@ class IsolinePipeline(Pipeline2D): """Implementation of the Pipeline interface for VCS isoline plots.""" - def __init__(self, context_): - super(IsolinePipeline, self).__init__(context_) + def __init__(self, gm, context_): + super(IsolinePipeline, self).__init__(gm, context_) def _updateVTKDataSet(self): """Overrides baseclass implementation.""" @@ -85,8 +85,7 @@ def _plotInternal(self): lut = vtk.vtkLookupTable() lut.SetNumberOfTableValues(len(self._contourColors)) - cmap = self._context().canvas.getcolormapname() - cmap = vcs.elements["colormap"][cmap] + cmap = self.getcolormap() for i, col in enumerate(self._contourColors): r, g, b = cmap.index[col] lut.SetTableValue(i, r / 100., g / 100., b / 100.) @@ -138,14 +137,15 @@ def _plotInternal(self): tprop = vtk.vtkTextProperty() vcs2vtk.prepTextProperty(tprop, self._context().renWin.GetSize(), - to, tt) + to, tt, cmap = cmap) tprops.AddItem(tprop) if colorOverride is not None: del(vcs.elements["texttable"][tt]) else: # No text properties specified. Use the default: tprop = vtk.vtkTextProperty() vcs2vtk.prepTextProperty(tprop, - self._context().renWin.GetSize()) + self._context().renWin.GetSize(), + cmap = cmap) tprops.AddItem(tprop) self._resultDict["vtk_backend_contours_labels_text_properties"] = \ tprops diff --git a/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py b/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py index 2b4831e3a3..3c978f9dec 100644 --- a/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py @@ -11,8 +11,8 @@ class MeshfillPipeline(Pipeline2D): """Implementation of the Pipeline interface for VCS meshfill plots.""" - def __init__(self, context_): - super(MeshfillPipeline, self).__init__(context_) + def __init__(self, gm, context_): + super(MeshfillPipeline, self).__init__(gm, context_) def _updateScalarData(self): """Overrides baseclass implementation.""" @@ -118,6 +118,7 @@ def _plotInternal(self): mappers = [] luts = [] geos = [] + _colorMap = self.getcolormap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off @@ -136,7 +137,7 @@ def _plotInternal(self): geos.append(geoFilter2) mapper.SetInputConnection(geoFilter2.GetOutputPort()) lut.SetNumberOfTableValues(1) - r, g, b = self._colorMap.index[color] + r, g, b = _colorMap.index[color] lut.SetTableValue(0, r / 100., g / 100., b / 100.) mapper.SetLookupTable(lut) mapper.SetScalarRange(l[j], l[j + 1]) @@ -288,7 +289,7 @@ def _plotInternal(self): self._resultDict.update( self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, legend, - self._colorMap)) + self.getcolormap())) if self._context().canvas._continents is None: self._useContinents = False diff --git a/Packages/vcs/Lib/vcsvtk/pipeline.py b/Packages/vcs/Lib/vcsvtk/pipeline.py index 08a4242dc0..2cba0cd8c3 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline.py @@ -9,15 +9,29 @@ class Pipeline(object): VTK plot command. Refer to the method documentation for details. """ - def __init__(self, context_): + def __init__(self, graphics_method, context_): """Initialize the pipeline object. + _gm is a vcs graphics method _context is a weakref of the VTKVCSBackend object that created this Pipeline. """ self._context = weakref.ref(context_) + self._gm = graphics_method # For now, we'll just throw everything at plot. This might need to be # broken up into set_data, set_template, etc methods... def plot(self, data1, data2, template, graphics_method, grid, transform): raise NotImplementedError("Missing override.") + + def getcolormap(self): + _colorMap = self._gm.colormap + if _colorMap is None: + _colorMap = \ + _colorMap = self._context().canvas.getcolormapname() + if _colorMap is None: + _colorMap = vcs.colormap + if isinstance(_colorMap,str): + _colorMap = vcs.elements["colormap"][_colorMap] + return _colorMap + diff --git a/Packages/vcs/Lib/vcsvtk/pipeline1d.py b/Packages/vcs/Lib/vcsvtk/pipeline1d.py index e2260c5ce4..10253f7746 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline1d.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline1d.py @@ -18,10 +18,10 @@ class Pipeline1D(Pipeline): """Implementation of the Pipeline interface for 1D VCS plots.""" - def __init__(self, context_): - super(Pipeline1D, self).__init__(context_) + def __init__(self, gm, context_): + super(Pipeline1D, self).__init__(gm, context_) - def plot(self, data1, data2, tmpl, gm, grid, transform): + def plot(self, data1, data2, tmpl, grid, transform): """Overrides baseclass implementation.""" Y = self._context().trimData1D(data1) if data2 is None: @@ -31,13 +31,13 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): data1._yname = data2.id Y = self._context().trimData1D(data2) - if gm.flip: + if self._gm.flip: tmp = Y Y = X X = tmp - if gm.smooth is not None: - Y = smooth(Y, gm.smooth) + if self._gm.smooth is not None: + Y = smooth(Y, self._gm.smooth) l = self._context().canvas.createline() Xs = X[:].tolist() @@ -64,17 +64,17 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): l._x = xs l._y = ys - l.color = gm.linecolor - if gm.linewidth > 0: - l.width = gm.linewidth + l.color = self._gm.linecolor + if self._gm.linewidth > 0: + l.width = self._gm.linewidth else: l.priority = 0 - l.type = gm.line + l.type = self._gm.line l._viewport = [tmpl.data.x1, tmpl.data.x2, tmpl.data.y1, tmpl.data.y2] # Also need to make sure it fills the whole space - x1, x2, y1, y2 = vcs.utils.getworldcoordinates(gm, X, Y) + x1, x2, y1, y2 = vcs.utils.getworldcoordinates(self._gm, X, Y) if numpy.allclose(y1, y2): y1 -= .0001 y2 += .0001 @@ -82,12 +82,12 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): x1 -= .0001 x2 += .0001 l._worldcoordinate = [x1, x2, y1, y2] - if gm.marker is not None: + if self._gm.marker is not None: m = self._context().canvas.createmarker() - m.type = gm.marker - m.color = gm.markercolor - if gm.markersize > 0: - m.size = gm.markersize + m.type = self._gm.marker + m.color = self._gm.markercolor + if self._gm.markersize > 0: + m.size = self._gm.markersize else: m.priority = 0 m._x = l.x @@ -99,17 +99,17 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): X[:].min() > max(x1, x2) or X[:].max() < min(x1, x2)): if l.priority > 0: self._context().canvas.plot(l, donotstoredisplay=True) - if gm.marker is not None and m.priority > 0: + if self._gm.marker is not None and m.priority > 0: self._context().canvas.plot(m, donotstoredisplay=True) ren2 = self._context().createRenderer() self._context().renWin.AddRenderer(ren2) - tmpl.plot(self._context().canvas, data1, gm, bg=self._context().bg, + tmpl.plot(self._context().canvas, data1, self._gm, bg=self._context().bg, renderer=ren2, X=X, Y=Y) if hasattr(data1, "_yname"): del(data1._yname) del(vcs.elements["line"][l.name]) - if gm.marker is not None: + if self._gm.marker is not None: del(vcs.elements["marker"][m.name]) if tmpl.legend.priority > 0: diff --git a/Packages/vcs/Lib/vcsvtk/pipeline2d.py b/Packages/vcs/Lib/vcsvtk/pipeline2d.py index 4d30d42bc8..d52792d53f 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline2d.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline2d.py @@ -115,22 +115,19 @@ class Pipeline2D(IPipeline2D): """Common VTK pipeline functionality for 2D VCS plot.""" - def __init__(self, context_): - super(Pipeline2D, self).__init__(context_) + def __init__(self, gm, context_): + super(Pipeline2D, self).__init__(gm, context_) - def plot(self, data1, data2, tmpl, gm, grid, transform): + def plot(self, data1, data2, tmpl, grid, transform): """Overrides baseclass implementation.""" # Clear old results: self._resultDict = {} - self._gm = gm self._template = tmpl self._originalData1 = data1 self._originalData2 = data2 self._vtkDataSet = grid self._vtkGeoTransform = transform - self._colorMap = \ - vcs.elements["colormap"][self._context().canvas.getcolormapname()] # Preprocess the input scalar data: self._updateScalarData() diff --git a/Packages/vcs/Lib/vcsvtk/pipelinefactory.py b/Packages/vcs/Lib/vcsvtk/pipelinefactory.py index 0efd773a88..b4939bb47c 100644 --- a/Packages/vcs/Lib/vcsvtk/pipelinefactory.py +++ b/Packages/vcs/Lib/vcsvtk/pipelinefactory.py @@ -11,21 +11,21 @@ def createPipeline(graphics_method, context): if graphics_method.g_name == "Gfb": from .boxfillpipeline import BoxfillPipeline - return BoxfillPipeline(context) + return BoxfillPipeline(graphics_method,context) elif graphics_method.g_name == "Gfi": from .isofillpipeline import IsofillPipeline - return IsofillPipeline(context) + return IsofillPipeline(graphics_method,context) elif graphics_method.g_name == "Gi": from .isolinepipeline import IsolinePipeline - return IsolinePipeline(context) + return IsolinePipeline(graphics_method,context) elif graphics_method.g_name == "Gfm": from .meshfillpipeline import MeshfillPipeline - return MeshfillPipeline(context) + return MeshfillPipeline(graphics_method,context) elif graphics_method.g_name == "G1d": from .pipeline1d import Pipeline1D - return Pipeline1D(context) + return Pipeline1D(graphics_method,context) elif graphics_method.g_name == "Gv": from .vectorpipeline import VectorPipeline - return VectorPipeline(context) + return VectorPipeline(graphics_method,context) return None diff --git a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py index 3b58fbf81d..040456a57d 100644 --- a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py @@ -9,8 +9,8 @@ class VectorPipeline(Pipeline): """Implementation of the Pipeline interface for VCS vector plots.""" - def __init__(self, context_): - super(VectorPipeline, self).__init__(context_) + def __init__(self, gm, context_): + super(VectorPipeline, self).__init__(gm, context_) def plot(self, data1, data2, tmpl, gm, grid, transform): """Overrides baseclass implementation.""" @@ -94,8 +94,7 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): act = vtk.vtkActor() act.SetMapper(mapper) - cmap = self._context().canvas.getcolormapname() - cmap = vcs.elements["colormap"][cmap] + cmap = self.getcolormap() r, g, b = cmap.index[lcolor] act.GetProperty().SetColor(r / 100., g / 100., b / 100.) From 45973a5165fc77a4a904d00f74056bc7c03905e2 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 8 Sep 2015 12:25:52 -0700 Subject: [PATCH 2/9] flake8ed --- Packages/vcs/Lib/VTKPlots.py | 8 ++++---- Packages/vcs/Lib/isoline.py | 3 ++- Packages/vcs/Lib/vcs2vtk.py | 2 +- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 3 ++- Packages/vcs/Lib/vcsvtk/isolinepipeline.py | 4 ++-- Packages/vcs/Lib/vcsvtk/pipeline.py | 12 ++++++------ Packages/vcs/Lib/vcsvtk/pipelinefactory.py | 12 ++++++------ Packages/vcs/Lib/vtk_ui/slider.py | 6 ++++-- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Packages/vcs/Lib/VTKPlots.py b/Packages/vcs/Lib/VTKPlots.py index 38fb673265..c4134edd24 100644 --- a/Packages/vcs/Lib/VTKPlots.py +++ b/Packages/vcs/Lib/VTKPlots.py @@ -486,12 +486,12 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): ren, to=to, tt=tt, - cmap = self.canvas.colormap) + cmap=self.canvas.colormap) self.setLayer(ren, tt.priority) elif gtype == "line": if gm.priority != 0: actors = vcs2vtk.prepLine(self.renWin, gm, - cmap = self.canvas.colormap) + cmap=self.canvas.colormap) returned["vtk_backend_line_actors"] = actors for act, geo in actors: ren = self.fitToViewport( @@ -503,7 +503,7 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): elif gtype == "marker": if gm.priority != 0: actors = vcs2vtk.prepMarker(self.renWin, gm, - cmap = self.canvas.colormap) + cmap=self.canvas.colormap) returned["vtk_backend_marker_actors"] = actors for g, gs, pd, act, geo in actors: ren = self.fitToViewport( @@ -518,7 +518,7 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): elif gtype == "fillarea": if gm.priority != 0: actors = vcs2vtk.prepFillarea(self.renWin, gm, - cmap = self.canvas.colormap) + cmap=self.canvas.colormap) returned["vtk_backend_fillarea_actors"] = actors for act, geo in actors: ren = self.fitToViewport( diff --git a/Packages/vcs/Lib/isoline.py b/Packages/vcs/Lib/isoline.py index 8a407173ea..1875be69fc 100755 --- a/Packages/vcs/Lib/isoline.py +++ b/Packages/vcs/Lib/isoline.py @@ -988,7 +988,8 @@ def script(self, script_filename, mode='a'): (unique_name, self.yaxisconvert)) # Unique attribute for isoline fp.write("%s.label = '%s'\n" % (unique_name, self.label)) - fp.write("%s.labelskipdistance = '%s'\n" % (unique_name, self.labelskipdistance)) + fp.write("%s.labelskipdistance = '%s'\n" % + (unique_name, self.labelskipdistance)) fp.write("%s.line = %s\n" % (unique_name, self.line)) fp.write("%s.linecolors = %s\n" % (unique_name, self.linecolors)) fp.write("%s.linewidths = %s\n" % (unique_name, self.linewidths)) diff --git a/Packages/vcs/Lib/vcs2vtk.py b/Packages/vcs/Lib/vcs2vtk.py index c97860b0e5..1227aaa693 100644 --- a/Packages/vcs/Lib/vcs2vtk.py +++ b/Packages/vcs/Lib/vcs2vtk.py @@ -1424,7 +1424,7 @@ def prepLine(renWin, line, cmap=None): if line.colormap is not None: cmap = line.colormap elif cmap is None: - cmap = vcs.colormap + cmap = vcs.colormap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 3610bdfdfc..2553cd0a06 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -244,7 +244,8 @@ def _plotInternal(self): if isinstance(self._contourLevels[0], list): if numpy.less(abs(self._contourLevels[0][0]), 1.e20): # Ok we need to add the ext levels - self._contourLevels.insert(0, [-1.e20, self._contourLevels[0][0]]) + self._contourLevels.insert( + 0, [-1.e20, self._contourLevels[0][0]]) else: if numpy.less(abs(self._contourLevels[0]), 1.e20): # need to add an ext diff --git a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py index b2842dc873..c9215ed404 100644 --- a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py @@ -137,7 +137,7 @@ def _plotInternal(self): tprop = vtk.vtkTextProperty() vcs2vtk.prepTextProperty(tprop, self._context().renWin.GetSize(), - to, tt, cmap = cmap) + to, tt, cmap=cmap) tprops.AddItem(tprop) if colorOverride is not None: del(vcs.elements["texttable"][tt]) @@ -145,7 +145,7 @@ def _plotInternal(self): tprop = vtk.vtkTextProperty() vcs2vtk.prepTextProperty(tprop, self._context().renWin.GetSize(), - cmap = cmap) + cmap=cmap) tprops.AddItem(tprop) self._resultDict["vtk_backend_contours_labels_text_properties"] = \ tprops diff --git a/Packages/vcs/Lib/vcsvtk/pipeline.py b/Packages/vcs/Lib/vcsvtk/pipeline.py index 2cba0cd8c3..454f55b6ca 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline.py @@ -1,4 +1,5 @@ import weakref +import vcs class Pipeline(object): @@ -27,11 +28,10 @@ def plot(self, data1, data2, template, graphics_method, grid, transform): def getcolormap(self): _colorMap = self._gm.colormap if _colorMap is None: - _colorMap = \ - _colorMap = self._context().canvas.getcolormapname() + _colorMap = \ + _colorMap = self._context().canvas.getcolormapname() if _colorMap is None: - _colorMap = vcs.colormap - if isinstance(_colorMap,str): - _colorMap = vcs.elements["colormap"][_colorMap] + _colorMap = vcs.colormap + if isinstance(_colorMap, str): + _colorMap = vcs.elements["colormap"][_colorMap] return _colorMap - diff --git a/Packages/vcs/Lib/vcsvtk/pipelinefactory.py b/Packages/vcs/Lib/vcsvtk/pipelinefactory.py index b4939bb47c..ff1238b85a 100644 --- a/Packages/vcs/Lib/vcsvtk/pipelinefactory.py +++ b/Packages/vcs/Lib/vcsvtk/pipelinefactory.py @@ -11,21 +11,21 @@ def createPipeline(graphics_method, context): if graphics_method.g_name == "Gfb": from .boxfillpipeline import BoxfillPipeline - return BoxfillPipeline(graphics_method,context) + return BoxfillPipeline(graphics_method, context) elif graphics_method.g_name == "Gfi": from .isofillpipeline import IsofillPipeline - return IsofillPipeline(graphics_method,context) + return IsofillPipeline(graphics_method, context) elif graphics_method.g_name == "Gi": from .isolinepipeline import IsolinePipeline - return IsolinePipeline(graphics_method,context) + return IsolinePipeline(graphics_method, context) elif graphics_method.g_name == "Gfm": from .meshfillpipeline import MeshfillPipeline - return MeshfillPipeline(graphics_method,context) + return MeshfillPipeline(graphics_method, context) elif graphics_method.g_name == "G1d": from .pipeline1d import Pipeline1D - return Pipeline1D(graphics_method,context) + return Pipeline1D(graphics_method, context) elif graphics_method.g_name == "Gv": from .vectorpipeline import VectorPipeline - return VectorPipeline(graphics_method,context) + return VectorPipeline(graphics_method, context) return None diff --git a/Packages/vcs/Lib/vtk_ui/slider.py b/Packages/vcs/Lib/vtk_ui/slider.py index 74f2ae7693..ba1ede008a 100644 --- a/Packages/vcs/Lib/vtk_ui/slider.py +++ b/Packages/vcs/Lib/vtk_ui/slider.py @@ -75,9 +75,11 @@ def set_value(self, value): # Make sure value is between min and max if f < minimum: - raise ValueError("Value for slider should be >= %f; received %f" % (minimum, f)) + raise ValueError( + "Value for slider should be >= %f; received %f" % (minimum, f)) if f > maximum: - raise ValueError("Value for slider should be <= %f; received %f" % (maximum, f)) + raise ValueError( + "Value for slider should be <= %f; received %f" % (maximum, f)) self.repr.SetValue(f) From 8a7157694eb1ee15f047d71f50b20f60003a4bd9 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 8 Sep 2015 13:42:47 -0700 Subject: [PATCH 3/9] vcs.colormap was already in used forgot one class where init needed to be updated --- Packages/vcs/Lib/__init__.py | 2 +- Packages/vcs/Lib/vcsvtk/pipeline.py | 2 +- Packages/vcs/Lib/vcsvtk/pipeline2d.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Packages/vcs/Lib/__init__.py b/Packages/vcs/Lib/__init__.py index 48e14cfb5a..5f09d7acc7 100755 --- a/Packages/vcs/Lib/__init__.py +++ b/Packages/vcs/Lib/__init__.py @@ -36,7 +36,7 @@ import os from manageElements import * # noqa -colormap = "default" +_colorMap = "default" _default_time_units = 'days since 2000' diff --git a/Packages/vcs/Lib/vcsvtk/pipeline.py b/Packages/vcs/Lib/vcsvtk/pipeline.py index 454f55b6ca..2bb8fb423d 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline.py @@ -31,7 +31,7 @@ def getcolormap(self): _colorMap = \ _colorMap = self._context().canvas.getcolormapname() if _colorMap is None: - _colorMap = vcs.colormap + _colorMap = vcs._colorMap if isinstance(_colorMap, str): _colorMap = vcs.elements["colormap"][_colorMap] return _colorMap diff --git a/Packages/vcs/Lib/vcsvtk/pipeline2d.py b/Packages/vcs/Lib/vcsvtk/pipeline2d.py index d52792d53f..0a98e184ea 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline2d.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline2d.py @@ -47,8 +47,8 @@ class IPipeline2D(Pipeline): - _maskedDataMapper: The mapper used to render masked data. """ - def __init__(self, context_): - super(IPipeline2D, self).__init__(context_) + def __init__(self, gm, context_): + super(IPipeline2D, self).__init__(gm, context_) # TODO This should be replaced by getters that retrieve the info # needed, or document the members of the map somewhere. Much of this @@ -57,7 +57,6 @@ def __init__(self, context_): # reexecute visualization operations. self._resultDict = None - self._gm = None self._template = None self._originalData1 = None self._originalData2 = None @@ -190,8 +189,9 @@ def _updateFromGenGridDict(self, genGridDict): def _createMaskedDataMapper(self): """Overrides baseclass implementation.""" color = getattr(self._gm, "missing", None) + _colorMap = self.getcolormap() if color is not None: - color = self._colorMap.index[color] + color = _colorMap.index[color] self._maskedDataMapper = vcs2vtk.putMaskOnVTKGrid( self._data1, self._vtkDataSet, color, self._useCellScalars, deep=False) From c6c242502ee12d8094dd6b136c09f278d7fab2b4 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 8 Sep 2015 15:03:32 -0700 Subject: [PATCH 4/9] primtive needed updated vcs._colorMap name vector pipeline was still expecting gm as argument to plot function --- Packages/vcs/Lib/vcs2vtk.py | 8 +++--- Packages/vcs/Lib/vcsvtk/vectorpipeline.py | 22 ++++++++-------- Packages/vcs/Lib/vector.py | 31 ++++++++++++++++++----- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/Packages/vcs/Lib/vcs2vtk.py b/Packages/vcs/Lib/vcs2vtk.py index 1227aaa693..c2625be03e 100644 --- a/Packages/vcs/Lib/vcs2vtk.py +++ b/Packages/vcs/Lib/vcs2vtk.py @@ -900,7 +900,7 @@ def prepTextProperty(p, winSize, to="default", tt="default", cmap=None, if tt.colormap is not None: cmap = tt.colormap elif cmap is None: - cmap = vcs.colormap + cmap = vcs._colorMap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] colorIndex = overrideColorIndex if overrideColorIndex else tt.color @@ -1033,7 +1033,7 @@ def prepFillarea(renWin, farea, cmap=None): if farea.colormap is not None: cmap = farea.colormap elif cmap is None: - cmap = vcs.colormap + cmap = vcs._colorMap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] @@ -1289,7 +1289,7 @@ def setMarkerColor(p, marker, c, cmap=None): if marker.colormap is not None: cmap = marker.colormap elif cmap is None: - cmap = vcs.colormap + cmap = vcs._colorMap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] color = cmap.index[c] @@ -1424,7 +1424,7 @@ def prepLine(renWin, line, cmap=None): if line.colormap is not None: cmap = line.colormap elif cmap is None: - cmap = vcs.colormap + cmap = vcs._colorMap if isinstance(cmap, str): cmap = vcs.elements["colormap"][cmap] diff --git a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py index 040456a57d..e7fc26cf98 100644 --- a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py @@ -12,7 +12,7 @@ class VectorPipeline(Pipeline): def __init__(self, gm, context_): super(VectorPipeline, self).__init__(gm, context_) - def plot(self, data1, data2, tmpl, gm, grid, transform): + def plot(self, data1, data2, tmpl, grid, transform): """Overrides baseclass implementation.""" # Preserve time and z axis for plotting these inof in rendertemplate geo = None # to make flake8 happy @@ -27,7 +27,7 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): data1 = self._context().trimData2D(data1) data2 = self._context().trimData2D(data2) - gridGenDict = vcs2vtk.genGridOnPoints(data1, gm, deep=False, grid=grid, + gridGenDict = vcs2vtk.genGridOnPoints(data1, self._gm, deep=False, grid=grid, geo=transform) for k in ['vtk_backend_grid', 'xm', 'xM', 'ym', 'yM', 'continents', 'wrap', 'geo']: @@ -49,7 +49,7 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): grid.GetPointData().AddArray(w) # Vector attempt - l = gm.line + l = self._gm.line if l is None: l = "default" try: @@ -61,10 +61,10 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): lstyle = "solid" # noqa lwidth = 1. # noqa lcolor = 0 - if gm.linewidth is not None: - lwidth = gm.linewidth # noqa - if gm.linecolor is not None: - lcolor = gm.linecolor + if self._gm.linewidth is not None: + lwidth = self._gm.linewidth # noqa + if self._gm.linecolor is not None: + lcolor = self._gm.linecolor arrow = vtk.vtkGlyphSource2D() arrow.SetGlyphTypeToArrow() @@ -81,7 +81,7 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): # Scale to vector magnitude: glyphFilter.SetScaleModeToScaleByVector() - glyphFilter.SetScaleFactor(2. * gm.scale) + glyphFilter.SetScaleFactor(2. * self._gm.scale) # These are some unfortunately named methods. It does *not* clamp the # scale range to [min, max], but rather remaps the range @@ -98,7 +98,7 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): r, g, b = cmap.index[lcolor] act.GetProperty().SetColor(r / 100., g / 100., b / 100.) - x1, x2, y1, y2 = vcs.utils.getworldcoordinates(gm, data1.getAxis(-1), + x1, x2, y1, y2 = vcs.utils.getworldcoordinates(self._gm, data1.getAxis(-1), data1.getAxis(-2)) act = vcs2vtk.doWrap(act, [x1, x2, y1, y2], self._dataWrapModulo) @@ -109,12 +109,12 @@ def plot(self, data1, data2, tmpl, gm, grid, transform): create_renderer=True) returned.update( - self._context().renderTemplate(tmpl, data1, gm, taxis, zaxis)) + self._context().renderTemplate(tmpl, data1, self._gm, taxis, zaxis)) if self._context().canvas._continents is None: continents = False if continents: - projection = vcs.elements["projection"][gm.projection] + projection = vcs.elements["projection"][self._gm.projection] self._context().plotContinents(x1, x2, y1, y2, projection, self._dataWrapModulo, tmpl) diff --git a/Packages/vcs/Lib/vector.py b/Packages/vcs/Lib/vector.py index 21b57c8243..acea94c047 100755 --- a/Packages/vcs/Lib/vector.py +++ b/Packages/vcs/Lib/vector.py @@ -243,6 +243,7 @@ class Gv(object): 'alignment', 'type', 'reference', + 'colormap', '_name', '_xaxisconvert', '_yaxisconvert', @@ -268,8 +269,11 @@ class Gv(object): '_alignment', '_type', '_reference', + '_colormap', ] + colormap = VCS_validation_functions.colormap + def _getname(self): return self._name @@ -563,6 +567,7 @@ def __init__(self, Gv_name, Gv_name_src='default'): self._reference = 1.e20 self._datawc_timeunits = "days since 2000" self._datawc_calendar = 135441 + self._colormap = None else: if isinstance(Gv_name_src, Gv): Gv_name_src = Gv_name_src.name @@ -577,7 +582,7 @@ def __init__(self, Gv_name, Gv_name_src='default'): 'datawc_y1', 'datawc_y2', 'datawc_x1', 'datawc_x2', 'xaxisconvert', 'yaxisconvert', 'line', 'linecolor', 'linewidth', - 'datawc_timeunits', 'datawc_calendar', + 'datawc_timeunits', 'datawc_calendar', 'colormap', 'scale', 'alignment', 'type', 'reference']: setattr(self, att, getattr(src, att)) # Ok now we need to stick in the elements @@ -695,13 +700,17 @@ def script(self, script_filename=None, mode=None): raise ValueError( 'Error - Mode can only be "w" for replace or "a" for append.') - # By default, save file in python script mode - scr_type = script_filename[ - len(script_filename) - - 4:len(script_filename)] + # By default, save file in json + scr_type = script_filename.split(".") + if len(scr_type) == 1 or len(scr_type[-1]) > 5: + scr_type = "json" + if script_filename != "initial.attributes": + script_filename += ".json" + else: + scr_type = scr_type[-1] if scr_type == '.scr': raise DeprecationWarning("scr script are no longer generated") - else: + elif scr_type == "py": mode = mode + '+' py_type = script_filename[ len(script_filename) - @@ -792,6 +801,16 @@ def script(self, script_filename=None, mode=None): fp.write("%s.alignment = '%s'\n" % (unique_name, self.alignment)) fp.write("%s.type = '%s'\n" % (unique_name, self.type)) fp.write("%s.reference = %s\n\n" % (unique_name, self.reference)) + fp.write( + "%s.colormap = '%s'\n\n" % + (unique_name, repr( + self.colormap))) + else: + # Json type + mode += "+" + f = open(script_filename, mode) + vcs.utils.dumpToJson(self, f) + f.close() ############################################################################### From 9313c1f5424a438fc89fdf8477f71fa57723c151 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 8 Sep 2015 16:33:09 -0700 Subject: [PATCH 5/9] Added test for cmap source --- testing/vcs/CMakeLists.txt | 12 +++++ testing/vcs/test_vcs_colormaps_source.py | 61 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 testing/vcs/test_vcs_colormaps_source.py diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index ac1550428a..13bea8db0f 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -280,6 +280,18 @@ cdat_add_test(vcs_test_taylor_2_quads # These test actually plot things need sample data if (CDAT_DOWNLOAD_SAMPLE_DATA) + FOREACH(gm boxfill isofill meshfill isoline vector) + FOREACH(src vcs canvas gm) + cdat_add_test(test_vcs_colormaps_source_${gm}_${src} + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_colormaps_source.py + -b ${BASELINE_DIR}/test_vcs_colormaps_source_${gm}_${src}.png + -g ${gm} + -s ${src} + ) + ENDFOREACH() + ENDFOREACH() + cdat_add_test(test_vcs_meshfill_regular_grid "${PYTHON_EXECUTABLE}" ${cdat_SOURCE_DIR}/testing/vcs/test_meshfill_regular_grid.py diff --git a/testing/vcs/test_vcs_colormaps_source.py b/testing/vcs/test_vcs_colormaps_source.py new file mode 100644 index 0000000000..1dcc7d8807 --- /dev/null +++ b/testing/vcs/test_vcs_colormaps_source.py @@ -0,0 +1,61 @@ +import vcs +import argparse +import cdms2 +import os +import sys + + +pth = os.path.join(os.path.dirname(__file__),"..") +sys.path.append(pth) +import checkimage + +parser = argparse.ArgumentParser() + +parser.add_argument("-g",dest="gm",default="boxfill",choices = ["boxfill","isofill","meshfill","isoline","vector","1d"]) +parser.add_argument("-s",dest="src",default="vcs",choices=["vcs","canvas","gm"]) +parser.add_argument("-b",dest="baseline") + + +args = parser.parse_args() + +x=vcs.init() +x.setantialiasing(0) +x.setbgoutputdimensions(1200, 1091, units="pixels") +x.drawlogooff() + +exec("gm = x.create%s()" % args.gm) + +if args.src == "vcs": + vcs._colorMap = "blue_to_grn" +elif args.src == "canvas": + ## Still setting vcs to make sure it is not used + vcs._colorMap = "blue_to_grn" + x.setcolormap("blue_to_grey") +else: + ## Still setting vcs and canvas to make sure it is not used + vcs._colorMap = "blue_to_grn" + x.setcolormap("blue_to_grey") + gm.colormap = "blue_to_orange" + +if args.gm != "meshfill": + f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc")) + if args.gm == "vector": + u = f("u") + v = f("v") + else: + s=f("clt",slice(0,1)) +else: + f=cdms2.open(os.path.join(vcs.sample_data,'sampleCurveGrid4.nc')) + s=f("sample") +if args.gm == "vector": + x.plot(u,v,gm,bg=True) +else: + x.plot(s,gm,bg=True) + +fnm = "test_vcs_colormaps_source_%s_%s.png" % (args.gm,args.src) +x.png(fnm) +baselineImage = args.baseline +ret = checkimage.check_result_image(fnm, baselineImage, + checkimage.defaultThreshold) + +sys.exit(ret) From f9474eba5b849fc37a48cb588d6744d57ade4fa0 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Mon, 14 Sep 2015 08:20:05 -0700 Subject: [PATCH 6/9] Renaming the function from getcolormap to getColorMap as suggested by @aashish24 --- Packages/vcs/Lib/vcsvtk/boxfillpipeline.py | 6 +++--- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 4 ++-- Packages/vcs/Lib/vcsvtk/isolinepipeline.py | 2 +- Packages/vcs/Lib/vcsvtk/meshfillpipeline.py | 4 ++-- Packages/vcs/Lib/vcsvtk/pipeline.py | 2 +- Packages/vcs/Lib/vcsvtk/pipeline2d.py | 2 +- Packages/vcs/Lib/vcsvtk/vectorpipeline.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py index 7aa3197570..e3a4d3738f 100644 --- a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py @@ -220,7 +220,7 @@ def _plotInternal(self): self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, self._contourLabels, - self.getcolormap())) + self.getColorMap())) if self._context().canvas._continents is None: self._useContinents = False @@ -264,7 +264,7 @@ def _plotInternalBoxfill(self): lut = vtk.vtkLookupTable() lut.SetNumberOfTableValues(numLevels) - _colorMap = self.getcolormap() + _colorMap = self.getColorMap() for i in range(numLevels): r, g, b = _colorMap.index[self._contourColors[i]] lut.SetTableValue(i, r / 100., g / 100., b / 100.) @@ -334,7 +334,7 @@ def _plotInternalCustomBoxfill(self): luts = [] geos = [] wholeDataMin, wholeDataMax = vcs.minmax(self._originalData1) - _colorMap = self.getcolormap() + _colorMap = self.getColorMap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 2553cd0a06..c05ccdf0b1 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -134,7 +134,7 @@ def _plotInternal(self): luts = [] cots = [] mappers = [] - _colorMap = self.getcolormap() + _colorMap = self.getColorMap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off @@ -264,7 +264,7 @@ def _plotInternal(self): self._resultDict.update( self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, legend, - self.getcolormap())) + self.getColorMap())) if self._context().canvas._continents is None: self._useContinents = False diff --git a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py index c9215ed404..536dccaf0a 100644 --- a/Packages/vcs/Lib/vcsvtk/isolinepipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isolinepipeline.py @@ -85,7 +85,7 @@ def _plotInternal(self): lut = vtk.vtkLookupTable() lut.SetNumberOfTableValues(len(self._contourColors)) - cmap = self.getcolormap() + cmap = self.getColorMap() for i, col in enumerate(self._contourColors): r, g, b = cmap.index[col] lut.SetTableValue(i, r / 100., g / 100., b / 100.) diff --git a/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py b/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py index 3c978f9dec..e9078457b6 100644 --- a/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/meshfillpipeline.py @@ -118,7 +118,7 @@ def _plotInternal(self): mappers = [] luts = [] geos = [] - _colorMap = self.getcolormap() + _colorMap = self.getColorMap() for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join # will happen if: next set of levels contnues where one left off @@ -289,7 +289,7 @@ def _plotInternal(self): self._resultDict.update( self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, legend, - self.getcolormap())) + self.getColorMap())) if self._context().canvas._continents is None: self._useContinents = False diff --git a/Packages/vcs/Lib/vcsvtk/pipeline.py b/Packages/vcs/Lib/vcsvtk/pipeline.py index 2bb8fb423d..d517dff775 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline.py @@ -25,7 +25,7 @@ def __init__(self, graphics_method, context_): def plot(self, data1, data2, template, graphics_method, grid, transform): raise NotImplementedError("Missing override.") - def getcolormap(self): + def getColorMap(self): _colorMap = self._gm.colormap if _colorMap is None: _colorMap = \ diff --git a/Packages/vcs/Lib/vcsvtk/pipeline2d.py b/Packages/vcs/Lib/vcsvtk/pipeline2d.py index 0a98e184ea..04d23c4b08 100644 --- a/Packages/vcs/Lib/vcsvtk/pipeline2d.py +++ b/Packages/vcs/Lib/vcsvtk/pipeline2d.py @@ -189,7 +189,7 @@ def _updateFromGenGridDict(self, genGridDict): def _createMaskedDataMapper(self): """Overrides baseclass implementation.""" color = getattr(self._gm, "missing", None) - _colorMap = self.getcolormap() + _colorMap = self.getColorMap() if color is not None: color = _colorMap.index[color] self._maskedDataMapper = vcs2vtk.putMaskOnVTKGrid( diff --git a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py index e7fc26cf98..46f710fc59 100644 --- a/Packages/vcs/Lib/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/vectorpipeline.py @@ -94,7 +94,7 @@ def plot(self, data1, data2, tmpl, grid, transform): act = vtk.vtkActor() act.SetMapper(mapper) - cmap = self.getcolormap() + cmap = self.getColorMap() r, g, b = cmap.index[lcolor] act.GetProperty().SetColor(r / 100., g / 100., b / 100.) From 469973a848a63e53a6642e4f769417c4c8da2ec8 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Mon, 14 Sep 2015 11:27:31 -0700 Subject: [PATCH 7/9] fixed typo when merging master conflicts --- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 047e5b13e4..8e453f2fbc 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -314,7 +314,7 @@ def _plotInternal(self): self._resultDict.update( self._context().renderColorBar(self._template, self._contourLevels, self._contourColors, legend, - self.getColorMap())) + self.getColorMap(), style=style, index=self._gm.fillareaindices, opacity=opacities)) From 77c1c61bece18948623e52f33b6b2c7b14c89eaa Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Mon, 14 Sep 2015 14:18:30 -0700 Subject: [PATCH 8/9] Another merge conflict tweak --- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 8e453f2fbc..554aa5190e 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -193,7 +193,7 @@ def _plotInternal(self): mappers.append(mapper) # Since pattern creation requires a single color, assuming the first - c = [val*255/100.0 for val in self._colorMap.index[tmpColors[i][0]]] + c = [val*255/100.0 for val in _colorMap.index[tmpColors[i][0]]] act = fillareautils.make_patterned_polydata(cot.GetOutput(), fillareastyle=style, fillareaindex=tmpIndices[i], From 616cf4d61589739c3403d4b4e3264ba9318928e3 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Mon, 14 Sep 2015 20:41:05 -0700 Subject: [PATCH 9/9] Update isofillpipeline.py fixed typo in comment, mainly trying to retrigger builds --- Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py index 554aa5190e..372a01f016 100644 --- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py +++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py @@ -162,7 +162,7 @@ def _plotInternal(self): self._patternActors = [] for i, l in enumerate(tmpLevels): # Ok here we are trying to group together levels can be, a join - # will happen if: next set of levels contnues where one left off + # will happen if: next set of levels continues where one left off # AND pattern is identical mapper = vtk.vtkPolyDataMapper() lut = vtk.vtkLookupTable()