Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1339 labels distance #1485

Merged
merged 3 commits into from Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Packages/vcs/Lib/Canvas.py
Expand Up @@ -826,7 +826,6 @@ def _reconstruct_tv(self, arglist, keyargs):
if yrev == 1:
tv = tv[..., ::-1, :].clone()


# -- This s no longer needed since we are making a copy of the data.
# We now apply the axes changes below in __plot. Dean and Charles keep
# an eye opened for the errors concerning datawc in the VCS module.
Expand Down Expand Up @@ -2804,6 +2803,7 @@ def __plot(self, arglist, keyargs):
'xaxisconvert',
'yaxisconvert',
'label',
'labelskipdistance',
'line',
'linewidth',
'linecolors',
Expand Down
19 changes: 18 additions & 1 deletion Packages/vcs/Lib/isoline.py
Expand Up @@ -194,6 +194,7 @@ class Gi(object):
Options:::
%s
label :: (str) ('n') turn on/off labels on isolines
labelskipdistance :: (float) (0.0) minimum distance between isoline labels
%s
%s
level :: ([float,...]) ([[0.0, 1.0000000200408773e+20]]) isocountours to display
Expand Down Expand Up @@ -327,6 +328,7 @@ class Gi(object):
'levels',
'level',
'label',
'labelskipdistance',
'linecolors',
'line',
'linewidths',
Expand Down Expand Up @@ -356,6 +358,7 @@ class Gi(object):
'_yaxisconvert',
'_level',
'_label',
'_labelskipdistance',
'_linecolors',
'_line',
'_linewidths',
Expand Down Expand Up @@ -651,6 +654,17 @@ def _setlabel(self, value):
self._label = value
label = property(_getlabel, _setlabel)

def _getlabelskipdistance(self):
return self._labelskipdistance

def _setlabelskipdistance(self, value):
value = VCS_validation_functions.checkIntFloat(
self,
'labelskipdistance',
value)
self._labelskipdistance = value
labelskipdistance = property(_getlabelskipdistance, _setlabelskipdistance)

def _getspacing(self):
return self._spacing

Expand Down Expand Up @@ -747,6 +761,7 @@ def __init__(self, Gi_name, Gi_name_src='default'):
self._angle = [35.]
self._spacing = [1.]
self._label = 'n'
self._labelskipdistance = 0.0
self._colormap = None
else:
if isinstance(Gi_name_src, Gi):
Expand All @@ -760,7 +775,7 @@ def __init__(self, Gi_name, Gi_name_src='default'):
'yticlabels1', 'yticlabels2', 'ymtics1', 'ymtics2', 'datawc_y1', 'datawc_y2', 'datawc_x1',
'datawc_x2', 'xaxisconvert', 'yaxisconvert', 'level', 'datawc_timeunits',
'datawc_calendar', "line", "linecolors", "linewidths", "text", "textcolors",
"clockwise", "scale", "angle", "spacing"]:
"clockwise", "scale", "angle", "spacing", "labelskipdistance"]:
setattr(self, att, getattr(src, att))
vcs.elements["isoline"][Gi_name] = self

Expand Down Expand Up @@ -825,6 +840,7 @@ def list(self):
print "xaxisconvert = ", self.xaxisconvert
print "yaxisconvert = ", self.yaxisconvert
print "label = ", self.label
print "labelskipdistance = ", self.labelskipdistance
print "line = ", self.line
print "linecolors = ", self.linecolors
print "linewidths = ", self.linewidths
Expand Down Expand Up @@ -972,6 +988,7 @@ 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.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))
Expand Down
1 change: 1 addition & 0 deletions Packages/vcs/Lib/vcsvtk/isolinepipeline.py
Expand Up @@ -154,6 +154,7 @@ def _plotInternal(self):
mapper.SetTextProperties(tprops)
mapper.SetTextPropertyMapping(tpropMap)
mapper.SetLabelVisibility(1)
mapper.SetSkipDistance(self._gm.labelskipdistance)

pdMapper = mapper.GetPolyDataMapper()

Expand Down
5 changes: 5 additions & 0 deletions testing/vcs/CMakeLists.txt
Expand Up @@ -532,6 +532,11 @@ cdat_add_test(vcs_test_taylor_2_quads
"${cdat_SOURCE_DIR}/testing/vcs/test_isoline_labels.py"
"${BASELINE_DIR}/test_isoline_labels.png"
)
cdat_add_test(vcs_test_isoline_labelskipdistance
"${PYTHON_EXECUTABLE}"
"${cdat_SOURCE_DIR}/testing/vcs/test_isoline_labelskipdistance.py"
"${BASELINE_DIR}/test_isoline_labelskipdistance.png"
)
cdat_add_test(vcs_test_isofill_isoline_labels
"${PYTHON_EXECUTABLE}"
"${cdat_SOURCE_DIR}/testing/vcs/test_isofill_isoline_labels.py"
Expand Down
46 changes: 46 additions & 0 deletions testing/vcs/test_isoline_labelskipdistance.py
@@ -0,0 +1,46 @@
import cdms2
import os
import sys
import vcs

baselineImage = sys.argv[1]

pth = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(pth)
import checkimage

dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
data = dataset("clt")

canvas = vcs.init()
canvas.setantialiasing(0)
canvas.setbgoutputdimensions(1200, 1091, units="pixels")
canvas.drawlogooff()

isoline = canvas.createisoline()
isoline.label = "y"
isoline.labelskipdistance = 15.0
texts = []
colors = []
for i in range(10):
text = canvas.createtext()
text.color = 20 * i
text.height = 12
colors.append(255 - text.color)
if i % 2 == 0:
texts.append(text.name)
else:
texts.append(text)
isoline.text = texts
isoline.linecolors = colors

# Next plot the isolines with labels
canvas.plot(data, isoline, bg=1)

testImage = os.path.abspath("test_isoline_labelskipdistance.png")
canvas.png(testImage)

ret = checkimage.check_result_image(testImage, baselineImage,
checkimage.defaultThreshold)

sys.exit(ret)