Skip to content

Commit 16ecbbc

Browse files
committed
Merge branch 'master' into vector_graphics_text_as_object
2 parents f53c74a + 69539a7 commit 16ecbbc

18 files changed

+207
-110
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
set(CRYPTOGRAPHY_MAJOR_SRC 1)
2-
set(CRYPTOGRAPHY_MINOR_SRC 2)
2+
set(CRYPTOGRAPHY_MINOR_SRC 3)
33
set(CRYPTOGRAPHY_PATCH_SRC 2)
44

55
set(CRYPTOGRAPHY_VERSION ${CRYPTOGRAPHY_MAJOR_SRC}.${CRYPTOGRAPHY_MINOR_SRC}.${CRYPTOGRAPHY_PATCH_SRC})
66
set(CRYPTOGRAPHY_GZ cryptography-${CRYPTOGRAPHY_VERSION}.tar.gz)
77
set(CRYPTOGRAPHY_SOURCE ${LLNL_URL}/${CRYPTOGRAPHY_GZ})
8-
set(CRYPTOGRAPHY_MD5 a8daf092d0558dac6700d7be93b555e5)
8+
set(CRYPTOGRAPHY_MD5 0359190f291824dc8ad9e6d477a607b2)
99

1010
add_cdat_package_dependent(CRYPTOGRAPHY "" "" OFF "CDAT_BUILD_LEAN" OFF)

Packages/testing/regression.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ def init(*args, **kwargs):
2020
testingDir = os.path.join(os.path.dirname(__file__), "..")
2121
sys.path.append(testingDir)
2222

