Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

# 

# LSST Data Management System 

# Copyright 2008, 2009, 2010, 2015 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

 

class DisplayImpl: 

"""Back-end for display objects. 

 

Parameters 

---------- 

display 

The display object that we're providing the implementation for 

verbose : `bool` 

be chatty? 

""" 

def __init__(self, display, verbose=False): 

self.display = display 

self.verbose = verbose 

 

def __del__(self): 

self._close() 

 

def _close(self): 

"""Close the display, cleaning up any allocated resources 

""" 

if hasattr(self, "verbose") and self.verbose and hasattr(self, "display"): 

print("virtual[%s]._close()" % (self.frame)) 

 

def _buffer(self, enable=True): 

"""Enable or disable buffering of writes to the display 

 

Parameters 

---------- 

enable : `bool` 

`True` or `False`, as appropriate 

""" 

55 ↛ exitline 55 didn't return from function '_buffer', because the condition on line 55 was never false if self.verbose: 

print("virtual[%s]._buffer(%s)" % (self.frame, enable)) 

 

def _dot(self, symb, c, r, size, ctype, *args, **kwargs): 

"""Draw a symbol at (c, r) 

 

Parameters 

---------- 

symb 

The desired symbol. See `dot` for details 

c : `float` 

(x) column position 

r : `float` 

(y) row position 

size : `int` 

Size of symbol, in pixels 

ctype : `str` 

The desired color, either e.g. `lsst.afw.display.RED` or a color name known to X11 

*args 

Extra arguments to backend 

**kwargs 

Extra keyword arguments to backend 

""" 

if self.verbose: 

print("virtual[%s]._dot('%s', %.2f, %.2f, size=%g, ctype=%s, %s, %s)" % 

(self.frame, symb, c, r, size, ctype, args, kwargs)) 

 

def _drawLines(self, points, ctype): 

"""Draw line defined by the list points 

 

Parameters 

---------- 

points : `list` of `tuple` of `float` 

A list of 0-indexed positions [(x, y), (x, y), ...] 

ctype : `str` 

The desired color, either e.g. `lsst.afw.display.RED` or a color name known to X11 

""" 

92 ↛ exitline 92 didn't return from function '_drawLines', because the condition on line 92 was never false if self.verbose: 

print("virtual[%s]._drawLines(%s, ctype=%s)" % 

(self.frame, points, ctype)) 

 

def _erase(self): 

"""Erase all glyphs drawn on display 

""" 

if self.verbose: 

print("virtual[%s]._erase()" % (self.frame)) 

 

def _flush(self): 

"""Flush any I/O buffers 

""" 

105 ↛ exitline 105 didn't return from function '_flush', because the condition on line 105 was never false if self.verbose: 

print("virtual[%s]._flush()" % self.frame) 

 

def _setCallback(self, what, func): 

109 ↛ 110line 109 didn't jump to line 110, because the condition on line 109 was never true if self.verbose > 1: 

print("setCallback %s -> %s" % (what, func)) 

 

def _getEvent(self): 

"""Return an event generated by a keypress or mouse click 

""" 

from .interface import Event 

ev = Event("q") 

 

118 ↛ 121line 118 didn't jump to line 121, because the condition on line 118 was never false if self.verbose: 

print("virtual[%s]._getEvent() -> %s" % (self.frame, ev)) 

 

return ev 

 

def _getMaskTransparency(self): 

"""Return the mask transparency for a display 

""" 

if self.verbose: 

print("virtual[%s]._getMaskTransparency()" % self.frame) 

 

def _mtv(self, image, wcs=None, mask=None, title=""): 

"""Display an image and maybe a mask overlay on a display 

 

Parameters 

---------- 

image : `lsst.afw.image.Image` 

`~lsst.afw.image.Image` to display 

mask : `lsst.afw.image.Mask` 

`~lsst.afw.image.Mask` to display 

wcs : `lsst.afw.geom.SkyWcs` 

A Wcs to associate with data 

title : `str` 

Name to display with the data 

""" 

if self.verbose: 

print("virtual[%s]._mtv(image=%s, mask=%s, wcs=%s, title=\"%s\")" % 

(self.frame, "Image" if image else None, 

"Mask" if mask else None, "Wcs" if wcs else None, title)) 

 

def _setImageColormap(self, cmap): 

"""Set the desired colormap 

 

Parameters 

---------- 

cmap : `str` 

the name of a colormap (e.g. "gray") or a backend-specific object 

""" 

if self.verbose: 

print("virtual[%s]._setImageColormap(cmap=\"%s\")" % (self.frame, cmap)) 

 

def _setMaskTransparency(self, transparency, maskplane): 

"""Set the transparency of a maskplane 

 

Parameters 

---------- 

transparency : `float` 

The desired transparency, in the range [0, 100] 

maskplane 

The maskplane to set (None: all) 

""" 

if self.verbose: 

print("virtual[%s]._setMaskTransparency(%g, maskplane=\"%s\")" % 

(self.frame, transparency, maskplane)) 

 

def _scale(self, algorithm, min, max, *args, unit=None, **kwargs): 

"""Set the scaling from DN to displayed pixels 

 

Parameters 

---------- 

algorithm 

Scaling algorithm (e.g. linear) 

min 

The minimum value of the stretch (or "zscale" or "minmax") 

max 

The maximum value of the stretch 

unit 

Units for min and max (e.g. Percent, Absolute, Sigma) 

*args 

Optional arguments to the backend 

**kwargs 

Optional keyword arguments to the backend 

""" 

191 ↛ exitline 191 didn't return from function '_scale', because the condition on line 191 was never false if self.verbose: 

print("virtual[%s]._scale(%s, %s, %s, %s, %s, %s)" % (self.frame, algorithm, 

min, max, unit, args, kwargs)) 

 

def _show(self): 

"""Show the requested display 

""" 

198 ↛ exitline 198 didn't return from function '_show', because the condition on line 198 was never false if self.verbose: 

print("virtual[%s]._show()" % self.frame) 

 

def _pan(self, r, c): 

"""Pan to a row and column 

 

Parameters 

---------- 

c : `float` 

Desired column (x) position 

r : `float` 

Desired row (y) position 

""" 

if self.verbose: 

print("virtual[%s]._pan(%.2f, %.2f)" % (self.frame, r, c)) 

 

def _zoom(self, zoomfac): 

"""Set the zoom 

 

Parameters 

---------- 

zoomfac : `float` 

Zoom factor to use 

""" 

if self.verbose: 

print("virtual[%s]._zoom(%g)" % (self.frame, zoomfac))