Skip to content

Commit fb84a97

Browse files
danlipsadoutriaux1
authored andcommitted
BUG #190: When setting the initial size, we set bgX and bgY as well. (#191)
* BUG #190: When setting the initial size, we set bgX and bgY as well. * make sure we get latest vtk-cdat * autoindent ruined indentation * Fix flake8 and default size for bg test. * Default window size is based on the screen size.
1 parent 8293dd0 commit fb84a97

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ before_install:
1111
- conda config --set always_yes yes --set changeps1 no
1212
- conda update -y -q conda
1313
script:
14-
- conda install -c uvcdat/label/nightly -c conda-forge -c uvcdat cdutil genutil dv3d-nox "mesalib>17" nose image-compare flake8 matplotlib
14+
- conda install -c uvcdat/label/nightly -c conda-forge -c uvcdat "vtk-cdat-nox >7.1.0.2.8" cdutil genutil dv3d-nox "mesalib>17" nose image-compare flake8 matplotlib
1515
- export UVCDAT_ANONYMOUS_LOG=False
1616
- echo $TRAVIS_BRANCH
1717
- export TRAVIS_PR_BRANCH=$TRAVIS_BRANCH

tests/test_vcs_background_mode_rotate.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,47 @@
33
import numpy
44

55
class TestVCSBackgroundModeRotate(basevcstest.VCSBaseTest):
6-
def testBackgroundModeRotate(self):
6+
def testBackgroundModeRotate(self):
77

8-
data = numpy.sin(numpy.arange(100))
9-
data = numpy.reshape(data, (10, 10))
8+
data = numpy.sin(numpy.arange(100))
9+
data = numpy.reshape(data, (10, 10))
1010

11-
self.x = vcs.init()
12-
self.x.plot(data, bg=self.bg)
13-
self.assertEqual(self.x.orientation(), "landscape", "Default canvas orientation failed")
14-
c = self.x.canvasinfo()
15-
self.assertEqual(c['width'], 814, "Default canvas width failed")
16-
self.assertEqual(c['height'], 606, "Default canvas height failed")
11+
self.x = vcs.init()
12+
self.x.plot(data, bg=self.bg)
13+
self.assertEqual(self.x.orientation(), "landscape", "Default canvas orientation failed")
14+
c = self.x.canvasinfo()
15+
# default window size is based on the screen size
16+
width = c['width']
17+
height = c['height']
1718

18-
self.x.clear()
19-
self.x.portrait()
20-
self.x.plot(data, bg=self.bg)
21-
self.assertEqual( self.x.orientation(), "portrait", "Portrait canvas orientation failed")
22-
c = self.x.canvasinfo()
23-
self.assertEqual( c['width'], 606, "Portrait canvas width failed")
24-
self.assertEqual( c['height'], 814, "Portrait canvas height failed")
19+
self.x.clear()
20+
self.x.portrait()
21+
self.x.plot(data, bg=self.bg)
22+
self.assertEqual( self.x.orientation(), "portrait", "Portrait canvas orientation failed")
23+
c = self.x.canvasinfo()
24+
self.assertEqual( c['width'], height, "Portrait canvas width failed")
25+
self.assertEqual( c['height'], width, "Portrait canvas height failed")
2526

26-
self.x.clear()
27-
self.x.landscape()
28-
self.x.plot(data, bg=self.bg)
29-
self.assertEqual( self.x.orientation(), "landscape", "Landscape canvas orientation failed")
30-
c = self.x.canvasinfo()
31-
self.assertEqual( c['width'], 814, "Landscape canvas width failed")
32-
self.assertEqual( c['height'], 606, "Landscape canvas height failed")
27+
self.x.clear()
28+
self.x.landscape()
29+
self.x.plot(data, bg=self.bg)
30+
self.assertEqual( self.x.orientation(), "landscape", "Landscape canvas orientation failed")
31+
c = self.x.canvasinfo()
32+
self.assertEqual( c['width'], width, "Landscape canvas width failed")
33+
self.assertEqual( c['height'], height, "Landscape canvas height failed")
3334

34-
self.x.clear()
35-
self.x.landscape()
36-
self.x.plot(data, bg=self.bg)
37-
self.assertEqual( self.x.orientation(), "landscape", "Landscape canvas orientation failed")
38-
c = self.x.canvasinfo()
39-
self.assertEqual( c['width'], 814, "Landscape canvas width failed")
40-
self.assertEqual( c['height'], 606, "Landscape canvas height failed")
35+
self.x.clear()
36+
self.x.landscape()
37+
self.x.plot(data, bg=self.bg)
38+
self.assertEqual( self.x.orientation(), "landscape", "Landscape canvas orientation failed")
39+
c = self.x.canvasinfo()
40+
self.assertEqual( c['width'], width, "Landscape canvas width failed")
41+
self.assertEqual( c['height'], height, "Landscape canvas height failed")
4142

42-
self.x.clear()
43-
self.x.portrait()
44-
self.x.plot(data, bg=self.bg)
45-
self.assertEqual( self.x.orientation(), "portrait", "Portrait canvas orientation failed")
46-
c = self.x.canvasinfo()
47-
self.assertEqual( c['width'], 606, "Portrait canvas width failed")
48-
self.assertEqual( c['height'], 814, "Portrait canvas height failed")
43+
self.x.clear()
44+
self.x.portrait()
45+
self.x.plot(data, bg=self.bg)
46+
self.assertEqual( self.x.orientation(), "portrait", "Portrait canvas orientation failed")
47+
c = self.x.canvasinfo()
48+
self.assertEqual( c['width'], height, "Portrait canvas width failed")
49+
self.assertEqual( c['height'], width, "Portrait canvas height failed")

tests/test_vcs_init_size_keyword.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
class TestVCSInit(unittest.TestCase):
66
def testInitOpenSize(self):
77

8-
x=vcs.init()
9-
print x.size
10-
x.open()
11-
i = x.canvasinfo()
12-
r = float(i["width"])/i["height"]
13-
print "r is:",r,i
14-
assert(numpy.allclose(r,1.29438202247,.001))
15-
168
x=vcs.init(size=4)
179
x.open()
1810
i = x.canvasinfo()

vcs/VTKPlots.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
import vcsvtk
1515

1616

17+
def _makeEven(val):
18+
if (val & 0x1):
19+
val -= 1
20+
return val
21+
22+
1723
class VCSInteractorStyle(vtk.vtkInteractorStyleUser):
1824

1925
def __init__(self, parent):
@@ -524,7 +530,12 @@ def initialSize(self, width=None, height=None):
524530
# Respect user chosen aspect ratio
525531
bgY = int(bgX / self.canvas.size)
526532
# Sets renWin dimensions
533+
# make the dimensions even for Macs
534+
bgX = _makeEven(bgX)
535+
bgY = _makeEven(bgY)
527536
self.renWin.SetSize(bgX, bgY)
537+
self.canvas.bgX = bgX
538+
self.canvas.bgY = bgY
528539
self._lastSize = (bgX, bgY)
529540

530541
def open(self, width=None, height=None, **kargs):

0 commit comments

Comments
 (0)