23-
if ((('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs)) and
24-
('geometry' not in kwargs)):
23+
if ((('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs))):
2524
vcsinst = vcs.init(*args, **dict(kwargs, bg=1))
26-
vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
25+
if ('geometry' not in kwargs):
26+
vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
27+
else:
28+
xy = kwargs['geometry']
29+
vcsinst.setbgoutputdimensions(xy[0], xy[1], units="pixels")
2730
else:
2831
vcsinst = vcs.init(*args, **dict(kwargs, bg=0))
2932

Packages/vcs/vcs/Canvas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
import vcsaddons # noqa
7272
import vcs.manageElements # noqa
7373
import configurator # noqa
74-
from projection import round_projections # noqa
74+
from projection import no_deformation_projections # noqa
7575

7676
# Python < 3 DeprecationWarning ignored by default
7777
warnings.simplefilter('default')
@@ -3497,7 +3497,7 @@ def set_convert_labels(copy_mthd, test=0):
34973497
if hasattr(gm, "priority") and gm.priority == 0:
34983498
return
34993499
p = self.getprojection(gm.projection)
3500-
if p.type in round_projections and (
3500+
if p.type in no_deformation_projections and (
35013501
doratio == "0" or doratio[:4] == "auto"):
35023502
doratio = "1t"
35033503
for keyarg in keyargs.keys():
@@ -3554,7 +3554,7 @@ def set_convert_labels(copy_mthd, test=0):
35543554
t.data.y2 = p.viewport[3]
35553555

35563556
proj = self.getprojection(p.projection)
3557-
if proj.type in round_projections and (
3557+
if proj.type in no_deformation_projections and (
35583558
doratio == "0" or doratio[:4] == "auto"):
35593559
doratio = "1t"
35603560

@@ -3610,7 +3610,7 @@ def set_convert_labels(copy_mthd, test=0):
36103610
tp = "textcombined"
36113611
gm = vcs.elements[tp][arglist[4]]
36123612
p = self.getprojection(gm.projection)
3613-
if p.type in round_projections:
3613+
if p.type in no_deformation_projections:
36143614
doratio = "1t"
36153615
if p.type == 'linear':
36163616
if gm.g_name == 'Gfm':

Packages/vcs/vcs/VTKPlots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs):
597597

598598
vtk_backend_grid = kargs.get("vtk_backend_grid", None)
599599
vtk_backend_geo = kargs.get("vtk_backend_geo", None)
600+
bounds = vtk_backend_grid.GetBounds() if vtk_backend_grid else None
600601

601602
pipeline = vcsvtk.createPipeline(gm, self)
602603
if pipeline is not None:
@@ -626,7 +627,7 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs):
626627
ren,
627628
to=to,
628629
tt=tt,
629-
cmap=self.canvas.colormap)
630+
cmap=self.canvas.colormap, geoBounds=bounds, geo=vtk_backend_geo)
630631
self.setLayer(ren, tt.priority)
631632
self.text_renderers[tt_key] = ren
632633
elif gtype == "line":
@@ -635,7 +636,6 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs):
635636
cmap=self.canvas.colormap)
636637
returned["vtk_backend_line_actors"] = actors
637638
create_renderer = True
638-
bounds = vtk_backend_grid.GetBounds() if vtk_backend_grid else None
639639
for act, geo in actors:
640640
ren = self.fitToViewport(
641641
act,

Packages/vcs/vcs/isoline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class Gi(object):
310310
iso.linewidths=([1,2,3,4,5,6,7,8]) # Will set the isoline to a specific
311311
# width size
312312
iso.linewidths=None # Turns off the line width size
313+
If the number of line styles, colors or widths are less than the number of levels
314+
we extend the attribute list using the last attribute value in the attribute list.
313315
314316
There are three ways to specify the text or font number:
315317
iso.text=(1,2,3,4,5,6,7,8,9) # Font numbers are between 1 and 9

Packages/vcs/vcs/projection.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
import vcs
1717
import copy
1818

19-
# projection that seems to be doing a circle
20-
# We will probably to add some more in it as we find more that fit this
21-
round_projections = ['polar (non gctp)', 'stereographic',
22-
'orthographic', "ortho", ]
19+
# used to decide if we show longitude labels for round projections or
20+
# latitude labels for elliptical projections
21+
round_projections = ['polar (non gctp)', 'stereographic']
22+
elliptical_projections = ["robinson", "mollweide", 'orthographic', "ortho"]
23+
# projections in this list are not deformed based on the window size
24+
no_deformation_projections = ['polar (non gctp)', 'stereographic',
25+
'orthographic', "ortho", ]
2326

2427
no_over_proj4_parameter_projections = round_projections+["aeqd", "lambert conformal c"]
25-
elliptical_projections = ["robinson", "mollweide"]
2628

2729

2830
def process_src(nm, code):

Packages/vcs/vcs/vcs2vtk.py

Lines changed: 89 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import numpy
55
import json
66
import os
7+
import math
78
import meshfill
89
from vtk.util import numpy_support as VN
910
import cdms2
1011
import warnings
1112
from projection import round_projections, no_over_proj4_parameter_projections
1213
from vcsvtk import fillareautils
14+
import sys
1315
import numbers
1416

1517
f = open(os.path.join(vcs.prefix, "share", "vcs", "wmo_symbols.json"))
@@ -163,23 +165,6 @@ def putMaskOnVTKGrid(data, grid, actorColor=None, cellData=True, deep=True):
163165
return mapper
164166

165167

166-
def handleProjectionEdgeCases(projection, data):
167-
# For mercator projection, latitude values of -90 or 90
168-
# transformation result in infinity values. We chose -85, 85
169-
# as that's the typical limit used by the community.
170-
ptype = projDict.get(projection._type, projection.type)
171-
if (ptype.lower() == "merc"):
172-
lat = data.getLatitude()
173-
if isinstance(lat, cdms2.axis.TransientAxis):
174-
lat = lat[:]
175-
# Reverse the latitudes incase the starting latitude is greater
176-
# than the ending one
177-
if lat[-1] < lat[0]:
178-
lat = lat[::-1]
179-
data = data(latitude=(max(-85, lat.min()), min(85, lat.max())))
180-
return data
181-
182-
183168
def getBoundsList(axis, hasCellData, dualGrid):
184169
'''
185170
Returns the bounds list for 'axis'. If axis has n elements the
@@ -220,6 +205,34 @@ def getBoundsList(axis, hasCellData, dualGrid):
220205
return None
221206

222207

208+
def setInfToValid(geoPoints, ghost):
209+
'''
210+
Set infinity points to a point that already exists in the list.
211+
If a ghost array is passed, we also hide infinity points.
212+
We return true if any points are infinity
213+
'''
214+
anyInfinity = False
215+
validPoint = [0, 0, 0]
216+
for i in range(geoPoints.GetNumberOfPoints()):
217+
point = geoPoints.GetPoint(i)
218+
if (not math.isinf(point[0]) and not math.isinf(point[1])):
219+
validPoint[0] = point[0]
220+
validPoint[1] = point[1]
221+
break
222+
for i in range(geoPoints.GetNumberOfPoints()):
223+
point = geoPoints.GetPoint(i)
224+
if (math.isinf(point[0]) or math.isinf(point[1])):
225+
anyInfinity = True
226+
newPoint = list(point)
227+
if (math.isinf(point[0])):
228+
newPoint[0] = validPoint[0]
229+
if (math.isinf(point[1])):
230+
newPoint[1] = validPoint[1]
231+
geoPoints.SetPoint(i, newPoint)
232+
ghost.SetValue(i, vtk.vtkDataSetAttributes.HIDDENPOINT)
233+
return anyInfinity
234+
235+
223236
def genGrid(data1, data2, gm, deep=True, grid=None, geo=None, genVectors=False,
224237
dualGrid=False):
225238
continents = False
@@ -230,10 +243,6 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None, genVectors=False,
230243
xm, xM, ym, yM = None, None, None, None
231244
projection = vcs.elements["projection"][gm.projection]
232245

233-
data1 = handleProjectionEdgeCases(projection, data1)
234-
if data2 is not None:
235-
data2 = handleProjectionEdgeCases(projection, data2)
236-
237246
try: # First try to see if we can get a mesh out of this
238247
g = data1.getGrid()
239248
# Ok need unstructured grid
@@ -444,6 +453,25 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None, genVectors=False,
444453
data1.getAxis(-2))
445454
geo, geopts = project(pts, projection, getWrappedBounds(
446455
wc, [xm, xM, ym, yM], wrap))
456+
# proj4 returns inf for points that are not visible. Set those to a valid point
457+
# and hide them.
458+
ghost = vg.AllocatePointGhostArray()
459+
if (setInfToValid(geopts, ghost)):
460+
# if there are hidden points, we recompute the bounds
461+
xm = ym = sys.float_info.max
462+
xM = yM = - sys.float_info.max
463+
for i in range(pts.GetNumberOfPoints()):
464+
if (ghost.GetValue(i) & vtk.vtkDataSetAttributes.HIDDENPOINT == 0):
465+
# point not hidden
466+
p = pts.GetPoint(i)
467+
if (p[0] < xm):
468+
xm = p[0]
469+
if (p[0] > xM):
470+
xM = p[0]
471+
if (p[1] < ym):
472+
ym = p[1]
473+
if (p[1] > yM):
474+
yM = p[1]
447475
# Sets the vertics into the grid
448476
vg.SetPoints(geopts)
449477
else:
@@ -557,24 +585,42 @@ def apply_proj_parameters(pd, projection, x1, x2, y1, y2):
557585
else:
558586
pd.SetOptionalParameter("over", "false")
559587
setProjectionParameters(pd, projection)
560-
if (hasattr(projection, 'centralmeridian') and
561-
numpy.allclose(projection.centralmeridian, 1e+20)):
562-
pd.SetCentralMeridian(float(x1 + x2) / 2.0)
563-
if (hasattr(projection, 'centerlongitude') and
564-
numpy.allclose(projection.centerlongitude, 1e+20)):
565-
pd.SetOptionalParameter("lon_0", str(float(x1 + x2) / 2.0))
566-
if (hasattr(projection, 'originlatitude') and
567-
numpy.allclose(projection.originlatitude, 1e+20)):
568-
pd.SetOptionalParameter("lat_0", str(float(y1 + y2) / 2.0))
569-
if (hasattr(projection, 'centerlatitude') and
570-
numpy.allclose(projection.centerlatitude, 1e+20)):
571-
pd.SetOptionalParameter("lat_0", str(float(y1 + y2) / 2.0))
572-
if (hasattr(projection, 'standardparallel1') and
573-
numpy.allclose(projection.standardparallel1, 1.e20)):
574-
pd.SetOptionalParameter('lat_1', str(min(y1, y2)))
575-
if (hasattr(projection, 'standardparallel2') and
576-
numpy.allclose(projection.standardparallel2, 1.e20)):
577-
pd.SetOptionalParameter('lat_2', str(max(y1, y2)))
588+
if (hasattr(projection, 'centralmeridian')):
589+
if (numpy.allclose(projection.centralmeridian, 1e+20)):
590+
centralmeridian = float(x1 + x2) / 2.0
591+
else:
592+
centralmeridian = projection.centralmeridian
593+
pd.SetCentralMeridian(centralmeridian)
594+
if (hasattr(projection, 'centerlongitude')):
595+
if (numpy.allclose(projection.centerlongitude, 1e+20)):
596+
centerlongitude = float(x1 + x2) / 2.0
597+
else:
598+
centerlongitude = projection.centerlongitude
599+
pd.SetOptionalParameter("lon_0", str(centerlongitude))
600+
if (hasattr(projection, 'originlatitude')):
601+
if (numpy.allclose(projection.originlatitude, 1e+20)):
602+
originlatitude = float(y1 + y2) / 2.0
603+
else:
604+
originlatitude = projection.originlatitude
605+
pd.SetOptionalParameter("lat_0", str(originlatitude))
606+
if (hasattr(projection, 'centerlatitude')):
607+
if (numpy.allclose(projection.centerlatitude, 1e+20)):
608+
centerlatitude = float(y1 + y2) / 2.0
609+
else:
610+
centerlatitude = projection.centerlatitude
611+
pd.SetOptionalParameter("lat_0", str(centerlatitude))
612+
if (hasattr(projection, 'standardparallel1')):
613+
if (numpy.allclose(projection.standardparallel1, 1.e20)):
614+
standardparallel1 = min(y1, y2)
615+
else:
616+
standardparallel1 = projection.standardparallel1
617+
pd.SetOptionalParameter('lat_1', str(standardparallel1))
618+
if (hasattr(projection, 'standardparallel2')):
619+
if (numpy.allclose(projection.standardparallel2, 1.e20)):
620+
standardparallel2 = max(y1, y2)
621+
else:
622+
standardparallel2 = projection.standardparallel2
623+
pd.SetOptionalParameter('lat_2', str(standardparallel2))
578624

579625

580626
def projectArray(w, projection, wc, geo=None):
@@ -1072,7 +1118,7 @@ def prepTextProperty(p, winSize, to="default", tt="default", cmap=None,
10721118

10731119

10741120
def genTextActor(renderer, string=None, x=None, y=None,
1075-
to='default', tt='default', cmap=None):
1121+
to='default', tt='default', cmap=None, geoBounds=None, geo=None):
10761122
if isinstance(to, str):
10771123
to = vcs.elements["textorientation"][to]
10781124
if isinstance(tt, str):
@@ -1096,21 +1142,8 @@ def genTextActor(renderer, string=None, x=None, y=None,
10961142
sz = renderer.GetRenderWindow().GetSize()
10971143
actors = []
10981144
pts = vtk.vtkPoints()
1099-
geo = None
11001145
if vcs.elements["projection"][tt.projection].type != "linear":
1101-
# Need to figure out new WC
1102-
Npts = 20
1103-
for i in range(Npts + 1):
1104-
X = tt.worldcoordinate[
1105-
0] + float(i) / Npts * (tt.worldcoordinate[1] -
1106-
tt.worldcoordinate[0])
1107-
for j in range(Npts + 1):
1108-
Y = tt.worldcoordinate[
1109-
2] + float(j) / Npts * (tt.worldcoordinate[3] -
1110-
tt.worldcoordinate[2])
1111-
pts.InsertNextPoint(X, Y, 0.)
1112-
geo, pts = project(pts, tt.projection, tt.worldcoordinate, geo=None)
1113-
wc = pts.GetBounds()[:4]
1146+
wc = geoBounds[:4]
11141147
# renderer.SetViewport(tt.viewport[0],tt.viewport[2],tt.viewport[1],tt.viewport[3])
11151148
renderer.SetWorldPoint(wc)
11161149

@@ -1120,8 +1153,8 @@ def genTextActor(renderer, string=None, x=None, y=None,
11201153
prepTextProperty(p, sz, to, tt, cmap)
11211154
pts = vtk.vtkPoints()
11221155
pts.InsertNextPoint(x[i], y[i], 0.)
1123-
if geo is not None:
1124-
geo, pts = project(pts, tt.projection, tt.worldcoordinate, geo=geo)
1156+
if vcs.elements["projection"][tt.projection].type != "linear":
1157+
_, pts = project(pts, tt.projection, tt.worldcoordinate, geo=geo)
11251158
X, Y, tz = pts.GetPoint(0)
11261159
X, Y = world2Renderer(renderer, X, Y, tt.viewport, wc)
11271160
else:

Packages/vcs/vcs/vcsvtk/boxfillpipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def _plotInternal(self):
152152
z = None
153153
kwargs = {"vtk_backend_grid": self._vtkDataSet,
154154
"dataset_bounds": self._vtkDataSetBounds,
155-
"plotting_dataset_bounds": plotting_dataset_bounds}
155+
"plotting_dataset_bounds": plotting_dataset_bounds,
156+
"vtk_backend_geo": self._vtkGeoTransform}
156157
if ("ratio_autot_viewport" in self._resultDict):
157158
kwargs["ratio_autot_viewport"] = vp
158159
self._resultDict.update(self._context().renderTemplate(

Packages/vcs/vcs/vcsvtk/isofillpipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def _plotInternal(self):
176176
z = None
177177
kwargs = {"vtk_backend_grid": self._vtkDataSet,
178178
"dataset_bounds": self._vtkDataSetBounds,
179-
"plotting_dataset_bounds": plotting_dataset_bounds}
179+
"plotting_dataset_bounds": plotting_dataset_bounds,
180+
"vtk_backend_geo": self._vtkGeoTransform}
180181
if ("ratio_autot_viewport" in self._resultDict):
181182
kwargs["ratio_autot_viewport"] = vp
182183
self._resultDict.update(self._context().renderTemplate(

0 commit comments

Comments
 (0)